Re: cProfile for python 2.4

2008-03-29 Thread ptrk
On Mar 28, 3:50 pm, David Pratt <[EMAIL PROTECTED]> wrote:
> I'd like to compile cProfile for python 2.4. Where can I get it to do
> this? I realize it is part of python 2.5. Many thanks.

can you use cProfile's predecessor, profile?

http://docs.python.org/lib/module-profile.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Files, directories and imports - relative to the current directory only

2008-03-25 Thread ptrk . mcm
On Mar 25, 11:27 am, ptn <[EMAIL PROTECTED]> wrote:
> Hello, group.
>
> I can only read files and import modules that are in the same
> directory
> as the one my script is.  Here is a test script (path.py):
>
> import os
> import uno  # some module I wrote
>
> print list(os.walk('~/hacking/python'))
> f = open('~/read/foo.txt')
> print f.read()
>
> And here is the output:
>
> Traceback (most recent call last):
>   File "path.py", line 2, in 
> import uno
> ImportError: No module named uno
>
> If I comment that import, the output becomes this:
>
> []
> Traceback (most recent call last):
>   File "path.py", line 4, in 
> f = open('~/read/foo.txt')
> IOError: [Errno 2] No such file or directory: '~/read/foo.txt'
>
> (Notice the empty list at the beginning, that would be the output of
> os.walk().)
>
> I have added this line to my .bashrc:
> export PYTHONPATH=$PYTHONPATH:~/hacking/python
> I thought that by doing so all the scripts found in that directory and
> all it's children would be available for import, but that doesn't seem
> to be the case.

i'm not sure why you are unable to import uno (assuming uno is at ~/
hacking/python/uno.py) after exporting the PYTHONPATH variable. an
alternative way to incorporate uno is to change sys.path, the list of
search paths

 import sys
 sys.path.append(os.path.expanduser('~/hacking/python'))
 import uno

-- 
http://mail.python.org/mailman/listinfo/python-list