Nested scopes hitch

Christian Tanzer tanzer at swing.co.at
Tue Apr 9 03:13:48 EDT 2002


Jeff Shannon <jeff at ccvcorp.com> wrote:

> In article <mailman.1018310800.31349.python-list at python.org>,
> pinard at iro.umontreal.ca says...
> > [Jeff Shannon]
> >
> > > 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.
> >
> > I beg to disagree, a bit strongly.
> >
> > Something is not ugly just because you prefer something else.  I have very,
> > very neat applications which use globals() and locals(), and they will
> > loose much if they use arguments all over, or get assembled into classes.
>
> Very well, I suppose we will have to disagree, then.  To my mind,
> using globals() and locals() in this way is a gross violation of
> encapsulation.

Sometimes it is, sometimes it isn't.

Without knowing the problem it's hard to tell.

> I obviously can't speak to your specific designs, not having seen
> them, but I can't imagine how globals()/locals() would be
> necessary unless you have a large amount of interdependencies in
> your code

Try to imagine interactive access to an application, or a function
displaying all local variables in case of an exception, or ...

Dogmatism-doesn't-improve-SW-design-ly yr's

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92






More information about the Python-list mailing list