Re: [Tutor] Python 2.2... os.exec catch stdout

2009-06-04 Thread Lie Ryan
Chris Mueller wrote: > /Hello. > > I am relegated to running python 2.2; so I do not have access to subprocess. > > In my script; at one point, I need to run a program; interact with the > program; exit the program; and parse the output printed to stdout. > > This would be simple; if I did not

Re: [Tutor] stripping 0's from 01's - 09's

2009-06-04 Thread Lie Ryan
Norman Khine wrote: > Hello, > Simple, I guess, but I am trying to do a formated date function, which > I have working but for a small annoyance in that: > from datetime import date def format_date(day): > if day > 3 and day < 14: > return '%b %dth %Y' >

Re: [Tutor] Fw: unicode, utf-8 problem again

2009-06-04 Thread Stefan Behnel
Dinesh B Vadhia wrote: > Hi! I'm processing a large number of xml files that are all declared as > utf-8 encoded in the header ie. > > > > I'm using elementtree to process the xml files and > don't (usually) have any problems with that. Plus, the workaround that > works is to encode each eleme

Re: [Tutor] unicode, utf-8 problem again

2009-06-04 Thread Mark Tolonen
"Dinesh B Vadhia" wrote in message news:col103-ds25bb23a18e216061c32eb1a3...@phx.gbl... Hi! I'm processing a large number of xml files that are all declared as utf-8 encoded in the header ie. My Python environment has been set for 'utf-8' through site.py. It's a bad idea to change th

Re: [Tutor] serious problem with graphics module

2009-06-04 Thread W W
On Thu, Jun 4, 2009 at 7:47 PM, Kent Johnson wrote: > On Wed, Jun 3, 2009 at 5:51 PM, W W wrote: > > > Do you (or sombody else) know how to get ipython working with Python 2.6 > > (you know, > > the Python release, which has that new turtle module ;-) ) > > > > doesn't install on my Windows box

Re: [Tutor] serious problem with graphics module

2009-06-04 Thread Kent Johnson
On Wed, Jun 3, 2009 at 5:51 PM, W W wrote: > Do you (or sombody else) know how to get ipython working with Python 2.6 > (you know, > the Python release, which has that new turtle module ;-)   ) > > doesn't install on my Windows box... other than that I've got no experience > with it What trouble

Re: [Tutor] serious problem with graphics module

2009-06-04 Thread Gregor Lingl
Alan Gauld schrieb: "W W" wrote Do you (or sombody else) know how to get ipython working with Python 2.6 (you know, the Python release, which has that new turtle module ;-) ) doesn't install on my Windows box... other than that I've got no experience with it I thought the new turtle

Re: [Tutor] Python 2.2... os.exec catch stdout

2009-06-04 Thread Emile van Sebille
On 6/4/2009 1:49 PM Chris Mueller said... /Hello. I am relegated to running python 2.2; so I do not have access to subprocess. In my script; at one point, I need to run a program; interact with the program; exit the program; and parse the output printed to stdout. This would be simple; if I

[Tutor] Python 2.2... os.exec catch stdout

2009-06-04 Thread Chris Mueller
*Hello. I am relegated to running python 2.2; so I do not have access to subprocess. In my script; at one point, I need to run a program; interact with the program; exit the program; and parse the output printed to stdout. This would be simple; if I did not need to interact with my sub-program.

Re: [Tutor] stripping 0's from 01's - 09's

2009-06-04 Thread Emile van Sebille
On 6/4/2009 12:04 PM Norman Khine said... Hello, Simple, I guess, but I am trying to do a formated date function, which I have working but for a small annoyance in that: from datetime import date def format_date(day): ... if day > 3 and day < 14: ... return '%b %dth %Y' ...

[Tutor] stripping 0's from 01's - 09's

2009-06-04 Thread Norman Khine
Hello, Simple, I guess, but I am trying to do a formated date function, which I have working but for a small annoyance in that: >>> from datetime import date >>> def format_date(day): ... if day > 3 and day < 14: ... return '%b %dth %Y' ... indicator = day % 10 ... if indic

Re: [Tutor] unicode, utf-8 problem again

2009-06-04 Thread Dinesh B Vadhia
That was very useful - thanks! Hopefully, I'm "all Unicode" now. From: wesley chun Sent: Thursday, June 04, 2009 10:45 AM To: Dinesh B Vadhia ; tutor@python.org Subject: Re: [Tutor] unicode, utf-8 problem again >> But, I still get this error: >> Traceback (most recent call last): >> ...

Re: [Tutor] unicode, utf-8 problem again

2009-06-04 Thread wesley chun
>>  But, I still get this error: >>  Traceback (most recent call last): >> ... >> UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in >> position 76: ordinal not in range(128) >>  What am I missing? > > Take a read through http://evanjones.ca/python-utf8.html which will give you >

