Re: [Tutor] lib2to3 fixers

2010-06-12 Thread Steven D'Aprano
On Sat, 12 Jun 2010 05:27:39 am Zubin Mithra wrote: > Hey everyone, > > I just discovered that the following construct does not work in Py3k. > > >>> string.maketrans('-', '_') Like the error message says, you have to use bytes, which I grant is counter-intuitive, but it does work: >>> table =

Re: [Tutor] Better construct? (was no subject)

2010-06-12 Thread Luke Paireepinart
> >> ## Can someone suggest a pythonesque way of doing this? >> >> >> def getid(): >>    response  = raw_input('prompt') >>    if response not in [ "", "y", "Y", "yes"] : >>        getid()    # ouch >>    print "continue working" >>    # do more stuff >>    # do more stuff >> This seems like really

Re: [Tutor] Python a substitute/alternative for PhP?

2010-06-12 Thread Eldon Londe Mello Junior
Hi there, Just would like to thanks all of those who provided me with some insight about which ways to go about programming. I'll consider every single piece of advice. I would also like to apologize for I didn't mean to hijack no thread, that was just so stupid of me. As I'm finishing my PhP

[Tutor] OT: Great find!

2010-06-12 Thread Eike Welk
On Saturday June 12 2010 20:22:03 Wayne Werner wrote: > I want to do something like this: > http://www.kulturblog.com/2007/11/marshie-attacks-halloween-interactive-dri > veway-activity/ Great find! That's a very nice idea! Eike. ___ Tutor maillist -

Re: [Tutor] Better construct? (was no subject)

2010-06-12 Thread bob gailer
On 6/12/2010 3:59 PM, Alan Gauld wrote: "bob gailer" wrote You can collect functions in a sequence, then iterate over it. This allows for easy expansion (when you decide to add another function). funcs = (dosomething(), dosomethingelse()) I suspect Bob meant to leave off the (). Yep. T

Re: [Tutor] Problems with Importing into the Python Shell

