5 Years of Bad Ideas -- Python tips, tricks, and chicanery
1–10 of 45 posts
Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#2Judging by the number of projects I have seen recently that are predicated on defining new keywords and recognizing them through magic decorators, it may be too late.
Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#3Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#4Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#5Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#6Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#7Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#8Everything is a first class object? What about the if-statement? Anyway, my personal gripes aside, I've been looking for something like this: http://www.scribd.com/doc/58306088/Bad-Ideas#outer_page_54 ... a way to print "name=value" for variables for debugging.
import gc, sys
def find_names(obj):
frame = sys._getframe(1)
while frame is not None:
frame.f_locals
frame = frame.f_back
result = set()
for referrer in gc.get_referrers(obj):
if isinstance(referrer, dict):
for k, v in referrer.iteritems():
if v is obj:
result.add(k)
return tuple(result)Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#9Everything is a first class object? What about the if-statement? Anyway, my personal gripes aside, I've been looking for something like this: http://www.scribd.com/doc/58306088/Bad-Ideas#outer_page_54 ... a way to print "name=value" for variables for debugging.
Your link just goes to the first page. Is this presumably the code you're referencing? import gc, sys def find_names(obj): frame = sys._getframe(1) while frame is not None: frame.f_locals frame = frame.f_back result = set() for referrer in gc.get_referrers(obj): if isinstance(referrer, dict): for k, v in referrer.iteritems(): if v is obj: result.add(k) return tuple(result)
import gc, sys
def show(*args):
for obj in args:
frame = sys._getframe(1)
for k,v in frame.f_locals.iteritems():
if v is obj:
print "%s=%r" % (k,v)
a, b, c, d, e, = False, 1, [1,2,3], {'x':2 }, map
show(a, b, c, d, e)
outputs: a=False
b=1
c=[1, 2, 3]
d={'x': 2}
e=
[ http://codepad.org/4JogU069 ] [ edit: slight cleanup]Re: 5 Years of Bad Ideas -- Python tips, tricks, and chicanery
#10I was just tricked into clicking an ad that simply said "play now" underneath the first slide. I thought it was going to start a slide show of the presentation. Scribd, if you are going to let just anybody advertise on your site you need to clearly mark what is an ad and what isn't.
Google team, clicking the add opened a tab that when attempting to close opened a custom dialog with two buttons at the bottom. "leave now" and "cancel" (or something like that). The page had populated that dialog with a bunch of text and ascii art pointing to the cancel button.
I didn't feel confident enough to click either buttons on this dialog because I thought be may have been some co-oped permissions dialog.I was unable to close the tab. I ended up using the task manager to kill chrome.
I took the time to make a note here because it's been ages (5 years perhaps) since I had to deal with this kind of crap. Has it always been around and I just haven't seen it or is there a resurgence these days.