#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 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 Next

#python

<polpak> sipher: x="foo\ntest"; x.encode('string_escape')
<sipher> I thought it was repr.. but repr is.. bah. Not working. I guess I have a space delimited set of values. :\
<Rustre> so if I wish to do "print myObject" i'd rather have myObject implement __str__
<ZenMasterJG> sipher: it worked fine for me
<alakdan> polpak: seems by doing self.myvar its not a class attribute anymore http://deadbeefbabe.org/paste/3781
<polpak> Rustre: yes
<ZenMasterJG> did you try that line i sent you?
<sipher> zen: I know. It works for me too.
<Rustre> polpak, ZenMasterJG : thanks a lot for your answers ;)
<polpak> alakdan: self.myvar=2
<sipher> I'm saying I wanted it to see the format of some input.. but it's not tab delimited like I thought. It's padded with spaces
<polpak> alakdan: if you assign an instance variable it'll mask the class variable the next time you access it
<Rustre> alakdan, if you do "self.myvar" it doesn't use the class attribute myvar (if there is one), it create a new data attribute (an attribute held by the instance, not the class) ;)
<polpak> Rustre: not true
<Rustre> polpak, really? it was what I saw in "dive into python" and what I experienced, but maybe i didn't phrase it correctly?
<polpak> Rustre: it will use the class variable so long as you haven't defined an instance variable with the same name
<alakdan> polpak: oh I see. lol. Thanks a lot !!! :)
<alakdan> darn
<alakdan> hahaha
<alakdan> sorry
<polpak> typically you'll want to use a classmethod to change class variables
<Rustre> polpak, is that REALLY true? I tested, and didn't experience that... I had to use "self.__class__.myvar" to access the class attribute from the class methods, using "self.myvar" was just creating a new variable
<polpak> Rustre: again.. If you assign it, it'll mask
<alakdan> Rustre: http://deadbeefbabe.org/paste/3781
<alakdan> Rustre: you can actually access myvar with self.myvar :)
<Rustre> polpak, ok thanks for the precision, i'll test that right away ;)
<polpak> so one thing which class methods can be used for nicely is saving on space when you have many many objects with the same (or similiar data) and only a few values are changed. If you assign class variables for everything with the defaults then you only need to change the variables that are different, and the rest will be shared unless they're masked for a particular instance
<Rustre> it works exactly as you said polpak, thanks a lot ;)
<polpak> err not class methods, I mean class variables
<polpak> this is an example where it's useful for methods to use self.myvar rather than TheClass.myvar to access it, because they can be overwritten on a per instance basis
<Rustre> I didn't know about that, very clever thinking ;)
<Necroalbert> Hi
<Necroalbert> :)
<Otacon22> how can i make addictions in binary like
<Necroalbert> Someone can help me please
<Otacon22> 1001+1=1010
<Necroalbert> http://deadbeefbabe.org/paste/3782
<Necroalbert> Otacon python have base changer you can change your value to base 10 addiction and return to your wanted base
<polpak> Otacon22: 9+1
<Otacon22> hum
<Necroalbert> Why i have Warning: Data truncated for column 'X' at row 1 :(
<Otacon22> Necroalbert, I don't understand
<Necroalbert> What your source base ?
<Necroalbert> binary == base 2
<Necroalbert> Change your binary value to decimal value
<Necroalbert> make the addition and return to binary value
<Otacon22> Necroalbert, how can i return to binary value?
<Otacon22> to go to decimal i do int("1111", 2)
<Otacon22> to return to binary?
<whaley> Necroalbert: what is Parser.py and what are you attempting to do?

Previous Page  Next Page

Search ircarchive.info