[Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator
Steven D'Aprano
steve at pearwood.info
Sun Feb 12 21:55:50 EST 2017
On Sun, Feb 12, 2017 at 05:01:58PM -0200, Joao S. O. Bueno wrote:
> You realize now that if we accept this change, and given your example,
> any "well behaved" Python code with markup will in a couple months
> required to be like
>
> class MyClass:
> """Docstring."""
>
> def MyClass.__init__(self: MyClass, ...) -> None:
> ...
>
> # add other methods here.
This is pure and unadulterated FUD.
Nobody is going to use this as the standard way of writing classes. That
would be silly: you end up repeating the class name over and over and
over again.
And to say that this will happen "in a couple [of] months" is totally
unrealistic. Although, I suppose that if the entire Python community did
drop 2.7-3.6 and move to 3.7 within just one or two months so they could
use this syntax, that would certainly vindicate the (hypothetical)
decision to add this syntax.
But honestly, no. This is not going to happen. .Net VB and C# have
something like this, as does Lua, and people still write classes the
ordinary way 99.99% of the time.
The chances of this becoming the required, or even the recommended, way
to write methods is much less than the chances of President Trump
introducing Sharia law to the United States.
> And all it will take is some bureaucratic minded person to put that as default
> option in some highly used linter, like the one that used-to-be-known-as-pep8.
Do you *really* think that a linter that used to be called "PEP8" is
going to require as a default syntax which (1) doesn't work before
Python 3.7 at the earliest, and (2) has no support in PEP-8?
It's one thing to question whether this feature is useful enough to be
worth adding. It's another to make panicky claims that the Sky Will Fall
if it is accepted.
--
Steve
More information about the Python-ideas
mailing list