mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Updated interactive examples in the "Examples" session to reflect the
fact that compiler.ast.Function now takes a "decorators" argument.
This commit is contained in:
parent
87de0ca741
commit
a7f62814cf
1 changed files with 10 additions and 7 deletions
|
@ -269,21 +269,24 @@ the class names from the \module{compiler.ast} module.
|
||||||
>>> mod = compiler.parseFile("/tmp/doublelib.py")
|
>>> mod = compiler.parseFile("/tmp/doublelib.py")
|
||||||
>>> mod
|
>>> mod
|
||||||
Module('This is an example module.\n\nThis is the docstring.\n',
|
Module('This is an example module.\n\nThis is the docstring.\n',
|
||||||
Stmt([Function('double', ['x'], [], 0, 'Return twice the argument',
|
Stmt([Function(None, 'double', ['x'], [], 0,
|
||||||
Stmt([Return(Mul((Name('x'), Const(2))))]))]))
|
'Return twice the argument',
|
||||||
|
Stmt([Return(Mul((Name('x'), Const(2))))]))]))
|
||||||
>>> from compiler.ast import *
|
>>> from compiler.ast import *
|
||||||
>>> Module('This is an example module.\n\nThis is the docstring.\n',
|
>>> Module('This is an example module.\n\nThis is the docstring.\n',
|
||||||
... Stmt([Function('double', ['x'], [], 0, 'Return twice the argument',
|
... Stmt([Function(None, 'double', ['x'], [], 0,
|
||||||
... Stmt([Return(Mul((Name('x'), Const(2))))]))]))
|
... 'Return twice the argument',
|
||||||
|
... Stmt([Return(Mul((Name('x'), Const(2))))]))]))
|
||||||
Module('This is an example module.\n\nThis is the docstring.\n',
|
Module('This is an example module.\n\nThis is the docstring.\n',
|
||||||
Stmt([Function('double', ['x'], [], 0, 'Return twice the argument',
|
Stmt([Function(None, 'double', ['x'], [], 0,
|
||||||
Stmt([Return(Mul((Name('x'), Const(2))))]))]))
|
'Return twice the argument',
|
||||||
|
Stmt([Return(Mul((Name('x'), Const(2))))]))]))
|
||||||
>>> mod.doc
|
>>> mod.doc
|
||||||
'This is an example module.\n\nThis is the docstring.\n'
|
'This is an example module.\n\nThis is the docstring.\n'
|
||||||
>>> for node in mod.node.nodes:
|
>>> for node in mod.node.nodes:
|
||||||
... print node
|
... print node
|
||||||
...
|
...
|
||||||
Function('double', ['x'], [], 0, 'Return twice the argument',
|
Function(None, 'double', ['x'], [], 0, 'Return twice the argument',
|
||||||
Stmt([Return(Mul((Name('x'), Const(2))))]))
|
Stmt([Return(Mul((Name('x'), Const(2))))]))
|
||||||
>>> func = mod.node.nodes[0]
|
>>> func = mod.node.nodes[0]
|
||||||
>>> func.code
|
>>> func.code
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue