[Tutor] Need to discuss about a class that can be used to print number of vowels, consonants, uppercase and lowercase letters and spaces in a string
Alan Gauld
alan.gauld at yahoo.co.uk
Fri Aug 20 03:49:39 EDT 2021
On 20/08/2021 01:25, Mats Wichmann wrote:
> On 8/19/21 6:23 PM, Alan Gauld via Tutor wrote:
>
>> Just so... If the class only has an init() and a __str__()
>> is it really a class?
>>
>
> but it might be... a @dataclass :)
True, but I don't consider these to be real classes,
it's just substituting for Python's lack of a Record or
Structure class. It's one of the big lacks in Python and
traditionally filled by named tuples or dicts for one-off
instances or a method-free class for collections.
But it's all a bit of a kludge in my opinion and encourages
abuse of OOP concepts. People claim that they have an OOP
program because they have some classes but in fact they only
have data structures.
OTOH it would be difficult to add a major new keyword and
structure into the language at this late date that didn't
break loads of existing code. How many programs out there
have 'record' or 'struct' or 'data' or similar as variable
names?!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list