[Pythonmac-SIG] Re: Path Issues

Joshua Tompkins joshua at joshuatompkins.us
Mon Nov 3 15:55:29 EST 2003


Bob Ippolito wrote:

>
> On Nov 3, 2003, at 3:44 PM, Joshua Tompkins wrote:
>
>> Bob Ippolito wrote:
>>
>>>
>>> On Nov 3, 2003, at 3:28 PM, Joshua Tompkins wrote:
>>>
>>>> Yes, I'm using the open() builtin function.
>>>
>>>
>>>
>>> Are you using it from an application bundle?  an app opened via 
>>> LaunchServices (Finder, the open command) will have a getcwd() of / 
>>> when it starts.  Try "print os.getcwd()" to see where the cwd is.
>>>
>>> -bob
>>>
>>>
>> I'm running Python by typing "python" from the Terminal.
>>
>> os.getcwd() returns "/Users/joshua" (with that capitalization).
>
>
> What is the line of code that you're trying?
>
> open("~/source/python/file") does not work
>
> you need to do
>
> open(os.path.expanduser("~/source/python/file"))
>
> if you want to use tilde expansion.
>
> -bob
>
>
Wow, that works.  Duh.  Should have figured that one out on my own.  
Anyway, thanks for your help, since I probably *wouldn't* have ever 
thought about that.  Maybe it's time for another jaunt through the 
library reference.

-joshua




More information about the Pythonmac-SIG mailing list