Re: [Tutor] Syntax error help

2012-03-30 Thread S.Irfan Rizvi
Please remove me from listi can't do itthey are doing it Attention On Mar 30, 2012 9:21 PM, "bob gailer" wrote: > Please always reply-all so a copy goes to the list. > > On 3/30/2012 8:01 PM, chris knarvik wrote: > >> that was incomplete it was supposed to be ive fixed most of my problems

Re: [Tutor] Syntax error help

2012-03-30 Thread bob gailer
Please always reply-all so a copy goes to the list. On 3/30/2012 8:01 PM, chris knarvik wrote: that was incomplete it was supposed to be ive fixed most of my problems with your help That's great. Would you post the correct program so we can all learn? And possibly make other helpful suggestio

Re: [Tutor] Problem Stripping

2012-03-30 Thread bob gailer
Then, of course, there's "15:45".replace(':','') -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Problem Stripping

2012-03-30 Thread Mark Lawrence
On 30/03/2012 18:28, Joel Goldstick wrote: On Fri, Mar 30, 2012 at 1:25 PM, Joel Goldstick wrote: On Fri, Mar 30, 2012 at 1:09 PM, leam hall wrote: Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters but it doesn't seem to work like I thought. res = subprocess.Popen(['uname

Re: [Tutor] Syntax error help

2012-03-30 Thread bob gailer
On 3/30/2012 6:20 PM, x23ch...@gmail.com wrote: Thanks I've fixed Great. Please share with us your new program and tell us what you do to run it. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] Syntax error help

2012-03-30 Thread x23ch...@gmail.com
Thanks I've fixed Sent from my iPod On Mar 30, 2012, at 5:30 PM, bob gailer wrote: > On 3/30/2012 4:26 PM, chris knarvik wrote: >> Alright i have been trying to right a (relatively) simple to calculate area >> and volume below is my current working code > > Suggestion: start with a VERY SIMPL

Re: [Tutor] New to this list ....

2012-03-30 Thread Emile van Sebille
On 3/30/2012 2:41 PM Barry Drake said... On 30/03/12 19:18, Cranky Frankie wrote: Here's what you need - he starts simple and winds up with some nice games: http://www.amazon.com/Python-Programming-Absolute-Beginner-Edition/dp/1435455002/ref=sr_1_6?ie=UTF8&qid=1333131438&sr=8-6 If you have

Re: [Tutor] Syntax error help

2012-03-30 Thread Modulok
On 3/30/12, chris knarvik wrote: > Alright i have been trying to right a (relatively) simple to calculate area > and volume below is my current working code > def areamenu(): > print 'Square (1)' > print 'triangle (2)' > print 'rectangle (3)' > print 'trapazoid (4)' > print 'ci

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 19:18, Cranky Frankie wrote: Here's what you need - he starts simple and winds up with some nice games: http://www.amazon.com/Python-Programming-Absolute-Beginner-Edition/dp/1435455002/ref=sr_1_6?ie=UTF8&qid=1333131438&sr=8-6 Wow! I found an e-book copy online and got it. Looks go

Re: [Tutor] Syntax error help

2012-03-30 Thread bob gailer
On 3/30/2012 4:26 PM, chris knarvik wrote: Alright i have been trying to right a (relatively) simple to calculate area and volume below is my current working code Suggestion: start with a VERY SIMPLE program and get that working. Then add one new feature at a time. Is the following in Area.p

Re: [Tutor] What to call a string with embedded descriptor?

2012-03-30 Thread Tim Johnson
* Emile van Sebille [120330 12:21]: <> >If the string above is split on the first occurance of '|', > >the result is a 'leftmost' component which can be decomposed into a > >nested list of integers which can then be used to parse the > >'rightmost' string into a dictionary. > > > >What would b

Re: [Tutor] Syntax error help

2012-03-30 Thread Evert Rol
> Alright i have been trying to right a (relatively) simple to calculate area > and volume below is my current working code > def areamenu(): > print 'Square (1)' > print 'triangle (2)' > print 'rectangle (3)' > print 'trapazoid (4)' > print 'circle (5)' > > def squareacalc():

[Tutor] Syntax error help

2012-03-30 Thread chris knarvik
Alright i have been trying to right a (relatively) simple to calculate area and volume below is my current working code def areamenu(): print 'Square (1)' print 'triangle (2)' print 'rectangle (3)' print 'trapazoid (4)' print 'circle (5)' def squareacalc(): sidelength = inp

Re: [Tutor] What to call a string with embedded descriptor?

2012-03-30 Thread Emile van Sebille
On 3/30/2012 11:57 AM Tim Johnson said... This is kind of a theoretical question. I.E. I am looking for a keyword to do research on. Consider the following string: '3:2,6:2,4:3,5:0|age50height63nametimvalue' If the string above is split on the first occurance of '|', the result is a 'leftmost'

Re: [Tutor] What to call a string with embedded descriptor?

