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.

classification
Title: allow import from file having name containing hyphen or blank
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Phillip.M.Feldman@gmail.com, pitrou
Priority: normal Keywords:

Created on 2009-11-30 07:01 by Phillip.M.Feldman@gmail.com, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg95832 - (view) Author: Phillip M. Feldman (Phillip.M.Feldman@gmail.com) Date: 2009-11-30 07:01
It appears that there is currently no way to import from a file whose
name contains a hyphen or blank.  This makes it difficult to encode a
version number or date in the file name.   The solution that I favor
would be to allow the name of the file to be specified via a quoted string.
msg95838 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-30 15:51
Yes, there is:

$ cat > "file-with-hyphen and space.py"
x = 5

$ python
Python 2.6.4 (r264:75706, Oct 27 2009, 15:50:27) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> mod = __import__("file-with-hyphen and space")
>>> mod.x
5
>>>
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51660
2009-11-30 15:51:21pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg95838

resolution: not a bug
2009-11-30 07:01:15Phillip.M.Feldman@gmail.comcreate