e in the newsgroup
or otherwise communicate this interest to the PSF so they have a feel
for how many people would take advantage of the donation option if they
offered it.
For those not familiar with the PSF, plenty of info can be found here:
http://python.org/psf/
Thanks!
Alan McIntyre
Thanks; I didn't read close enough. :)
--
Alan McIntyre
ESRG LLC
http://www.esrgtech.com
Michael Hoffman wrote:
Alan McIntyre wrote:
>>>class test(object):
...def __call1(self):
...print 1
...__call__ = __call1
Is that what you were looking for?
That still only allo
I tried this:
>>>class test(object):
... def __call1(self):
... print 1
... __call__ = __call1
...
>>>t = test()
>>>t()
1
>>>
Is that what you were looking for?
--
Alan McIntyre
ESRG LLC
http://www.esrgtech.com
Stefan Behnel wrote:
Hi!
This
d think of.
Hope this helps,
Alan McIntyre
ESRG LLC
http://www.esrgtech.com
Cyril BAZIN wrote:
Hello,
I want to build a function which return values which appear two or
more times in a list:
So, I decided to write a little example which doesn't work:
#l = [1, 7, 3, 4, 3, 2, 1]
#i = iter(l)
#for
Hope this helps,
Alan McIntyre
ESRG LLC
http://www.esrgtech.com
--
http://mail.python.org/mailman/listinfo/python-list
Thanks to everybody that responded; I appreciate all the input, even if
I didn't respond to all of it individually. :)
--
http://mail.python.org/mailman/listinfo/python-list
Earl,
Try this:
>>> ord('\x00')
0
or:
>>> import struct
>>> struct.unpack('b', '\x00')
(0,)
If you're needing to pull values out of multiple bytes (shorts, longs,
floats, etc.), have a look at the struct module. Here's an example:
>>> struct.unpack('f', '\x00\x00(B')
(42.0,)
Hope this helps,
Alan
Alex,
Wow, that method turns out to be the fastest so far in a simple
benchmark on Python2.3 (on my machine, of course, YMMV); it takes 14%
less time than the one that I deemed most straightforward. :)
Thanks,
Alan
Alex Martelli wrote:
H, what role does the enumeration play here? I don't se
Tony,
Actually I only want to remove a certain kind of duplication; if an item
occurs twice - say like this: [1,1,1,2,2,2,1,1,1], then I need to keep
the order and occurrence of the individual values: [1,2,1]. Using a
dict as you proposed loses the order of occurrence, as well as multiple
occu
Steve,
Yeah, in this particular application the ordering and reoccurrence of a
value in a non-contiguous way does matter; if those two things weren't
required I think the method you suggested would be a good way to remove
the duplicates.
Thanks!
Coates, Steve (ACHE) wrote:
It's not _exactly_ wh
Wow, that's cool; I'd never seen that before. :) Thanks, Steve..
Steve Holden wrote:
You are modifying the list as you iterate over it. Instead, iterate over
a copy by using:
for ip in ips[:]:
...
regards
Steve
--
http://mail.python.org/mailman/listinfo/python-list
']
ips_new = []
for ip in ips:
if '255' not in ip:
ips_new.append(ip)
print ips_new
Or this:
ips_new = [ip for ip in ips if '255' not in ip]
print ips_new
Hope this helps,
Alan McIntyre
http://www.esrgtech.com
rbt wrote:
Either I'm crazy and I'm missi
Christopher,
I've found myself doing the same thing. You could do something like this:
blah = type('Struct', (), {})()
blah.some_field = x
I think I'd only do this if I needed to construct objects at runtime
based on information that I don't have at compile time, since the two
lines of code for
Jack,
I'm not using 2.4 yet; still back in 2.3x. :) Thanks for the examples,
though - they are clear enough that I will probably use them when I upgrade.
Thanks,
Alan
Jack Diederich wrote:
If you are using python2.4,
import itertools as it
[x[0] for (x) in it.groupby([0,0,1,1,1,2,2,3,3,3,2,2,2,
I think you're right; sometimes I'm susceptible to the "I can do that in
one line of code" temptation. :)
Since this current bit of code will probably end up in something that's
going to be maintained, I will probably stick with the straightforward
method just to be nice to the maintainer (espe
Your first example is along the lines of what I was thinking when I said
"elegant." :) I was looking for something that I could drop into one
or two lines of code; I may not do that if I'm writing code that will
have to be maintained, but it's still nice to know how to do it.
Thanks :)
Alan
libraries that
come as part of the standard Python distribution have made my life a lot
easier than it ever was when I was only using C/C++.
Of course, your mileage may vary, depending on what sort of programming
you'd like to do. :)
Hope this helps,
Alan McIntyre
http://www.esrgtech.com
the way I'm doing this now:
def straightforward_collapse(myList):
collapsed = [myList[0]]
for n in myList[1:]:
if n != collapsed[-1]:
collapsed.append(n)
return collapsed
Is there an elegant way to do this, or should I just stick with the code
above?
Thanks,
18 matches
Mail list logo