Re: question of style

2009-07-02 Thread Lie Ryan
Simon Forman wrote: > Hey I was hoping to get your opinions on a sort of minor stylistic > point. > These two snippets of code are functionally identical. Which would you > use and why? If self is an object (and it must have been), it would be preferrable to set self.higher and self.lower to a kno

Re: Sequence splitting

2009-07-02 Thread Rickard Lindberg
> I tried posting on python-ideas and received a "You are not allowed to > post to this mailing list" reply. Perhaps because I am posting through > Google groups? Or maybe one must be an approved member to post? If you got an "awaiting moderator approval" message you post might appear on the list

Re: question of style

2009-07-02 Thread Lie Ryan
Paul Rubin wrote: > Tim Harig writes: >> That being the case, it might be a good idea either to handle the situation >> and raise an exception or add: >> >> assert self.lower <= self.higher >> >> That way an exception will be raised if there is an error somewhere else >> in the code rather then si

ANNOUNCE: libmsgque 3.4

2009-07-02 Thread Andreas Otto
Dear Users, I would like to provide a new !! Major Feature Release !! of >>> LibMsgque (3.4) <<< This Release Introduce a new technology called >>> Master / Slave - Link <<< and is used to create, mange and configure a MESH of node's (process or thread) distributed o

Re: question of style

2009-07-02 Thread Lie Ryan
Lie Ryan wrote: > Tim Harig wrote: >>> Speaking only to the style issue, when I've wanted to do something like >>> that, I find: >>>if self.higher is None is self.lower: >>> more readable, by making clear they are both being compared to a >>> constant, rather than compared to each other. >>

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 8:17 pm, "Pablo Torres N." wrote: > > This sounds like it belongs to the python-ideas list.  I suggest > posting there for better feedback, since the core developers check > that list more often than this one. I tried posting on python-ideas and received a "You are not allowed to post t

Re: question of style

2009-07-02 Thread Lie Ryan
Paul Rubin wrote: > Generally, having a special > value like None to denote a missing datum was considered standard > practice a few decades ago, I guess in python, None as the missing datum idiom is still quite prevalent: def cat_list(a=None, b=None): # poor man's list concatenation if

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 9:40 pm, "Pablo Torres N." wrote: > > If it is speed that we are after, it's my understanding that map and > filter are faster than iterating with the for statement (and also > faster than list comprehensions).  So here is a rewrite: > > def split(seq, func=bool): >         t = filter(fu

Re: Sequence splitting

2009-07-02 Thread Gabriel Genellina
En Fri, 03 Jul 2009 01:58:22 -0300, > escribió: "Pablo Torres N." writes: def split(seq, func=bool): t = filter(func, seq) f = filter(lambda x: not func(x), seq) return list(t), list(f) That is icky--you're calling func (which might be slow) twice instead of once on e

Re: question of style

2009-07-02 Thread Lie Ryan
Simon Forman wrote: > On Jul 2, 3:57 pm, Scott David Daniels wrote: >> Duncan Booth wrote: >>> Simon Forman wrote: ... if self.higher is self.lower is None: return ... >>> As a matter of style however I wouldn't use the shorthand to run two 'is' >>> comparisons together, I'd write

Re: question of style

2009-07-02 Thread Lie Ryan
Tim Harig wrote: >> Speaking only to the style issue, when I've wanted to do something like >> that, I find: >>if self.higher is None is self.lower: >> more readable, by making clear they are both being compared to a >> constant, rather than compared to each other. > > By comparing them to

Re: Sequence splitting

2009-07-02 Thread Paul Rubin
"Pablo Torres N." writes: > def split(seq, func=bool): > t = filter(func, seq) > f = filter(lambda x: not func(x), seq) > return list(t), list(f) That is icky--you're calling func (which might be slow) twice instead of once on every element of the seq. -- http://mail.python.org

Re: question of style

2009-07-02 Thread Paul Rubin
Simon Forman writes: > > Yes, but the concept of null pointers is considered kludgy these days. > Seriously? "kludgy"? (I really AM getting old.) http://math.andrej.com/2009/04/11/on-programming-language-design/ discusses the issue (scroll down to "Undefined values" section). > Well I wouldn

