[Tutor] sys.path.append
Kent Johnson
kent37 at tds.net
Wed Dec 17 17:17:14 CET 2008
On Wed, Dec 17, 2008 at 10:20 AM, ppaarrkk <simon_ecc at yahoo.co.uk> wrote:
>
> I can do this :
>
>>>> sys.path.append ( 'C:\dump1' )
Note you should use raw strings r'C:\dump1' or double backslash
'C:\\dump1' because the \ is a string escape character.
> but not :
>
>>>> x = 'C:\dir1'
>>>> sys.path.append(x)
That should work fine (other than the single \). What happens when you try it?
> or :
??
> but not :
>>>> x = ['C:\dir1']
>>>> sys.path.append(x)
Here you are appending a list of strings to sys.path, that will not do
what you want.
> Can I append variables to the path, rather than explicit strings ?
Sure.
Kent
More information about the Tutor
mailing list