Alex Hall writes:

 > OK, that's fair. What about `{foo::}`?

I don't like any of these, I'm just saying why, when I can.  People
who are going to use the syntax should choose it.

 > I would personally be quite happy if I could replace:
 > 
 > ```
 > class A:
 >     def __init__(self, foo, bar, spam):
 >         self.foo = foo
 >         self.spam = spam
 >         self.bar = bar
 > ```
 > 
 > with something like:
 > 
 > ```
 > class A:
 >     def __init__(self, foo, bar, spam):
 >         setattrs(self, **, foo, bar, spam)
 > ```
 > 
 > Wouldn't you?

No, I doubt I would use that.  But I apologize for wasting your time
on that comment.  It turns out to be incoherent and I shouldn't have
mentioned it.

 > Please make a PR showing how you would refactor some of these.

It's not my problem, though.  A syntax change is a high bar to clear.
As an advocate, you need to show that this is useful enough to be
worth it.  A dozen examples in the whole stdlib?  I'm not going to do
hours of work understanding those modules and refactoring perfectly
good code.

I will outline what I'd look at, though.  The two dicts look fine to
me as they are.  In fact, in general the vertically formatted examples
look fine to me, and I see no reason to refactor them.  If I were
designing the dicts now, I probably would use enums.  Something like:

class LogLevel(IntEnum):
    CRITICAL = 6
    FATAL = 5
    ERROR = 4
    WARN = 3
    WARNING = 3
    INFO = 2
    DEBUG = 1
    NOTSET = 0
_nameToLevel = { member.name : member for member in LogLevel }

There are four calls to super (all in argparse), which seems to be due
to heavy use of mixins.  I don't use mixins much, so I don't know if
it's avoidable or not.  I would not redesign to avoid mixins, though.

There are the two calls to cls (in json/__init__.py).  I doubt the
redundancy is avoidable.  Both the calls to super and the calls to cls
seem to be idiosyncratic to the authors of those particular modules,
but if the plethora of same name arguments is typical of these
techniques, that would be some support for a syntax change.

That leaves four various other examples in the whole stdlib, not very
many.  Although I'm sure you'd find more with a lower limit, I doubt
they're as convincing as the ones with many same name arguments.
We'll see what the senior committers have to say, but I think you have
an uphill battle on your hands.

Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/3SMK37XLIA7JVPGLJ6SC2LL62J2QNIZJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to