Re: [Pythonmac-SIG] Question on user's directory ( ~ )
import os.path os.path.expanduser('~') you da man! That works perfectly. I mostly use Python on WinXP, so I haven't been familiar with that function up until now. It's a common problem... I ran into that once when I was moving an PC based Python application over to MOSX... I knew there was a way expand it, but forgot that it wasn't automagically performed... - Ben ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Question on user's directory ( ~ )
The tilde is just UNIX shorthand for the environment variable, home. You can access environment variables in python like this: os.getenv(HOME) Scott On Mar 18, 2006, at 4:22 PM, Stewart Midwinter wrote: I have a question on use of the tilde symbol (~) to access the current user's home directory. If you are in a bash shell, you can cd ~ and be in the default user's home directory. I want my python app to be able to switch to the user's directory. But I can't use os.chdir('~') since Python doesn't understand the tilde. Nor can I do this: file = os.path.join('~', filename) What options do I have? thanks S ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Question on user's directory ( ~ )
I have a question on use of the tilde symbol (~) to access the current user's home directory. If you are in a bash shell, you can cd ~ and be in the default user's home directory. I want my python app to be able to switch to the user's directory. But I can't use os.chdir('~') since Python doesn't understand the tilde. Nor can I do this: file = os.path.join('~', filename) What options do I have? thanks S ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Question on user's directory ( ~ )
Try this: import os.path os.path.expanduser('~') You might also find a use for os.path.expandvars() Kent -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stewart Midwinter Sent: Saturday, March 18, 2006 7:22 PM To: pythonmac-sig@python.org Subject: [Pythonmac-SIG] Question on user's directory ( ~ ) I have a question on use of the tilde symbol (~) to access the current user's home directory. If you are in a bash shell, you can cd ~ and be in the default user's home directory. I want my python app to be able to switch to the user's directory. But I can't use os.chdir('~') since Python doesn't understand the tilde. Nor can I do this: file = os.path.join('~', filename) What options do I have? thanks S ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Question on user's directory ( ~ )
On 3/18/06, Kent Quirk [EMAIL PROTECTED] wrote: Try this: import os.path os.path.expanduser('~') you da man! That works perfectly. I mostly use Python on WinXP, so I haven't been familiar with that function up until now. thanks again S ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig