Something More Elegant

Iuri iurisilvio at gmail.com
Sat Jan 9 14:30:17 CET 2010


Your code select some ids from database and list distinct ids in packageIDs.
You can use SELECT DISTINCT in your SQL statement.



On Sat, Jan 9, 2010 at 11:23 AM, Victor Subervi <victorsubervi at gmail.com>wrote:

> Hi;
> The following code works fine. I would like you to suggest something more
> simple and elegant:
>
>       sql = 'select p.ID from %sPackages p join %sCategoriesPackages c
> where c.CategoryID=%s;' % (store, store, categoryID)
>       cursor.execute(sql)
>       tmp = [itm[0] for itm in cursor]
>       packageIDs = []
>       for t in tmp:
>         if t not in packageIDs:
>           packageIDs.append(t)
>
> TIA,
> beno
>
> --
> The Logos has come to bear
> http://logos.13gems.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100109/cf466c45/attachment.html>


More information about the Python-list mailing list