On Fri, Feb 25, 2011 at 6:21 PM, <s...@uce.gov> wrote: > > When I do: > > datetime.datetime.now().isoformat(' ') > > I get the time with the microseconds. The docs says: > "if microsecond is 0 YYYY-MM-DDTHH:MM:SS+HH:MM". > > How do I set microsecond to 0? > > >>> datetime.datetime.microsecond = 0 > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: can't set attributes of built-in/extension type > 'datetime.datetime'
Here you're trying to modify the *class* itself, not an *instance* of the class like you want to. However, datetime.datetime instances are immutable anyway. You have to create a new instance with the desired values, as Ned Deily demonstrated. Cheers, Chris -- Your "From:" address is annoying. http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list