'Use-Once' Variables and Linear Objects

2011-08-02 Thread Neal Becker
I thought this was an interesting article http://www.pipeline.com/~hbaker1/Use1Var.html -- http://mail.python.org/mailman/listinfo/python-list

Re: writable iterators?

2011-06-23 Thread Neal Becker
Chris Torek wrote: > In article I wrote, in part: >>Another possible syntax: >> >>for item in container with key: >> >>which translates roughly to "bind both key and item to the value >>for lists, but bind key to the key and value for the value for >>dictionary-ish items". Then ... the OP wo

Re: writable iterators?

2011-06-23 Thread Neal Becker
Ian Kelly wrote: > On Wed, Jun 22, 2011 at 3:54 PM, Steven D'Aprano > wrote: >> Fortunately, that's not how it works, and far from being a "limitation", >> it would be *disastrous* if iterables worked that way. I can't imagine >> how many bugs would occur from people reassigning to the loop varia

Re: writable iterators?

2011-06-22 Thread Neal Becker
Steven D'Aprano wrote: > On Wed, 22 Jun 2011 15:28:23 -0400, Neal Becker wrote: > >> AFAICT, the python iterator concept only supports readable iterators, >> not write. Is this true? >> >> for example: >> >> for e in sequence: >> do s

writable iterators?

2011-06-22 Thread Neal Becker
AFAICT, the python iterator concept only supports readable iterators, not write. Is this true? for example: for e in sequence: do something that reads e e = blah # will do nothing I believe this is not a limitation on the for loop, but a limitation on the python iterator concept. Is thi

Re: cPickle -> invalid signature

2011-05-17 Thread Neal Becker
Gabriel Genellina wrote: > En Tue, 17 May 2011 08:41:41 -0300, Neal Becker > escribió: > >> What does it mean when cPickle.load says: >> RuntimeError: invalid signature >> >> Is binary format not portable? > > Are you sure that's the actual error me

cPickle -> invalid signature

2011-05-17 Thread Neal Becker
What does it mean when cPickle.load says: RuntimeError: invalid signature Is binary format not portable? -- http://mail.python.org/mailman/listinfo/python-list

Re: Get the IP address of WIFI interface

2011-05-15 Thread Neal Becker
Far.Runner wrote: > Hi python experts: > There are two network interfaces on my laptop: one is 100M Ethernet > interface, the other is wifi interface, both are connected and has an ip > address. > The question is: How to get the ip address of the wifi interface in a python > script without parsing

Re: python ioctl

2011-04-14 Thread Neal Becker
Nitish Sharma wrote: > Hi PyPpl, > For my current project I have a kernel device driver and a user-space > application. This user-space application is already provided to me, and > written in python. I have to extend this application with some addition > features, which involves communicating with

Re: argparse csv + choices

2011-03-31 Thread Neal Becker
Robert Kern wrote: > On 3/30/11 10:32 AM, Neal Becker wrote: >> I'm trying to combine 'choices' with a comma-seperated list of options, so I >> could do e.g., >> >> --cheat=a,b >> >> parser.add_argument ('--cheat'

argparse csv + choices

2011-03-30 Thread Neal Becker
I'm trying to combine 'choices' with a comma-seperated list of options, so I could do e.g., --cheat=a,b parser.add_argument ('--cheat', choices=('a','b','c'), type=lambda x: x.split(','), default=[]) test.py --cheat a error: argument --cheat: invalid choice: ['a'] (choose from 'a', 'b',

Re: argparse, tell if arg was defaulted

2011-03-15 Thread Neal Becker
Robert Kern wrote: > On 3/15/11 12:46 PM, Neal Becker wrote: >> Robert Kern wrote: >> >>> On 3/15/11 9:54 AM, Neal Becker wrote: >>>> Is there any way to tell if an arg value was defaulted vs. set on command >>>> line? >>> >>> N

Re: argparse, tell if arg was defaulted

2011-03-15 Thread Neal Becker
Robert Kern wrote: > On 3/15/11 9:54 AM, Neal Becker wrote: >> Is there any way to tell if an arg value was defaulted vs. set on command >> line? > > No. If you need to determine that, don't set a default value in the > add_argument() method. Then just check for

argparse, tell if arg was defaulted

2011-03-15 Thread Neal Becker
Is there any way to tell if an arg value was defaulted vs. set on command line? -- http://mail.python.org/mailman/listinfo/python-list

