trictionary?
Randy Bush
randy at psg.com
Mon Aug 29 13:38:07 EDT 2005
> So I'm going to try to pump you for a little more information here. Is
> your goal to count, for each week, how many times it's "full" and how
> many times it's "not full"? What do you use the counts for? What does
> "full" mean? Is it always a 0 or 1? What's the importance of the
> output formatting?
'full' is boolean. it says whether a particular bgp announcement
was for the entire ip address allocation, or is a longer prefix.
e.g., if an allocation was for 666.42.0.0/16 and we heard a bgp
announcement for 666.42.1.0/24 that is !full, while an announcement
for the prefix 666.42.0.0/16 is full.
you asked :-)
> for start, end, AS, full in heard:
> week = int((start-startDate)/aWeek)
> if week in bin:
> bin[week][not full] += 1
> else:
> # I'm assuming "full" takes the values 0 or 1
> # but if not, you can coerce it with bool()
> bin[week] = [full, int(not full)]
hmmm. this also reads well.
as an old pascal and modula-2 bondage and discipline type, i gotta
say is it a breath of fresh air to be in a language and community
which care about how code reads more than how clever it is.
randy
More information about the Python-list
mailing list