Re: How does one write a function that increments a number?

2005-06-24 Thread [EMAIL PROTECTED]
Thank you all for your helpful replies. Regards, Vaibhav -- http://mail.python.org/mailman/listinfo/python-list

Re: How does one write a function that increments a number?

2005-06-24 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Apologies if this question seems stupid: How does one write a > function that increments a value in Python? When I tried, the variable > never changed. > The session went like this: > def incr(counter): > counter = int(counter) > counter += 1 > cou

Re: How does one write a function that increments a number?

2005-06-24 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 25/06/2005 01:41: > Wait... so this means it is impossible to write a function that > increments an integer without turning the integer into a list? > Well, one of these options will probably suit: >>> def increment_counter(data): ... data += 1 ...

Re: How does one write a function that increments a number?

2005-06-24 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: > Wait... so this means it is impossible to write a function that > increments an integer without turning the integer into a list? The short answer is no you can't, because integers are immutable (as well as floats and strings among others). The longer answer is you can

Re: How does one write a function that increments a number?

2005-06-24 Thread [EMAIL PROTECTED]
Wait... so this means it is impossible to write a function that increments an integer without turning the integer into a list? -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-24 Thread Steve
Hi, > I'm curious -- what is everyone's favorite trick from a non-python > language? And -- why isn't it in Python? One thing that I miss every once in a while is "pre-processing". I'm wondering if I'm the only one here, since nobody seems to have brought that up. For example, after testing is do

Re: How does one write a function that increments a number?

2005-06-24 Thread sun . aries
Hi, please refer to the sections about the augments passing in Python tutorial. Python’s pass-by-assignment scheme isn’t the same as C++’s reference parameters, but it turns out to be very similar to C’s arguments in practice:  Immutable arguments act like C's "by value" mode. Objects such a

Re: formatted xml output from ElementTree inconsistency

2005-06-24 Thread Patrick Maupin
Dennis Bieber wrote: > Off hand, I'd consider the non-binary nature to be because the > internet protocols are mostly designed for text, not binary. A document at http://www.w3.org/TR/REC-xml/ lists "the design goals for XML". One of the listed goals is "XML documents should be human-legible and

How does one write a function that increments a number?

2005-06-24 Thread [EMAIL PROTECTED]
Apologies if this question seems stupid: How does one write a function that increments a value in Python? When I tried, the variable never changed. The session went like this: >>> def incr(counter): counter = int(counter) counter += 1 >>> counter = 1 >>> incr(counter) >>> print c

Re: Tracing down segfault

2005-06-24 Thread Tim Peters
[Tony Meyer] > I have (unfortunately) a Python program that I can consistently (in a > reproducible way) segfault. However, I've got somewhat used to Python's > very nice habit of protecting me from segfaults and raising exceptions > instead, and am having trouble tracking down the problem. > > Th

Re: http POST only returning GET data

2005-06-24 Thread vm
Benji - that worked like a champ - my mistake. thanks Vinod -- http://mail.python.org/mailman/listinfo/python-list

Re: http POST only returning GET data

2005-06-24 Thread Benji York
vm wrote: > Hi, for some reason my POST is not working properly. Look at the URL again, you missed a character. You had: httpSess.request("POST","/",params,headers) It should be: httpSess.request("POST","/q",params,headers) -- Benji York -- http://mail.python.org/mailman/listinfo/python-lis

Tracing down segfault

2005-06-24 Thread Tony Meyer
I have (unfortunately) a Python program that I can consistently (in a reproducible way) segfault. However, I've got somewhat used to Python's very nice habit of protecting me from segfaults and raising exceptions instead, and am having trouble tracking down the problem. The problem that occurs lo

http POST only returning GET data

2005-06-24 Thread vm
Hi, for some reason my POST is not working properly. I am basically just trying to get a simple stock quote from yahoo by posting the ticker symbol (GE as an example) into finance.yahoo.com. However, when I POST, I do get a response back, but it is just the main page finance.yahoo.com and it does

Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

