Re: import random module

2006-03-23 Thread Just
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

Re: import random module

2006-03-22 Thread Carl Banks
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

Re: import random module

2006-03-22 Thread Ben Finney
"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

Re: import random module

2006-03-22 Thread Michael Tobis
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

Re: import random module

2006-03-22 Thread Tomas Brabenec
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

Re: import random module

2006-03-22 Thread DataSmash
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

Re: import random module

2006-03-22 Thread DataSmash
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

Re: import random module

2006-03-22 Thread Richard Brodie
"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

Re: import random module

2006-03-22 Thread Michael Tobis
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

Re: import random module

2006-03-22 Thread Gerard Flanagan
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

Re: import random module

2006-03-22 Thread Jorge Godoy
"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.

Re: import random module

2006-03-22 Thread Daniel Dittmar
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 >

Re: import random module

2006-03-22 Thread Benjamin Niemann
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

Re: import random module

2006-03-22 Thread Diez B. Roggisch
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 "

import random module

2006-03-22 Thread DataSmash
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