summaryrefslogtreecommitdiff
path: root/Grammar
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-08 05:00:18 +0000
committerGuido van Rossum <guido@python.org>2001-08-08 05:00:18 +0000
commit4668b000a1d9113394941ad39875c827634feb49 (patch)
tree734560442fef1ce34912ceb772099b9a006e010a /Grammar
parent074c9d2b2081237c1071a3775f6e36252cf16ad7 (diff)
downloadcpython-git-4668b000a1d9113394941ad39875c827634feb49.tar.gz
Implement PEP 238 in its (almost) full glory.
This introduces: - A new operator // that means floor division (the kind of division where 1/2 is 0). - The "future division" statement ("from __future__ import division) which changes the meaning of the / operator to implement "true division" (where 1/2 is 0.5). - New overloadable operators __truediv__ and __floordiv__. - New slots in the PyNumberMethods struct for true and floor division, new abstract APIs for them, new opcodes, and so on. I emphasize that without the future division statement, the semantics of / will remain unchanged until Python 3.0. Not yet implemented are warnings (default off) when / is used with int or long arguments. This has been on display since 7/31 as SF patch #443474. Flames to /dev/null.
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar4
1 files changed, 2 insertions, 2 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index c791892dff..d85863e9a2 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -38,7 +38,7 @@ stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt
expr_stmt: testlist (augassign testlist | ('=' testlist)*)
-augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**='
+augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//='
# For normal assignments, additional restrictions enforced by the interpreter
print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] )
del_stmt: 'del' exprlist
@@ -77,7 +77,7 @@ xor_expr: and_expr ('^' and_expr)*
and_expr: shift_expr ('&' shift_expr)*
shift_expr: arith_expr (('<<'|'>>') arith_expr)*
arith_expr: term (('+'|'-') term)*
-term: factor (('*'|'/'|'%') factor)*
+term: factor (('*'|'/'|'%'|'//') factor)*
factor: ('+'|'-'|'~') factor | power
power: atom trailer* ('**' factor)*
atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+