On Wed, Sep 1, 2010 at 9:26 AM, Shashwat Anand <anand.shash...@gmail.com>wrote:
> > > On Wed, Sep 1, 2010 at 6:45 PM, Matt Saxton <m...@scotweb.co.uk> wrote: > >> On Wed, 1 Sep 2010 09:00:03 -0400 >> Victor Subervi <victorsube...@gmail.com> wrote: >> >> > Hi; >> > I have this code: >> > >> > cursor.execute('describe products;') >> > cols = [item[0] for item in cursor] >> > cols = cols.reverse() >> > cols.append('Delete') >> > cols = cols.reverse() >> > >> > Unfortunately, the list doesn't reverse. If I print cols after the first >> > reverse(), it prints None. Please advise. >> >> The reverse() method modifies the list in place, but returns None, so just >> use >> >>> cols.reverse() >> >> rather than >> >>> cols = cols.reverse() >> > > Alternatively you can do \, > > >>>cols = reversed(cols) > Thanks again, all beno
-- http://mail.python.org/mailman/listinfo/python-list