Re: socket.rcv timeout while-loop

2011-02-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Dwayne Blind wrote: or rather timeout = s.gettimeout() b=time.clock() while time.clock()-b<3 : s.settimeout(3-time.clock()+b) try : data=s.recv(1024) except : break s.settimeout(t

code structure advise for a model

2011-02-03 Thread Martin De Kauwe
Hi, I am translating some c++ code to python and just wanted to ask some advise on structure. The original has everything declared globally and nothing passed via function (I assume, but don't know, that this isn't just standard c++ practice!). So given this, I have a pretty much clean slate as I

Re: Download an attachment from an IMAP email

2011-02-03 Thread Kushal Kumaran
On Fri, Feb 4, 2011 at 3:44 AM, Vincent Davis wrote: > I have a few emails I am trying to download from my google account. I seem > to be getting the message but each of these messages have an attachment. I > don't understand what I ned to do to get and save the attachment to a local > file. > Her

Re: socket.rcv timeout while-loop

2011-02-03 Thread Stephen Hansen
On 2/3/11 3:02 PM, Dwayne Blind wrote: > Thanks Stephen. It's really nice of you. > > I have not understood everything though. (I have never used a context > manager before.) > > Here are some comments : > > timeout = s.gettimeout()# Is that the default timeout ? > s.settimeout(3)

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
or rather timeout = s.gettimeout() b=time.clock() while time.clock()-b<3 : s.settimeout(3-time.clock()+b) try : data=s.recv(1024) except : break s.settimeout(timeout) Sorry for all these messages Dwayne 2011/2/4 D

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
On Thu, 2011-02-03 at 17:57 -0600, Thomas L. Shinnick wrote: > At 05:33 PM 2/3/2011, Westley Martínez wrote: > > > On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote: > > > > > On Thu, 03 Feb 2011 > > > 07:58:55 -0800, Ethan Furman wrote: > > > > Steven D'Aprano wrote: > > > [snip] > > >

8-Day Python Power Course in Leipzig/Germany

2011-02-03 Thread Mike Müller
Eight Days of Python Training - Can't get enough of Python? Then this course is for you. A three day introduction to Python as a warm-up, followed by five days of advanced Python training. All courses given in English. May 13 - 15, 2011 Python for Programmers May

Re: os.path.join doubt

2011-02-03 Thread Thomas L. Shinnick
At 05:33 PM 2/3/2011, Westley Martínez wrote: On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote: On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > Steven D'Aprano wrote: [snip] Yes. Is there a problem? All those paths should be usable from Windows. If you find it ugly to see path

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote: > On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > > > Steven D'Aprano wrote: > >> BTW, Windows accepts / as well as \ as a path separator. You will have > >> far fewer headaches if you use that. > > > > Just because Windows acce

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
The solution would be timeout = s.gettimeout() s.settimeout(3) b=time.clock() while time.clock()-b<3 : try : data=s.recv(1024) except : break s.settimeout(timeout) Am I right ? Dwayne 2011/2/4 Dwayne Blind > Thanks Ste

Re: os.path.join doubt

2011-02-03 Thread Steven D'Aprano
On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > Steven D'Aprano wrote: >> BTW, Windows accepts / as well as \ as a path separator. You will have >> far fewer headaches if you use that. > > Just because Windows accepts / doesn't make it a good idea... No. Windows accepting slashes as th

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
Thanks Stephen. It's really nice of you. I have not understood everything though. (I have never used a context manager before.) Here are some comments : timeout = s.gettimeout()# Is that the default timeout ? s.settimeout(3) # I guess this is a 3 second timeout s.recv(1024)

Download an attachment from an IMAP email

2011-02-03 Thread Vincent Davis
I have a few emails I am trying to download from my google account. I seem to be getting the message but each of these messages have an attachment. I don't understand what I ned to do to get and save the attachment to a local file. Here is what I have so far. M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP

JSONBOT 0.6.1 RELEASED

2011-02-03 Thread Bart Thate
Hello every human out there ! i'm pleased to announce the release of JSONBOT 0.6.1 FINAL, a release that saw a lot of work into the shell side of things and no changes to GAE. 0.6.1 has the following changes: * the ! char is not used instead of | in a pipeline. This is to make it easier to use a

Re: returning all matching groups with re.search()

2011-02-03 Thread Benjamin Kaplan
On Thu, Feb 3, 2011 at 3:32 PM, mhearne808[insert-at-sign-here]gmail[insert-dot-here]com wrote: > Here's a scenario: > > import re > m = re.search('e','fredbarneybettywilma') > > Now, here's a stupid question: > why doesn't m.groups() return ('e','e','e'). > > I'm trying to figure out how to match

Re: returning all matching groups with re.search()

2011-02-03 Thread Chris Rebert
On Thu, Feb 3, 2011 at 12:32 PM, mhearne808[insert-at-sign-here]gmail[insert-dot-here]com wrote: > Here's a scenario: > > import re > m = re.search('e','fredbarneybettywilma') > > Now, here's a stupid question: > why doesn't m.groups() return ('e','e','e'). Straight from the docs (http://docs.pyt

returning all matching groups with re.search()

2011-02-03 Thread mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
Here's a scenario: import re m = re.search('e','fredbarneybettywilma') Now, here's a stupid question: why doesn't m.groups() return ('e','e','e'). I'm trying to figure out how to match ALL of the instances of a pattern in one call - the group() and groups() return subgroups... how do I get my se

ptrace vs. python-ptrace

2011-02-03 Thread Grant Edwards
I'd like to do some experimentation with the Linux ptrace facility. Before I jump in, I was wondering if anybody has any comments they'd like to offer on the relative merits of ptrace vs. python-ptrace: http://pypi.python.org/pypi/ptrace http://pypi.python.org/pypi/python-ptrace Ptrace appear

Re: socket.rcv timeout while-loop

2011-02-03 Thread Stephen Hansen
On 2/3/11 10:13 AM, Dwayne Blind wrote: > Thanks for your answer. I don't want to reset my socket. I want to apply > the timeout to the rcv method only. Setting the timeout does not "reset [your] socket", I don't think. And I get that you want to only timeout recv... that's why I pointed out its a

Pydev 1.6.5 Released

2011-02-03 Thread Fabio Zadrozny
Hi All, Pydev 1.6.5 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: --- * Syntax highlighting now has options to have {}, [] and () as well as operators in different colors * Code gener

Re: socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
Thanks for your answer. I don't want to reset my socket. I want to apply the timeout to the rcv method only. What about select ? http://docs.python.org/library/select.html#select.select How to implement it ? Thanks a lot, Dwayne 2011/2/3 Stephen Hansen > On 2/3/11 9:56 AM, Dwayne Blind wrote

New article on grabbing city points from geonames, processing with Python, and rendering in MapPoint

2011-02-03 Thread Eric Frost
Add City Coverage to MapPoint using the GeoNames Database by Richard Marsden http://www.mapforums.com/add-city-coverage-mappoint-using-geonames-database-15244.html -- m: 312-399-1586 http://www.MapForums.com http://www.MP2Kmag.com -- http://mail.python.org/mailman/listinfo/python-list

Re: socket.rcv timeout while-loop

2011-02-03 Thread Stephen Hansen
On 2/3/11 9:56 AM, Dwayne Blind wrote: > However I would like to set timeout on the socket rcv method, so that > the while loop stops exactly after 3 seconds. Is this possible ? I rarely do low-level socket stuff -- but I think s.settimeout() is what you're looking for. It applies to the whole soc

socket.rcv timeout while-loop

2011-02-03 Thread Dwayne Blind
Hi everybody, I am using Python 3.0. I have such a code : b=time.clock() while time.clock()-b<3 : data=s.recv(1024) However I would like to set timeout on the socket rcv method, so that the while loop stops exactly after 3 seconds. Is this possible ? Thanks a lot, Dwayne -- http://mail.pyt

Re: Errors while using strip and remove on a variable.

2011-02-03 Thread Stephen Hansen
On 2/3/11 7:21 AM, anand jeyahar wrote: > Hi, > I am trying to strip a string and then remove on the resulting list > to remove a set of characters. It works fine with the python shell. > > But after remove the list becomes None, when i am running it from within > a script. > > I am guessing

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread rantingrick
If anyone would like to see a good example of how IDLE code should be written. I highly suggest you check out the source for PyShell and PyCrust which is located in roughly... HOME\PythonXX\Lib\site-packages\wx-2.8-msw-ansi\wx\py: * shell.py * crust.py * filling.py Also run these scripts to s

Re: Style question: Nicknames for deeply nested objects

2011-02-03 Thread Jean-Michel Pichavant
Gerald Britton wrote: Nope. it's nothing to do with imports. It's about objects passed to methods at run time. Complicated objects with many levels. Not about modules at all. Who is providing these objects ? - Your code ? => as said before, you can fix your design with a proper object

Fwd: 'Upload a valid image' errors with PIL 1.1.7/ Python 2.6/ Mac 10.6.2/ Django 1.2.3

2011-02-03 Thread Anjali Arora
I'm sorry, by admin site below, I mean Django Admin site. Hi, I am struggling with this for the past 2 days: first I got the above error, & googled around to find that I needed the libjpeg module as well, so I re-installed the lot, first libjpeg & then PIL; got a couple errors like JPEG decoder n

Re: Perl Hacker, Python Initiate

2011-02-03 Thread Jorgen Grahn
On Wed, 2011-02-02, Gary Chambers wrote: > All, > > Given the following Perl script: > > #!/usr/bin/perl I'm a Perl user, but I generally refuse to read Perl code which doesn't utilize 'use warnings/-w' and 'use strict'. There are just too many crazy bugs and 1980s constructs which go unnoticed w

'Upload a valid image' errors with PIL 1.1.7/ Python 2.6/ Mac 10.6.2

2011-02-03 Thread Anjali Arora
Hi, I am struggling with this for the past 2 days: first I got the above error, & googled around to find that I needed the libjpeg module as well, so I re-installed the lot, first libjpeg & then PIL; got a couple errors like JPEG decoder not available etc, fixed that. Now it passes the selftest, b

Re: Perl Hacker, Python Initiate

2011-02-03 Thread waku
you've already got a hint on how to do it using library functions in python. below is a more literal suggestion. On Feb 1, 10:36 pm, Gary Chambers wrote: > All, > > Given the following Perl script: > > #!/usr/bin/perl > > %dig = ( >      solaris => "/usr/sbin/dig", >      linux   => "/usr/bin/di

Re: Perl Hacker, Python Initiate

2011-02-03 Thread sturlamolden
On 2 Feb, 05:36, Gary Chambers wrote: > Given the following Perl script: (...) Let me quote the deceased Norwegian lisp hacker Erik Naggum: "Excuse me while I barf in Larry Wall's general direction." Sturla -- http://mail.python.org/mailman/listinfo/python-list

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread rantingrick
On Feb 3, 4:29 am, flebber wrote: > For an example of a brilliant beginners "ide" racket has it covered > with DrRackethttp://racket-lang.org/, it has selectable language > levels beginner, intermediate, advanced that allows the learner to > adjust the level of language features available as they

Re: os.path.join doubt

2011-02-03 Thread Ethan Furman
Steven D'Aprano wrote: BTW, Windows accepts / as well as \ as a path separator. You will have far fewer headaches if you use that. Just because Windows accepts / doesn't make it a good idea... Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help",

Re: Perl Hacker, Python Initiate

2011-02-03 Thread Hrvoje Niksic
Gary Chambers writes: > Will someone please provide some insight on how to accomplish that > task in Python? I am unable to continually (i.e. it stops after > displaying a single line) loop through the output while testing for > the matches on the two regular expressions. Thank you. If I under

Re: Errors while using strip and remove on a variable.

2011-02-03 Thread Gary Herron
On 02/03/2011 07:21 AM, anand jeyahar wrote: Hi, I am trying to strip a string and then remove on the resulting list to remove a set of characters. It works fine with the python shell. But after remove the list becomes None, when i am running it from within a script. I am guessing it ha

Re: Errors while using strip and remove on a variable.

2011-02-03 Thread Benjamin Kaplan
On Thu, Feb 3, 2011 at 10:21 AM, anand jeyahar wrote: > Hi, >     I am trying to strip a string and then remove on the resulting list to > remove a set of characters. It works fine with the python shell. > > But after remove the list becomes None, when i am running it from within a > script. > > I

Errors while using strip and remove on a variable.

2011-02-03 Thread anand jeyahar
Hi, I am trying to strip a string and then remove on the resulting list to remove a set of characters. It works fine with the python shell. But after remove the list becomes None, when i am running it from within a script. I am guessing it has something to do with the way python handles assig

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg' is a valid path. .. means parent, not 'go back a directory'. But you should really be trying this: p1 = os.environ['HOMEPATH'] p2 = os.path.join(p1, 'Pictures', 'images', 'my.jpg') On Wed, 2011-02-02 at 20:46 -0800, harryos wrote: > In win

Re: locale settings and date parsing under windows

2011-02-03 Thread python
Matt, > I'm now just using a handbuilt dict that holds translations like > > 'fr_FR' : 'French_France' > 'da_DK' : 'Danish_Denmark' What sources are you using for your dict keys and dict values? I'm struggling with the same issue and I'm looking for master references for both sets of code. Than

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread Benjamin Kaplan
On Thu, Feb 3, 2011 at 5:29 AM, flebber wrote: > On Feb 1, 11:38 pm, rantingrick wrote: >> On Feb 1, 4:20 am, flebber wrote: >> >> > Sorry Rick too boringtrying to get bored people to bite at your >> > ultra lame post yawn... >> >> Well reality and truth both has a tendency to be bor

Re: locale settings and date parsing under windows

2011-02-03 Thread AlienBaby
On Feb 3, 12:13 pm, "Martin P. Hellwig" wrote: > On 02/03/11 10:59, AlienBaby wrote: > > > > > > > On Feb 3, 10:22 am, AlienBaby  wrote: > >> Hi, > > >> I'm attempting to convert some date-time strings from a text file > >> under windows into a datetime object as returned by strptime() > > >> Howe

Re: locale settings and date parsing under windows

2011-02-03 Thread Martin P. Hellwig
On 02/03/11 10:59, AlienBaby wrote: On Feb 3, 10:22 am, AlienBaby wrote: Hi, I'm attempting to convert some date-time strings from a text file under windows into a datetime object as returned by strptime() However, the strings can represent dates in various formats based on the country of ori

Re: locale settings and date parsing under windows

2011-02-03 Thread AlienBaby
On Feb 3, 10:22 am, AlienBaby wrote: > Hi, > > I'm attempting to convert some date-time strings from a text file > under windows into a datetime object as returned by strptime() > > However, the strings can represent dates in various formats based on > the country of origin, for example shortened

Re: Style question: Nicknames for deeply nested objects

2011-02-03 Thread Jean-Michel Pichavant
Gerald Britton wrote: however, considering what "import a.module.that.is.quite.nested as myModule" Won't work since I get the objects at run time myModule = __import__('whatever.module.imported.at.run.time', globals(), locals(), [], -1) See http://docs.python.org/library/function

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread flebber
On Feb 1, 11:38 pm, rantingrick wrote: > On Feb 1, 4:20 am, flebber wrote: > > > Sorry Rick too boringtrying to get bored people to bite at your > > ultra lame post yawn... > > Well reality and truth both has a tendency to be boring. Why? Well > because we bathe in them daily. We have

locale settings and date parsing under windows

2011-02-03 Thread AlienBaby
Hi, I'm attempting to convert some date-time strings from a text file under windows into a datetime object as returned by strptime() However, the strings can represent dates in various formats based on the country of origin, for example shortened month names etc.. are different between countries.

Re: DRY and static attribute for multiple classes.

2011-02-03 Thread Marc Aymerich
On Feb 3, 10:24 am, Peter Otten <__pete...@web.de> wrote: > Marc Aymerich wrote: > > On Feb 2, 12:11 am, Peter Otten <__pete...@web.de> wrote: > >> Marc Aymerich wrote: > > Hi!, > > Unfortunately per_class attribute losses the "independence" when I try > > to mix it with django models.Model . > > >

Re: os.path.join doubt

2011-02-03 Thread Nobody
On Thu, 03 Feb 2011 06:31:49 +, Steven D'Aprano wrote: > On Wed, 02 Feb 2011 20:46:12 -0800, harryos wrote: > >> In windows ,I tried this >> >> p1 = "C:\Users\me\Documents" >> p2 = "..\Pictures\images\my.jpg" Don't do this; backslash is significant within Python string literals. If want to

Re: Reassign or discard Popen().stdout from a server process

2011-02-03 Thread Nobody
On Tue, 01 Feb 2011 08:30:19 +, John O'Hagan wrote: > I can't keep reading because that will block - there won't be any more > output until I send some input, and I don't want it in any case. > > To try to fix this I added: > > proc.stdout = os.path.devnull > > which has the effect of stopp

Re: DRY and static attribute for multiple classes.

2011-02-03 Thread Peter Otten
Marc Aymerich wrote: > On Feb 2, 12:11 am, Peter Otten <__pete...@web.de> wrote: >> Marc Aymerich wrote: > Hi!, > Unfortunately per_class attribute losses the "independence" when I try > to mix it with django models.Model . > > from django.db import models > class Plugin(models.base.ModelBase):

Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-03 Thread Red John
On Feb 2, 9:03 pm, alex23 wrote: > rantingrick wrote: > > Hmm, that coming from someone who has two posts in this group. And the > > last he posted was a year ago! > > Wait, I thought you had the approval of the silent majority? > > So once anyone actually posts, they lost the right to be counted

Re: parse GET/POST data on simple http server

2011-02-03 Thread Markus
On Feb 3, 9:35 am, Chris Rebert wrote: > On Thu, Feb 3, 2011 at 12:15 AM, Markus wrote: > > Hi, > > > As a beginner in python, I am looking for example code that would help > > me understand how to > > code following idea: > > 1. Start minimal http server > > http://docs.python.org/library/baseht

Re: parse GET/POST data on simple http server

2011-02-03 Thread Chris Rebert
On Thu, Feb 3, 2011 at 12:15 AM, Markus wrote: > Hi, > > As a beginner in python, I am looking for example code that would help > me understand how to > code following idea: > 1. Start minimal http server http://docs.python.org/library/basehttpserver.html http://docs.python.org/library/simplehttp

Re: parse GET/POST data on simple http server

2011-02-03 Thread Corey Richardson
On 02/03/2011 03:15 AM, Markus wrote: > Hi, > > As a beginner in python, I am looking for example code that would help > me understand how to > code following idea: > 1. Start minimal http server > 2. Send GET or POST data (url encoded, or from form) - example > Name="Foo" > 3. Analyze the GET/POS

Re: parse GET/POST data on simple http server

2011-02-03 Thread Corey Richardson
On 02/03/2011 03:15 AM, Markus wrote: > Hi, > > As a beginner in python, I am looking for example code that would help > me understand how to > code following idea: > 1. Start minimal http server > 2. Send GET or POST data (url encoded, or from form) - example > Name="Foo" > 3. Analyze the GET/POS

parse GET/POST data on simple http server

2011-02-03 Thread Markus
Hi, As a beginner in python, I am looking for example code that would help me understand how to code following idea: 1. Start minimal http server 2. Send GET or POST data (url encoded, or from form) - example Name="Foo" 3. Analyze the GET/POST variable value on server and match to different value