prova.py è il file che ha il contenuto mostrato dall'OP.
nella stessa directory ho creato il file random.py
Con python2 versione 2.7.17
La traceback è questa:
Codice: Seleziona tutto
$ python2 prova.py
Traceback (most recent call last):
File "prova.py", line 3, in <module>
x = random.random()
AttributeError: 'module' object has no attribute 'random'
Con python3 viene fuori una fracca di roba:
Codice: Seleziona tutto
$ python3 prova.py
Traceback (most recent call last):
File "prova.py", line 3, in <module>
x = random.random()
AttributeError: module 'random' has no attribute 'random'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, re, pwd, grp, os, time, io
File "/usr/lib/python3.6/tempfile.py", line 184, in <module>
from random import Random as _Random
ImportError: cannot import name 'Random'
Original exception was:
Traceback (most recent call last):
File "prova.py", line 3, in <module>
x = random.random()
AttributeError: module 'random' has no attribute 'random'
In entrambi i casi, zero informazioni sul modulo effettivamente importato.
Boh.