[Tutor] Recognizing real numbers
Dave Angel
d at davea.name
Thu Feb 23 03:08:01 CET 2012
On 02/22/2012 08:54 PM, Michael Lewis wrote:
> On Wed, Feb 22, 2012 at 2:52 PM, Dave Angel<d at davea.name> wrote:
> <SNIP>
>
> I actually have a function written in my imported file to check if
> a string is a valid float, but I didn't use it because I also have
> raw_input in that same function, which I don't want. I'll rework the
> imported function to remove the raw_input and put that in a function by
> itself so I can utilize the valid float try/except that I've already
> written.
>
That alone is a valuable lesson. When writing functions, try to make
each function do one task, thoroughly and flexibly. Then it's much more
likely to be reusable.
--
DaveA
More information about the Tutor
mailing list