file.read() doesn't read the whole file

2009-03-19 Thread Sreejith K
Hi, >>> snapdir = './mango.txt_snaps' >>> snap_cnt = 1 >>> block = 0 >>> import os >>> os.chdir('/mnt/gfs_local') >>> snap = open(snapdir + '/snap%s/%s' % (repr(snap_cnt), repr(block)),'r') >>> snap.read() 'dfdfdgagdfgdf\ngdgfadgagadg\nagafg\n\nfs\nf\nsadf\n\nsdfsdfsadf\n' >>> snapdir + '/snap%s/%

Re: Python + PostgreSQL

2009-03-19 Thread Martin v. Löwis
> I saw in a different post that psycopg2 does work on Python 3.x as > long as a patch is applied (by Martin v. Löwis): > [...] > Do you know where can I find this patch It's linked in http://wiki.python.org/moin/Early2to3Migrations and lives in http://www.dcl.hpi.uni-potsdam.de/home/loewis/ps

Re: Unicode problem in ucs4

2009-03-19 Thread Martin v. Löwis
> Any idea on why this is happening? Can you provide a complete example? Your code looks correct, and should just work. How do you know the result contains only 't' (i.e. how do you know it does not contain 'e', 's', 't')? Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads not Improving Performance in Program

2009-03-19 Thread Vijayendra Bapte
On Mar 20, 4:21 am, Tim Rowe wrote: > > Thank you for your response. I did not realize that. That seems like a > > huge limitation for such a great language. > > I will look into forking off processes instead of using threads. > > If that's what you need to do, yes it is. If it isn't, no it's not.

Re: improve this newbie code/nested functions in Python?

2009-03-19 Thread Terry Reedy
Esmail wrote: Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this code? Also, I am using two nested functions, it seems that nested functions aren't used that much in P

Re: Object System

2009-03-19 Thread Terry Reedy
John Mendelewski wrote: I was wondering if anyone had documents or articles what gave an in- depth view of the object system in Python. http://effbot.org/zone/python-objects.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: [python-list] Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-19 Thread CJ Kucera
CJ Kucera wrote: > Okay, I've got a reproducible testcase of this available up here: > http://apocalyptech.com/pygtk-zlib/ Hello, two brief notes here: 1) Someone on the PyGTK list mentioned that I should really be using StringIO instead of my own hacky attempt at one, in there, and of course he

