4 ms·
This is covered in the link. Just put a * without a name, as in def foo(*, x=None, y="") (Edit) The specific slide: http://www.asmeurer.com/python3-present
by arximboldi 9y ago
This is covered in the link. Just put a * without a name, as in
def foo(*, x=None, y="")
(Edit) The specific slide: http://www.asmeurer.com/python3-presentation/slides.html#16 http://www.asmeurer.com/python3-presentation/slides.html#16
- iainmerrick 9y agoAha, thanks! I misunderstood -- I assumed the lone * would parse and discard any number of arguments. This is a very good feature, but a weird syntax!
- dozzie 9y agoOh my, it looks atrocious. Almost every time I see something introduced in Python 3 I have an impression that current Python envies Perl its baroque semantics, except that Perl usually tries to guess what the programmer meant, while with Python the relationship is reversed: the programmer needs to guess what the language wants. Python's main selling point was simplicity of syntax and semantics that preserved its high-level language status. This simplicity is no longer present in 3.x line.
- dom0 9y agoPython 2 is a vastly more complex language compared to Python 3. Just try to name the basic classes of types that exist in Python 2. Hint: Cannot be counted on two hands.
- dozzie 9y agoWell, try this for me, especially that you didn't use searchable terminology, so it's hard to confirm what you're saying. And then tell how much of that is important for typical code.
- dom0 9y agoPython 2 has old-style classes, new-style classes, functions, bound methods, unbound methods, slot wrappers, descriptors, method wrappers, built-ins, ... and I'm rather certain I forgot some. All kinda callable types I mentioned behave differently. This makes the language complicated; and due to the dynamic nature leads to subtle bugs that are only detectable at runtime. Python 2 is a lot like C there. This isn't limited to callables but is spread around the language in a lot of places. Python (both 2 and 3) is not a simple language. It has a supremely complicated data model whose documentation is insufficient and scattered.