[Tutor] Python Beginners

2011-06-08 Thread Vincent Balmori
Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says "Improve 'WordJumble so that each word is paired with a hint. The player should be able to see the hint if he or she

Re: [Tutor] Python Beginners

2011-06-08 Thread Válas Péter
Since you have jumbled the word in the same variable, you have a very small chance (1:len(word)! which is 1:120 for a five-letter word) to have any of the given words in the variable "word" whan your program reaches the yellow part. You shold try to use "correct" instead of "word" in the yellow if.

Re: [Tutor] if statement

2011-06-08 Thread Steven D'Aprano
Matthew Brunt wrote: i'm very new to python (currently going through a python for beginners book at work to pass the time), and i'm having trouble with an if statement exercise. basically, i'm creating a very simple password program that displays "Access Granted" if the if statement is true. the

Re: [Tutor] Python Beginners

2011-06-08 Thread Steven D'Aprano
Vincent Balmori wrote: Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says "Improve 'WordJumble so that each word is paired with a hint. The player should be able to se

Re: [Tutor] Python Beginners

2011-06-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Vincent Balmori wrote: Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says "Improve 'WordJumble so that each word is paired with a hint. The pl

Re: [Tutor] Python Beginners

2011-06-08 Thread Steven D'Aprano
Dave Angel wrote: On 01/-10/-28163 02:59 PM, Vincent Balmori wrote: Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says "Improve 'WordJumble so that each word is paired

Re: [Tutor] Copying a mutable

2011-06-08 Thread Steven D'Aprano
Válas Péter wrote: Being one of the purposes of Python to be a simple educational language, I want to make this simple to a beginner who does care. :-) Here is a piece of code, Python 3.1.2, a small game with a list and a tuple: li=[3,4] id(li) 13711200 la=li id(la) 13711200 You can make

Re: [Tutor] Copying a mutable

2011-06-08 Thread col speed
I think this is easily seen by a for loop: for something in range(20): print something In the above "something" is a variable, in this case an int(which is immutable). However, "something" is changed every time it goes through the loop. It's the equivalent of: x = 0 x = 1 x = 2 and so on Just

Re: [Tutor] Copying a mutable

2011-06-08 Thread Walter Prins
2011/6/8 Válas Péter > As far as I understand, assignment means giving a value to a variable which > is the expression used by classical languages that have variables (such as > Pascal or Basic). Python has no variables, since even the simpliest data is > an object, but we still say assignment, b

[Tutor] lxml.html

