#python - Sat 21 Apr 2007 between 08:01 and 08:20

NY Lost Funds



KirkMcDonalds/Any/And/
BrendKirkMcDonald, does it not?
theTravTenOfTen: yeah ok, but say I want an object to have a new function named after an element in an xml fragment
and I want the function to return the contents of the xml fragment
BrendtheTrav: Do you mean a new method?
KirkMcDonaldBrend: If you have an object instance, and you assign a global function such as e.g. def foo(self) to it, it won't act like a bound method.
theTrav<object><foo>bar</foo></object>
TenOfTentheTrav: just setattr()
theTravneeds to make the object have a method called foo that returns bar
setattr, thanks will check the docs
TenOfTentheTrav: pydoc setattr
KirkMcDonaldBut you can assign the function to the object's class.
TenOfTentheTrav: sounds more like you want functions in a dict though
theTravis pydoc the language reference? or something else?
TenOfTentheTrav: pydoc extracts in-code docs
theTravoh
similar to the javadoc api's?
TenOfTenworks on your own code too, no need to pre-process
Brendhttp://www.deadbeefbabe.org/paste/4469
TenOfTeni bet you need to "compile" something with javadoc
BrendHooray
theTravyeah but I'm talking about output
it outputs something similar to what javadoc does
BrendtheTrav, see paste
TenOfTentheTrav: there's html output too if you want that yes
BrendThough in general that is probably not a good way to do things ;)
theTravthanks Brend
TenOfTenhttp://pydoc.org/
theTravhmm, well I think I can probably solve the situation using setattr without functions
GaKkGaKkDoes anyone know how I get an image from PIL to pygame?
theTravdoes python have a concept of null?
how do I test to see whether an attribute exists or not?
deltabit has None
starGaminghasattr
deltabhasatt
r
theTravok, thanks
starGamingAnother way would be try-except + getattr. hasattr is way more elegant, tho.
theTravif(this.hasattr("attrname")) or if(this.attrname == None) yeah?
starGamingThe latter will raise an error if it hasn't.

Page: 2 9 16 23 30 37 44 51 58 65 

IrcArchive

NY Lost Funds