Python Script to get Info from Site not working

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Mar 11 13:28:15 EST 2010


En Wed, 10 Mar 2010 23:26:05 -0300, Jimbo <nilly16 at yahoo.com> escribió:

> On Mar 11, 12:38 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> En Wed, 10 Mar 2010 20:06:41 -0300, Jimbo <nill... at yahoo.com> escribió:
>>
>> > I found a semi Python & internet tutorial here if anyone else would
>> > like ithttp://www.upriss.org.uk/python/session6.html
>>
>> Replace the last line with something like this, to see what you are  
>> getting exactly:
>>
>>         print("Sorry, no %r (%r) available." % (
>>            drink,
>>            cgi.escape(repr(type(drink)))))
>>
>> BTW, which Python version are you using? The tutorial you linked to is  
>> aimed at Python 2.x, but your print syntax suggests you're using Python  
>> 3.x

> I am using 3.x, do you think I should be using something else?

Yes, you should use the same version as the tutorial you're following.
Learning how to program, CGI, HTML and Python at the same time is hard
enough to complicate it with incompatible version differences. I suggest
Python 2.6.4

> Also
> the your code I put in does the some thing, just now it says "Sorry no
> none drink available" all the time.

As a general rule, always directly copy and paste the error messages you
get and the source code you execute. Do not retype or paraphrase them.
That's important for the rest of us to be able to help you - now and in
the future.

In this case, the message should read "Sorry, no None (<type 'NoneType'>)
available." (None, not none, is a built-in special object in Python). So
we know that drink is None instead of one of the expected values, and we
could start investigating why. But there is no point in digging further -
instead, downgrade to Python 2.6.4 and try again.
This might be a server issue, unrelated to your script. BTW, you didn't
mention the server software.

-- 
Gabriel Genellina




More information about the Python-list mailing list