2010-06-12 Thread Alan Gauld
"Andrew Martin" wrote am having some trouble. First off, I do not understand how to import things into the python shell. I have a script I saved as chap03.py, but when I try to import it into the python shell i get an error like this: from chap03 import * Traceback (most recent call last

Re: [Tutor] Tutor Digest, Vol 76, Issue 31

2010-06-12 Thread Alan Gauld
Please do not send the entire digest when replying rto a single email. Use your editor to remove the redundant material. "saurabh agrawal" wrote You can use method name count in list also for getting the repeats. #!/usr/bin/python li=[1,2,3,1,4,5,7,3,4,1] for i in range(l

Re: [Tutor] Adding line numbers to a Python Script

2010-06-12 Thread Alan Gauld
"Sudip Bhattacharya" wrote for line in fileinput.input(inplace = true)(2) line = line.rstrip()(3) num=fileinput.lineno()..(4) print '%-40s #%2i' %(line,num).(5) Line (3) - Are we stri

Re: [Tutor] Better construct? (was no subject)

2010-06-12 Thread Alan Gauld
"bob gailer" wrote You can collect functions in a sequence, then iterate over it. This allows for easy expansion (when you decide to add another function). funcs = (dosomething(), dosomethingelse()) I suspect Bob meant to leave off the (). You would normally just use the function name. (Un

Re: [Tutor] New to Programming

2010-06-12 Thread Alan Gauld
"Kaushal Shriyan" wrote I am absolutely new to programming language. Dont have any programming experience. Can some one guide me please. is python a good start for novice. Yes, it is one of the best languages for an absolute beginner. It may be all the language you ever need but even if you

Re: [Tutor] Python a substitute/alternative for PhP?

2010-06-12 Thread Alan Gauld
"Eldon Londe Mello Junior" wrote First, please don't hijack an existing thread, this message appears under a thread about Zope DB! Always post a new message to start a new thread. It will get more readers and not confuse readers using threaded mail/newsreaders. However, I've been reading a lot

Re: [Tutor] Tutor Digest, Vol 76, Issue 31

2010-06-12 Thread saurabh agrawal
Hi, You can use method name count in list also for getting the repeats. #!/usr/bin/python li=[1,2,3,1,4,5,7,3,4,1] for i in range(len(li)):     print li[i], li.count(li[i]) cheers, Saurabh --- On Fri, 11/6/10, tutor-requ...@python.org wrote: From: tutor-requ...@python.org Subject: Tutor

[Tutor] Linux webcam libraries?

2010-06-12 Thread Wayne Werner
Hi, I want to do something like this: http://www.kulturblog.com/2007/11/marshie-attacks-halloween-interactive-driveway-activity/ I want to be able to grab a webcam image via python. So I'm curious if anyone has had any experience/luck in this particular area and/or knows of any libraries I should

Re: [Tutor] Python a substitute/alternative for PhP?

2010-06-12 Thread Juan Jose Del Toro
2010/6/11 Alex Hall > Personally, I would learn Python. My college does not offer Python > either, so I had to learn what I know on my own(of course, by that I > mean constantly pestering this and other of the amazing Python email > lists). PHP is fine in itself, but, after using it, Java, and in

Re: [Tutor] Better construct? (was no subject)

2010-06-12 Thread bob gailer
On 6/11/2010 5:12 PM, Advertising Department wrote: Please supply a meaningful subject. #!/Library/Frameworks/Python.framework/Versions/Current/bin/pythonw """still thinking in imperative" """ ## obviously this is a bad construct. Why is it "obvious"? What is "this"? Are you referring to t

Re: [Tutor] winsound.Beep(500,500) "Failed to beep"

2010-06-12 Thread Alex Hall
Not that it helps much, but using win7x64 and Python 2.6 it works as expected. Possibly your sound card? Update drivers? On 6/12/10, Richard D. Moores wrote: import winsound winsound.Beep(500,500) > Traceback (most recent call last): > File "", line 1, in > RuntimeError: Failed to be

Re: [Tutor] Looking for duplicates within a list

2010-06-12 Thread Peter Otten
Ken G. wrote: > I have been working on this problem for several days and I am not making > any progress. I have a group of 18 number, in ascending order, within a > list. They ranged from 1 to 39. Some numbers are duplicated as much as > three times or as few as none. > > I started with one li

[Tutor] Adding line numbers to a Python Script

2010-06-12 Thread Sudip Bhattacharya
I quote this example (and the problem that I am facing trying to understand) from the book "Beginning Python - From Novice to Professional" by Magnus Lie Hetland Page 227 # numberlines.py import fileinput(1) for line in fileinput.input(inplace = true)(2) li

Re: [Tutor] New to Programming

2010-06-12 Thread Dave Angel
Kaushal Shriyan wrote: Hi, I am absolutely new to programming language. Dont have any programming experience. Can some one guide me please. is python a good start for novice. Thanks, Kaushal Like nearly all questions, the answer is "it depends." Mainly, it depends on what your goal is.

[Tutor] New to Programming

2010-06-12 Thread Kaushal Shriyan
Hi, I am absolutely new to programming language. Dont have any programming experience. Can some one guide me please. is python a good start for novice. Thanks, Kaushal ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription option

Re: [Tutor] (no subject)

2010-06-12 Thread Jose Amoreira
On Friday, June 11, 2010 10:12:27 pm Advertising Department wrote: > #!/Library/Frameworks/Python.framework/Versions/Current/bin/pythonw > """still thinking in imperative" > """ > > ## obviously this is a bad construct. > ## Can someone suggest a pythonesque way of doing this? > > > def getid():

[Tutor] winsound.Beep(500,500) "Failed to beep"

2010-06-12 Thread Richard D. Moores
>>> import winsound >>> winsound.Beep(500,500) Traceback (most recent call last): File "", line 1, in RuntimeError: Failed to beep >>> Vista, Python 3.1 Any ideas? Dick Moores ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscrip

[Tutor] (no subject)

2010-06-12 Thread Advertising Department
#!/Library/Frameworks/Python.framework/Versions/Current/bin/pythonw """still thinking in imperative" """ ## obviously this is a bad construct. ## Can someone suggest a pythonesque way of doing this? def getid(): response = raw_input('prompt') if response not in [ "", "y", "Y",

[Tutor] lib2to3 fixers

2010-06-12 Thread Zubin Mithra
Hey everyone, I just discovered that the following construct does not work in Py3k. >>> string.maketrans('-', '_') However, the following works, >>> str.maketrans('-', '_') When i try to convert a python module containing the above construct, it does not get modified in a way such that it coul

Re: [Tutor] Problems with Importing into the Python Shell

2010-06-12 Thread Steven D'Aprano
On Sat, 12 Jun 2010 02:50:26 pm Andrew Martin wrote: > >>> from chap03 import * > > Traceback (most recent call last): > File "", line 1, in > from chap03 import * > File "C:/Python26\chap03.py", line 2 > print param param > ^ > SyntaxError: invalid syntax This te

Re: [Tutor] Problems with Importing into the Python Shell

2010-06-12 Thread Mark Lawrence
On 12/06/2010 05:50, Andrew Martin wrote: Hey, everyone, I am new to programming and just downloaded Python 2.6 onto my windows vista laptop. I am attempting to follow 4.11 of the tutorial called "How to Think Like a Computer Scientist: Learning with Python v2nd Edition documentation" ( http://op