multiprocessing and freezing on Windows

2009-07-02 Thread SK
Is there a method for freezing a Python 2.6 app using multiprocessing on Windows using PyInstaller or py2exe that works? It is trying to call my executable instead of python.exe when the process starts and passes it --multiprocessing-fork . Adding a freeze_support() to my main doesn't help. Do I ha

Re: Open Source RSS Reader in Python?

2009-07-02 Thread Chris Rebert
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 ? Straw for GTK/GNOM

Searching equivalent to C++ RAII or deterministic destructors

2009-07-02 Thread Ulrich Eckhardt
Hi! I'm currently converting my bioware to handle Python code and I have stumbled across a problem... Simple scenario: I have a handle to a resource. This handle allows me to manipulate the resource in various ways and it also represents ownership. Now, when I put this into a class, instances to

Re: Accessing windows structures through ctypes.

2009-07-02 Thread Enrico
"Rajat" ha scritto nel messaggio news:8c8b5cf2-bc77-4633-96ca-e3b908430...@z14g2000yqa.googlegroups.com... > > > > Using ctypes can I access the windows structures like: > > > > > PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB), > > > PEB_LDR_DATA, etc? > > > > ctypes.wintypes lists all

Re: PEP 376

2009-07-02 Thread Joachim Strömbergson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Aloha! Richard Brodie wrote: > "Joachim Str�mbergson" wrote in message > news:mailman.2422.1246418400.8015.python-l...@python.org... > >> Even so, choosing md5 in 2009 for something that (hopefully) will be >> used in years is a bad design decision

Re: getting rid of —

2009-07-02 Thread Tep
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: > > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position > > 1: ordinal not in range(128) > > > Than

PEP368 and pixeliterators

2009-07-02 Thread Joachim Strömbergson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Aloha! I just read the PEP368 and really liked the proposed idea, sound like a great battery addition to include in the std lib: http://www.python.org/dev/peps/pep-0368/ One question/idea though: The proposed iterator will iterate over all pixels in

Re: string character count

2009-07-02 Thread noydb
thanks everyone for all the ideas -- simple stuff, I know for you all, but very helpful for me. -- http://mail.python.org/mailman/listinfo/python-list

Re: getting rid of —

2009-07-02 Thread Tep
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: > > > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position

Re: Determining if a function is a method of a class within a decorator

2009-07-02 Thread Jeremiah Dodds
On Wed, Jul 1, 2009 at 2:14 AM, David Hirschfield wrote: > Unfortunately that still requires two separate decorators, when I was > hoping there was a way to determine if I was handed a function or method > from within the same decorator. > > Seems like there really isn't, so two decorators is th

Re: A question about fill_free_list(void) function

2009-07-02 Thread Peter Otten
Pedram wrote: > On Jul 1, 10:01 pm, Christian Heimes wrote: >> Pedram schrieb: >> >> > Hello community, >> > I'm reading the CPython interpreter source code, >> > first, if you have something that I should know for better reading >> > this source code, I would much appreciate that :) >> > second,

Need Help

2009-07-02 Thread Tengiz Davitadze
Hello. I can't find a wright mail address. If you can help me I need to get an information about UNICODE. I am georgian and I need to write programs on georgian language . If you can transfer this mail or send me a wright mail about encoding or unicode information. -- Tengiz Davitadze { programin

Re: deleting certain entries in numpy array

2009-07-02 Thread Sebastian Schabe
Robert Kern schrieb: First, convert the pos array to integers, and just the columns with indices in them: ipos = pos[:,:2].astype(int) Now check the values in the mask corresponding to these positions: mask_values = mask[ipos[:,0], ipos[:,1]] Now extract the rows from the original pos ar

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

2009-07-02 Thread Bearophile
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 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi thread reading a file

2009-07-02 Thread Gabriel Genellina
En Wed, 01 Jul 2009 12:49:31 -0300, Scott David Daniels escribió: Gabriel Genellina wrote: ... def convert(in_queue, out_queue): while True: row = in_queue.get() if row is None: break # ... convert row out_queue.put(converted_line) These loops work well with the two-argum

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

2009-07-02 Thread Ulrich Eckhardt
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, I'm not sure this applies to my case. The point is that

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

2009-07-02 Thread Peter Otten
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, I'm not sure this a

Re: A question about fill_free_list(void) function

2009-07-02 Thread Pedram
On Jul 2, 1:11 pm, Peter Otten <__pete...@web.de> wrote: > Pedram wrote: > > On Jul 1, 10:01 pm, Christian Heimes wrote: > >> Pedram schrieb: > > >> > Hello community, > >> > I'm reading the CPython interpreter source code, > >> > first, if you have something that I should know for better reading

Re: Why re.match()?