2005-06-24 Thread Grant Edwards
On 2005-06-25, Jp Calderone <[EMAIL PROTECTED]> wrote: >>[I've never figured out why one would do a shutdown RDWR rather >>than close the connection, but I haven't put a lot of thought >>into it.] > > shutdown actually tears down the TCP connection; close > releases the file descriptor. > > If the

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread Stephen Prinster
guy lateur wrote: > So, ideally, I'd like to program as much as possible in python (I'm > pretty new to that, too, btw), and only use VBA if needed - say, to > call python objects/methods (+ wxGUI, please). > If you are new to Python and want to use it with COM, definitely get yourself a copy of

Re: formatted xml output from ElementTree inconsistency

2005-06-24 Thread Steven Bethard
Matthew Thorley wrote: > from elementtree import ElementTree as et > > xmla = et.ElementTree('some_file.xml') > xmlb = et.Element('parent') > et.SubElement(xmlb, 'child1') > et.SubElement(xmlb, 'child2') > > root = et.Element('root') > root.append(xmla.getroot()) > root.append(xmlb) > > print et

Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

2005-06-24 Thread pwilkins
On Fri, 24 Jun 2005 21:42:48 -0400, Jp Calderone wrote: > shutdown actually tears down the TCP connection; close releases the file > descriptor. > > If there is only one file descriptor referring to the TCP connection, > these are more or less the same. If there is more than one file > descript

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread Chris Smith
> "guy" == guy lateur <[EMAIL PROTECTED]> writes: guy> Hi all, I am trying to write some code (macro's, if you like) guy> to glue together our Office applications (mainly Word, Excel guy> and Outlook). We have a lot of different projects going on guy> simultaneously. The idea i

Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

2005-06-24 Thread Jp Calderone
On Sat, 25 Jun 2005 01:36:56 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2005-06-25, Giovanni Tumiati <[EMAIL PROTECTED]> wrote: > >> (2)Does one have to do a socket.shutdown() before one does a >> socket.close?? > >No. > >[I've never figured out why one would do a shutdown RDWR >rather tha

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread Grant Edwards
On 2005-06-25, Jp Calderone <[EMAIL PROTECTED]> wrote: > The argument to listen() is only a _hint_ to the TCP/IP stack. > Linux, at least, will not create a buffer large enough for > only a single connection. You can test this easily: create a > socket, bind it to an address, call listen(1) on it

Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

2005-06-24 Thread Grant Edwards
On 2005-06-25, Giovanni Tumiati <[EMAIL PROTECTED]> wrote: > However some of my questions still remain from earlier post: > (1) What is the difference between > - setdefaulttimeout(timeout) That sets the timeout for any sockets created in the future. > - settimeout(value) That sets the timeo

Re: a dictionary from a list

2005-06-24 Thread Peter Hansen
Dave Cook wrote: > On 2005-06-24, infidel <[EMAIL PROTECTED]> wrote: > > >>dict((x, None) for x in alist) > > Whoa, I thought dictionary comprehensions were still planned feature. I > guess I gotta start paying closer attention. Added in Python 2.4, it's actually a generator expression as the

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread Jp Calderone
On Fri, 24 Jun 2005 21:21:34 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote: >ncf wrote: >> Heh, like I said. I was not at all sure. :P >> >> Nevertheless, could this be the problem? =\ > >You *may* correct, mainly because the OP's code doesn't appear to spawn >off new threads to handle the client c

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread Grant Edwards
On 2005-06-25, Peter Hansen <[EMAIL PROTECTED]> wrote: > You *may* correct, mainly because the OP's code doesn't appear > to spawn off new threads to handle the client connections, > which means he can handle only one connection at a time. > Specifically, while he is talking to one client he is no

Re: Newbie question: SOLVED (how to keep a socket listening), but still some questions

2005-06-24 Thread Peter Hansen
Giovanni Tumiati wrote: > However some of my questions still remain from earlier post: > (1) What is the difference between / how should they be used? > - setdefaulttimeout(timeout) > - settimeout(value) I think it's basically as you surmised. Calling socket.setdefaulttimeout() (where "socket"

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread Peter Hansen
ncf wrote: > Heh, like I said. I was not at all sure. :P > > Nevertheless, could this be the problem? =\ You *may* correct, mainly because the OP's code doesn't appear to spawn off new threads to handle the client connections, which means he can handle only one connection at a time. Specifical

Re: a dictionary from a list

2005-06-24 Thread Dave Cook
On 2005-06-24, infidel <[EMAIL PROTECTED]> wrote: > dict((x, None) for x in alist) Whoa, I thought dictionary comprehensions were still planned feature. I guess I gotta start paying closer attention. Dave Cook -- http://mail.python.org/mailman/listinfo/python-list

RE: Newbie question: SOLVED (how to keep a socket listening), but still some questions

2005-06-24 Thread Giovanni Tumiati
To all those that replied - thank you. I solved the problem I posted earlier. I'm embarrassed to admit that it was caused by the following: ... while 1: ## wait for a connection try: #...waiting for connection (client, address)=sa.accept() except sa.timeout: <--there is no such e

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread ncf
Heh, like I said. I was not at all sure. :P Nevertheless, could this be the problem? =\ -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-24 Thread John Machin
James Stroud wrote: > On Friday 24 June 2005 05:58 am, Steven D'Aprano wrote: > >>with colour do begin >>red := 0; blue := 255; green := 0; >>end; >> >>instead of: >> >>colour.red := 0; colour.blue := 255; colour.green := 0; >> >>Okay, so maybe it is more of a feature than a trick, but I miss it a

Re: a dictionary from a list

2005-06-24 Thread George Sakkis
"Rocco Moretti" wrote: > Are you sure you need a dictionary? You may want to look at the Set > module instead, if the values aren't important. Set is the name of the type in the module sets, introduced in 2.3. Since 2.4 you can use the builtin set type. Here's the import snippet that works for 2.

windows service problem

2005-06-24 Thread Austin
class HelloService(win32serviceutil.ServiceFramework): _svc_name_ = "HelloService" _svc_display_name_ = "Hello Service" def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) self.c

Re: a dictionary from a list

2005-06-24 Thread Rocco Moretti
David Bear wrote: > I know there must be a better way to phrase this so google understands, but > I don't know how.. So I'll ask people. > > Assume I have a list object called 'alist'. > > Is there an easy way to create a dictionary object with the members of > 'alist' being the keys in the dicti

Re: Favorite non-python language trick?

2005-06-24 Thread James Stroud
On Friday 24 June 2005 05:58 am, Steven D'Aprano wrote: > with colour do begin > red := 0; blue := 255; green := 0; > end; > > instead of: > > colour.red := 0; colour.blue := 255; colour.green := 0; > > Okay, so maybe it is more of a feature than a trick, but I miss it and it > would be nice to hav

Re: Favorite non-python language trick?

2005-06-24 Thread johng2001
John Machin wrote: > James wrote: > > Interesting thread ... > > > > 1.) Language support for ranges as in Ada/Pascal/Ruby > > 1..10 rather than range(1, 10) > > Did you mean 1..9 or 1...10 or both or neither? You are right. There is a difference. 1..10 == range(1, 10 + 1) > Can this construct be

