[Python-ideas] Default arguments in Python - the return - running out of ideas but...

Gerald Britton gerald.britton at gmail.com
Thu May 14 16:30:58 CEST 2009


Typo:

> (print_) is interpreted as an expression, which is then passed to the
> print statement

should be:

(p) is interpreted as an expression, which is then passed to the print statement


On Thu, May 14, 2009 at 10:29 AM, Gerald Britton
<gerald.britton at gmail.com> wrote:
> print(print) is not a function call in 2.x:
>
>>>> import types
>>>> def f(): pass
> ...
>>>> isinstance(f, types.FunctionType)
> True
>>>> isinstance(print, types.FunctionType)
>  File "<stdin>", line 1
>    isinstance(print, types.FunctionType)
>                   ^
> SyntaxError: invalid syntax
>>>> p = "hi there"
>>>> print p
> hi there
>>>> print(p)
> hi there
>
>
> (print_) is interpreted as an expression, which is then passed to the
> print statement
>
> On Wed, May 13, 2009 at 3:30 PM, Scott David Daniels
> <Scott.Daniels at acm.org> wrote:
>> spir wrote:
>>>
>>> My opinion on this is you're basically right. Even 'print' (for py<3.0)
>>> could be an identifier you could use in an assignment (or in any value
>>> expression), I guess, for parse patterns are different:
>>>   print_statement : "print" expression
>>>   assignment      : name '=' expression
>>> So you can safely have "print" as name, or inside an expression. Even
>>> "print print" should work !
>>
>> But you would not want
>>    print print
>> and
>>    print(print)
>> to have two different meanings.
>> In Python, extra parens are fair around expressions,
>> and print(print) is clearly a function call.
>>
>> --Scott David Daniels
>> Scott.Daniels at Acm.Org
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>
>
>
>
> --
> Gerald Britton
>



-- 
Gerald Britton



More information about the Python-ideas mailing list