miniblog.

← Back to all posts
5
@PeterLudemann It complicates namespaces: the availability of .foo() now depends on what you've imported, especially if you want x.foo() and y.foo() to be different. It also leads to multiple ways of expressing the same thing, making codebases less consistent. This is all subjective, of course, but I'm currently favouring not implementing UFCS.

5 Comments

@wilfredh Static or dynamic types? Function overloading? Also, this has had extensive discussion, both in the PEP and the mailing list, which might give you a sense of the pros and cons.
@wilfredh I don't understand how the availability of .foo() depends on what you've imported ... the whole point of x.foo() and y.foo() is to isolate the "foo" to the types that x and y have. That is, "foo" isn't visible outside of using or specifying x or y.
@PeterLudemann Sure, but under UFCS, x.foo() and foo(x) are equivalent, so importing a standalone function foo makes x.foo() available.
@wilfredh Disambiguation the Python way: Class.method? It turns out that for large programs, fully qualified names help a lot with readability, even with IDEs that can do lookup. (Or partially qualified names) "from mymodule import *" is forbidden in the Google style guide, instead do "import my module" and then "mymodule.foo()"