mod, modulo and % under 2.4 and 2.5
steve at REMOVE-THIS-cybersource.com.au
Fri Jan 1 04:06:20 CET 2010
On Fri, 01 Jan 2010 13:48:28 +1100, Ben Finney wrote:
> "W. eWatson" <wolftracks at invalid.com> writes:
>> Steven D'Aprano wrote:
>> > NameError: name 'mod' is not defined
>> So where is it? Here are the choices. import sys, os, glob
>> import string
>> from numpy import *
> If you use ‘from foo import *’ you forfeit any way of saying where a
> name in your code gets bound.
>>> from math import *
But this only works with functions and classes, not arbitrary objects:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'float' object has no attribute '__module__'
> Hence, don't do that.
Avoiding "from module import *" is generally excellent advice. There's
one or two exceptions, but if you have to ask what they are, you don't
need to know *wink*
More information about the Python-list