~pythonregexp2.7/python/issue2636-01+09-01-01

« back to all changes in this revision

Viewing changes to Doc/reference/expressions.rst

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:02:12 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922000212-7r0q4f4ugiq57jph
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
625
625
   call: `primary` "(" [`argument_list` [","]
626
626
       : | `expression` `genexpr_for`] ")"
627
627
   argument_list: `positional_arguments` ["," `keyword_arguments`]
628
 
                : ["," "*" `expression`]
629
 
                : ["," "**" `expression`]
 
628
                :   ["," "*" `expression`] ["," `keyword_arguments`]
 
629
                :   ["," "**" `expression`]
630
630
                : | `keyword_arguments` ["," "*" `expression`]
631
 
                : ["," "**" `expression`]
632
 
                : | "*" `expression` ["," "**" `expression`]
 
631
                :   ["," "**" `expression`]
 
632
                : | "*" `expression` ["," "*" `expression`] ["," "**" `expression`]
633
633
                : | "**" `expression`
634
634
   positional_arguments: `expression` ("," `expression`)*
635
635
   keyword_arguments: `keyword_item` ("," `keyword_item`)*
686
686
 
687
687
If the syntax ``*expression`` appears in the function call, ``expression`` must
688
688
evaluate to a sequence.  Elements from this sequence are treated as if they were
689
 
additional positional arguments; if there are positional arguments *x1*,...,*xN*
690
 
, and ``expression`` evaluates to a sequence *y1*,...,*yM*, this is equivalent
691
 
to a call with M+N positional arguments *x1*,...,*xN*,*y1*,...,*yM*.
 
689
additional positional arguments; if there are positional arguments *x1*,...,
 
690
*xN*, and ``expression`` evaluates to a sequence *y1*, ..., *yM*, this is
 
691
equivalent to a call with M+N positional arguments *x1*, ..., *xN*, *y1*, ...,
 
692
*yM*.
692
693
 
693
 
A consequence of this is that although the ``*expression`` syntax appears
694
 
*after* any keyword arguments, it is processed *before* the keyword arguments
 
694
A consequence of this is that although the ``*expression`` syntax may appear
 
695
*after* some keyword arguments, it is processed *before* the keyword arguments
695
696
(and the ``**expression`` argument, if any -- see below).  So::
696
697
 
697
698
   >>> def f(a, b):
1113
1114
 
1114
1115
The operators :keyword:`is` and :keyword:`is not` test for object identity: ``x
1115
1116
is y`` is true if and only if *x* and *y* are the same object.  ``x is not y``
1116
 
yields the inverse truth value.
 
1117
yields the inverse truth value. [#]_
1117
1118
 
1118
1119
 
1119
1120
.. _booleans:
1244
1245
   (expr1, expr2, expr3, expr4)
1245
1246
   {expr1: expr2, expr3: expr4}
1246
1247
   expr1 + expr2 * (expr3 - expr4)
1247
 
   func(expr1, expr2, *expr3, **expr4)
 
1248
   expr1(expr2, expr3, *expr4, **expr5)
1248
1249
   expr3, expr4 = expr1, expr2
1249
1250
 
1250
1251
 
1299
1300
+-----------------------------------------------+-------------------------------------+
1300
1301
| ``**``                                        | Exponentiation                      |
1301
1302
+-----------------------------------------------+-------------------------------------+
1302
 
| ``x.attribute``                               | Attribute reference                 |
1303
 
+-----------------------------------------------+-------------------------------------+
1304
1303
| ``x[index]``                                  | Subscription                        |
1305
1304
+-----------------------------------------------+-------------------------------------+
1306
1305
| ``x[index:index]``                            | Slicing                             |
1307
1306
+-----------------------------------------------+-------------------------------------+
1308
 
| ``f(arguments...)``                           | Function call                       |
 
1307
| ``x(arguments...)``                           | Call                                |
 
1308
+-----------------------------------------------+-------------------------------------+
 
1309
| ``x.attribute``                               | Attribute reference                 |
1309
1310
+-----------------------------------------------+-------------------------------------+
1310
1311
| ``(expressions...)``                          | Binding or tuple display            |
1311
1312
+-----------------------------------------------+-------------------------------------+
1352
1353
   only, but this caused surprises because people expected to be able to test a
1353
1354
   dictionary for emptiness by comparing it to ``{}``.
1354
1355
 
 
1356
.. [#] Due to automatic garbage-collection, free lists, and the dynamic nature of 
 
1357
   descriptors, you may notice seemingly unusual behaviour in certain uses of
 
1358
   the :keyword:`is` operator, like those involving comparisons between instance
 
1359
   methods, or constants.  Check their documentation for more info.