2012-03-30 Thread Emile van Sebille
On 3/30/2012 12:57 PM S.Irfan Rizvi said... please help me disable this...i made big mistake searching your site note that at the bottom of every email you're getting from this list has a link to the unsubscribe page... ___ Tutor maillist -

Re: [Tutor] What to call a string with embedded descriptor?

2012-03-30 Thread S.Irfan Rizvi
please help me disable this...i made big mistake searching your site On Fri, Mar 30, 2012 at 1:57 PM, Tim Johnson wrote: > This is kind of a theoretical question. I.E. I am looking for a > keyword to do research on. > Consider the following string: > > '3:2,6:2,4:3,5:0|age50height63nametimva

[Tutor] New to this list ....

2012-03-30 Thread Cranky Frankie
Message: 1 Date: Fri, 30 Mar 2012 15:04:09 +0100 Barry Drake wrote: << I'm getting a Raspberry-pi for our local Junior school and am starting to learn Python so I can show the year five and year six kids how to write simple games.>> Here's what you need - he starts simple and winds up with some

[Tutor] What to call a string with embedded descriptor?

2012-03-30 Thread Tim Johnson
This is kind of a theoretical question. I.E. I am looking for a keyword to do research on. Consider the following string: '3:2,6:2,4:3,5:0|age50height63nametimvalue' If the string above is split on the first occurance of '|', the result is a 'leftmost' component which can be decomposed into a nes

Re: [Tutor] New to this list ....

2012-03-30 Thread Russel Winder
Barry, On Fri, 2012-03-30 at 18:27 +0100, Barry Drake wrote: > On 30/03/12 17:58, Mark Lawrence wrote: > > The recipe here > > http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ > > > > > > refers to several other recipes which you might want to take a

Re: [Tutor] New to this list ....

2012-03-30 Thread Emile van Sebille
On 3/30/2012 10:56 AM Prasad, Ramit said... Lists are mutable objects. When you pass a list to a function you bind a name in the functions namespace to the list object. Every name binding to that object will have the ability to modify the list. If you want to modify the list but not change it f

Re: [Tutor] Problem Stripping

2012-03-30 Thread Prasad, Ramit
> strip(...) > S.strip([chars]) -> string or unicode > > Return a copy of the string S with leading and trailing > whitespace removed. > If chars is given and not None, remove characters in chars instead. > If chars is unicode, S will be converted to unicode before strippi

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
[snip] >I'm used to c > variables going out of scope once you leave the called function. I > imagine if you want to leave the variables unchanged, you have to > re-assign them inside the function. [snip] Lists are mutable objects. When you pass a list to a function you bind a name in the functi

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 17:22, Prasad, Ramit wrote: Unlike C, the parenthesis in if statements and returns are not necessary. Furthermore, the way Python binds names means that modifying the list in getflags modifies it in the callee. No need to return and reassign results. This is lovely. It's so much

Re: [Tutor] Problem Stripping

2012-03-30 Thread Mark Lawrence
On 30/03/2012 18:09, leam hall wrote: Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters but it doesn't seem to work like I thought. What do you expect it to do? res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) uname = res.stdout.read().strip() uname 'Linu

Re: [Tutor] Problem Stripping

2012-03-30 Thread Joel Goldstick
On Fri, Mar 30, 2012 at 1:25 PM, Joel Goldstick wrote: > On Fri, Mar 30, 2012 at 1:09 PM, leam hall wrote: >> Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters >> but it doesn't seem to work like I thought. >> >> >> res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE)

Re: [Tutor] Problem Stripping

2012-03-30 Thread Emile van Sebille
On 3/30/2012 10:09 AM leam hall said... Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters but it doesn't seem to work like I thought. ... but it works as advertised... Help on built-in function strip: strip(...) S.strip([chars]) -> string or unicode Return a copy o

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 17:58, Mark Lawrence wrote: The recipe here http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ refers to several other recipes which you might want to take a look at, sorry I meant to mention this earlier. Oh, that's neat. Not worth

Re: [Tutor] Problem Stripping

2012-03-30 Thread Prasad, Ramit
> Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters > but it doesn't seem to work like I thought. > > > res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) > uname = res.stdout.read().strip() > > >>> uname > 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:

Re: [Tutor] Problem Stripping

2012-03-30 Thread Joel Goldstick
On Fri, Mar 30, 2012 at 1:09 PM, leam hall wrote: > Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters > but it doesn't seem to work like I thought. > > > res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) > uname = res.stdout.read().strip() > uname > 'Linux myse

Re: [Tutor] Problem Stripping

2012-03-30 Thread Evert Rol
> Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters > but it doesn't seem to work like I thought. > > > res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) > uname = res.stdout.read().strip() > uname > 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09

[Tutor] Problem Stripping

2012-03-30 Thread leam hall
Python 2.4.3 on Red Hat 5. Trying to use strip to remove characters but it doesn't seem to work like I thought. res = subprocess.Popen(['uname', '-a'], stdout=subprocess.PIPE) uname = res.stdout.read().strip() >>> uname 'Linux myserver 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011 i686 i6

