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
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
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?
--
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
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
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
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
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
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
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.
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
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
--
computers are cheap. i am expensive. give me clear and maintainable
code every time.
randy
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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():
17 matches
Mail list logo