Re: getting rid of —

2009-07-02 Thread Simon Forman
On Jul 2, 4:31 am, Tep wrote: > On 2 Jul., 10:25, Tep wrote: > > > > > On 2 Jul., 01:56, MRAB wrote: > > > > someone wrote: > > > > Hello, > > > > > how can I replace '—' sign from string? Or do split at that character? > > > > Getting unicode error if I try to do it: > > > > > UnicodeDecodeErro

Re: Sequence splitting

2009-07-02 Thread Pablo Torres N.
On Thu, Jul 2, 2009 at 23:34, Brad wrote: > On Jul 2, 9:08 pm, Paul Rubin wrote: >> Brad writes: >> > On Jul 2, 8:14 pm, Paul Rubin wrote: >> > > schickb writes: >> > > > def split(seq, func=None): >> > > >     if func is None: >> > >

Re: Config files with different types

2009-07-02 Thread Lawrence D'Oliveiro
In message , Zach Hobesh wrote: > I want to be able to look at the value and determine what type it > SHOULD be. Right now, configs['overwrite'] = 'true' (a string) when > it might be more useful as a boolean. Typically the type should be what you expect, not what is given. For example, it doe

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 9:08 pm, Paul Rubin wrote: > Brad writes: > > On Jul 2, 8:14 pm, Paul Rubin wrote: > > > schickb writes: > > > > def split(seq, func=None): > > > >     if func is None: > > > >         func = bool > > > >     t, f = [], [] >

Re: Multi thread reading a file