2009-07-02 Thread kj
In Steven D'Aprano writes: >On Thu, 02 Jul 2009 03:49:57 +, kj wrote: >> In Duncan Booth >> writes: >>>So, for example: >> >> re.compile("c").match("abcdef", 2) >>><_sre.SRE_Match object at 0x02C09B90> >> re.compile("^c").search("abcdef", 2) >> >> >> I find this

performance problem with time.strptime()

2009-07-02 Thread Nils Rüttershoff
Hi everyone, In my free time I translate scripts from open source projects or write my own, to train my python skills. ATM I convert the aplogmerge.pl from awstats. It merges multiple apache logfiles and sort the output by the timestamps of each line. My first version of this script hasn't a good

Re: Need Help

2009-07-02 Thread Simon Brunning
2009/7/2 Tengiz Davitadze : > Hello. I can't find a wright mail address. If you can help me I need to get > an information about UNICODE. I am georgian and I need to write programs on > georgian language . If you can transfer this mail or send me a wright mail > about encoding or unicode informatio

Re: performance problem with time.strptime()

2009-07-02 Thread Casey Webster
On Jul 2, 7:30 am, Nils Rüttershoff wrote: > Rec = > re.compile(r"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*") > Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] "GET /foo HTTP/1.0" 200 - > "-" "www.example.org" "-" "-" "-"' I'm not sure how

Re: PEP 376

2009-07-02 Thread Tarek Ziadé
2009/7/2 Joachim Strömbergson : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Aloha! > > Richard Brodie wrote: >> "Joachim Str�mbergson" wrote in message >> news:mailman.2422.1246418400.8015.python-l...@python.org... >> >>> Even so, choosing md5 in 2009 for something that (hopefully) will

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

2009-07-02 Thread Dave Angel
Ulrich Eckhardt wrote: Hi! I'm currently converting my bioware to handle Python code and I have stumbled across a problem... Simple scenario: I have a handle to a resource. This handle allows me to manipulate the resource in various ways and it also represents ownership. Now, when I put this in

Re: Why re.match()?

2009-07-02 Thread Hrvoje Niksic
kj writes: > For a recovering Perl-head like me it is difficult to understand > why Python's re module offers both match and search. Why not just > use search with a beginning-of-string anchor? I need re.match when parsing the whole string. In that case I never want to search through the strin

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

2009-07-02 Thread Christian Heimes
Dave Angel wrote: > Look also at 'del' a command in the language which explicitly deletes an > object. No, you are either explaining it the wrong way or you have been fallen for a common misinterpretation of the del statement. The del statement only removes the object from the current scope. This

Re: PEP368 and pixeliterators

2009-07-02 Thread Casey Webster
On Jul 2, 4:32 am, Joachim Strömbergson wrote: > But, wouldn't it be more Pythonic and simpler to have an iterator that > iterates over all pixels in an image? Starting with upper left corner > and moving left-right and (line by line) to lower right. This would > change the code above to: Unless

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

2009-07-02 Thread Peter Otten
Dave Angel wrote: > But I'm guessing you want something that automatically deletes objects > whenever the last reference disappears. That's an implementation > detail, not a language guarantee. In particular CPython does what you > want, by using reference counting. That's the only Python I've

Re: performance problem with time.strptime()

2009-07-02 Thread Nils Rüttershoff
Hi Casey Casey Webster wrote: > On Jul 2, 7:30 am, Nils Rüttershoff wrote: > > >> Rec = >> re.compile(r"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*") >> Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] "GET /foo HTTP/1.0" 200 >> - "-" "www.e

Re: performance problem with time.strptime()

2009-07-02 Thread Dave Angel
Nils Rüttershoff wrote: Hi everyone, In my free time I translate scripts from open source projects or write my own, to train my python skills. ATM I convert the aplogmerge.pl from awstats. It merges multiple apache logfiles and sort the output by the timestamps of each line. My first version of

Re: PEP 376

2009-07-02 Thread Joachim Strömbergson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 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

Re: PEP368 and pixeliterators

2009-07-02 Thread Joachim Strömbergson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Aloha! Casey Webster wrote: > Unless I'm totally misreading the PEP, the author does provide both > iterators. Quoting the PEP: > > Non-planar images offer the following additional methods: > > pixels() -> iterator[pixel] > > Returns an iterator

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

2009-07-02 Thread Dave Angel
Christian Heimes wrote: Dave Angel wrote: Look also at 'del' a command in the language which explicitly deletes an object. No, you are either explaining it the wrong way or you have been fallen for a common misinterpretation of the del statement. The del statement only removes the obje

Re: Trying to use sets for random selection, but the pop() method returns items in order

2009-07-02 Thread Mario Garcia
This could be better: >>> import random >>> population = range(10) >>> choice = random.choice(population) >>> population.remove(choice) >>> print population >>> print population [0, 1, 2, 3, 4, 5, 6, 8, 9] That was my idea with the previous pop(), remove from the population a certain number of