Re: a dictionary from a list

2005-06-24 Thread Leif K-Brooks
David Bear wrote: > Is there an easy way to create a dictionary object with the members of > 'alist' being the keys in the dictionary, and the value of the keys set to > null? adict = dict.fromkeys(alist) -- http://mail.python.org/mailman/listinfo/python-list

Re: a dictionary from a list

2005-06-24 Thread infidel
dict((x, None) for x in alist) -- http://mail.python.org/mailman/listinfo/python-list

Re: a dictionary from a list

2005-06-24 Thread Benji York
David Bear wrote: > Assume I have a list object called 'alist'. > > Is there an easy way to create a dictionary object with the members of > 'alist' being the keys in the dictionary, and the value of the keys set to > null? You mean None, right? :) >>> a_list = [1, 2, 3, 'a', 'b', 'c'] >>> di

Re: Favorite non-python language trick?

2005-06-24 Thread Steve Horsley
Neat. Thank Goodness for syntax-colouring editors! Steve -- http://mail.python.org/mailman/listinfo/python-list

a dictionary from a list

2005-06-24 Thread David Bear
I know there must be a better way to phrase this so google understands, but I don't know how.. So I'll ask people. Assume I have a list object called 'alist'. Is there an easy way to create a dictionary object with the members of 'alist' being the keys in the dictionary, and the value of the keys

