The fundamental use-case here is "any object that needs to know its own name". Most objects need more than just a name.
A more general solution could be:
def x, y, z as <expression>
Where <expression> should return a callable that accept only one argument. So, you can do some like:
def Type(bases, namespace): def get_name(name): return type(name, bases, namespace) return get_name
def x, y, z as Type(bases, namespace)
That is a syntax sugar of:
dummy = Type(bases, namespace) x = dummy("x") y = dummy("y") z = dummy("z")
2016-05-31 12:27 GMT-03:00 David Mertz email@example.com:
This is bikeshedding a bit, but a keyword that looks good to me:
expose Typevar as T expose Symbol as X On May 31, 2016 2:06 AM, "Paul Moore" firstname.lastname@example.org wrote:
On 31 May 2016 at 09:56, Stephen J. Turnbull email@example.com wrote:
I know you don't think a keyword works for you, but either the recently reraised "def <name> = <type-expr>" or perhaps "type <name>: <type-expr>" make more sense to me right out of the box.
I was thinking along the lines of "name <some_keyword> callable", which I don't think works because it needs some "punctuation" to separate the name from the callable.
But "def name = callable" (or some other preceding keyword combined with =) might work. I don't like "type" though, as the point here (I thought - see below) is to come up with a construct useful for more than just types.
I'm +1 for stopping the bikeshedding until we've all got a lot of stubfile reading under our belts.
If this was simply about type definitions, I'd agree. But I thought the point of Guido's post was that having seen two examples (TypeVar and Symbol) is there a more general approach that might cover these two cases as well as others? So just looking at the problem in terms of stub files isn't really the point here.
Paul _______________________________________________ Python-ideas mailing list Pythonfirstname.lastname@example.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Python-ideas mailing list Pythonemail@example.com https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/