Re: pep 8 constants

2009-07-02 Thread Lie Ryan
Eric S. Johansson wrote: > Steven D'Aprano wrote: >> That assumes that every word is all caps. In practice, for real-life >> Python code, I've tripled the vocal load of perhaps one percent of your >> utterances, which cuts your productivity by 2%. >> >> If you have 1 words in you per day, and

Re: pep 8 constants

2009-07-02 Thread Lie Ryan
Eric S. Johansson wrote: > I've been working with speech recognition for 15 years. I've written something > on the order of 10,000 lines of Python code both as open source and private > projects. I've tried it least two dozen editors and they all fail miserably > because they're focused on keyboar

Re: Timeout when connecting to sybase DBS

2009-07-02 Thread eranlevi
On Jul 2, 1:08 am, s...@pobox.com wrote: >     Gil> There's no such group as python-sybase :-( > > http://sourceforge.net/mailarchive/forum.php?forum_name=python-sybase... > > S Thanks :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Timeout when connecting to sybase DBS

2009-07-02 Thread eranlevi
On Jul 2, 1:07 am, s...@pobox.com wrote: >     Gil> Are you saying, that when you trying to connect to a sybase DBS >     Gil> server and the DBS or the server is down, you get an error after a >     Gil> few seconds and not after a few minutes? > > Yes, though thankfully our server tends to almost

Re: PEP368 and pixeliterators

2009-07-02 Thread Nobody
On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote: > I just read the PEP368 and really liked the proposed idea, sound like a > great battery addition to include in the std lib: > > http://www.python.org/dev/peps/pep-0368/ Unfortunately, it's too simplistic, meaning that most of the

Re: Idioms and Anti-Idioms Question

2009-07-02 Thread J. Cliff Dyer
On Wed, 2009-07-01 at 17:19 +1200, Lawrence D'Oliveiro wrote: > In message , J. Cliff > Dyer wrote: > > > If the lines got separated, a leading + could disappear into its line > > without any errors showing up. A trailing + would raise a syntax error. > > Unless, of course, it was moved onto th

Re: Spam? Re: whizBase vs. Python

2009-07-02 Thread Nils Rüttershoff
NurAzije wrote: > On Jun 29, 11:04 am, Tim Harig wrote: > >> On 2009-06-29, NurAzije wrote: >> >> >>> Hi, >>> I am working on a study and I need expert opinion, I did not work with >>> Python before, can anyone help me with a comparison betweenWhizBase >>> (www.whizbase.com) and Python pl

logging of strings with broken encoding

2009-07-02 Thread Thomas Guettler
Hi, I have bug in my code, which results in the same error has this one: https://bugs.launchpad.net/bzr/+bug/295653 {{{ Traceback (most recent call last): File "/usr/lib/python2.6/logging/__init__.py", line 765, in emit self.stream.write(fs % msg.encode("UTF-8")) .. UnicodeDecodeError: 'a

multiprocessing: pool with blocking queue

2009-07-02 Thread masher
Hi, I am trying to implement a multiprocessing pool that assigns tasks from a blocking queue. My situation is a pretty classic producer/ consumer conundrum, where the producer can produce much faster than the consumers can consume. The wrinkle in the story is that the producer produces objects tha

Re: logging of strings with broken encoding

2009-07-02 Thread David Smith
Thomas Guettler wrote: > Hi, > > I have bug in my code, which results in the same error has this one: > > https://bugs.launchpad.net/bzr/+bug/295653 > {{{ > Traceback (most recent call last): > File "/usr/lib/python2.6/logging/__init__.py", line 765, in emit > self.stream.write(fs % msg.enc

Re: logging of strings with broken encoding

2009-07-02 Thread Peter Otten
Thomas Guettler wrote: > I have bug in my code, which results in the same error has this one: > > https://bugs.launchpad.net/bzr/+bug/295653 > {{{ > Traceback (most recent call last): > File "/usr/lib/python2.6/logging/__init__.py", line 765, in emit > self.stream.write(fs % msg.encode("UTF

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

2009-07-02 Thread Wells Oliver
Is there some kind of mysterious logic to how the the columns are ordered when executing the following: sql = "SELECT player_id, SUM(K) AS K, SUM(IP) AS IP, SUM(ER) AS ER, SUM(HR) AS HR, SUM(H) AS H, SUM(BB) AS BB, Teams.league FROM Pitching INNER JOIN Teams ON Pitching.team = Teams.team_id WHERE

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

