This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: strange behavior of importing random module
Type: crash Stage:
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Bekket.McClane, steven.daprano, vstinner
Priority: normal Keywords:

Created on 2014-09-24 09:21 by Bekket.McClane, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
Screenshot from 2014-09-24 17:04:58.png Bekket.McClane, 2014-09-24 09:21 The is the testing file with "import random" and "random.randrange(1,10)"
Messages (3)
msg227428 - (view) Author: Bekket McClane (Bekket.McClane) Date: 2014-09-24 09:21
When I import the random module using "import random" in the command line, it worked fine. But if I import it in the file, the program will throw a strange error, but sometimes it just exit right away after the import statement with no error. Moreover, if I execute the python command line again and "import random" after that, the command line python exit right away too(with exit code 0). Only if I restarted the whole terminal program did the strange behavior gone
msg227431 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-09-24 09:42
It's not a bug in Python. The problem is that your project contains a file called "" which is used instead of the random from the standard library. Rename the file (and remove random.pyc).
msg227449 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2014-09-24 13:21
For future reference, we *strongly* recommend that instead of taking a screen shot and posting it as an attachment, you copy and paste the text directly. Don't retype it, any decent terminal application will allow you to select and copy the text, then paste it elsewhere.
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66669
2014-09-24 13:21:53steven.dapranosetnosy: + steven.daprano
messages: + msg227449
2014-09-24 09:42:00vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg227431

resolution: not a bug
2014-09-24 09:21:10Bekket.McClanecreate