Nested scopes hitch

Fernando Pérez fperez528 at yahoo.com
Mon Apr 8 21:55:21 EDT 2002


Jeff Shannon wrote:

> If you want access to variables inside of a function, you should
> pass those specific variables as arguments.  If you've got lots
> of arguments in common between lots of functions, assemble the
> lot into a class.  If neither of these is appropriate, then you
> should redesign -- you're using a very ugly approach.
> 

Not necessarily. I can show you several examples of functions which need to 
know the context of the caller in a generic enough fashion that argument 
passing isn't a viable option. Fortunately so far I've been able to get what 
I've needed by manipulating the stack, but the point remains. Yes, in _most_ 
cases a clean, explicit passing of arguments is the right way to do things. 
But there are perfectly valid cases where more complex solutions are needed, 
don't dismiss them so quickly.

Cheers,

f.



More information about the Python-list mailing list