Re: mysqldb duplicate entry error handling

2007-02-01 Thread John Nagle
Dennis Lee Bieber wrote: > On 1 Feb 2007 10:17:31 -0800, "baur79" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: >>IntegrityError: (1062, "Duplicate entry '[EMAIL PROTECTED]' for key 1") > > So show us the schema for the database... My take: Your database > ALREADY HAS a

Re: Python does not play well with others

2007-02-01 Thread John Nagle
Paul Rubin wrote: > Ben Finney <[EMAIL PROTECTED]> writes: > >>>Python still isn't ready for prime time in the web hosting world. >> >>That doesn't follow. It's just as valid to say that the web hosting >>providers (that you've interacted with so far) aren't ready to support >>the Python functiona

Re: win32com.client

2007-02-01 Thread Tim Roberts
"vithi" <[EMAIL PROTECTED]> wrote: >Hi, >I use python for window. If you are saying win32com in part of the >python then you are wrong. Look, you aren't paying attention. No one has said win32com is part of Python. What everyone has said is that win32com is part of the "Python for Windows extens

Re: Overloading the tilde operator?

2007-02-01 Thread Ben Finney
James Stroud <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > The Python runtime parser is designed to parse Python, not some > > arbitrary language that someone chooses to implement in Python. > > You haven't addressed why the limitation isn't arbitrary. Good thing I wasn't trying to do that,

Re: Overloading the tilde operator?

2007-02-01 Thread George Sakkis
On Feb 2, 12:49 am, James Stroud <[EMAIL PROTECTED]> wrote: > Ben Finney wrote: > > > The Python runtime parser is designed to parse Python, not some > > arbitrary language that someone chooses to implement in Python. > > You haven't addressed why the limitation isn't arbitrary. Indeed, and that'

Re: Overloading the tilde operator?

2007-02-01 Thread James Stroud
Ben Finney wrote: > James Stroud <[EMAIL PROTECTED]> writes: > > >>Peter Otten wrote: >> >>>Chris wrote: >>> I am trying to overload the __invert__ operator (~) such that it can take a second argument, >>> >>x ~ x >>> >>> File "", line 1 >>>x ~ x >>> ^ >>>SyntaxError: invali

Re: Python, readline and OS X

2007-02-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > James Stroud <[EMAIL PROTECTED]> wrote: > > > >>Is LD_LIBRARY_PATH pointing to the directory libreadline.dylib? > > > > > > It wasn't, but changing it so it did

Re: Overloading the tilde operator?

2007-02-01 Thread Ben Finney
James Stroud <[EMAIL PROTECTED]> writes: > Peter Otten wrote: > > Chris wrote: > >>I am trying to overload the __invert__ operator (~) such that it > >>can take a second argument, > > > x ~ x > > File "", line 1 > > x ~ x > > ^ > > SyntaxError: invalid syntax > > Seems an arbitrar

Spring Python 0.2.0 is released

2007-02-01 Thread gregturn
Spring Python is an offshoot of the Java-based SpringFramework and AcegiSecurityFramework, targeted for Python. Spring provides many useful features, and I wanted those same features available when working with Python. The site is http://springpython.python-hosting.com, with information about sour

Re: Overloading the tilde operator?

2007-02-01 Thread James Stroud
Peter Otten wrote: > Chris wrote: > > >>I am trying to overload the __invert__ operator (~) such that >>it can take a second argument, other than >>self, so that I can express: >> >>x ~ y >> >>by using: >> >>def __invert__(self, other): >> >>for example. Is this possible? > > > No, you will ge

Re: win32com.client

2007-02-01 Thread rzed
"vithi" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi, > I use python for window. If you are saying win32com in part of the > python then you are wrong. That is not what I or anyone else is saying. What we have said, perhaps not in words you understand, is this: 1) In your browser

Re: Python, readline and OS X

