Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106434 > unrolled thread

Collection: weak error prompt drives beginner crazy

Started byanimalize <animalize81@hotmail.com>
First post2016-04-04 19:24 +0800
Last post2016-04-04 07:48 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Collection: weak error prompt drives beginner crazy animalize <animalize81@hotmail.com> - 2016-04-04 19:24 +0800
    Re: Collection: weak error prompt drives beginner crazy Ned Batchelder <ned@nedbatchelder.com> - 2016-04-04 07:48 -0700

#106434 — Collection: weak error prompt drives beginner crazy

Fromanimalize <animalize81@hotmail.com>
Date2016-04-04 19:24 +0800
SubjectCollection: weak error prompt drives beginner crazy
Message-ID<mailman.12.1459769484.32530.python-list@python.org>
An example, the file-name is conflict with library-name in stdlib or 
installed library.

There is a file uuid.py that only has two lines:

     import uuid
     print(uuid.uuid4())

Run uuid.py, output on Python 3.5.1:

     Traceback (most recent call last):
       File "D:\uuid.py", line 1, in <module>
         import uuid
       File "D:\uuid.py", line 3, in <module>
         print(uuid.uuid4())
     AttributeError: module 'uuid' has no attribute 'uuid4'

I was spending about an hour to find out what happend when I was a 
beginner, and I found I'm not the only one who confused by this problem.

If the prompt can be beginner-friendly a little bit, I think it's a very 
good thing.
E.g. says you are importing the file itself, rather than importing other 
file or library.

[toc] | [next] | [standalone]


#106443

FromNed Batchelder <ned@nedbatchelder.com>
Date2016-04-04 07:48 -0700
Message-ID<f56d3ad4-5ff7-4fdb-a725-9082542b30eb@googlegroups.com>
In reply to#106434
On Monday, April 4, 2016 at 7:31:38 AM UTC-4, animalize wrote:
> An example, the file-name is conflict with library-name in stdlib or 
> installed library.
> 
> There is a file uuid.py that only has two lines:
> 
>      import uuid
>      print(uuid.uuid4())
> 
> Run uuid.py, output on Python 3.5.1:
> 
>      Traceback (most recent call last):
>        File "D:\uuid.py", line 1, in <module>
>          import uuid
>        File "D:\uuid.py", line 3, in <module>
>          print(uuid.uuid4())
>      AttributeError: module 'uuid' has no attribute 'uuid4'
> 
> I was spending about an hour to find out what happend when I was a 
> beginner, and I found I'm not the only one who confused by this problem.
> 
> If the prompt can be beginner-friendly a little bit, I think it's a very 
> good thing.
> E.g. says you are importing the file itself, rather than importing other 
> file or library.

I agree that it would be good if Python would be clear about this error.
I suggested as much on Python-Ideas a few months ago:
https://groups.google.com/d/topic/python-ideas/dNbXlL2XoJ8/discussion
or https://mail.python.org/pipermail/python-ideas/2016-January/038165.html

The thread did not end with a strong opinion one way or the other, though
it did get distracted by other kinds of import mistakes.

--Ned.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web