#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
Top Prev 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 Next
#python
<arkanes> no, don't return anything from init
<sedeki> I have no need to use __init__ except for self
<arkanes> __init__ is the rough equivilent of a constructor
<sedeki> I have no lines in method body of __init_; python complains
<arkanes> if you're getting confused about declarations you're probably creating class level attributes which are not what you want
<sedeki> what do I do?
<timonator> sedeki: use pass
<timonator> pass does nothing, but keeps the indent error from happening
<sedeki> okay.
<sedeki> still complaining.
<Zal> sedeki if you have no lines in __init__, you can just leave it out entirely
<sedeki> global name 'self' is not defined
<timonator> Zal: unless he wants to override a subclassed __init__
<sedeki> I need self
<Zal> by doing nothing?
<timonator> sedeki: your function body is completely empty?
<arkanes> sedeki: you're trying to write your code at the class level
<timonator> def (something):
<timonator> [following nothing at all]
<arkanes> you need to move the code that you have at class level into the __init__ method
<sedeki> Is it worth saying I'm importing this as a module not a class
<sedeki> I have no "class" sorry
<arkanes> then you're totally on the wrong track
<sedeki> I don't think it even calls __init__ at all
<arkanes> it doesn't
<arkanes> cause it's not a class :P
<ZenMasterJG> sedeki: maybe it would help if you put it on the pastebin so we could take a look
<sedeki> unbound method omrade() must be called with Fastighet instance as first argument (got str instance instead)
<sedeki> ?
<computerlinguist> That means that obviously the programmer is from Scandinavia.
<arkanes> if you're getting that error you do have a class
<sedeki> obviously.
<spaceinvader> is there anything like trac that natively uses mercurial?
<arkanes> put your code on the pastebin
<sedeki> man, pastebin is slow.
<Greatred> when you've got multiple inheritance, is it seen to be "okay" to not use super() and to directly call __init__ on parent classes where the arguments differ?
<sedeki> http://rafb.net/p/t9fW1u45.html
<computerlinguist> f = Fastighet()
<computerlinguist> if you want to create an object of class Fastighet
<sedeki> computerlinguist: hmm.. omrade() takes at most 1 argument, two given?
<arkanes> sedeki: you didn't declare the self parameter
<computerlinguist> sedeki: you have to add self in the method declaration
<computerlinguist> def omrade( self, argOmrade = None ):
<computerlinguist> same with agare()
<arkanes> sedeki: what you're doing with the setter/accessor thing is considered generally poor python style, fyi
<sedeki> won't self.omrade = ... remove the method itself?
<computerlinguist> every class method needs the implicit self
<arkanes> and yes, it won't work because you're going to remove the method
<arkanes> sedeki: the conventional way to do this is to just set the attribute directly
<sedeki> arkanes: do I access local vars directly from caller?
Previous Page Next Page