2007-02-01 Thread James Stroud
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > James Stroud <[EMAIL PROTECTED]> wrote: > >>Is LD_LIBRARY_PATH pointing to the directory libreadline.dylib? > > > It wasn't, but changing it so it did didn't fix the problem. (I didn't > try recompiling Python, just running it. I'll try r

Re: need help on a data structure problem

2007-02-01 Thread Ben Finney
"Dongsheng Ruan" <[EMAIL PROTECTED]> writes: > Not quite related with Python. But my Data Structure course is > experiemented on python and there is no data structure group, So I > have to post here: Better, you should discuss it in your class, with your teacher. -- \ "As we enjoy great ad

Re: python executing windows exe

2007-02-01 Thread Kiran
On Feb 1, 6:25 pm, "aspineux" <[EMAIL PROTECTED]> wrote: > First look if your .exe will accept to work that way ! > try in a DOS prompt > > > echo yourfilename | nec2d.exe > > or if the program expect more input, write them all in a file > ( myinputs.txt ) and try : > > > nec2d.exe < myinputs.txt >

Re: need help on a data structure problem

2007-02-01 Thread Tom Plunket
Dongsheng Ruan wrote: > Not quite related with Python. But my Data Structure course is experiemented > on python and there is no data structure group, So I have to post here: > > Write a procedure (in pseudocode!) to increase the number of buckets in a > (closed) hash table. Analyze its time an

Re: Python does not play well with others

2007-02-01 Thread Ben Finney
John Nagle <[EMAIL PROTECTED]> writes: > Python is the only major open source project I've encountered where > there's so much hostility to bug reports. Bear in mind that if you send a message only to this mailing list, that's not a bug report. That's a discussion, which may be worth having, but

Re: Python, readline and OS X

2007-02-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, James Stroud <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I have installed Python 2.5 on my new Intel Mac but I can't for the life > > of me get readline to work. I have libreadline installed, I've tried > > copying readline.so from my Python 2.3 installat

Re: Python, readline and OS X

2007-02-01 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Irmen de Jong <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I have installed Python 2.5 on my new Intel Mac but I can't for the life > > of me get readline to work. I have libreadline installed, I've tried > > copying readline.so from my Python 2.3 installa

need help on a data structure problem

2007-02-01 Thread Dongsheng Ruan
Not quite related with Python. But my Data Structure course is experiemented on python and there is no data structure group, So I have to post here: Write a procedure (in pseudocode!) to increase the number of buckets in a (closed) hash table. Analyze its time and space complexity. -- http:/

Re: Python does not play well with others

2007-02-01 Thread skip
John> From Aplus.net tech support: John> "No, db connectivity with Python is not supported. Modules for John> Python can't be installed by request on shared hosting." John> And these are companies that say they support Python. John> Python still isn't ready for prime time in

Re: Python does not play well with others

2007-02-01 Thread msoulier
On Jan 24, 2:59 pm, John Nagle <[EMAIL PROTECTED]> wrote: > Python is the only major open source project I've encountered where > there's so much hostility to bug reports. Try telling the Perl community that their debugger is broken. That didn't go well. ;-) Mike -- http://mail.python.org/m

Re: Python does not play well with others

2007-02-01 Thread msoulier
On Jan 23, 8:50 pm, John Nagle <[EMAIL PROTECTED]> wrote: >The major complaint I have about Python is that the packages > which connect it to other software components all seem to have > serious problems. As long as you don't need to talk to anything > outside the Python world, you're fine. A

Re: Python does not play well with others

2007-02-01 Thread Paul Rubin
Ben Finney <[EMAIL PROTECTED]> writes: > > Python still isn't ready for prime time in the web hosting world. > That doesn't follow. It's just as valid to say that the web hosting > providers (that you've interacted with so far) aren't ready to support > the Python functionality you want. I'd say t

Re: A* search implementation in Python

2007-02-01 Thread Steven D'Aprano
On Thu, 01 Feb 2007 18:21:57 -0800, bearophileHUGS wrote: > Reid Priedhorsky: >> I'm looking for an open-source Python implementation of A* search for use >> in a mapping application. > > You can try this one: > http://aima.cs.berkeley.edu/python/search.html To paraphrase a wise saying: If you

Re: Sorting a list

2007-02-01 Thread Steven D'Aprano
On Thu, 01 Feb 2007 14:52:03 -0500, John Salerno wrote: > Bruno Desthuilliers wrote: > >> You don't tell how these lines are formatted, but it's possible that you >> don't even need a regexp here. But wrt/ sorting, the list of tuples with >> the sort key as first element is one of the best solu

Re: "Correct" db adapter