Re: howto load and unload a module

2005-06-24 Thread Guy Robinson
> BTW, question for the OP: what on earth is the use-case for this? Bulk > checking of scripts written by students? > > Cheers, > John I've embedded python in an application which has a .NET API. So users can write scripts in python that access the .NET API. Because of the way the API works r

Handling more zodb databases with zeo

2005-06-24 Thread Almad
Hello, sorry for bothering with same question again. However, month ago, I have tried to handle more zodb databases with zeo as described here: http://mail.python.org/pipermail/python-list/2005-May/279915.html Since then, I don't have had a time to play with it and now I tried again. However, ev

Re: Favorite non-python language trick?

2005-06-24 Thread John Machin
James wrote: > Interesting thread ... > > 1.) Language support for ranges as in Ada/Pascal/Ruby > 1..10 rather than range(1, 10) Did you mean 1..9 or 1...10 or both or neither? Can this construct be used like this: (i+1)..n ? If not, what would you use? What is the frequency of range literals i

Re: Favorite non-python language trick?

2005-06-24 Thread Ron Adam
George Sakkis wrote: > "Joseph Garvin" wrote: > > >>I'm curious -- what is everyone's favorite trick from a non-python >>language? And -- why isn't it in Python? > > > Although it's an optimization rather than language trick, I like the > inline functions/methods in C++. There has been a thread

Re: Favorite non-python language trick?

2005-06-24 Thread James
Interesting thread ... 1.) Language support for ranges as in Ada/Pascal/Ruby 1..10 rather than range(1, 10) 2.) Contracts 3.) With -- http://mail.python.org/mailman/listinfo/python-list

Re: Running Python interpreter in Emacs

