Movatterモバイル変換
[0]ホーム
Changing global variables in tkinter/pmw callback
Jonathan Claggettjcc.ugm at ix.netcom.com
Fri Apr 6 20:13:16 EDT 2001
Alex wrote:"...but the resulting confusion between items and attributes seems a strangetarget to aim for."I ought to just admit now to being overly excited by all of python's niftyextensibility. It IS nifty, so you can hardly expectInstead, I'll rashly claim that blurring the line between attributes andhashes is sometimes useful when dealing with a structure whose attributesyou wish to access programmatically. One example might be a doubly linkedlist where most of the code accesses the attributes directly but a generictraverse function uses a parameter to access the attributes. My (trivial)example:# normal usage (using Bunch as a structure)head = Bunch(value="cat", left=None, right=None)tail = Bunch(value="dog", left=None, right=None)head.right = tailtail.left = head# generic usage (using Bunch as a hash)def traverse(node, next): while node: print node.value node = node[next]traverse(head, "right")traverse(tail, "left")
More information about the Python-listmailing list
[8]ページ先頭