the annoying, verbose self

samwyse samwyse at gmail.com
Sat Nov 24 11:27:56 EST 2007


On Nov 24, 7:50 am, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote:
> > On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> >> On Sat, 24 Nov 2007 01:55:38 -0800, samwyse wrote:
> >> > I've had the same thought, along with another.  You see, on of my pet
> >> > peeves about all OO languages that that when creating new code, I
> >> > generally begin by writing something like this:
>
> >> > cat = 'felix'
> >> > dog = 'rover'
> >> > def example():
> >> >   global cat, dog  # not always required, but frequently needed
> >> >   return ', '.join((cat, dog))
>
> >> Ouch that's bad design IMHO.  The need to use ``global`` is a design
> >> smell, if needed *frequently* it starts to stink.
>
> > I'm not sure what you mean.  In the example that I gave, the 'global'
> > statement isn't needed.  However, here's a different example:
>
> I mean that global names that are (re)bound from within functions couple
> these functions in a non-obvious way and make the code and data flow harder
> to follow and understand.  Also it makes refactoring and testing more
> difficult because of the dependencies.

The whole point of this sub-thread is the difficulty of turning global
vars and functions into class vars and functions, and that is
something that is usually done precisely because the code and data
flow has become harder to follow and understand.



More information about the Python-list mailing list