python 3 - instantiating class from user input
computer_brad at yahoo.com
Thu Apr 7 06:04:44 CEST 2011
I dont understand why this is such a big deal. Nor do i understand why google can't find a reasonable answer. If one can't figure out from the title what I'm trying to do, then a look at code should firmly plant the intent. The general idea of the code is, in my opinion, very basic.
I notice, that when you are coding a class instance, it's in the format of:
newInstance = someClass()
OK, so we are calling someClass as if it's a function. Is there a way to do something to the effect of:
I've seen all kinds of hacks and workarounds that seem 10 times more complicated that this ought to be.
itsDecrtiption = None
itsVendor = None
itsCost = None
itsMarkup = None
itsQuantity = None
newItem = input('enter the new item to add to inventory')
findItem = input('enter the item number to find')
More information about the Python-list