Re: newbie - threading

2005-03-29 Thread MyHaz
Posting the error message could help. Also you might check out this example http://thraxil.org/thread.txt - Haz -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread OPQ
#For the record, I'm not on premature optimisation anymore. #The code is working. I just want to save hours of computing, without relying to much on C extensions. #Nevertheless, thansk for tips, clarifications and explanations. > longone=longone + char # where len(char)== 1 > > > > I known t

Re: Overriding methods in classes you don't control

2005-03-29 Thread Amaury Forgeot d'Arc
Alex VanderWoude a écrit : Here's the situation. I'm using wxPython, and I want to make an enhancement in the __init__ method of all the frame classes. The ideal place to do this is in wxFrame.__init__, since any change there will automatically be inherited by the other frame classes (for example,

Re: Overriding methods in classes you don't control

2005-03-29 Thread Amaury Forgeot d'Arc
Alex VanderWoude a écrit : Here's the situation. I'm using wxPython, and I want to make an enhancement in the __init__ method of all the frame classes. The ideal place to do this is in wxFrame.__init__, since any change there will automatically be inherited by the other frame classes (for example,

newbie - threading

2005-03-29 Thread martijn
H!, I have made a spider and now I want to use threading so it will be faster faster and faster :) But I don't understand threading. So I try this but I get a error in windows 2000. --- class connector(threading.Thread): def __init__(self,url): self.url = url threading

Re: Weakrefs to classes that derive from str

2005-03-29 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Steven Bethard <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > Why doesn't this work? > > > from weakref import ref > class C(str): pass > > ... > ref(C()) > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: cannot cre

Re: IMAP4.search by message-id ?

2005-03-29 Thread Max M
Sean Dodsworth wrote: Can anyone tell me how to get a message's number from the message-id using IMAP4.search? I've tried this: resp, items = server.search(None, 'HEADER', '"Message-id"', msgID) but it gives me a 'bogus search criteria' error Why do you need the 'HEADER' Wouldn't this be enou

Re: Queue.Queue-like class without the busy-wait

2005-03-29 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > > There needs to be a way to send signals to threads, or raise > > asynchronous exceptions in them. There's been some discussion in > > sourceforge about that, but the issues involved are complex. > > Well I have raised this issue before and as far as I

Re: Things you shouldn't do

2005-03-29 Thread Andrew Dalke
Steve wrote: > [an anecdote on distinguishing l1 and 11] > What are some of other people's favourite tips for > avoiding bugs in the first place, as opposed to finding > them once you know they are there? There's a good book on this topic - Writing Solid Code. A

Re: [maintenance doc updates]

2005-03-29 Thread Do Re Mi chel La Si Do
Hi ! Thanks. But, for previous versions of Python, I downloaded a CHM version; and, at http://docs.python.org/download.html, I don't found this format. is this a lapse of memory? Would it be possible to have a continuity in the availability of the formats? Thanks again. Michel Claveau

Re: Why tuple with one item is no tuple

2005-03-29 Thread Antoon Pardon
Op 2005-03-29, Ville Vainio schreef <[EMAIL PROTECTED]>: >> "Antoon" == Antoon Pardon <[EMAIL PROTECTED]> writes: > >Antoon> Op 2005-03-27, Joal Heagney schreef <[EMAIL PROTECTED]>: > >> Antoon Pardon wrote: > >> > >>> So python choose a non-deterministic direction. To me (2,3)

IMAP4.search by message-id ?

2005-03-29 Thread Sean Dodsworth
Can anyone tell me how to get a message's number from the message-id using IMAP4.search? I've tried this: resp, items = server.search(None, 'HEADER', '"Message-id"', msgID) but it gives me a 'bogus search criteria' error Any ideas? -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Ville Vainio
> "Steven" == Steven Bethard <[EMAIL PROTECTED]> writes: Steven> to be documented as a builtin type. I don't find the Steven> argument "builtin type methods are hard to find" Steven> convincing -- the solution here is to fix the Steven> documentation, not refuse to add builtin

Re: Trouble with RC2

2005-03-29 Thread Do Re Mi chel La Si Do
Hi ! Yes, P4RC2 is a error ; it is Python 2.4.1 release candidate 2 Yes, P2.4 is Python 2.4 The scripts use ONLY space-indentation. But the important points are : - if I install Python 2.4 on the rc2 (overwrite), then problem disappears, with the SAME scripts. - the problem is only wi

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Tim Roberts
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > >"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> 1) The stuff doesn't has to be spread over multiple pages. One >> can have 2 functions, each about three quarter of a page. >> The second function will then cross a page

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Steven Bethard
Terry Reedy wrote: But if classmethods are intended to provide alternate constructors But I do not remember that being given as a reason for classmethod(). But I am not sure what was. Well I haven't searched thoroughly, but I know one place that it's referenced is in descrintro[1]: "Factoid: __

Re: instance vs class attributes

2005-03-29 Thread James Stroud
You need 2 underscores to mangle. On Tuesday 29 March 2005 09:58 pm, runsun pan wrote: > >>> shy._Shy__mangled_method() > > Ive been mangled! > > > Hi Brian, > > can you explain how this could possibly work? First of all it's not > standard python usage, > and secondly it's not working on my compu

Re: BF interpreter in Python

2005-03-29 Thread Do Re Mi chel La Si Do
Hi ! Good idea. I take this interpreter with jubilation. Can I add your URL at http://mclaveau.com/esolang ? Other question : do you know PATH ? (http://pathlang.sourceforge.net) @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Terry Reedy
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Terry Reedy wrote: >> "Steven Bethard" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >>>True it's not a huge win. But I'd argue that for the same reasons that >>>dict.fromkeys is a dict classmeth

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Myles Strous
I wrote: > It can be quite useful for inserting something into a list (or string), > after finding the position where you wish to insert it. Oops, I missed Dennis Lee Bieber's working example of exactly that. My apologies. Regars, Myles. -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Myles Strous
Javier Bezos wrote: > "Jacob Lee" <[EMAIL PROTECTED]> escribió en el mensaje > > satisfy some handy properties, the first of which being: > > l[:n] + l[n:] = l > > I don't think l[:5] + l[5:] = l is a handy property > and to me is clearly counterintuitive. Further, It can be quite useful for ins

Re: urllib.urlretireve problem

2005-03-29 Thread gene . tani
Mertz' "Text Processing in Python" book had a good discussion about trapping 403 and 404's. http://gnosis.cx/TPiP/ Larry Bates wrote: > I noticed you hadn't gotten a reply. When I execute this it put's the following > in the retrieved file: > > > > 404 Not Found > > Not Found > The requested

Re: instance vs class attributes

2005-03-29 Thread runsun pan
>>> shy._Shy__mangled_method() Ive been mangled! Hi Brian, can you explain how this could possibly work? First of all it's not standard python usage, and secondly it's not working on my computer... pan -- http://mail.python.org/mailman/listinfo/python-list

Re: Weakrefs to classes that derive from str

2005-03-29 Thread Steven Bethard
Ron Garret wrote: Why doesn't this work? from weakref import ref class C(str): pass ... ref(C()) Traceback (most recent call last): File "", line 1, in ? TypeError: cannot create weak reference to 'C' object Note that you don't need the class redirection: py> ref('') Traceback (most recent call

math - need divisors algorithm

2005-03-29 Thread Philp Smith
Hi Does anyone have suggested code for a compact, efficient, elegant, most of all pythonic routine to produce a list of all the proper divisors of an integer (given a list of prime factors/powers) -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Steven Bethard
Terry Reedy wrote: "Steven Bethard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] True it's not a huge win. But I'd argue that for the same reasons that dict.fromkeys is a dict classmethod, the itertools methods could be iter classmethods (or staticmethods). As near as I could te

RE: mod_python

2005-03-29 Thread Delaney, Timothy C (Timothy)
onur2029 wrote: >I need mod_python resources,documentation or ebook.But not manual > from modpython.org.I'm waiting for your links. http://www.catb.org/~esr/faqs/smart-questions.html Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

mod_python

2005-03-29 Thread onur2029
Hi everybody, I need mod_python resources,documentation or ebook.But not manual from modpython.org.I'm waiting for your links. ONUR YILMAZ -- http://mail.python.org/mailman/listinfo/python-list

Re: Things you shouldn't do

2005-03-29 Thread Paul McGuire
This struck me also when I first saw this post. It reminded me of a body of code I inherited at a former job, that I had to help untangle. The code was filled with two key variables: t_1 and t_l. Printing out the source in a Courier font made these two vars completely indistinguishable, and it to

Re: how do you use a closure in a class

2005-03-29 Thread Paul McGuire
Well, despite my parenthetical disclaimer, my attempted point was that the OP wanted to avoid replicating several functions that were mostly the same. I think Python's idiom of using a function to create and return callables is a comparable feature to using anonymous closures. Unfortunately, I gue

Re: instance vs class attributes

2005-03-29 Thread Brian van den Broek
James Stroud said unto the world upon 2005-03-29 20:37: Sarir said: Here are my questions: 3) Should private data be written as self._x instead of self.x? This is a long standing debate. The usual answer is "we are all grownups here", meaning that self.x is preferred. However, I personally like

Re: Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-29 Thread George Yoshida
Rakesh wrote: > To quote a much smaller trimmed-down example, here is how it looks > like: > ## --- > # Entry Point to the whole program > ## --- > def main(): > mylist = GenerateList() > minnumber = min

Re: Python for a 10-14 years old?

2005-03-29 Thread Greg Ewing
Leif B. Kristensen wrote: I've got a thirteen-year old daughter to whom I have recently taught the HTML basics, but she doesn't readily take to actual programming. If you've got any idea what I should push to her to get her fascinated about _real_ programming, I'd be obliged. If she's interested in

Re: Python for a 10-14 years old?

2005-03-29 Thread Joal Heagney
Duncan Booth wrote: Joal Heagney wrote: Nice. I still have to download a version of pygame to try this out, but the fact that you can't hide the turtle in python.turtle was bugging me out with my version. (A fair bit of copy/paste in gimp, I can tell you!) What was wrong with hiding the turtle?

Re: itertools to iter transition (WAS: Pre-PEP: Dictionaryaccumulator methods)

2005-03-29 Thread George Sakkis
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > > "Steven Bethard" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > True it's not a huge win. But I'd argue that for the same reasons that > > dict.fromkeys is a dict classmethod, the itertools methods could be iter > > classmethods (or s

Things you shouldn't do

2005-03-29 Thread Steve
All names have been removed to protect the guilty :-) In an earlier post, I read a piece of code: l1 = [1, 2, 3] l2 = [1, 2, 3] l1 == l2 True I immediately gave a double-take: 11 equals 12? What gives? Can you re-bind literals in Python??? >>> 11 = [1, 2, 3] SyntaxError: can't assign to literal A

Re: Python for a 10-14 years old?

2005-03-29 Thread Joal Heagney
Joal Heagney wrote: Joal Heagney wrote: Duncan Booth wrote: Joal Heagney wrote: Nice. I still have to download a version of pygame to try this out, but the fact that you can't hide the turtle in python.turtle was bugging me out with my version. (A fair bit of copy/paste in gimp, I can tell you!

reading from a txt file

2005-03-29 Thread jrlen balane
how should i modify this data reader: (assumes that there is only one entry per line followed by '\n') data_file = open(os.path.normpath(self.TextFile.GetValue()), 'r') data = data_file.readlines() self.irradianceStrings = map(str, data) self.irradianceIntegers = map(int, data) self.Irrad

Re: Python for a 10-14 years old?

2005-03-29 Thread Joal Heagney
Joal Heagney wrote: Duncan Booth wrote: Joal Heagney wrote: Nice. I still have to download a version of pygame to try this out, but the fact that you can't hide the turtle in python.turtle was bugging me out with my version. (A fair bit of copy/paste in gimp, I can tell you!) What was wrong wi

Re: Python for a 10-14 years old?

2005-03-29 Thread Greg Ewing
Jot wrote: If she's really gifted i hope she dumps that obsolete monolithic kernel as soon as she realizes that such beautiful language as python shouldn't be used on top of ugly, badly designed software. Maybe she'll go on to write that oft-proposed pure Python operating system, and give us a co

Re: automatically mapping builtins (WAS: itertools to iter transition)

2005-03-29 Thread Michael Spencer
Steven Bethard wrote: Michael Spencer wrote: > While we're on the topic, what do you think of having unary, > non-summary builtins automatically map themselves when called with an > iterable that would otherwise be an illegal argument: I personally don't much like the idea because I expect 'int'

Re: numbering variables

2005-03-29 Thread Steve
Ron_Adam wrote: On Mon, 28 Mar 2005 13:39:17 +0200, remi <[EMAIL PROTECTED]> wrote: Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is fi

Re: why and when we should do it?

2005-03-29 Thread Terry Reedy
"Su Wei" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >i hvae seen some code like this before: I really hope not... >class BusinessBO : dev __init__(slef): #write you own code here dev businessMethod : #write you own code here That is 'def', not 'dev' >p

Re: How to use "__new__"?

2005-03-29 Thread Terry Reedy
"could ildg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > __new__() is intended mainly to allow subclasses of immutable types > (like int, str, or tuple) to customize instance creation. Exactly. It is an anwer to the conundrum: How do you give an immutable object its unchangea

Re: How to use "__new__"?

2005-03-29 Thread Heiko Wundram
Am Mittwoch, 30. März 2005 04:36 schrieb Heiko Wundram: > You could extend the above example quite easily to deal with deallocation > (a reference to each created singleton is retained using the above class, > always, as long as the program is running) and also to make it threadsafe > or to disable

Re: how do you use a closure in a class

2005-03-29 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have several functions that are almost the same in one class I would > like to use a closure to get rid of the extra code how would I do this? A more specific example might get a more to the point solution ;-) TJR -- http://mail

