In article <[EMAIL PROTECTED]>,
"Carl Banks" <[EMAIL PROTECTED]> wrote:
> Ben Finney wrote:
> > "DataSmash" <[EMAIL PROTECTED]> writes:
> > > * random.py:
> > >
> > > import random
> >
> > Now that you've tripped over this ambiguity of Python's current
> > 'import' behaviour, you may be intereste
Ben Finney wrote:
> "DataSmash" <[EMAIL PROTECTED]> writes:
> > * random.py:
> >
> > import random
>
> Now that you've tripped over this ambiguity of Python's current
> 'import' behaviour, you may be interested to know that the behaviour
> will change to solve this:
>
> http://www.python.org/de
"DataSmash" <[EMAIL PROTECTED]> writes:
> * random.py:
>
> import random
Now that you've tripped over this ambiguity of Python's current
'import' behaviour, you may be interested to know that the behaviour
will change to solve this:
http://www.python.org/dev/peps/pep-0328/>
In brief: Python
Wow. Six simultaneous responses! Python rocks!
Anyway, I actually tried it, and persisted through the secondary
confusion about the lurking .pyc file, so even though I'm in sixth
place I get points for completeness...
mt
--
http://mail.python.org/mailman/listinfo/python-list
You must rename Your script.
Your script doesn't same name as calling module.
Tomas Brabenec
http://brabenec.net
DataSmash napsal(a):
> Hi,
> When I import the random module at the python interpreter, it works
> fine:
>
import random
x = random.randint(1,55)
print x
Much Thanks!
I deleted the random.pyc and renamed the script and everything is good!
R.D.
--
http://mail.python.org/mailman/listinfo/python-list
Much Thanks!
I deleted the random.pyc and renamed the script and everything is good!
R.D.
--
http://mail.python.org/mailman/listinfo/python-list
"Benjamin Niemann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Don't name your script 'random.py' (or any other name from the stdlib).
> 'import random' will import the script itself (not the random module from
> the stdlib), which is not what you want.
I discovered long, long
1) remove the file random.pyc in your working directory
2) rename the file random.py to something else and run it.
The import mechanism is looking for random.pyc or random.py, but you
have already named your file that! Your current directory is above your
library directory in python's search path
DataSmash wrote:
> Hi,
> When I import the random module at the python interpreter, it works
> fine:
> >>> import random
> >>> x = random.randint(1,55)
> >>> print x
> 14
> >>>
>
> BUT, when I put the same code in a python script:
> * random.py:
>
> import random
>
> x = random.randint(1,55)
> pr
"DataSmash" <[EMAIL PROTECTED]> writes:
> Hi,
> When I import the random module at the python interpreter, it works
> fine:
import random
x = random.randint(1,55)
print x
> 14
>
> BUT, when I put the same code in a python script:
> * random.py:
>
> import random
>
> x = random.
DataSmash wrote:
> Hi,
> When I import the random module at the python interpreter, it works
> fine:
import random
x = random.randint(1,55)
print x
> 14
>
> BUT, when I put the same code in a python script:
> * random.py:
>
> import random
>
> x = random.randint(1,55)
> print x
>
DataSmash wrote:
> Hi,
> When I import the random module at the python interpreter, it works
> fine:
import random
x = random.randint(1,55)
print x
> 14
>
> BUT, when I put the same code in a python script:
> * random.py:
>
> import random
>
> x = random.randint(1,55)
> prin
DataSmash wrote:
> Hi,
> When I import the random module at the python interpreter, it works
> fine:
import random
x = random.randint(1,55)
print x
> 14
>
> BUT, when I put the same code in a python script:
> * random.py:
^^
There is your problem: you named your module "
Hi,
When I import the random module at the python interpreter, it works
fine:
>>> import random
>>> x = random.randint(1,55)
>>> print x
14
>>>
BUT, when I put the same code in a python script:
* random.py:
import random
x = random.randint(1,55)
print x
and run it at the command line, I get:
Tr
15 matches
Mail list logo