Re: How to create an object instance from a string??

2005-03-19 Thread Do Re Mi chel La Si Do
Hi ! Sorry, but : The statement exec does not have impact on the style. Like with exefile or import (and other), the style is determined by the contents. Rather judge "exec" (or import, or execfile) than the contents, it is an error of causality. @-salutations -- Michel Claveau -- ht

Re: Text-to-speech

2005-03-19 Thread Tim Churches
Charles Hartman wrote: > Does anyone know of a cross-platform (OSX and Windows at least) library > for text-to-speech? I know there's an OSX API, and probably also for > Windows. I know PyTTS exists, but it seems to talk only to the Windows > engine. I'd like to write a single Python module to han

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kay Schluehr
*pling* ! I'm sometimes a bit slow :) Regards Kay -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
"Michael Spencer" <[EMAIL PROTECTED]> wrote: > I could imagine a class: accumulator(mapping, default, incremetor) such that: > >>> my_tally = accumulator({}, 0, operator.add) > or > >>> my_dict_of_lists = accumulator({}, [], list.append) > or > >>> my_dict_of_sets = accumulator({}, set(),

Re: inline comparison

2005-03-19 Thread Tim Roberts
sam <[EMAIL PROTECTED]> wrote: >Hi, > >I got the the following syntax error in comparison: > File "/usr/local/work/myparser.py", line 85 > if ( (m=self.macro_parser.match (d)) != None ): >^ >SyntaxError: invalid syntax > >How can I get around wtih this? I don't want to break down

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Ron
On Sat, 19 Mar 2005 01:24:57 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >def count(self, value, qty=1): >try: >self[key] += qty >except KeyError: >self[key] = qty > >def appendlist(self, key, *values): >tr

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
> > +1 on this. The new suggested operations are meaningful for a subset > of all > > valid dicts, so they > > should not be part of the base dict API. If any version of this is > approved, > it will clearly be an > > application of the "practicality beats purity" zen rule, and the > > justificatio

Re: Working with Huge Text Files

2005-03-19 Thread cwazir
John Machin wrote: > More meaningful names wouldn't go astray either :-) I heartily concur! Instead of starting with: fields = line.strip().split(',') you could use something like: (f_name, f_date, f_time, ...) = line.strip().split(',') Of course then you won't be able to use ', '.join(fiel

1

2005-03-19 Thread Ron038547
2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Michele Simionato
I am surprised nobody suggested we put those two methods into a separate module (say dictutils or even UserDict) as functions: from dictutils import tally, listappend tally(mydict, key) listappend(mydict, key, value) I am -1 about a specific subclass of dict in the standard library, I would not

Re: Text-to-speech

2005-03-19 Thread Robert Kern
Charles Hartman wrote: Does anyone know of a cross-platform (OSX and Windows at least) library for text-to-speech? I know there's an OSX API, and probably also for Windows. I know PyTTS exists, but it seems to talk only to the Windows engine. I'd like to write a single Python module to handle t

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Michael Spencer
Kay Schluehr wrote: Maybe also the subclassing idea I introduced falls for short for the same reasons. Adding an accumulator to a dict should be implemented as a *decorator* pattern in the GoF meaning of the word i.e. adding an interface to some object at runtime that provides special facilities. U

Re: Building Time Based Bins

2005-03-19 Thread John Machin
On 19 Mar 2005 19:01:05 -0800, "MCD" <[EMAIL PROTECTED]> wrote: >Hello, I'm new to python and this group and am trying to build some >bins and was wondering if any of you could kindly help me out. I'm a >bit lost on how to begin. Are you (extremely) new to computer programming? Is this school hom

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kay Schluehr
George Sakkis wrote: > > -1 form me. > > > > I'm not very glad with both of them ( not a naming issue ) because i > > think that the dict type should offer only methods that apply to each > > dict whatever it contains. count() specializes to dict values that are > > addable and appendlist to those

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
"John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > George Sakkis wrote: > > +1 on this. The new suggested operations are meaningful for a subset > of all valid dicts, so they > > should not be part of the base dict API. If any version of this is > approved, it will clearl

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Beni Cherniavsky
Alexander Schmolck wrote: "Raymond Hettinger" <[EMAIL PROTECTED]> writes: The rationale is to replace the awkward and slow existing idioms for dictionary based accumulation: d[key] = d.get(key, 0) + qty d.setdefault(key, []).extend(values) Indeed not too readable. The try..except version is

Re: Building Time Based Bins

2005-03-19 Thread Michael Spencer
MCD wrote: Hello, I'm new to python and this group and am trying to build some bins and was wondering if any of you could kindly help me out. I'm a bit lost on how to begin. I have some text files that have a time filed along with 2 other fields formatted like this >> 1231 23 56 1232 25 79 1234 26

Text-to-speech

2005-03-19 Thread Charles Hartman
Does anyone know of a cross-platform (OSX and Windows at least) library for text-to-speech? I know there's an OSX API, and probably also for Windows. I know PyTTS exists, but it seems to talk only to the Windows engine. I'd like to write a single Python module to handle this on both platforms,

Re: inline comparison

2005-03-19 Thread Peter Hansen
sam wrote: I got the the following syntax error in comparison: File "/usr/local/work/myparser.py", line 85 if ( (m=self.macro_parser.match (d)) != None ): ^ SyntaxError: invalid syntax How can I get around wtih this? Break the comparison into two steps. > I don't want to break dow

Re: 2.4 crashes when try to exit app and mulitple threads active

2005-03-19 Thread Peter Hansen
Maxwell Hammer wrote: An application I am developing executes many threads and then has a "monitor" part that waits for certain events. One of these events causes the application to have to shutdown. On shutdown the monitor part notifies the threads of a shutdown, and the threads must cleanup and e

Re: How to create an object instance from a string??

2005-03-19 Thread Peter Hansen
Do Re Mi chel La Si Do wrote: Also : classname = "Dog" exec("b="+classname+"()") b.bark() or classname = "Dog" exec("cl="+classname) b=cl() b.bark() Ugh. The statement exec (note: it's a statement, not a function call as you imply with the above) is rarely either require

Simple sizer question

2005-03-19 Thread skol
I have a SplitterWindow and two panels p1 and p2 in it. I can put GenericDirCtrl into the left panel (p1), however it (DirCtrl) stays small. I'd like to stretch it in the whole of p1. The following code doesn't work, please help. dir3 = wx.GenericDirCtrl(p1, -1, size=(-1,-1), style=... etc

inline comparison

2005-03-19 Thread sam
Hi, I got the the following syntax error in comparison: File "/usr/local/work/myparser.py", line 85 if ( (m=self.macro_parser.match (d)) != None ): ^ SyntaxError: invalid syntax How can I get around wtih this? I don't want to break down this comparison in two steps. Thanks Sam --

Re: Working with Huge Text Files

2005-03-19 Thread John Machin
[EMAIL PROTECTED] wrote: > Lorn Davies wrote: > > > if (fields[8] == 'N' or 'P') and (fields[6] == '0' or '1'): > > ## This line above doesn't work, can't figure out how to struct? > > In Python you would need to phrase that as follows: > if (fields[8] == 'N' or fields[8] == 'P') and (fields[6

Building Time Based Bins

2005-03-19 Thread MCD
Hello, I'm new to python and this group and am trying to build some bins and was wondering if any of you could kindly help me out. I'm a bit lost on how to begin. I have some text files that have a time filed along with 2 other fields formatted like this >> 1231 23 56 1232 25 79 1234 26 88 1235 2

Re: Working with Huge Text Files

2005-03-19 Thread cwazir
Lorn Davies wrote: > if (fields[8] == 'N' or 'P') and (fields[6] == '0' or '1'): > ## This line above doesn't work, can't figure out how to struct? In Python you would need to phrase that as follows: if (fields[8] == 'N' or fields[8] == 'P') and (fields[6] == '0' or fields[6] == '1'): or al

How two modules call functions defined in each other?

2005-03-19 Thread Tian
I am python beginner, I have a question about the interdependence of modules. For example, when I have two modules: module1.py - def plus(x): return add(x,1) module2.py - def add(x,y): return x+y def plus2(x): return plus(x)+1 How should I write "import" in both

Hi Guys. First Time Poster

2005-03-19 Thread sheldon279
Hi guys. First time poster long time reader. Just wanted to say "Hi" ;) On a side note my Hubby is REAL excited about this new IPO stock GRDX. They just started trading this one like 2 days ago. It's already almost doubled in just 2 days! My Husband is really excited about this stock. Say's it co

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread John Machin
George Sakkis wrote: > +1 on this. The new suggested operations are meaningful for a subset of all valid dicts, so they > should not be part of the base dict API. If any version of this is approved, it will clearly be an > application of the "practicality beats purity" zen rule, and the justificat

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Alexander Schmolck
"Raymond Hettinger" <[EMAIL PROTECTED]> writes: > The rationale is to replace the awkward and slow existing idioms for > dictionary > based accumulation: > > d[key] = d.get(key, 0) + qty > d.setdefault(key, []).extend(values) > > In simplest form, those two statements would now be coded m

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
Michael Spencer wrote: > 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

2.4 crashes when try to exit app and mulitple threads active

2005-03-19 Thread Maxwell Hammer
An application I am developing executes many threads and then has a "monitor" part that waits for certain events. One of these events causes the application to have to shutdown. On shutdown the monitor part notifies the threads of a shutdown, and the threads must cleanup and exit. When all threads

how to refresh grid on a notebook?

2005-03-19 Thread dimitri pater
Hello, To be honest, I also posted this on the wxPython mailing list. But I thought maybe some of you on the python list can help me... I am trying to refresh a pane of a notebook that contains a grid that contains data from a MySQL database. Here is the code (sorry, it's quite long): #!/usr/bin/

Re: PyGTK and pyexe

2005-03-19 Thread Tom Cocagne
H. Well, the way I did it, if I remember correctly (the files are at work), was to run the line "python setup.py py2exe --force --excludes gtk, gobject,pango" and then copied the entire GTK directory into the distribution directory. Just copying the DLLs doesn't suffice since there are other f

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Michael Spencer
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, *values):

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread George Sakkis
> -1 form me. > > I'm not very glad with both of them ( not a naming issue ) because i > think that the dict type should offer only methods that apply to each > dict whatever it contains. count() specializes to dict values that are > addable and appendlist to those that are extendable. Why not > su

Re: Simple XML-to-Python conversion

2005-03-19 Thread [EMAIL PROTECTED]
Thanks Lutz! I should have looked into Amara's binderytools module earlier. This is just the type of tool I was looking for. When I tried testing its compatibility with py2exe, I was _almost_ able to compile... Does anyone know where the following libraries exist? I thought Amara would have th

Re: importing two modules with the same name

2005-03-19 Thread El Pitonero
Tim Jarman wrote: > But if your foo is under your control, why not do everyone a favour and call > it something else? His case is a canonical example of a patch. Often you'd like to choose the "patch" approach because: (1) the third-party may eventually incorporate the changes themselves, hence y

ANN: Snakelets 1.38 (simple-to-use web app server with dynamic pages)

2005-03-19 Thread Irmen de Jong
I'm happy to say that Snakelets 1.38 is available. Snakelets is a very simple-to-use Python web application server. This project provides a built-in threaded web server (so you don't need to set up Apache or another web server), Ypages (HTML+Python language, similar to Java's JSPs) and Snakelets:

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Ron
On 19 Mar 2005 11:33:20 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >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 K

Re: Event Handeling Between Two wxPanles in A wxNotebook

2005-03-19 Thread MyHaz
so you run data pool as like a sruct that contains all your global objects? That sounds like an iteresting way of doing things. i try to stay away from gloabs as much as possible but this might be a good time to queue up that particular tool thanks for your reply -- http://mail.python.org/mailma

Re: How to create an object instance from a string??

2005-03-19 Thread Ksenia Marasanova
On 19 Mar 2005 14:16:42 -0800, Tian <[EMAIL PROTECTED]> wrote: > How can I create an instance of an object from a string? > > For example, I have a class Dog: > class Dog: > def bark(self): > print "Arf!!!" > > I have a string: > classname = "Dog" > > How can I create a instance of Dog fro

Re: How to create an object instance from a string??

2005-03-19 Thread Do Re Mi chel La Si Do
Hi ! Also : classname = "Dog" exec("b="+classname+"()") b.bark() or classname = "Dog" exec("cl="+classname) b=cl() b.bark() Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread David Eppstein
In article <[EMAIL PROTECTED]>, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > Also, in all of my code base, I've not run across a single opportunity to use > something like unionset(). In my code, this would be roughly tied with appendlist for frequency of use. -- David Eppstein Computer

Re: How to create an object instance from a string??

2005-03-19 Thread Patrick Useldinger
Tian wrote: I have a string: classname = "Dog" It's easier without strings: >>> classname = Dog >>> classname().bark() Arf!!! >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: importing two modules with the same name

2005-03-19 Thread El Pitonero
Francisco Borges wrote: > 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?? In other words, you would like to make a "patch" on third-party code. There are many ways to do it. Here is j

Re: How to create an object instance from a string??

2005-03-19 Thread Tian
This is very useful, thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: [python-sybase] Sybase module 0.37pre1 released

2005-03-19 Thread Skip Montanaro
Dave> This release contains a number of small bugfixes and patches Dave> received from users. ... I don't see this change: *** /Users/skip/src/sybase-0.36/Sybase.py Sun Apr 27 05:54:35 2003 --- /Users/skip/tmp/Sybase.py Sat Mar 19 16:46:17 2005 *** *** 436,441 **

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread David Eppstein
In article <[EMAIL PROTECTED]>, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > The rationale is to replace the awkward and slow existing idioms for > dictionary > based accumulation: > > d[key] = d.get(key, 0) + qty > d.setdefault(key, []).extend(values) > > In simplest form, those t

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Raymond Hettinger
[Bengt Richter] > IMO Raymond's Zen concerns > are the ones to think about first, and then efficiency, which was one of the motivators > in the first place ;-) Well said. I find the disassembly (presented in the first post) to be telling. The compiler has done a great job and there is no fluff -

Re: How to create an object instance from a string??

2005-03-19 Thread Peter Hansen
Tian wrote: How can I create an instance of an object from a string? For example, I have a class Dog: class Dog: def bark(self): print "Arf!!!" I have a string: classname = "Dog" How can I create a instance of Dog from classname? Is there any such methods like those in Java? You generally get

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread John Machin
Reinhold Birkenfeld wrote: > John Machin wrote: > Are you kidding? If you know what "set" and "default" means, you will be > able to guess what "setdefault" means. Same goes for updateBy. > No I'm not kidding -- people from some cultures have no difficulty at all in mentally splitting up "words"

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

2005-03-19 Thread John Machin
On 19 Mar 2005 12:05:18 -0800, "MackS" <[EMAIL PROTECTED]> 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() >

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Paul Rubin
"Raymond Hettinger" <[EMAIL PROTECTED]> writes: > I find the disassembly (presented in the first post) to be telling. > The compiler has done a great job and there is no fluff -- all of > those steps have been specified by the programmer and he/she must at > some level be aware of every one of them

How to create an object instance from a string??

2005-03-19 Thread Tian
How can I create an instance of an object from a string? For example, I have a class Dog: class Dog: def bark(self): print "Arf!!!" I have a string: classname = "Dog" How can I create a instance of Dog from classname? Is there any such methods like those in Java? -- http://mail.python.o

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Reinhold Birkenfeld
John Machin wrote: > Raymond Hettinger wrote: >> I would like to get everyone's thoughts on two new dictionary > methods: > > +1 for each. > >> PROBLEMS BEING SOLVED >> - >> >> The readability issues with the existing constructs are: >> >> * They are awkward to teach, create,

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread John Machin
Raymond Hettinger wrote: > I would like to get everyone's thoughts on two new dictionary methods: +1 for each. > PROBLEMS BEING SOLVED > - > > The readability issues with the existing constructs are: > > * They are awkward to teach, create, read, and review. > * Their wording

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Bengt Richter
On Sat, 19 Mar 2005 07:13:15 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: >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, valu

Re: list of unique non-subset sets

2005-03-19 Thread Dirk Thierbach
Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] ] >>> OK, so I need to be more precise. >>> Given a list of sets, output the largest list of sets (from this list, >>> order does not matter) such that: >>> 1) there is no set that is a PROPER subset of another set in this list >>> 2

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

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

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

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

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

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

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

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

  1   2   >