Creating a single list
Xavier Ho
contact at xavierho.com
Sat May 29 09:40:48 EDT 2010
On 29 May 2010 23:24, Astley Le Jasper <astley.lejasper at gmail.com> wrote:
> def createlist():
> column_title_list = (
> ("id",20,"integer"),
> ("companyname",50,"text"),
> getproducts(),
> ("contact",50,"text"),
> ("email",50,"text"),
> )
> return column_title_list
>
Note that you're creating a Tuple, not a List. They're not the same thing.
Try this:
column_title_list = [
("id",20,"integer"),
("companyname",50,"text"),
("contact",50,"text"),
("email",50,"text"),
]
# Insert into the list with slicing syntax.
column_title_list[2:3} = getproduct()
This will not work with tuples, as they are immutable. Lists are.
Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100529/71a53387/attachment-0001.html>
More information about the Python-list
mailing list