2007-02-01 Thread Alejandro Dubrovsky
Bruno Desthuilliers wrote: > king kikapu a écrit : >> Thanks for the replies. >> >> I think i do not need something like ORM, but just a db-module that i >> can "work" the database with it. > > FWIW, SQLAlchemy is not an ORM, but an higher-level API for SQL > integration. The ORM part is an opti

Re: Overloading the tilde operator?

2007-02-01 Thread bearophileHUGS
Peter Otten: > No, you will get a syntax error before python even look up the names: There are some tricks that allow the use of "undefined" symbols in Python too, but they are probably just toys. I have recently posted a recipe in the cookbook for that. Bye, bearophile -- http://mail.python.or

Re: Calculating future dates

2007-02-01 Thread Ben Finney
"Toine" <[EMAIL PROTECTED]> writes: > On Feb 1, 4:54 pm, "Dan Bishop" <[EMAIL PROTECTED]> wrote: > > str(datetime.date.today() + datetime.timedelta(31)) > > Your example gave me a few errors but I was able to adapt it into > this: > > str(date.today() + timedelta(31)) That only works if you're im

Re: A* search implementation in Python

2007-02-01 Thread bearophileHUGS
Reid Priedhorsky: > I'm looking for an open-source Python implementation of A* search for use > in a mapping application. You can try this one: http://aima.cs.berkeley.edu/python/search.html Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me with this!!!

2007-02-01 Thread Steven D'Aprano
On Thu, 01 Feb 2007 08:53:55 -0800, Ravi Teja wrote: >> > > It search a text inside that hex value. >> > > It works perfecly on a txt file but if I open a binary file (.exe,.bin >> > > ecc...) with the same value it wont work, why? >> > > Please help! >> >> > Because the pattern isn't in the file,

Re: Python does not play well with others

2007-02-01 Thread Ben Finney
John Nagle <[EMAIL PROTECTED]> writes: > Just a followup. I'm still trying to get Python, MySQL, MySQLdb, > M2Crypto, and maybe mod_python to work on a shared hosting server. >From your description in the rest of the message, it seems that it's the *hosting providers* who are unable to do this,

OSS and ALSA

2007-02-01 Thread Silver Rock
Hi all, I've seen that python comes by default with a module for communication with OSS. I've looked for a ALSA module too (pyalsa) but it seems to handle only limited operations. Can anyone confirm or point wrong the impression that a newbie should use the ossaudiodev module? thanks, cl -- h

Re: win32com.client

2007-02-01 Thread Gabriel Genellina
En Thu, 01 Feb 2007 22:18:49 -0300, vithi <[EMAIL PROTECTED]> escribió: > If you are saying win32com in part of the python then you are wrong. Uh, what is so difficult to understand? vithi wrote: >> Any one tell me where I can get (or download) python modules win32com On Jan 31, 1:45 pm, Gary

A* search implementation in Python

2007-02-01 Thread Reid Priedhorsky
Hi folks, I'm looking for an open-source Python implementation of A* search for use in a mapping application. As the star is an operator in Google, I haven't figured out how to formulate a useful search. :/ Any help would be very much appreciated. Reid -- http://mail.python.org/mailman/listinf

script not opening applications

2007-02-01 Thread elrondrules
hi i have a html as follows: my hello.py is as follows import os os.system ("export DISPLAY=10.0.1.1:0.0") os.system ("./Test &") #Testtool opens a new window What I expected this to do was once I click "Run Test" it should run the hello.py script and open a new window for the Test ap

Re: coping directories

2007-02-01 Thread Gabriel Genellina
En Thu, 01 Feb 2007 21:33:03 -0300, Gigs_ <[EMAIL PROTECTED]> escribió: > class CVisitor(FileVisitor): > def __init__(self, fromdir, todir): > self.fromdirLen = len(fromdir) + 1# here is my problem > self.todir = todir > FileVisitor.__init__(self, fromdir) >

Re: win32com.client

2007-02-01 Thread vithi
Hi, I use python for window. If you are saying win32com in part of the python then you are wrong. Here is a prove:- IDLE 1.2 >>> import win32com Traceback (most recent call last): File "", line 1, in import win32com ImportError: No module named win32com >>> you try in your computer

Re: win32com.client

2007-02-01 Thread vithi
On Jan 31, 6:35 pm, rzed <[EMAIL PROTECTED]> wrote: > "vithi" <[EMAIL PROTECTED]> wrote innews:[EMAIL PROTECTED]: > > > Hi > > Any one tell me where I can get (or download) python modules > > win32com or win32com.client because I have to use "Dispatch" > > thanks > > What distribution are you using

