what's this instance?

2008-01-21 Thread J. Peng
def safe_float(object): try: retval = float(object) except (ValueError, TypeError), oops: retval = str(oops) return retval x=safe_float([1,2,3,4]) print x The code above works well.But what's the instance of "oops"? where is it coming from? I'm totally confused on it.thanks. -- ht

Re: Boa constructor debugging - exec some code at breakpoint?

2008-01-21 Thread Joel
Can you please tell me how this can be done.. are there any other IDEs for the same purpose if Boa can't do it? Joel On Jan 6, 11:01 am, Joel <[EMAIL PROTECTED]> wrote: > Hey there.. > I'm using boa constructor to debug a python application. For my > application, I need to insert break points and

Re: pairs from a list

2008-01-21 Thread Arnaud Delobelle
On Jan 22, 3:20 am, Alan Isaac <[EMAIL PROTECTED]> wrote: > I want to generate sequential pairs from a list. > Here is a way:: > >     from itertools import izip, islice >     for x12 in izip(islice(x,0,None,2),islice(x,1,None,2)): >         print x12 > > (Of course the print statement is just illu

Re: pairs from a list

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 21:34:28 -0800, George Sakkis wrote: > I believe the "what is the fastest way" question for such small well- > defined tasks is worth asking on its own, regardless of whether it makes > a difference in the application (or even if there is no application to > begin with). Just b

Calculate net transfer rate without dummy file

2008-01-21 Thread whatazor
Hi, how can I calulate transfer rate to a host , without using a file ? can ping module (written by Jeremy Hylton) be useful ? -- http://mail.python.org/mailman/listinfo/python-list

Electronic and Computer Science video courses, No login, No fee

2008-01-21 Thread AK444
Hi Guys Good news is 23 Electronic and Computer Science video courses are free, No login, No fee. All you need to have is real player installed on your PC. Electronics is at http://freevideolectures.com/electronics/circuits_and_electronics.php Computer Science is at http://freevideolectu

Re: py2exe and modules question

2008-01-21 Thread Tim Roberts
azrael <[EMAIL PROTECTED]> wrote: > >I'm working on an application and i'm having some questions. I am >working with python 2.5, numpy and PIL. does anyone know if there are >some problems while compiling the source because of the modules.. It >has to be closed source. What does that mean to you?

Re: I don't understand what is happening in this threading code

2008-01-21 Thread Tim Roberts
Matthew Wilson <[EMAIL PROTECTED]> wrote: >In this code, I tried to kill my thread object by setting a variable on it >to False. > >Inside the run method of my thread object, it checks a different >variable. > >I've already rewritten this code to use semaphores, but I'm just curious >what is going

Re: read files

2008-01-21 Thread J. Peng
Gabriel Genellina 写道: > En Tue, 22 Jan 2008 02:03:10 -0200, Paul Rubin > <"http://phr.cx"@NOSPAM.invalid> escribió: > >> "J. Peng" <[EMAIL PROTECTED]> writes: >>> print line, >> Do you really want all the lines crunched together like that? If not, >> leave off the comma. > > Remember t

Re: pairs from a list

2008-01-21 Thread George Sakkis
On Jan 22, 12:15 am, Paddy <[EMAIL PROTECTED]> wrote: > On Jan 22, 3:20 am, Alan Isaac <[EMAIL PROTECTED]> wrote:> I want to generate > sequential pairs from a list. > <> > > What is the fastest way? (Ignore the import time.) > > 1) How fast is the method you have? > 2) How much faster does it nee

HTML parsing confusion

2008-01-21 Thread Alnilam
Sorry for the noob question, but I've gone through the documentation on python.org, tried some of the diveintopython and boddie's examples, and looked through some of the numerous posts in this group on the subject and I'm still rather confused. I know that there are some great tools out there for

Re: newbie question: On installation of additional packages to Python

