IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: Well that was fun. A NULL in a directory name?
I know nothing about Python, but have you tried:

>>> myDataDir = "c:\\data\\00-LatestData"

Hell, I don't even know if that's legal.
-Mike

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."
- Benjamin Franklin, 1759 Historical Review of Pennsylvania
New What Mike said...
Actually, \0 is the null. Mike's suggestion is correct, but also take a look at the os.path module to avoid the pain.

FWIW, the board doesn't like it either :-/ I had to escape the backslash or it shows as "0".
Expand Edited by scoenye Jan. 31, 2012, 07:30:19 PM EST
New Thanks for the correction.
There's an awful lot of stuff in the python standard library! :-)

I too found that you can do "\\" and "\0" here - you just have to double the number of backslashes you want to be visible.

Apparently this "null in a string" issue is something that python web programmers have to think about - http://lucumr.pocoo....as-web-developer/

Thanks.

Cheers,
Scott.
New Backslashes are for escaping things
Including backslashes. Working as designed.
Regards,
-scott
Welcome to Rivendell, Mr. Anderson.
New It's an easy fix.
There's likely a way to escape the backslash, but I just did a substitution.

testing inside the Python shell (omitting earlier steps):

>>>myDataDir = myDataDir.replace("\\", "/") # escape the backslash in the command

>>>os.chdir(myDataDir)

Easy, peasy.

Your solution works, too:

>>> myDataDir = "c:\\data\\00-LatestData"
>>> os.chdir(myDataDir)
>>> print os.getcwd()
c:\data\00-LatestData
>>>

There may even a 'os' method to give the 'myDataDir' already pre-escaped; no doubt this has come up before... But I learned some things with my adventures today, so it's all good.

Thanks.

Cheers,
Scott.
     Well that was fun. A NULL in a directory name? - (Another Scott) - (12)
         There is also a difference... - (folkert)
         Re: Well that was fun. A NULL in a directory name? - (mvitale) - (4)
             What Mike said... - (scoenye) - (2)
                 Thanks for the correction. - (Another Scott)
                 Backslashes are for escaping things - (malraux)
             It's an easy fix. - (Another Scott)
         for what it's worth - (lincoln) - (3)
             It's not an OS issue, it a python method issue. - (Another Scott) - (2)
                 Not just Python - (scoenye) - (1)
                     Null terminated strings are evil. - (Another Scott)
         This is, of course, actually a Windows bug. - (static) - (1)
             Blame Kildall. - (Another Scott)

We do, after all, survive every moment... except the last.
52 ms