Text-mode apps (Was :Who are the "spacists"?)

Chris Angelico rosuav at gmail.com
Sat Apr 1 17:54:21 EDT 2017


On Sun, Apr 2, 2017 at 7:49 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>>Yes it can; however, there is no way within Python to have a string
>>that can represent two strings, which is what directory separators do.
>
>   To represent two strings, /internally/ ("within Python"),
>   a straightforward way would be a list of two strings.
>
>   If one wants to represent this list /as a single string/,
>   one can use any serialization of this list, for example,
>   using JSON.
>
>   (I have not read the whole thread, so I might have missed
>   some context here. I am just responding to what is quoted
>   above.)

The context is a file name, in which you need something that a user
can input which is capable of representing path components that
contain arbitrary characters. Currently, a Unix path always interprets
a slash as a directory separator, so there's no way to have a slash in
a file or directory name. If you want to have *every* component
capable of containing *any* character, you either need a string to be
able to represent two strings, or you need some sort of escaping
mechanism.

ChrisA



More information about the Python-list mailing list