Re: win32com.client

2007-02-01 Thread vithi
Hi, If you are saying win32com in part of the python then you are wrong. Here is a prove:- IDLE 1.2 >>> import win32com Traceback (most recent call last): File "", line 1, in import win32com ImportError: No module named win32com >>> you try in your computer On Jan 31, 7:17 pm, "Gabrie

Re: Calculating future dates

2007-02-01 Thread Toine
On Feb 1, 4:54 pm, "Dan Bishop" <[EMAIL PROTECTED]> wrote: > On Feb 1, 6:51 pm, "Toine" <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I'm new to Python so please bare with me... > > > I need to calculate a date that is exactly 31 days from the current > > date in -MM-DD format. I know that date

Re: Calculating future dates

2007-02-01 Thread Irmen de Jong
Toine wrote: > Hello, > > I'm new to Python so please bare with me... > > I need to calculate a date that is exactly 31 days from the current > date in -MM-DD format. I know that date.today() returns the > current date, but how can I add 31 days to this result? I'm sure this > task is simple,

Re: Calculating future dates

2007-02-01 Thread Dan Bishop
On Feb 1, 6:51 pm, "Toine" <[EMAIL PROTECTED]> wrote: > Hello, > > I'm new to Python so please bare with me... > > I need to calculate a date that is exactly 31 days from the current > date in -MM-DD format. I know that date.today() returns the > current date, but how can I add 31 days to this

Calculating future dates

2007-02-01 Thread Toine
Hello, I'm new to Python so please bare with me... I need to calculate a date that is exactly 31 days from the current date in -MM-DD format. I know that date.today() returns the current date, but how can I add 31 days to this result? I'm sure this task is simple, but I haven't been able to f

Re: Python, readline and OS X

2007-02-01 Thread Irmen de Jong
Ron Garret wrote: > I have installed Python 2.5 on my new Intel Mac but I can't for the life > of me get readline to work. I have libreadline installed, I've tried > copying readline.so from my Python 2.3 installation into 2.5, I've > searched the web, and no joy. Could someone please give me

Re: Python does not play well with others

2007-02-01 Thread John Nagle
Just a followup. I'm still trying to get Python, MySQL, MySQLdb, M2Crypto, and maybe mod_python to work on a shared hosting server. This is amazingly difficult, because of all the version incompatibility issues. Python, MySQL, MySQLdb, SWIG, OpenSSL, and gcc all have to have the right versions

coping directories