Re: Problem in designing a global directory in python

2005-03-29 Thread Terry Reedy
"Tian" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want to create a object directory called Context in my program, which > is based on a dict to save and retrieve values/objects by string-type I suspect that you would accomplish your goal much more easily by calling your modu

Re: How to use "__new__"?

2005-03-29 Thread Heiko Wundram
Am Mittwoch, 30. März 2005 03:27 schrieb could ildg: > Thank you. > I'm clear after I read the doc: > If __new__() returns an instance of cls, then the new instance's > __init__() method will be invoked like "__init__(self[, ...])", where > self is the new instance and the remaining arguments are t

Re: checksum works in unix but not win32 os

2005-03-29 Thread Peter Hansen
GujuBoy wrote: i have the following code...which works fine in UNIX but then i move it over to WINDOWS XP and check the sum on the same file that i tested on unix and i get different results. def checksum(fileobj): filedata = array.array('B', fileobj.read()) Did you make sure you opened this "f

Re: distance, angle restraint

2005-03-29 Thread Terry Reedy
"HYUN-CHUL KIM" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I put more than 10,000 points in a box > and then want to get one of many solutions that matches all > angle restraints among any 3 points and all distance restraints > between any 2 points. It is not clear to me what

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Terry Reedy
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > True it's not a huge win. But I'd argue that for the same reasons that > dict.fromkeys is a dict classmethod, the itertools methods could be iter > classmethods (or staticmethods). As near as I could tell from the

