On Mon, Feb 25, 2013 at 9:33 AM, Ethan Furman <et...@stoneleaf.us> wrote:
> On 02/24/2013 12:58 PM, Chris Angelico wrote:
>>
>> On Mon, Feb 25, 2013 at 7:34 AM, Ethan Furman <et...@stoneleaf.us> wrote:
>>>
>>>
>>>    - no variable declarations, just use 'em
>>
>>
>> Variable declarations can go either way; Python requires you to name
>> all globals that you mutate
>
>
> I'm not sure what you mean -- example?

Whoops, said the wrong thing. All globals that you assign to.

>>> a=1
>>> b=[]
>>> def foo(x):
        y=x+1
        global a
        a+=x
        b.append(y)     
>>> foo(2)
>>> a
3
>>> b
[3]

Python requires that you name 'a' in a global statement; C would
require a declaration for 'y' to make it local. PHP, meanwhile, would
require declarations for both a and b.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to