Python - if/else statements

Peter Hansen peter at engcorp.com
Sat Jul 12 05:10:42 EDT 2003


Bengt Richter wrote:
> 
> It could. It depends. A script or a file (extension may vary, .py, .pyc, etc) that's imported
> is like a big room with a single cork bulletin board. Think of that bulletin board as
> the script's or module's global name space. It's where name tags can be tacked up with names
> associated with objects. You can think of the objects themselves as balloons attached to
> the name tags by strings (the houses have no roofs, so all the balloons occupy space
> someplace high up outside ;-)
> [...]
> When you leave the playhouse, its inside bulletin board is cleared of name tags (and the
> strings detached).  When you enter again, you start with a clean inside board with only
> name tags matching the formal parameter names (if any). If the last string is detached,
> it is grabbed by a balloon collector, who pops it to make sure there is always space in
> the sky for new balloons. Kind of ;-)

Almost correct.  Actually, the balloons are helium-filled and they simply float
off into the sky where, after an undefined period of time, but usually instantly,
they will POP and cease to exist.  ;-)

In Jython, the balloons don't usually POP instantly, but instead float up to the
stratosphere where a garbage collection airplane flies through and explodes as 
many as it can find, from time to time.

Even in C Python, balloons which are tied together (since balloons can actually 
have small bulletin board attached too) will actually float around for a while until
a garbage collection airplane flies through and does its job.  Unfortunately, 
some balloons have their own automated popping feature attached (__del__) which
makes it unsafe for the plane to pop them, so it leaves those alone and it's your
job to untie their strings from each other so they can pop on their own, or 
be popped by the GC airplane on its next pass.

> But every eyelet must have a string leading to some balloon, even if it is the None balloon.

Note also that the None balloon is filled with "super Helium(tm)" as it must stay
aloft even with so many strings attached!  No, wait, the strings are actually
weightless, right?

-Peter

P.S.: Very cute, not to mention accurate, way to describe it, if somewhat involved. :-)




More information about the Python-list mailing list