Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-17 Thread Alan Gauld via Tutor
On 17/05/16 18:11, Ek Esawi wrote: > output comes out in the correct format (the desired output as shown below). > I used converters to covert time and date values, but all came out in > string format (output below). What makes you think they are strings? I would expect to see quote signs if they

[Tutor] genfromtxt and dtype to convert data to correct format

2016-05-17 Thread Ek Esawi
Hi All— I am reading data from a file using genfromtxt. A part of my data (input, output, and desired output) is shown below which consists of string, integer, time, and date type data. I want to read the data so that the output comes out in the correct format (the desired output as shown below)

Re: [Tutor] sqlite

2016-05-17 Thread Terry Carroll
On Tue, 3 May 2016, Crusier wrote: I am just wondering if there is any good reference which I can learn how to program SQLITE using Python I can not find any book is correlated to Sqlite using Python. "The Definitive Guide to SQLite" is about SQLite, but includes a chapter on both PySQLite a

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Steven D'Aprano
On Tue, May 17, 2016 at 06:56:40PM -0400, Chris Kavanagh wrote: > Thank you so much for the help, and the example! > > So, by putting quotes around a dict key, like so dict["key"] or in my case > cart["item"] this makes the dict have ONE key. The loop assigns the > cart_items to this ONE key until

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Alan Gauld via Tutor
On 17/05/16 23:56, Chris Kavanagh wrote: > So, by putting quotes around a dict key, like so dict["key"] or in my case > cart["item"] this makes the dict have ONE key. The loop assigns the > cart_items to this ONE key until the end of the loop, and I'm left with > {'item': 5}. . . > > Where as if

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Chris Kavanagh
Thank you so much for the help, and the example! So, by putting quotes around a dict key, like so dict["key"] or in my case cart["item"] this makes the dict have ONE key. The loop assigns the cart_items to this ONE key until the end of the loop, and I'm left with {'item': 5}. . . Where as if you

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread cs
On 17May2016 04:28, Chris Kavanagh wrote: Could someone tell me why this different behavior occurs between these 2 code snippets, please. The 1st example has quotes around it ['item'] only adds the last item to the dict (cart). In the 2nd example the item does not have quotes around it [item] an

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Alan Gauld via Tutor
On 17/05/16 09:28, Chris Kavanagh wrote: > # Example #1 > cart_items = ['1','2','3','4','5'] > > cart = {} > > for item in cart_items: > cart['item'] = item 'item' is a literal string. It never changes. So you keep overwriting the dict entry so that at the end of the loop the dict contains

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Sibylle Koczian
Hello, Am 17.05.2016 um 10:28 schrieb Chris Kavanagh: Could someone tell me why this different behavior occurs between these 2 code snippets, please. The 1st example has quotes around it ['item'] only adds the last item to the dict (cart). In the 2nd example the item does not have quotes around

[Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Chris Kavanagh
Could someone tell me why this different behavior occurs between these 2 code snippets, please. The 1st example has quotes around it ['item'] only adds the last item to the dict (cart). In the 2nd example the item does not have quotes around it [item] and every entry is added to the dict. Why? #