On Wed, Dec 23, 2009 at 3:03 PM, MRAB <pyt...@mrabarnett.plus.com> wrote:
> Victor Subervi wrote: > >> I've isolated the problem in the print-out at the bottom of this post. It >> occurs when these values are passed: >> >> ['LastDatePrice', 'date', '10', 'yyyy/mm/dd', None], >> >> Since this is the first datetime that is passed, it would appear to be >> associated with such values, which are processed thus: >> >> elif typeName == 'datetime': >> > > Where does the value of typeName come from? It is the descriptor of the MySQL type. > > > print "<input type='text' width='%s' maxlength='%s' name='%s' >> value='%s' /> " \ >> "<i>This field takes a datetime up to %s alphanumeric characters >> inclusive.</i>" \ >> % (shortNum, str(typeNum), colName, theVal, str(typeNum)) >> >> colName == 'LastDatePrice' >> typeNum = 10 >> >> elif 10 < int(typeNum) < 20: >> > > If typeNum is 10 then 10 < int(typeNum) < 20 is False. Thank you for catching that! However, the code is followed by an else clause. > > > shortNum = '10' >> >> Therefore... >> shortNum = '10' >> >> if whatDo == 'insert': >> theVal = defaultVal >> val = defaultVal >> >> What's the difference between theVal and val? The names don't help me! > :-) if whatDo == 'insert': theVal = defaultVal val = defaultVal else: theVal = val > > > Since whatDo == 'insert'... >> and >> val = 'yyyy/mm/dd' >> therefore >> theVal = None >> >> Now, this value of None doesn't cause any problems with the other values >> printed out. This is the code: >> >> print 'printTheForm: ', descrProds, '<br />' >> for value in descrProds: >> print 'value: ', value, '<br />' >> >> that produces this print-out: >> >> printTheForm: [['ID', 'tinyint', '5', '0', None], ['SKU', 'varchar', '40', >> '', None], ['Category', 'varchar', '40', '', None], ['Name', 'varchar', >> '50', '', None], ['Title', 'varchar', '100', '', None], ['Description', >> 'mediumtext', '100', '', None], ['Price', 'float', '8', '0.0', None], >> ['SortFactor', 'int', '4', '0', None], ['Availability', 'tinyint', '1', '0', >> '1'], ['OutOfStock', 'tinyint', '1', '0', '0'], ['ShipFlatFee', 'float', >> '5', '0.0', '0.00'], ['ShipPercentPrice', 'tinyint', '2', '0', '0'], >> ['ShipPercentWeight', 'tinyint', '2', '0', '0'], ['Associations', 'varchar', >> '40', '', None], ['TempPrice', 'tinyint', '1', '0', None], ['LastDatePrice', >> 'date', '10', 'yyyy/mm/dd', None], ['Weight', 'float', '7', '0.0', None], >> ['Metal', 'enum', ['14k gold', '18k gold', 'white gold', 'silver', >> 'tungsten', 'titanium'], '', None], ['PercentMetal', 'tinyint', '2', '0', >> None], ['colorsShadesNumbersShort', 'set', [''], '', None]] >> value: ['ID', 'tinyint', '5', '0', None] >> value: ['SKU', 'varchar', '40', '', None] >> value: ['Category', 'varchar', '40', '', None] >> value: ['Name', 'varchar', '50', '', None] >> value: ['Title', 'varchar', '100', '', None] >> value: ['Description', 'mediumtext', '100', '', None] >> value: ['Price', 'float', '8', '0.0', None] >> value: ['SortFactor', 'int', '4', '0', None] >> value: ['Availability', 'tinyint', '1', '0', '1'] >> value: ['OutOfStock', 'tinyint', '1', '0', '0'] >> value: ['ShipFlatFee', 'float', '5', '0.0', '0.00'] >> value: ['ShipPercentPrice', 'tinyint', '2', '0', '0'] >> value: ['ShipPercentWeight', 'tinyint', '2', '0', '0'] >> value: ['Associations', 'varchar', '40', '', None] >> value: ['TempPrice', 'tinyint', '1', '0', None] >> value: ['LastDatePrice', 'date', '10', 'yyyy/mm/dd', None] >> >> If in fact the problem has to do with the None value, how can I easily >> substitute a different value? I tried: >> >> if theVal == None: >> > > The Pythonic way is to use "is" when comparing with singletons like > > None. > Can you please explain by example? > > theVal = '' >> >> but that didn't capture it. >> >> What do you mean by "didn't capture it"? > The output was identical to what I originally posted. TIA, beno
-- http://mail.python.org/mailman/listinfo/python-list