Re: outputting time in microseconds or milliseconds

2013-08-08 Thread Roy Smith
In article , Skip Montanaro wrote: > When Tim Peters wrote datetime, the world became a better > place. Lots of languages and databases have things called datetimes. It's easy to be lulled into thinking that they're all the same, but they're not. They all have slightly different ranges an

Re: outputting time in microseconds or milliseconds

2013-08-08 Thread Skip Montanaro
> i did: > >from time import strftime, time >from datetime import datetime > >now = datetime.now() > >self.logfile.write('%s\t'%(strftime("%Y-%m-%d",))) >self.logfile.write('%s\t'%(now.strftime("%H:%M:%S.%f",))) Note that you don't need the time module here. Datetime objects h

Re: outputting time in microseconds or milliseconds

2013-08-07 Thread matt . doolittle33
> > Taking a step back, you're probably better off using datetimes. You'll > > get all this conversion nonsense for free: > i did: from time import strftime, time from datetime import datetime now = datetime.now() self.logfile.write('%s\t'%(strftime("%Y-%m-%d",))) self.logf

Re: outputting time in microseconds or milliseconds

2013-08-05 Thread Ulrich Eckhardt
Am 02.08.2013 15:17, schrieb matt.doolittl...@gmail.com: so you are saying that self.logfile.write('%s\t'%(str(time( should be: self.logfile.write('%s\t'%(str(time.time( No, I'm not saying that. What I wanted to make clear is that your code is impossible to understand as it

Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Roy Smith
In article <07f6b1c7-069d-458b-a9fe-ff30c09f2...@googlegroups.com>, matt.doolittl...@gmail.com wrote: > self.logfile.write('%s\t'%(str(time( > [...] > 1375588774.89 > [...] > Why is it only giving me the centisecond precision? the docs say i should > get microsecond precision When citing d

Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Dave Angel
matt.doolittl...@gmail.com wrote: > ok so now i import the module like this: > >from time import strftime, time > > i made the write statement like this: > >self.logfile.write('%s\t'%(str(strftime("%Y-%m-%d", >self.logfile.write('%s\t'%(str(strftime("%H:%M:%S", >self.logf

Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Alain Ketterlin
matt.doolittl...@gmail.com writes: >self.logfile.write('%s\t'%(str(time( [...] > 2013-08-0323:59:341375588774.89 [...] > Why is it only giving me the centisecond precision? the docs say i > should get microsecond precision with the code i put together. Because of str()'s defau

Re: outputting time in microseconds or milliseconds

2013-08-04 Thread matt . doolittle33
ok so now i import the module like this: from time import strftime, time i made the write statement like this: self.logfile.write('%s\t'%(str(strftime("%Y-%m-%d", self.logfile.write('%s\t'%(str(strftime("%H:%M:%S", self.logfile.write('%s\t'%(str(time( (oh and btw,i kno

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Skip Montanaro
> is the third column is only the microsecond? Yes. > how could i get this to write with the rest of the time (the hh:mm:ss) ? It sounds like you really want the time formatted in a particular way, not just the numeric value of one or more fields. Look at the documentation for the strftime meth

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread matt . doolittle33
On Friday, August 2, 2013 8:35:13 AM UTC-4, Steven D'Aprano wrote: > On Fri, 02 Aug 2013 03:54:32 -0700, matt.doolittle33 wrote: > > > > > Hey everybody, > > > > > > I am using 2.7 on Ubuntu 12.10. All I need to do is to print time with > > > the microseconds. I have been looking at the do

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread matt . doolittle33
On Friday, August 2, 2013 8:37:45 AM UTC-4, Skip Montanaro wrote: > Perhaps use datetime? > > > > >>> now = datetime.datetime.now() > > >>> now.isoformat() > > '2013-08-02T07:37:08.430131' > > >>> now.strftime("%f") > > '430131' > > > > Skip Thanks Skip, what i currently i have is:

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread matt . doolittle33
so you are saying that self.logfile.write('%s\t'%(str(time( should be: self.logfile.write('%s\t'%(str(time.time( ??? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Chris Angelico
On Fri, Aug 2, 2013 at 1:08 PM, Dave Angel wrote: > matt.doolittl...@gmail.com wrote: > >> Hey everybody, >> >> I am using 2.7 on Ubuntu 12.10. > > and what version of Python are you using? I don't know if it matters, > but it's useful to always supply both Python version and OS version. > Looks

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Steven D'Aprano
On Fri, 02 Aug 2013 03:54:32 -0700, matt.doolittle33 wrote: > Hey everybody, > > I am using 2.7 on Ubuntu 12.10. All I need to do is to print time with > the microseconds. I have been looking at the docs and trying things for > about half a day now with no success. Currently my code looks like

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Skip Montanaro
Perhaps use datetime? >>> now = datetime.datetime.now() >>> now.isoformat() '2013-08-02T07:37:08.430131' >>> now.strftime("%f") '430131' Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Ulrich Eckhardt
Am 02.08.2013 12:54, schrieb matt.doolittl...@gmail.com: I am using 2.7 on Ubuntu 12.10. All I need to do is to print time with the microseconds.[...] # write date and time and microseocnds self.logfile.write('%s\t'%(str(strftime("%Y-%m-%d", self.logfile.write(

Re: outputting time in microseconds or milliseconds

2013-08-02 Thread Dave Angel
matt.doolittl...@gmail.com wrote: > Hey everybody, > > I am using 2.7 on Ubuntu 12.10. and what version of Python are you using? I don't know if it matters, but it's useful to always supply both Python version and OS version. > All I need to do is to print time with the microseconds. I have b

outputting time in microseconds or milliseconds

2013-08-02 Thread matt . doolittle33
Hey everybody, I am using 2.7 on Ubuntu 12.10. All I need to do is to print time with the microseconds. I have been looking at the docs and trying things for about half a day now with no success. Currently my code looks like this: # write date and time and microseocnds self.