2009-07-02 Thread Tim Chase
sql = "SELECT player_id, SUM(K) AS K, SUM(IP) AS IP, SUM(ER) AS ER, SUM(HR) AS HR, SUM(H) AS H, SUM(BB) AS BB, Teams.league FROM Pitching INNER JOIN Teams ON Pitching.team = Teams.team_id WHERE Date BETWEEN '%s' AND '%s' GROUP BY player_id" % (start, date) cursor.execute(sql) for row in cursor.fe

Re: logging of strings with broken encoding

2009-07-02 Thread Lie Ryan
Thomas Guettler wrote: > Hi, > > I have bug in my code, which results in the same error has this one: > > https://bugs.launchpad.net/bzr/+bug/295653 > {{{ > Traceback (most recent call last): > File "/usr/lib/python2.6/logging/__init__.py", line 765, in emit > self.stream.write(fs % msg.enc

Re: logging of strings with broken encoding

2009-07-02 Thread Thomas Guettler
My quick fix is this: class MyFormatter(logging.Formatter): def format(self, record): msg=logging.Formatter.format(self, record) if isinstance(msg, str): msg=msg.decode('utf8', 'replace') return msg But I still think handling of non-ascii byte strings shoul

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

2009-07-02 Thread Wells Oliver
Will this order at least be the same for that same query every time the script is executed? On Thu, Jul 2, 2009 at 10:48 AM, Tim Chase wrote: > sql = "SELECT player_id, SUM(K) AS K, SUM(IP) AS IP, SUM(ER) AS ER, SUM(HR) >> AS HR, SUM(H) AS H, SUM(BB) AS BB, Teams.league FROM Pitching INNER JOIN >

Re: multiprocessing: pool with blocking queue

2009-07-02 Thread J Kenneth King
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 never really used multiprocessing all that much)... But couldn't you just assi

Re: deleting certain entries in numpy array

2009-07-02 Thread Robert Kern
On 2009-07-02 04:40, Sebastian Schabe wrote: Robert Kern schrieb: > You will want to ask numpy questions on the numpy mailing list. > > http://www.scipy.org/Mailing_Lists > I ever thought news-groups are the right way for questions like this. And the mailing list page just confuses me, bu

Re: multiprocessing: pool with blocking queue

2009-07-02 Thread masher
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 never really used multipro

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

2009-07-02 Thread Tim Wintle
On Thu, 2009-07-02 at 10:32 -0500, Wells Oliver wrote: > for row in cursor.fetchall(): > print row.keys() > > What I get is: > > ['league', 'BB', 'HR', 'IP', 'K', 'H', 'player_id', 'ER'] > > Neither alphabetical nor the order in which they were specified in the > query nor... any seeming ord

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

2009-07-02 Thread 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 (regular/default) query result

regex question on .findall and \b

2009-07-02 Thread Ethan Furman
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 is test a3 attempt 79')

Re: logging of strings with broken encoding

2009-07-02 Thread Stefan Behnel
Thomas Guettler wrote: > My quick fix is this: > > class MyFormatter(logging.Formatter): > def format(self, record): > msg=logging.Formatter.format(self, record) > if isinstance(msg, str): > msg=msg.decode('utf8', 'replace') > return msg > > But I still thi

Re: regex question on .findall and \b

2009-07-02 Thread Tim Chase
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 is

Re: logging of strings with broken encoding

2009-07-02 Thread Lie Ryan
Thomas Guettler wrote: > My quick fix is this: > > class MyFormatter(logging.Formatter): > def format(self, record): > msg=logging.Formatter.format(self, record) > if isinstance(msg, str): > msg=msg.decode('utf8', 'replace') > return msg > > But I still thi

Re: invoking a method from two superclasses

2009-07-02 Thread Lie Ryan
Carl Banks wrote: > On Jun 30, 6:23 pm, Carl Banks wrote: >> On Jun 30, 5:34 pm, Mitchell L Model wrote: >> >>> Allow me to add to my previous question that certainly the superclass >>> methods can be called explicitly without resorting to super(), e.g.: >>> class C(A, B): >>> def __i

Re: dealloc function in python extend c module

2009-07-02 Thread Philip Semanchuk
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 count). ex: --- ty

question of style

2009-07-02 Thread Simon Forman
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 [marginally] harder to follo

Re: regex question on .findall and \b

2009-07-02 Thread Sjoerd Mullender
On 2009-07-02 18:38, 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.find

Re: Direct interaction with subprocess - the curse of blocking I/O

2009-07-02 Thread Pascal Chambon
Thank you all for the comments you might want something like Expect. Yes "Expect" deals with such things, unfortunately it's posix only (due to the PTY module requirement...); whereas I'd like to find generic ways (i.e at least windows/linux/mac recipes) The latter is inherently tricky (wh

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

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: 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 (

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: 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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

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

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

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'

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

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 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

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: 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, 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

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: 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.

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: 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

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: 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

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

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

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

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

  1   2   >