Sep-11-2018, 11:33 PM
i have written a script that gets one or more numeric values on a command line (ultimately from sys.argv). i would like to include an ability to let the user give a range a have the script work the same as if that range's numbers were typed in. i have tried a couple of ways to do this. one of them was to run each argument through eval() and work with the results. if the result was an int, it was just collected into the list of ints. otherwise the result was run through list() and if that succeeded, that list was concatenated to the list of ints. that allowed the user to use a range() call or any other call that created an iterator. the other method i tried was to see if the argument had a ":" in it. if so, then it was split(":") and if the result was length 2 or 3, it was fed to range() as 2 or 3 arguments. a disadvantage to this was that it did not provide a means to give range() just one argument. it also did not provide a means to call other functions.
which of these should i use or do you have another idea?
which of these should i use or do you have another idea?
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.