Re: [Tutor] improvement of if - else code

2009-06-04 Thread Steve Willoughby
On Thu, Jun 04, 2009 at 07:25:20PM +0200, Norman Khine wrote: > Hello, > Is there a better way to write this: Depends on what's cleaner and clearer for what you're doing, especially as the complexity of this code grows. For example, if the only difference is which method to call, one approach mi

Re: [Tutor] improvement of if - else code

2009-06-04 Thread Norman Khine
Thanks On Thu, Jun 4, 2009 at 7:34 PM, vince spicer wrote: > you could assign loop variable > >    @staticmethod >    def get_form(address=None, postcode=None, town=None, phone=None, > fax=None, >                 freephone=None, address_country=None, address_region=None, >                 address

Re: [Tutor] improvement of if - else code

2009-06-04 Thread vince spicer
you could assign loop variable @staticmethod def get_form(address=None, postcode=None, town=None, phone=None, fax=None, freephone=None, address_country=None, address_region=None, address_county=None, hotel=None): context = get_context() root = co

[Tutor] improvement of if - else code

2009-06-04 Thread Norman Khine
Hello, Is there a better way to write this: @staticmethod def get_form(address=None, postcode=None, town=None, phone=None, fax=None, freephone=None, address_country=None, address_region=None, address_county=None, hotel=None): context = get_context(

Re: [Tutor] unicode, utf-8 problem again

2009-06-04 Thread Dinesh B Vadhia
Okay, I get it now ... reading/writing files with the codecs module and the 'utf-8' option fixes it. Thanks! From: Christian Witts Sent: Thursday, June 04, 2009 7:05 AM To: Dinesh B Vadhia Cc: tutor@python.org Subject: Re: [Tutor] unicode, utf-8 problem again Dinesh B Vadhia wrote: > H

Re: [Tutor] advise on this loop

2009-06-04 Thread Norman Khine
On Thu, Jun 4, 2009 at 3:48 PM, W W wrote: > On Thu, Jun 4, 2009 at 8:29 AM, Norman Khine wrote: >> >> Hello, >> I have the following code, which searches through a directory structure >> such as: >> >> $ tree -L 2 companies >> companies >> |-- aberdeen-airport-ltd >> |   |-- aberdeen-airport-dyc

Re: [Tutor] unicode, utf-8 problem again

2009-06-04 Thread Christian Witts
Dinesh B Vadhia wrote: Hi! I'm processing a large number of xml files that are all declared as utf-8 encoded in the header ie. My Python environment has been set for 'utf-8' through site.py. Additionally, the top of each program/module has the declaration: # -*- coding: utf-8 -*- But,

[Tutor] Fw: unicode, utf-8 problem again

2009-06-04 Thread Dinesh B Vadhia
I forgot to add that I'm using elementtree to process the xml files and don't (usually) have any problems with that. Plus, the workaround that works is to encode each elementtree output ie.: thisxmlline = thisxmlline.encode('utf8') But, this seems odd to me as isn't it already being processed

Re: [Tutor] advise on this loop

2009-06-04 Thread W W
On Thu, Jun 4, 2009 at 8:29 AM, Norman Khine wrote: > Hello, > I have the following code, which searches through a directory structure > such as: > > $ tree -L 2 companies > companies > |-- aberdeen-airport-ltd > | |-- aberdeen-airport-dyce-grampian > | `-- aberdeen-airport-dyce-grampian.meta

[Tutor] unicode, utf-8 problem again

2009-06-04 Thread Dinesh B Vadhia
Hi! I'm processing a large number of xml files that are all declared as utf-8 encoded in the header ie. My Python environment has been set for 'utf-8' through site.py. Additionally, the top of each program/module has the declaration: # -*- coding: utf-8 -*- But, I still get this error: Tr

[Tutor] advise on this loop

2009-06-04 Thread Norman Khine
Hello, I have the following code, which searches through a directory structure such as: $ tree -L 2 companies companies |-- aberdeen-airport-ltd | |-- aberdeen-airport-dyce-grampian | `-- aberdeen-airport-dyce-grampian.metadata |-- aberdeen-airport-ltd.metadata |-- aberdeen-motor-company-ltd |

Re: [Tutor] array manipulations

2009-06-04 Thread Alan Gauld
"NTB" wrote array [['Food 1', 'Nutrient 1', 0.9], ['Food 1', 'Nutrient 2', 0.2], ['Food 2', 'Nutrient 1', 0.55], ['Food 2', 'Nutrient 2', 0.11]] into a new array that looks like this: array [['Food 1', 0.9, 0.2], ['Food 2', 0.55, 0.11]] I'd proba

[Tutor] Generating Hetmaps

2009-06-04 Thread vishwajeet singh
Hi, I have a small query is there any standard module available for generating heatmap from given set of data. -- Cheers, Vishwajeet http://www.singhvishwajeet.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor