General Python Tips
Convert a string to a date object
Convert a string to a list
from DateTime import DateTime
dateobj = DateTime(string)Convert a string to a list
This comes in handy when you offer a web form with multiple check boxes or options, delivered to your script in a list. Unfortunately, if only one option is selected, that option is stored in a string variable, rather than a single-element list. To remedy this situation, you can use this quick string-to-list conversion before attempting any looping on the list:
if samplesList.count(samplesList) == 1:
samplesList = [samplesList]
Need assistance with your project? Universal Web Services can help.
Contact us to request a quote.