multiprocessing and Tk GUI program (won't work under Linux)

2009-03-19 Thread akineko
Hello everyone, I have started using multiprocessing module, which is now available with Python 2.6. It definitely opens up new possibilities. Now, I developed a small GUI package, which is to be used from other programs. It uses multiprocessing and Pipes are used to pump image data/command to th

Re: Creating a python extension that works with multiprocessing.Queue

2009-03-19 Thread Gabriel Genellina
En Fri, 20 Mar 2009 00:16:29 -0200, Travis Miller escribió: So far the C Api is really cool. I can do all the math stuff where I need the speed, and still be able to use python which is way more expressive. Sure! One gets the best of both worlds that way. -- Gabriel Genellina -- http://m

Re: Object System

2009-03-19 Thread Michele Simionato
On Mar 19, 10:18 pm, John Mendelewski wrote: > I was wondering if anyone had documents or articles what gave an in- > depth view of the object system in Python. Ones concerning dispatch, > how self really works, and maybe some meta-programming that comes > along with the new style classes. The se

EasyGui now supports Python 3.0

2009-03-19 Thread Steve Ferg
Just a follow-up: I've just uploaded a version of Easygui that works with Python 2.x and 3.x. http://easygui.sourceforge.net/current_version/index.html I blog a bit about it at http://pythonconquerstheuniverse.blogspot.com/2009/03/moving-to-python-30-part3.html -- http://mail.python.org/mailman/l

Re: Can I rely on...

2009-03-19 Thread alex23
On Mar 20, 1:42 am, "Emanuele D'Arrigo" wrote: > I just had a bit of a shiver for something I'm doing often in my code > but that might be based on a wrong assumption on my part. Take the > following code: > > pattern = "aPattern" > > compiledPatterns = [ ] > compiledPatterns.append(re.compile(pat

improve this newbie code/nested functions in Python?

2009-03-19 Thread Esmail
Hi, I'm new to writing Python code. This is a simple client I wrote, it works, but I feel it doesn't look as clean as it could. Can anyone make suggestions how to streamline this code? Also, I am using two nested functions, it seems that nested functions aren't used that much in Python - is that

Re: Creating a python extension that works with multiprocessing.Queue

2009-03-19 Thread Travis Miller
I'm on linux actually. I found that so long as I implement __reduce__, then pickling works, and my extension works with Queue objects correctly. So far the C Api is really cool. I can do all the math stuff where I need the speed, and still be able to use python which is way more expressive. tra

Re: REDIRECT

2009-03-19 Thread gaeasiankom
On Mar 19, 11:39 am, I V wrote: > On Wed, 18 Mar 2009 21:30:59 -0700, gaeasiankom wrote: > > What actually I'm try to do is : > > > I'm having a Login page which developed in HTML. When I click on the > > "Login" button I want the page to validate (at datastore of google app) > > using python and

Concrete Factory Pattern syntax?

2009-03-19 Thread R. David Murray
Austin Schutz wrote: > > I have a fairly simple bit of code, something like: > > # This should be importing the subclasses somehow, so that the factory > # can make them. > # import Parser.One > # import Parser.Two > # or.. from Parser import *? > class Parser(): >def parse: > 'Impleme

Re: read web page that requires javascript on client

2009-03-19 Thread Greg
On Mar 18, 7:25 pm, Carl wrote: > On Mar 18, 1:56 pm, a...@pythoncraft.com (Aahz) wrote: > > > > > In article , > > R. David Murray wrote: > > > >That said, I've heard mention here of something that can apparently be > > >used for this.  I think it was some incarnation of Webkit.  I remember > >

Re: Concrete Factory Pattern syntax?

2009-03-19 Thread Benjamin Kaplan
On Thu, Mar 19, 2009 at 6:52 PM, Austin Schutz wrote: > > I have a fairly simple bit of code, something like: > > # This should be importing the subclasses somehow, so that the factory > # can make them. > # import Parser.One > # import Parser.Two > # or.. from Parser import *? > class Parser():

Re: Object System

2009-03-19 Thread Benjamin Peterson
John Mendelewski gmail.com> writes: > > What goes on behind the scenes to make a.do() evaluate the do > method with a bound to self in that method? Is this implemented > in C, Python? I think I have a grasp of how to use objects, but > I was wondering about the implementation I suppose. This is

Re: Need guidelines to show results of a process

2009-03-19 Thread MRAB
Vizcayno wrote: Hi: I wrote a Python program which, during execution, shows me messages on console indicating at every moment the time and steps being performed so I can have a 'log online' and guess remaining time for termination, I used many 'print' instructions to show those messages, i.e. pr

Re: Need guidelines to show results of a process

2009-03-19 Thread Mensanator
On Mar 19, 7:00 pm, Vizcayno wrote: > Hi: > I wrote a Python program which, during execution, shows me messages on > console indicating at every moment the time and steps being performed > so I can have a 'log online' and guess remaining time for termination, > I used many 'print' instructions to

Need guidelines to show results of a process

2009-03-19 Thread Vizcayno
Hi: I wrote a Python program which, during execution, shows me messages on console indicating at every moment the time and steps being performed so I can have a 'log online' and guess remaining time for termination, I used many 'print' instructions to show those messages, i.e. print "I am in step

Re: Object System

2009-03-19 Thread John Mendelewski
On Mar 19, 6:19 pm, Benjamin Peterson wrote: > John Mendelewski gmail.com> writes: > > > > > I was wondering if anyone had documents or articles what gave an in- > > depth view of the object system in Python. Ones concerning dispatch, > > how self really works, and maybe some meta-programming tha

Re: Threads not Improving Performance in Program

2009-03-19 Thread Tim Rowe
> Thank you for your response. I did not realize that. That seems like a > huge limitation for such a great language. > I will look into forking off processes instead of using threads. If that's what you need to do, yes it is. If it isn't, no it's not. No language is optimum for all possible appli

Re: Ordered Sets

2009-03-19 Thread Aahz
In article <9a5d59e1-2798-4864-a938-9b39792c5...@s9g2000prg.googlegroups.com>, Raymond Hettinger wrote: > >Here's a new, fun recipe for you guys: > >http://code.activestate.com/recipes/576694/ That is *sick* and perverted. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncr

Re: Neatest way to do a case insensitive "in"?

2009-03-19 Thread Jervis Whitley
> > I agree that it's an alternative. There are a number of alternatives. > However the OP was asking for a "neater/easier" alternative. I argue > that introducing an external module/function to do the exact same thing > as a built-in type's method doesn't exactly qualify as a "neater/easier" > alt

RE: Is python worth learning as a second language?

2009-03-19 Thread Delaney, Timothy (Tim)
Aahz wrote: > In article <49b58b35$0$3548$426a7...@news.free.fr>, > Bruno Desthuilliers wrote: >> Tomasz Rola a écrit : >>> >>> I may not be objective (tried Java, hated it after 6 years). >> >> Arf - only took me 6 months !-) > > That long? It only took me six minutes. I was young and fool