2009-07-02 Thread ryles
On Jul 2, 11:55 pm, Paul Rubin wrote: > Yeah, it should allow supplying a predicate instead of using == on > a value.  How about (untested): > >    from itertools import * >    ... >    for row in takewhile(lambda x: x is sentinel, >                          starmap(i

Re: Sequence splitting

2009-07-02 Thread Paul Rubin
Brad writes: > On Jul 2, 8:14 pm, Paul Rubin wrote: > > schickb writes: > > > def split(seq, func=None): > > >     if func is None: > > >         func = bool > > >     t, f = [], [] > > >     for item in seq: > > >         if func(item): > > >             t.append(

Re: multiprocessing: pool with blocking queue

2009-07-02 Thread ryles
On Jul 2, 11:09 am, masher wrote: > My questions, then, is: Is there a more elegant/pythonic way of doing > what I am trying to do with the current Pool class? Another thing you might try is to subclass Pool and add an apply_async () wrapper which would wait for _taskqueue.qsize() to reach the de

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 8:17 pm, "Pablo Torres N." wrote: > On Jul 2, 9:56 pm, schickb wrote: > > > I have fairly often found the need to split a sequence into two groups > > based on a function result. > > This sounds like it belongs to the python-ideas list.  I suggest > posting there for better feedback, si

Re: Multi thread reading a file

2009-07-02 Thread Paul Rubin
"Gabriel Genellina" writes: > We're talking about the iter() builtin behavior, and that uses == > internally. Oh, I see. Drat. > It could have used an identity test, and that would be better for this > specific case. But then iter(somefile.read, '') wouldn't work. Yeah, it should allow supplyi

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 8:14 pm, Paul Rubin wrote: > schickb writes: > > def split(seq, func=None): > >     if func is None: > >         func = bool > >     t, f = [], [] > >     for item in seq: > >         if func(item): > >             t.append(item) > >         else: > >      

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 9:30 pm, Paul Rubin wrote: > Simon Forman writes: > > This code is part of a delete() method for a binary tree > > implementation. "None" is used to simulate a NULL pointer. In the case > > where both children are non-None the code goes on to handle that. >

Re: Multi thread reading a file

2009-07-02 Thread Gabriel Genellina
En Fri, 03 Jul 2009 00:15:40 -0300, > escribió: ryles writes: >    sentinel = object() I agree, this is cleaner than None. We're still in the same boat, though, regarding iter(). Either it's 'item == None' or 'item == object ()' Use "item is sentinel". We're talking about the iter() bui

Re: Sequence splitting

2009-07-02 Thread Pablo Torres N.
On Jul 2, 9:56 pm, schickb wrote: > I have fairly often found the need to split a sequence into two groups > based on a function result. Much like the existing filter function, > but returning a tuple of true, false sequences. In Python, something > like: > > def split(seq, func=None): >     if fu

Re: Multi thread reading a file

2009-07-02 Thread Paul Rubin
ryles writes: > >    sentinel = object() > > I agree, this is cleaner than None. We're still in the same boat, > though, regarding iter(). Either it's 'item == None' or 'item == object ()' Use "item is sentinel". -- http://mail.python.org/mailman/listinfo/python-list

Re: Sequence splitting

2009-07-02 Thread Pablo Torres N.
On Thu, Jul 2, 2009 at 21:56, schickb wrote: > I have fairly often found the need to split a sequence into two groups > based on a function result. Much like the existing filter function, > but returning a tuple of true, false sequences. In Python, something > like: > > def split(seq, func=None): >

Re: dealloc function in python extend c module

2009-07-02 Thread Philip Semanchuk
On Jul 2, 2009, at 9:28 PM, Gabriel Genellina wrote: En Thu, 02 Jul 2009 14:22:53 -0300, Philip Semanchuk escribió: Hi Shen, I'm no expert on Python memory management, but since no once else has answered your question I'll tell you what I *think* is happening. Python doesn't delete objec

Re: Sequence splitting

2009-07-02 Thread Paul Rubin
schickb writes: > def split(seq, func=None): > if func is None: > func = bool > t, f = [], [] > for item in seq: > if func(item): > t.append(item) > else: > f.append(item) > return (t, f) untested: def split(seq, func=bool):

Re: Multi thread reading a file

2009-07-02 Thread ryles
On Jul 2, 10:20 pm, Paul Rubin wrote: > ryles writes: > > >>> # Oh... yeah. I really *did* want 'is None' and not '== None' > > >>> which iter() will do. Sorry guys! > > > Please don't let this happen to you too ;) > > None is a perfectly good value to put onto a que

Re: Python 3.0 (pinin' for the fjords)

2009-07-02 Thread Alan G Isaac
Using the 3.1 Windows installer, I chose that I did not want the extensions registered, and the installer unregistered the .py and .pyw extensions (which I had wanted to keep associated with Python 2.6). Is this intentional? Alan Isaac PS I already fixed the problem. My question is about intent

Sequence splitting

2009-07-02 Thread schickb
I have fairly often found the need to split a sequence into two groups based on a function result. Much like the existing filter function, but returning a tuple of true, false sequences. In Python, something like: def split(seq, func=None): if func is None: func = bool t, f = [], [

Re: Adding an object to the global namespace through " f_globals" is that allowed ?

2009-07-02 Thread ryles
On Jul 2, 1:25 am, Terry Reedy wrote: > > The next statement works, > > but I'm not sure if it will have any dramatical side effects, > > other than overruling a possible object with the name A > > > def some_function ( ...) : > > A = object ( ...) > > sys._getframe(1).f_globals [ Name ]

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-02 Thread Benjamin Peterson
ryles gmail.com> writes: > > This reminds me. Would anyone object to adding a sentence to > http://docs.python.org/library/stringio.html#module-cStringIO just to > mention that attributes cannot be added to a cStringIO, like such: That's true of almost all types that are implemented in C. -

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-02 Thread Simon Forman
On Wed, Jul 1, 2009 at 7:48 AM, Barak, Ron wrote: > Hi, > > I think I'm up against a limitation in cStringIO.StringIO(), but could not > find any clues on the web, especially not in > http://docs.python.org/library/stringio.html. > > What I have is the following function: > >     def concatenate_fi

Re: stringio+tarfile

2009-07-02 Thread Dave Angel
superpollo wrote: why the following does not work? can you help me correct (if possible)? 1 import tarfile 2 import StringIO 3 sf1 = StringIO.StringIO("one\n") 4 sf2 = StringIO.StringIO("two\n") 5 tf = StringIO.StringIO() 6 tar = tarfile.open(tf , "w")

Re: Is Psyco good for Python 2.6.1?

2009-07-02 Thread Bearophile
Russ P.: Python works well to me on Python 2.6+, on Windows. You can find a compiled version too, around. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: What are the limitations of cStringIO.StringIO() ?

2009-07-02 Thread ryles
This reminds me. Would anyone object to adding a sentence to http://docs.python.org/library/stringio.html#module-cStringIO just to mention that attributes cannot be added to a cStringIO, like such: % import cStringIO, StringIO % StringIO.StringIO().value = 1 % cStringIO.StringIO().value = 1 Traceb

Re: Multi thread reading a file

2009-07-02 Thread Paul Rubin
ryles writes: > >>> # Oh... yeah. I really *did* want 'is None' and not '== None' > >>> which iter() will do. Sorry guys! > > Please don't let this happen to you too ;) None is a perfectly good value to put onto a queue. I prefer using a unique sentinel to mark the end of the stream: sentin

Re: Multi thread reading a file

2009-07-02 Thread ryles
On Jul 2, 6:10 am, "Gabriel Genellina" wrote: > En Wed, 01 Jul 2009 12:49:31 -0300, Scott David Daniels   > escribió: > > These loops work well with the two-argument version of iter, > > which is easy to forget, but quite useful to have in your bag > > of tricks: > > >      def convert(in_queue,

Re: A question about fill_free_list(void) function

2009-07-02 Thread Gabriel Genellina
En Thu, 02 Jul 2009 07:55:42 -0300, Pedram escribió: On Jul 2, 1:11 pm, Peter Otten <__pete...@web.de> wrote: [snip explanation of strange pointer manipulations in the C code of the integer type] Oh, I got it! What a wonderful implementation! :o Well, I would not say it's "wonderful"...

Re: dealloc function in python extend c module

2009-07-02 Thread Gabriel Genellina
En Thu, 02 Jul 2009 14:22:53 -0300, Philip Semanchuk escribió: On Jul 2, 2009, at 2:11 AM, Shen, Yu-Teh wrote: I create my extend type something like http://www.python.org/doc/current/extending/newtypes.html. And my type has a member which is a pointer point to my allocate memory ( no ref co

Re: question of style

2009-07-02 Thread Paul Rubin
Simon Forman writes: > This code is part of a delete() method for a binary tree > implementation. "None" is used to simulate a NULL pointer. In the case > where both children are non-None the code goes on to handle that. > > None is a "unitary" or "singleton" value, so "is" is the right > compari

Re: stringio+tarfile

2009-07-02 Thread Gabriel Genellina
En Thu, 02 Jul 2009 17:57:49 -0300, superpollo escribió: why the following does not work? can you help me correct (if possible)? Explain "does not work" please. Does it raise an exception? Which one? Please post the complete traceback. You don't get the expected result? Tell us what did you e

Re: how to spawn a process under different user

2009-07-02 Thread Gabriel Genellina
En Thu, 02 Jul 2009 19:27:05 -0300, Tim Harig escribió: On 2009-07-02, sanket wrote: sanket wrote: > I am trying to use python's subprocess module to launch a process. > but in order to do that I have to change the user. I am using python 2.4 on centos. I have never done this in python;

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-02 Thread ryles
> You can go ahead and implement a __del__() method. It will often work in > CPython, but you get no guarantees, especially when you have reference > cycles and with other Python implementations that don't use refcounting. And for resources whose lifetime is greater than your process (e.g. a file)

Re: question of style

2009-07-02 Thread Paul Rubin
Tim Harig writes: > > Well, that assert is not right because you have to handle the case > > where one of the values is None... > Sorry, it worked under 2.5: Well, it didn't crash under 2.5. Whether the result was correct is a different question. > None seems to have been evaluated less the

Re: Is Psyco good for Python 2.6.1?

2009-07-02 Thread Mensanator
On Jul 2, 5:41 pm, "Russ P." wrote: > I need to speed up some Python code, and I discovered Psyco. However, > the Psyco web page has not been updated since December 2007. Before I > go to the trouble of installing it, does anyone know if it is still > good for Python 2.6.1? Thanks. Go back to the

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 3:57 pm, Scott David Daniels wrote: > Duncan Booth wrote: > > Simon Forman wrote: > >> ... > >> if self.higher is self.lower is None: return > >> ... > > As a matter of style however I wouldn't use the shorthand to run two 'is' > > comparisons together, I'd write that out in full if it

Python 3.0 (pinin' for the fjords)

2009-07-02 Thread Barry Warsaw
Now that Python 3.1 is out, it seems there's been some confusion as to whether there will be one last Python 3.0 release, i.e. Python 3.0.2. At the PyCon 2009 language summit it was decided that there will be *no* Python 3.0.2. Python 3.0 is different than all other releases. There will b

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 4:08 pm, Erik Max Francis wrote: > Simon Forman wrote: > > Hey I was hoping to get your opinions on a sort of minor stylistic > > point. > > These two snippets of code are functionally identical. Which would you > > use and why? > > The first one is easier [for me anyway] to read and und

Re: question of style

2009-07-02 Thread Tim Harig
On 2009-07-02, Tim Harig wrote: > Sorry, it worked under 2.5: [SNIP] > None seems to have been evaluated less then any integer. The same isn't > true under 3.0: None seem to have been evaluated less then any non-negative integer including 0. -- http://mail.python.org/mailman/listinfo/python-lis

Re: question of style

2009-07-02 Thread Tim Harig
On 2009-07-02, Paul Rubin wrote: > Tim Harig writes: >> That being the case, it might be a good idea either to handle the situation >> and raise an exception or add: >> assert self.lower <= self.higher >> That way an exception will be raised if there is an error somewhere else >> in the code rath

Is Psyco good for Python 2.6.1?

2009-07-02 Thread Russ P.
I need to speed up some Python code, and I discovered Psyco. However, the Psyco web page has not been updated since December 2007. Before I go to the trouble of installing it, does anyone know if it is still good for Python 2.6.1? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: String to List Question

2009-07-02 Thread Rhodri James
On Thu, 02 Jul 2009 23:05:46 +0100, Hanna Michelsen wrote: Hi, I am brand new to python and I love it, but I've been having some trouble with a file parser that I've been working on. It contains lines that start with a name and then continue with names, nicknames and phone numbers of peop

Re: regex question on .findall and \b

2009-07-02 Thread Ethan Furman
Ethan Furman wrote: Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.9.1 -- An enhanced Interactive Python. In [161]: re.findall('\d+','this i

Re: question of style

2009-07-02 Thread Paul Rubin
Tim Harig writes: > That being the case, it might be a good idea either to handle the situation > and raise an exception or add: > > assert self.lower <= self.higher > > That way an exception will be raised if there is an error somewhere else > in the code rather then silently passing a possibly

Detecting platform architecture with Parallels and Win XP x64

2009-07-02 Thread Doug McCorkle
Hello, I am using Python 2.5.4 on Windows XP x64 with Parallels. When I try to use: distutils.util.get_platform sys.platform I always get win32 but if I use: platform.architecture() with the amd64 installer I get 64bit for the first argument. Is there a way to detect win64 without having

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Charles Yeomans
On Jul 2, 2009, at 6:06 PM, Allen Fowler wrote: I have an (in-development) python system that needs to shuttle events / requests around over the network to other parts of itself. It will also need to cooperate with a .net application running on yet a different machine. So, naturally

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Paul Rubin
Allen Fowler writes: > Since I need to work with other platforms, pickle is out... what > are the alternatives? XML? JSON? json is the easiest to prototype with and is less bureaucratic. xml has more serious tools for schema specification and validation etc. You could start with json and switc

Re: how to spawn a process under different user

2009-07-02 Thread Tim Harig
On 2009-07-02, sanket wrote: >> sanket wrote: >> > I am trying to use python's subprocess module to launch a process. >> > but in order to do that I have to change the user. > I am using python 2.4 on centos. I have never done this in python; but, using the normal system calls in C the process is

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Chris Rebert
On Thu, Jul 2, 2009 at 3:06 PM, Allen Fowler wrote: > > I have an (in-development) python system that needs to shuttle events / > requests around over the network to other parts of itself.   It will also > need to cooperate with a .net application running on yet a different machine. > > So, natur

Re: question of style

2009-07-02 Thread Tim Harig
On 2009-07-02, Paul Rubin wrote: > Tim Harig writes: >> If lower is 5 and higher is 3, then it returns 3 because 3 != None in the >> first if. > Sorry, the presumption was that lower <= higher, i.e. the comparison > had already been made and the invariant was enforced by the class > constructor.

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Allen Fowler
> I have an (in-development) python system that needs to shuttle events / > requests > around over the network to other parts of itself. It will also need to > cooperate with a .net application running on yet a different machine. > > So, naturally I figured some sort of HTTP event / RPC t

Re: String to List Question

2009-07-02 Thread Philip Semanchuk
On Jul 2, 2009, at 6:05 PM, Hanna Michelsen wrote: Hi, I am brand new to python and I love it, but I've been having some trouble with a file parser that I've been working on. It contains lines that start with a name and then continue with names, nicknames and phone numbers of people asso

XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Allen Fowler
I have an (in-development) python system that needs to shuttle events / requests around over the network to other parts of itself. It will also need to cooperate with a .net application running on yet a different machine. So, naturally I figured some sort of HTTP event / RPC type of would be

String to List Question

2009-07-02 Thread Hanna Michelsen
Hi, I am brand new to python and I love it, but I've been having some trouble with a file parser that I've been working on. It contains lines that start with a name and then continue with names, nicknames and phone numbers of people associated with that name. I need to create a list of the names o

Re: how to spawn a process under different user

2009-07-02 Thread sanket
On Jul 2, 1:58 pm, Tim Golden wrote: > sanket wrote: > > Hello All, > > > I am trying to use python's subprocess module to launch a process. > > but in order to do that I have to change the user. > > > I am not getting any clue how to do that? > > so can anyone please tell me How can I spawn a pro

Re: question of style

2009-07-02 Thread Paul Rubin
Tim Harig writes: > If lower is 5 and higher is 3, then it returns 3 because 3 != None in the > first if. Sorry, the presumption was that lower <= higher, i.e. the comparison had already been made and the invariant was enforced by the class constructor. The comment should have been more explicit

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-02 Thread Roel Schroeven
Peter Otten schreef: > Ulrich Eckhardt wrote: > >> Bearophile wrote: >>> Ulrich Eckhardt: a way to automatically release the resource, something which I would do in the destructor in C++. >>> Is this helpful? >>> http://effbot.org/pyref/with.htm >> Yes, it aims in the same direction. How

stringio+tarfile

2009-07-02 Thread superpollo
why the following does not work? can you help me correct (if possible)? 1 import tarfile 2 import StringIO 3 sf1 = StringIO.StringIO("one\n") 4 sf2 = StringIO.StringIO("two\n") 5 tf = StringIO.StringIO() 6 tar = tarfile.open(tf , "w") 7 for name in [sf1 ,

Re: how to spawn a process under different user

2009-07-02 Thread Tim Golden
sanket wrote: Hello All, I am trying to use python's subprocess module to launch a process. but in order to do that I have to change the user. I am not getting any clue how to do that? so can anyone please tell me How can I spawn a process under different user than currently I am logging in as.

PyTextMagicSMS text messaging library released

2009-07-02 Thread Dawie Strauss
TextMagic (http://www.textmagic.com) offers a convenient way to send text messages programmatically. This package provides a simple Python API on top of the TextMagic HTTPS API. Project documentation and source code is hosted at http://code.google.com/p/textmagic-sms-api-python/ The package can b

Re: question of style

2009-07-02 Thread Tim Harig
On 2009-07-02, Paul Rubin wrote: [reformated with emphasis added] >#self.higher and self.lower are each either "available" (i.e. are not >#None), or unavailable (are None). [EMPHASIS] Return the highest of the >#available values. [/EMPHASIS] If no value is available, return None. Y

Re: System default sys.path

2009-07-02 Thread Brock Pytlik
David Lyon wrote: On Wed, 01 Jul 2009 19:48:04 -0700, Brock Pytlik wrote: Hi, I'm trying to find a way to get the value sys.path would have on a particular system if python was started with an empty python path. I do want it to include the site specific additional paths. I know I can hack

Re: question of style

2009-07-02 Thread Tim Harig
On 2009-07-02, Scott David Daniels wrote: > Duncan Booth wrote: >> Simon Forman wrote: >> As a matter of style however I wouldn't use the shorthand to run two 'is' >> comparisons together, I'd write that out in full if it was actually needed >> here. That part I don't really have a problem wit

Re: question of style

2009-07-02 Thread Erik Max Francis
Simon Forman wrote: Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one is easier [for me anyway] to read and understand, but slightly less efficient, while the second is [margi

how to spawn a process under different user

2009-07-02 Thread sanket
Hello All, I am trying to use python's subprocess module to launch a process. but in order to do that I have to change the user. I am not getting any clue how to do that? so can anyone please tell me How can I spawn a process under different user than currently I am logging in as. Thank you, san

Re: question of style

2009-07-02 Thread Paul Rubin
Simon Forman writes: > ## Second snippet > > if self.higher is None: > if self.lower is None: > return > return self.lower > if self.lower is None: > return self.higher > > What do you think? I'm not sure, but my guess is that what you are really trying to write is something

Re: question of style

2009-07-02 Thread Scott David Daniels
Duncan Booth wrote: Simon Forman wrote: ... if self.higher is self.lower is None: return ... As a matter of style however I wouldn't use the shorthand to run two 'is' comparisons together, I'd write that out in full if it was actually needed here. Speaking only to the style issue, when I'

Intro to Python class, 7/21-23, Ft Worth TX

2009-07-02 Thread Rich Drehoff
We are looking for someone that can help with the subject class, Intro to Python class, 7/21-23, Ft Worth TX. Please let me know if you can help. Would need your resume and best possible daily rate. Best regards, Rich Drehoff TechnoTraining, Inc. 328 Office Square Lane, Ste. 202, Virgini

Deadline for Toronto PyCamp Registraiton Appoaching

2009-07-02 Thread Chris Calloway
Tomorrow (July 3) by midnight will be the last opportunity for Toronto PyCamp registration before the late registration period ending July 10. PyCamp is the original Python BootCamp developed by a user group for user groups. This year PyCamp is July 13-17 at the University of Toronto, sponsored

Re: question of style

2009-07-02 Thread Tim Harig
On 2009-07-02, Duncan Booth wrote: > so apart from reversing the order of the comparisons once you've dropped > the redundant test it is the same as the first one. I try to evaluate what you have given regardless of what Booth pointed out. So, I will only evaluate the first line as it contains m

Re: question of style

2009-07-02 Thread Paul Rubin
Simon Forman writes: > These two snippets of code are functionally identical. Which would you > use and why? Both are terrible. I can't tell what you're really trying to do. As Terry Reedy points out, the case where self.higher and self.lower are both not None is not handled. If you want to ex

Re: Open Source RSS Reader in Python?

2009-07-02 Thread member thudfoo
On Wed, Jul 1, 2009 at 4:18 PM, Alex wrote: > I am looking for an open source RSS reader (desktop, not online) > written in Python but in vain. I am not looking for a package but a > fully functional software. > > Google: python "open source" (rss OR feeds) reader > > Any clue ? > -- > http://mail.

Re: Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-02 Thread andrew cooke
David Bolen wrote: > "andrew cooke" writes: > >> However, when printed via format_exc(), this new exception still has the old exception attached via the mechanism described at >> http://www.python.org/dev/peps/pep-3134/ (this is Python 3.0). > > If you're in control of the format_exc() call, I thi

Re: multiprocessing: pool with blocking queue

2009-07-02 Thread J Kenneth King
masher writes: > On Jul 2, 12:06 pm, J Kenneth King wrote: >> masher writes: >> > My questions, then, is: Is there a more elegant/pythonic way of doing >> > what I am trying to do with the current Pool class? >> >> Forgive me, I may not fully understand what you are trying to do here >> (I've n

Re: question of style

2009-07-02 Thread Terry Reedy
Simon Forman wrote: Hey I was hoping to get your opinions on a sort of minor stylistic point. These two snippets of code are functionally identical. Which would you use and why? The first one is easier [for me anyway] to read and understand, but slightly less efficient, while the second is [margi

Re: regex question on .findall and \b

2009-07-02 Thread Nobody
On Thu, 02 Jul 2009 09:38:56 -0700, Ethan Furman wrote: > Greetings! > > My closest to successfull attempt: > > Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] > Type "copyright", "credits" or "license" for more information. > > IPython 0.9.1 -- An enhanced Interact

Re: Searching equivalent to C++ RAII or deterministic destructors

2009-07-02 Thread Carl Banks
On Jul 2, 3:12 am, Ulrich Eckhardt wrote: > Bearophile wrote: > > Ulrich Eckhardt: > >> a way to automatically release the resource, something > >> which I would do in the destructor in C++. > > > Is this helpful? > >http://effbot.org/pyref/with.htm > > Yes, it aims in the same direction. However,

Re: question of style

2009-07-02 Thread Kee Nethery
the fact that you felt compelled to explain the "one minor point" in the first snippet tells me that the second snippet does not need that explanation and will be easier for someone (like you for example) to maintain in the future. Second snippet would be my choice. Kee Nethery On Jul 2, 20

Re: Config files with different types

2009-07-02 Thread MRAB
Zach Hobesh wrote: Hi all, I've written a function that reads a specifically formatted text file and spits out a dictionary. Here's an example: config.txt: Destination = C:/Destination Overwrite = True Here's my function that takes 1 argument (text file) the_file = open(textfile,'r') linel

Re: PEP 376

2009-07-02 Thread Charles Yeomans
On Jul 2, 2009, at 1:37 PM, Lie Ryan wrote: Joachim Strömbergson wrote: Aloha! Tarek Ziadé wrote: The prefix is a good idea but since it's just a checksum to control that the file hasn't changed what's wrong with using a weak hash algorithm like md5 or now sha1 ? Because it creates a depen

Re: question of style

2009-07-02 Thread Simon Forman
On Jul 2, 1:44 pm, Duncan Booth wrote: > Simon Forman wrote: > > Hey I was hoping to get your opinions on a sort of minor stylistic > > point. > > These two snippets of code are functionally identical. Which would you > > use and why? > > The first one is easier [for me anyway] to read and unders

Re: Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-02 Thread David Bolen
"andrew cooke" writes: > However, when printed via format_exc(), this new exception still has the > old exception attached via the mechanism described at > http://www.python.org/dev/peps/pep-3134/ (this is Python 3.0). If you're in control of the format_exc() call, I think the new chain keyword

Config files with different types

2009-07-02 Thread Zach Hobesh
Hi all, I've written a function that reads a specifically formatted text file and spits out a dictionary.  Here's an example: config.txt: Destination = C:/Destination Overwrite = True Here's my function that takes 1 argument (text file) the_file = open(textfile,'r') linelist = the_file.read()

Re: MySQLdb and ordering of column names in list returned by keys() w/ a DictCursor

2009-07-02 Thread Petr Messner
2009/7/2 Tim Chase : >> Will this order at least be the same for that same query every time the >> script is executed? > > I wouldn't count on it. The order is only defined for the one iteration > (result of the keys() call). If the order matters, I'd suggest a > double-dispatch with a non-dict (

Re: question of style

2009-07-02 Thread Duncan Booth
Simon Forman wrote: > Hey I was hoping to get your opinions on a sort of minor stylistic > point. > These two snippets of code are functionally identical. Which would you > use and why? > The first one is easier [for me anyway] to read and understand, but > slightly less efficient, while the seco

Re: PEP 376

2009-07-02 Thread Lie Ryan
Joachim Strömbergson wrote: > Aloha! > > Tarek Ziadé wrote: >> The prefix is a good idea but since it's just a checksum to control >> that the file hasn't changed >> what's wrong with using a weak hash algorithm like md5 or now sha1 ? > > Because it creates a dependency to an old algorithm that s

  1   2   >