bug? mmap doesn't like 0-length files

2010-11-22 Thread Neal Becker
mmap.mmap (f.fileno(), 0, prot=mmap.PROT_READ) error: [Errno 22] Invalid argument According to http://docs.python.org/library/mmap.html, mmap on _windows_ doesn't accept 0-length file. But this was tested on linux. Is this a bug? I don't see anything in linux man-page about the underlying C

argparse subparser problem

2010-11-16 Thread Neal Becker
I want to have subparsers, but I also want to be able to say: myprogram --version and get the version # --- import argparse def stop(): pass parser = argparse.ArgumentParser() parser.add_argument ('--version', action='store_true') subparsers = parser.add_subparsers

question on ConfigParser defaults

2010-11-15 Thread Neal Becker
import ConfigParser # New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each config = ConfigParser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'}) config.read('example.cfg') print config.get('Section1', 'foo') # -> "Python is fun!" config.remove_option('Section1', 'bar') config.r

argparse '--' not working?

2010-11-12 Thread Neal Becker
It is a 'standard' behaviour that a lone '--' terminates options. argparse says: If you have positional arguments that must begin with '-' and don’t look like negative numbers, you can insert the pseudo-argument '--' which tells parse_args that everything after that is a positional argument:

strange problem with multiprocessing

2010-11-11 Thread Neal Becker
Any idea what this could be about? Traceback (most recent call last): File "run-tests-1004.py", line 48, in results = pool.map (run_test, cases) File "/usr/lib64/python2.7/multiprocessing/pool.py", line 199, in map return self.map_async(func, iterable, chunksize).get() File "/us

sigaction?

2010-11-04 Thread Neal Becker
Why doesn't python signal support sigaction? I'm interested in trying sigaction with SA_RESTART to prevent interrupted system calls. Or, would the usage of SA_RESTART within python cause other problems? -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing signal defect

2010-10-29 Thread Neal Becker
Antoine Pitrou wrote: > On Fri, 29 Oct 2010 08:12:19 -0400 > Neal Becker wrote: >> Seems multiprocessing doesn't behave well with signals: >> [...] > > By the way, could you post an issue on the tracker with instructions on > how to reproduce (including OS)?

Re: multiprocessing signal defect

2010-10-29 Thread Neal Becker
Adam Tauno Williams wrote: > On Fri, 2010-10-29 at 08:12 -0400, Neal Becker wrote: >> Seems multiprocessing doesn't behave well with signals: >> - >> from multiprocessing import Pool >> import time >> def sleep (dummy): >> time.sleep (1

multiprocessing signal defect

2010-10-29 Thread Neal Becker
Seems multiprocessing doesn't behave well with signals: --- from multiprocessing import Pool import time def sleep (dummy): time.sleep (10) if __name__ == '__main__': pool = Pool (processes=2) result = pool.map (sleep, range (4)) - start it up $ python t

Re: exception during module initialization + python3

2010-10-20 Thread Neal Becker
Neal Becker wrote: > Has behavior of exception thrown during module initialization changed with > python3? > > using boost::python, throwing a c++ exception in module initialization, I > get: > > SystemError: initialization of ldpc_45 raised unreported exception >

exception during module initialization + python3

2010-10-20 Thread Neal Becker
Has behavior of exception thrown during module initialization changed with python3? using boost::python, throwing a c++ exception in module initialization, I get: SystemError: initialization of ldpc_45 raised unreported exception I exepected to see the string associated with exception, which g

Re: Python in Linux - barrier to Python 3.x

2010-09-21 Thread Neal Becker
Ant wrote: > Hi all, > > I've just seen this: http://sheddingbikes.com/posts/1285063820.html > > Whatever you think of Zed Shaw (author of the Mongrel Ruby server and > relatively recent Python convert), he has a very good point in this. I > run Fedora 12 on my home computers, and find it far to

bool constructor is inconsistent?

2010-09-10 Thread Neal Becker
IN [3]: bool('False') Out[3]: True In [4]: int('32') Out[4]: 32 -- http://mail.python.org/mailman/listinfo/python-list

Re: argparse list

2010-09-02 Thread Neal Becker
Peter Otten wrote: import argparse def csv(value): > ... return map(int, value.split(",")) > ... p = argparse.ArgumentParser() p.add_argument("--option1", type=csv) and None p.parse_args(["--option1=1,10,37"]) Thanks! But, why the 'and None'? -- http://mail.python.

argparse list

