Re: [Tutor] Better structure?

2005-02-03 Thread Alan Gauld
> > Try writing the code to do what lstrip actually does > > - its much harder. So the library includes the more > > difficult function and lets you code the easy ones. > > def lstrip(string,chars=' ') > string = list(string) > t = 0 > for x in string: > if x in chars: >

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> Just wondering if I should bite the bullet and code from scratch in > Perl, or if my Python - Perl is Ok. Its nearly always a bad idea to just translate code structures from one language to another. It will usually be sub optimal and non idiomatic - thus harder for the 'native' programmers to un

[Tutor] Re: Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Wolfram Kraus
Alan Gauld wrote: [...] 1) I'll use Perl for the regex stuff from now on, Perl is obviously built for this. Yes, or PHP. Both have RE baked in. Beware! Overcome the temptation! Try this: http://kodos.sourceforge.net/ HTH ;-) Wolfram ___ Tutor maillist -

Re: [Tutor] Re: Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Patrick Hall
> Beware! Overcome the temptation! > Try this: http://kodos.sourceforge.net/ While I have no problem personally with Perl or PHP, I'll second the recommendation for kodos -- it's very useful for learning to use regexes in Python. ___ Tutor maillist - T

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> > How's Ruby? I bookmarked the homepage, but never got around to looking > > at it. > > Very, very nice. Cleanest object-orientedness I ever saw in a language > (not that I have that much experience -- people like Alan would > probably be better judges than me on this). You knew I couldn't resis

