On Thu, 4 Feb 2010 07:39:29 -0800 (PST)
Albert-Jan Roskam <fo...@yahoo.com> wrote:

> Hi,
>  
> A dictionary (associative array of keys and values) seems a good datatype to 
> use.
> vocab = {}
> vocab[frenchword] = englishword
>  
> For instance:
> >>> vocab = {"aimer": "love"}
> >>> vocab
> {'aimer': 'love'}
> >>> vocab["parler"] = "speak"
> >>> vocab
> {'aimer': 'love', 'parler': 'speak'}
> >>> for engword, frword in vocab.iteritems():
>  print "%s - %s" % (engword, frword)
>  aimer - love
> parler - speak
>  
> But if one word has different meanings in the other language, you may need to 
> use a list of words as the values.
> 
> Cheers!!
> Albert-Jan

Sure, a dict is the obvious choice. For saving into file, if the app is to be 
used internally, you can even print it in the form of a python dict (with the 
'{}', ':' & ',') so that reading the dict data is just importing:
    import french_english

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to