2010-09-02 Thread Neal Becker
I'm interested in using argparse to parse a string formatted as: my_prog --option1=1,10,37 That is, a list of comma delimited values. I guess nargs almost does it, but expects options to be space-delimited. What would be the easiest approach? -- http://mail.python.org/mailman/listinfo/python

Sumatra m/l?

2010-07-10 Thread Neal Becker
Sumatra looks like an interesting project http://pypi.python.org/pypi/Sumatra/0.2 But I have some questions. Is there any mail list or forum? I can't find anything on the website. -- http://mail.python.org/mailman/listinfo/python-list

bug in parser?

2010-06-20 Thread Neal Becker
Isn't this a bug? print \" SyntaxError: unexpected character after line continuation character -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't define __call__ within __init__?

2010-03-11 Thread Neal Becker
Steven D'Aprano wrote: > On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote: > >> Want to switch __call__ behavior. Why doesn't this work? What is the >> correct way to write this? >> >> class X (object): >> def __init__(self, i): >>

Re: Can't define __call__ within __init__?

2010-03-10 Thread Neal Becker
Robert Kern wrote: > On 2010-03-10 12:23 PM, Neal Becker wrote: >> Duncan Booth wrote: >> ... >>> >>> P.S. I don't know what you did in your post but your Followup-To header >>> is pointing to a group on gmane which makes extra work for me replying.

Re: Can't define __call__ within __init__?

2010-03-10 Thread Neal Becker
Duncan Booth wrote: > Neal Becker wrote: > >> Duncan Booth wrote: >> ... >>> >>> P.S. I don't know what you did in your post but your Followup-To >>> header is pointing to a group on gmane which makes extra work for me >>> replying.

Re: Can't define __call__ within __init__?

2010-03-10 Thread Neal Becker
Duncan Booth wrote: ... > > P.S. I don't know what you did in your post but your Followup-To header is > pointing to a group on gmane which makes extra work for me replying. > Please don't do that. I'm sorry about that, there is some bad interaction between gmane's nntp- smtp gateway and python's

Re: Can't define __call__ within __init__?

2010-03-10 Thread Neal Becker
Simon Brunning wrote: > On 10 March 2010 13:12, Neal Becker wrote: >> Want to switch __call__ behavior. Why doesn't this work? What is the >> correct way to write this? >> >> class X (object): >> def __init__(self, i): >> if i == 0: >> def __

Can't define __call__ within __init__?

2010-03-10 Thread Neal Becker
Want to switch __call__ behavior. Why doesn't this work? What is the correct way to write this? class X (object): def __init__(self, i): if i == 0: def __call__ (self): return 0 else: def __call_ (self): return 1 x =

Re: multiprocessing as batch system

2010-01-21 Thread Neal Becker
Adam Tauno Williams wrote: > On Thu, 2010-01-21 at 07:13 -0500, Neal Becker wrote: >> I'm using multiprocessing as a poor man's batch system. It is working >> OK, except that it doesn't seem to do load balancing quite right. >> I have a 8-cpu machine. If

multiprocessing as batch system

2010-01-21 Thread Neal Becker
I'm using multiprocessing as a poor man's batch system. It is working OK, except that it doesn't seem to do load balancing quite right. I have a 8-cpu machine. If I start, using multiprocessing pool, calling map with more than 8 elements, it will start 8 processes. It seems, though, that whe

multiprocessing question

2010-01-18 Thread Neal Becker
I'm using multiprocessing as a crude batch queuing system, like this: import my_test_program as prog (where my_test_program has a function called 'run') def run_test (args): prog.run (args[1:]) cases = [] for t in test_conditions: args = [prog.__name__]+[more args...] cases.append (args

difflib get_close_matches improvement?

2009-12-21 Thread Neal Becker
difflib.get_close_matches looks useful. But, I don't see where it defines 'close'. Besides that, wouldn't it be much more useful if one could supply their own distance metric? -- http://mail.python.org/mailman/listinfo/python-list

use mudflap with python extensions?

2009-12-21 Thread Neal Becker
Is it possible to build python extensions using gcc's -fmudflap to check memory access? I'm not real familiar with mudflap usage, not sure if it works on building shared objects. Perhaps it requires a rebuilt python main? Hopefully not. -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: withrestart 0.2.1

2009-12-18 Thread Neal Becker
I haven't tried it, but it sounds really cool. I suppose I should expect a lot more overhead compared to try/except, since it's not built-in to python? -- http://mail.python.org/mailman/listinfo/python-list