Re: [Tutor] Re: Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Kent Johnson
Patrick Hall wrote: Beware! Overcome the temptation! Try this: http://kodos.sourceforge.net/ While I have no problem personally with Perl or PHP, I'll second the recommendation for kodos -- it's very useful for learning to use regexes in Python. Or, if you don't have Qt available, use the regular

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Max Noel
On Feb 3, 2005, at 09:48, Alan Gauld wrote: Pythons lambda feature is a bare minimum (and Guido wants to remove it!). Does he? Damn, just when I was learning functional programming! (in Haskell, if you're curious ^^) Yes the Japanese thing is an issue. THere are a few English books now, and the

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread R. Alan Monroe
> code to run it on a different platform. But most existing Java projects > have platform-specific versions, if only to make the GUI (try to) look > native. You can spot a Java app from a hundred meters away. > (then again, the same critic could be made of Python's and Perl's > "standard

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Nicholas . Montpetit
Well, here's my $0.02.   I would recommend caution regarding the trashing of Perl.  One thing I've been very impressed with on this list (and other segments of the Python community) is the _fairly_ cordial relationship between the supporters of the two languages.  Contrast that to a lot of PHP li

[Tutor] i have a question???

2005-02-03 Thread alieks laouhe
This is from a tutorial "EXERCISE 3.9 Use the math library to write a program to print out the sin and cos of numbers from 0 to 2pi in intervals of pi/6. You will need to use the range() function." Range won't let me use pi/6 as an incremator is there some other way i can accomplish this task

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Nicholas . Montpetit
> (I am an ex-perler gone clean. Been straight for 5 years now with only > the occasional work forced binges.) > > Perl was designed by a linguist. He wanted it to act like human language > -- which is not very consistent. And from what I gather, quite effective.  :-)   > Personally, the thin

Re: [Tutor] i have a question???

2005-02-03 Thread Michael Janssen
On Thu, 3 Feb 2005 05:53:31 -0800 (PST), alieks laouhe <[EMAIL PROTECTED]> wrote: > This is from a tutorial > > "EXERCISE 3.9 > Use the math library to write a program to print out > the sin and cos of numbers from 0 to 2pi in intervals > of pi/6. You will need to use the range() function." > >

Re: [Tutor] i have a question???

2005-02-03 Thread Pierre Barbier de Reuille
Michael Janssen a écrit : On Thu, 3 Feb 2005 05:53:31 -0800 (PST), alieks laouhe <[EMAIL PROTECTED]> wrote: This is from a tutorial "EXERCISE 3.9 Use the math library to write a program to print out the sin and cos of numbers from 0 to 2pi in intervals of pi/6. You will need to use the range() fun

RE: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Smith, Jeff
Title: Message Nicholas,   Well put.  I come from a physics FORTRAN background and when I decided to learn C and start using it I heard the same arguments: it's too hard to read.   It's a silly argument to use against a language.  It's like an English-only speaker claiming he won't learn Gr

RE: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Nicholas . Montpetit
Hi Jeff, > Well put.  I come from a physics FORTRAN background and when I > decided to learn C and start using it I heard the same arguments: > it's too hard to read. >   > It's a silly argument to use against a language.  It's like an > English-only speaker claiming he won't learn Greek becau

Re: [Tutor] i have a question???

2005-02-03 Thread Michael Janssen
[the problem provided by alieks] > >>"EXERCISE 3.9 > >>Use the math library to write a program to print out > >>the sin and cos of numbers from 0 to 2pi in intervals > >>of pi/6. You will need to use the range() function." [Michael] > > You _can_ do the exercise > > with the range function but it

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Marilyn Davis
I once heard that Larry Wall said, "Perl is worse than Python because people needed it worse". And I've heard it said that "Perl is the Write-Only language" Marilyn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] got it

2005-02-03 Thread alieks laouhe
i came up with z=0 while z<= 2*pi: z=z+pi/6 print z z=z+pi/6 "while" makes alot more sense than using range i still don't know if its the most efficient way to do it this is day two with python, im pushing 30hrs straight lots of coffee and ciggarettes! So far I really like python...alot. it's

Re: [Tutor] got it

2005-02-03 Thread Kent Johnson
alieks laouhe wrote: i came up with z=0 while z<= 2*pi: z=z+pi/6 print z z=z+pi/6 I don't think you're quite there. You are incrementing by pi/6 twice in the loop, so the printed values will differ by pi/3. And the first value printed will be pi/6, not 0. Where are you getting the value of p

[Tutor] oops.

2005-02-03 Thread alieks laouhe
sorry way off heh... i think i'll sleep and try later. __ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 ___ Tutor maillist - Tutor

Re: [Tutor] Better structure?

2005-02-03 Thread Alan Gauld
> >for x in string: > >if x in chars: > >string[i] = '' > > I just have a hangover from other languages, but I really wanted to know > how Python handles iteration over a variable which is being changed > within the loop itself. Is the "for" condition evaluated in every loo

[Tutor] v.00001

2005-02-03 Thread alieks laouhe
from math import * z=0 while z<=2*pi: print cos(z) z=z+(pi/6) ok i think this is right... __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail _

Re: [Tutor] got it

2005-02-03 Thread Max Noel
On Feb 3, 2005, at 18:17, alieks laouhe wrote: So far I really like python...alot. it's so intuitive I started trying to learn c but it's lack of intuitive string handling made me shudder... so, i tried perl and it was a breath of fresh air after c. then i stumbled upon python. it's the most intuit

[Tutor] In-place changes on loops

2005-02-03 Thread Danny Yoo
On Thu, 3 Feb 2005, Sandip Bhattacharya wrote: > >for x in string: > >if x in chars: > >string[i] = '' > > I just have a hangover from other languages, but I really wanted to know > how Python handles iteration over a variable which is being changed > within the loop itse

Re: [Tutor] In-place changes on loops

2005-02-03 Thread Danny Yoo
> But let's change it to what I think you were thinking of: > > ### > def lstrip(string, chars): > scratchspace = list(string) ## get a mutable list of characters > for x in scratchspace: > if x in chars: > scratchspace[i] = '' > return ''.join(scratchspace)

Re: [Tutor] v.00001

2005-02-03 Thread Danny Yoo
On Thu, 3 Feb 2005, alieks laouhe wrote: > from math import * > z=0 > while z<=2*pi: > print cos(z) > z=z+(pi/6) > > ok i think this is right... Hi Alieks, This looks ok, and is probably the most straightforward way to do this. For safety's sake, you may want to modify the top i

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Sean Perry
[EMAIL PROTECTED] wrote: Btw, I'm skeptical that the code below does what you want it to do. :-) that was kind of my point. In python I just type the obvious and it works. In Perl I have to muck with references, slashes, arrows and the like. Every time I have had to write a nested datastructu

Re: [Tutor] Re: Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Bill Mill
On Thu, 3 Feb 2005 04:24:06 -0500, Patrick Hall <[EMAIL PROTECTED]> wrote: > > Beware! Overcome the temptation! > > Try this: http://kodos.sourceforge.net/ > > While I have no problem personally with Perl or PHP, I'll second the > recommendation for kodos -- it's very useful for learning to use >

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Nicholas . Montpetit
> [EMAIL PROTECTED] wrote: > > > > > > Btw, I'm skeptical that the code below does what you want it to do.  :-) > >   > > that was kind of my point. In python I just type the obvious and it > works. In Perl I have to muck with references, slashes, arrows and the > like. Every time I have ha

Re: [Tutor] i have a question???

2005-02-03 Thread Jacob S.
From what I understand, range() no longer allows you to use floats as arguments. (Or it gives you a deprication warning) This tutorial must be old. Not the only way, but. import math num = 0 while num <= 2*math.pi: ## Do stuff to figure pi/6 things num = num + math.pi/6.0 ## Don't forget .

Re: [Tutor] Better structure?

2005-02-03 Thread Jacob S.
You can also iterate over a copy of the list and change the original. i.e. a = range(10) for x in a[:]: if x % 2 == 0: a.remove(x) print a And yes, I did test it this time. Jacob >for x in string: >if x in chars: >string[i] = '' I just have a hangover from other

Re: [Tutor] v.00001

2005-02-03 Thread Jacob S.
I should have thought of that! Here I looked at the concept of generators, what they can do, and totally overlooked a user defined range type function that allows floats. Any reason why range doesn't? Is it for speed, or to keep the arguments pure (without floating point errors)? Jacob There ar

[Tutor] Ogg Tag Module recommendations

2005-02-03 Thread Miles Stevenson
Can anyone recommend to me a Python module to work with ID3v2 tags in Ogg Vorbis files? I tried using the EyeD3 module, but it only supports mp3 right now, and I couldn't get the pyid3tag module to work reliably, or I'm just not understanding the documentation. I just need to retrieve all of th

Re: [Tutor] i have a question???

2005-02-03 Thread Mike Bell
>num = num + math.pi/6.0 ## Don't forget .0 or you'll get an integer the division operator returns a float when either of the operands are floats -- in this case math.pi is, so you don't have to worry about passing it 6.0 instead of 6 >>> import math >>> math.pi 3.1415926535897931 >>> math.

Re: [Tutor] Ogg Tag Module recommendations

2005-02-03 Thread Sean Perry
Miles Stevenson wrote: Can anyone recommend to me a Python module to work with ID3v2 tags in Ogg Vorbis files? I tried using the EyeD3 module, but it only supports mp3 right now, and I couldn't get the pyid3tag module to work reliably, or I'm just not understanding the documentation. I just nee

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Jacob S.
MessageI hate to be a spoiled sport and do exactly what you said to not do. But I present two counter examples 1. The indentation IS the closure on flow statements. Indenting starts a flow, then removing indentation on next line closes the flow. Again its all about the language. If your English

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Jeff Shannon
Max Noel wrote: On Feb 3, 2005, at 09:48, Alan Gauld wrote: Pythons lambda feature is a bare minimum (and Guido wants to remove it!). Does he? Damn, just when I was learning functional programming! (in Haskell, if you're curious ^^) However, Python doesn't need lambdas to be able to write in

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Sean Perry
Jeff Shannon wrote: However, Python doesn't need lambdas to be able to write in a functional style. Functions are first-class objects and can be passed around quite easily, and IIRC Python's list comprehensions were borrowed (though probably with notable modification) from Haskell. Note, it is

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> > For the non-Perl people here, let me defend Perl by saying it is > > VERY good at what it was built for and not so good (but passable) at > > what it was not built for. > > > > What it is good at: > > Very rapid development of small scripts > > Replacing sed/awk/ksh/etc for scripting >

RE: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Smith, Jeff
Jacob, As I said I'm well aware of the defense of these peculiarities of Python but I still disagree with them from a language design choice. That doesn't stop me from learning and using and enjoying Python but I feel that both of them introduce some instability to the langauge. In only 6 months

RE: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Smith, Jeff
Alan, We'll just have to have to disagree about awk. I starting learning Perl to avoid learning awk :-) I also disagree about the symbology. I am never confused by it. In fact, I find it clarifies the language although I agree its ugly. When I see a random variable in Perl I can tell at a gla

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Max Noel
On Feb 3, 2005, at 22:21, Smith, Jeff wrote: Perl and Python both resist the introduction of a switch statement which I (and many others) feel is the most elegant way to express what it does. I echo that. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 "Look at you hacker... A pathetic crea

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> I also disagree about the symbology. I am never confused by it. I'll believe you, but its interesting that computer scientists have done lots of studies to test people's comprehension of programs and in every single case there has been clear evidence that additional prefixes/characters etc

RE: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Smith, Jeff
I think the point is that different people are...different. It probably won't surprise you to find out that I am in the C camp that prefers your second example. I'm sure what those studies show is what the "majority" find easier not what "everyone" finds easier. Who knows, maybe it's a left-brai

RE: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread lumbricus
> Alan, > > We'll just have to have to disagree about awk. I starting learning Perl > to avoid learning awk :-) But awk is smaller and simpler than perl. So it should be faster (esp. at startup) for small and simple tasks. As usual: Right tool for right task. > Jeff ___ Greetings, J

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> haskell: > > [ x | x <- xs ] > [ foo x | x <- xs, x > 2 ] > > python > > [ x for x in xs ] > [ foo(x) for x in xs if x > 2 ] > Sean, what book/tutor are you using for Haskell? I learned it from "The Haskell School of Expression" which was OK but very graphics focused, I'd be interested in

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> Perl and Python both resist the introduction of a switch statement > which I (and many others) feel is the most elegant way to express > what it does. Interesting. What do you feel is the problem with elif? Its not even much more typing and allows for much more expressive test conditions. Swi

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> We'll just have to have to disagree about awk. > I starting learning Perl to avoid learning awk :-) Really? Why for? awk is far easier to learn than Perl - and far less generally capable! - but it makes Perl seem positively verbose! Alan G. ___ Tu

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Jeff Shannon
Alan Gauld wrote: There is no perfect language, and very few truly bad languages - they never get out of the lab - they all have something that they are good at and from which we can learn! Heh, I'd look at that a bit differently -- I think that there's a *lot* of bad languages, it's just that we'

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> second example. I'm sure what those studies show is what the "majority" > find easier not what "everyone" finds easier. They are statistical its true, but they were based on the folks who actually used the second style indent and they actually got worse scores in the tests using their own style

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Max Noel
On Feb 3, 2005, at 23:19, Alan Gauld wrote: Sean, what book/tutor are you using for Haskell? I learned it from "The Haskell School of Expression" which was OK but very graphics focused, I'd be interested in recommended second source on Haskell. I'm not Sean, but I'm using Simon Thompson's "Haskell

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Max Noel
On Feb 3, 2005, at 23:41, Jeff Shannon wrote: (But then, at my job I'm stuck using a horrible Frankenstein's monster of a proprietary language on a daily basis, so I can't help but believe that there's plenty more awful languages around that didn't happen to be "rescued" from oblivion by an acci

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Max Noel
On Feb 3, 2005, at 23:41, Alan Gauld wrote: The reasons for the K&R style of brace winning is to do with the way the brain process structure and despite the subjects stated preference for the 'Pascal' style they still had lower perception scores. Little nit-picking here: if(foo) { bar()

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Jeff Shannon
Alan Gauld wrote: However, Python doesn't need lambdas to be able to write in a functional style. I disagree Jeff. It does need lambdas to do FP properly, and better lambdas than we have currently. What it doesn't need is the lambda keyword and syntax - although pesonally I like lambda since it is

Re: [Tutor] i have a question???

2005-02-03 Thread Jacob S.
Sorry, over paranoid. ;-) Jacob num = num + math.pi/6.0 ## Don't forget .0 or you'll get an integer the division operator returns a float when either of the operands are floats -- in this case math.pi is, so you don't have to worry about passing it 6.0 instead of 6 import math math.pi 3.14159

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Liam Clarke
>I suppose that one might argue that I *still* just don't really get >lambdas (and I wouldn't argue with that). I can see some advantages >to small inline functions, though I suspect that a more-explicit >currying mechanism (such as the proposed partial() higher-order >function) could easily repla

Re: [Tutor] Better structure?

2005-02-03 Thread Liam Clarke
Alan said - > Its bad practice to delete a member in the collection being iterated > but Python copes OK if you just change the current item. Yeah, that's very bad. Makes for all sorts of subtle errors. I usually do the iteration as a for i in range(len(someList) type thing, and collect the indexe

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Bud Rogers
On Thursday 03 February 2005 17:41, Alan Gauld wrote: > In fact the best style of all is neither of the two I showed, > its actually this - which early everyone hates when they see it! > > inf f(x) >     { >     bah() >     } Ugh. Alan, I won't even try to dispute the study. But if I have to wr

Re: [Tutor] Better structure?

2005-02-03 Thread Jacob S.
Although, (and this will be rough) a list comprehension would be probably do the same thing j=[1, 2,3,4, 5,6,7,8] q = [if not item % 2 for item in j] I really think I've got that 'if not item % 2' wrong, as I can't test it, but I'd be hoping for print q [1, 3, 5, 7] Backwards. ;-) q = [item for it

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Jeff Shannon
Max Noel wrote: On Feb 3, 2005, at 23:41, Jeff Shannon wrote: (But then, at my job I'm stuck using a horrible Frankenstein's monster of a proprietary language on a daily basis, so I can't help but believe that there's plenty more awful languages around that didn't happen to be "rescued" from obl

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Chad Crabtree
How about a concrete example where lambda is more elegant than a named block of code aList=['a','bb','ccc','','ee'] bList=aList[:] #deep copy assert not bList is aList def sortByLength(item1,item2): return cmp(len(item1),len(item2)) bList.sort(sortByLength) assert bList==['a', 'bb', 'ee

[Tutor] This Deletes All my Files

2005-02-03 Thread Chad Crabtree
I've tried this and I cannot figure out why this does not work. I figure this has something to do with order of operations. I figured someone would know exactly why it doesn't work. Wouldn't this start inside parens then from left to right? open(item,'w').write(open(item,'r').read().replace(

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Alan Gauld
> >> Pythons lambda feature is a bare minimum (and Guido wants to remove > >> it!). > However, Python doesn't need lambdas to be able to write in a > functional style. I disagree Jeff. It does need lambdas to do FP properly, and better lambdas than we have currently. What it doesn't need is the l