Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

'-' is not special. The import statement requires the module name been an 
identifier. This is just a requirement of Python syntax. But when pass the 
module name as a string, there is no such limitation in CPython. This is like 
an attribute name or keyword argument name should be identifiers in 
expressions, but you can pass an arbitrary string to getattr() and use a dict 
with arbitrary string keys as kwargs. Currently non-identifier strings are 
accepted, but this is an implementation detail, not a part of the language.

There are reasons against adding additional checks for attribute names and 
keyword argument names. This will slow down execution of all code. This is less 
critical for importing, because it is slower than attribute access and function 
call. But on other side, the benefit of adding this check is not obvious.

It may be worth to discuss this on mailing lists. First read previous 
discussions about attribute names and keyword argument names.

----------
nosy: +brett.cannon, eric.snow, gvanrossum, ncoghlan, serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35358>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to