Difficulty with `cmp', still

François Pinard pinard at iro.umontreal.ca
Tue Sep 21 19:20:54 EDT 1999


"Gordon McMillan" <gmcm at hypernet.com> écrit:

> You need to: "import __builtin__" and use "__builtin__.cmp".

"Fredrik Lundh" <fredrik at pythonware.com> écrit:

> Use "__builtin__", not "__builtins__".  And you have to import it,
> just like any other module.

Thanks to both of you.  It solved it indeed.

I noticed indeed that `__builtins__' says it is the module `__builtin__',
without an `s', at least interactively.  But did not understand why this
subtle difference.

Gordon adds:

> __builtins__ is a dictionary.

So, it is a dictionary in batch, and a module interactively?  This looks
rather strange.  It does not fit well within Python's usual simplicity.

> Recall things like eval and exec, where you can pass a globals dict. If
> this dict is empty, Python will stuff an entry "__builtins__" into it
> for the eval'ed / exec'ed code to use.

Thanks for the pointer.  On the next reading session in the manuals,
I'll try to understand this better.  Thanks!

> BTW, I fell for it, and voluteered to carry out the BDFL's "suggestion".

Oops!  I'm unable to decipher the above sentence, not knowing the meaning
of `fell' nor `BDFL'.  Is `fell' associated with `to feel', or `to fall'?
Also, I do not have `BDFL' in this little collection of acronyms I slowly
accumulated along the years, which English people affectionate in email. :-)

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list