2007-02-01 Thread Gigs_
hi people I have problem with this example, not actually the problem, but [code] class FileVisitor(object): def __init__(self, data=None): self.context = data def run(self, startdir=os.curdir): os.path.walk(startdir, self.visitor, None) def visitor(self, data, dirn

Re: how to add class attributes in __new__

2007-02-01 Thread aspineux
On 1 fév, 17:50, "jeremito" <[EMAIL PROTECTED]> wrote: > I am subclassing the array class and have __new__ to initialize and > create my class. In that class I create not only do I create an array > object, but I also create some other data in __new__ I want to have > access to outside of __new__.

Re: how to make a python windows service know it's own identity

2007-02-01 Thread Larry Bates
Chris Curvey wrote: > On Feb 1, 2:10 pm, Larry Bates <[EMAIL PROTECTED]> wrote: >> Chris Curvey wrote: >>> Hi all, >>> I have used the win32com libraries to set up a service called >>> MyService under Windows. So far, so good. Now I need to run multiple >>> copies of the service on the same machi

Re: python executing windows exe

2007-02-01 Thread aspineux
First look if your .exe will accept to work that way ! try in a DOS prompt > echo yourfilename | nec2d.exe or if the program expect more input, write them all in a file ( myinputs.txt ) and try : > nec2d.exe < myinputs.txt If it works looks for module subprocess and more precisely object subpro

Re: Odd import behavior

2007-02-01 Thread Gabriel Genellina
En Thu, 01 Feb 2007 19:33:50 -0300, Gregory Piñero <[EMAIL PROTECTED]> escribió: > I didn't realize Python behaved like this. Is there an FAQ I can read > on this? > > FILE module1.py: > VAR1='HI' > > FILE MAIN.py: > from module1 import * > import module1 > > print VAR1 > print module1.VAR1 >

Re: Python, readline and OS X

2007-02-01 Thread James Stroud
Ron Garret wrote: > I have installed Python 2.5 on my new Intel Mac but I can't for the life > of me get readline to work. I have libreadline installed, I've tried > copying readline.so from my Python 2.3 installation into 2.5, I've > searched the web, and no joy. Could someone please give me

Re: python executing windows exe

2007-02-01 Thread Gabriel Genellina
En Thu, 01 Feb 2007 19:57:59 -0300, Kiran <[EMAIL PROTECTED]> escribió: > I am making python run an executable using the os module. Here is > my question. The executable, once it is running, asks the user to > input a filename that it will process. Now, my question is how do i > automate this

Re: python executing windows exe

2007-02-01 Thread Larry Bates
Kiran wrote: > Hi everybody, > I am making python run an executable using the os module. Here is > my question. The executable, once it is running, asks the user to > input a filename that it will process. Now, my question is how do i > automate this. let me make this clear, it is not an argu

Re: Ubunu - Linux - Unicode - encoding

2007-02-01 Thread Alan Franzoni
Il Thu, 01 Feb 2007 20:57:53 +0100, Franz Steinhäusler ha scritto: > If I copy files with german umlauts (äöü and strong 's' ß), these > filenames are not copied properly, and that characters are replaces > by little square symbols. Yes... I, myself, am italian, and I found no problem in using ac

Re: LDAP/LDIF Parsing

2007-02-01 Thread aspineux
The tree hierarchy is defined by the DN of each object, the types of the object is specified by its objectClass. Just collect all items (or do it dynamically by tunning the scope and the base of your search request) On 1 fév, 18:22, "Cruelemort" <[EMAIL PROTECTED]> wrote: > All, > > I am hoping

python executing windows exe

2007-02-01 Thread Kiran
Hi everybody, I am making python run an executable using the os module. Here is my question. The executable, once it is running, asks the user to input a filename that it will process. Now, my question is how do i automate this. let me make this clear, it is not an argument you pass in when y

imaplib: support for more cyrus extension : expire

2007-02-01 Thread aspineux
setacl and getacl look to be already "Cyrus" specific (according the doc), why not to extend imaplib a little bit more ? Here are some code I wrote and tested to support cyrus "expire" that manage how long a message can stay into a mailbox. This is usefull for NEWS server ! The code is preceded b

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Matt Waite
Thanks everyone for your help. I got Skip's answer to work (mine is pasted below): import sys import csv last = {} reader = csv.DictReader(open("/home/mwaite/test/test2.csv", "rb")) writer = csv.DictWriter(open("/home/mwaite/test/test3.csv", "wb"), ['ZONE','CITY','EVENT'], dialect='excel') for ro

Odd import behavior

2007-02-01 Thread Gregory Piñero
I didn't realize Python behaved like this. Is there an FAQ I can read on this? FILE module1.py: VAR1='HI' FILE MAIN.py: from module1 import * import module1 print VAR1 print module1.VAR1 VAR1='bye' print VAR1 print module1.VAR1 And the results are: >>> HI HI bye HI It seems to use module1.V

Setting IP TOS fields

2007-02-01 Thread Tulpule Naren-MGI2846
Hi, I don't see the ToS field that I set, in the generated IP packets captured via Ethereal/WireShark. What step am I missing in the code below? s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind((sIntf, sPort)) tos = 64 # I also tried tos = struct.pack("B", 64) s.setsockopt(socket.SOL

imaplib : error reporting use 'randomly' exception or return value

2007-02-01 Thread aspineux
imaplib use exception to report errors, but some problems must be detected by checking the return value ! For example, when trying to append into a mailbox with wrong ACL, imaplib return 'NO', but dont raise any exception (I give a sample at the end). This make error handling more complicate, beca

Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan, Take a look at http://www.xml.com/pub/a/2003/03/12/py-xml.html. It's a starting point to output XML data via use of SAX. Bruno also mentioned Genshi. I haven't used Genshi myself, but it'd be worth it to take a look at what it has to offer. - Jonathan -- http://mail.python.org/mai

Re: LDAP/LDIF Parsing

2007-02-01 Thread Bruno Desthuilliers
Cruelemort a écrit : > All, > > I am hoping someone would be able to help me with a problem. I have an > LDAP server running on a linux box, this LDAP server contains a > telephone list in various groupings, the ldif file of which is - > (snip) > > I am creating a python client program that will

Re: pil, histogram, mask

2007-02-01 Thread Daniel Nogradi
> > I don't need the histogram really, only the mean color > > value, but as far as I can see the 'mean' attribute only applies to an > > image and a mask can not be specified. > > You can slice parts of the image, and then use the > ImageStat.Stat(im).mean > On it. > > Bye, > bearophile Okay, I'l

Re: Sorting a list

2007-02-01 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Ah, so simply using sort() [on a list of tuples] will default to the > first element of each tuple? More precisely, list.sort will ask the elements of the list to compare themselves. Those elements are tuples; two tuples will compare based on comparison

Re: OT: Variant name spellings (Re: how to "free" an object/var ?)

2007-02-01 Thread Ben Finney
greg <[EMAIL PROTECTED]> writes: > Or Mr. Luxury-Yacht, which as we all know is pronounced > Throatwarbler-Mangrove. With a silent hyphen. You're a very silly person and I'm not going to interview you anymore. -- \ "When I turned two I was really anxious, because I'd doubled my | `\ ag

Python, readline and OS X

2007-02-01 Thread Ron Garret
I have installed Python 2.5 on my new Intel Mac but I can't for the life of me get readline to work. I have libreadline installed, I've tried copying readline.so from my Python 2.3 installation into 2.5, I've searched the web, and no joy. Could someone please give me a clue? rg -- http://mai

Re: division by 7 efficiently ???

2007-02-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Krypto wrote: > The correct answer as told to me by a person is > > (N>>3) + ((N-7*(N>>3))>>3) How could it be correct if it uses `-`? You ruled out `-` and `/` in your first post. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python

Re: Sorting a list

2007-02-01 Thread Bruno Desthuilliers
John Salerno a écrit : (snip) > Oh I didn't sort then reverse, I just replaced sort with reverse. Maybe > that's why! Hmmm... Probably, yes... !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about a single underscore.

2007-02-01 Thread Bruno Desthuilliers
Steven W. Orr a écrit : > On Thursday, Feb 1st 2007 at 21:45 +0100, quoth Bruno Desthuilliers: > (snip) > =>irrational_const = const.__class__() > =>even_const = const.__class__() > => > =>Now while I find this hack interesting, it's also totally unpythonic > =>IMHO. The usual convention is to u

Re: Sorting a list

2007-02-01 Thread John Salerno
Bruno Desthuilliers wrote: >> One more thing. What if I want them in reverse chronological order? I >> tried reverse() but that seemed to put them in reverse alphabetical >> order based on the second element of the tuple (not the year). > > Really ? > > >>> lines = [('1995', 'aaa'), ('1997',

Re: Recursive zipping of Directories in Windows

2007-02-01 Thread Larry Bates
Jandre wrote: > Hi > > I am a python novice and I am trying to write a python script (most of > the code is borrowed) to Zip a directory containing some other > directories and files. The script zips all the files fine but when it > tries to zip one of the directories it fails with the following >

Re: Sorting a list

2007-02-01 Thread Bruno Desthuilliers
Steven Bethard a écrit : > Bruno Desthuilliers wrote: > >> If you want to prevent this from happening and don't mind creating a >> copy of the list, you can use the sorted() function with the key and >> reverse arguments and operator.itemgetter: >> (snip) > > You don't need to use sorted() -- s

Re: xml.dom.minidom memory usage

2007-02-01 Thread Bruno Desthuilliers
Dan a écrit : > I'm using python's xml.dom.minidom module to generate xml files, and > I'm running into memory problems. The xml files I'm trying to create > are relatively flat, with one root node which may have millions of > direct child nodes. Woops ! You're looking for trouble. > > So, my qu

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Bruno Desthuilliers
Matt Waite a écrit : > My first post, my first real python use, please be gentle: > > I have a CSV file, exported from Excel, that has blank records in it, > and I need to fill them in with the values from the record just above > it until it hits a non-blank value. Here's an example of the data, >

Re: Sorting a list

2007-02-01 Thread Steven Bethard
Bruno Desthuilliers wrote: > If you want to prevent this from happening and don't mind creating a > copy of the list, you can use the sorted() function with the key and > reverse arguments and operator.itemgetter: > > >>> lines = [('1995', 'aaa'), ('1997', 'bbb'), ('1995', 'bbb'), > ('1997', '

Re: Question about a single underscore.

2007-02-01 Thread Steven W. Orr
On Thursday, Feb 1st 2007 at 21:45 +0100, quoth Bruno Desthuilliers: =>Steven W. Orr a écrit : =>> I saw this and tried to use it: =>> =>> --><8--- const.py- =>> class _const: =>> class ConstError(TypeError): pass =>> def __setattr__(self,name,v

RE: division by 7 efficiently ???

2007-02-01 Thread skip
Michael> I think it is off by 1 in small numbers, off by a little more Michael> with large numbers: ... Sorta makes you think using the DIV instruction in the CPU is the way to go. ;-) Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting a list

2007-02-01 Thread Bruno Desthuilliers
John Salerno a écrit : > John Salerno wrote: > >> Bruno Desthuilliers wrote: >> >>> John Salerno a écrit : >>> Hi everyone. If I have a list of tuples, and each tuple is in the form: (year, text) as in ('1995', 'This is a citation.') How can I sort the list so that they ar

RE: division by 7 efficiently ???

2007-02-01 Thread Michael Yanowitz
I think it is off by 1 in small numbers, off by a little more with large numbers: >>> def div7 (N): ...return (N>>3) + ((N-7*(N>>3))>>3) ... >>> div7 (70) 9 >>> div7 (77) 10 >>> div7 (700) 98 >>> div7 (7) 0 >>> div7 (10) 1 >>> div7 (14) 1 >>> div7 (21) 2 >>> div7 (700) 98 >>> div7 (7000) 984

Re: division by 7 efficiently ???

2007-02-01 Thread Paul Rubin
"Krypto" <[EMAIL PROTECTED]> writes: > The correct answer as told to me by a person is > > (N>>3) + ((N-7*(N>>3))>>3) > > > The above term always gives division by 7 Well, not exactly: [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2 Type "help", "copyright", "credits" or "license

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Laszlo Nagy
> import csv > citynew='' > reader = csv.DictReader(open("/home/mwaite/test/test2.csv", "rb")) > for row in reader: > row['CITY'] == citynew > else: > citynew=row['CITY'] > > The logic here -- in this case trying to fill in the city information > -- would seem to work, but I'm not sure. An

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread skip
Matt> I have a CSV file, exported from Excel, that has blank records in Matt> it, and I need to fill them in with the values from the record Matt> just above it until it hits a non-blank value. Try something like: #!/usr/bin/env python import sys import csv last = {

Re: Sorting a list

2007-02-01 Thread Bruno Desthuilliers
John Salerno a écrit : > Bruno Desthuilliers wrote: > >> John Salerno a écrit : >> >>> Hi everyone. If I have a list of tuples, and each tuple is in the form: >>> >>> (year, text) as in ('1995', 'This is a citation.') >>> >>> How can I sort the list so that they are in chronological order based >

Re: Sorting a list

2007-02-01 Thread Bruno Desthuilliers
John Salerno a écrit : > Bruno Desthuilliers wrote: > >> You don't tell how these lines are formatted, but it's possible that >> you don't even need a regexp here. But wrt/ sorting, the list of >> tuples with the sort key as first element is one of the best solutions. > > > Ah, so simply using

Re: xml.dom.minidom memory usage

2007-02-01 Thread Dan
On Feb 1, 3:12 pm, Jonathan Curran <[EMAIL PROTECTED]> wrote: > Dan, > The DOM (Document Object Model) is such that it loads all the > elements of the > XML document into memory before you can do anything with it. With your file > containing millions of child nodes this will eat up as much

Re: division by 7 efficiently ???

2007-02-01 Thread Krypto
The correct answer as told to me by a person is (N>>3) + ((N-7*(N>>3))>>3) The above term always gives division by 7 -- http://mail.python.org/mailman/listinfo/python-list

Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan, I jumped the gun and didn't read your entire post. I ended up skipping a lot of parts, especially where you say that you are creating a document (for some reason I thought you were reading it). I looked at the setAttribute function and thought: ah he's writing it out. Sorry

Re: Quad Perspective Transformation

2007-02-01 Thread Gabriel Genellina
En Thu, 01 Feb 2007 13:46:37 -0300, Kamilche <[EMAIL PROTECTED]> escribió: > I have a need to tile a bitmap across an arbitrary quadrilateral, and > apply perspective to it. > The Python Imaging Library (PIL) has an undocumented function that > might work, but I can't figure out how to make it w

Re: Question about a single underscore.

2007-02-01 Thread Bruno Desthuilliers
Steven W. Orr a écrit : > I saw this and tried to use it: > > --><8--- const.py- > class _const: > class ConstError(TypeError): pass > def __setattr__(self,name,value): > if self.__dict__.has_key(name): > raise self.ConstError

Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan, The DOM (Document Object Model) is such that it loads all the elements of the XML document into memory before you can do anything with it. With your file containing millions of child nodes this will eat up as much memory as you have. A solution to this is to use the SAX method of p

Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Matt Waite
My first post, my first real python use, please be gentle: I have a CSV file, exported from Excel, that has blank records in it, and I need to fill them in with the values from the record just above it until it hits a non-blank value. Here's an example of the data, which is in a file called test2.

Recursive zipping of Directories in Windows

2007-02-01 Thread Jandre
Hi I am a python novice and I am trying to write a python script (most of the code is borrowed) to Zip a directory containing some other directories and files. The script zips all the files fine but when it tries to zip one of the directories it fails with the following error: "IOError: [Errno 13]

Re: Ubunu - Linux - Unicode - encoding

2007-02-01 Thread Franz Steinh�usler
On 1 Feb 2007 08:24:07 -0800, "Paul Boddie" <[EMAIL PROTECTED]> wrote: >On 1 Feb, 16:02, Franz Steinhaeusler <[EMAIL PROTECTED]> >wrote: >> >> The case: >> I have a file on a WindowsXP partition which has as contents german >> umlauts and the filename itself has umlauts like iÜüäßk.txt >> >> I

Re: Inconsistent list/pointer problem

2007-02-01 Thread Gabriel Genellina
En Thu, 01 Feb 2007 10:23:16 -0300, Doug Stell <[EMAIL PROTECTED]> escribió: > I am having a problem with the corruption of a list. It occurs only > the first time that I call a function and never happens on subsequent > calls. Any suggestions would be appreciated. > > I call the function, passi

RE: Sorting a list

2007-02-01 Thread Carroll, Barry
> -Original Message- > From: John Salerno [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 01, 2007 11:54 AM > To: python-list@python.org > Subject: Re: Sorting a list > > Bruno Desthuilliers wrote: > > John Salerno a écrit : > >> Hi everyone. If I have a list of tuples, and each tuple

Re: Question about a single underscore.

2007-02-01 Thread Bruno Desthuilliers
Paul Rubin a écrit : > "Steven W. Orr" <[EMAIL PROTECTED]> writes: > >>AttributeError: _const instance has no attribute '_const' >> >>What am I missing here? (Sorry if it should be obvious) > > > Oh I see. No it's not obvious. module "const" has gotten overwritten > by the _const instance. I

Re: Sorting a list

2007-02-01 Thread John Salerno
John Salerno wrote: > Bruno Desthuilliers wrote: >> John Salerno a écrit : >>> Hi everyone. If I have a list of tuples, and each tuple is in the form: >>> >>> (year, text) as in ('1995', 'This is a citation.') >>> >>> How can I sort the list so that they are in chronological order based >>> on the

Re: Ubunu - Linux - Unicode - encoding

2007-02-01 Thread Franz Steinh�usler
On Thu, 1 Feb 2007 16:42:02 +0100, Alan Franzoni <[EMAIL PROTECTED]> wrote: >Il Thu, 01 Feb 2007 16:02:52 +0100, Franz Steinhaeusler ha scritto: > >> The case: >> I have a file on a WindowsXP partition which has as contents german >> umlauts and the filename itself has umlauts like iÜüäßk.txt

Re: Sorting a list

2007-02-01 Thread John Salerno
John Salerno wrote: > Bruno Desthuilliers wrote: >> John Salerno a écrit : >>> Hi everyone. If I have a list of tuples, and each tuple is in the form: >>> >>> (year, text) as in ('1995', 'This is a citation.') >>> >>> How can I sort the list so that they are in chronological order based >>> on the

  1   2   3   >