Re: [Tutor] code improvement

2009-09-29 Thread Patrick Sabin
You could invert your if-expressions, e.g. instead of if query_company_name: ... you could write if not query_company_name: return adresses, company ... This way you could save some indentation. If you want to get rid of the for loops, you could look at list comprehensions, e

Re: [Tutor] code improvement

2009-09-25 Thread Kent Johnson
On Fri, Sep 25, 2009 at 1:00 AM, Norman Khine wrote: >>> Is there a better method to write the last bit of the code. > Apologies for not being clear. I was thinking more  that I may have > one the too many 'for' loops at the end of the code. > > http://paste.lisp.org/display/87659#1 It's only t

Re: [Tutor] code improvement

2009-09-24 Thread Norman Khine
On Thu, Sep 24, 2009 at 10:25 PM, Kent Johnson wrote: > On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine wrote: >> Hello, >> I have this function in my class: >> >> http://paste.lisp.org/display/87659 >> >> Is there a better method to write the last bit of the code. > > Better in what way? What are

Re: [Tutor] code improvement

2009-09-24 Thread Kent Johnson
On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine wrote: > Hello, > I have this function in my class: > > http://paste.lisp.org/display/87659 > > Is there a better method to write the last bit of the code. Better in what way? What are these things? What is resource? Some context would be helpful, I s

[Tutor] code improvement

2009-09-24 Thread Norman Khine
Hello, I have this function in my class: http://paste.lisp.org/display/87659 Is there a better method to write the last bit of the code. Thanks Norman ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.py

Re: [Tutor] code improvement for beginner ?

2005-10-21 Thread Kent Johnson
Jacob S. wrote: >> Text mode is the default, you have to specify the 'b' if you want >> binary mode. And open() seems to accept any mode quite happily: >> >> >>> f=open('build.xml', 'rt') >> >>> f >> >> >>> f.close() >> >>> f=open('build.xml', 'rabcd') >> >>> f >> >> >> Kent > > > I'll bet you

Re: [Tutor] code improvement for beginner ?

2005-10-21 Thread Jacob S.
> Text mode is the default, you have to specify the 'b' if you want binary > mode. And open() seems to accept any mode quite happily: > > >>> f=open('build.xml', 'rt') > >>> f > > >>> f.close() > >>> f=open('build.xml', 'rabcd') > >>> f > > > Kent I'll bet you'll find that open() is coded somet

Re: [Tutor] code improvement for beginner ?

2005-10-11 Thread Scott Oertel
lmac wrote: > --- > >The problem with downloading the images is this: > >- >http://images.nfl.com/images/globalnav-shadow-gray.gif >Traceback (most recent call last): > File "/home/internet/bin/nflgrab.py", line 167, in ? >urllib.urlretrieve(img,img[f:]) > File "/usr/

Re: [Tutor] code improvement for beginner ? (fwd)

2005-10-11 Thread Danny Yoo
-- Forwarded message -- Date: Tue, 11 Oct 2005 20:55:24 +0200 From: lmac <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re:code improvement for beginner ? Danny Yoo wrote: > >>>The point of this restructuring is to allow you to add more image >>>types without too

Re: [Tutor] code improvement for beginner ?

2005-10-11 Thread Roel Schroeven
Kent Johnson wrote: > Roel Schroeven wrote: > >> Danny Yoo wrote: >> >> >>> Looking at pageimgs(): I'm not sure what 't' means in the open >>> statement: >>> >>> f = open(filename, "rt") >> >> It's not a typo. 't' opens the file in text mode. > > > Are you sure? Is that documented anywhere?

Re: [Tutor] code improvement for beginner ?

2005-10-10 Thread Danny Yoo
> > The point of this restructuring is to allow you to add more image > > types without too much pain, since there's no more hardcoded array > > indexing against r1. It also simplifies to calls to imgreg from: > > > > if imgreg(r1[0],a) == 1: > > continue > > if imgreg(r1[1],a) =

Re: [Tutor] code improvement for beginner ?

2005-10-10 Thread Kent Johnson
Roel Schroeven wrote: > Danny Yoo wrote: > >>Looking at pageimgs(): I'm not sure what 't' means in the open statement: >> >> f = open(filename, "rt") > > It's not a typo. 't' opens the file in text mode. Are you sure? Is that documented anywhere? Text mode is the default, you have to spec

Re: [Tutor] code improvement for beginner ?

2005-10-10 Thread lmac
Danny Yoo wrote: > > On Sat, 8 Oct 2005, lmac wrote: > > >>Ok. Here we go. Wanted to start my page long ago. Now is the right time. >> >>http://daderoid.freewebspace24.de/python/python1.html > > > Hi lmac, > > I'll pick out some stuff that I see; I'm sure others will be happy to give > commen

Re: [Tutor] code improvement for beginner ?

2005-10-09 Thread Roel Schroeven
Danny Yoo wrote: > Looking at pageimgs(): I'm not sure what 't' means in the open statement: > > f = open(filename, "rt") > > and I think that 't' might be a typo: I'm surprised that Python doesn't > complain. Can anyone confirm this? I think you may have tried to do "r+" > mode, but even

Re: [Tutor] code improvement for beginner ?

2005-10-08 Thread Danny Yoo
On Sat, 8 Oct 2005, lmac wrote: > Ok. Here we go. Wanted to start my page long ago. Now is the right time. > > http://daderoid.freewebspace24.de/python/python1.html Hi lmac, I'll pick out some stuff that I see; I'm sure others will be happy to give comments too. I'll try to make sure that all

Re: [Tutor] code improvement for beginner ?

2005-10-08 Thread lmac
Ok. Here we go. Wanted to start my page long ago. Now is the right time. http://daderoid.freewebspace24.de/python/python1.html Thank you. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] code improvement for beginner ?

2005-10-08 Thread Danny Yoo
On Sat, 8 Oct 2005, lmac wrote: > i wonder if i could post some of my scripts and anyone can tell me if > there is a better way for coding the problem. In the way of some > teaching class. ;-) Sure, that's perfectly fine. If the script is very large, you may want to post it on the web and sen

[Tutor] code improvement for beginner ?

2005-10-08 Thread lmac
Hi there, i wonder if i could post some of my scripts and anyone can tell me if there is a better way for coding the problem. In the way of some teaching class. ;-) Or is this mailing-list only for specific questions ? Thanks. ___ Tutor maillist - Tu