Concrete Factory Pattern syntax?

2009-03-19 Thread Austin Schutz
I have a fairly simple bit of code, something like: # This should be importing the subclasses somehow, so that the factory # can make them. # import Parser.One # import Parser.Two # or.. from Parser import *? class Parser(): def parse: 'Implemented only in subclass' def make_parser

Re: can someone help me (again) stuck on ' hands on python'

2009-03-19 Thread Rhodri James
On Thu, 19 Mar 2009 14:40:55 -, Gary Wood wrote: #i adjusted the main function helps me see the code as the program runs Put it back the way it was (you've broken it rather thoroughly there), and put the debug "print" calls in printLocations where they stand some chance of showing you wha

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Aahz
In article , Linuxguy123 wrote: > >I've got a small piece of code that I don't understand. Basically, a >variable inside an if statement inside a for loop doesn't seem to be >updating. Is this a scope issue ? Nope, it's a spelling issue. I suggest you change your code to a more readable: new

Re: Threads not Improving Performance in Program

2009-03-19 Thread Ryan Rosario
On Mar 19, 10:35 am, Jean-Paul Calderone wrote: > On Thu, 19 Mar 2009 09:50:51 -0700, Ryan Rosario > wrote: > >I have a parser that needs to process 7 million files. After running > >for 2 days, it had only processed 1.5 million. I want this script to > >parse several files at once by using mult

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Benjamin Peterson
Linuxguy123 gmail.com> writes: > > > Hi people. > > I've got a small piece of code that I don't understand. Basically, a > variable inside an if statement inside a for loop doesn't seem to be > updating. Is this a scope issue ? No, it's because you mispelled the variables. -- http://ma

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Ryan Kelly
> newCylinderTempertature = newCylinderTemperature + deltaTemp Take a careful look at the variable name here: "Tempertature". Python's dynamic nature provides a lot of wonderful benefits, but you've just hit one of the drawbacks - you don't get any protection from typos in variable names.

Re: Lambda forms and scoping

2009-03-19 Thread Benjamin Peterson
Márcio Faustino gmail.com> writes: > > Hi, > > Executing the example below doesn't produce the expected behavior, but > using the commented code does. Is this normal, or is it a problem with > Python? I've tested it with version 2.6.1 on Windows XP. > > Thanks, > > -- > > from abc import * >

Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Linuxguy123
Hi people. I've got a small piece of code that I don't understand. Basically, a variable inside an if statement inside a for loop doesn't seem to be updating. Is this a scope issue ? Thanks Code segment: # run through the cycle and calculate the temperature and pressure at each position,

Re: Object System

2009-03-19 Thread Benjamin Peterson
John Mendelewski gmail.com> writes: > > I was wondering if anyone had documents or articles what gave an in- > depth view of the object system in Python. Ones concerning dispatch, > how self really works, and maybe some meta-programming that comes > along with the new style classes. What do you

Re: Neatest way to do a case insensitive "in"?

2009-03-19 Thread Albert Hopkins
On Fri, 2009-03-20 at 08:52 +1100, Jervis Whitley wrote: > On Fri, Mar 20, 2009 at 8:28 AM, Albert Hopkins > wrote: > > On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote: > >> > > >> >if stringA.lower() in stringB.lower(): > >> >bla bla bla > >> > > >> > >> from string impor