2011-06-08 Thread nitin chandra
Hello Every One, doc = lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot() name = doc.forms[0].fields['name'] html = 'name is ' html += name ERROR [Wed Jun 08 20:29:51 2011] [error] [client 192.168.1.9] Traceback (most recent call last): [Wed Jun 08 2

Re: [Tutor] lxml.html

2011-06-08 Thread Steven D'Aprano
nitin chandra wrote: Hello Every One, doc = lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot() name = doc.forms[0].fields['name'] html = 'name is ' html += name ERROR [Wed Jun 08 20:29:51 2011] [error] [client 192.168.1.9] Traceback (most recent ca

Re: [Tutor] lxml.html

2011-06-08 Thread Jerry Hill
On Wed, Jun 8, 2011 at 11:20 AM, nitin chandra wrote: > Hello Every One, > >         doc = lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot() Is index.py really an XML document? If so, it's named pretty oddly... -- Jerry ___ Tutor maillist

Re: [Tutor] lxml.html

2011-06-08 Thread Joel Goldstick
On Wed, Jun 8, 2011 at 11:49 AM, Jerry Hill wrote: > On Wed, Jun 8, 2011 at 11:20 AM, nitin chandra > wrote: > > Hello Every One, > > > > doc = > lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot() > > Is index.py really an XML document? If so, it's named pretty oddly... > > --

[Tutor] Q

2011-06-08 Thread Vincent Balmori
For the Absolute Beginner 3rd Edition book, I am having trouble with another question, which says "create a game where the computer picks a random word and the player must guess that word. The computer tells the player how many letters are in the word. Then the player gets 5 chances to ask if a

[Tutor] String formatting question with 's'.format()

2011-06-08 Thread eizetov
I'm working through the 'Learn Python' book by Mark Lutz, in this example: somelist = list('SPAM') parts = somelist[0], somelist[-1], somelist[1:3] 'first={0}, last={1}, middle={2}'.format(*parts) "first=S, last=M, middle=['P', 'A']" why do we need the '*' at 'parts'. I know we need it, becaus

Re: [Tutor] String formatting question with 's'.format()

2011-06-08 Thread Prasad, Ramit
From: tutor-bounces+ramit.prasad=jpmchase@python.org [mailto:tutor-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of eize...@gmail.com Sent: Wednesday, June 08, 2011 3:11 PM To: tutor@python.org Subject: [Tutor] String formatting question with 's'.format() I'm working through the 'L

Re: [Tutor] String formatting question with 's'.format()

2011-06-08 Thread Evgeny Izetov
I see now, that example helps. Basically I use one asterisk to extract a list or a tuple and double asterisks for a dictionary, but I have to provide keys in case of a dictionary, like here: >>> template = '{motto}, {pork} and {food}' >>> a = dict(motto='spam', pork='ham', food='eggs') >>> templat

Re: [Tutor] Copying a mutable

2011-06-08 Thread Alan Gauld
"Válas Péter" wrote > really care if the two names are bound to same object, or just to > two > objects that happen to have the same value. Being one of the purposes of Python to be a simple educational language, I want to make this simple to a beginner who does care. :-) That's good. Bu

Re: [Tutor] String formatting question with 's'.format()

2011-06-08 Thread Alan Gauld
wrote 'first={0}, last={1}, middle={2}'.format(*parts) "first=S, last=M, middle=['P', 'A']" why do we need the '*' at 'parts'. I know we need it, because otherwise it gives an error: The * tells Python to unpack parts and treat the contents as individual values. format is looking for 3 v

Re: [Tutor] Q

2011-06-08 Thread Brett Ritter
On Wed, Jun 8, 2011 at 3:25 PM, Vincent Balmori wrote: > In the "Loop of Game" section of my code for some reason it gives me five > more chances than I wanted it to. When I put two as the chance limit, it > allowed seven. Also, the program will always say "yes" to any letter I > enter, even if it

Re: [Tutor] lxml.html

2011-06-08 Thread Steven D'Aprano
nitin chandra wrote to me off-list. I've taken the liberty of returning the conversation to the mailing list. Hi, ERROR [Wed Jun 08 20:29:51 2011] [error] [client 192.168.1.9] Traceback (most recent call last): What is all this extraneous date/error/ip address nonsense in the traceback? Wher

[Tutor] Objects C++ vs Python

2011-06-08 Thread Ashwini Oruganti
I'm trying to learn Python, and know C++. I have a slight confusion regarding the meaning of "object" in python. Here's what I've concluded so far: When we say "object" in C++, it means an instance of a class. e.g. class x{...}; x ob1; // here ob1 is an object. but, for; int

Re: [Tutor] Objects C++ vs Python

2011-06-08 Thread Steve Willoughby
On 08-Jun-11 22:38, Ashwini Oruganti wrote: I'm trying to learn Python, and know C++. I have a slight confusion regarding the meaning of "object" in python. Here's what I've concluded so far: When we say "object" in C++, it means an instance of a class. e.g. This is true in both Python and C++

Re: [Tutor] Objects C++ vs Python

2011-06-08 Thread Ashwini Oruganti
That clears it up to an extent. On Thu, Jun 9, 2011 at 11:31 AM, Steve Willoughby wrote: > The value 5 is an integer-class object. But now what is "Integer-class"? Isn't integer a data type? I mean there is no concept of "classes" in C, and yet in C, we can write int x = 5; Will "5", then be