#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11
Top Prev 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 Next
#python
<Anusien> After learning Python, I suddenly want to do all kinds of scripting, so...
<sipher> scripting languages are nice for lots of things. Dynamic type etc.
<Anusien> well, I fianlly have a language under my belt that's appropriate for CGI, so I feel like learning that
<chopin> and this is a scripting language that's fully OO
<sipher> Look at Django
<Anusien> Django?
<sipher> http://djangoproject.com/
<Anusien> ahh, I see
<chopin> Anusien: http://www.diveintopython.org/index.html
<Anusien> ooh, neat, thanks
<chopin> np
<Anusien> Sadly, lack of static typing means lack of some nifty automatic typecasts
<Anusien> string_thing = len(arg) + "\n" doesn't work, so I have to change like 40 statements
<chopin> Anusien: you can do '' + len(arg) + '\n'
<chopin> that should work
<chopin> ...
<Anusien> No
<chopin> ? oh
<Anusien> That was my first guess
<Anusien> But then it said "can't concatenate str + int + str
<chopin> ah, must be acting stricter
<spaceinvader> eh?
<spaceinvader> what are you trying to do?
<Anusien> Parsing and building the AST
<spaceinvader> string_thing = str(len(arg)) + '\n' ??
<Anusien> spaceinvader: yes
<Anusien> I'm also learning a lot of neat VI tricks, but that's neither here nor there
<sedeki> How can I join two types into one string?
<Yhg1s_PyCon> sedeki: "%s %s" % (x, y)
<chopin> types?
<sedeki> I want to write out a number variable
<chopin> %d
<Anusien> Alright, it's official. <3 interpreted languages
<Anusien> So convenient to be able to fire up the interpreter and just test a function
<sedeki> I've written a class. Don't I need to declare any local variables?
<arkanes> you don't need to declare variables ever
<sedeki> do I just create them by myclass.new_var = something
<computerlinguist> sedeki: self.var
<arkanes> since python has neither declarations nor variables ;)
<sedeki> I don't know whether I should be happy or cry
<Anusien> What do you need your local variables to do?
<sedeki> global name 'self' not defined?
<computerlinguist> sedeki: 'self' when inside the class
<Anusien> def __init__(self, variable_declarations...)
<Anusien> don't forget to put (self) as the first variable in your class functions
<sedeki> do I need to return something in it?
<Anusien> But yeah, python creates variables the first time they're used, so if you need to, you can "create" them by setting them equal to something in __init__
<Anusien> no, the interpreter automatically passes self
<sedeki> but in __init__
<sedeki> do I need to "return None" or something?
Previous Page Next Page