Re: [Tutor] New to this list ....

2012-03-30 Thread Mark Lawrence
On 30/03/2012 15:04, Barry Drake wrote: One of the few c things I miss is the switch/case statement. if and elif in it's place is a bit cumbersome. Still, it works. The recipe here http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ refers to severa

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
> [...] > > C switch is just a different way of doing an if/elif tree, I do not > > really see any real difference. Although, if there is you can feel free > > to enlighten me. :) > [...] > > 'fraid not -- though it depends on which compiler and how many cases. > For 3 or more cases compilers will

Re: [Tutor] New to this list ....

2012-03-30 Thread Russel Winder
Ramit, On Fri, 2012-03-30 at 16:22 +, Prasad, Ramit wrote: [...] > C switch is just a different way of doing an if/elif tree, I do not > really see any real difference. Although, if there is you can feel free > to enlighten me. :) [...] 'fraid not -- though it depends on which compiler and

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
> Furthermore, the way Python binds names means that modifying the list > in getflags modifies it in the callee. No need to return and reassign > results. I correct myself. It has nothing to do with name binding, but entirely to do with Python's object model. Ramit Ramit Prasad | JPMorgan Chas

Re: [Tutor] New to this list ....

2012-03-30 Thread Prasad, Ramit
> > Hi there I've just joined this list and thought I'd introduce myself. Welcome! > > correct = 0 > > match = 0 > > wrong = 0 > > results = [correct, match, wrong] > > > > results = getflag(flag_1, results) > > results = getflag(flag_2, results) > > results = get

Re: [Tutor] New to this list ....

2012-03-30 Thread Peter Otten
Barry Drake wrote: > On 30/03/12 16:19, Evert Rol wrote: >> Not sure. In the sense that you can "optimise" (refactor) it in the same >> way you could do with C. Eg: results = [0, 0, 0] >> flags = [0, 1, 2, 3] >> for flag in flags: >> results = getflag(flag, results) >> > > That's exactly wha

Re: [Tutor] New to this list ....

2012-03-30 Thread Russel Winder
Barry, On Fri, 2012-03-30 at 16:42 +0100, Barry Drake wrote: [...] > def getflag(thisflag, results): > if (thisflag == 2): > results[0] += 1 > elif (thisflag == 1): > results[1] += 1 > elif (thisflag == 0): > results[2] += 1 > return(results) Two tho

[Tutor] problem with key in mailbox.Maildir

2012-03-30 Thread Kantesh Raj
hi everyone, i am not able to get email from my mailbox by using key. key is automatically removed after program termination but file is present there. i get data by same code method by using fresh key (which is generated by adding email again) import mailbox mailb = mailbox.Maildir('~/Maildir',fa

Re: [Tutor] New to this list ....

2012-03-30 Thread Asokan Pichai
On Fri, Mar 30, 2012 at 9:12 PM, Barry Drake wrote: > On 30/03/12 16:19, Evert Rol wrote: >> >> Not sure. In the sense that you can "optimise" (refactor) it in the same >> way you could do with C. Eg: >> results = [0, 0, 0] >> flags = [0, 1, 2, 3] >> for flag in flags: >>     results = getflag(fla

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 16:19, Evert Rol wrote: Not sure. In the sense that you can "optimise" (refactor) it in the same way you could do with C. Eg: results = [0, 0, 0] flags = [0, 1, 2, 3] for flag in flags: results = getflag(flag, results) That's exactly what I hoped for. I hadn't realised I can

Re: [Tutor] New to this list ....

2012-03-30 Thread Mark Lawrence
On 30/03/2012 15:13, Barry Drake wrote: On 30/03/12 15:04, Barry Drake wrote: One of the things I wanted to do is to use a four integer array to get four integers returned from a function. I ended up using what I think is a list. (I'm not really sure of the datatypes yet). This is what I Pleas

Re: [Tutor] New to this list ....

2012-03-30 Thread Evert Rol
Hi and welcome Barry, > One of the things I wanted to do is to use a four integer array to get four > integers returned from a function. I ended up using what I think is a list. > (I'm not really sure of the datatypes yet). This is what I did, and it > works, but looks very inelegant to me:

Re: [Tutor] New to this list ....

2012-03-30 Thread Barry Drake
On 30/03/12 15:04, Barry Drake wrote: One of the things I wanted to do is to use a four integer array to get four integers returned from a function. I ended up using what I think is a list. (I'm not really sure of the datatypes yet). This is what I did, and it works, but looks very inelegant

[Tutor] New to this list ....

2012-03-30 Thread Barry Drake
Hi there I've just joined this list and thought I'd introduce myself. I used to be fairly competent in c but never made the grade to c++. I've done very little programming in the last couple of years or so. I'm getting a Raspberry-pi for our local Junior school and am starting to learn