Python Forum

Full Version: ranch expression
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i have in mind a few commands i want to implement in which arguments or input will need to express a number or a range (possibly with an increment). i want to implement a function that will take a string with such an expression and return a list of 1 to 3 numbers (generally ints but perhaps also floats .. maybe even complex) being expressed. a simpler command i will rewrite is one that outputs select lines from a file. i am looking for ideas on what the syntax of a range expression in a string (str or bytes) should be like so i can first write a parser function for it that returns a list if it is in a valid firm or False if it is invalid (None if the arguments are bad, such as the expression being an unparseable type). what are your ideas?