[Python-Dev] Third and hopefully final post: PEP 557, Data Classes

Serhiy Storchaka storchaka at gmail.com
Thu Nov 30 06:56:52 EST 2017


30.11.17 03:02, Guido van Rossum пише:
> I tried to look up the discussion but didn't find much except that you 
> flagged this as an issue. To repeat, your concern is that isdataclass() 
> applies to *instances*, not classes, which is how Eric has designed it, 
> but you worry that either through the name or just because people don't 
> read the docs it will be confusing. What do you suppose we do? I think 
> making it work for classes as well as for instances would cause another 
> category of bugs (confusion between cases where a class is needed vs. an 
> instance abound in other situations -- we don't want to add to that). 
> Maybe it should raise TypeError when passed a class (unless its 
> metaclass is a dataclass)? Maybe it should be renamed to 
> isdataclassinstance()? That's a mouthful, but I don't know how common 
> the need to call this is, and people who call it a lot can define their 
> own shorter alias.

There is isdatadescriptor() which is not too shorter.



More information about the Python-Dev mailing list