Is there any library for COREL or ILLUSTRATOR?

2009-03-19 Thread alejandro
I need to import cdr files to python and just make some calculations (surface size of some objects, perimeters..) Don't need to show them or manipulate with them... -- http://mail.python.org/mailman/listinfo/python-list

Lambda forms and scoping

2009-03-19 Thread Márcio Faustino
Hi, Executing the example below doesn't produce the expected behavior, but using the commented code does. Is this normal, or is it a problem with Python? I've tested it with version 2.6.1 on Windows XP. Thanks, -- from abc import * from types import * import re class Base (ObjectType): __m

Re: Neatest way to do a case insensitive "in"?

2009-03-19 Thread Jervis Whitley
On Fri, Mar 20, 2009 at 8:28 AM, Albert Hopkins wrote: > On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote: >> > >> >    if stringA.lower() in stringB.lower(): >> >        bla bla bla >> > >> >>     from string import lower >> >>     if lower(stringA) in lower(stringB): >>          # was thi

Ordered Sets

2009-03-19 Thread Raymond Hettinger
Here's a new, fun recipe for you guys: http://code.activestate.com/recipes/576694/ Enjoy, Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Neatest way to do a case insensitive "in"?

2009-03-19 Thread Albert Hopkins
On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote: > > > >if stringA.lower() in stringB.lower(): > >bla bla bla > > > > from string import lower > > if lower(stringA) in lower(stringB): > # was this what you were after? > This is analogous to standing behind a

Object System

2009-03-19 Thread John Mendelewski
I was wondering if anyone had documents or articles what gave an in- depth view of the object system in Python. Ones concerning dispatch, how self really works, and maybe some meta-programming that comes along with the new style classes. -- http://mail.python.org/mailman/listinfo/python-list

Re: cross compile Python to Linux-ARM

2009-03-19 Thread Paul McGuire
On Mar 19, 11:54 am, jefm wrote: > Hi, > We are looking to use Python on an embedded Linux ARM system. > What I gather from googling the subject is that it is not that > straight forward (a fair amount of patching & hacking). > Nobody out there that has done it claims it is easy, which makes me >

Re: How complex is complex?

2009-03-19 Thread Daniel Fetchinson
>> > I understand that my question was foolish, even for a newbie. >> > I will not ask any more such questions in the future. >> >> Gaaah! Your question was just fine, a good question on coding style. >> I wish more people would ask such questions so that bad habits could >> be avoided. >> >> The n

Re: cross compile Python to Linux-ARM

2009-03-19 Thread Nick Craig-Wood
jefm wrote: > We are looking to use Python on an embedded Linux ARM system. > What I gather from googling the subject is that it is not that > straight forward (a fair amount of patching & hacking). > Nobody out there that has done it claims it is easy, which makes me > worried. > > I haven

Re: Neatest way to do a case insensitive "in"?

2009-03-19 Thread Jervis Whitley
> >    if stringA.lower() in stringB.lower(): >        bla bla bla > from string import lower if lower(stringA) in lower(stringB): # was this what you were after? Cheers, Jervis -- http://mail.python.org/mailman/listinfo/python-list

Re: Concurrent tasklets in Stackless Python

2009-03-19 Thread Aahz
[posted and e-mailed] In article , Minesh Patel wrote: > >Can you suggest any Python libraries for true parallelism or should I >just stick with Python Threads or asyncore Python threads are mostly only parallel for I/O (you have to write special C code to release the GIL). If you want paralle

Re: How complex is complex?

2009-03-19 Thread pruebauno
On Mar 19, 1:25 pm, Paul Hildebrandt wrote: > On Mar 19, 9:41 am, Kottiyath wrote: > > > > > On Mar 19, 9:33 pm, Kottiyath wrote: > > > > On Mar 19, 8:42 pm, Paul McGuire wrote: > > > > > On Mar 19, 4:39 am, Kottiyath wrote: > > > > > > I understand that my question was foolish, even for a new

Re: Neatest way to do a case insensitive "in"?

