f(n=4) works; bug or feature?

Aahz Maruch aahz at panix.com
Mon Dec 24 10:27:22 EST 2001


In article <3C27404E.8030601 at erols.com>,
Edward C. Jones <edcjones at erols.com> wrote:
>Aahz Maruch wrote:
>> In article <3C26B3DA.4000102 at erols.com>,
>> Edward C. Jones <edcjones at erols.com> wrote:
>>> 
>>>In Python 2.2, the following code prints a "4".
>>>
>>>def fun(n):
>>>    print n
>>>
>>>fun(n=4)
>>>
>>>Bug or feature?
>>>
>> 
>> Feature.  You're using the ability of Python to define keyword arguments
>> to functions.
>
>Embarrassment. In this minimal context, it looked like an assignment.

It is an assignment, but the assignment occurs in the function's
context.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

Tenth Virtual Anniversary: 7 days and counting



More information about the Python-list mailing list