2005-06-24 Thread Philippe C. Martin
I do not think there is any need to tell emacs where Python is; besides having python.exe in your Windows $PATH. Regards, Philippe Rex Eastbourne wrote: > I have the following in my .emacs: > > (add-to-list 'load-path "C:\Program Files\Python24") > > Is that enough? I didn't see anything s

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread guy lateur
> You want to use --- Python ??? So far I haven't been informed of any serious arguments as to why I wouldn't. > How, pray tell, do you add up (VBA+VBA+VBA+VBA+VBA) and have it come out > equaling Python? My total was this: 57*python + wxPython. > Do you think that might please a few of us

ANN: Python Computer Graphics Kit v2.0.0alpha4

2005-06-24 Thread Matthias Baas
The fourth alpha release of version 2 of the Python Computer Graphics Kit is available at http://cgkit.sourceforge.net What is it? --- The Python Computer Graphics Kit is a generic 3D package written in C++ and Python that can be used for a variety of domains such as scientific visualiza

Re: Favorite non-python language trick?

2005-06-24 Thread D H
Terry Reedy wrote: > "Tom Anderson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >>sometimes in python. No, it's not really possible in a typeless language, >>and yes, there are implementations based on decorators, but frankly, >>they're awful. > > > Python has strongly ty

Re: formatted xml output from ElementTree inconsistency

2005-06-24 Thread Patrick Maupin
Jarek Zgoda wrote: > Why want you to read an XML document "by hand"? It's a "machine related" > data chunk. > I see this attitude all the time, and frankly I don't understand it. Please explain why XML is in ASCII/unicode instead of binary. Is it because it is easier for a machine to parse? No,

Re: Favorite non-python language trick?

2005-06-24 Thread D H
Terry Reedy wrote: > "D H" <[EMAIL PROTECTED]> wrote in message > > >>Roy Smith wrote: > > >>>Tom Anderson <[EMAIL PROTECTED]> wrote: >>> The one thing i really do miss is method overloading by parameter type. I used this all the time in java > > >>>You do things like that in type-b

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread Thomas Bartkus
"guy lateur" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > I am trying to write some code (macro's, if you like) to glue together > our Office applications (mainly Word, Excel and Outlook). We have a lot > of different projects going on simultaneously. The idea is to dev

Re: trouble with win32serviceutil

2005-06-24 Thread Erik Myllymaki
Erik Myllymaki wrote: > I am trying to start and stop a service with python. This used to work > on an NT box but not on this 2003 server machine. (note- using "net stop > myService" and net start myService" from the command line works just > fine). The event viewer does tell me that a "Start co

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread erinhouston
Can you make python into a com object? I think you can I just don't rember. If so you want to find a page about com add-ins for office. This is a com object that you can teach office to look for when It is started. I wrote one in vb years ago and havn't looked back. But I think that would be the

Re: Running Python interpreter in Emacs

2005-06-24 Thread Rex Eastbourne
I have the following in my .emacs: (add-to-list 'load-path "C:\Program Files\Python24") Is that enough? I didn't see anything similar to that in your .emacs file, so I'm wondering if I'm supposed to add the path to my PATH elsewhere. Thanks, Rex -- http://mail.python.org/mailman/listinfo/pyth

Re: Office COM automatisation - calling python from VBA

2005-06-24 Thread Do Re Mi chel La Si Do
Hi ! Perso, j'utilise ça (VBA) : Sub TestPonx() Dim oa As Object Set oa = CreateObject("Ponx.Mci") Cells(2, 4) = oa.PRet("123+45+6") Set oa = Nothing End Sub "Ponx.Mci" est le nom du serveur COM Python PRet() est équ

ANN: Python Mock 0.1.0 released

2005-06-24 Thread [EMAIL PROTECTED]
I am pleased to announce the first release of Python Mock (version 0.1.0) on SourceForge: http://sourceforge.net/projects/python-mock/ About Python Mock - The Python Mock library enables the easy creation and use of Mock objects for Python unit testing, inspired by the various Jav

Re: Two questions on lambda:

2005-06-24 Thread Terry Reedy
"Xavier Décoret" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I cannot find the way to do generic lambda functions using the lambda > syntax in python. I am probably missing a point. Thinking of lambda args: expression as more or less abbreviati

Re: trouble subclassing str

2005-06-24 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Paul McGuire" <[EMAIL PROTECTED]> wrote: ... > This reminds me of some maddening O-O discussions I used to > have at a former place of employment, in which one developer cited > similar behavior for not having Square inherit from Rectangle - calling > Square.setWid

Re: Favorite non-python language trick?

2005-06-24 Thread Terry Reedy
"Tom Anderson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > sometimes in python. No, it's not really possible in a typeless language, > and yes, there are implementations based on decorators, but frankly, > they're awful. Python has strongly typed objects. Only names are typel

Re: help!

2005-06-24 Thread Renato Ramonda
Johannes Findeisen ha scritto: > some filesystems do support that. From the ext2 specification > ( http://e2fsprogs.sourceforge.net/ext2intro.html ): > > "As a response to these problems, two new filesytems were released in > Alpha version in January 1993: the Xia filesystem and the Second > Exten

Re: Favorite non-python language trick?

2005-06-24 Thread Torsten Bronger
Hallöchen! Jeffrey Maitland <[EMAIL PROTECTED]> writes: > [...] > > { > for(int i = 0; i < 100; i++){ > //do stuff > } > } > > wrapping the for loop in { } makes the i a local variable It's local anyway. > and then you can use it again in the code if not you will get a > variable already defi

Re: Favorite non-python language trick?

2005-06-24 Thread Terry Reedy
"D H" <[EMAIL PROTECTED]> wrote in message > Roy Smith wrote: >> Tom Anderson <[EMAIL PROTECTED]> wrote: >>>The one thing i really do miss is method overloading by parameter >>>type. I used this all the time in java >> You do things like that in type-bondage languages like Java and C++ >> bec

Office COM automatisation - calling python from VBA

2005-06-24 Thread guy lateur
Hi all, I am trying to write some code (macro's, if you like) to glue together our Office applications (mainly Word, Excel and Outlook). We have a lot of different projects going on simultaneously. The idea is to develop a centralized framework (starting point, common interface) for my users to vi

Re: Frame widget (title and geometry)

2005-06-24 Thread Jeff Epler
Tkinter.Frame instances are not created with "geometry" or "title" attributes. Whatever 'classtitle' and 'classtitle2' are, they are not written to work with Tkinter.Frame instances. Jeff pgppDkXNnBRVL.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: autoconfigure vss python question

2005-06-24 Thread John Machin
lode leroy wrote: > Hi folks, > > I'm trying to build a python module using MINGW on MSYS > the "configure" script is determining where python is installed as follows: > > python.exe -c 'import sys; print sys.prefix' > c:\Python24 > > which is good on native windows (i.e. when invoked from CMD.E

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread pwilkins
On Fri, 24 Jun 2005 11:21:28 -0700, ncf wrote: > I think your problem /may/ be in the following line of code: > sa.listen(1) > > I believe what's happening is that the listen() creates a decremental > counter of the number of connections to accept. Once it decrements to > 0, it won't accept any m

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread pwilkins
On Fri, 24 Jun 2005 13:59:19 -0400, pwilkins wrote: > if data == 'q': >##disconnect client but keep waiting for connections > ... > client.close() Sorry - made a mistake in my posting... the

OT: Boston-Area QA/Python Job

2005-06-24 Thread Jesse Noller
Sorry for the off-topic post everyone. The company I work for has a job opening for a Senior QA/Automation person, and they are looking for someone strong in Python to help develop tests/testing frameworks/etc. The complete job description follows - you can feel free to email resumes and questions

Re: what list comprehension can't

2005-06-24 Thread [EMAIL PROTECTED]
Thank you pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: key - key pairs

2005-06-24 Thread Paul McGuire
Man, this is not my week! Another bug in my posted code! The posted version of SymmetricDict fails when adding an entry in which the key equals the value. First bug is in __setitem__ in which the insertion is done twice, which is wasteful but benign. The second bug is in __delitem__, which thro

Re: what list comprehension can't

2005-06-24 Thread Christophe Delord
Hello, On 24 Jun 2005 11:45:14 -0700, [EMAIL PROTECTED] wrote: > Hello, > > Can we impose if then else into list comprehension ? > Like we do in lambda-map form: > > This code change None into 0 > L = [None, 12] > R = map(lambda x: (x==None and [0] or x)[0], L) # [0,12] > Do you mean: [(x=

Re: what list comprehension can't

2005-06-24 Thread Devan L
I wasn't aware that python supported "if then else". -- http://mail.python.org/mailman/listinfo/python-list

what list comprehension can't

2005-06-24 Thread [EMAIL PROTECTED]
Hello, Can we impose if then else into list comprehension ? Like we do in lambda-map form: This code change None into 0 L = [None, 12] R = map(lambda x: (x==None and [0] or x)[0], L) # [0,12] pujo -- http://mail.python.org/mailman/listinfo/python-list

Re: Frame widget (title and geometry)

2005-06-24 Thread Shankar Iyer ([EMAIL PROTECTED])
Here is an example of what I tried to do: from Tkinter import * import classtitle import classtitle2 BLUE1 = '#7080B0' RED1 = '#B08080' class Master(Frame): def createWidgets(self): self.FrameOne = Frame(self) self.FrameOne.grid(sticky = NW) self.FrameOne["backgroun

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Steven D'Aprano wrote: > On Fri, 24 Jun 2005 12:54:34 -0500, D H wrote: > > >>Riccardo Galli wrote: >> >>>On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: >>> >>> >>> >Bo Peng wrote: > > > >>I need to pass a bunch of parameters conditionally. In C/C++, I can >>do func(cond1?

Re: trouble subclassing str

2005-06-24 Thread Paul McGuire
Look at the related post, on keeping key-key pairs in a dictionary. Based on our discussion in this thread, I created a subclass of dict called SymmetricDict, that, when storing symDict["A"] = 1, implicitly saves the backward looking symDict[1] = "A". I chose to inherit from dict, in part just to

Re: Getting binary data out of a postgre database

2005-06-24 Thread Diez B. Roggisch
> So, rec[0] is an instance, but an instance of what? Since I needed to > use the PgSQL.PgBytea method on the image before inserting it into the > database, do I need to use a similar method to undo what PgBytea did to > it, or am I incorrectly writing this binary data? I tried > PgSQL.PgUnQuoteByt

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread Grant Edwards
On 2005-06-24, ncf <[EMAIL PROTECTED]> wrote: > I think your problem /may/ be in the following line of code: > sa.listen(1) > > I believe what's happening is that the listen() creates a decremental > counter of the number of connections to accept. Once it decrements to > 0, it won't accept any mor

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Steven D'Aprano
On Fri, 24 Jun 2005 12:54:34 -0500, D H wrote: > Riccardo Galli wrote: >> On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: >> >> Bo Peng wrote: >I need to pass a bunch of parameters conditionally. In C/C++, I can >do func(cond1?a:b,cond2?c:d,.) > >Is there an easi

Re: Newbie question: how to keep a socket listening?

2005-06-24 Thread ncf
I think your problem /may/ be in the following line of code: sa.listen(1) I believe what's happening is that the listen() creates a decremental counter of the number of connections to accept. Once it decrements to 0, it won't accept any more connections. (I'm not at all sure, but that sounds like

Getting binary data out of a postgre database

2005-06-24 Thread projecktzero
Well, I've managed to get an image into a postgre database, but now I'm having trouble getting it out. #! /usr/bin/env python from pyPgSQL import PgSQL def main(): connectdb = PgSQL.connect('server:port:database:username:password') cur = connectdb.cursor() sqlStatement = """SELECT im

Newbie question: how to keep a socket listening?

2005-06-24 Thread pwilkins
First off I'm want to learn socket/network programming with python so a lot of what I ask is newbie related. I have written a test socket server that runs as a daemon. It listens on two sockets (say at ports 8000 and 9000) so that I can telnet over from another machine and get process info (ps ty

Looking for Python Finite State Machine Implementations

2005-06-24 Thread Leonard J. Reder
Hello, Although posted this a few weeks ago I still have gotten much feedback so I want to put this out again and see if the response gets a bit more interesting. I have been searching on the web for a while now for a specific Python implementation of an FSM. More specifically what I am looki

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Riccardo Galli wrote: > On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: > > >>>Bo Peng wrote: >>> >>> I need to pass a bunch of parameters conditionally. In C/C++, I can do func(cond1?a:b,cond2?c:d,.) Is there an easier way to do this in Python? >>> >>> >>The answer is simply

Re: Favorite non-python language trick?

2005-06-24 Thread Jeffrey Maitland
1 trick I liked in C++ was for For loops. { for(int i = 0; i < 100; i++){ //do stuff } } wrapping the for loop in { } makes the i a local variable and then you can use it again in the code if not you will get a variable already defined error. As a side note python already keeps it a local var

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread Riccardo Galli
On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote: >> Bo Peng wrote: >> >>> I need to pass a bunch of parameters conditionally. In C/C++, I can >>> do func(cond1?a:b,cond2?c:d,.) >>> >>> Is there an easier way to do this in Python? >> >> > The answer is simply no, just use an if statement instead.

Re: trouble subclassing str

2005-06-24 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Paul McGuire" <[EMAIL PROTECTED]> wrote: [ ... lots of interesting discussion removed ... ] > Most often, I see "is-a" confused with "is-implemented-using-a". A > developer decides that there is some benefit (reduced storage, perhaps) > of modeling a zip code usi

Re: Favorite non-python language trick?

2005-06-24 Thread George Sakkis
"Joseph Garvin" wrote: > I'm curious -- what is everyone's favorite trick from a non-python > language? And -- why isn't it in Python? Although it's an optimization rather than language trick, I like the inline functions/methods in C++. There has been a thread on that in the past (http://tinyurl.

Parallel execution (CGI)

2005-06-24 Thread mmf
Hi! I am using Python for CGI scripting. I had the following script: #!/usr/bin/python import sys print 'Content-type: text/html\r\n\r\n' print 'starting...' sys.stdout.flush() x = 99 y = 5478 counter = 0 while counter < 1000: z = x^y counter += 1 print 'finished!' sys.std

Re: Two questions on lambda:

2005-06-24 Thread Sean McIlroy
def PRINT(x): print x f = lambda: PRINT("hello") ### def let(x,y): globals()[x] = y return True f = lambda x: let('y',x*x) and y+y -- http://mail.python.org/mailman/listinfo/python-list

Re: Running Python interpreter in Emacs

2005-06-24 Thread Philippe C. Martin
Hi, Since I'm a Linux user, I went through the following procedure: I installed emacs 20.7.1 and Python 2.4 I installed python-mode 1.0A into site-lisp I added c:\python24 to my path I put this .emacs on c:\ (see further down - I'm sure you don't need half of it) And everyhing is working fine:

Re: Two questions on lambda:

2005-06-24 Thread Christophe Delord
hello, On Fri, 24 Jun 2005 14:48:16 +0200, Xavier Décoret wrote: > Hi, > > In the same spirit, how can I do to compute intermediary values in the > > body of a lambda function. Let's say (dummy example): > > f = lambda x : y=x*x,y+y > > > In languages like Caml, you can do: > > let f = func

Re: Favorite non-python language trick?

2005-06-24 Thread D H
Roy Smith wrote: > Tom Anderson <[EMAIL PROTECTED]> wrote: > >>The one thing i really do miss is method overloading by parameter >>type. I used this all the time in java > > > You do things like that in type-bondage languages like Java and C++ > because you have to. Can you give an example of

Re: help!

2005-06-24 Thread Johannes Findeisen
On Fri, 2005-06-24 at 14:14 +0200, Andreas Kostyrka wrote: > On Fri, Jun 24, 2005 at 02:49:01PM +0300, Eser Çetinkaya wrote: > > > > > > In your documentation, it is written : > > " > > os.path.getatime(path) > > Return the time of last access of path. The return value is a number

Running Python scripts under W2K with I/O redirection

2005-06-24 Thread sub1ime_uk
I apologise if this is a well known problem. I've searched and can't find a clear description or fix. Hope someone can help. I am running my Python scripts under Windows 2000 using Python 2.4 Build 243 from Activestate. If I want to specify a file as standard input to my script I can just enter a

Re: Python as client-side browser script language

2005-06-24 Thread jeoffwilks
Sorry to resurrect a slightly older topic, but I want to clarify some points about how the browser DOM and the script language interact. Paul Rubin wrote: > Huh? The language itself has to provide the sandbox. > Remember that scripts have to be able to see > certain DOM elements but not others, a

Re: Favorite non-python language trick?

2005-06-24 Thread Roy Smith
Tom Anderson <[EMAIL PROTECTED]> wrote: > The one thing i really do miss is method overloading by parameter > type. I used this all the time in java You do things like that in type-bondage languages like Java and C++ because you have to. Can you give an example of where you miss it in Python?

Re: Frame widget (title and geometry)

2005-06-24 Thread Eric Brunel
On Fri, 24 Jun 2005 10:21:01 -0400, Shankar Iyer ([EMAIL PROTECTED]) <[EMAIL PROTECTED]> wrote: > Hi, > > I am still new to Python and Tkinter, so I apologize in advance if I do not > word my question optimally. I am trying to use a frame widget as the parent > for other widgets. There is a cla

  1   2   >