Creating a local variable scope.
rwwh
rob.hooft at gmail.com
Thu Dec 10 01:47:04 EST 2009
On Nov 30, 1:26 am, markolopa <marko.lopa... at gmail.com> wrote:
> I would be much happier with the smaller namespace. To fix the code
> that you show I would impose
>
> s = None
> while True:
> s = raw_input("enter something: ")
> if s not in ('q', 'quit', 'exit'): break
> print s
So you propose: if the variable exists in a wider scope, you ideal
python would not create it in an inner scope. How is this helping your
original case?
I remind you:
class ValueColumn(AbstractColumn):
def __init__(self, name, header, domain_names):
if type(domain_names) != tuple:
raise ValueError('blub')
for name in domain_names:
if type(name) != str:
raise ValueError('blub')
self.domain_names = domain_names
super(ValueColumn, self).__init__(name, header)
When "for name" is reached, "name" already exists and no local
variable would be created. How does this help you?
More information about the Python-list
mailing list