| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Comments:
<0> Here's mine: <0> http://deadbeefbabe.org/paste/3036 <1> is #python clothing optional <2> brian: no. <3> brian: Put your pants on. <4> oops, I'm naked <5> NO PANTS <0> If you need overlapping segments, replace i += n with i += 1. <2> anyway, #python has no rules. only guidelines. <3> Yango: Put your kippah on. <5> I am the king... of.. no pants! <3> Jerub: lol <1> What is the difference between yield and return <2> CSWookie: exactly. <6> brian: yield is a generator thing. hard to explain those in 100 words or less <0> brian: Yield suspends, return stops.
<3> Jerub: Scratch seems pretty authoitarian in my msg window over here. <2> brian: using yield in a def() will create a generator on call. <6> actually, i probably could, i'm just too lazy <1> Jerub: Returns multiple values? <7> here is my solution, fyi: http://pastebin.com/579548 <8> >>> x = [1,2,3,4,5,6] <8> >>> [(x[i], x[i+1]) for i in range(0,len(x)-1,2)] <3> Jerub: The message should be revised to make it clear that it is merely a guideline. <8> [(1, 2), (3, 4), (5, 6)] <0> brian: That is, yield is resumable. <2> CSWookie: that's just a guideline. if it were a rule, this conversation wouldn't be continuing. <3> Ah. <1> sanxiyn: returns multiple values? <0> brian: No. <0> brian: Return multiple times. <1> How does that work? <1> That might be useful for something I need to do soon. <0> brian: It works by saving all state at the time of yield, and then restore when resumed. <0> brian: But it's not necessary to understand how it works to use it. <4> in the case sanxiyn pasted it seems to me that yield sends the value but continues the execution of the function, if you'd replace yiled for return it would only return the first segment <8> yield is black magic <1> what <0> parks: Not really. <6> http://www.dalkescientific.com/writings/NBN/generators.html <0> brian: Have you used C? <1> very rarely <0> brian: State is saved, as in C's "static variable" of function. <8> sanxiyn in the context that black magic is cool <3> How do you get at the state of a function? I mean, if yield has someplace to save it... <9> I have an object attribute, used as index in some sequences, it may be 0 or 1... sometimes I need to reverse it... int(not obj.attr) works but doesn't look so nice... any other option I missed ? <0> brian: It's like strtok(), in some way. <1> why do i have to wear stupid clothes you guys are mean! <6> CSWookie: the state of a function is all its locals <1> sanxiyn: what <3> sproingie: I understand this. <1> sanxiyn: how is it like strtok <0> brian: Maybe I confused you more... <2> sanxiyn: you mean buggy and an indication that code should be deleted? <0> Jerub: Eh. <3> sproingie: I'm wondering where they get kept. <6> CSWookie: internally by the python VM <0> CSWookie: In a frame. <1> Jerub is wise and all knowing! <2> sanxiyn: read the BUGS section of man strtok on linux <6> CSWookie: the generator object stores the stack frame of the generator function <3> sanxiyn: Could I get at the frame via sneaky tricks? <2> brian: anyway, stop being silly. <1> strtok has bugs? <1> *gasp* <2> brian: and there are references on how generators using yield work, in the python manual. <1> I'm reading it. <1> BUGS <1> Never use these functions. If you do, note that: <1> Heh. <1> What do you use then if not strtok <6> CSWookie: the frame is an attribute of the generator object, should show up in dir() <6> CSWookie: it's a property called gi_frame <6> CSWookie: stands for generator/iterator <3> Not intrigue enough to experiment, because generators are something that I've only had reason to use once. <6> or "generating iterator" or "generic idiot" or something
<6> oh wow i use generators all the live long day <3> When I worked for MFen. <6> i keep wanting to learn icon. it does absolutely everything with generators <10> how do I remove an installed python egg from the system? <3> I use closures all the time, though, and they seem rather similar. <6> icon generators also combine with backtracking tho, python's don't <3> JoaoJoao: egg? <6> generators are in fact closures <6> with extra syntax support <3> I use cosures frequently for partial method evalution stup. For callbacks. <3> I didn't use them much in python. <11> python cant do closerues <6> tho objects require that annoying explicit 'self' parameter <3> I use them all the time in Javascript. <11> thats for lisp <11> u bastards <3> Because Javascripts objects are not good enough, and need help. <3> star-trekio: It can too. <6> javascript's objects are just fine. using a static closure to create objects is a sound methodology <6> objects pretty much *are* static closures <6> tho python ruins that illusion with the explicit self arg <6> well, perl too <4> i like languages which ruin my illusions <6> i like languages that let me create new ones <3> star-trekio: What manner of closureness does python not supporT? <6> CSWookie: writable closures <0> Indeed. <3> I see to recall messing with stuff like that once. I will mess with it again. <12> hi.. I know this sounds stupid, but how do I get the hostname I am running on .. in perl it is via Sys::Hostname .. any clues? <0> def: <0> a <0> def: <0> # modify a here! <6> i've used writable closures in a few areas before. objects usually suffice for that <0> iholsman: socket.gethostname() <9> iholsman, socket.gethostname <12> thanks! <0> sproingie: I did some unforgivable things like a = [val] and accessing it with a[0]... <6> writable closures are really fun in old lisps with dynamic scope <13> are they called closures? <6> it's like tcl and upvar. you can do some truly baffling gyrations with dynamic scope <13> what's being closed over? <3> You're right. <3> That ****s. <3> Heh. <3> But if I put a dictionary in my closure, the dictionary is writeable. <3> So at least there's a workaround. <0> CSWookie: That's what length-one list trick is for... <3> Why aren't closures just writeable in python, though? <3> Would it horribley crush something vital? <0> CSWookie: Well, closure was added later in Python's life. <6> steg: a dynamic closure might close on the environment it was created in ... it'd still be a closure <14> CSWookie: http://www.mrmiddleamerica.com/uploaded_images/pony-769979.jpg <2> ignacio: that's just uncalled for. <3> But it WAS funny. <11> how do u add afeautre <11> to a lang <0> star-trekio: You just add. <6> in some languages you have macros <6> in others, you overload <6> and in java, you wait 3-5 years for the JCP to debate and then do it half-***ed <0> sproingie: In some, one preprocesses. :( <6> if java had a macro system we wouldn't need aspectJ <0> Very true. <4> jav***ist <4> but that's for ##java <6> openjava ... shame that's not maintained tho <11> may I pose a problem to the form? for suggested solution? <15> g'evening everyone <11> forum <0> sproingie: How does it compare to Nice?
Return to
#python or Go to some related
logs:
#asm #css #perl #linux what does oggnogg mean
symbian irc client drupal Warning: session_start() [function.session-start]: Cannot send session co kozanatos #physics magicqoutes
|
|