Global variables
laotseu
bdesth at removethis.free.fr
Thu Feb 13 23:30:49 EST 2003
gislan wrote:
> Hi everyone
>
> I have two questions
>
> 1. Is there any reason for NOT using globall variables (I know that
> using global variables in i.e. C isn't very good idea. What about
> python?)
The language doesn't matter. Globals are *evil* ! Shoot'em all !
No, I'm joking...
The point is that :
1/ globals means tight coupling of code that relies on the globals
2/ code become harder to understand
3/ you end up with a plate of spaghetti (I like spaghetti, but not in my
code)
So, as Gerhard says, better ask yourself *why* you'd need globals...
There is almost always a way to do without globals. This may include
more code, more parameters to functions etc, but, except for small one
shot throwable script, it is worth the extra work, as soon as your
client ask for more feature or let you know that business rules have
changed... That day, what at first seems to be useless extra work
becomes a life-saver.
> 2. I want to run other application (using os.system) and 'catch'
> everything it will print on stdin. How can I do this?
redirect stdin may be a solution ? google for this, you should find many
examples.
Laotseu
More information about the Python-list
mailing list