2009-03-19 Thread Steve Holden
aiwarrior wrote: > On Mar 13, 9:31 pm, Albert Hopkins wrote: >> On Fri, 2009-03-13 at 21:04 +, tinn...@isbd.co.uk wrote: >>> What's the neatest way to do the following in case insensitive fashion:- >>> if stringA in stringB: >>> bla bla bla >>> I know I can just do:- >>> if str

Re: DictReader and fieldnames

2009-03-19 Thread skip
Ted> Thanks. Is there any way to make this work before actually reading Ted> in a row of data? In version 2.5, I need to first do a rdr.next() Ted> before rdr.fieldnames gives me anything. If you know the csv file contains column headers this should work: f = open("f.csv", "rb"

Re: Heuristically processing documents

2009-03-19 Thread MRAB
BJörn Lindqvist wrote: I have a large set of documents in various text formats. I know that each document contains its authors name, email and phone number. Sometimes it also contains the authors home address. The task is to find out the name, email and phone of as many documents as possible. Si

Re: Can I rely on...

2009-03-19 Thread R. David Murray
"Emanuele D'Arrigo" wrote: > Thank you everybody for the informative replies. > > I'll have to comb my code for all the instances of "item in sequence" > statement because I suspect some of them are as unsafe as my first > example. Oh well. One more lesson learned. You may have far fewer unsafe

Re: What happened to NASA at Python? :(

2009-03-19 Thread Steve Holden
Dotan Cohen wrote: >> There are about 40 people supporting the Mars Lander mission using >> Python and aiming for a launch window this September. Wish them luck! >> > > What, exactly, are they using Python for? > Mostly for testing, I understand, but during their training I was the Python guy amo

Heuristically processing documents

2009-03-19 Thread BJörn Lindqvist
I have a large set of documents in various text formats. I know that each document contains its authors name, email and phone number. Sometimes it also contains the authors home address. The task is to find out the name, email and phone of as many documents as possible. Since the documents are not

Re: REDIRECT

2009-03-19 Thread I V
On Wed, 18 Mar 2009 21:30:59 -0700, gaeasiankom wrote: > What actually I'm try to do is : > > I'm having a Login page which developed in HTML. When I click on the > "Login" button I want the page to validate (at datastore of google app) > using python and redirect to other HTML page. As what I un

Re: converting pipe delimited file to fixed width

2009-03-19 Thread MRAB
John Posner wrote: [snip] field_widths = [14, 6, 18, 21, 21, 4, 6] out = open("/home/chatdi/ouptut.csv", 'w') for line in open("/home/chatdi/input.csv", "r"): fields = line.rstrip().split('|') padded_fields = [field.ljust(width) for field, width in zip(fields, field_widths)] out.

Re: Parallel processing on shared data structures

2009-03-19 Thread MRAB
psaff...@googlemail.com wrote: I'm filing 160 million data points into a set of bins based on their position. At the moment, this takes just over an hour using interval trees. I would like to parallelise this to take advantage of my quad core machine. I have some experience of Parallel Python, bu

Re: Missing values in tuple assignment

2009-03-19 Thread Terry Reedy
Jim Garrison wrote: Use case: parsing a simple config file line where lines start with a keyword and have optional arguments. I want to extract the keyword and then pass the rest of the line to a function to process it. An obvious use of split(None,1) cmd,args= = line.split(None,1); if

Re: cross compile Python to Linux-ARM

2009-03-19 Thread Tino Wildenhain
jefm wrote: Hi, We are looking to use Python on an embedded Linux ARM system. What I gather from googling the subject is that it is not that straight forward (a fair amount of patching & hacking). Nobody out there that has done it claims it is easy, which makes me worried. Yes unfortunately its

Re: converting pipe delimited file to fixed width

2009-03-19 Thread John Posner
[snip] > field_widths = [14, 6, 18, 21, 21, 4, 6] > > out = open("/home/chatdi/ouptut.csv", 'w') > for line in open("/home/chatdi/input.csv", "r"): > fields = line.rstrip().split('|') > padded_fields = [field.ljust(width) for field, width in zip(fields, > field_widths)] > out.write

Parallel processing on shared data structures

2009-03-19 Thread psaff...@googlemail.com
I'm filing 160 million data points into a set of bins based on their position. At the moment, this takes just over an hour using interval trees. I would like to parallelise this to take advantage of my quad core machine. I have some experience of Parallel Python, but PP seems to only really work fo

Re: converting pipe delimited file to fixed width

2009-03-19 Thread Tim Chase
Caveat: none of the solutions (including mine) deal with the case of the field being longer than the width. You might want to throw an exception. Alternatively, you can just crop the results. Tweaking MRAB's elegant solution: field_widths = [14, 6, 18, 21, 21, 4, 6] infile = open("input.

Re: Missing values in tuple assignment

2009-03-19 Thread MRAB
Albert Hopkins wrote: On Thu, 2009-03-19 at 11:57 -0500, Jim Garrison wrote: Use case: parsing a simple config file line where lines start with a keyword and have optional arguments. I want to extract the keyword and then pass the rest of the line to a function to process it. An obvious use of

Re: What happened to NASA at Python? :(

2009-03-19 Thread Dotan Cohen
> Could you perhaps be persuaded to post in ASCII? Sorry, Aahz, Gmail sends the mail as base64 encoded if there are non-ascii characters. This is the first problem that I've encountered with this, what mailer are you using? -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- http:/

Re: Threads not Improving Performance in Program

2009-03-19 Thread Jean-Paul Calderone
On Thu, 19 Mar 2009 09:50:51 -0700, Ryan Rosario wrote: I have a parser that needs to process 7 million files. After running for 2 days, it had only processed 1.5 million. I want this script to parse several files at once by using multiple threads: one for each file currently being analyzed. T

Re: converting pipe delimited file to fixed width

2009-03-19 Thread MRAB
Terry Reedy wrote: digz wrote: Hi, I am trying to convert a | delimited file to fixed width by right padding with spaces, Here is how I have written the program , just get the feeling this can be done in a much better ( python functional ) way rather than the procedural code i have below . Any

Re: What happened to NASA at Python? :(

2009-03-19 Thread Aahz
[posted and e-mailed] In article , Dotan Cohen wrote: > >PiBUaGVyZSBhcmUgYWJvdXQgNDAgcGVvcGxlIHN1cHBvcnRpbmcgdGhlIE1hcnMgTGFuZGVyIG1p >c3Npb24gdXNpbmcKPiBQeXRob24gYW5kIGFpbWluZyBmb3IgYSBsYXVuY2ggd2luZG93IHRoaXMg >U2VwdGVtYmVyLiBXaXNoIHRoZW0gbHVjayEKPgoKV2hhdCwgZXhhY3RseSwgYXJlIHRoZXkgdXNp >bmcgU

Re: How complex is complex?

2009-03-19 Thread Paul Hildebrandt
On Mar 19, 9:41 am, Kottiyath wrote: > On Mar 19, 9:33 pm, Kottiyath wrote: > > > > > On Mar 19, 8:42 pm, Paul McGuire wrote: > > > > On Mar 19, 4:39 am, Kottiyath wrote: > > > > > I understand that my question was foolish, even for a newbie. > > > > I will not ask any more such questions in th

Re: What happened to NASA at Python? :(

2009-03-19 Thread Dotan Cohen
> There are about 40 people supporting the Mars Lander mission using > Python and aiming for a launch window this September. Wish them luck! > What, exactly, are they using Python for? -- Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק

Re: Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Thank you everybody for the informative replies. I'll have to comb my code for all the instances of "item in sequence" statement because I suspect some of them are as unsafe as my first example. Oh well. One more lesson learned. Thank you again. Manu -- http://mail.python.org/mailman/listinfo/py

Re: What happened to NASA at Python? :(

2009-03-19 Thread Steve Holden
s...@pobox.com wrote: > >> In fact, graphics were added for several organizations. I believe > >> they will be chosen randomly. NASA is still there. > > MiO> In that case, they must be using the random number generator from > MiO> Dilbert. You know, the one that said 9, 9, 9, 9,.

Re: Memory efficient tuple storage

2009-03-19 Thread psaff...@googlemail.com
In the end, I used a cStringIO object to store the chromosomes - because there are only 23, I can use one character for each chromosome and represent the whole lot with a giant string and a dictionary to say what each character means. Then I used numpy arrays for the data and coordinates. This sque

Re: Strange crash issue on Windows w/ PyGTK, Cairo...

2009-03-19 Thread CJ Kucera
CJ Kucera wrote: > Anyway, the issue turned out to be zlib.decompress() - for larger sets > of data, if I wasn't specifying "bufsize," the malloc()s that it was > doing behind-the-scenes must have been clobbering memory. As soon as I > specified bufsize, everything was totally kosher. Okay, I've

Re: Missing values in tuple assignment

2009-03-19 Thread Albert Hopkins
On Thu, 2009-03-19 at 11:57 -0500, Jim Garrison wrote: > Use case: parsing a simple config file line where lines start with a > keyword and have optional arguments. I want to extract the keyword and > then pass the rest of the line to a function to process it. An obvious > use of split(None,1) >

Re: What happened to NASA at Python? :(

2009-03-19 Thread Steve Holden
r wrote: > On Mar 12, 3:31 am, Michele Simionato > wrote: > >> That's pretty much impossible. I am sure NASA uses all programming >> languages in existence, >> plus probably many internal ones we never heard of. > > True but... > all([NASA.does_endorse(lang) for lang in NASA['languages']])

Re: Simple question about yyyy/mm/dd

2009-03-19 Thread Scott David Daniels
mattia wrote: Hi all, I need to receive in input a date represented by a string in the form "/mm/dd" (or reversed), then I need to assure that the date is = the current date and then split the dates in variables like year, month, day. Is there some module to do this quickly? Look into tim

Re: Threads not Improving Performance in Program

2009-03-19 Thread odeits
On Mar 19, 9:50 am, Ryan Rosario wrote: > I have a parser that needs to process 7 million files. After running > for 2 days, it had only processed 1.5 million. I want this script to > parse several files at once by using multiple threads: one for each > file currently being analyzed. > > My code i

Missing values in tuple assignment

2009-03-19 Thread Jim Garrison
Use case: parsing a simple config file line where lines start with a keyword and have optional arguments. I want to extract the keyword and then pass the rest of the line to a function to process it. An obvious use of split(None,1) cmd,args= = line.split(None,1); if cmd in self.switch: s

cross compile Python to Linux-ARM

2009-03-19 Thread jefm
Hi, We are looking to use Python on an embedded Linux ARM system. What I gather from googling the subject is that it is not that straight forward (a fair amount of patching & hacking). Nobody out there that has done it claims it is easy, which makes me worried. I haven't seen a description on port

Re: converting pipe delimited file to fixed width

2009-03-19 Thread odeits
On Mar 19, 8:51 am, digz wrote: > Hi, > I am trying to convert a | delimited  file to fixed width by right > padding with spaces, Here is how I have written the program , just get > the feeling this can be done in a much better ( python functional ) > way rather than the procedural code i have bel

Re: converting pipe delimited file to fixed width

2009-03-19 Thread Terry Reedy
digz wrote: Hi, I am trying to convert a | delimited file to fixed width by right padding with spaces, Here is how I have written the program , just get the feeling this can be done in a much better ( python functional ) way rather than the procedural code i have below . Any help appreciated #!

Threads not Improving Performance in Program

2009-03-19 Thread Ryan Rosario
I have a parser that needs to process 7 million files. After running for 2 days, it had only processed 1.5 million. I want this script to parse several files at once by using multiple threads: one for each file currently being analyzed. My code iterates through all of the directories within a dire

Re: Simple question about yyyy/mm/dd

2009-03-19 Thread skip
>> Hi all, I need to receive in input a date represented by a string in >> the form "/mm/dd" (or reversed), then I need to assure that the >> date is = the current date and then split the dates in variables like >> year, month, day. Is there some module to do this quickly? The

Re: DictReader and fieldnames

2009-03-19 Thread skip
Ted> Is it possible to grab the fieldnames that the csv DictReader Ted> module automatically reads from the first line of the input file? Like this, perhaps? >>> rdr = csv.DictReader(open("f.csv", "rb")) >>> rdr.fieldnames ['col1', 'col2', 'color'] >>> rdr.next() {'co

Re: Can I rely on...

2009-03-19 Thread Terry Reedy
Emanuele D'Arrigo wrote: Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] compiledPatterns.append(re.compile(pattern)) if(re.compil

Re: How complex is complex?

2009-03-19 Thread Kottiyath
On Mar 19, 9:33 pm, Kottiyath wrote: > On Mar 19, 8:42 pm, Paul McGuire wrote: > > > > > On Mar 19, 4:39 am, Kottiyath wrote: > > > > I understand that my question was foolish, even for a newbie. > > > I will not ask any more such questions in the future. > > > Gaaah! Your question was just fine

Re: How complex is complex?

2009-03-19 Thread Kottiyath
On Mar 19, 8:42 pm, Paul McGuire wrote: > On Mar 19, 4:39 am, Kottiyath wrote: > > > > > I understand that my question was foolish, even for a newbie. > > I will not ask any more such questions in the future. > > Gaaah! Your question was just fine, a good question on coding style. > I wish more p

Simple question about yyyy/mm/dd

2009-03-19 Thread mattia
Hi all, I need to receive in input a date represented by a string in the form "/mm/dd" (or reversed), then I need to assure that the date is >= the current date and then split the dates in variables like year, month, day. Is there some module to do this quickly? -- http://mail.python.org/mail

Re: File Compare with difflib.context_diff

2009-03-19 Thread JohnV
Here is the latest version of the code: currentdata_file = r"C:\Users\Owner\Desktop\newdata.txt" # the latest download from the clock lastdata_file = r"C:\Users\Owner\Desktop\mydata.txt" # the prior download from the clock output_file = r"C:\Users\Owner\Desktop\out.txt" # will hold delta clock dat

Re: Do deep inheritance trees degrade efficiency?

2009-03-19 Thread Terry Reedy
Terry Reedy wrote: Anthra Norell wrote: Would anyone who knows the inner workings volunteer to clarify whether or not every additional derivation of a class hierarchy adds an indirection to the base class's method calls and attribute read-writes. More potential search layers rather than poin

Re: converting pipe delimited file to fixed width

2009-03-19 Thread MRAB
digz wrote: Hi, I am trying to convert a | delimited file to fixed width by right padding with spaces, Here is how I have written the program , just get the feeling this can be done in a much better ( python functional ) way rather than the procedural code i have below . Any help appreciated #!

Re: Can I rely on...

2009-03-19 Thread Albert Hopkins
On Thu, 2009-03-19 at 08:42 -0700, Emanuele D'Arrigo wrote: > Hi everybody, > > I just had a bit of a shiver for something I'm doing often in my code > but that might be based on a wrong assumption on my part. Take the > following code: > > pattern = "aPattern" > > compiledPatterns = [ ] > compi

Re: Can I rely on...

2009-03-19 Thread MRAB
Emanuele D'Arrigo wrote: [snip] If the answer is no, am I right to state the in the case portrayed above the only way to be safe is to use the following code instead? for item in compiledPatterns: if(item.pattern == pattern): print("The compiled pattern is stored.") break Co

Re: Can I rely on...

2009-03-19 Thread MRAB
Emanuele D'Arrigo wrote: Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] compiledPatterns.append(re.compile(pattern)) if(re.compil

converting pipe delimited file to fixed width

2009-03-19 Thread digz
Hi, I am trying to convert a | delimited file to fixed width by right padding with spaces, Here is how I have written the program , just get the feeling this can be done in a much better ( python functional ) way rather than the procedural code i have below . Any help appreciated #!/usr/bin/pytho

Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Sorry for the double-post, the first one was sent by mistake before completion. Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] comp

Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] compiledPatterns.append(re.compile(pattern)) if(re.compile(pattern) in compiledPatte

Re: How complex is complex?

2009-03-19 Thread Paul McGuire
On Mar 19, 4:39 am, Kottiyath wrote: > > I understand that my question was foolish, even for a newbie. > I will not ask any more such questions in the future. > Gaaah! Your question was just fine, a good question on coding style. I wish more people would ask such questions so that bad habits coul

Re: Preferred syntax for the docstrings

2009-03-19 Thread Scott David Daniels
Luis Zarrabeitia wrote: What's the preferred style to document code in python? ... def somefunction(arg1, arg2, out = sys.stdout): """ This function does blahblablha with the string arg1, using the tuple of ints arg2 as the control sequence, and prints the result to out (defaults to

  1   2   >