On Mar 20, 5:08 pm, grocery_stocker wrote:
> On Mar 20, 8:34 am, Paul McGuire wrote:
>
> > On Mar 20, 9:54 am, "thomasvang...@gmail.com"
>
> > wrote:
> > > You could use:
> > > B=list(set(A)).sort()
> > > Hope that helps.
> > > T
>
> > That may hurt more than help, sort() only works in-place, an
On Mar 20, 5:07 pm, Michael Spencer wrote:
> Alexzive wrote:
snip
> And, if you really want, you can get the body of this into 1-line, noting that
> seen.add returns None, so the expression (item in seen or seen.add(item))
> evaluates to True if item is in seen, or None (and item is added to seen)
On Mar 20, 8:34 am, Paul McGuire wrote:
> On Mar 20, 9:54 am, "thomasvang...@gmail.com"
>
> wrote:
> > You could use:
> > B=list(set(A)).sort()
> > Hope that helps.
> > T
>
> That may hurt more than help, sort() only works in-place, and does
> *not* return the sorted list. For that you want the
Alexzive wrote:
Hello there,
I'd like to get the same result of set() but getting an indexable
object.
How to get this in an efficient way?
Example using set
A = [1, 2, 2 ,2 , 3 ,4]
B= set(A)
B = ([1, 2, 3, 4])
B[2]
TypeError: unindexable object
Many thanks, alex
--
http://mail.python.org/m
On Fri, 20 Mar 2009 07:16:40 -0700, Alexzive wrote:
> Hello there,
>
> I'd like to get the same result of set() but getting an indexable
> object.
> How to get this in an efficient way?
Your question is too open-ended. Do you want to keep the items in the
original order? Are the items hashable?
Alexzive wrote:
> I'd like to get the same result of set() but getting an indexable
> object.
> How to get this in an efficient way?
>
> Example using set
>
> A = [1, 2, 2 ,2 , 3 ,4]
> B= set(A)
> B = ([1, 2, 3, 4])
>
> B[2]
> TypeError: unindexable object
If the initial list is ordered or at
Alexzive wrote:
I'd like to get the same result of set() but getting an indexable
object. How to get this in an efficient way?
Go look at Ray Hettinger's recently announced recipe for 'OrderedSet':
http://code.activestate.com/recipes/576694/
--Scott David Daniels
Scott,dani...@acm.org
-
On Mar 20, 9:54 am, "thomasvang...@gmail.com"
wrote:
> You could use:
> B=list(set(A)).sort()
> Hope that helps.
> T
That may hurt more than help, sort() only works in-place, and does
*not* return the sorted list. For that you want the global built-in
sorted:
>>> data = map(int,"6 1 3 2 5 2 5 4
Tino Wildenhain wrote:
thomasvang...@gmail.com wrote:
You could use:
B=list(set(A)).sort()
Hope that helps.
That would leave a B with value None :-)
B=list(sorted(set(A))
could work.
sorted() accepts an iterable, eg a set, and returns a list:
B = sorted(set(A))
--
http://mail.python.org/m
thomasvang...@gmail.com wrote:
You could use:
B=list(set(A)).sort()
Hope that helps.
That would leave a B with value None :-)
B=list(sorted(set(A))
could work.
smime.p7s
Description: S/MIME Cryptographic Signature
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2009-03-20 at 07:54 -0700, thomasvang...@gmail.com wrote:
> You could use:
> B=list(set(A)).sort()
> Hope that helps.
Which will assign None to B.
sorted(list(... or B.sort() is probably what you meant.
--
http://mail.python.org/mailman/listinfo/python-list
You could use:
B=list(set(A)).sort()
Hope that helps.
T
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2009-03-20 at 07:16 -0700, Alexzive wrote:
> Hello there,
>
> I'd like to get the same result of set() but getting an indexable
> object.
> How to get this in an efficient way?
>
> Example using set
>
> A = [1, 2, 2 ,2 , 3 ,4]
> B= set(A)
> B = ([1, 2, 3, 4])
>
> B[2]
> TypeError: unin
Hello there,
I'd like to get the same result of set() but getting an indexable
object.
How to get this in an efficient way?
Example using set
A = [1, 2, 2 ,2 , 3 ,4]
B= set(A)
B = ([1, 2, 3, 4])
B[2]
TypeError: unindexable object
Many thanks, alex
--
http://mail.python.org/mailman/listinfo/py
14 matches
Mail list logo