python on Linux

Chris Angelico rosuav at gmail.com
Fri Oct 10 17:53:18 CEST 2014


On Sat, Oct 11, 2014 at 2:44 AM, Peter Pearson
<pkpearson at nowhere.invalid> wrote:
> On Fri, 10 Oct 2014 08:31:04 +0200, Irmen de Jong wrote:
>> On 10-10-2014 6:21, Igor Korot wrote:
>
>>> When I am on Windows, I can write something like this:
>>>
>>> sys.path.append('C:\Users\Igor\Documents\MyLib')
>>
>> While this might work on your system, it may not work on others.
>>
>> - you need to escape the backslashes (or just use forward slashes,
>> they work on windows too)
>
> And remember that os.path.join() will join path fragments with
> the right kind of slashes for your operating system.

That's fine if you have the parts separately already, but when it's
primarily a single literal string, just use slashes and save yourself
the trouble.

ChrisA



More information about the Python-list mailing list