[Python-ideas] Augmented assignment syntax for objects.

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Apr 26 17:50:01 EDT 2017


On 26/04/2017 21:50, Chris Angelico wrote:
> On Thu, Apr 27, 2017 at 6:24 AM, Erik <python at lucidity.plus.com> wrote:
>> The background is that what I find myself doing a lot of for private
>> projects is importing data from databases into a structured collection of
>> objects and then grouping and analyzing the data in different ways before
>> graphing the results.
>>
>> So yes, I tend to have classes that accept their entire object state as
>> parameters to the __init__ method (from the database values) and then any
>> other methods in the class are generally to do with the subsequent analysis
>> (including dunder methods for iteration, rendering and comparison etc).
> 
> You may want to try designing your objects as namedtuples. That gives
> you a lot of what you're looking for.
> 
> ChrisA
> 

Something like https://docs.python.org/3/library/sqlite3.html#row-objects ?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Python-ideas mailing list