Building Time Based Bins
MCD
mcdesigns at walla.com
Tue Mar 22 23:51:49 EST 2005
Michael Spencer wrote:
> (BTW, there must be more to your code than you have shared for the
above line to
> execute without raising an exception - where are 'time' and 'a'
initially bound?
> BTW2, 'time' is the name of a stdlib module, so it's bad practice to
use it as
> an identifier)
Yes there is more, I was copy/pasting a bit haphazardly as I see now.
You're right about the identifier, I changed it in my current code to
"t".
> > print " ==>> %04d %2d" % (bintm, binl) ## this is the bin
> This is where you've declared that you have a bin, so add it to the
bins cache:
> bins.append((bintm, binl))
> > bintm = newbintm
> > binl = a
> >
> Michael
Thanks Michael, I haven't been able to read my mail so I ended up
placing the append a bit differently than the way you described, and
somehow got it working... your way looks much easier :-). I'm going to
try that right now.
I've mostly been racking my brain with this bit of code:
newtm = ((klock + 4) // 5 * 5 ) % 2400
It works ok until you get to the last five minutes of the hour. For
instance, 956 will return 960... oops, that's not gonna work :). I
don't completely understand how this code is doing what it's doing...
I've played around with different values, but it's still a bit of a
mystery in coming up with a solution. My only work around that I've
been able to come up with is to add 40 to newtm when the last 2 digits
are at 60, but I'm still working on how to do that.
Anyway, thanks for your help, mentioning the append function... that
really opened up a lot of solutions/possibilities for me.
Take care,
Marcus
More information about the Python-list
mailing list