| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Comments:
<0> Mrdini: Isn't that what the name of the company they work for is? <0> Mrdini: Ah. <1> it's been too long :P <0> Mrdini: I never knew what it's official designation was. <2> kosh: how can i put self in it? <2> the decorator takes the function as argument.. <3> def wrapper(self, *args) <3> change the wrapper to that <2> :o! <2> no way! <2> kosh: awesome, thanks <4> /away Z <4> ops :P <5> ah, mailman day comes around so quickly <6> And it's such a mess when you're on 50+ MLs... <5> I'm not on quite that many... anyway, time to go to Australia...
<7> hi how do I print the set of alphabets A-Z dynamically? <7> B doesn't seem to be 'A' +1 <8> hiya <8> is python good for network programming <8> ? <6> print [chr(x+ord('A')) for x in xrange(26)] <3> a_staff: what do you mean by network programming? <7> thanks ignacio ord converts A alphabet into ascii range? <6> A character into its ASCII/Unicode value. <7> aah cool <8> kosh i want to learn networking deeper.. and what i mean is for socket programming <6> chr() does the reverse for SBCS, unichr() for Unicode. <7> thanks ignacio <3> socket stuff I think you can do but I am not really familiar with that <3> with higher level stuff there is twisted <8> kosh what dou mean by that? <8> higher level stufff? <6> Not dealing with raw sockets. <3> http, ssl, ftp, ssh etc etc <0> So here's a hypothetical, guys: <6> "A friend of mine, yeah, he has a problem..." <0> I have to get rid of the data on a hard drive. How hot would I need to heat it deolarize it? <6> You're looking for the "Curie point". <3> just melt it down entirely <6> No need. <3> however what is so sensitive you have to go to those lengths to destroy it? <8> kosh u mean application layer stuff? hows that? i mean what is python good at networking? <0> Nothing. <3> ignacio: of course there is no need, but it is more fun :) <0> It's a hypothetical. <6> http://en.wikipedia.org/wiki/Curie_point <3> a_staff: I deal with database apps, I don't do socket layer stuff at all so I don't know how well python works for that, but it must work pretty well since http, ftp etc are all built on top of it <0> I'm just thinking if the MIB ever are coming, could I fix my problem by hitting my computer a few times with a hammer, and then throwing it in the oven. <9> I need to generate automatically a set of functions in a cl*** based on the keys of a dict. For example, cl*** a: p*** dict = { 'a1': 42, 'a2': 43 } create_methods(a,dict) and having as a result cl*** a with methods meth_a1 and meth_a2 <9> what would be a good way to go and do it? <6> setattr() <6> Of course, you'd need to generate closures first. <9> explain that to me, please :) <8> kosh, hows python in database? <6> First, you generate the closure. Then you use setattr to stick it to the cl***. <3> a_staff: seems to work fine <8> kosh the libraries...? <6> Look elsewhere for info on generating the closures. <3> a_staff: I have been doing zope devel for about 6 years now and it works very well <9> what _is_ a closure :) <0> My oven is not that awesome. :-( <6> It's a function that takes a variable at a point in time and uses that as one of the arguments in an algorithm. <8> anyone does network programming with python? <0> I'd like to get back into python developement. <0> It's so much more fun to code in than C. <9> is there another way to generate closures than lambda? the function I need needs to return and maybe print <6> You can do it with a cl***. Wikipedia shows how to do it that way. <10> i thought you do closures in python by using default arguments <11> AirCastle: a closure is a function which "remembers" the stack frame where it was defined <9> setattr doesn't bind the methods though <6> Yes, yes it does. <6> Make sure you remember the self arg. <6> foo=lambda x, y: return y+3 \ cl*** bar: \ baz=foo \ bar().baz(4) <8> :) <9> http://pastebin.com/577946
<6> Argh. Kill the return there obviously. <6> Hrm... <6> wfm <6> http://rafb.net/paste/results/gqU6ib83.html <9> ignacio, so you bind them first... i found about new.instancemethod <9> which is probably more generic <9> else i would have to bind all new methods beforehand which kinda beats the purpose of dynamically generating the functions <6> I used del on it and it still worked after. <9> ignacio, dumb me i was using a instead of a() <12> Yango, check PEP 227 regarding nested scopes <9> why doesn't this work? (Invalid Syntax) eval('Orderer.get_'+item[0]+'_order = new.instancemethod(order,None,Orderer)') <13> can you tell us the exact error message <14> oh my f-ing god. <3> umm wouldn't that be reversed? <14> Yango: I've just revoked your coding privelidges. <3> Jerub: can I provide the ammunition? <13> Jerub: I wasn't going to comment :-) <14> kosh: no, radix came round in divmod's time machine and gave me two crates, I didn't know why until now. <9> Jerub, before you kill me, tell me my mistake :) (besides the ugliness of the intent) <14> Yango: what you actually want is something like: <14> Orderer.order[num] = order <14> then Orderer.order[num]() will work fine. <14> but that's just ****ed up anyway, write a couple methods and do dict lookups. <9> Jerub, that's not what i want...I want to add methods with a name based on some string var <15> Yango: whan not getattr? <15> s/get/set/ <14> Yango: oh, I don't care what you WANT. this is what you are going to DO. <15> setattr(Orderer, 'get_%s_order' % item[0], new.instancemethod(order, None, Orderer))? <9> yes, i've been playing with that, mitsuhiko, but got problems with binding the method <9> so that eval call was a desperate shot at the problem :) <15> Yango: than ***ign it over the dict <15> Orderer.__dict__['get_%s_order' % item[0]] = new.instancemethod(order,None,Orderer) <14> mitsuhiko: die. <9> so desperate that it backfired <9> :) <15> Jerub: i know why he wants that <14> mitsuhiko: I don't care. <15> if you would know why you would care <15> cl*** C(object): <15> def __init__(self): <15> self.__cl***__ = OtherCl*** <15> Jerub: does that look silly in your mind? <14> mitsuhiko: no, it looks unnecessery. <14> mitsuhiko: present a use-case <15> Jerub: you have a queue <15> when you queue is longer then 100 entries it should change it's usage case <15> then you can do self.__cl***__ = SpecialQueue <14> huh? <14> mitsuhiko: why should you do that? <15> much faster than always doing if len(self) > 100: ... else: .. <15> Jerub: because this is a typical pattern? <9> thanks mitsuhiko, worked perfectly <3> that doesn't make it a good idea especially in python <16> it's been a while since i've used python, and i'm looking at the "Tutorial" section to refresh how to create a cl***... aren't we still supposed to declare a cl*** like so: "cl*** X(Object):...", or can we just do "cl*** X:..." now and it inherits Object? <15> kosh: but it's fast <14> mitsuhiko: bah, this shows a fundamental misunderstanding. <14> mitsuhiko: and pre-emptive optimisation. <3> I sitll don't see how this helps with speed or anything else for that matter <14> neither do I. <14> mitsuhiko: hey, is it fast? <15> Jerub: replacing the cl***? yes <14> mitsuhiko: show me the results of your tests using the profile module. <14> in fact, which profile module did you use? <15> Jerub: no one? all you have to know is a bit of python interna <15> if conditions take time <15> replaceing a cl*** *one* time doesn't take time later <13> :-) <14> mitsuhiko: oh, so you were just prematurely optimising <14> I see. <15> i only said that this is useful <14> Don't do that. Don't encourage ****ty practices based on premature optimiation because you think you know better than the profile module. <15> i don't use it in my code <3> what if statement is there in this?
Return to
#python or Go to some related
logs:
madwifi requires madwifi-kmod
#fluxbox javascript event.register #debian install rtorrent on suse #lisp buu eat #php ububtu C compiler cannot create executables howto use perldoc in eclipse
|
|