Weakrefs to classes that derive from str

2005-03-29 Thread Ron Garret
Why doesn't this work? >>> from weakref import ref >>> class C(str): pass ... >>> ref(C()) Traceback (most recent call last): File "", line 1, in ? TypeError: cannot create weak reference to 'C' object >>> Note that this does work: >>> class D(int): pass ... >>> ref(D()) >>> Likewise for

Re: checksum works in unix but not win32 os

2005-03-29 Thread Trent Mick
[GujuBoy wrote] > i have the following code...which works fine in UNIX but then i move it > over to WINDOWS XP and check the sum on the same file that i tested on > unix and i get different results. > > def checksum(fileobj): > filedata = array.array('B', fileobj.read()) > totbytes = len(f

Re: why and when we should do it?

2005-03-29 Thread Swaroop C H
On Wed, 30 Mar 2005 09:38:28 +0800, Su Wei <[EMAIL PROTECTED]> wrote: > hi,everybody,Sorry to bother you. > why and when we should add the keyword "pass" ? You can use the 'pass' keyword to indicate an empty block. For example, if True: pass pass is usually used as a placeholder so that you

distutils: package data

2005-03-29 Thread Qiangning Hong
I am writing a setup.py for my package. I have a pre-compiled myextmod.pyd file in my package and I want the distutils to automatically copy it to C:\Python23\Lib\site-packages\mypackage\myextmod.pyd. I try to add the following parameter to setup(): data_file = [('mypackage', ['mypackage/myex

Weekly Python Patch/Bug Summary

2005-03-29 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 297 open (+11) / 2812 closed (+11) / 3109 total (+22) Bugs: 871 open ( +1) / 4900 closed (+33) / 5771 total (+34) RFE : 175 open ( +0) / 150 closed ( +0) / 325 total ( +0) New / Reopened Patches __ Decimal i

Re: convert user input to Decimal objects using eval()?

2005-03-29 Thread Terry Reedy
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [Julian Hernandez Gomez] >> This is maybe a silly question, but... >> >> is there a "easy way" to make eval() convert all floating >> numbers to Decimal objects and return a Decimal? > > from decimal import Decimal

checksum works in unix but not win32 os

2005-03-29 Thread GujuBoy
i have the following code...which works fine in UNIX but then i move it over to WINDOWS XP and check the sum on the same file that i tested on unix and i get different results. def checksum(fileobj): filedata = array.array('B', fileobj.read()) totbytes = len(filedata) result = 0 de

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 1) The stuff doesn't has to be spread over multiple pages. One > can have 2 functions, each about three quarter of a page. > The second function will then cross a page boundary. Once upon a time, one could put a li

Re: Please help for Python programming

2005-03-29 Thread yy0127
Thanks for your help! I am already fix it!! Many thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: instance vs class attributes

2005-03-29 Thread James Stroud
On Tuesday 29 March 2005 05:37 pm, James Stroud wrote: > > 1) What are the benefits of using a member variable without the 'self' > >    qualifier? (I think this is because you can use _x without an > >    instance of A().) > > No such thing as a benefit here. self.a inside a method is the same as

Re: Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-29 Thread Rakesh
To quote a much smaller trimmed-down example, here is how it looks like: <--> import sys ## ## def GenerateList(): array = ' ' for i in xrange(10): array = (array, i) return array ## --

Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int'

2005-03-29 Thread Rakesh
In my Python code fragment, I want to write a code fragment such that the minimum element of a tuple is subtracted from all the elements of a given tuple. When I execute the following python script I get the following interpreter error. C:\>python test.py 200 ddf DNEWS Version 5.7b1,, S0, posti

why and when we should do it?

2005-03-29 Thread Su Wei
hi,everybody,Sorry to bother you. i hvae seen some code like this before: class BusinessBO : dev __init__(slef): #write you own code here dev businessMethod : #write you own code here pass why and when we should add the keyword "pass" ? and some time i have seen class S

Re: instance vs class attributes

2005-03-29 Thread James Stroud
Sarir said: > Here are my questions: > > 1) What are the benefits of using a member variable without the 'self' >qualifier? (I think this is because you can use _x without an >instance of A().) No such thing as a benefit here. self.a inside a method is the same as a outside (see code belo

Re: urllib.urlretireve problem

2005-03-29 Thread Larry Bates
I noticed you hadn't gotten a reply. When I execute this it put's the following in the retrieved file: 404 Not Found Not Found The requested URL /pool/updates/main/p/perl/libparl5.6_5.6.1-8.9_i386.deb was no t found on this server. You will probably need to use something else to first determ

Re: How to execute a cmd line program without invoking console window?

2005-03-29 Thread Bengt Richter
On 29 Mar 2005 13:23:55 -0800, "Tian" <[EMAIL PROTECTED]> wrote: >In Windows, I have been simply using os.system() to run command line >program in python. but there will be a black console window. How can I >run the program without invoking that window? i guess there are some >function with which

Re: How to use "__new__"?

2005-03-29 Thread could ildg
Thank you. I'm clear after I read the doc: If __new__() returns an instance of cls, then the new instance's __init__() method will be invoked like "__init__(self[, ...])", where self is the new instance and the remaining arguments are the same as were passed to __new__(). If __new__() does not ret

Re: Python Cookbook, 2'nd. Edition is published

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Trent Mick <[EMAIL PROTECTED]> wrote: >> > I don't have my copy yet. Can you give any guidance on how the 2'nd >> > edition compares to the 1'st edition? > >Here is an excerpt from the preface (typing errors are mine): > >If you already own the first edition, yo

Re: good design & method calls

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Ron_Adam <[EMAIL PROTECTED]> wrote: >On Tue, 29 Mar 2005 09:09:37 -0500, Charles Hartman ><[EMAIL PROTECTED]> wrote: > >>I know the answer to this is going to be "It depends . . .", but I want >>to get my mind right. In Fowler's *Refactoring* I read: "Older >>lang

Re: How to use "__new__"?

2005-03-29 Thread Steven Bethard
could ildg wrote: As there is already __init__, why need a __new__? What can __new__ give us while __init__ can't? In what situations we should use __new__? And in what situations we must use __new__? Can __new__ take the place of __init__? I believe the current documentation will be updated when 2

Dr. Dobb's Python-URL! - weekly Python news and links (Mar 30)

2005-03-29 Thread Cameron Laird
QOTW: "This is a Python newsgroup. Assume that we all have been brainwashed." -- Peter Otten "[M]y experience porting Java to Jython is that it mostly involves deleting stuff :-)" -- Kent Johnson "[K]eep in mind, however, that not all problems in life can be solved with software." -- Roy Smith

Re: What's the best GUI toolkit in Python,Tkinter,wxPython,QT,GTK?

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Dave Cook <[EMAIL PROTECTED]> wrote: . . . >wxPython seems to have the best cross-platform support among CPython >toolkits, but it never seemed very Pythonic to me. There's a higher-level >pack

Re: how do you use a closure in a class

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Paul McGuire <[EMAIL PROTECTED]> wrote: >Well, I'm not sure "closure" is the Pythonic way. But in Python, you >can use functions to dynamically create other functions. Here's an >example of this feature (although there are far simpler ways to do >this), tallying vo

Re: Python & LEGO Mindstorm control...

2005-03-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, D H <[EMAIL PROTECTED]> wrote: . . . >I would use the graphical language environment that comes with Lego >Mindstorms. It was designed for kids. > >I haven't seen anyone show how to program mi

Re: Finding attributes in a list

2005-03-29 Thread Bengt Richter
On Tue, 29 Mar 2005 11:29:33 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: >infidel wrote: >> You can use the new 'sorted' built-in function and custom "compare" >> functions to return lists of players sorted according to any criteria: >> >> >players = [ >> >> ... {'name' : 'joe', 'defe

How to use "__new__"?

2005-03-29 Thread could ildg
As there is already __init__, why need a __new__? What can __new__ give us while __init__ can't? In what situations we should use __new__? And in what situations we must use __new__? Can __new__ take the place of __init__? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

instance vs class attributes

2005-03-29 Thread Sarir Khamsi
I come from a C++ background and am learning some of the details of Python's OO capability and now have some questions. Given: #!/bin/env python class A(object): _x = 10 def __init__(self): self.x = 20 def square(self): return self.x * self.x print 'A.x = %d' % A._x a = A() print 'a.x =

RE: Python & LEGO Mindstorm control...

2005-03-29 Thread Tony Meyer
> I have a question re the use of Python to control a robot > built with the LEGO Mindstorm system. > This is to help my 11yr old with his increased interest in > 'programming' and 'robotics'... If not feasible, he wants to > use the graphical-tool that comes with it... > > Would you suggest: >

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Bengt Richter
On Tue, 29 Mar 2005 11:32:33 -0800, Michael Spencer <[EMAIL PROTECTED]> wrote: [...] >While we're on the topic, what do you think of having unary, non-summary >builtins automatically map themselves when called with an iterable that would >otherwise be an illegal argument: That last "otherwise" is

Re: Problem in designing a global directory in python

2005-03-29 Thread '@'.join([..join(['fred', 'dixon']), ..join(['gmail', 'com'])])
noob warning: what is so wonderful about the NEW class over the old ? -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread Jack Diederich
On Tue, Mar 29, 2005 at 12:38:42PM +0300, Ville Vainio wrote: > > "Raymond" == Raymond Hettinger <[EMAIL PROTECTED]> writes: > > Raymond> If the experience works out, then all you're left with is > Raymond> the trivial matter of convincing Guido that function > Raymond> attributes

Re: How do I get better at Python programming?

2005-03-29 Thread alex23
Steve Holden wrote: > Where programming's concerned it's never too soon to start reading other > people's code, and fortunately there's a huge amount of Python about and > available as open source. I found the Cookbook to be especially helpful for this initially: digestable code chunks with plent

Re: How to execute a cmd line program without invoking console window?

2005-03-29 Thread raver2046
Or launch it with pythonw.exe ( on windows ) Sorcier glouton http://sorcier-glouton.ath.cx "rbt" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Tian wrote: >> In Windows, I have been simply using os.system() to run command line >> program in python. but there will be a

automatically mapping builtins (WAS: itertools to iter transition)

2005-03-29 Thread Steven Bethard
Michael Spencer wrote: > While we're on the topic, what do you think of having unary, > non-summary builtins automatically map themselves when called with an > iterable that would otherwise be an illegal argument: > > e.g., > int(iterable) -> (int(i) for i in iterable) > ord(iterable) -> (ord(i) fo

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Peter Herndon
If you have three different implementations, and can read all three of them well enough to understand the code, use all three. If you are going to port software from one language to another, and want to reimplement it properly in your target language, you won't be porting word-for-word anyway. So

Re: Grouping code by indentation - feature or ******?

2005-03-29 Thread Diez B. Roggisch
> What I or you prefer carries very little weight. I know layout-things > stir up a lot of bad feeling, but I honostly think those people should > grow up. When I cooperate in a project, I adapt my style to the one > used in the project. I may use a tool to change between styles for > things I work

Re: How to execute a cmd line program without invoking console window?

2005-03-29 Thread rbt
Tian wrote: In Windows, I have been simply using os.system() to run command line program in python. but there will be a black console window. How can I run the program without invoking that window? i guess there are some function with which I can redirect the output? name your scripts with .pyw ext

Re: Python & LEGO Mindstorm control...

2005-03-29 Thread D H
Venkat B wrote: Hi all, I have a question re the use of Python to control a robot built with the LEGO Mindstorm system. This is to help my 11yr old with his increased interest in 'programming' and 'robotics'... If not feasible, he wants to use the graphical-tool that comes with it... Would you sugg

How to execute a cmd line program without invoking console window?

2005-03-29 Thread Tian
In Windows, I have been simply using os.system() to run command line program in python. but there will be a black console window. How can I run the program without invoking that window? i guess there are some function with which I can redirect the output? -- http://mail.python.org/mailman/listinf

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread John Machin
OPQ wrote: > (2)- in a dict mapping a key to a list of int, remove every entrie > where the list of int have of length < 2 > > > So far, my attempts are > for (2): > for k in hash.keys()[:]: # Note : Their may be a lot of keys here >if len(hash[k])<2: > del hash[k] > > > Here again, I th

Re: itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

2005-03-29 Thread George Sakkis
"Steven Bethard" <[EMAIL PROTECTED]> wrote: > > [snip] > > I guess the real questions are[1]: > * How much does iter feel like a type? > * How closely are the itertools functions associated with iter? > > STeVe > > [1] There's also the question of how much you believe in OO tenets like > "functions

Python & LEGO Mindstorm control...

2005-03-29 Thread Venkat B
Hi all, I have a question re the use of Python to control a robot built with the LEGO Mindstorm system. This is to help my 11yr old with his increased interest in 'programming' and 'robotics'... If not feasible, he wants to use the graphical-tool that comes with it... Would you suggest: 1. Using

Re: how do you use a closure in a class

2005-03-29 Thread Paul McGuire
Well, I'm not sure "closure" is the Pythonic way. But in Python, you can use functions to dynamically create other functions. Here's an example of this feature (although there are far simpler ways to do this), tallying vowels and consonants in an input string by calling a function looked up in a

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Ron_Adam
On Tue, 29 Mar 2005 14:58:45 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: >> >> Or something else depending on how many references you made to the >> value 8. > >Yes, this is true, assuming that he looks for keys with the value 8 in >locals(). It's not necessarily true if there's a way to ask py

Re: Need Help: Server to pass py objects

2005-03-29 Thread Ken Godee
>I have a legacy system with data stored in binary files on a remote >server. >I need to access and modify the content of those files from a webserver >running on a different host. (All Linux) > >I would like to install a server on the legacy host that would use my >python >code to translate bet

Re: problem with tkinter

2005-03-29 Thread Pierre Quentel
Instead of indexing self.lab by strings, you can index them by the attributes themselves : self.lab[self.i], and change line 23 into for var in (self.s, self,i) For your example, I wouldn't have used the "text" option in the definition of the labels, then "textvariable" in the callback meth

Re: pyopenGL: glutInit : TypeError: not a list

2005-03-29 Thread Rakesh
After some playing around, here is how my code looks like and it works: from OpenGL.GL import * from OpenGL.GLUT import * import sys def init(): glClearColor(0, 0, 0, 0) glMatrixMode(GL_PROJECTION) glLoadIdentity() glLightfv(GL_LIGHT0, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0]) glLightf

pyopenGL: glutInit : TypeError: not a list

2005-03-29 Thread Rakesh
Hi, I am starting to write this sample program in Python to use the GLUT library. <--> from OpenGL.GL import * from OpenGL.GLUT import * def init(): glClearColor(0, 0, 0, 0) glMatrixMode(GL_PROJECTION) glLoadIdentity() glLightfv(GL_LIGHT0, GL_AMBIENT, [0.0, 0.0, 0.0, 1.0]) g

Re: Need Help: Server to pass py objects

2005-03-29 Thread M.E.Farmer
Fred, Let me see if i understand, you want to 'serve' binary data as PYTHON OBJECTS to a REMOTE client. I am gonna show you how to fish ;) Search strategy: PYthon Remote Objects Python remote python objects I tried them and found plenty of information and code. hint: PYthon Remote Objects hth,

  1   2   3   >