[Tutor] tagging pieces of information
Ian Witham
witham.ian at gmail.com
Tue Aug 28 05:44:44 CEST 2007
You may be able to use a dictionary to store your data chunks. eg:
>>> tagged_items = {('spam, swordfights'): 'ITEM A',
... ('swordfights', 'custard'): 'ITEM B'}
>>> [tagged_items[tags] for tags in tagged_items if 'spam' in tags]
['ITEM A']
>>> [tagged_items[tags] for tags in tagged_items if 'swordfights' in tags]
['ITEM A', 'ITEM B']
or..
>>> for tags in tagged_items:
... if 'custard' in tags:
... print tagged_items[tags]
...
ITEM B
Ian.
On 8/28/07, Che M <pine508 at hotmail.com> wrote:
>
> Hi, I am curious about ways in Python to approach the idea of "tagging"
> pieces of information much in the way that one can tag favorite websites
> like on the site Del.icio.us. I'm not sure if tagging is the best term
> for
> this (due to confusion with HTML tags), but the idea would be a way to
> assign one or more words to stored data such that later one might search
> by
> those words in order to retrieve the data. That data might be a chunk of
> text, a graph, image, whatever...the point would be to be able to search
> later by tags name. I know the prorgram GyrFalcon uses tags and is
> written
> in Python. And of course Flickr and many other things.
>
> I don't know if there are any preexisting Python structures which would
> help
> with this or if it has to be done by scratch, or if it is easy or
> difficult.
> I also don't know what are good ideas for ways to save the tags, whether
> in a text file, in a database (if so, comma separated in one cell?), or
> some
> other means, and how to associate them with the data chunk they refer to,
> and lastly how to search for them.
>
> Some starting points in the right direction, jargon words to search for,
> etc., would be very helpful. Thanks.
>
> _________________________________________________________________
> Learn.Laugh.Share. Reallivemoms is right place!
> http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070828/fd6a2c19/attachment.htm
More information about the Tutor
mailing list