Converting a naïve Python datetime object from one timezone to another

Suppose you have a naïve datetime object (one without associated timezone information) that you know is in, say, Austin localtime, and you want the equivalent in another timezone, say, UTC.

print my_dt

import pytz
austin = pytz.timezone("America/Chicago")
utc_dt = austin.localize(my_dt).astimezone(pytz.utc).replace(tzinfo=None)

print utc_dt

localize is important. my_dt.replace(tzinfo=austin) is not correct during summer time, for instance.