how best to split into singleton and sequence

2005-10-18 Thread Randy Bush
l = [] s = 'a|b' t, l = s.split('|') t 'a' l 'b' s = 'a|b|c|d' t, l = s.split('|') Traceback (most recent call last): File stdin, line 1, in ? ValueError: too many values to unpack so, i imagine what is happening is the lhs, t,l, is really (t, (l)), i.e. only two items. so how should

Re: OpenSource documentation problems

2005-09-01 Thread Randy Bush
I'm very sorry to say, that the Python doc is one of the worst possible in the industry. you are entitled to a full refund -- http://mail.python.org/mailman/listinfo/python-list

Re: Arguement error

2005-08-31 Thread Randy Bush
I am wondering why I am getting this error. when I try to run a script. TypeError: translate() takes at most 3 arguments (10 given) but the thing is the method translate actually accepts 10 arguements. without code, how is anyone to know? --

Re: trictionary?

2005-08-29 Thread Randy Bush
bin = {} for start, end, AS, full in heard: week = int((start-startDate)/aWeek) counters = bin.setdefault(week, [0, 0]) if full: counters[0] += 1 else: counters[1] += 1 yes! thanks! Using an idea you used earlier, you could get

Re: trictionary?

2005-08-29 Thread Randy Bush
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

trictionary?

2005-08-28 Thread Randy Bush
i have some code which looks kinda like bin = {} for whatever: for [a, b] in foo: x = 42 - a y = 42 - b if bin.has_key(x): bin[x] += 1 else: bin[x] = 1 for i, j in bin.iteritems(): print i, j now i want

Re: trictionary?

2005-08-28 Thread Randy Bush
bin = {} for whatever: for [a, b] in foo: x = 42 - a if bin.has_key(x): bin[x.b] += 1 else: bin[x.b] = 1 bin[x.not b] = 0 for x, y, z in bin.iteritems(): print x, y, z should the dict value become a two

Re: need a little help with time

2005-08-27 Thread Randy Bush
i am doing disgusting looking junk based on calendar. example now = calendar.timegm(time.gmtime()) aWeek = 7*24*60*60 print time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(now + aWeek)) randy -- http://mail.python.org/mailman/listinfo/python-list

Re: Experience regarding Python tutorials?

2005-08-27 Thread Randy Bush
There is also a python tutor newsgroup at gmane (gmane.comp.python.tutor). is there a mailing list to which it is gated? randy -- http://mail.python.org/mailman/listinfo/python-list

Re: list insertion

2005-08-27 Thread Randy Bush
hold = self.next self.next = DaClass(value) self.next.next = hold but i suspect (from print statement insertions) that the result is not as i expect. as the concept and code should be very common, as i am too old for pride, i thought i would ask. I think you're fine. indeed.

Re: Jargons of Info Tech industry

2005-08-26 Thread Randy Bush
i left the usenet in the latter half of the '80s. a few weeks ago i decided i wanted to do a new project with a new language, and chose python. so i joined this mailing list, which is gated to the usenet. i am impressed that the s:n has not gotten significantly worse than when i left, about

Re: list insertion

2005-08-24 Thread Randy Bush
hold = self.next self.next = DaClass(value) self.next.next = hold shouldn't that last line be this? self.next.prev = hold single threaded list What did you expect, and what did you ovserve? i will try to distill a case randy --

Re: loop in python

2005-08-23 Thread Randy Bush
computers are cheap. i am expensive. give me clear and maintainable code every time. randy -- http://mail.python.org/mailman/listinfo/python-list

list insertion

2005-08-23 Thread Randy Bush
i am trying to insert into a singly linked list hold = self.next self.next = DaClass(value) self.next.next = hold but i suspect (from print statement insertions) that the result is not as i expect. as the concept and code should be very common, as i am too old for pride, i thought i

dict duplicity

2005-08-18 Thread Randy Bush
a dict written as pKey = (prefix, pLen, origin) val = dict.get(pKey) if val == None: dict[pKey] = (timeB, timeB) else: if val[0] timeB: val[0] = timeB if val[1] timeB: val[1] = timeB dict[pKey] = val and read back as for pKey, pVal in

Re: dict duplicity

2005-08-18 Thread Randy Bush
a dict written as pKey = (prefix, pLen, origin) val = dict.get(pKey) if val == None: dict[pKey] = (timeB, timeB) else: if val[0] timeB: val[0] = timeB if val[1] timeB: val[1] = timeB dict[pKey] = val and read back as for pKey, pVal in

Re: dict duplicity

2005-08-18 Thread Randy Bush
Firstly, to remove one possible source of confusion, change the name of your dictionary ... mydict or fred ... anything but dict Next, after you have created the dictionary and added items to it, do this: print len(fred) print len(fred.items()) nitems = 0 for k, v in fred.iteritems():