mirror of
https://github.com/python/cpython.git
synced 2025-11-28 14:11:15 +00:00
Further beautification of the example
This commit is contained in:
parent
9c47d778f7
commit
23157e5ddc
1 changed files with 6 additions and 3 deletions
|
|
@ -1331,13 +1331,16 @@ successive matches::
|
||||||
if pos != len(s):
|
if pos != len(s):
|
||||||
raise RuntimeError('Unexpected character %r on line %d' %(s[pos], line))
|
raise RuntimeError('Unexpected character %r on line %d' %(s[pos], line))
|
||||||
|
|
||||||
>>> statements = '''\
|
statements = '''\
|
||||||
total := total + price * quantity;
|
total := total + price * quantity;
|
||||||
tax := price * 0.05;
|
tax := price * 0.05;
|
||||||
'''
|
'''
|
||||||
>>> for token in tokenize(statements):
|
|
||||||
|
for token in tokenize(statements):
|
||||||
print(token)
|
print(token)
|
||||||
|
|
||||||
|
The tokenizer produces the following output::
|
||||||
|
|
||||||
Token(typ='ID', value='total', line=1, column=8)
|
Token(typ='ID', value='total', line=1, column=8)
|
||||||
Token(typ='ASSIGN', value=':=', line=1, column=14)
|
Token(typ='ASSIGN', value=':=', line=1, column=14)
|
||||||
Token(typ='ID', value='total', line=1, column=17)
|
Token(typ='ID', value='total', line=1, column=17)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue