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

My 1st /prog/ram

Name: Anonymous 2009-03-11 19:52

So I took /prog/'s advice and started learning python:

Here is my first ever program that is not copypasted from the tutorial. (I went further by not ONLY having it say 'too high' or 'too low' or 'you guessed it')

Am I doing it right or is declaring 5 variables a waste of time?
Why cant I just say
if a < 5:
    print('way too low') #?
why does it have to be a variable?

Name: Anonymous 2009-03-12 1:06

>>22
Yes, you declare "self" as the first parameter for (most) methods, but that allows you to reference them inside your function definitions and refer them to the actual outside variable.

note that:
class Name:
    def __init__ (bill):
       bill.x = 7

is also valid. "self" is just commonly used because it make sense. I don't see why any one would consider this stupid or in anyway a hassle. you might as well complain that __init__ has TWO underscores rather than 1.

As for speed:
yes, great. C is faster, WE KNOW. so don't use python to develop 3d engines. developing a small utility program which doesn't consume all your CPUs? who cares.

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