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: 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: 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

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: 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

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: 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: 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: 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: 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: 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: 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: 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: 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 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 >

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: 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

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 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

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

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

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

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

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: 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 * >

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: 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: 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 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: 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

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: 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

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: 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: 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: 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

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: 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

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: 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: 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: 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 > >

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: 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

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

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: 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

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: 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

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

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: [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

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: 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: 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: 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: 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

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/%

<    1   2