Re: Autocompletion in interactive mode doesn't work in 2.5.1

2007-06-12 Thread jitudon
On Jun 12, 9:36 am, "Papalagi Pakeha" <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> How can I turn on autocompletion when I push  in python 2.5.1
> interactive mode? E.g. to give me a list of all methods and attributes
> of a given object.
>
> It works great on my Linux / Ubuntu 7.04 installation but doesn't work
> on Solaris 10 (x86). I have libreadline.so and libncurses.so installed
> and "import readline" is executed during startup, but  still
> doesn't work. ArrowUp and ArrowDown however work and I can browse the
> history of commands so I believe readline is installed and loaded
> correctly.
>
> Any hints?
>
> Thanks
>
> PaPa

http://docs.python.org/lib/module-rlcompleter.html

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


Re: Want to learn Python

2007-06-15 Thread jitudon
On Jun 15, 4:41 pm, Amol <[EMAIL PROTECTED]> wrote:
> Hi, I want to learn Python in less than a month which resources should
> I use. I prefer to read books . Please give me a list of *recognized*
> resources. Thank You all

http://python.org/doc/

JItendra Nair

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


Re: How to close a program I execute with subprocess.Popen?

2007-07-05 Thread jitudon
On Jun 29, 6:36 pm, [EMAIL PROTECTED] wrote:
> I'm writing a program which has to execute a command, get its output
> and show it on a treeview.
> This command runs for a very long time.
> I want to end the execution of the command when the user closes my
> application.
>
> Right now I'm using an object my_child of type subprocess.Popen to
> execute the command, inside a thread with an infinite loop where we
> constantly ask for its output.
>
> To end the program when the user closes the application, I send a
> SIGTERM to the process with pid my_child.pid using os.kill. But I also
> have to send a SIGTERM to my_child.pid + 1 because my_child.pid is the
> pid of /bin/sh -c which is the one which calls the command, because
> when I try to run Popen with shell=False, it sends an exception and
> says the file or directory doesn't exist.
>
> Anyone knows of a better way to close the command than using a
> SIGTERM? I just can't help myself thinking this is an ugly dirty hack.

As nick pointed out use process group's .
I use the  "preexec_fn" keyword argument to Popen and "os.setsid()"
call's side effect
to make process groups and then os.killpg() to send the signal to
process groups.

child = Popen( cmd , preexec_fn = os.setsid )
os.killpg( child.pid,signal.SIGINT)

Regards
jitu




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


stdlib doc for logger.findCaller() needs update.

2007-05-23 Thread jitudon
The logger objects findCaller() method  is returning a "3" element
tuple instead of "2" two as
documented in the 2.4.4 Python Library Reference .DocString is showing
it correctly.

findCaller()
Finds the caller's source filename and line number. Returns the
filename and line number as a 2-element tuple.

[EMAIL PROTECTED] python]$ python
Python 2.4.4 (#1, Feb  2 2007, 17:43:17)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.basicConfig()
>>> logger = logging.getLogger()
>>> help(logger.findCaller)
Help on method findCaller in module logging:

findCaller(self) method of logging.RootLogger instance
Find the stack frame of the caller so that we can note the source
file name, line number and function name.

>>> logger.findCaller()
('', 1, '?')
>>>

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