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

Pages: 1-

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 7:43

the best IDE, obviously, is vim, and the best book is language reference and standard library documentation.
If you expect that after all your Java years, the official docs are shit, fuck you, nikker

Name: Anonymous 2011-06-24 8:15

Name: Anonymous 2011-06-24 9:26

>>1

I learned programming roughly the same way: when I discovered the VBA macro editor embedded in MS Office applications, I spent some weeks figuring how to use it, and then made some really cool board games. The most awkward part, was distributing these games to friends as “.doc”/“.xls”. XD

Then I started to look for “serious” languages, and started with C.

What >>2 said is true. If you already have some experience, read the language standard, which gives you a quick introduction to the basic language constructs, and quickly skim over standard library reference, which introduces you to the basic API (string/regex/IO/threads/network...)

Later you can try your skills with some challenges sites, and at last consider joining an open-source project.

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.

Name: Anonymous 2011-06-24 10:29

>>5

In that if statement the value of v is still integer so you can'y iterate it.

And... why do you even want to check if str is in v? str is string object in Python, right?


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

Name: 6 2011-06-24 10:30

>>6
and obviously you want to change the if clauese to
if ',' in s:

Name: 6,7 2011-06-24 10:31

ok, nevermind, i can't code shit
v = int(s)

Name: Anonymous 2011-06-24 11:42

>>5-8 why do you need to complicate?


t = 0
while 1:
    try:
        t += int(raw_input(": "))
        print t
    except:
        print "use int numbers only!"

Name: Anonymous 2011-06-24 12:59

>>9
Keep it simple.

Ok, I understand.

Thank you.

Name: Anonymous 2011-06-24 13:53

EXPERT PROGRAMMERS don't need nor use EXCEPTIONS

Name: Anonymous 2011-06-24 21:01

>>11 that's right

Name: Anonymous 2011-06-25 17:37

>>11
>>12
Well in Go you're forced to handle exceptions. Some functions will return an error variable and not checking that variable will result in a compile time error. Then again, I guess Ken Thompson and Rob Pike aren't EXPERT PROGRAMMERS.

Name: Anonymous 2011-06-26 2:17

>>13
Wow, none of that is true.

Name: Anonymous 2011-06-26 4:24

A beginners IDE is IDLE.

Name: Anonymous 2011-06-26 4:28

>>13
Compile-time errors in conjunction with exception handling? Surely you are talking about Java!

Name: Anonymous 2011-06-26 19:24

Name: Anonymous 2011-06-27 5:41

call/cc is cooler than exceptions.

Name: Anonymous 2011-06-27 8:27

>>18
hipster/schemer

Name: Anonymous 2011-06-27 13:14

>>19
sellout/Java programmer

Name: Anonymous 2011-06-27 13:18

>>20
nigger/tsk

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