Modifying access to local variables

Jason Orendorff jason at
Tue Jan 8 11:40:44 EST 2002

> def foo():
>    x = z
> z isn't define anywhere (not a global variable) and I want it to be of
> special class, say Myclass.
> So what I want the code to mean is the following :
> def foo():
>    z = MyClass()
>    x = z
> But this line of declaration is useless as all the variables I'll use
> in the function will be MyClass object. Is there a way to avoid
> declarations of variables in function (in my case, I'll have more than
> a hundred ones).

No way to do this, if I understand you correctly.

Tell a bit more about your application.  I'm sure there's
a workable alternative, but you don't give enough information
for anyone to suggest one.

## Jason Orendorff

More information about the Python-list mailing list