[egenix-users] cmp() function

Moof moof at metamoof.net
Mon Dec 19 16:23:52 CET 2005


On 12/19/05, Dirk Holtwick <holtwick at spirito.de> wrote:
>
> > In summary: You should never do "from mx.DateTime import *" -
> > that's bad style :-)
>
> Okay, looks nicer and is more expressive. I agree. But I like the "bad
> style" too and as far as I know it is still allowed ;-)
>
>

>From "The Tao of Python" ("import this"):

Explicit is better than implicit
Namespaces are one honking great idea -- let's do more of those!

Anyway, yeah, the solution I tend to do is rather than:

>>> from mx.DateTime import *

I explicitly import the things I want to use, thus making sure I don't
pollute my namespace too much. At the top of many of my files you will see:

>>> from mx.DateTime import Date, oneDay

which means I keep track of what I'm putting into my namespace. My current
coding conventions do actually disallow "import *", and invariably I find I
have much less in the way of problems in my code this way. Of course, when
prototyping in the interactive shell, I sometimes resort to import *, but
most of the time even there I only import what I need.

Incidentally, you can get to the built-in cmp function by explicitly calling
__builtins__.cmp

Moof -- giving this gmail lark a try
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman-archives/egenix-users/attachments/20051219/930e3df6/attachment-0138.htm


More information about the egenix-users mailing list