Re: Great Python books for the beginner

2008-01-13 Thread Graeme Glass
class as well. The text book for this class is Python for the > Absolute Beginner or something similar to that name. > > I was wondering if anyone had any opinions on what other titles I > could look into since this one seems from a glance at reviews to be > teaching mainly th

Re: Great Python books for the beginner

2008-01-12 Thread Dick Moores
book for this class is Python for the >Absolute Beginner or something similar to that name. > >I was wondering if anyone had any opinions on what other titles I >could look into since this one seems from a glance at reviews to be >teaching mainly through game programming (a topic I'm

Re: Great Python books for the beginner

2008-01-12 Thread [EMAIL PROTECTED]
On 12 jan, 21:04, Landon <[EMAIL PROTECTED]> wrote: > One thing I wonder about is the examples these books use to teach the > concepts. I found myself really attached to K&R because the end of > section projects were utilities that I would find be able to find > useful in day to day work such as a

Re: Great Python books for the beginner

2008-01-12 Thread André
On Jan 12, 4:04 pm, Landon <[EMAIL PROTECTED]> wrote: > One thing I wonder about is the examples these books use to teach the > concepts. I found myself really attached to K&R because the end of > section projects were utilities that I would find be able to find > useful in day to day work such as

Re: Great Python books for the beginner

2008-01-12 Thread Landon
One thing I wonder about is the examples these books use to teach the concepts. I found myself really attached to K&R because the end of section projects were utilities that I would find be able to find useful in day to day work such as a version of wc and a program that would take collapse all con

Re: Great Python books for the beginner

2008-01-12 Thread GeneralCody
> the class as well. The text book for this class is Python for the > Absolute Beginner or something similar to that name. > > I was wondering if anyone had any opinions on what other titles I > could look into since this one seems from a glance at reviews to be > teaching mainl

Re: Great Python books for the beginner

2008-01-12 Thread babycode
On Jan 12, 2:03 am, Landon <[EMAIL PROTECTED]> wrote: > I was wondering if anyone had any opinions on what other titles I > could look into since this one seems from a glance at reviews to be > teaching mainly through game programming (a topic I'm not too > interested in) or if this one is a quali

Re: Great Python books for the beginner

2008-01-12 Thread Mike
On Jan 12, 7:47 am, Ben Finney <[EMAIL PROTECTED]> wrote: > Landon <[EMAIL PROTECTED]> writes: > > I was wondering if anyone had any opinions on what other titles I > > could look into since this one seems from a glance at reviews to be > > teaching mainly through game programming (a topic I'm not

Re: Great Python books for the beginner

2008-01-12 Thread sween119
class as well. The text book for this class is Python for the > Absolute Beginner or something similar to that name. > > I was wondering if anyone had any opinions on what other titles I > could look into since this one seems from a glance at reviews to be > teaching mainly th

Re: Great Python books for the beginner

2008-01-12 Thread Ben Finney
Landon <[EMAIL PROTECTED]> writes: > I was wondering if anyone had any opinions on what other titles I > could look into since this one seems from a glance at reviews to be > teaching mainly through game programming (a topic I'm not too > interested in) or if this one is a quality book by itself.

Re: Great Python books for the beginner

2008-01-12 Thread Jim
Look at http://www.python.org/doc/ . The tutorial is quite good. Jim -- http://mail.python.org/mailman/listinfo/python-list

Great Python books for the beginner

2008-01-11 Thread Landon
Hi, I'm a freshman in college and I'm going to be taking an intro to programming course next semester which mainly uses Python, so I thought it might be a good time to pick up Python beyond the scope of the class as well. The text book for this class is Python for the Absolute B

Re: Beginner question!

2007-12-21 Thread Bruno Desthuilliers
SMALLp a écrit : (snip) > One more question. How does my code looks like. I couldn't find any open > source program written in python You must be jocking ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question!

2007-12-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Dec 21, 9:11 am, SMALLp <[EMAIL PROTECTED]> wrote: > (snip) >>class insertData: >>def insert(self, dataTable, data): (snip) > > I think you need to post the real traceback or the real code since > your error message doesn't look like it has anything to do

Re: Beginner question!

2007-12-21 Thread kyosohma
On Dec 21, 1:44 pm, SMALLp <[EMAIL PROTECTED]> wrote: > Carsten Haese wrote: > > On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote: > sql ="INSERT INTO "+dataTable+" (user_name, file_name, > file_size, > file_path_local, file_path_FTP, curent_location, FTP_valid_time,

Re: Beginner question!

2007-12-21 Thread SMALLp
Carsten Haese wrote: > On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote: sql ="INSERT INTO "+dataTable+" (user_name, file_name, file_size, file_path_local, file_path_FTP, curent_location, FTP_valid_time, uploaded, last_modified, last_verified, file_type, file_cat

Re: Beginner question!

2007-12-21 Thread Carsten Haese
On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote: > >> sql ="INSERT INTO "+dataTable+" (user_name, file_name, > >> file_size, > >> file_path_local, file_path_FTP, curent_location, FTP_valid_time, > >> uploaded, last_modified, last_verified, file_type, file_category) VLAUES > >> "+da

Re: Beginner question!

2007-12-21 Thread SMALLp
[EMAIL PROTECTED] wrote: >> Traceback (most recent call last): >>File "/home/pofuk/MzMFIleShare/sharePanel.py", line 130, in share >> self.scanDirsAndFiles(dirPath) >>File "/home/pofuk/MzMFIleShare/sharePanel.py", line 158, in >> scanDirsAndFiles >> sql.insertData.insert("files",

Re: Beginner question!

2007-12-21 Thread kyosohma
> Traceback (most recent call last): >File "/home/pofuk/MzMFIleShare/sharePanel.py", line 130, in share > self.scanDirsAndFiles(dirPath) >File "/home/pofuk/MzMFIleShare/sharePanel.py", line 158, in > scanDirsAndFiles > sql.insertData.insert("files", data) > TypeError: unbound met

Re: Beginner question!

2007-12-21 Thread Chris Mellon
On Dec 21, 2007 9:11 AM, SMALLp <[EMAIL PROTECTED]> wrote: > Hy! I have error something like this > > TypeError: unbound method insert() must be called with insertData > instance as first argument (got str instance instead) > > CODE: > > File1.py > sql.insertData.insert("files", data) > > sql.py >

Re: Beginner question!

2007-12-21 Thread SMALLp
[EMAIL PROTECTED] wrote: > On Dec 21, 9:11 am, SMALLp <[EMAIL PROTECTED]> wrote: >> Hy! I have error something like this >> >> TypeError: unbound method insert() must be called with insertData >> instance as first argument (got str instance instead) >> >> CODE: >> >> File1.py >> sql.insertData.inse

Re: Beginner question!

2007-12-21 Thread kyosohma
On Dec 21, 9:11 am, SMALLp <[EMAIL PROTECTED]> wrote: > Hy! I have error something like this > > TypeError: unbound method insert() must be called with insertData > instance as first argument (got str instance instead) > > CODE: > > File1.py > sql.insertData.insert("files", data) > > sql.py > > cla

Beginner question!

2007-12-21 Thread SMALLp
Hy! I have error something like this TypeError: unbound method insert() must be called with insertData instance as first argument (got str instance instead) CODE: File1.py sql.insertData.insert("files", data) sql.py class insertData: def insert(self, dataTable, data):

Re: Omitting results with id3reader [Beginner]

2007-12-05 Thread Ionis
Thank you for your help, it is really appreciated. I'll post back if there are any more problems. -- http://mail.python.org/mailman/listinfo/python-list

Re: Omitting results with id3reader [Beginner]

2007-12-05 Thread Bruno Desthuilliers
Ionis a écrit : > Hey guys, hope you can help me here. I've been playing with python for > about a week or two and I've been reading "A Byte Of Python" to get me > on my feet. I've decided to write a program which will list all ID3 > information in a directory of .mp3 files into a .html file. > >

Re: Omitting results with id3reader [Beginner]

2007-12-05 Thread Chris
On Dec 5, 2:04 pm, Ionis <[EMAIL PROTECTED]> wrote: > On Dec 5, 11:59 am, Chris <[EMAIL PROTECTED]> wrote: > > > Ok, just noticed you linked the id3reader. I tested my code and it > > worked fine. > > Thanks alot Chris. Could you comment your code so I can see what each > line is doing? I hope tha

Re: Omitting results with id3reader [Beginner]

2007-12-05 Thread Ionis
On Dec 5, 11:59 am, Chris <[EMAIL PROTECTED]> wrote: > Ok, just noticed you linked the id3reader. I tested my code and it > worked fine. Thanks alot Chris. Could you comment your code so I can see what each line is doing? I hope that isn't a problem. Still pretty new to python. -- http://mail.py

Re: Omitting results with id3reader [Beginner]

2007-12-05 Thread Chris
Ok, just noticed you linked the id3reader. I tested my code and it worked fine. -- http://mail.python.org/mailman/listinfo/python-list

Re: Omitting results with id3reader [Beginner]

2007-12-05 Thread Chris
On Dec 5, 1:43 pm, Ionis <[EMAIL PROTECTED]> wrote: > Hey guys, hope you can help me here. I've been playing with python for > about a week or two and I've been reading "A Byte Of Python" to get me > on my feet. I've decided to write a program which will list all ID3 > information in a directory of

Omitting results with id3reader [Beginner]

2007-12-05 Thread Ionis
Hey guys, hope you can help me here. I've been playing with python for about a week or two and I've been reading "A Byte Of Python" to get me on my feet. I've decided to write a program which will list all ID3 information in a directory of .mp3 files into a .html file. The python script I'm using

Re: Python beginner!

2007-11-18 Thread Asun Friere
On Nov 17, 12:41 am, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > It is true that I could have been way more polite. I don't see how. You said "please" read it. You didn't make fun of the poor spelling and said nothing rude. I can't agree that the response "reeks of arrogance." I've seen

Re: which Python ? asks beginner

2007-11-18 Thread Donn Ingle
>> You know, I've always wanted ask; if plans are afoot, what are hands? > The answer, seeing as it's late, is that whisky is at hand. Ha. Brilliant answer! It also explains decorators :D /d -- http://mail.python.org/mailman/listinfo/python-list

Re: which Python ? asks beginner

2007-11-18 Thread Hendrik van Rooyen
"Donn Ingle" wrote: > > plans are afoot > You know, I've always wanted ask; if plans are afoot, what are hands? > > :D > > Sorry, it's late. The answer, seeing as it's late, is that whisky is at hand. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: Python beginner!

2007-11-18 Thread John Salerno
[EMAIL PROTECTED] wrote: > On Nov 15, 2:38 pm, "SMALLp" <[EMAIL PROTECTED]> wrote: >> Could someone please paste some program in wxPython that uses inharitance. I >> would be very thankfull. > > Most examples of wxPython use inheritance. I would recommend going to > their website and downloading t

Re: Python beginner!

2007-11-18 Thread Brandon Sandrowicz
On 11/16/07, Shawn Milochik <[EMAIL PROTECTED]> wrote: > I completely support Wildemar. Lazy questions like that deserve absolutely > nothing. > > I agree that cushioning the reply with a brief explanation of why that > question sucks would have helped the original poster, but he doesn't deserve >

Re: which Python ? asks beginner

2007-11-17 Thread John Salerno
Dave WB3DWE wrote: > Have given up Java. Want to switch to Python. But _which_ ? > There is ver : > 2.5 out now > 2.6 in beta , final expected Apr 2008 > 3.0 ? in alpha or beta > 3.0 final expected Sep 2008 ? > Will the real python please stand up. > Thanks, Dave WB3DW

Re: which Python ? asks beginner

2007-11-17 Thread [EMAIL PROTECTED]
On Nov 17, 4:20 pm, Dave WB3DWE wrote: > Have given up Java. Want to switch to Python. But _which_ ? > There is ver : > 2.5 out now > 2.6 in beta , final expected Apr 2008 > 3.0 ? in alpha or beta > 3.0 final expected Sep 2008 ? > Will the real python please stand up. > T

Re: which Python ? asks beginner

2007-11-17 Thread Donn Ingle
> plans are afoot You know, I've always wanted ask; if plans are afoot, what are hands? :D Sorry, it's late. /d -- http://mail.python.org/mailman/listinfo/python-list

Re: which Python ? asks beginner

2007-11-17 Thread Simon Brunning
On Nov 17, 2007 6:20 PM, <[EMAIL PROTECTED]> wrote: > Have given up Java. Want to switch to Python. Welcome! > But _which_ ? > There is ver : > 2.5 out now > 2.6 in beta , final expected Apr 2008 You should go for 2.5.1 unless you have a reason to stick to an older version. (Such re

Re: which Python ? asks beginner

2007-11-17 Thread Scott SA
On 11/17/07, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: >Have given up Java. Want to switch to Python. But _which_ ? >There is ver : > 2.5 out now > 2.6 in beta , final expected Apr 2008 > 3.0 ? in alpha or beta > 3.0 final expected Sep 2008 ? >Will the real python please s

Re: which Python ? asks beginner

2007-11-17 Thread Paul McGuire
On Nov 17, 12:20 pm, Dave WB3DWE wrote: > Have given up Java. Want to switch to Python. But _which_ ? > There is ver : > 2.5 out now > 2.6 in beta , final expected Apr 2008 > 3.0 ? in alpha or beta > 3.0 final expected Sep 2008 ? This is not for us to decide, but rather fo

which Python ? asks beginner

2007-11-17 Thread Dave
Have given up Java. Want to switch to Python. But _which_ ? There is ver : 2.5 out now 2.6 in beta , final expected Apr 2008 3.0 ? in alpha or beta 3.0 final expected Sep 2008 ? Will the real python please stand up. Thanks, Dave WB3DWE [EMAIL PROTECTED] -- http://

Re: Python beginner!

2007-11-16 Thread Shawn Milochik
I completely support Wildemar. Lazy questions like that deserve absolutely nothing. I agree that cushioning the reply with a brief explanation of why that question sucks would have helped the original poster, but he doesn't deserve any effort from any of us until he has shown evidence of his own e

Re: Python beginner!

2007-11-16 Thread Wildemar Wildenburger
Tony wrote: > On Nov 15, 8:57 pm, Wildemar Wildenburger > Give me back the old comp.lang.python, where anyone could ask anything > and be sure of a range of replies, instead of this sort of > pedanticism. Sorry, nothing personal, maybe Python users have become > too professional and geeky to rememb

Re: Python beginner!

2007-11-15 Thread kyosohma
On Nov 15, 2:38 pm, "SMALLp" <[EMAIL PROTECTED]> wrote: > Could someone please paste some program in wxPython that uses inharitance. I > would be very thankfull. Most examples of wxPython use inheritance. I would recommend going to their website and downloading the demo as it has lots of code to l

Re: Python beginner!

2007-11-15 Thread Tony
On Nov 15, 8:38 pm, "SMALLp" <[EMAIL PROTECTED]> wrote: > Could someone please paste some program in wxPython that uses inharitance. I > would be very thankfull. HI SMALLp: welcome to Python! Here is a link that shows some basics of inheritance in Wx, try other searches on Google:) http://www.ib

Re: Python beginner!

2007-11-15 Thread Tony
On Nov 15, 8:57 pm, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > > Please read this: > http://www.catb.org/~esr/faqs/smart-questions.html> > > Then ask again. > > /W Give me back the old comp.lang.python, where anyone could ask anything and be sure of a range of replies, instead of this sort

Re: Python beginner!

2007-11-15 Thread Wildemar Wildenburger
SMALLp wrote: > Could someone please paste some program in wxPython that uses inharitance. I > would be very thankfull. > Please read this: http://www.catb.org/~esr/faqs/smart-questions.html> Then ask again. /W -- http://mail.python.org/mailman/listinfo/python-list

Python beginner!

2007-11-15 Thread SMALLp
Could someone please paste some program in wxPython that uses inharitance. I would be very thankfull. -- http://mail.python.org/mailman/listinfo/python-list

Re: concise code (beginner)

2007-09-10 Thread Gabriel Genellina
> "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> Why not just build a new list? E.g. >> >>newdevs = [] >>for dev in devs : >>... >>if not removing_dev : >>newdevs.append(dev) >>#end if >>#end for >>devs =

Re: concise code (beginner)

2007-09-10 Thread Gabriel Genellina
"Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Why not just build a new list? E.g. newdevs = [] for dev in devs : ... if not removing_dev : newdevs.append(dev) #end if #end for devs = newdevs En Sun, 09 Sep 2007 22:58

Re: concise code (beginner)

2007-09-10 Thread Paul Rudin
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > On Mon, 10 Sep 2007 17:42:16 +1000, bambam wrote: > >> "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in >> message news:[EMAIL PROTECTED] >>> In message <[EMAIL PROTECTED]>, bambam wrote: >>> Thank you, >>> >>> Don't top-post. >> >> I h

Re: concise code (beginner)

2007-09-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Sep 2007 17:42:16 +1000, bambam wrote: > "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] >> In message <[EMAIL PROTECTED]>, bambam wrote: >> >>> Thank you, >> >> Don't top-post. > > I have a number of news readers here, but all of them work > better

Re: concise code (beginner)

2007-09-10 Thread Lawrence D'Oliveiro
A: Skid-marks in front of the hedgehog. Q: What's the difference between a dead hedgehog on the road, and a dead top-poster on the road? -- http://mail.python.org/mailman/listinfo/python-list

Re: concise code (beginner)

2007-09-10 Thread Francesco Guerrieri
On 9/10/07, bambam <[EMAIL PROTECTED]> wrote: > > I have a number of news readers here, but all of them work > better with top-posting, and in none of them is top posting > a problem. What software are you using? > > Steve. > I use gmail and I can assure you that top posting is annoying. france

Re: concise code (beginner)

2007-09-10 Thread bambam
I have a number of news readers here, but all of them work better with top-posting, and in none of them is top posting a problem. What software are you using? Steve. "Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In message <[EMAIL PROTECTED]>, bambam wrot

Re: concise code (beginner)

2007-09-09 Thread Alex Martelli
bambam <[EMAIL PROTECTED]> wrote: > > O(n) to find the element you wish to remove and move over > > everything after it, > > Is that how lists are stored in cPython? It seems unlikely? So-called "lists" in Python are stored contiguously in memory (more like "vectors" in some other languages), so

Re: concise code (beginner)

2007-09-09 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, bambam wrote: > Thank you, Don't top-post. -- http://mail.python.org/mailman/listinfo/python-list

Re: concise code (beginner)

2007-09-09 Thread bambam
I can try that, but I'm not sure that it will work. The problem is that devList is just a pointer to a list owned by someone else. Making devList point to a new list won't work: I need to make the parent list different. I could do this by adding an extra level of indirection, but I think at the ris

Re: concise code (beginner)

2007-09-09 Thread bambam
I'm testing a series of scripts. The scripts are testing a series of hardware devices. The scripts are a sequence of device commands. The scripts have sequence numbers. I am adding exception handling to the to the 'inner platform' that executes sequences. I am doing this because testing of error

Re: concise code (beginner)

2007-09-09 Thread bambam
> Removing from a list while you iterate will had quadratic performance Anecdote: I was doing a route-finding program for a railway ticketing system. My replacement explained to my boss that it couldn't be done: the problem was one of that class of problems that has no good optimum solution. M

Re: concise code (beginner)

2007-09-07 Thread Rhamphoryncus
On Sep 6, 1:56 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > That said, it may be a good future language enhancement to define a > reasonable consistent behavior for an iterator over a changing > collection. This occurs quite common when we walk a collection and > usually delete the current ite

Re: concise code (beginner)

2007-09-06 Thread Michele Simionato
On Sep 6, 7:44 am, "bambam" <[EMAIL PROTECTED]> wrote: > First, thank you. > > All of the suggestions match what we want to do much better > than what we are doing. We have a script, written in python, > which is doing testing. But the python script doesn't look anything > like the test script, bec

Re: concise code (beginner)

2007-09-06 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, bambam wrote: > The devices are in a list, and are removed by using pop(i). This > messes up the loop iteration, so it is actually done by setting a > flag on each device in the exception handler, with ANOTHER > loop after each write/read/calculate sequence. Why no

Re: concise code (beginner)

2007-09-06 Thread Steven D'Aprano
On Fri, 07 Sep 2007 12:03:26 +1000, bambam wrote: > Hi Steven. > > Looking at your code, why are you naming the value __all__? It looks > like a built-in variable? When you say: from module import * Python looks in the module for a list of names called "__all__", and imports only the names in

Re: concise code (beginner)

2007-09-06 Thread bambam
Hi Steven. Looking at your code, why are you naming the value __all__? It looks like a built-in variable? Unless there is an automatic way to correctly get the function list, I will probably be better off giving the lines sequence numbers, and generating the function list from that. Steve. "Ste

Re: concise code (beginner)

2007-09-06 Thread Karthik Gurusamy
On Sep 5, 1:37 pm, James Stroud <[EMAIL PROTECTED]> wrote: > Karthik Gurusamy wrote: > > On Sep 5, 11:17 am, James Stroud <[EMAIL PROTECTED]> wrote: > > >> for i in xrange(number_of_reads): > >>for dev in devs: > >> try: > >>_reader = getattr(dev, 'read%d' % i) > >>_reader(

Re: concise code (beginner)

2007-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2007 15:44:57 +1000, bambam wrote: > First, thank you. > > All of the suggestions match what we want to do much better than what we > are doing. We have a script, written in python, which is doing testing. > But the python script doesn't look anything like the test script, > becaus

Re: concise code (beginner)

2007-09-06 Thread Marc 'BlackJack' Rintsch
On Thu, 06 Sep 2007 15:44:57 +1000, bambam wrote: > def script(self) > def a0010(): global self; self.power_on([self.dev]); > def a0020(): global self; self.dev.addLog([self.name, ' started']); > def a0030(): global self; self.resetMinuteReg([self.dev]); > def a0040(): global self;

Re: concise code (beginner)

2007-09-05 Thread bambam
First, thank you. All of the suggestions match what we want to do much better than what we are doing. We have a script, written in python, which is doing testing. But the python script doesn't look anything like the test script, because the python script is written in python, and the test script i

Re: concise code (beginner)

2007-09-05 Thread Francesco Guerrieri
On 9/5/07, James Stroud <[EMAIL PROTECTED]> wrote: > > > Another way is to make a copy of devs, if devs is short, which makes my > > When I process something of that genre (e.g. files) I prefer not to lose trace of what's happened by removing the "bad items". Instead I prefer to flag or otherwise

Re: concise code (beginner)

2007-09-05 Thread James Stroud
Karthik Gurusamy wrote: > On Sep 5, 11:17 am, James Stroud <[EMAIL PROTECTED]> wrote: >> >> for i in xrange(number_of_reads): >>for dev in devs: >> try: >>_reader = getattr(dev, 'read%d' % i) >>_reader() >> except Exception, e: >>print e >>devs.remove(

Re: concise code (beginner)

2007-09-05 Thread Daniel Larsson
On 9/5/07, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > > On Sep 5, 11:17 am, James Stroud <[EMAIL PROTECTED]> wrote: > > bambam wrote: > > > I have about 30 pages (10 * 3 pages each) of code like this > > > (following). Can anyone suggest a more compact way to > > > code the exception handling? I

Re: concise code (beginner)

2007-09-05 Thread Karthik Gurusamy
On Sep 5, 11:17 am, James Stroud <[EMAIL PROTECTED]> wrote: > bambam wrote: > > I have about 30 pages (10 * 3 pages each) of code like this > > (following). Can anyone suggest a more compact way to > > code the exception handling? If there is an exception, I need > > to continue the loop, and conti

Re: concise code (beginner)

2007-09-05 Thread James Stroud
bambam wrote: > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > > --- > f

Re: concise code (beginner)

2007-09-05 Thread Bruno Desthuilliers
bambam a écrit : > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > > ---

Re: concise code (beginner)

2007-09-05 Thread Wesley Brooks
Sorry, just seen a mistake in my code, however Diez beat me to what I was actually thinking! Wes On 05/09/07, Wesley Brooks <[EMAIL PROTECTED]> wrote: > Try adding all the functions into a list such as; > > funcList = [dev.read1, dev.read2, dev.read3] > > for func in funcList: >for dev in dev

Re: concise code (beginner)

2007-09-05 Thread Francesco Guerrieri
On 9/5/07, bambam <[EMAIL PROTECTED]> wrote: > > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > >

Re: concise code (beginner)

2007-09-05 Thread Daniel Larsson
def process_devs(devs, fun): for dev in devs: try: fun(dev) except: print exception remove dev from devs return devs process_devs(devs, lambda d: d.read1()) process_devs(devs, lambda d: d.read2()) ... On 9/5/07, bambam <[EMAIL PROTECT

Re: concise code (beginner)

2007-09-05 Thread Wesley Brooks
Try adding all the functions into a list such as; funcList = [dev.read1, dev.read2, dev.read3] for func in funcList: for dev in devs: try: func() except: print exception remove dev from devs Wes. On 05/09/07, bambam <[EMAIL PROTECTED]> wrote: >

Re: concise code (beginner)

2007-09-05 Thread Diez B. Roggisch
bambam wrote: > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > > --- >

concise code (beginner)

2007-09-05 Thread bambam
I have about 30 pages (10 * 3 pages each) of code like this (following). Can anyone suggest a more compact way to code the exception handling? If there is an exception, I need to continue the loop, and continue the list. Steve. --- for dev in devs try:

Re: beginner, idomatic python 2

2007-08-31 Thread Bruno Desthuilliers
bambam a écrit : > "Bruno Desthuilliers" <[EMAIL PROTECTED]> > wrote in message news:[EMAIL PROTECTED] >> As a side note, in Python, inheritance ... >> ... should usually not be used for typing. > > :~( > I'm sorry, I don't even know what that means... The code I > have inherited from someone onl

Re: beginner, idomatic python 2

2007-08-30 Thread Neil Cerutti
On 2007-08-31, bambam <[EMAIL PROTECTED]> wrote: > "Bruno Desthuilliers" > <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] >> As a side note, in Python, inheritance ... ... should usually >> not be used for typing. > >:~( > I'm sorry, I don't even know what that means... The code I ha

Re: beginner, idomatic python 2

2007-08-30 Thread bambam
"Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > As a side note, in Python, inheritance ... > ... should usually not be used for typing. :~( I'm sorry, I don't even know what that means... The code I have inherited from someone only a little more knowledgeabl

Re: beginner, idomatic python 2

2007-08-30 Thread bambam
Thank you. I'm glad to see that I don't need to choose between two opposing viewpoints :~) Steve. -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner, idiomatic python

2007-08-27 Thread Paul Rubin
Neil Cerutti <[EMAIL PROTECTED]> writes: > i = 0 > while i < self.parent.GetPageCount(): > # do stuff > i += 1 Alternatively: from itertools import count for i in count(): if i >= self.parent.GetPageCount(): break ... -- http://mail.python.org/mailman/listinfo

Re: beginner, idiomatic python

2007-08-27 Thread Neil Cerutti
On 2007-08-27, Neil Cerutti <[EMAIL PROTECTED]> wrote: > This sort of suggests a direct solution: > > for i in xrange(self.parent.GetPageCount()): > if i >= self.parent.GetPageCount(): > break > # do stuff > > At least that way you're spared the manual manipulation of i. On second thought,

Re: beginner, idiomatic python

2007-08-27 Thread Neil Cerutti
On 2007-08-27, bambam <[EMAIL PROTECTED]> wrote: > Thank you, I have been through the tutorial several times, I > guess I'm just not smart enough. Perhaps I have been led astray > by what I read here? > > My code started like this: > > for i in range(self.parent.GetPageCount()): > > I was asked: >

Re: beginner, idiomatic python

2007-08-27 Thread Bruno Desthuilliers
bambam a écrit : > Thank you, I have been through the tutorial several times, I guess > I'm just not smart enough. Perhaps I have been led astray by what > I read here? > > My code started like this: > > for i in range(self.parent.GetPageCount()): > > I was asked: > >> Does page count change? i

Re: beginner, idomatic python 2

2007-08-27 Thread Bruno Desthuilliers
bambam a écrit : Steve, could you please stop top-posting ?-) TIA > "Dan Bishop" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Aug 23, 10:21 pm, "bambam" <[EMAIL PROTECTED]> wrote: >>> Would someone like to suggest a replacement for this? This is a >>> function that return

Re: beginner, idomatic python 2

2007-08-27 Thread Steve Holden
bambam wrote: [but he top-posted] > "Dan Bishop" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Aug 23, 10:21 pm, "bambam" <[EMAIL PROTECTED]> wrote: >>> Would someone like to suggest a replacement for this? This is a >>> function that returns different kinds of similar object

Re: beginner, idiomatic python

2007-08-26 Thread bambam
Thank you. I figured the set would probably be faster, but the lists are small, and I'm concerned that the code is going to look Byzantine if I keep swapping between lists, sets and dictionaries :~). At the moment there are no sets or dictionaries in the entire code base I am working with. I'm not

Re: beginner, idiomatic python

2007-08-26 Thread bambam
Thank you. Steve. "Alex Martelli" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > bambam <[EMAIL PROTECTED]> wrote: > >> Is it safe to write >> >> A = [x for x in A if x in U] >> >> or is that undefined? I understand that the slice operation > > It's perfectly safe and well-defined

Re: beginner, idiomatic python

2007-08-26 Thread Paul Rubin
"bambam" <[EMAIL PROTECTED]> writes: > Is it safe to write > A = [x for x in A if x in U] > or is that undefined? I understand that the slice operation > can be used to make a temporary copy, so I could write > A=[x for x in A[:] if x in U] > but I've just copied that without any understanding. Yo

Re: beginner, idiomatic python

2007-08-26 Thread Alex Martelli
bambam <[EMAIL PROTECTED]> wrote: ... > Bags don't seem to be built in to my copy of Python, and A "bag" is a collections.defaultdict(int) [[you do have to import collections -- it's in the standard library, NOT built-in]]. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner, idomatic python 2

2007-08-26 Thread bambam
Thank you. I didn't reply earlier because I was trying to get my head around what you wrote, which was strange and foreign to me. It seems to me that the dictionary object you suggested is a direct replacement for the function code, only more efficient because the case table is internalised with a

Re: beginner, idiomatic python

2007-08-26 Thread Alex Martelli
bambam <[EMAIL PROTECTED]> wrote: > Is it safe to write > > A = [x for x in A if x in U] > > or is that undefined? I understand that the slice operation It's perfectly safe and well-defined, as the assignment rebinds the LHS name only AFTER the RHS list comprehension is done. Alex -- http://

Re: beginner, idiomatic python

2007-08-26 Thread bambam
Is it safe to write A = [x for x in A if x in U] or is that undefined? I understand that the slice operation can be used to make a temporary copy, so I could write A=[x for x in A[:] if x in U] but I've just copied that without any understanding. Steve. "bambam" <[EMAIL PROTECTED]> wrote in

Re: beginner, idiomatic python

2007-08-26 Thread bambam
Thank you, I have been through the tutorial several times, I guess I'm just not smart enough. Python is quite different from the languages I am familiar with. My code sample started like this: >>for i in range(self.parent.GetPageCount()): I was asked: >Does page count change? i.e. is it necessa

<    5   6   7   8   9   10   11   12   13   14   >