Any other Python flaws?

D-Man dsh8290 at rit.edu
Tue Jun 19 14:37:07 EDT 2001


On Mon, Jun 18, 2001 at 11:28:50PM +0100, Michael Hudson wrote:
| D-Man <dsh8290 at rit.edu> writes:
| 
| > On Mon, Jun 18, 2001 at 08:10:12PM +0100, Michael Hudson wrote:
<snip> 
| > | I agree that what Michael posted doesn't really do what he wanted; but
| > | it doesn't do what you said, either.
| > 
| > It seems to, with some cursory tests in the interactive interpreter.
| 
| Yeah, it looks the same, but None is being found in the global
| namespace, not the builtin one like normal.  I can't think of any
| remotely sane situation where this would make a difference, but the
| difference is there.  Eg. consider assigning to __builins__.None (I
| don't recommend actually doing this!).

Oh, that's why you meant there was a difference.  Like you said, it is
basically the same, except the lookup finds the result sooner.

| > I would have to look at the source to see _how_ the function
| > implicitly returns 'None' to understand why it doesn't behave as
| > intended.
| 
| Because falling off the end of a function compiles into a LOAD_CONST

Yeah, I knew the functions implicitly returned None, but I didn't know
(until now) why you said it didn't work.  I thought maybe there was
some special case where it wouldn't find None or would find a
different one.

-D





More information about the Python-list mailing list