2008-01-21 Thread Gabriel Genellina
En Tue, 22 Jan 2008 00:36:34 -0200, Nasser Abbasi <[EMAIL PROTECTED]> escribió: > I am running on windowz. I have downloaded and installed 2.5.1 Python. > > my question is on installing additional packages. > > What is the easiest way to do that? I read about python 'eggs' (like jar > files for J

Re: read files

2008-01-21 Thread Gabriel Genellina
En Tue, 22 Jan 2008 02:03:10 -0200, Paul Rubin <"http://phr.cx"@NOSPAM.invalid> escribió: > "J. Peng" <[EMAIL PROTECTED]> writes: >> print line, > > Do you really want all the lines crunched together like that? If not, > leave off the comma. Remember that Python *keeps* the end-of-line

Re: pairs from a list

2008-01-21 Thread Paddy
On Jan 22, 3:20 am, Alan Isaac <[EMAIL PROTECTED]> wrote: > I want to generate sequential pairs from a list. <> > What is the fastest way? (Ignore the import time.) 1) How fast is the method you have? 2) How much faster does it need to be for your application? 3) Are their any other bottlenecks in

Re: pairs from a list

2008-01-21 Thread George Sakkis
On Jan 21, 10:20 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > I want to generate sequential pairs from a list. > Here is a way:: > > from itertools import izip, islice > for x12 in izip(islice(x,0,None,2),islice(x,1,None,2)): > print x12 > > (Of course the print statement is just ill

Re: How to solve "TypeError: list indices must be integers".

2008-01-21 Thread 顏灝
On 1月22日, 上午1時56分, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Mon, 21 Jan 2008 08:15:02 -0800 (PST), "ÃCø¯" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > I was assigned dialog.colorDialog(self) return value to a result > > object, but I suspect that result.color is

Re: How to solve "TypeError: list indices must be integers".

2008-01-21 Thread 顏灝
On 1月22日, 上午3時05分, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 22, 3:15 am, "顏灝" <[EMAIL PROTECTED]> wrote: > > > This is more details about my problem, which I running my py script > > for my project. Programming in pythoncard that we can develop a GUI > > based application easily. > > > I was

Re: read files

2008-01-21 Thread J. Peng
Thank you. That gave so much solutions. And thanks all. Steven D'Aprano 写道: > On Tue, 22 Jan 2008 11:00:53 +0800, J. Peng wrote: > >> first I know this is the correct method to read and print a file: >> >> fd = open("/etc/sysctl.conf") >> done=0 >> while not done: >> line = fd.readline() >>

Re: read files

2008-01-21 Thread Paul Rubin
"J. Peng" <[EMAIL PROTECTED]> writes: > print line, Do you really want all the lines crunched together like that? If not, leave off the comma. > I dont like that flag of "done",then I tried to re-write it as: > > fd = open("/etc/sysctl.conf") > while line = fd.readline(): > print li

Re: read files

2008-01-21 Thread Steven D'Aprano
On Tue, 22 Jan 2008 11:00:53 +0800, J. Peng wrote: > first I know this is the correct method to read and print a file: > > fd = open("/etc/sysctl.conf") > done=0 > while not done: > line = fd.readline() > if line == '': > done = 1 > else: > print line, > > fd.close()

Re: pairs from a list

2008-01-21 Thread Paul Rubin
Alan Isaac <[EMAIL PROTECTED]> writes: > (Of course the print statement is just illustrative.) > What is the fastest way? (Ignore the import time.) You have to try a bunch of different ways and time them. One idea (untested): def pairs(seq): while True: yield (seq.next(), s

pairs from a list

2008-01-21 Thread Alan Isaac
I want to generate sequential pairs from a list. Here is a way:: from itertools import izip, islice for x12 in izip(islice(x,0,None,2),islice(x,1,None,2)): print x12 (Of course the print statement is just illustrative.) What is the fastest way? (Ignore the import time.) Thanks, A

Re: read files

2008-01-21 Thread Benjamin
On Jan 21, 9:08 pm, Mel <[EMAIL PROTECTED]> wrote: > J. Peng wrote: > > first I know this is the correct method to read and print a file: > > > fd = open("/etc/sysctl.conf") > > done=0 > > while not done: > > line = fd.readline() > > if line == '': > > done = 1 > > else: > >

Re: read files

2008-01-21 Thread Mel
J. Peng wrote: > first I know this is the correct method to read and print a file: > > fd = open("/etc/sysctl.conf") > done=0 > while not done: > line = fd.readline() > if line == '': > done = 1 > else: > print line, > > fd.close() > > > I dont like that flag of "don

Re: read files

2008-01-21 Thread Alex Ezell
You might could do one of these two methods: fd.readlines() or: for line in fd: print line These are both from the Python tutorial found here: http://docs.python.org/tut/node9.html#SECTION00921 /alex On Jan 21, 2008 9:00 PM, J. Peng <[EMAIL PROTECTED]> wrote: > first I kno

read files

2008-01-21 Thread J. Peng
first I know this is the correct method to read and print a file: fd = open("/etc/sysctl.conf") done=0 while not done: line = fd.readline() if line == '': done = 1 else: print line, fd.close() I dont like that flag of "done",then I tried to re-write it as: fd = open

newbie question: On installation of additional packages to Python

2008-01-21 Thread Nasser Abbasi
hello; I have not used Python before directly, but I am interested in trying it. I've read some good things about it. ( I am mainly interested in trying it for some scientific applications and simulation.) I am running on windowz. I have downloaded and installed 2.5.1 Python. my question is o

Re: Curses and Threading

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 23:06:10 -0200, <[EMAIL PROTECTED]> escribió: > I am writing a program that uses curses and threading. I am working on > displaying a clock in the upper right hand corner of the screen. I > have only one thread at the moment, that gets the time and displays it > in curses. In

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread p.
Thanks to all for the ideas. I am familiar with external sorting. Hadn't considered it though. Will definitely be giving that a go, and then merging. Again, thanks all. -- http://mail.python.org/mailman/listinfo/python-list

Re: Max Long

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 22:02:34 -0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > On Jan 21, 5:36 pm, Gary Herron <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >> > How can I figure out the largest long available?  I was hoping for >> >> There is no explicit (defined) limit.  The a

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread Arnaud Delobelle
On Jan 20, 5:41 pm, [EMAIL PROTECTED] wrote: > Ever since I learnt to program I've always loved writing solvers for > the Countdown numbers game problem in different languages, and so now > I'm wondering what the most elegant solution in Python is. I've tried a completely different approach, that

Curses and Threading

2008-01-21 Thread Brett . Friermood
I am writing a program that uses curses and threading. I am working on displaying a clock in the upper right hand corner of the screen. I have only one thread at the moment, that gets the time and displays it in curses. To make it easier to debug right now, the program starts curses in a try: claus

Re: Max Long

2008-01-21 Thread tjhnson
On Jan 21, 3:34 pm, Bjoern Schliessmann wrote: > [EMAIL PROTECTED] wrote: > > How can I figure out the largest long available? > > Why would you? AFAIK, longs are only limited by available memory. Indeed, as the docs pointed out. I guess I was confused by "If pylong is greater than ULONG_MAX, a

Re: problem With Psyco on Wingide mac

2008-01-21 Thread Wingware Support
Arash Arfaee wrote: > I am trying to use psyco with wingide on mac. when I open Mac Python > shell I can import psyco, but not inside the wingide. Even python > shell on wingide cannot import psyco. > Can anybody help me to solvethis problem? I suspect Wing is finding a different Python installati

problem With Psyco on Wingide mac

2008-01-21 Thread Arash Arfaee
Hello All, I am trying to use psyco with wingide on mac. when I open Mac Python shell I can import psyco, but not inside the wingide. Even python shell on wingide cannot import psyco. Can anybody help me to solvethis problem? Thanks, Arash -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread MRAB
On Jan 21, 9:15 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Arne a écrit : > > > On 21 Jan, 19:15, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > >> This should not prevent you from learning how to properly parse XML > >> (hint: with an XML parser). XML is *not* a line-oriented forma

Re: Max Long

2008-01-21 Thread [EMAIL PROTECTED]
On Jan 21, 5:36 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > How can I figure out the largest long available?  I was hoping for > > something like sys.maxint, but I didn't see it.  Also, can someone > > point me to where I can (concisely) read about size of such types >

Re: Max Long

2008-01-21 Thread Gary Herron
[EMAIL PROTECTED] wrote: > How can I figure out the largest long available? I was hoping for > something like sys.maxint, but I didn't see it. Also, can someone > point me to where I can (concisely) read about size of such types > (int, float, long). > There is no explicit (defined) limit. Th

Re: constructor question

2008-01-21 Thread azrael
5 days ago I looked at it and didn't take a notice. thnx, this helped On Jan 22, 12:10 am, TeroV <[EMAIL PROTECTED]> wrote: > azrael wrote: > > lets supose i have a object > > class a: >   __init__(self,b): >        self.b=b > > object=a(2) > > > how can I bind the object wit

Re: Max Long

2008-01-21 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > How can I figure out the largest long available? Why would you? AFAIK, longs are only limited by available memory. > I was hoping for something like sys.maxint, but I didn't see it. > Also, can someone point me to where I can (concisely) read about > size of such types

Max Long

2008-01-21 Thread tjhnson
How can I figure out the largest long available? I was hoping for something like sys.maxint, but I didn't see it. Also, can someone point me to where I can (concisely) read about size of such types (int, float, long). -- http://mail.python.org/mailman/listinfo/python-list

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread Bruno Desthuilliers
p. a écrit : > I need to take a series of ascii files and transform the data > contained therein so that it can be inserted into an existing > database. The ascii files are just a series of lines, each line > containing fields separated by '|' character. Relations amongst the > data in the various

Re: bags? 2.5.x?

2008-01-21 Thread Dan Stromberg
On Thu, 17 Jan 2008 18:18:53 -0800, Raymond Hettinger wrote: >> >> I keep wanting something like them - especially bags with something >> >> akin to set union, intersection and difference. >> >> > How about this recepie >> > http://www.ubookcase.com/book/Oreilly/ >> >> The author of the bag class

Re: constructor question

2008-01-21 Thread TeroV
azrael wrote: > lets supose i have a object > class a: __init__(self,b): self.b=b > object=a(2) > > > how can I bind the object with "print". I supose that this should be > possible with a constructor. but I don't know how. > print a > 2 > > Something like th

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread Paul Rubin
"p." <[EMAIL PROTECTED]> writes: > So as an exercise, lets assume 800MB file, each line of data taking up > roughly 150B (guesstimate - based on examination of sample data)...so > roughly 5.3 million unique IDs. I still don't understand what the problem is. Are you familiar with the concept of ex

constructor question

2008-01-21 Thread azrael
lets supose i have a object >>>class a: >>> __init__(self,b): >>>self.b=b >>>object=a(2) how can I bind the object with "print". I supose that this should be possible with a constructor. but I don't know how. >>>print a 2 >>> Something like this Thnx -- http://mail.python.org/mai

Re: Prioritization function needed (recursive help!)

2008-01-21 Thread Kent Johnson
rh0dium wrote: > Hi all, > > I need some help on writing a recursive priority function > > Given a list = [ A, B, C, D] > > Where the following constraints are in place: > > A depends on [B, C] > C depends on [B] > > Figure out real order that prioritizes these. You need a topological sort. h

PyGTK, Glade, and ComboBoxEntry.append_text()

2008-01-21 Thread Greg Johnston
Hey all, I'm a relative newbie to Python (switched over from Scheme fairly recently) but I've been using PyGTK and Glade to create an interface, which is a combo I'm very impressed with. There is, however, one thing I've been wondering about. It doesn't seem possible to modify ComboBoxEntry choic

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread p.
So in answer to some of the questions: - There are about 15 files, each roughly representing a table. - Within the files, each line represents a record. - The formatting for the lines is like so: File1: somval1|ID|someval2|someval3|etc. File2: ID|someval1|someval2|somewal3|etc. Where ID is the o

Re: Prioritization function needed (recursive help!)

2008-01-21 Thread Arnaud Delobelle
On Jan 21, 10:30 pm, rh0dium <[EMAIL PROTECTED]> wrote: > Hi all, > > I need some help on writing a recursive priority function > > Given a list = [ A, B, C, D] > > Where the following constraints are in place: > > A depends on [B, C] > C depends on [B] > > Figure out real order that prioritizes th

Re: Prioritization function needed (recursive help!)

2008-01-21 Thread Paul Rubin
rh0dium <[EMAIL PROTECTED]> writes: > I am really struggling on simply how to organize the data and write > the corresponding function - I tried classes but I don't know if > that's the best approach. See my other post on this. We just had a discussion thread about this. Is it a homework problem

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread George Sakkis
On Jan 21, 4:45 pm, Paul Rubin wrote: > "p." <[EMAIL PROTECTED]> writes: > > 1. Has anyone done anything like this before, and if so, do you have > > any advice? > > Sort all the files with an external sort utility (e.g. unix sort), so > that records with the same key are

Prioritization function needed (recursive help!)

2008-01-21 Thread rh0dium
Hi all, I need some help on writing a recursive priority function Given a list = [ A, B, C, D] Where the following constraints are in place: A depends on [B, C] C depends on [B] Figure out real order that prioritizes these. Output [ B, C, A, D ] is valid. (Actually D could be anywhere in it

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 18:38:48 -0200, Arne <[EMAIL PROTECTED]> escribi�: > On 21 Jan, 19:15, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: > >> This should not prevent you from learning how to properly parse XML >> (hint: with an XML parser). XML is *not* a line-oriented format, so you >> just can'

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 18:00:05 +, Pete Forman wrote: > If NaNs in your data are important then you must take care in explicit > and implicit comparisons to consider unordered results. And even if they're not important, beware of bugs from failing to consider unordered results due to unexpected

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Bruno Desthuilliers
Arne a écrit : > On 21 Jan, 19:15, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: > >> This should not prevent you from learning how to properly parse XML >> (hint: with an XML parser). XML is *not* a line-oriented format, so you >> just can't get nowhere trying to parse it this way. >> >> HTH >

Re: Bug in __init__?

2008-01-21 Thread Steven D'Aprano
On Mon, 21 Jan 2008 17:38:10 -0200, Gabriel Genellina wrote: > En Mon, 21 Jan 2008 05:59:38 -0200, <[EMAIL PROTECTED]> escribi�: > >> Is there no way of adding a possible warning message (that obviously >> could be turned off) to warn users of possible problems linked to using >> mutable types as

Re: index of min element of sequence

2008-01-21 Thread Paul Rubin
John Machin <[EMAIL PROTECTED]> writes: > >>> from itertools import count, izip > >>> min(izip(seq, count())) > (7, 3) Serves me right for cutting and pasting. minvalue, minindex = min(izip(seq, count())) -- http://mail.python.org/mailman/listinfo/python-list

pygep

2008-01-21 Thread Blubaugh, David A.
To Anyone out there!! I was wondering if anyone out there has had any experience with pygep program. this program is an open source version for Gene Expression Programming, which I will need to utilize in order to complete my Master's Thesis. Thanks for any help!! David Blubaug

Re: index of min element of sequence

2008-01-21 Thread John Machin
On Jan 22, 7:56 am, Paul Rubin wrote: > John Machin <[EMAIL PROTECTED]> writes: > > s/[1]/[0]/ or more generally: > > Oops, got two spellings confused. Originally was going to use > > from itertools import count, izip > min(izip(seq, count()))[1] > > but did it with en

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread Paul Rubin
"p." <[EMAIL PROTECTED]> writes: > 1. Has anyone done anything like this before, and if so, do you have > any advice? Sort all the files with an external sort utility (e.g. unix sort), so that records with the same key are all brought together. Then you can process the files sequentially. -- htt

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread John Machin
On Jan 22, 7:51 am, "p." <[EMAIL PROTECTED]> wrote: > I need to take a series of ascii files and transform the data > contained therein so that it can be inserted into an existing > database. The ascii files are just a series of lines, each line > containing fields separated by '|' character. Relat

Re: Help with cPAMIE

2008-01-21 Thread romo20350
On Jan 21, 11:09 am, [EMAIL PROTECTED] wrote: > Hi, I'm in need of help with cPAMIE. I'm currently trying to submit > this form on a webpage: > > > > Submit Coupon > Coupon Code: > > > > Submit Coupon > > > > I can fill in the textboxes alright but I'm having trouble submitting > it. I've tr

Re: problem deriving form type long

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 18:33:10 -0200, Frederic Rentsch <[EMAIL PROTECTED]> escribi�: > Hi, here's something that puzzles me: > > >>> class Fix_Point (long): > def __init__ (self, l): >long.__init__ (self, l * 0x1): > > >>> fp = Fix_Point (99) > >>> fp > 99 You have

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread Tim Chase
> I need to take a series of ascii files and transform the data > contained therein so that it can be inserted into an existing > database. [snip] > I need to transform the data from the files before inserting > into the database. Now, this would all be relatively simple if > not for the followin

Re: is it possible to set namespace to an object.

2008-01-21 Thread George Sakkis
On Jan 21, 2:52 pm, glomde <[EMAIL PROTECTED]> wrote: > On 21 Jan, 20:16, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > > > > On 21 Jan, 18:59, Wildemar Wildenburger > > > > <[EMAIL PROTECTED]> wrote: > > > > glomde wrote: > > > > > Hi, >

problem deriving form type long

2008-01-21 Thread Frederic Rentsch
Hi, here's something that puzzles me: >>> class Fix_Point (long): def __init__ (self, l): long.__init__ (self, l * 0x1): >>> fp = Fix_Point (99) >>> fp 99 With prints: >>> class Fix_Point (long): def __init__ (self, l): print l l_ = l *

Re: index of min element of sequence

2008-01-21 Thread Paul Rubin
John Machin <[EMAIL PROTECTED]> writes: > s/[1]/[0]/ or more generally: Oops, got two spellings confused. Originally was going to use from itertools import count, izip min(izip(seq, count()))[1] but did it with enumerate instead. I don't know which is actually faster. > minindex, minvalue =

Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread p.
I need to take a series of ascii files and transform the data contained therein so that it can be inserted into an existing database. The ascii files are just a series of lines, each line containing fields separated by '|' character. Relations amongst the data in the various files are denoted throu

Re: ctypes CDLL - which paths are searched?

2008-01-21 Thread Thomas Heller
Helmut Jarausch schrieb: > Hi, > > how can I specify the paths to be searched for a dynamic library > to be loaded by ctypes' CDLL class on a Linux system. > > Do I have to set os.environment['LD_LIBRARY_PATH'] ? > ctypes passes the argument given to CDLL(path) straight to the dlopen(3) call, s

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Arne
On 21 Jan, 19:15, Bruno Desthuilliers wrote: > This should not prevent you from learning how to properly parse XML > (hint: with an XML parser). XML is *not* a line-oriented format, so you > just can't get nowhere trying to parse it this way. > > HTH Do you think i should use xml.dom.minidom for

Re: problem with 'global'

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 17:36:29 -0200, Duncan Booth <[EMAIL PROTECTED]> escribi�: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Mon, 21 Jan 2008 17:08:46 -0200, Gabriel Genellina wrote: >> >>> The future statement is another example, even worse: >>> >>> if 0: >>> from __future_

Re: index of min element of sequence

2008-01-21 Thread Peter Otten
Roger Miller wrote: > On Jan 21, 8:48 am, Peter Otten <[EMAIL PROTECTED]> wrote: > >> Neal Becker wrote: >> > What's a good/fast way to find the index of the minimum element of a >> > sequence? > ... > >> >>> min(xrange(len(items)), key=items.__getitem__) > ... > > Or just >items.index(min(

Re: Is there a portable way to tell if data is available on a pipe?

2008-01-21 Thread John Nagle
Scott David Daniels wrote: > John Nagle wrote: >>I need some way to find out if a pipe has data available for >> a read without blocking if it does not. > ... >> I'd like to avoid having a thread to manage each pipe, but if I >> have to, so be it. > > Well, without granting your wish, put a Q

Re: index of min element of sequence

2008-01-21 Thread John Machin
On Jan 22, 6:38 am, Paul Rubin wrote: > Neal Becker <[EMAIL PROTECTED]> writes: > > What's a good/fast way to find the index of the minimum element of a > > sequence? (I'm fairly sure sorting the sequence is not the fastest > > approach) > > Python 2.5 (untested): > >

Building a pretrigger / posttrigger framework class

2008-01-21 Thread rh0dium
Hi all, I am thinking about a class which can automatically determine the order which it is run. I would like to implement a super class which has a run() method and a pretrigger() method. The purpose of the pretrigger method is to state what classes need to be run before this class.run() method

Re: is it possible to set namespace to an object.

2008-01-21 Thread glomde
On 21 Jan, 20:16, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > > > > > On 21 Jan, 18:59, Wildemar Wildenburger > > > <[EMAIL PROTECTED]> wrote: > > > glomde wrote: > > > > Hi, > > > > > is it somehow possible to set the current namespace so that

Re: index of min element of sequence

2008-01-21 Thread Roger Miller
On Jan 21, 8:48 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Neal Becker wrote: > > What's a good/fast way to find the index of the minimum element of a > > sequence? ... > >>> min(xrange(len(items)), key=items.__getitem__) ... Or just items.index(min(items)) I found this to be significantly

Re: index of min element of sequence

2008-01-21 Thread Paul Rubin
Neal Becker <[EMAIL PROTECTED]> writes: > What's a good/fast way to find the index of the minimum element of a > sequence? (I'm fairly sure sorting the sequence is not the fastest > approach) Python 2.5 (untested): from operator import itemgetter minindex = min(enumerate(seq), key=itemgett

Re: problem with 'global'

2008-01-21 Thread Duncan Booth
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 21 Jan 2008 17:08:46 -0200, Gabriel Genellina wrote: > >> The future statement is another example, even worse: >> >> if 0: >> from __future__ import with_statement >> >> with open("xxx") as f: >> print f > > In Python >=2.

Re: Bug in __init__?

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 05:59:38 -0200, <[EMAIL PROTECTED]> escribi�: > Is there no way of adding a possible warning message (that obviously > could be turned off) to warn users of possible problems linked to > using mutable types as parameters? > > Seems to me this could save users a few minutes/hour

Re: Default attribute values pattern

2008-01-21 Thread George Sakkis
On Jan 19, 6:02 pm, "David Tweet" <[EMAIL PROTECTED]> wrote: > Hello, > > Seems to me that setattrs sort of assumes that you want to have all your > initialization arguments set as attributes of the same name. I would think > you'd sometimes want to be able to process the extra arguments inside of

Re: problem with 'global'

2008-01-21 Thread Marc 'BlackJack' Rintsch
On Mon, 21 Jan 2008 17:08:46 -0200, Gabriel Genellina wrote: > The future statement is another example, even worse: > > if 0: > from __future__ import with_statement > > with open("xxx") as f: > print f In Python >=2.5 it's a compile time error if that import is not the very first sta

Re: is it possible to set namespace to an object.

2008-01-21 Thread George Sakkis
On Jan 21, 1:56 pm, glomde <[EMAIL PROTECTED]> wrote: > On 21 Jan, 18:59, Wildemar Wildenburger > > > > <[EMAIL PROTECTED]> wrote: > > glomde wrote: > > > Hi, > > > > is it somehow possible to set the current namespace so that is in an > > > object. > > > [snip] > > > set namespace testObj > > > Na

Re: How to solve "TypeError: list indices must be integers".

2008-01-21 Thread John Machin
On Jan 22, 3:15 am, "" <[EMAIL PROTECTED]> wrote: > This is more details about my problem, which I running my py script > for my project. Programming in pythoncard that we can develop a GUI > based application easily. > > I was assigned dialog.colorDialog(self) return value to a result > object

Re: problem with 'global'

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 11:44:54 -0200, Mel <[EMAIL PROTECTED]> escribi�: > Duncan Booth wrote: >> >> The first sentence (which hasn't changed since 2.4) describing the >> global >> statement seems clear enough to me: "The global statement is a >> declaration >> which holds for the entire current

Re: is it possible to set namespace to an object.

2008-01-21 Thread glomde
On 21 Jan, 18:59, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > glomde wrote: > > Hi, > > > is it somehow possible to set the current namespace so that is in an > > object. > > [snip] > > set namespace testObj > > Name = "Test" > > > Name would set testObj.Name to "Test". > > > [snip] > > > Is

Re: index of min element of sequence

2008-01-21 Thread Peter Otten
Neal Becker wrote: > What's a good/fast way to find the index of the minimum element of a > sequence? (I'm fairly sure sorting the sequence is not the fastest > approach) >>> items = "defbhkamnz" >>> min(xrange(len(items)), key=items.__getitem__) 6 >>> items[6] 'a' Peter -- http://mail.python.

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Gabriel Genellina
En Mon, 21 Jan 2008 14:12:43 -0200, Arne <[EMAIL PROTECTED]> escribi�: > I try to make a rss-reader in python just for fun, and I'm almost > finished. I don't have any syntax-errors, but when i run my program, > nothing happends. > > This program is supposed to download a .xml-file, save the conte

index of min element of sequence

2008-01-21 Thread Neal Becker
What's a good/fast way to find the index of the minimum element of a sequence? (I'm fairly sure sorting the sequence is not the fastest approach) -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : > On Mon, 21 Jan 2008 08:12:43 -0800 (PST), Arne <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> The problem is that i cant find the data in the database! If i watch >> my program while im running it, i can see that it sucsessfuly >> downloads th

Re: Default attribute values pattern

2008-01-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : >> Grab(argdict, key, default) is argdict.pop(key, default) > > "pop() raises a KeyError when no default value is given and the key is > not found." Then use it with a default value !-) >> def grab(kw, key, default=None): >>try: >> return kw.pop(key) >>ex