Re: Which graph library is best suited for large graphs?

2009-12-11 Thread Neal Becker
Wolodja Wentland wrote: > On Fri, Dec 11, 2009 at 08:55 -0500, Neal Becker wrote: >> Bearophile wrote: >> > Wolodja Wentland: >> >> Which library would you choose? > >> > This one probably uses low memory, but I don't know if it works still: >&g

Re: Which graph library is best suited for large graphs?

2009-12-11 Thread Neal Becker
Bearophile wrote: > Wolodja Wentland: >> Which library would you choose? > > This one probably uses low memory, but I don't know if it works still: > http://osl.iu.edu/~dgregor/bgl-python/ > > Bye, > bearophile How about python interface to igraph? -- http://mail.python.org/mailman/listinfo/p

pep370 python 2.6?

2009-09-27 Thread Neal Becker
Is pep370 (per-user site-packages) available on 2.6? -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a local variable scope.

2009-09-18 Thread Neal Becker
markol...@gmail.com wrote: > On Sep 11, 7:36 pm, Johan Grönqvist wrote: >> Hi All, >> >> I find several places in my code where I would like to have a variable >> scope that is smaller than the enclosing function/class/module >> definition. > > This is one of the single major frustrations I have

Re: Creating a local variable scope.

2009-09-11 Thread Neal Becker
Johan Grönqvist wrote: > Hi All, > > I find several places in my code where I would like to have a variable > scope that is smaller than the enclosing function/class/module definition. > > One representative example would look like: > > -- > spam = { ... } > eggs = { ... } > > ham = (a

Re: Graph library recommendations for large graphs

2009-08-25 Thread Neal Becker
VanL wrote: > I am working on a project that will require building and querying large > graph objects (initially 8M nodes, 30-40M edges; eventually 40M nodes, > 100M edges). NetworkX seems to be the most popular, but I am concerned > that a dict representation for nodes would use too much memory -

Re: #elements of seq A in seq B

2009-08-20 Thread Neal Becker
Jan Kaliszewski wrote: > 20-08-2009 o 01:19:24 Neal Becker wrote: > >> What would be a time efficient way to count the number of occurrences of >> elements of sequence A in sequence B? (in this particular case, these >> sequences are strings, if that matters). &g

#elements of seq A in seq B

2009-08-19 Thread Neal Becker
What would be a time efficient way to count the number of occurrences of elements of sequence A in sequence B? (in this particular case, these sequences are strings, if that matters). -- http://mail.python.org/mailman/listinfo/python-list

Re: Parallelization in Python 2.6

2009-08-19 Thread Neal Becker
sturlamolden wrote: > On 18 Aug, 11:41, Stefan Behnel wrote: > >> I think the canonical answer is to use the threading module or >> (preferably) the multiprocessing module, which is new in Py2.6. >> >> http://docs.python.org/library/threading.htmlhttp://docs.python.org/library/multiprocessing.h

Re: Fast reading and unpacking of binary data (struct module)

2009-07-22 Thread Neal Becker
Daniel Platz wrote: > Hi, > > I have a Python newbie question about reading data from a binary file. > I have an huge binary file from an external program. I want to read > and process the data in this file in a reasonable time. It turns out > that the reading of the data itself and the processin

Re: proposal: add setresuid() system call to python

2009-07-20 Thread Neal Becker
Mahmoud Abdelkader wrote: > Why don't you write a python extension module? This is a perfect > opportunity for that. > I think having a module just for one system call is a bit silly. Why not add to os module? -- http://mail.python.org/mailman/listinfo/python-list

Re: unladen swallow: python and llvm

2009-06-08 Thread Neal Becker
bearophileh...@lycos.com wrote: > s...@pobox.com: >> Why not just write extension modules in C then? > > In the past I have used some C for that purpose, but have you tried > the D language (used from Python with Pyd)? It's way better, > especially if you for example use libs similar to itertools

itertools question

2009-05-14 Thread Neal Becker
Is there any canned iterator adaptor that will transform: in = [1,2,3] into: out = [(1,2,3,4), (5,6,7,8),...] That is, each time next() is called, a tuple of the next N items is returned. -- http://mail.python.org/mailman/listinfo/python-list

Re: jinja arbitrary code expressions?

2009-04-29 Thread Neal Becker
Neal Becker wrote: > Can jinja templates contain arbitrary python code? > > In mako, I could do (for example): > > from mako.template import Template > > mytemplate = Template(''' > <%! > from math import sin, pi > %> > hell

jinja arbitrary code expressions?

2009-04-29 Thread Neal Becker
Can jinja templates contain arbitrary python code? In mako, I could do (for example): from mako.template import Template mytemplate = Template(''' <%! from math import sin, pi %> hello ${name}! ${x}**2 = ${x**2} % for i in xrange (10): w[${i}] = ${sin (pi/4*i)} % endfor ''') d = {'na

Re: Presentation software for Python code

2009-04-23 Thread Neal Becker
John Reid wrote: > > > Scott David Daniels wrote: >> Michael Hoffman wrote: >> You might take a look at Crunchy, and just do up your talk there. >> Crunchy is a Python program that combines an otherwise static html >> document with an interactive Python session within a browser >> http://cod

Re: more fun with iterators (mux, demux)

2009-04-08 Thread Neal Becker
pataphor wrote: > On 07 Apr 2009 02:05:59 GMT > Steven D'Aprano wrote: > >> The demuxer can't be an iterator, since it needs to run through the >> entire collection. > > Then your demuxer obviously cannot handle infinite sequences. > >> def demux(it, n): >> collectors = [[] for i in xrang

more fun with iterators (mux, demux)

2009-04-06 Thread Neal Becker
I'm trying to make a multiplexor and demultiplexor, using generators. The multiplexor will multiplex N sequences -> 1 sequence (assume equal length). The demultiplexor will do the inverse. The mux seems easy enough: --- def mux (*ranges): iterables = [iter (r) for r i

Re: PEP 382: Namespace Packages

2009-04-02 Thread Neal Becker
While solving this problem, is it possible also to address an issue that shows up in certain distributions? I'm specifically talking about the fact that on Redhat/Fedora, we have on x86_64 both /usr/lib/pythonxx/ and /usr/lib64/pythonxx. The former is supposed to be for non-arch specific pack

simple iterator question

2009-04-02 Thread Neal Becker
How do I interleave 2 sequences into a single sequence? How do I interleave N sequences into a single sequence? -- http://mail.python.org/mailman/listinfo/python-list

Re: argument problem in optparse

2009-03-21 Thread Neal Becker
Qian Xu wrote: > Hi All, > > I have a problem with OptParse. > I want to define such an arugument. It can accept additional value or no > value. > > "myscript.py --unittest File1,File2" > "myscript.py --unittest" > > Is it possible in OptParse? I have tried several combination. But ... > > >

multiprocessing + atexit

2009-03-12 Thread Neal Becker
I have some code that uses atexit (remove old log files). Before converting to use multiprocessing, it worked. Since converting, it seems to not be running the atexit code (old log files are not removed). Any known issues with multiprocessing + atexit? -- http://mail.python.org/mailman/listi

Re: This should be a simple question...

2009-03-06 Thread Neal Becker
Bruno Desthuilliers wrote: > Neal Becker a écrit : >> Maybe I'm missing something obvious here >> >> def A (...): >> #set a bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >&

This should be a simple question...

2009-03-06 Thread Neal Becker
Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setting of these variables

looking for template package

2009-03-03 Thread Neal Becker
I'm looking for something to do template processing. That is, transform text making various substitutions. I'd like to be able to do substitutions that include python expressions, to do arithmetic computations within substitutions. I know there are lots of template packages, but most seem aim

Re: logging and daemons

2009-02-16 Thread Neal Becker
Garrett Cooper wrote: > On Mon, Feb 16, 2009 at 5:15 AM, Fernando M. Maresca > wrote: >> Hello, thanks for the answer. >> >> On Mon, Feb 16, 2009 at 05:07:45AM -0800, Garrett Cooper wrote: >>> You can actually set sys.std[err|out] to your ?file? descriptor of >>> choice in python (it has to have

mmap doesn't support weakref

2009-01-07 Thread Neal Becker
r = weakref.ref (m) TypeError: cannot create weak reference to 'mmap.mmap' object I believe it would be very useful for mmap object to support weakref. Can it be added? -- http://mail.python.org/mailman/listinfo/python-list

mmap only supports string

2009-01-07 Thread Neal Becker
Problem is, AFAIK a string can only be created as a copy of some other data. Say I'd like to take some large object and read/write to/from mmap object. A good way to do this would be the buffer protocol. Unfortunately, mmap only supports string. A string could only be created after copying t

buffer creates only read-only buffer?

2009-01-07 Thread Neal Becker
m = mmap.mmap (fd, 64, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) b2 = buffer (m) print b2 Why read-only? Why doesn't 'buffer' allow creation of read-write? Should buffer constructor take an additional optional arg for specifying this? Doc doesn't say anything about the fa

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Neal Becker
Steven D'Aprano wrote: > BTW Neal, your posts aren't word wrapped. When I read your posts, I get > each paragraph as one extremely LONG line scrolling way out to the side. > That's against the Internet standards for both email and Usenet, so could > you please configure your client to word-wrap at

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Neal Becker
Mel wrote: > Neal Becker wrote: > >> Tino Wildenhain wrote: >> >>> Neal Becker wrote: >>>> Reading some FAQ, I see that __str__ is "meant for human eyes". >>>> >>>> But it seems that: >>>> class X(obje

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Neal Becker
Diez B. Roggisch wrote: > Neal Becker wrote: > >> Tino Wildenhain wrote: >> >>> Neal Becker wrote: >>> ... >>>>>> So if __str__ is "meant for human eyes", then why isn't print using >>>>>> it! >>>>

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Neal Becker
Tino Wildenhain wrote: > Neal Becker wrote: > ... >>>> So if __str__ is "meant for human eyes", then why isn't print using it! >>> it is: >>> >>> > print x >>> str >>> >>> but dict just uses repr() for

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Neal Becker
Tino Wildenhain wrote: > Neal Becker wrote: >> Reading some FAQ, I see that __str__ is "meant for human eyes". >> >> But it seems that: >> class X(object): >> def __str__(self): >> return "str" >> def __repr__(self)

confused about __str__ vs. __repr__

2008-12-18 Thread Neal Becker
Reading some FAQ, I see that __str__ is "meant for human eyes". But it seems that: class X(object): def __str__(self): return "str" def __repr__(self): return "repr" x = X() d = {0 : x} print d {0: repr} So if __str__ is "meant for human eyes", then why isn't print using

Re: OpenOpt 0.21 (free optimization framework)

2008-12-15 Thread Neal Becker
Is it easy_install able? I got: sudo easy_install -U openopt Searching for openopt Reading http://pypi.python.org/simple/openopt/ Couldn't find index page for 'openopt' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading http://pypi.python.org/simple/ Reading http:/

subprocess to pipe through several processes?

2008-12-13 Thread Neal Becker
How would I use suprocess to do the equivalent of: cat - | program_a | program_b -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Neal Becker
Daniel Fetchinson wrote: > Hi folks, > > The story of the explicit self in method definitions has been > discussed to death and we all know it will stay. However, Guido > himself acknowledged that an alternative syntax makes perfect sense > and having both (old and new) in a future version of pyt

Re: problem with optparse

2008-12-02 Thread Neal Becker
Robert Kern wrote: > Neal Becker wrote: >> This example is right out of python library reference. What's wrong >> here? >> >> import optparse >> >> def store_value(option, opt_str, value, parser): >> setattr(parser.values, option.

problem with optparse

2008-12-02 Thread Neal Becker
This example is right out of python library reference. What's wrong here? import optparse def store_value(option, opt_str, value, parser): setattr(parser.values, option.dest, value) parser = optparse.OptionParser() parser.add_option("--foo", action="callback", callback=sto

Re: optimization

2008-12-02 Thread Neal Becker
Robert Kern wrote: > Neal Becker wrote: >> Arnaud Delobelle wrote: >> >>> Neal Becker <[EMAIL PROTECTED]> writes: >>> >>>> I noticed in some profiling, that it seems that: >>>> >>>> def Func (): >>>> def

Re: optimization

2008-12-01 Thread Neal Becker
Arnaud Delobelle wrote: > Neal Becker <[EMAIL PROTECTED]> writes: > >> I noticed in some profiling, that it seems that: >> >> def Func (): >> def something(): >> ... >> >> It appears that if Func is called many times, this nested func &

optimization

2008-12-01 Thread Neal Becker
I noticed in some profiling, that it seems that: def Func (): def something(): ... It appears that if Func is called many times, this nested func definition will cause significant overhead. Is this true? I guess I've become accustomed to decent compilers performing reasonable transforma

Re: Daemon and logging - the best approach?

2008-11-07 Thread Neal Becker
Lech Karol Pawłaszek wrote: > Hello. > > I'm trying to make a daemon and I want to log to a file its activity. > I'm using logging module with a configuration file for it (loaded via > fileConfig()). > > And now I want to read logging config file before daemonize the program > because the file m

@contextlib question

2008-11-07 Thread Neal Becker
http://www.python.org/doc/2.5.2/lib/module-contextlib.html has this example: from contextlib import contextmanager @contextmanager def tag(name): print "<%s>" % name yield print "" % name contexlib.contextmanager doc string (2.5.1) says: Typical usage: @contextmanager

email for gpg encrypted?

2008-11-06 Thread Neal Becker
I know we have 'email' module. Is there something I could use to produce properly mime-encoded gpg encrypted messages? -- http://mail.python.org/mailman/listinfo/python-list

Re: add method to class dynamically?

2008-10-22 Thread Neal Becker
Diez B. Roggisch wrote: > BTW, could you stop setting the followup-to to a non-existing (at least > for a standard newsreader) gmane-newsgroup? > Is this any better? -- http://mail.python.org/mailman/listinfo/python-list

add method to class dynamically?

2008-10-22 Thread Neal Becker
I have a class (actually implemented in c++ using boost::python). For an instance of this class, 'r', I'd like to support len (r). I don't want to add it to the c++ code, because this is a unique situation: this class should not normally support len(). So I try: r = ring_int (10) r.__len__ =

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Neal Becker
Aaron "Castironpi" Brady wrote: > On Sep 23, 6:52 pm, Neal Becker <[EMAIL PROTECTED]> wrote: >> In hindsight, I am disappointed with the choice of conditional syntax. I >> know it's too late to change. The problem is >> >> y = some thing or ot

python syntax for conditional is unfortunate

2008-09-23 Thread Neal Becker
In hindsight, I am disappointed with the choice of conditional syntax. I know it's too late to change. The problem is y = some thing or other if x else something_else When scanning this my eye tends to see the first phrase and only later notice that it's conditioned on x (or maybe not notice

Re: posix semaphore support?

2008-08-29 Thread Neal Becker
Christian Heimes wrote: > Neal Becker wrote: >> Is there a posix semaphore wrapper for python? >> >> Would that be a good addition? > > The threading module provides a high level interface to native > semaphores, e.g. pthread. > > Christian > Does th

posix semaphore support?

2008-08-29 Thread Neal Becker
Is there a posix semaphore wrapper for python? Would that be a good addition? -- http://mail.python.org/mailman/listinfo/python-list

Re: python-mode is missing the class browser

2008-08-08 Thread Neal Becker
>Alexander Schmolck wrote: > "Adam Jenkins" <[EMAIL PROTECTED]> writes: > >> On Fri, Aug 8, 2008 at 7:32 AM, Michele Simionato >> <[EMAIL PROTECTED]> wrote: >>> On Aug 7, 5:55 pm, Alexander Schmolck <[EMAIL PROTECTED]> wrote: >> ... >>> >>> I have solved by using ipython.el which was already inst

bbfreeze problem

2008-08-08 Thread Neal Becker
Any ideas on this? bb-freeze test5-coded-pre.py WARNING: found xml.sax in multiple directories. Assuming it's a namespace package. (found in /usr/lib64/python2.5/site-packages/_xmlplus/sax, /usr/lib64/python2.5/xml/sax) *** applied recipe_matplotlib: using the backend_qt4agg matplotlib backend

Find class of an instance?

2008-08-06 Thread Neal Becker
Sounds simple, but how, given an instance, do I find the class? -- http://mail.python.org/mailman/listinfo/python-list

Help with mechanize

2008-08-06 Thread Neal Becker
I'm trying to use mechanize to read for a M$ mail server. I can get past the login page OK using: import mechanize b = mechanize.Browser() b.open ('https://mail.hughes.com/owa/auth/logon.aspx?url=https://mail.hughes.com/OWA/&reason=0') b.select_form(nr=0) b['username']='myname' b['password']='

Re: decorator to prevent adding attributes to class?

2008-07-11 Thread Neal Becker
Robert Bossy wrote: > class Foo(Freezeable): > def __init__(self): > self.bar = 42 > self.freeze() # ok, we set all variables, no more from here > > > x = Foo() > print x.bar > x.bar = -42 > print x.bar > x.baz = "OMG! A typo!" > Pretty nice, but unfortunately the subclass has to remember to c

<    1   2   3   >