This is my take - form a production code (I use it to load
Ooops, seems like I misread the question (I saw the post by @ljmetzger - and misinterpreted the OP). Of course, this a method for string conversion.
ini
files - thus the name)def convert_config_value(value): for numeric_type in (int, float): try: converted_value = numeric_type(value) return converted_value except ValueError: pass return value
Ooops, seems like I misread the question (I saw the post by @ljmetzger - and misinterpreted the OP). Of course, this a method for string conversion.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.