question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow positional arguments to PClass.__init__

See original GitHub issue

PClass 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:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
exarkuncommented, Sep 7, 2017

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 the PClass is then trivially extracted by ordering the fields by their value of this counter.

0reactions
tobgucommented, Jul 3, 2021

Closing due to staleness, please reopen if anyone wants to act on this!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found