- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue5098
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.
Created on 2009-01-29 14:41 by stuaxo, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg80765 - (view) | Author: Stuart Axon (stuaxo) | Date: 2009-01-29 14:41 | |
os.environ doesn't escape spaces, but does backslashes and others In the windows python interpreter I echo'd the variable 'ProgramFiles', then in the commandprompt. >>> from os import environ >>> environ['ProgramFiles'] 'C:\\Program Files' >>> ^Z [C:\]echo %ProgramFiles% C:\Program Files This 'half' escapping seems odd, and is annoying when building file paths for instance, probably the space should also be escaped. |
|||
| msg80767 - (view) | Author: Jean-Paul Calderone (exarkun) * ![]() |
Date: 2009-01-29 14:58 | |
The backslash escaping has nothing to do with os.environ. It's the way any string with a backslash in it is displayed in the interactive interpreter (it's the way str.__repr__ works). Performing any escaping on a string to make it usable in a command line is a task which is inappropriate as a feature of os.environ. The contents of os.environ are just strings. If you want to use them in a command line, you need to escape them appropriately. Notice that in addition to escaping the space, you may also sometimes need to escape a backslash (not in this case on Windows, though, since a single \ is allowed here). The escaping of the \ in this example is *only* in the *display* of the variable - there is only one \ in the string itself. I recommend closing this ticket as invalid. |
|||
| msg80779 - (view) | Author: Martin v. Löwis (loewis) * ![]() |
Date: 2009-01-29 19:22 | |
As Jean-Paul explains, you are misinterpreting what you are seeing. Closing as invalid. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:45 | admin | set | github: 49348 |
| 2009-01-29 19:22:38 | loewis | set | status: open -> closed nosy: + loewis resolution: not a bug messages: + msg80779 |
| 2009-01-29 14:58:17 | exarkun | set | nosy:
+ exarkun messages: + msg80767 |
| 2009-01-29 14:41:56 | stuaxo | create | |


