>From ESR's "Why python?"
b = a.keys(); b.sort()
Two statements, one line. Doesn't create an incidental copy the way
sorted does but I'm not sure how much you like to jam on one line.
Cheers,
Aaron
--
http://mail.python.org/mailman/listinfo/python-list
> One way is to check the length of each dimension. Does any body
> know a simpler way?
No need to check the length of the list:
"""
>>> foo = [0, 1, 2, [3, 4, 5, 6, 7, [8, 9, 10]]]
>>> isInNested(0, foo)
True
>>> isInNested(11, foo)
False
>>> isInNested(3, foo)
True
>>> isInNested(8, foo)
True
""
> Only when the program has executed and the output available, subprocess can
> read through PIPE's stdout it seems ( not at any other time).
> With killing, I loose the output.
This is untrue.
>>> process.stdout.read() # Blocks until end of stream.
>>> process.stdout.read(1) # Reads one character
> How should I handle these kind of commands (ping 127.0.0.1) with
> subprocess module. I am using subprocess, instead of os.system because
> at anypoint in time, I need access to stdout and stderr of execution.
Ping, for one, allows you to set an upper bound on how long it runs
(the -c option).
On Jun 21, 6:32 pm, Ratko <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a python gui app that launches multiple applications using
> subprocess.Popen class and prints their output in the gui (using
> PIPEs, threads and wxPython). Everything works great but the problem
> is that some applications
> ...(if it is possible) how can I get, from method "called", the name
> of function/method that called it (in this case "caller")?
The traceback module will give you access to the call stack.
>>> import traceback
>>> def foo():
... return traceback.extract_stack()
...
>>> def bar():
...
On Mar 19, 10:30 pm, "cjl" <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I am trying to screen scrape some stock data from yahoo, so I am
> trying to use urllib2 to retrieve the html and beautiful soup for the
> parsing.
>
> Maybe (most likely) I am doing something wrong, but when I use
> urllib2.urlopen to
On Mar 19, 9:42 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote:
> On Mar 19, 9:25 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > En Mon, 19 Mar 2007 20:46:56 -0300, Luis M. González <[EMAIL PROTECTED]>
> > escribió:
>
> > > What I want now is execute the script I just created.
> >
Try looking into logging.Filters:
http://docs.python.org/lib/node358.html
An example:
import logging
class InfoFilter(logging.Filter):
def filter(self, record):
return record.levelno == 20
if __name__ == "__main__":
logger = logging.getLogger()
hdlr = log