Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Class or dictionary ? (was: class or inherited list ?)

Reply
Thread Tools

Class or dictionary ? (was: class or inherited list ?)

 
 
Stef Mientki
Guest
Posts: n/a
 
      03-28-2008
Sorry,
although the code example was correct,
the question was wrong.

Stef Mientki

Stef Mientki wrote:
> hello,
>
> Passing all kinds of data between objects,
> I'm looking for an elegant (and simple) way to pack the data.
> Now it looks to me that both the class and the inherited list,
> performs equally well.
> Till now, the most elegant way (in my view) is the list inheritance,
> mainly because you don't need brackets and no quotes.
> What are others opinion about this ?
>
> thanks,
> Stef Mientki
>
> class super_list(list):
> pass
>
> def kwadraat ( value ) :
> return value * value
>
> x={}
> x['frequency']=33
> x['functie']=kwadraat
> print x['functie'](2)
>
> y = super_list()
> y.frequency = 33
> y.functie = kwadraat
> print y.functie(3)
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance ordered dictionary vs normal dictionary Navkirat Singh Python 6 07-29-2010 10:18 AM
class or inherited list ? Stef Mientki Python 0 03-28-2008 03:15 PM
'Class.inherited' v. 'inherited' syntax inside Class 7stud -- Ruby 11 11-09-2007 06:45 PM
creating a dictionary from a dictionary with regex james_027 Python 1 08-22-2007 07:39 AM
[DICTIONARY] - Copy dictionary entries to attributes Ilias Lazaridis Python 6 02-21-2006 11:27 AM



Advertisments