[Tutor] Fwd: make a sqlite3 database from an ordinary text file
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Jun 19 14:09:02 EDT 2022
On 19/06/2022 18:52, Manprit Singh wrote:
> One more thing :
> def data_generator(workfile):
> with open(workfile) as obj:
> obj.readline()
> for line in obj:
> yield tuple(line.split())
>
> Instead of yield tuple(line.split()) i can write yield line.split()
> too.
>
> Am i right ?
It depends what you want. The first one gives a tuple
back, the second gives a list.
Often it won't make any difference but if you were using
the value as a dictionary key, say, then only the first
would work.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list