[Tutor] Structuring a class

Hilton Fernandes hgfernan at gmail.com
Tue Jun 15 20:17:31 CEST 2010


inded, a relational database is the best bet here.

however, a direct implementation in Python may need less previous knowledge.

On Tue, Jun 15, 2010 at 4:44 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "Lang Hurst" <lang at tharin.com> wrote
>
>> I'm trying to figure out how to deal with data which will look something
>> like:
>>
>>   Student:Bob Hurley
>>   Credits:
>>      Algebra C (20P)
>>            Chapter 1
>>            Chapter 2
>>      Consumer Math (24G)
>>            Module 2
>>
>> So, I just figured that I would have a couple of nested dictionaries.
>
> Or 3 classes: Student, Credit, Module
>
> But classses will be most useful if you are doing a lot of
> interaction between the students or calculations based on the credits.
>
> As Bob suggested, if you mainly just want to add/delete/modify
> and report on the data a database is a better bet.
>
> You mght still create a Student class to structure the data
> coming back from the database but the other classes will
> probably be overkill and your double dict will be as effective.
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list