Division oddity

Paul Rubin http
Tue Jan 13 14:41:20 EST 2004


Peter Hansen <peter at engcorp.com> writes:
> > Python has no support for macros or aliases, and it would be silly
> > to add some special kludge for input().  The user needs to be able
> > to redefine the function and so forth too.
> 
> Sure it does:
> 
> def input(*args):
>     return eval(raw_input(*args))

For it to be an alias, that definition would have to be injected into
the module that input is actually called from, not run in a separate
module.

How the heck does input get at the environment of its caller, anyway?
Through the frame object chain?  

I guess the obvious fix is for the future division flag to be part of
the environment, so evaling in the caller environment is done according
to the flag.  

Someone has already checked a fix into sourceforge, but I haven't
looked at it and don't know if it works that way or some other way.



More information about the Python-list mailing list