by eesmith · 1w ago · 0 comments
I remember when MRO was discussed on comp.lang.python. It improved on the previous implementation. Because of that discussion I've worked to avoid diamond inheritance, with a preference for mixins.
I think you mean **kwargs and *args (with a single star)? (I'm assuming it was an HN formatting issue.) One of the annoying things about them is APIs which pass **kwargs around, uses a few of them, and pass the rest to the lower level API. It's really hard to document what the top-level function accepts when you don't know the whole call path.
Looking through my code I see I rarely use *kwargs. One of the exceptions is when I do a pass-through to a function I can't control, but where I want to add, for example, timing instrumentation. Another is for a base-type with a default "raise NotImplementedError" where the subclasses have subclass-specific parameters.
Anything which can add to sys.path can tweak the rest of the Python run-time.
>>> def my_len(*args, **kwargs):
... print("Hello!")
... return old_len(*args, **kwargs)
...
>>> old_len = len
>>> import builtins
>>> builtins.len = my_len
>>> import uuid
Hello!
Hello!
Hello!
Hello!
Now tie that in with some 'import traceback' and stack exploration.If you can change PYTHONPATH then you can change LD_LIBRARY_PATH. I've had to shim some programs that way.
If you want to find who is being naughty: sys.path = tuple(sys.path)
I primarily use duck-typing, with OO mostly for implementation reuse. I think of it more like C++ templates than Smalltalk-like OO. I hate dealing with type annotations. Some places I just use Any. I don't understand the fascination with them. One of the few places in Python where you need OO is with exception handling.
One of the guidelines for Python development in the 1990s was "it's for consenting adults". The "__hack" for semi-private members was not meant for actual information hiding. It sounds like that's not the environment you're in, which helps explain why it's not a good fit.
You left out gc pausing. I remember working for hours trying to understand spikes in my data, not being able to reproduce with just that test case, until finally disabling gc.
And you left out failed __del__ calls during shutdown because the Python interpreter is in a partially destroyed state and certain things you expect are simply gone. I've had to ensure every temporary filename in my test suite has a unique name so I could help track those down. (See, if gc runs earlier then the __del_ doesn't fail, so it needs just the right patterns of calls to trigger an error.)
Does all that make me a tribalist? Oh woe is me, how am I to maintain group cohesion with that sort of attitude? /s
But really, I don't understand why you posed your question or comments. Is it just to complain about your experience with Python, or does it have something more directly related to the essay's commentary on language wars and techno-tribalism?*
No comments yet.