i am getting a value or reference from some place. i'll call it
i am looking for an existing way to make a non-iterator into a 1-list (actually, just need to iterate over it). having the non-iterator as the one element or if it is an iterator, either leave it as it is or convert it to another iterator form such as a list or tuple.
i can write a function to do this. or i can add extra lines of code and handle it that way. but, before i take that approach. i want to see if there is a nice way to do this inline with what comes with Python3 (e.g. nothing to install). if an idea can also be done in Python2 using the same code, that would be great, but not essential. it just needs to work in Python3.
it
. that place can be pretty much anywhere such as an element of a tuple. it
may or may not be a list. if i am getting it
from a set, it
cannot be a list. but in this expression i need for it
to be a list, even if the list is just one element having the original it
as that element. doing list(it)
won't work because it
might not be an iterator.i am looking for an existing way to make a non-iterator into a 1-list (actually, just need to iterate over it). having the non-iterator as the one element or if it is an iterator, either leave it as it is or convert it to another iterator form such as a list or tuple.
i can write a function to do this. or i can add extra lines of code and handle it that way. but, before i take that approach. i want to see if there is a nice way to do this inline with what comes with Python3 (e.g. nothing to install). if an idea can also be done in Python2 using the same code, that would be great, but not essential. it just needs to work in Python3.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.