May-27-2018, 01:43 AM
i have a sequence and a list/tuple of similar sequences. i want to find if any of the sequences in the list/tuple are in the first sequence. i know how i can make a loop to do this. is there any better, or more elegant, or uber pythonic way i should do this? in the use case i have today, sequence is string, but if the good solution can handle other sequence types, then it could be a solution for future use cases. it would also be great if after that code runs, i also end up with which sequence was found in the first sequence. order matters for this latter benefit. if two or more are in it the earlier in the list/tuple is the one i care about.
or
my use case might be better dealt with some other way. i have an argument that could be a single number or a range. the number separator will also indicate if the 2nd number is inclusive or exclusive. the range will be like that in the posix cut command which is '-' and inclusive, but i will be adding '..' and ':' as exclusive ways to express a range. in my current use case only integers make sense. in the future, use cases may include floats and names.
or
my use case might be better dealt with some other way. i have an argument that could be a single number or a range. the number separator will also indicate if the 2nd number is inclusive or exclusive. the range will be like that in the posix cut command which is '-' and inclusive, but i will be adding '..' and ':' as exclusive ways to express a range. in my current use case only integers make sense. in the future, use cases may include floats and names.
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.