Alex wrote: "...but the resulting confusion between items and attributes seems a strange target to aim for." I ought to just admit now to being overly excited by all of python's nifty extensibility. It IS nifty, so you can hardly expect Instead, I'll rashly claim that blurring the line between attributes and hashes is sometimes useful when dealing with a structure whose attributes you wish to access programmatically. One example might be a doubly linked list where most of the code accesses the attributes directly but a generic traverse 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 = tail tail.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")
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4