Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Learning Python

Name: Anonymous 2011-06-24 4:47

I'm currently trying to learn Python. My background with programming is that I took 3 courses in Java during college and wrote a medical scheduling program by myself during high school using VB6 and Access.  I would love to be able to contribute to open source projects, hoping to build a reputation in those communities.

Anyhow, I'm using this text: http://openbookproject.net//thinkCSpy/ch04.html  Is this a good book to use to learn Python given my background?  Also, what's the best IDE for python.

otherwise, python general thread.

Name: Anonymous 2011-06-24 10:09

Hey guys, can you please help a beginner in Python programming?

Here's the bitch: I have this block with try/except and I trying to make one if in the except check if there's in a variable some string, and with this print the message of error. Well, here part of the code:


t = 0
while 1:
    try:
        v = int(raw_input(": "))
        t+=v
        print t
       
    except:
        if str in v:
            print "string, use just number mtf"
        elif ',' in v:
            print "bla bla bla bla"


What I do not understand is because the conditional does not work. Instead, the error message just appears with:

if str in v:
TypeError: argument of type 'int' is not iterable

Teach me how could I make this if at the except check if there's a string and say that must be type just numbers.

Thanks.

Sorry for the english, I'm still leaning.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List