| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Comments:
<0> ok, then i missed something, unless someone defined partial themselves ;) <1> but type(some_func) <type curried, blah> looks like an interpreter stuff <2> Yango: Jerub's example was from MochiKit, which is a javascript library <3> (based on pythonic principals) <2> I don't know whether Python has a partial or not, offhand. <3> TML: it will. <3> anyway, the implemntation of partial looks like: <3> http://rafb.net/paste/results/A0gmLK18.html <4> beautifulsoup++ <0> masala, hehe <0> a perhaps clearer version (doesn't do kwargs and only curries one arg) is something like: <5> yeah, beautifulsoup is really cool. <0> >>> def partial(f, firstarg): <0> ... def f2(*args): <0> ... return f(firstarg, *args) <0> ... return f2
<1> i love that straightness of python. I still can't get used to the idea of messing with args and functions like that <2> Jerub: Does that actually happen often enough that it warrants language-level support? <0> did you know you can put functions on functions? <0> Jerub: i think it will be in a module <3> TML: it's only getting put into the builtins. <1> mcmillen, yes <0> erm, TML <3> TML: and it was to avoid people getting pissed off about lambda going away, which it isn't now. <5> wait, it's not? <2> I see <0> yango: i actually used that feature the other day, for a @memoize decorator <0> gzl: nope <5> .... <5> cool. <3> gzl: no, guido got pissed off with people wasting their time convincing him, and wasting their time inventing a better syntax. <5> I see. <1> that's another topic widely misstudied (and thus misunderstood) by me :) Python's decorators aren't exactly the GOF pattern implementation, right? <5> Jerub: wait, so he's just leaving it as is, or is using some new syntax? <3> gzl: it's staying exactly as it is. <5> ok <3> Yango: nope <0> yango: not really. <4> but it's still going away, right? <3> Yango: the GOF implementatino was only designed the way it was to get around language limitations. <3> Leeds: no, it's not. <0> Leeds: no <6> :) <1> Jerub, the objective though is the same? <3> Yango: dunno, I've ignored the GOF stuff since I came to python <2> Jerub: I'm still having trouble divorcing myself from my old internals@php.net attitude, where adding stuff to the core is what got us in the trouble we're in. :) <3> Yango: most of the patterns in their catalog in the book are designed to combat language limitations. <7> I never got the point of singletons <7> if you only want an object once, why not just instantiate it once? <3> steg: again, language limitation. <3> steg: in java, you can't do: <3> cl*** Foo: p*** <3> Foo = Foo() <3> and be done with it.l <1> The ideas are valuable though, regardless of language limitation <3> also, very few languages have this idea that the programmer is a consenting adult. <3> Yango: oh, sure. <7> Jerub: Ahh. <1> so, decorators in python append generic functionality to a function <1> ? <2> Jerub: I disagree. I always felt the point of the patterns book was to codify and name common problems faced in software. Solution implementation was a secondary goal, and only broadly discussed. <0> decorators are syntactic sugar for a function that operates on a function <3> TML: I ignore the patterns catalog. <3> TML: but I love the first section. <8> the only decorater ive seen and kind of groked was a @sychronised one <3> TML: but they don't publish a version of the book without the catalog. <9> how would i match an underscore with a regex? <3> _ <1> but operates on a function result, args, anything? <8> with _ <3> parks: seen turbogears ? <3> parks: it uses decorators extensively. <0> yango: @someDecorator def foo(): p*** is *equivalent* to simply def foo(): p*** foo = someDecorator(foo) <9> Jerub: it doesn't seem to work with a string like ' "_ ' <8> Jerub no
<3> mariodemon_11: are you using match or search? <10> The term 'decorator' in Python refers to a method wrapping construct, not to the term 'Decorator' in the gang of four. <3> parks: watch the 20 minute introductory screenscast. <3> parks: it's 30mb, available from turbogears.org <0> Yango: parks: see http://pastebin.com/577755 for a definition of a simple decorator <9> Jerub: o damn, i forgot, thanks <0> that "memoizes" a function... i.e. if the function has been called with the same args before, it returns the cached value <1> I love how geeks love to invent terms... :) cache_result seems a lot clearer to me <0> you could say something like def fib(n): if n <= 2: return 1 else: return fib(n-1) + fib(n-2), then say fib = memoized(fib). or you can say @memoized before the def of fib, which is clearer <0> memoized isn't my word, i blame Guy Steele :) <8> why would fib get called with the arguments <1> I wasn't blaming you, mcmillen <8> the same arguments <8> that should read <1> fib(n-1) was called before as fib(n), parks <1> or seomthing like that :) <1> I'm not thinking straight <0> parks: run my def of fib() without memoziing it and see how long it takes <11> is it possible to have an object emulate a boolean? I have a singleton NotSet which I would like to behave as None, so that NotSet or b == b <1> memoiizing, ell oh ell <12> http://rafb.net/paste/results/GytlWX75.nln.html' <0> to compute fib(100), it would have to compute fib(99) and fib(98), but fib(99) also wlill recompute fib(98), and the computational time blows up exponentially <12> anyone have a clue why that doesn't connect? <0> with memoization, you compute fib(98) just once, then return it immediately everywhere else that it's called <0> admittedly, fib is a dumb example because it has a trivial iterative method of computing it, but for some functions recursion is nice :) <12> no one? <0> kjetilho: define a __nonzero__ method <11> mcmillen: ah. I'm stuck with Python 2.3, but it seems I can use __len__ instead for this purpose <0> kjetilho: i think nonzero has existed since 2.2, but let me check <11> you're right <11> sorry, thanks a lot! <0> np! enjoy ;) <8> this channel is the best for procastination <1> parks++ <8> bulio put some print statements after each call to see whats happening <1> and you even learn some things! <8> kjetilho whats wrong with True, False and None ? <12> parks: ok <0> yango: you mean parks += 1? :) <8> zanella thinking about doing work, but doing everything to avoid doing said work <11> parks: I use it for keyword arguments where True, False and None are valid values <1> i mean operator.add(parks,1) <8> is there any value to being incremented? <13> parks: thanks <11> parks: I guess it wouldn't be an issue if there weren't an inheritance tree <0> yes, if you reach sys.maxint you progress to Level 2 of Python Mastery. <14> mcmillen: don't you just roll over to the negatives? O.o <0> roderyk: possibly, but that's also pretty cool :) <3> then, once you manage to fill the entire amount of memory a python process can hold with your number, you trancend, and you get ops in #python <0> i really only care about abs(mcmillen) <0> so if i ever go <0, i'll become a trolling flamer <0> you guys should be lucky i said somethin ginsightful my first time :D <12> how do I run python from windows command line? <14> the issue I'm worried about is if we start comparing each other relatively <12> I can't get my script running <12> its been awhile since I've used windows <14> so parks/mcmillen which will lead to floats... <3> bulio|: C:\python24\python.exe <3> or whatever <3> just like you'd run any other program. <14> I want to be a _whole_ person >< <12> Jerub: but to run a script <12> not python itself <3> bulio|: C:\python24\python.exe myscript.py <13> bulio| You don'treally like to read docs do you? <15> hello. I just wrote a small wrapper that I think is useful, in python+pygtk+glade. I only need the .py file and .glade to use this, but how should I go about packaging my app to make it installable? <1> engla, tar cvzf installer.tgz file.py file.glade :-) (you mean under windows?) <16> This is more difficult than I thought. <12> py2exe? <12> I can run python <12> but not the script <15> Yango: linux <15> but okay.. if that's so. But it would be nice to be able to make a .deb
Return to
#python or Go to some related
logs:
#ubuntu #perl #redhat +trs-80 +oregon trail #web sanderd d1 #ubuntu hibernate nested sets libvlcplugin undefined symbol xtwindowtowidget #perl
|
|