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

#python

<ZenMasterJG> well now i'm confused, actually
<ZenMasterJG> as i cant get it to work either...
<AndroidData> Leeds: in python
<polpak> ZenMasterJG: works fine for me
<SEAwolfx> VladDrac: so you would say for instance sqlalchemy decided to go the "wrong" way?
<kbrooks> are metaclasses _that bad_?
<HanzZ> hi... how can i detect, if is not variable unicode?
<alakdan> polpak: You mean self.myvar works?
<SEAwolfx> kbrooks: I would say no ;) as already said "it depends on the use-case"
<Ind[y]> HanzZ: Your question does not make sense.
<polpak> alakdan: yes
<ZenMasterJG> yeah, it does
<polpak> alakdan: as long as you don't reassign it to something else
<ZenMasterJG> the first test case i wrote didn't, for some reason
<HanzZ> ok... i need to detect, if variable is string or if it's something else....
<polpak> HanzZ: why?
<ZenMasterJG> test.var is clearer, though, IMHO
<alakdan> polpak: hmmm. try exiting the current python session and do it again.
<spaceinvader> HanzZ: if string == unicode: print 'unicorn'
<sipher> How do you convert a string so it print "\n" instead of an actual newline. I forget.. I've done this before
<sipher> prints*
<spaceinvader> sipher: \\n?
<ZenMasterJG> er, classname.classvar is clearer, i meant
<sipher> spaceinvader: No.. I mean an existing sting. I can't modify it
<spaceinvader> sipher: yeah...
<sipher> There's some escape method
<spaceinvader> sipher: if string == unicode: print 'its unicode'
<Rustre> hi people
<spaceinvader> sipher: ooh
<polpak> ZenMasterJG: depends on what you're trying to do
<spaceinvader> eek
<spaceinvader> mixed up
<Rustre> can anybody explain me the difference between the __str__ and __repr__ special class methods?
<Ind[y]> HanzZ: Somewhat better, but still not perfect.
<polpak> alakdan: eh.. why? I did it in a new python session to begin with
<alakdan> polpak: sorry for that, it works for me also :)
<Rustre> they look alike for me :/
<ZenMasterJG> polpak, i suppose. I still speak better java, and think of class attributes like static class variables. used that way, the classname is clearer, i think.
<Ind[y]> HanzZ: Anyway, isinstance( myVariable , str )
<polpak> Rustre: help(str) help(repr)
<Rustre> polpak, good idea, should have thought about it myself, sorry for that ;)
<sipher> Anyone?
<Rustre> polpak, yeah well, they still look alike for me :p
<ZenMasterJG> sipher x="foo\ntest"; print repr(x)
<ZenMasterJG> speaking of repr.
<Rustre> or nearly : maybe "repr" is the "string representation" and "str" is just the string itself
<polpak> Rustre: repr is typically used in conjunction with eval str is not
<Rustre> ok
<ZenMasterJG> Rustre, when you're using more complicated things, str is what print calls first. it should return something that looks nice to print at the user. supposedly, repr should be a string-based representation of the object, so you can rebuild it later.
<Rustre> ZenMasterJG, thanks for that

Previous Page  Next Page

Search ircarchive.info