Is there a way to create a list using both strings and a generator (for loop).
list() only takes one argument. The only way I can see so far is:
row = ['string1','string2']+list((t.string3[-7:]) for t in tobject)
What am I missing?
Is there a way to create a list using both strings and a generator (for loop).
list() only takes one argument. The only way I can see so far is:
row = ['string1','string2']+list((t.string3[-7:]) for t in tobject)
What am I missing?
Do you need to do it in only one line? chain() works, but it looks so unreadable to me. The following is probably less elegant, but I think it's far more readable:
row = ['string1', 'string2']
row.extend(t.string3[-7:] for t in tobject)
No, you have to concatenate two lists.
You may prefer to chain the iterables and then call list on them once.