Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Michele Simionato
Raymond Hettinger: > Any takers for tally()? Dunno, to me "tally" reads "counts the numbers of votes for a candidate in an election". > We should avoid abbreviations like inc() or incr() that different people tend to > abbreviate differently (for example, that is why the new partial() function ha

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Paul Rubin
Reinhold Birkenfeld <[EMAIL PROTECTED]> writes: > > Any takers for tally()? > > Well, as a non-native speaker, I had to look up this one in my > dictionary. That said, it may be bad luck on my side, but it may be that > this word is relatively uncommon and there are many others who would be > happ

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Roose
> Py2.5 is already going to include any() and all() as builtins. The signature > does not include a function, identity or otherwise. Instead, the caller can > write a listcomp or genexp that evaluates to True or False: > > any(x >= 42 for x in data) > > If you wanted an identify function, tha

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[Michele Simionato] > Dunno, to me "tally" reads "counts the numbers of votes for a candidate > in an election". That isn't a pleasant image ;-) >The > only right name would be "get_and_possibly_set" but it is a bit long to > type. > >> Even if a wording is found that better describes the both

how to use structured markup tools

2005-03-19 Thread Sean McIlroy
I'm dealing with XML files in which there are lots of tags of the following form: xy (all of these letters are being used as 'metalinguistic variables') Not all of the tags in the file are of that form, but that's the only type of tag I'm interested in. (For the insatiably curious, I'm talking abo

any() and all() Was: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
> > Py2.5 is already going to include any() and all() as builtins. The > > signature does not include a function, identity or otherwise. > > Instead, the caller can > > write a listcomp or genexp that evaluates to True or False: > > > > any(x >= 42 for x in data) [Roose] > Oh great, I just s

Re: HELP:UnboundLocalError: local variable '_nntp' referenced before assignment

2005-03-19 Thread Peter Moscatt
Diez B. Roggisch wrote: > Peter Moscatt wrote: >> UnboundLocalError: local variable '_nntp' referenced before assignment > > This pretty much says what your problem is: you haven't a variable called > _nntp > >> def callconnect(): >> if b["text"]=="Connect": >> _nntp = >>

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Roose
> Py2.5 is already going to include any() and all() as builtins. The signature > does not include a function, identity or otherwise. Instead, the caller can > write a listcomp or genexp that evaluates to True or False: Actually I was just looking at Python 2.5 docs since you mentioned this. htt

Re: How to create stuffit files on Linux?

2005-03-19 Thread Leif K-Brooks
Noah wrote: The problem is that my users want to see .sit files. I know it's sort of silly. Zip files are foreign and frightening to them. Would Stuffit open zip files renamed to .sit? -- http://mail.python.org/mailman/listinfo/python-list

Variable Variable

2005-03-19 Thread Tanteauguri
Hi List, is there in python a variable variable like in PHP ($$var)? What I want to do is something like that: pc=["a","b","c"] for i in pc: i = anyclass() a.shutdown() b.update() Any Ideas? Many Thanks, m -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Peter Otten
Roose wrote: > Not to belabor the point, but in the example on that page, max(L, key=len) > could be written max(len(x) for x in L). No, it can't: Python 2.5a0 (#2, Mar 5 2005, 17:44:37) [GCC 3.3.3 (SuSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >

Re: setDocumentLocator in validating parser (xmlproc)

2005-03-19 Thread Cees Wesseling
"James Kew" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... Thanks James, a perfect patch that works perfect for me. On a side note, it seems the locator is not standarized. expat gives positions at the "<"-char of startElement while xmlproc (PyXml) gives it the ">"-char of start

[question] Event Handeling Between Two wxPanles in A wxNotebook

2005-03-19 Thread support . services . complaints
Ok i have a wxFrame with a wxNotebook that has two wxPanels, lets call them panel_1 and panel_2 i have wxTextCtrl in panel_1 (call it panel_1_ctrl) that i want the user to be able to fill up. I then want the user to be able to click a button (i.e. create an EVT) and have Value() of panel_1_ctrl be

any() and all() Was: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[Roose] > Actually I was just looking at Python 2.5 docs since you mentioned this. > > http://www.python.org/dev/doc/devel/whatsnew/node3.html > > It says min() and max() will gain a key function parameter, and sort() > gained one in Python 2.4 (news to me). It also appears in itertools.groupby()

Re: Variable Variable

2005-03-19 Thread Leif K-Brooks
Tanteauguri wrote: Hi List, is there in python a variable variable like in PHP ($$var)? What I want to do is something like that: pc=["a","b","c"] for i in pc: i = anyclass() a.shutdown() b.update() Use a dictionary: stuff = {} pc = ['a', 'b', 'c'] for i in pc: stuff[i] = anyclass() stuff['

Re: Variable Variable

2005-03-19 Thread Premshree Pillai
On Sat, 19 Mar 2005 04:35:47 -0500, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Tanteauguri wrote: > > Hi List, is there in python a variable variable like in PHP ($$var)? > > > > What I want to do is something like that: > > > > pc=["a","b","c"] > > > > for i in pc: > > i = anyclass() > > > > a

Re: Database connection caching

2005-03-19 Thread lbolognini
Thanks everybody for their replies. Lorenzo -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython vs. pyQt

2005-03-19 Thread Jarek Zgoda
[EMAIL PROTECTED] napisał(a): I've narrowed down my toolkit selection for my project to wxPython and pyQt, and now i'd like to hear any opinions, war stories, peeves, etc, about them, particularly from anyone who's used _both_toolkits_. I'm only mildly interested in the IDEs and UI designers for ea

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
On Sat, 19 Mar 2005 01:24:57 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >I would like to get everyone's thoughts on two new dictionary methods: > >def count(self, value, qty=1): >try: >self[key] += qty >except KeyError: >self[

Re: how to use structured markup tools

2005-03-19 Thread Fredrik Lundh
Sean McIlroy wrote: > I'm dealing with XML files in which there are lots of tags of the > following form: xy (all of these letters are being > used as 'metalinguistic variables') Not all of the tags in the file are > of that form, but that's the only type of tag I'm interested in. (For > the insat

Re: Variable Variable

2005-03-19 Thread Kay Schluehr
Tanteauguri wrote: > Hi List, is there in python a variable variable like in PHP ($$var)? > > What I want to do is something like that: > > pc=["a","b","c"] > > for i in pc: > i = anyclass() > > a.shutdown() > b.update() > > > Any Ideas? def seq(n,cls,*args,**kw): "create a sequence of

pickle: No module named on. HELP!

2005-03-19 Thread fanbanlo
What seems to be the matter? >>> path = "C:\\eclipse\\workspace\\moin134\\docbook\\xslt\\html\\db_compiled.dat" >>> f = file(path) >>> cPickle.load(f) Traceback (most recent call last): File "", line 1, in ? ImportError: No module named on. >>> f = file(path) >>> pickle.load(f) Traceback (most re

Re: Simple XML-to-Python conversion

2005-03-19 Thread Kent Johnson
[EMAIL PROTECTED] wrote: I've tried xmltramp and element tree, but these tools aren't what I had in mind. What I'm looking to use are basic structures such as: root.path root.input.method root.input.filename root.output.filename I haven't used xmltramp but it seems to allow this style of access.

Re: pickle: No module named on. HELP!

2005-03-19 Thread fanbanlo
fanbanlo wrote: What seems to be the matter? >>> path = "C:\\eclipse\\workspace\\moin134\\docbook\\xslt\\html\\db_compiled.dat" >>> f = file(path) >>> cPickle.load(f) Traceback (most recent call last): File "", line 1, in ? ImportError: No module named on. >>> f = file(path) >>> pickle.load(

Re: create/access dynamic growth list

2005-03-19 Thread Kent Johnson
sam wrote: Since each line of the configuration file need to be parsed into "key" and "value" pairs, these pair of tokens need to be stored in another list. Can I use the following operation to store these pair of tokens? eg. Assumed macro_hash["key"]="some key" macro_hash["value"]="some valu

Re: Variable Variable

2005-03-19 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Kay Schluehr <[EMAIL PROTECTED]> wrote: > >Tanteauguri wrote: >> Hi List, is there in python a variable variable like in PHP ($$var)? >> >> What I want to do is something like that: >> >> pc=["a","b","c"] >> >> for i in pc: >> i = anyclass() >> >> a.shutdown() >

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kent Johnson
Bengt Richter wrote: On Sat, 19 Mar 2005 01:24:57 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: I would like to get everyone's thoughts on two new dictionary methods: def count(self, value, qty=1): try: self[key] += qty except KeyError: se

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Carl Banks
Raymond Hettinger wrote: > I would like to get everyone's thoughts on two new dictionary methods: > > def count(self, value, qty=1): > try: > self[key] += qty > except KeyError: > self[key] = qty > > def appendlist(self, key,

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kent Johnson
Brian van den Broek wrote: Raymond Hettinger said unto the world upon 2005-03-18 20:24: I would like to get everyone's thoughts on two new dictionary methods: def appendlist(self, key, *values): try: self[key].extend(values) except KeyError:

Re: Simple XML-to-Python conversion

2005-03-19 Thread Diez B. Roggisch
> If I used a simple INI file or CSV file, I would simply have to parse > my file once and match the name with the value. Why is it necessary to > parse a document once and then re-parse your information into a format > that you can use. This seems absurd to me. Any thoughts on this? Do > I eve

Re: Event Handeling Between Two wxPanles in A wxNotebook

2005-03-19 Thread support . services . complaints
well i have gotten to the point that i can send msgs one way by passing the to panel (panel_2 in example) as a param to __init__ of the from panel (panel_1) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to I restart an interactive session?

2005-03-19 Thread Diez B. Roggisch
> But, by deleting their namespace entries haven't I effectively unloaded > them? In other words, from the point of the interpreter, isn't the No. You haven't I'm not entirely sure why - that's deep in the internals of python - but I know for sure that reload() is not working fully as expected in

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Dan Sommers
On Sat, 19 Mar 2005 01:24:57 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > The proposed names could possibly be improved (perhaps tally() is more > active and clear than count()). Curious that in this lengthy discussion, a method name of "accumulate" never came up. I'm not sure how to se

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Pierre Barbier de Reuille
Ivan Van Laningham a écrit : Hi All-- Maybe I'm not getting it, but I'd think a better name for count would be add. As in d.add(key) d.add(key,-1) d.add(key,399) etc. > [...] There is no existing add() method for dictionaries. Given the name change, I'd like to see it. Metta, Ivan I don't think "

Re: Is Python like VB?

2005-03-19 Thread Ivan Voras
Cappy2112 wrote: Eric3 has been compiled for Windows, without Cygwin and Without a commercial license Can it be downloaded from somewhere? (where from?) Or is it forbidden by the license? -- http://mail.python.org/mailman/listinfo/python-list

Re: fastest postgresql module

2005-03-19 Thread Gerhard Häring
Timothy Smith wrote: [...] is there anyway i can check is it true psycopg is much faster or is it all hyperboll The overhead of psycopg per cursor row is a lot less. So it makes a difference if you fetch *a lot* of data. Anyway, if you don't have a performance problem, you don't need to care ;-)

Re: Is Python like VB?

2005-03-19 Thread Ivan Voras
Dennis Lee Bieber wrote: You know of an assembly language that does Object Oriented? My... The world has been waiting with bated breath for that. Hey, IIRC, old Turbo Assembler (tasm, by Borland) had those. Much of it was still manual, by it supported semi-automatic vtables and such :) --

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Jeff Epler
> [Jeff Epler] > > Maybe something for sets like 'appendlist' ('unionset'?) > On Sat, Mar 19, 2005 at 04:18:43AM +, Raymond Hettinger wrote: > I do not follow. Can you provide a pure python equivalent? Here's what I had in mind: $ python /tmp/unionset.py Set(['set', 'self', 'since', 's', 's

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Ivan Van Laningham
Hi All-- Raymond Hettinger wrote: > > [Michele Simionato] > > +1 for inc instead of count. > > Any takers for tally()? > Sure. Given the reasons for avoiding add(), tally()'s a much better choice than count(). What about d.tally(key,0) then? Deleting the key as was suggested by Michael Spen

Re: Simple XML-to-Python conversion

2005-03-19 Thread Ivan Voras
[EMAIL PROTECTED] wrote: I've been searching high and low for a way to simply convert a small XML configuration file to Python data structures. I came across gnosis XML tools, but need a built-in option for doing something similar. I too needed such thing, and made this simple parser: http://ivora

Re: PyGTK and pyexe

2005-03-19 Thread Viktor
Nope, it doesn't work... I've tried that and the only thing I got was: ImportError: could not import pango ImportError: could not import pango Traceback (most recent call last): File "test.py", line 5, in ? File "gtk\__init__.pyc", line 113, in ? AttributeError: 'module' object has no attribut

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Peter Hansen
Michele Simionato wrote: +1 for inc instead of count. -1 for inc, increment, or anything that carries a connotation of *increasing* the value, so long as the proposal allows for negative numbers to be involved. "Incrementing by -1" is a pretty silly picture. +1 for add and, given the above, I'm un

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Michele Simionato wrote: >> +1 for inc instead of count. > > -1 for inc, increment, or anything that carries a > connotation of *increasing* the value, so long as > the proposal allows for negative numbers to be > involved. "Incrementing by -1" is a pretty silly > picture. >

Re: Splitting with Regular Expressions

2005-03-19 Thread qwweeeit
It' s my faute that I have not read more deeply the Library Reference... In any case the time "wasted" in developping small applications to number lines and remove comments, triple quoted strings, multiline instructions etc. has been "useful" to learn the language... Now I already have the single t

Re: [question] Event Handeling Between Two wxPanles in A wxNotebook

2005-03-19 Thread F. GEIGER
That's the Visual Basic way to do it. I prefer it this way: Controls work on models. If a control has to store a value it does so by calling MyDataPool.storeMyValue(self.GetValue()). When the NotebookPage is changed, the new page tells all controls to update themeselves: self.SetValue(str(MyData

Shared Memory Example (Python, ctypes, VC++)

2005-03-19 Thread Srijit Kumar Bhadra
Hello, Here are code snippets to create and access shared memory in Python with and without ctypes module. With regards, Srijit Filename : SharedMemCreate.py import msvcrt, mmap from ctypes import * FILE_MAP_ALL_ACCESS = 0xF001F INVALID_HANDLE_VALUE = 0x SHMEMSIZE = 256 PAGE_READWRITE =

Checking if port is in use.

2005-03-19 Thread Alex Polite
If I try to bind a socket to a port that's already in use I get this error "error socket.error: (98, 'Address already in use')" Is there anyway to check in advance if a port i already taken? alex -- Alex Polite http://flosspick.org -- http://mail.python.org/mailman/listinfo/python-list

Build an Email Server with Sockets and MIME

2005-03-19 Thread fernandestb
Hi People, I'd like to know if exist the possibilite to build an email server with socket and Mime ? Tks FX -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Peter Hansen
Reinhold Birkenfeld wrote: Peter Hansen wrote: +1 for add and, given the above, I'm unsure there's a viable alternative (unless this is restricted to positive values, or perhaps even to "+1" specifically). What about `addto()'? add() just has the connotation of adding something to the dict and not

determine os language

2005-03-19 Thread Bryan
is there a way to determine the operating system's language? i can't seem to find a method that returns the value. thanks, bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking if port is in use.

2005-03-19 Thread Peter Hansen
Alex Polite wrote: If I try to bind a socket to a port that's already in use I get this error "error socket.error: (98, 'Address already in use')" Is there anyway to check in advance if a port i already taken? In general in Python it's not considered good style to "look before you leap". After all

sound processing - avarage amplitude?

2005-03-19 Thread Niklas Paro
Hello I would need way to check the amplitude (over time) for a sound file in python. I'm sure this can be done, for example the audioop.rms function seems to be able return amplitude values. However, it would be really great to get the results in dB, which does not seem to be the case. Anyone who

Re: Build an Email Server with Sockets and MIME

2005-03-19 Thread Peter Hansen
[EMAIL PROTECTED] wrote: I'd like to know if exist the possibilite to build an email server with socket and Mime ? You could build an email server with only the socket module, if you wanted to. The real puzzle is why you would want to build a mail server from scratch when there are so many existing

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[Jeff Epler] > Maybe something for sets like 'appendlist' ('unionset'?) While this could work and potentially be useful, I think it is better to keep the proposal focused on the two common use cases. Adding a third would reduce the chance of acceptance. Also, in all of my code base, I've not run

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[Dan Sommers] > Curious that in this lengthy discussion, a method name of "accumulate" > never came up. I'm not sure how to separate the two cases (accumulating > scalars vs. accumulating a list), though. Separating the two cases is essential. Also, the wording should contain strong cues that re

program hangs when external process crashes

2005-03-19 Thread Earl Eiland
I'm executing WinRK.exe in a loop using the following code: for x in Files: Command_String = 'C:\Program Files\WinRK\WinRK.exe -create ' + os.path.join(InputDirectory, os.path.splitext(x)[0]) + ' -set compression_method ppmz -setg include_paths none -add ' + os.path.join(InputDirectory, x)

Re: determine os language

2005-03-19 Thread Bryan
Bryan wrote: is there a way to determine the operating system's language? i can't seem to find a method that returns the value. thanks, bryan found it myself, thanks... >>> import locale >>> locale.getdefaultlocale() ('en_US', 'cp1252') >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Denis S. Otkidach
On 18 Mar 2005 21:03:52 -0800 Michele Simionato wrote: MS> +1 for inc instead of count. MS> appendlist seems a bit too specific (I do not use dictionaries of MS> lists that often). inc is too specific too. MS> The problem with setdefault is the name, not the functionality. The problem with func

Re: Add Properties to Instances?

2005-03-19 Thread Martin Miller
Bengt Richter wrote: > On 14 Mar 2005 13:07:29 -0800, "Martin Miller" <[EMAIL PROTECTED]> wrote: > > >Bengt Richter wrote, in part: > >> On 14 Mar 2005 01:19:23 -0800, "Martin Miller" > ><[EMAIL PROTECTED]> > >> wrote, in part: > >> >What still puzzles me, though, is why all the above to make > >pr

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Ivan Van Laningham
Hi All-- Raymond Hettinger wrote: > > Separating the two cases is essential. Also, the wording should contain > strong > cues that remind you of addition and of building a list. > > For the first, how about addup(): > > d = {} > for word in text.split(): > d.addup(word) > I

Re: Checking if port is in use.

2005-03-19 Thread Alex Polite
On lör, mar 19, 2005 at 10:12:10 -0500, Peter Hansen wrote: > Alex Polite wrote: > > You could, for example, bind to a port of "0" and that will > auto-assign an available port for you. Does that work > in your case? If not, please describe what you are really > trying to accomplish. I'm launch

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
Dan Sommers wrote: > On Sat, 19 Mar 2005 01:24:57 GMT, > "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > > > The proposed names could possibly be improved (perhaps tally() is more > > active and clear than count()). > > Curious that in this lengthy discussion, a method name of "accumulate" > never

Re: Checking if port is in use.

2005-03-19 Thread elbertlev
How about this? try: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1) s.bind((HOST, PORT)) except socket.error, e: if e print "address already in use" -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple XML-to-Python conversion

2005-03-19 Thread [EMAIL PROTECTED]
One reason I chose not to use ConfigParser module is that I also have a similar config file for a MATLAB compiled program to run along with my Python script. XML would eliminate the need to use two different style configuration files. Another reason is that the programmer who is writing the GUI t

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[Ivan Van Laningham] > What about adding another method, "setincrement()"? . . . > Not that there's any real utility in that. That was a short lived suggestion ;-) Also, it would entail storing an extra value in the dictionary header. That alone would be a killer. Raymond -- http://mail.

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Paul McGuire
-1 on set increment. I think this makes your intent much clearer: .d={} .for word in text.split(): .d.tally(word) .if word.lower() in ["a","an","the"]: .d.tally(word,-1) or perhaps simplest: .d={} .for word in text.split(): .if word.lower() not in ["a","an","the"]: .d

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Aahz
In article <[EMAIL PROTECTED]>, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >The proposed names could possibly be improved (perhaps tally() is more active >and clear than count()). +1 tally() -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "The joy of coding Pyth

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
Raymond Hettinger wrote: > Separating the two cases is essential. Also, the wording should contain strong > cues that remind you of addition and of building a list. > > For the first, how about addup(): > > d = {} > for word in text.split(): > d.addup(word) import copy class safe

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Aahz
In article <[EMAIL PROTECTED]>, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >How about countkey() or tabulate()? Those rank roughly equal to tally() for me, with a slight edge to these two for clarity and a slight edge to tally() for conciseness. -- Aahz ([EMAIL PROTECTED]) <*>

Re: RotatingFileHandler and logging config file

2005-03-19 Thread Rob Cranfill
Bengt Richter wrote: The first hit is http://docs.python.org/lib/node332.html HTH NID (No, It Doesn't) ;-) but thanks anyway. To reiterate, the question is how to make RotatingFileHandler do a doRotate() on startup from a *config file*. No mention of that in what you point to. - ro

subprocess 'wait' method causes .py program to hang.

2005-03-19 Thread Earl Eiland
I calling a Windows executable with PROC = subprocess.Popen('...'), and blocking further python execution until the process terminates with PROC.wait(). Occasionally, something unusual happens with the subprocess, and it fails without terminating the process. When this happens, my Python program

Re: RotatingFileHandler and logging config file

2005-03-19 Thread Rob Cranfill
news.sydney.pipenetworks.com wrote: Yeah...sorry about that. I misunderstood what node333.html was used for. Looks like your best bet may be to extend the RotatingFileHandler directly in the handlers module and call doRollover() in __init__. Ah, now *there's* an intriguing approach! I am too much

Re: Checking if port is in use.

2005-03-19 Thread Grant Edwards
On 2005-03-19, Alex Polite <[EMAIL PROTECTED]> wrote: > > If I try to bind a socket to a port that's already in use I get this > error > > "error socket.error: (98, 'Address already in use')" > > Is there anyway to check in advance if a port i already taken? Yes. Try to bind to the port. If you

Re: wxPython vs. pyQt

2005-03-19 Thread Hans-Peter Jansen
[EMAIL PROTECTED] wrote: > I've narrowed down my toolkit selection for my project to wxPython and > pyQt, and now i'd like to hear any opinions, war stories, peeves, etc, > about them, particularly from anyone who's used _both_toolkits_. I'm > only mildly interested in the IDEs and UI designers fo

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[El Pitonero] > Is it even necessary to use a method name? > > import copy > class safedict(dict): > def __init__(self, default=None): > self.default = default > def __getitem__(self, key): > try: > return dict.__getitem__(self, key) > except KeyError: >

Re: determine os language

2005-03-19 Thread Diez B. Roggisch
Bryan wrote: > is there a way to determine the operating system's language? i can't seem > to find a method that returns the value. Try the module locale. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking if port is in use.

2005-03-19 Thread Peter Hansen
Alex Polite wrote: On lör, mar 19, 2005 at 10:12:10 -0500, Peter Hansen wrote: Alex Polite wrote: You could, for example, bind to a port of "0" and that will auto-assign an available port for you. Does that work in your case? If not, please describe what you are really trying to accomplish. I'm l

Re: RotatingFileHandler and logging config file

2005-03-19 Thread Peter Hansen
Rob Cranfill wrote: Ah, now *there's* an intriguing approach! I am too much a Python noob to know - can I subclass RFH and then invoke that new class from a config file (the crux of my original question) ? I may play around with it today There's at least one way that will work, though it ma

Re: subprocess 'wait' method causes .py program to hang.

2005-03-19 Thread Jeff Epler
You can use PROC.poll() to find out whether the process has exited yet or not (for instance, in a 'while' loop along with a delay). I don't know what facilities exist to forcibly terminate programs on Windows, though. On Unix, os.kill() can be used to kill a process given its pid. Perhaps some of

Re: Working with Huge Text Files

2005-03-19 Thread Lorn Davies
Thank you all very much for your suggestions and input... they've been very helpful. I found the easiest apporach, as a beginner to this, was working with Chirag's code. Thanks Chirag, I was actually able to read and make some edit's to the code and then use it... woohooo! My changes are annotated

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-03-19 07:19: Brian van den Broek wrote: Raymond Hettinger said unto the world upon 2005-03-18 20:24: I would like to get everyone's thoughts on two new dictionary methods: def appendlist(self, key, *values): try: self[ke

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > [Jeff Epler] > > Maybe something for sets like 'appendlist' ('unionset'?) > > While this could work and potentially be useful, I think it is better to keep > the proposal focused on the two common use cases. Adding a third would reduce > the chance

Re: any() and all() Was: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Roose
Ah OK, I stand corrected. Whoops. I just read the web page and thought the wrong thing, that makes sense. > Think about it. A key= function is quite a different thing. It provides a > *temporary* comparison key while retaining the original value. IOW, your > re-write is incorrect: > > >>> L =

Re: Shared Memory Example (Python, ctypes, VC++)

2005-03-19 Thread Do Re Mi chel La Si Do
Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Do Re Mi chel La Si Do
Hi if key not in d: d[key] = {subkey:value} else: d[key][subkey] = value and d[(key,subkey)] = value ? Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
Raymond Hettinger wrote: > > As written out above, the += syntax works fine but does not work with append(). > ... > BTW, there is no need to make the same post three times. The append() syntax works, if you use the other definition of safedict (*). There are more than one way of defining safedict

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
"Aahz" <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > > >The proposed names could possibly be improved (perhaps tally() is more active > >and clear than count()). > > +1 tally() -1 for count(): Implies an accessor, not a mutator. -1

Re: Is Python like VB?

2005-03-19 Thread Ivan Voras
Dennis Lee Bieber wrote: On Sat, 19 Mar 2005 14:36:02 +0100, Ivan Voras <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: Hey, IIRC, old Turbo Assembler (tasm, by Borland) had those. Much of it was still manual, by it supported semi-automatic vtables and such :) I'd suspect throu

Re: how to use structured markup tools

2005-03-19 Thread Sean McIlroy
Exactly what I was looking for. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

importing two modules with the same name

2005-03-19 Thread Francisco Borges
Hello, This is not stricly necessary but it would be nice if I could get it done. Here is what I want to do: There are 2 "foo" named modules, 'std foo' and 'my foo'. I want to be able to import 'my foo' and then from within my foo, import 'std foo'. Anyone can help?? - Before you start

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
George Sakkis wrote: > "Aahz" <[EMAIL PROTECTED]> wrote: > > In article <[EMAIL PROTECTED]>, > > Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > > > > >The proposed names could possibly be improved (perhaps tally() is more active > > >and clear than count()). > > > > +1 tally() > > -1 for count():

Re: importing two modules with the same name

2005-03-19 Thread Mike Meyer
Francisco Borges <[EMAIL PROTECTED]> writes: > I could simply copy optparse's code and hack it or I could simply import > it and overload some methods, which is what I think would be a cleaner > solution. So why aren't you willing to give your optparse module a different name?

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Dan Sommers
On Sat, 19 Mar 2005 15:17:59 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > [Dan Sommers] >> Curious that in this lengthy discussion, a method name of >> "accumulate" never came up. I'm not sure how to separate the two >> cases (accumulating scalars vs. accumulating a list), though. > Se

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kay Schluehr
Raymond Hettinger wrote: > I would like to get everyone's thoughts on two new dictionary methods: > > def count(self, value, qty=1): > try: > self[key] += qty > except KeyError: > self[key] = qty > > def appendlist(self, key, *

Re: Variable Variable

2005-03-19 Thread Bruno Desthuilliers
Tanteauguri a écrit : Hi List, is there in python a variable variable like in PHP ($$var)? Hopefully, no. See other answers in that thread for pythonic idioms. -- http://mail.python.org/mailman/listinfo/python-list

FAQ 1.7.3 : How can I have modules that mutually import each other

2005-03-19 Thread MackS
Hi I'm new to Python, I've read the FAQ but still can't get the following simple example working: # file main_mod.py: global_string = 'abc' def main(): import auxiliary_mod instance = auxiliary_mod.ClassA() instance.fun() return main() # file auxiliary_mod.py: class ClassA:

Re: FAQ 1.7.3 : How can I have modules that mutually import each other

2005-03-19 Thread Reinhold Birkenfeld
MackS wrote: > Hi > > I'm new to Python, I've read the FAQ but still can't get the following > simple example working: > > # file main_mod.py: > > global_string = 'abc' > > def main(): > > import auxiliary_mod > instance = auxiliary_mod.ClassA() > instance.fun() > return > > m

Re: Obfuscated Python: fun with shadowing builtins

2005-03-19 Thread Bruno Desthuilliers
fraca7 a écrit : Michael Hoffman wrote: Enjoy ;) That's not the exact word that first came to my mind :) -- http://mail.python.org/mailman/listinfo/python-list

Re: importing two modules with the same name

2005-03-19 Thread Tim Jarman
Francisco Borges wrote: > Hello, > > This is not stricly necessary but it would be nice if I could get it > done. Here is what I want to do: > > There are 2 "foo" named modules, 'std foo' and 'my foo'. I want to be > able to import 'my foo' and then from within my foo, import 'std > foo'. Anyone

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Paul Rubin
"El Pitonero" <[EMAIL PROTECTED]> writes: > What about no name at all for the scalar case: > > a['hello'] += 1 > a['bye'] -= 2 I like this despite the minor surprise that it works even when a['hello'] is uninitialized. -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >