Re: Python scope

From: Steven Kurylo <sk_at_no.spam.please>
Date: Thu Jul 19 2007 - 12:22:28 CST

> Perhaps a little odd, but its not a problem once you are used to it.

I think its bad form to allow you to read a variable, but then do some
silent slight of hand if you try to write to it. Its the silent part
that bothers me.

And its not universally applied either:

list = [ 'a','b' ]
def foo():
        print list
        list.append('c')
        print list
foo()
print list

Gives

['a', 'b']
['a', 'b', 'c']
['a', 'b', 'c']

So I can append to a list inside a function, so its not read only.
Yes I understand why. Its still inconsistent.

It also bothers me that I don't get a warning if I only use a variable
once (that is, I made a typo in a variable name).
Received on Thu Jul 19 12:22:33 2007

This archive was generated by hypermail 2.1.8 : Thu Jul 19 2007 - 12:22:36 CST