Allow positional arguments to PClass.__init__
See original GitHub issuePClass
subclasses must be given keyword arguments for initialization, currently. This is often quite a good thing. However, particularly for a type with only one field, the ability to use a positional argument instead is rather convenient.
Compare:
self.assertThat(foo, MappingLikeEquals(expected=bar))`
vs
self.assertThat(foo, MappingLikeEquals(bar))`
It’s hardly an earth shattering difference but I don’t find the keyword argument adds anything to the former (and it stands out against the idiom of the API it’s being used with, which includes other such types as Equals(bar)
, Contains(bar)
, etc).
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
python - __init__( ) missing 1 requirement positional argument
def __init__(self, privilege) declares that the class requires one argument during instantiation: privilege .
Read more >Named and Optional Arguments - C# Programming Guide
Named arguments in C# specify arguments by name, not position. ... Optional arguments enable you to omit arguments for some parameters.
Read more >A tour of the Dart language
This page shows you how to use each major Dart feature, from variables and operators to classes and libraries, with the assumption that...
Read more >Allow for positional- or keyword-only arguments in dataclasses
There are some data classes where I want to have only keyword arguments, and some where I want only positional. Take for example:...
Read more >Positional and Keyword Arguments
An argument is a variable, value or object passed to a function or method as input. Positional arguments are arguments that need to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Order can be captured in other ways. For example,
field
could have an internal monotonic counter set at instantiation time. The order of fields in thePClass
is then trivially extracted by ordering the fields by their value of this counter.Closing due to staleness, please reopen if anyone wants to act on this!