On Saturday, October 10, 2015 at 11:32:24 PM UTC-7, Chris Angelico wrote:
> If you REALLY want to look like Ruby,
Ha! This thread has provided so many interesting monkey-patching techniques,
but this might be the most perverse. Very cute.
--
https://mail.python.org/mailman/listinfo/python-list
On Saturday, October 10, 2015 at 3:55:17 PM UTC-7, Steven D'Aprano wrote:
> # Solution 1: inject a new method into each and every instance in the tree.
>
> node.foo = MethodType(foo, node)
Ooh, interesting. I'll meditate on that for a while.
> # Solution 2: hack the node type of each instanc
On Saturday, October 10, 2015 at 10:40:15 AM UTC-7, Ian wrote:
> name mangling
Awesome! I didn't know this was a feature.
> There's nothing wrong with [functional programming] IMO. In fact, Python
> does this in the standard library, e.g. len(objects) rather than
> objects.len().
...good point.
(This is a long post, but the question is simple. Most of this is
just me enumerating what I've already tried.)
Someone wrote a library that creates and manipulates `Node`s.
I would like to write another layer on top of this, to make
trees that behave just like the library's trees, but whose nodes