Re: Trouble writing to database: RSS-reader

2008-01-21 Thread Bruno Desthuilliers
Arne a écrit : > Hi! > > I try to make a rss-reader in python just for fun, and I'm almost > finished. Bad news : you're not. > I don't have any syntax-errors, but when i run my program, > nothing happends. > > This program is supposed to download a .xml-file, save the contents in > a buffer-fi

Re: When is min(a, b) != min(b, a)?

2008-01-21 Thread Pete Forman
Grant Edwards <[EMAIL PROTECTED]> writes: > For applications I work on, it should be NaN. But I think the > result of comparing a Normal to a NaN is undefined, so the > above behavior is allowed by the IEEE spec. Comparison of two floating point datums results in exactly one of these being tr

Re: is it possible to set namespace to an object.

2008-01-21 Thread Wildemar Wildenburger
glomde wrote: > Hi, > > is it somehow possible to set the current namespace so that is in an > object. > [snip] > set namespace testObj > Name = "Test" > > Name would set testObj.Name to "Test". > > [snip] > > Is the above possible? > Don't know, sorry. But let me ask you this: Why do you want

Berlin (Germany) Python User Group is meeting on 23.1.

2008-01-21 Thread Stephan Diehl
The Berlin Python User Group is meeting on the 23.1. at newthinking store at 7pm. All details can be found at http://wiki.python.de/User_Group_Berlin. The Berlin Python User Group is planning to meet every two month to talk about Python. Most talking will be done in german, but I can assure you th

