Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Stephen Hansen
On Mon, Oct 12, 2009 at 4:15 PM, Stef Mientki wrote: > Hierarchical choices are done on todays knowledge, tomorrow we might have > different views and want/need to arrange things in another way. > An otter may become a reptile ;-) > So from the human viewpoint the following should be possible (and

Re: The rap against "while True:" loops

2009-10-12 Thread Steven D'Aprano
On Mon, 12 Oct 2009 11:32:27 -0700, Mensanator wrote: >> Nothing wrong with a having a break IMHO. > > My opinion is that there is everything wrong with having a break. I > don't think I have ever used one, I write code that doesn't depend on > that crutch. Using break can avoid a lot of compli

Re: deepcopy of class inherited from Thread

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 14:52:42 -0300, VYAS ASHISH M-NTB837 escribió: The function that I want to run is part of a class, not a standalone function. There are several class member variables also. What about modifying the run() method so it runs more than once? Perhaps using a Queue object to

Re: What is the correct way to define __hash__?

2009-10-12 Thread Chris Rebert
On Mon, Oct 12, 2009 at 7:04 PM, Steven D'Aprano wrote: > On Mon, 12 Oct 2009 15:45:30 -0500, Peng Yu wrote: > >>   def __cmp__(self, other): >>     if self._a < other._a: >>       return -1 >>     elif self._a > other._a: >>       return 1 >>     elif self._b < other._b: >>       return -1 >>    

Re: What is the correct way to define __hash__?

2009-10-12 Thread Steven D'Aprano
On Mon, 12 Oct 2009 15:45:30 -0500, Peng Yu wrote: > def __cmp__(self, other): > if self._a < other._a: > return -1 > elif self._a > other._a: > return 1 > elif self._b < other._b: > return -1 > elif self._b > other._b: > return 1 > else: > retur

Profiling python on OSX?

2009-10-12 Thread nitroamos
Hello -- I'm a python noob, so I'm trying to figure out how to get access to the same data I'm used to from gprof, if possible. I was able to get cPython/Stats to work just fine... but I'm disappointed with the lack of detail in the output... Is there a better way? For example, OSX has the nice S

Re: The rap against "while True:" loops

2009-10-12 Thread Paul Rubin
kj writes: > I use "while True"-loops often, and intend to continue doing this > "while True", but I'm curious to know: how widespread is the > injunction against such loops? Has it reached the status of "best > practice"? E. W. Dijkstra used to advocate that every loop have exactly one entry po

Re: Documentation of 2.x indicating what will be gone in 3.x?

2009-10-12 Thread Matt Bowcock
On Oct 12, 8:21 pm, Peng Yu wrote: > Hi, > > I'm wondering if there is a document for 2.x indicating what will be > gone in 3.x. For example, I heard that __cmp__ be not available in > Python 3. But I don't see it > inhttp://docs.python.org/reference/datamodel.html. > > Regards, > Peng 'Dive int

Re: Script to complete web form fields

2009-10-12 Thread Rene Katkowski
On Oct 11, 9:07 am, "Diez B. Roggisch" wrote: > Feyo schrieb: > > > How can I use Python to complete web form fields automatically? My > > work web-based email time-out is like 15 seconds. Every time I need to > > access my calendar, address book, or email, I have to type in my > > username and pa

Re: Script to complete web form fields

2009-10-12 Thread Rene Katkowski
On Oct 11, 5:11 am, ryles wrote: > On Oct 10, 9:39 pm, Feyo wrote: > > > How can I use Python to complete web form fields automatically? My > > work web-based email time-out is like 15 seconds. Every time I need to > > access my calendar, address book, or email, I have to type in my > > username

Re: The rap against "while True:" loops

2009-10-12 Thread Raymond Hettinger
[kj] > I use "while True"-loops often, and intend to continue doing this > "while True", but I'm curious to know: how widespread is the > injunction against such loops?  Has it reached the status of "best > practice"? This is the first I've ever heard of such an quasi-injunction. Like you, I use "

Re: Documentation of 2.x indicating what will be gone in 3.x?

2009-10-12 Thread Rhodri James
On Tue, 13 Oct 2009 01:21:17 +0100, Peng Yu wrote: Hi, I'm wondering if there is a document for 2.x indicating what will be gone in 3.x. For example, I heard that __cmp__ be not available in Python 3. But I don't see it in http://docs.python.org/reference/datamodel.html. Look in the "What's

Documentation of 2.x indicating what will be gone in 3.x?

2009-10-12 Thread Peng Yu
Hi, I'm wondering if there is a document for 2.x indicating what will be gone in 3.x. For example, I heard that __cmp__ be not available in Python 3. But I don't see it in http://docs.python.org/reference/datamodel.html. Regards, Peng -- http://mail.python.org/mailman/listinfo/python-list

POST value related question

2009-10-12 Thread ken
hello i have some problem to send POST value by use mechanize. i can't write my article to my blog site. here is full source. and what i want to do is, im posting my article to my blog site. thanks in advance. # -*- coding: cp949 -*- import mechanize import cookielib # Browser

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread greg
Stef Mientki wrote: - I can move the complete project anywhere I like and it should still work without any modifications (when I move my desk I can still do my work) Gabriel's organisation satisfies that. - I can move any file in he project to any other place in the project and again everyth

Re: pickle's backward compatibility

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 12:17:52 -0300, Peng Yu escribió: If I define my own class and use pickle to serialize the objects in this class, will the serialized object be successfully read in later version of python. From : "The pickle serialization form

Re: pickle's backward compatibility

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 12:17:52 -0300, Peng Yu escribió: If I define my own class and use pickle to serialize the objects in this class, will the serialized object be successfully read in later version of python. From : "The pickle serialization form

Re: "Error en el bus" from python

2009-10-12 Thread greg
Jorgen Grahn wrote: "Bus Error" is an old BSD-ism which I guess you don't see much in Linux or Solaris these days (or maybe I never run buggy code ;-). It translates roughly to "segmentation fault", but IIRC it is more about accessing memory words on nonaligned adresses than about accessing add

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Ethan Furman
Stef Mientki wrote: Gabriel Genellina wrote: [snip] That's what I meant to say. It IS a zero-installation schema, and it also works if you properly install the package. Quoting Steven D'Aprano (changing names slightly): """You would benefit greatly from separating the interface from the

In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

2009-10-12 Thread zxo102
Hi everyone, How can I pass a string generated from python cgi at server side to a javascript function as an argument at client side? Here is my case: 1. client side: "load" is a javascript function in a html page. It starts the python CGI "test.py" via Apache: ... load("test.py" )

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Carl Banks
On Oct 12, 11:24 am, Buck wrote: > On Oct 10, 9:44 am, "Gabriel Genellina" > wrote: > > > The good thing is that, if the backend package is properly installed   > > somewhere in the Python path ... it still works with no modifications. > > I'd like to get to zero-installation if possible. It's ea

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 19:07:38 -0300, Buck escribió: On Oct 10, 1:57 am, Steven D'Aprano wrote: #!/usr/bin/python import os, sys if __name__ == '__main__':     # find out where we are, and add it to the path     [...] That's not a lot of boilerplate for a script. My issues with boilerplate a

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Stef Mientki
Gabriel Genellina wrote: En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" wrote: The good thing is that, if the backend package is properly installed somewhere in the Python path ... it still works with no modifications. I'd like to get to zero-i

Re: getting equal behavior for scripts and modules ?

2009-10-12 Thread Gabriel Genellina
En Sun, 11 Oct 2009 18:07:30 -0300, Stef Mientki escribió: Gabriel Genellina wrote: En Sun, 11 Oct 2009 14:50:31 -0300, Stef Mientki escribió: Now I finally (after 2 years) knowing there's a difference between modules and scripts, I want to guarantee that I always get the same functiona

Re: getting equal behavior for scripts and modules ?

2009-10-12 Thread Gabriel Genellina
En Sun, 11 Oct 2009 18:07:30 -0300, Stef Mientki escribió: Gabriel Genellina wrote: En Sun, 11 Oct 2009 14:50:31 -0300, Stef Mientki escribió: Now I finally (after 2 years) knowing there's a difference between modules and scripts, I want to guarantee that I always get the same functiona

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" wrote: The good thing is that, if the backend package is properly installed   somewhere in the Python path ... it still works with no modifications. I'd like to get to zero-installation if possible. I

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" wrote: The good thing is that, if the backend package is properly installed   somewhere in the Python path ... it still works with no modifications. I'd like to get to zero-installation if possible. I

Re: What is the correct way to define __hash__?

2009-10-12 Thread Robert Kern
On 2009-10-12 17:12 PM, Peng Yu wrote: On Mon, Oct 12, 2009 at 4:03 PM, Robert Kern wrote: On 2009-10-12 15:45 PM, Peng Yu wrote: Hi, I'm wondering what is the general way to define __hash__. I could add up all the members. But I am wondering if this would cause a performance issue for certa

Re: What is the correct way to define __hash__?

2009-10-12 Thread Chris Rebert
On Mon, Oct 12, 2009 at 3:12 PM, Peng Yu wrote: > On Mon, Oct 12, 2009 at 4:03 PM, Robert Kern wrote: >> On 2009-10-12 15:45 PM, Peng Yu wrote: >>> >>> Hi, >>> >>> I'm wondering what is the general way to define __hash__. I could add >>> up all the members. But I am wondering if this would cause

Re: What is the correct way to define __hash__?

2009-10-12 Thread Peng Yu
On Mon, Oct 12, 2009 at 4:03 PM, Robert Kern wrote: > On 2009-10-12 15:45 PM, Peng Yu wrote: >> >> Hi, >> >> I'm wondering what is the general way to define __hash__. I could add >> up all the members. But I am wondering if this would cause a >> performance issue for certain classes. > > Unless if

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Buck
On Oct 10, 1:57 am, Steven D'Aprano wrote: > #!/usr/bin/python > import os, sys > > if __name__ == '__main__': >     # find out where we are, and add it to the path >     location = __import__('__main__').__file__ >     location = os.path.dirname(location) >     if location not in sys.path: >    

Re: The rap against "while True:" loops

2009-10-12 Thread Brian Blais
On Oct 12, 2009, at 15:18 , Falcolas wrote: Glad to hear, by the way, that you don't use gotos in Python. =D actually, it is there. http://entrian.com/goto/ I particularly like the comefrom construct! bb -- Brian Blais bbl...@bryant.edu http://web.bryant.edu/~bblais --

Re: The rap against "while True:" loops

2009-10-12 Thread David C Ullrich
kj wrote: I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with "while True". Of course, that's one way to start an infinite loop, Heh-heh: When I read this it occurred to me that another

XML-RPC(using SimpleXMLRPCServer) slow on the first call

2009-10-12 Thread Mahi Haile
Hello all,I have an xml-rpc server running on a machine in the same LAN as the client. Both the server and the client are in Python. When I have a series of xmlrepc calls from the client to the server, the first call usually takes much longer than it should - orders of magnitude. The latency is us

Re: which "dictionary with attribute-style access"?

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 16:58:35 -0300, Andreas Balogh escribió: googling I found several ways of implementing a "dictionary with attribute-style access". 1. ActiveState cookbook: http://code.activestate.com/recipes/473786/ 2. ActiveState cookbook: http://aspn.activestate.com/ASPN/Cookbook

Re: windows side-by-side configuration woes on windows HPC

2009-10-12 Thread M.-A. Lemburg
Nick Touran wrote: > It is indeed a pain. I would really like a work-around. Matplotlib is > supposed to be immune to this nowadays but it's not. Nor are some other > third-party modules. Did they break with the new release? (2.6.3?) The main problem appears to be that the the MS VC9 compiler defa

Re: which "dictionary with attribute-style access"?

2009-10-12 Thread Rhodri James
On Mon, 12 Oct 2009 20:58:35 +0100, Andreas Balogh wrote: Hello, googling I found several ways of implementing a "dictionary with attribute-style access". 1. ActiveState cookbook: http://code.activestate.com/recipes/473786/ 2. ActiveState cookbook: http://aspn.activestate.com/ASPN/Coo

Re: windows side-by-side configuration woes on windows HPC

2009-10-12 Thread Nick Touran
It is indeed a pain. I would really like a work-around. Matplotlib is supposed to be immune to this nowadays but it's not. Nor are some other third-party modules. Did they break with the new release? (2.6.3?) -nick On Thu, Oct 8, 2009 at 1:12 PM, M.-A. Lemburg wrote: > Nick Touran wrote: > > Cop

Work around metaclass programming

2009-10-12 Thread Zac Burns
I have a class called Signal which is a descriptor. It is a descriptor so that it can create BoundSignals, much like the way methods work. What I would like to do is to have the class be a descriptor when instantiated in what will be the locals of the class, but not a descriptor everywhere else. C

POST value related question

2009-10-12 Thread ken
hello i have some problem to send POST value by use mechanize. i can't write my article to my blog site. here is full source. and what i want to do is, im posting my article to my blog site. thanks in advance. # -*- coding: cp949 -*- import mechanize import cookielib # Browser br = mechanize.Bro

Re: The rap against "while True:" loops

2009-10-12 Thread Mensanator
On Oct 12, 2:18 pm, Falcolas wrote: > On Oct 12, 12:32 pm, Mensanator wrote: > > > > > > > On Oct 12, 1:02 pm, John Reid wrote: > > > Mensanator wrote: > > > > On Oct 12, 3:36 am, greg wrote: > > > >> Mensanator wrote: > > > >>> while not done: > > > >>> ... > > > >>> if n==1: done = True > > >

Re: What is the correct way to define __hash__?

2009-10-12 Thread Christian Heimes
Peng Yu schrieb: > Hi, > > I'm wondering what is the general way to define __hash__. I could add > up all the members. But I am wondering if this would cause a > performance issue for certain classes. > def __hash__(self): > return self._a + self._b The hash of a tuple is based on the ha

Re: What is the correct way to define __hash__?

2009-10-12 Thread Robert Kern
On 2009-10-12 15:45 PM, Peng Yu wrote: Hi, I'm wondering what is the general way to define __hash__. I could add up all the members. But I am wondering if this would cause a performance issue for certain classes. Unless if you are very familiar with the math of hash functions, I don't recomme

Re: What is the correct way to define __hash__?

2009-10-12 Thread Peng Yu
On Mon, Oct 12, 2009 at 3:45 PM, Peng Yu wrote: > Hi, > > I'm wondering what is the general way to define __hash__. I could add > up all the members. But I am wondering if this would cause a > performance issue for certain classes. > > Regards, > Peng > > > #!/usr/bin/env python > > class A: >  de

What is the correct way to define __hash__?

2009-10-12 Thread Peng Yu
Hi, I'm wondering what is the general way to define __hash__. I could add up all the members. But I am wondering if this would cause a performance issue for certain classes. Regards, Peng #!/usr/bin/env python class A: def __init__(self, a, b) : self._a = a self._b = b def __str__

Re: best vi / emacs python features

2009-10-12 Thread Gabor Urban
Hey guys, this is supposed to be a Python mailing list... Both editors are great and are with great potentials. I do use both of them daily, though for different purposes. It is meaningless to start this old issue of preferences anew. -- Linux: Choice of a GNU Generation -- http://mail.python.

Re: "Error en el bus" from python

2009-10-12 Thread Jorgen Grahn
On Mon, 2009-10-12, Philip Semanchuk wrote: > > On Oct 11, 2009, at 4:45 PM, Yusniel wrote: > >> Hi. I did installed a library for python named pyswip-0.2.2 but when I >> run a python example with the next lines, the python interpreter, it >> throw me the following error: "Error en el bus". The cod

Re: Daemon call python program

2009-10-12 Thread Jorgen Grahn
On Mon, 2009-10-12, §ä´m¦Û¤vª�...@¤ù¤Ñ wrote: > ?? ???z?mcommand (???m???v...@)?n???G > : I have a daemon process which will call a python program. > : What do I do if I want to dump the exception when the python program exist > : by uncaught exception. > : Thanks a lot! > > By

which "dictionary with attribute-style access"?

2009-10-12 Thread Andreas Balogh
Hello, googling I found several ways of implementing a "dictionary with attribute-style access". 1. ActiveState cookbook: http://code.activestate.com/recipes/473786/ 2. ActiveState cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361668 3. web2py codebase: Storage(dict) I

Re: start external program from python

2009-10-12 Thread Jorgen Grahn
On Mon, 2009-10-12, Bjorn wrote: > > Hi, I woul like to start a program from within python (under linux): > This works fine: > > import os > path = 'tclsh AppMain.tcl hej.gb' > os.system(path) > > The file AppMain.tcl is the executable Not really -- tclsh is the executable from Python's and the sy

Hello python users

2009-10-12 Thread Spencer Heckathorn
Hi, I am new to this list. I have some goals in mind but I am unsure of where to start. I want to connect to my gmail account, find specific emails and save the contents of the emails to a txt file. I would like to open none txt files (.nc files) which can be opened in note pad and saved as a txt.

Re: The rap against "while True:" loops

2009-10-12 Thread Falcolas
On Oct 12, 12:32 pm, Mensanator wrote: > On Oct 12, 1:02 pm, John Reid wrote: > > Mensanator wrote: > > > On Oct 12, 3:36 am, greg wrote: > > >> Mensanator wrote: > > >>> while not done: > > >>> ... > > >>> if n==1: done = True > > >>> ... > > >> Seems to me that 'while not done:' is no better t

Re: It Doesn't Add Up!

2009-10-12 Thread MRAB
Victor Subervi wrote: Hi; I have the following code: [snip] price = str(int(stuff[5]*100)) price = price[0:len(price)-2] + '.' + price[-2:] [snip] This is simpler: price = "%.2f" % stuff[5] (not that I like what you're doing with it; leaving it as a float and just fo

Re: It Doesn't Add Up!

2009-10-12 Thread Victor Subervi
Ouch! You're right! <;) V On Mon, Oct 12, 2009 at 1:38 PM, Rami Chowdhury wrote: > On Mon, 12 Oct 2009 11:33:31 -0700, Victor Subervi < > victorsube...@gmail.com> wrote: > > Hi; >> I have the following code: >> >>for row in data: >> i += 1 >> total = 0 >> > [snip] > >> As you can

Re: It Doesn't Add Up!

2009-10-12 Thread Rami Chowdhury
On Mon, 12 Oct 2009 11:33:31 -0700, Victor Subervi wrote: Hi; I have the following code: for row in data: i += 1 total = 0 [snip] As you can see, the total doesn't accumulate! There are two rows. The second "Total 1:" should show "1.98", not 0! What gives? You are sett

Re: It Doesn't Add Up!

2009-10-12 Thread Chris Kaynor
Chris On Mon, Oct 12, 2009 at 11:33 AM, Victor Subervi wrote: > Hi; > I have the following code: > > for row in data: > i += 1 > total = 0 > In the above line, you're setting total to 0 each time the loop runs. > quantity = form.getfirst('order_' + str(i), '') > if

Re: The rap against "while True:" loops

2009-10-12 Thread Mensanator
On Oct 12, 1:02�pm, John Reid wrote: > Mensanator wrote: > > On Oct 12, 3:36 am, greg wrote: > >> Mensanator wrote: > >>> while not done: > >>> ... > >>> if n==1: done = True > >>> ... > >> Seems to me that 'while not done:' is no better than > >> 'while True:', because in both cases you have to

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread M.-A. Lemburg
Chris Rebert wrote: > On Mon, Oct 12, 2009 at 4:27 AM, Piet van Oostrum wrote: >>> greg (g) wrote: >> >>> g> MRAB wrote: > And when someone says "January 30", do they really mean the day before > the last day of the month? >> >>> g> No, no, that's January -2, a *completely* different

It Doesn't Add Up!

2009-10-12 Thread Victor Subervi
Hi; I have the following code: for row in data: i += 1 total = 0 quantity = form.getfirst('order_' + str(i), '') if quantity != '': sql = 'select * from products p join %s c on p.ID=c.ID where c.ID=%s;' % (client, str(i)) cursor.execute(sql) stuf

Re: The rap against "while True:" loops

2009-10-12 Thread Ethan Furman
Mensanator wrote: On Oct 12, 3:36�am, greg wrote: Mensanator wrote: while not done: � � ... � � if n==1: done = True � � ... Seems to me that 'while not done:' is no better than 'while True:', because in both cases you have to look inside the loop to find out what the exit condition is. U

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Buck
On Oct 10, 9:44 am, "Gabriel Genellina" wrote: > The good thing is that, if the backend package is properly installed   > somewhere in the Python path ... it still works with no modifications. I'd like to get to zero-installation if possible. It's easy with simple python scripts, why not packages

Re: deepcopy of class inherited from Thread

2009-10-12 Thread Mick Krippendorf
VYAS ASHISH M-NTB837 schrieb: > > The function that I want to run is part of a class, not a standalone > function. There are several class member variables also. Then try: class MyClass(object): ... def run(self): """ do threaded stuff here """ ... Thread(target=MyClass().r

Re: The rap against "while True:" loops

2009-10-12 Thread John Reid
Mensanator wrote: On Oct 12, 3:36�am, greg wrote: Mensanator wrote: while not done: � � ... � � if n==1: done = True � � ... Seems to me that 'while not done:' is no better than 'while True:', because in both cases you have to look inside the loop to find out what the exit condition is. Usin

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread M.-A. Lemburg
Rhodri James wrote: > On Fri, 09 Oct 2009 13:39:43 +0100, Tim Chase > wrote: > >>> Month arithmetic is a bit of a mess, since it's not clear how >>> to map e.g. Jan 31 + one month. >> >> "Jan 31 + one month" usually means "add one to the month value and >> then keep backing off the day if you get

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread M.-A. Lemburg
Tim Chase wrote: >> Month arithmetic is a bit of a mess, since it's not clear how >> to map e.g. Jan 31 + one month. > > "Jan 31 + one month" usually means "add one to the month value and then > keep backing off the day if you get an exception making the date", so > you'd get Feb 31, exception, Fe

RE: deepcopy of class inherited from Thread

2009-10-12 Thread VYAS ASHISH M-NTB837
The function that I want to run is part of a class, not a standalone function. There are several class member variables also. Regards, Ashish Vyas -Original Message- From: python-list-bounces+ntb837=motorola@python.org [mailto:python-list-bounces+ntb837=motorola@python.org] On

Re: some site login problem help plz..

2009-10-12 Thread lkcl
On Oct 5, 8:26 am, "Diez B. Roggisch" wrote: > james27 wrote: > > > hello.. > > im new to python. > > i have some problem with mechanize. > > before i was used mechanize with no problem. > > but i couldn't success login with some site. > > for several days i was looked for solution but failed. > >

Re: The rap against "while True:" loops

2009-10-12 Thread Mensanator
On Oct 12, 3:36�am, greg wrote: > Mensanator wrote: > > while not done: > > � � ... > > � � if n==1: done = True > > � � ... > > Seems to me that 'while not done:' is no better than > 'while True:', because in both cases you have to look > inside the loop to find out what the exit condition > is.

Re: AJAX Widget Framework

2009-10-12 Thread lkcl
On Oct 1, 6:01 pm, Laszlo Nagy wrote: > I'm looking for an open source, AJAX based widget/windowing framework. > Here is what I need: > > - end user opens up a browser, points it to a URL, logs in > - on the server site, sits my application, creating a new session for > each user that is logged in

Re: deepcopy of class inherited from Thread

2009-10-12 Thread Mick Krippendorf
VYAS ASHISH M-NTB837 schrieb: > I have an object which has a run() method. But I can call it only once. > Calling the start() again will give > > RuntimeError: thread already started > > So what is the way to do this? > > I thought of doing a deep copy of the object, as shallow copy will also >

how to move a webiste in python

2009-10-12 Thread Bhanu Mangipudi
Hi, I am new to python I have few questions regarding it. I have to me a website with python scripts from one server to another server , when I moved the content the website is not working, do I have to recompile the code in new server too. Can any help me to resolve this issue ?? Thanks Bhanu --

Re: What do I do now?

2009-10-12 Thread Tim Chase
Che M wrote: 2. Start your own. As long it is not another new code editor for Python. There are a lot already. How about writing a web framework instead? [grins & ducks] -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-12 Thread Luis Zarrabeitia
On Monday 12 October 2009 09:47:23 am Xavier Ho wrote: > On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia wrote: > > Actually, in python, this works even better: > > > > for lin in iter(file_object.readline, ""): > >... do something with lin > > What about > > >>> with open(path_string)

Re: What do I do now?

2009-10-12 Thread Che M
On Oct 12, 12:19 am, Donn wrote: > On Monday 12 October 2009 00:53:42 Someone Something wrote:> 1) What should I > start programming (project that takes 1-2 months, not very > > short term)? > > 2) Whtat are some good open source projects I can start coding for? > > These kinds of questions amaze

Re: Looking for a buffered/windowed iterator

2009-10-12 Thread Robert Kern
On 2009-10-12 11:21 AM, samwyse wrote: Previous discussions in c.l.py (primarily those that propose new functions to be added to itertools) claim that people do this all the time, but seem woefully short of actual examples. Before I possibly re-invent the wheel(*), could someone point me to som

RE: deepcopy of class inherited from Thread

2009-10-12 Thread VYAS ASHISH M-NTB837
Hi I have an object which has a run() method. But I can call it only once. Calling the start() again will give RuntimeError: thread already started So what is the way to do this? I thought of doing a deep copy of the object, as shallow copy will also lead to the above error. I tried this: - d

Looking for a buffered/windowed iterator

2009-10-12 Thread samwyse
I have Python program that lets me interact with a bunch of files. Unfortunately, the program assumes that the bunch is fairly small, and I have thousands of files on relatively slow storage. Just creating a list of the file names takes several minutes, so I'm planning to replace the list with an

Re: start external program from python

2009-10-12 Thread TerryP
On Oct 12, 10:15 am, Bjorn wrote: > Hi, I woul like to start a program from within python (under linux): > This works fine: > > import os > path = 'tclsh AppMain.tcl hej.gb' > os.system(path) > > The file AppMain.tcl is the executable and the file hej.gb is a > textfile in the same directory. > Th

Re: POST value related question

2009-10-12 Thread Diez B. Roggisch
james27 wrote: > > hello > im using mechanize . > i want to send some post value by use mechanize. > but problem is one of POST value in html source is > looks like below. > > post.category.categoryNo=[*1] > > anyway so i was tried several method but all failed. > > here is source . > . > . >

Re: "Error en el bus" from python

2009-10-12 Thread Carsten Haese
Yusniel wrote: > Exactly. "hanoi.pl" is a prolog program. I'm using Ubuntu(9.04) 32 > bit. In this case, this error is generated when I try run the above > script. However, others scripts in python, not throws this error, I > think that there are some problem with this library. Maybe, but it's imp

Re: "Error en el bus" from python

2009-10-12 Thread Philip Semanchuk
On Oct 12, 2009, at 11:27 AM, Yusniel wrote: On 12 oct, 00:08, Philip Semanchuk wrote: On Oct 11, 2009, at 11:56 PM, Dennis Lee Bieber wrote: On Sun, 11 Oct 2009 13:45:54 -0700 (PDT), Yusniel declaimed the following in gmane.comp.python.general: prolog.consult("hanoi.pl") whe

Re: pickle's backward compatibility

2009-10-12 Thread exarkun
On 03:17 pm, pengyu...@gmail.com wrote: Hi, If I define my own class and use pickle to serialize the objects in this class, will the serialized object be successfully read in later version of python. What if I serialize (using pickle) an object of a class defined in python library, will it be s

Re: "Error en el bus" from python

2009-10-12 Thread Yusniel
On 12 oct, 00:08, Philip Semanchuk wrote: > On Oct 11, 2009, at 11:56 PM, Dennis Lee Bieber wrote: > > > On Sun, 11 Oct 2009 13:45:54 -0700 (PDT), Yusniel > > declaimed the following in gmane.comp.python.general: > > >>    prolog.consult("hanoi.pl") > >     > >> where "hanoy.pl" is a program with

POST value related question

2009-10-12 Thread james27
hello im using mechanize . i want to send some post value by use mechanize. but problem is one of POST value in html source is looks like below. post.category.categoryNo=[*1] anyway so i was tried several method but all failed. here is source . . . br = mechanize.browser() br.select_form(nr=0)

pickle's backward compatibility

2009-10-12 Thread Peng Yu
Hi, If I define my own class and use pickle to serialize the objects in this class, will the serialized object be successfully read in later version of python. What if I serialize (using pickle) an object of a class defined in python library, will it be successfully read in later version of pytho

Re: The rap against "while True:" loops

2009-10-12 Thread Mel
Luis Zarrabeitia wrote: > On Sunday 11 October 2009 11:56:55 pm Dennis Lee Bieber wrote: >> In this situation, the middle exit works best -- using >> non-optimal Python >> >> while True: >> lin = file_object.readline() >> if not lin: break >> do something with lin > > Actually, in python, this wo

Re: An assessment of Tkinter and IDLE

2009-10-12 Thread Mel
Ben Finney wrote: > TerryP writes: > >> One thing you should also learn about me, is I do not deal in >> absolutes. > > What, *never*? That's a pretty uncompromising position to h— > > I'll get my coat. Note, he said he does not deal in absolutes. He didn't deny that he does. Mel.

Re: Python-3.2 (SVN) bug [was syntax question]

2009-10-12 Thread Mark Dickinson
On Oct 12, 7:55 am, Helmut Jarausch wrote: > I wrote > I'm trying to build the recent Python-3.2a (SVN). > It fails in > Lib/tokenize.py  (line 87) [...] > with: TypeError: group() argument after ** must be a mapping, not tuple I believe I've found the source of this problem: the --with-tsc conf

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread MRAB
Piet van Oostrum wrote: greg (g) wrote: g> MRAB wrote: And when someone says "January 30", do they really mean the day before the last day of the month? g> No, no, that's January -2, a *completely* different thing! But for someone else it would be February -2. When is February 0? :-)

Re: What do I do now?

2009-10-12 Thread exarkun
On 11 Oct, 10:53 pm, fordhai...@gmail.com wrote: I've been programming since about 3 years, and come to think of it never written anything large. I know a few languages: c, python, perl, java. Right now, I just write little IRC bots that basically don't do anything. I have two questions: 1) W

Re: The rap against "while True:" loops

2009-10-12 Thread Xavier Ho
On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia wrote: > Actually, in python, this works even better: > > for lin in iter(file_object.readline, ""): >... do something with lin > > What about >>> with open(path_string) as f: >>> for line in f: >>> # do something Cheers, X

Re: deepcopy of class inherited from Thread

2009-10-12 Thread Dave Angel
VYAS ASHISH M-NTB837 wrote: Dear All I am running this piece of code: from threading import Thread import copy class Ashish(Thread): def __init__(self, i): Thread.__init__(self) self.foo = i def run(self): print (self, self.foo) d= Ashish(4) e = copy.de

Re: best vi / emacs python features

2009-10-12 Thread Jorgen Grahn
On Wed, 2009-10-07, OdarR wrote: > hello, > > * this is not a troll * > > which kind of help you have with your favorite editor ? Syntax highlighting and help with the indentation (move to the right after an else:, keep in the same column normally, etc). Nothing else specific to Python. > personn

Re: The rap against "while True:" loops

2009-10-12 Thread Luis Zarrabeitia
On Sunday 11 October 2009 11:56:55 pm Dennis Lee Bieber wrote: > In this situation, the middle exit works best -- using > non-optimal Python > > while True: > lin = file_object.readline() > if not lin: break > do something with lin Actually,

deepcopy of class inherited from Thread

2009-10-12 Thread VYAS ASHISH M-NTB837
Dear All I am running this piece of code: from threading import Thread import copy class Ashish(Thread): def __init__(self, i): Thread.__init__(self) self.foo = i def run(self): print (self, self.foo) d= Ashish(4) e = copy.deepcopy(d) <--- Exception here...

Re: Why ELIF?

2009-10-12 Thread Esmail
TerryP wrote: Somehow I doubt that "Look up X in dictionary D" could ever be more efficient (in terms of space and time, at least) then "Check if X is equal to Y". It's not about what you get in runtime but what you get in monkey time. Most expressions that would make someone reach for a C-lik

Re: code in a module is executed twice (cyclic import problems) ?

2009-10-12 Thread Dave Angel
greg wrote: Dave Angel wrote: The point you should get from that link is "Don't do circular imports. Ever." No, I would say the lesson to be learned from this is "don't use the same file as both a main script and an imported module". I would create another file called e.g. 'main.py' that

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread Chris Rebert
On Mon, Oct 12, 2009 at 4:27 AM, Piet van Oostrum wrote: >> greg (g) wrote: > >>g> MRAB wrote: And when someone says "January 30", do they really mean the day before the last day of the month? > >>g> No, no, that's January -2, a *completely* different thing! > > But for someone else

Re: postprocessing in os.walk

2009-10-12 Thread Dave Angel
kj wrote: Perl's directory tree traversal facility is provided by the function find of the File::Find module. This function accepts an optional callback, called postprocess, that gets invoked "just before leaving the currently processed directory." The documentation goes on to say "This hook is

Re: mxDateTime history (Re: mktime, how to handle dates before 01-01-1970 ?)

2009-10-12 Thread Piet van Oostrum
> greg (g) wrote: >g> MRAB wrote: >>> And when someone says "January 30", do they really mean the day before >>> the last day of the month? >g> No, no, that's January -2, a *completely* different thing! But for someone else it would be February -2. -- Piet van Oostrum WWW: http://pietvano

  1   2   >