#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 11 12 
Top Prev 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 Next

#python

<masterdriverz> Anusien: it's currently a package manager for gentoo, but the project lead is planning splitting bits of it out into an external lib
<Twey> Huh.
<Twey> I could've sworn I used it the other day.
<Twey> Oh well.
<Anusien> masterdriverz: I don't have that package at all, so I can't get his imports either
<masterdriverz> Anusien: just copying the function should work...
<Anusien> requires his import of expandable_chain
<bsmntbombdood> Python closures are broken.
<masterdriverz> Anusien: that's in http://www.pkgcore.org/trac/browser/pkgcore/util/iterables.py
<Zal> Twey locals()['_[1]'].__self__
<ironfroggy> bsmntbombdood: bullshit
<ironfroggy> bsmntbombdood: now, tell me why
<Twey> Aha
<Twey> locals()['_[1]'].__self__
<Twey> Zal: Oh, you found it first :-P
<Twey> Zal: Thanks :-)
<Zal> you won't thank me in the morning for that :-)
<bsmntbombdood> ironfroggy: local objects aren't always in scope in the closure
<joe_k> bsmntbombdood: can you paste an example
<joe_k> in the pastebin of course
<Twey> Zal: I'm not daft enough to use it -- nice to know it exists though
<Twey> Zal: It was bugging me :-P
<Zal> :-)
<bsmntbombdood> i've got a long, complicated example in an app, i'm trying to duplicate it
<joe_k> cool
<ironfroggy> bsmntbombdood: id love to see it.
<ironfroggy> Zal, Twey: i wouldnt rely on that local temp
<ironfroggy> its liable to stop existing
<ironfroggy> i wouldnt even expect it to exist outside of CPython
<Zal> it should exist as long as the list is being built
<bsmntbombdood> ok, got it
<Twey> ironfroggy: Like I said, I'm not daft enough to use it in a serious program :-)
<Zal> ironfroggy but as for "rely" on it ... of course not, it's an undocumented incidental
<bsmntbombdood> http://pastebin.ca/370609
<bsmntbombdood> NameError: global name 'sys' is not defined
<bsmntbombdood> sys is valid in f
<ironfroggy> bsmntbombdood: ok im interested. ill look.
<bsmntbombdood> s/valid/in scope/
<joe_k> dont have to exec the import either, a normal import sys also fails
<polpak> bsmntbombdood: return lambda x,sys=sys: sys.stdout.write(x)
<deltab> bsmntbombdood: only as a global name, because it's not defined as a local
<deltab> bsmntbombdood: the lambda is irrelevant
<bsmntbombdood> deltab: so?
<ironfroggy> you cant modify the locals() dictionary and modify the locals themselves
<Anusien> I'm building an Abstract Syntax Tree, and I have ASTNode as the base class, and then a bunch of different nodes that inherit from it. Is there an easy way to tell if something is only an ASTNode and not one of the inherited classes?
<bsmntbombdood> joe_k: no
<deltab> bsmntbombdood: so how does not being able to create arbitrary locals in a function show that "closures are broken"?
<ironfroggy> bsmntbombdood: thats why it doesnt work. just do a normal import
<Anusien> The only way I see to do it is to add an extra level of inheritance, and check on that? IE: ASTNode->IntermediateNode->other nodes, and then check is_instance(obj, IntermediateNode) instead of !instance(obj, ASTNode)
<bsmntbombdood> ironfroggy: i can't

Previous Page  Next Page

Search ircarchive.info