Re: Is there a portable way to tell if data is available on a pipe?

2008-01-21 Thread Scott David Daniels
John Nagle wrote: >I need some way to find out if a pipe has data available for > a read without blocking if it does not. ... > I'd like to avoid having a thread to manage each pipe, but if I > have to, so be it. Well, without granting your wish, put a Queue.Queue "in front" of each pipe. Th

Re: Basic inheritance question

2008-01-21 Thread Lie
> > Please stop taking my words to its letters. > > So we're supposed to actually guess what you really mean ??? That's what human does, otherwise you'll "Fail the Turing Test". > >> Personally, I've seen many C++ programs with complex class designs > >> where it definitely helps to consistently

is it possible to set namespace to an object.

2008-01-21 Thread glomde
Hi, is it somehow possible to set the current namespace so that is in an object. Somthing like. class Test(): testObj = Test() set namespace testObj Name = "Test" Name would set testObj.Name to "Test". I was thinking this could be done with the with statement somehow (without using

ctypes CDLL - which paths are searched?

2008-01-21 Thread Helmut Jarausch
Hi, how can I specify the paths to be searched for a dynamic library to be loaded by ctypes' CDLL class on a Linux system. Do I have to set os.environment['LD_LIBRARY_PATH'] ? Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52

  1   2   >