Python Path

Michal Wallace sabren at manifestation.com
Thu Aug 31 00:56:03 EDT 2000


On 31 Aug 2000, Poparosa wrote:

> sys.append('c:/mysqlgui/piddle') call to work. 
> 
> What is the syntax of the append call (what does it want as a formal
> parameter?)
> I get the following message:
> Traceback(innermost last):
>   File "<stdin>", line 1, in ?
> AttributeError: append

well, you may already know that "append" is a method that belongs to
lists:

>>> dir([])
['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 
'reverse', 'sort']
>>>

So, you probably want to find a list in the sys module:

>>> import sys
>>> for item in dir(sys):
...     if type(getattr(sys, item)) == type([]):
...         print item
...
argv
path
>>>


Well... this is a tough choice. check the docs:

>>> print sys.__doc__
[lots of good reading snipped]
argv -- command line arguments; argv[0] is the script pathname if known
path -- module search path; path[0] is the script directory, else ''
[more good stuff snipped]


so... you might try:

>>> import sys
>>> sys.path.append('c:/mysqldui/piddle')


I guess my point is that python itself has lots of ways to tell you
about python. Personally, when I have questions, I often find myself
trying things out in the interpreter before I even reach for the
manual.


> On another thread, how can I create a file with a .pth extension
> (notepad always appends .txt)?

Heh.. This is kinda funny. :) First, you might want to think about
getting a better text editor... One that does syntax highlighting and
whatnot might come in handy.

But.. all you have to do is go into windows explorer, find that
file and either:

   click on it and hit F2

or:

   right-click and select "rename"


Cheers,

- Michal
------------------------------------------------------------------------
www.manifestation.com  www.sabren.com  www.linkwatcher.com  www.zike.net
------------------------------------------------------------------------





More information about the Python-list mailing list