On Wed, Aug 2, 2017 at 11:49 AM, Chris Angelico wrote:
> On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote:
>> Given a list of objects that all have a particular attribute, is there
>> a simple way to get a list of those attributes?
>>
>> In other words:
>>
>
On 08/02/2017 12:49 PM, Chris Angelico wrote:
On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote:
You can't eliminate the loop, but you can compact it into a single
logical operation:
namelist = [foo.name for foo in foolist]
That's a "list comprehension", and is an elegant way to process a list
On 8/2/2017 1:21 PM, Ian Pilcher wrote:
Given a list of objects that all have a particular attribute, is there
a simple way to get a list of those attributes?
In other words:
class Foo(object):
def __init__(self, name):
self.name = name
foolist = [ Foo('a'
On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote:
> Given a list of objects that all have a particular attribute, is there
> a simple way to get a list of those attributes?
>
> In other words:
>
> class Foo(object):
> def __init__(self, name):
> self.n
Given a list of objects that all have a particular attribute, is there
a simple way to get a list of those attributes?
In other words:
class Foo(object):
def __init__(self, name):
self.name = name
foolist = [ Foo('a'), Foo('b'), Foo('c') ]
Chris I take good notice of your comments and suggestions. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks MRAB and Peter Otten that solved the problem.
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Aug 28, 2010 at 10:48 AM, cocolombo wrote:
> Hello.
>
> I am putting objects (test) into a container object (tests) and the
> test object is also a container for a another list of object
> (scores).
>
> Problem is that all instances of class tests have the same value.
>
> To illustrate:
>
cocolombo wrote:
> Problem is that all instances of class tests have the same value.
>
> To illustrate:
> class tests(object):
> listOfTest = []
This makes listOfTest a class attribute. To get one list per instance define
it in the initializer:
class Tests(object):
def __init__(self):
On 28/08/2010 18:48, cocolombo wrote:
Hello.
I am putting objects (test) into a container object (tests) and the
test object is also a container for a another list of object
(scores).
Problem is that all instances of class tests have the same value.
To illustrate:
class score(object):
va
Hello.
I am putting objects (test) into a container object (tests) and the
test object is also a container for a another list of object
(scores).
Problem is that all instances of class tests have the same value.
To illustrate:
class score(object):
val = 0
def __init__(self, val):
On Fri, 6 Feb 2009, greyw...@gmail.com wrote:
> On Jan 28, 4:37 am, John O'Hagan wrote:
> > On Tue, 27 Jan 2009, Reckoner wrote:
> > > I'm not sure this is possible, but I would like to have
> > > a list of objects
> > >
> > > A=[a,b,
On Feb 6, 2:41 pm, Stephen Hansen wrote:
> > I think there may have been a misunderstanding. I was already using
> > attrgetter, my problem is that it doesn't appear to be sorting by the
> > argument i give it. How does sort work with strings? How about with
> > datetime.time or datetime.date?
> I think there may have been a misunderstanding. I was already using
> attrgetter, my problem is that it doesn't appear to be sorting by the
> argument i give it. How does sort work with strings? How about with
> datetime.time or datetime.date?
You were using the attrgetter, but it looks like
On Feb 6, 2:34 pm, Robocop wrote:
> On Feb 6, 2:20 pm, Robocop wrote:
>
>
>
> > On Feb 6, 2:17 pm, Robocop wrote:
>
> > > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote:
>
> > > > Robocop:
>
> > > > >then within each department block of the list, have it organized by
> > > > >projects.<
>
>
Robocop wrote:
UH OH GUYS!
line 110, in sorter
timesheets.sort(key=attrgetter("department", "engagement",
"date","start"))
TypeError: attrgetter expected 1 arguments, got 4
Um... what version of Python are you running? Alway specify. (Too many
people do not). In 3.0
from operator imp
On Feb 6, 2:20 pm, Robocop wrote:
> On Feb 6, 2:17 pm, Robocop wrote:
>
>
>
> > On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote:
>
> > > Robocop:
>
> > > >then within each department block of the list, have it organized by
> > > >projects.<
>
> > > I don't know what does it means.
>
> > > > ti
On Feb 6, 2:17 pm, Robocop wrote:
> On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote:
>
>
>
> > Robocop:
>
> > >then within each department block of the list, have it organized by
> > >projects.<
>
> > I don't know what does it means.
>
> > > timesheets.sort(key=operator.attrgetter('string'))
>
On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote:
> Robocop:
>
> >then within each department block of the list, have it organized by
> >projects.<
>
> I don't know what does it means.
>
> > timesheets.sort(key=operator.attrgetter('string'))
>
> Try something like:
> timesheets.sort(key=attrgette
On Feb 6, 1:03 pm, bearophileh...@lycos.com wrote:
> Robocop:
>
> >then within each department block of the list, have it organized by
> >projects.<
>
> I don't know what does it means.
>
> > timesheets.sort(key=operator.attrgetter('string'))
>
> Try something like:
> timesheets.sort(key=attrgette
Robocop:
>then within each department block of the list, have it organized by projects.<
I don't know what does it means.
> timesheets.sort(key=operator.attrgetter('string'))
Try something like:
timesheets.sort(key=attrgetter("department", "engagement", "date",
"stare_hour"))
> My brain might
> I've found myself stumped when trying to organize this list of
> objects. The objects in question are timesheets which i'd like to
> sort by four attributes:
>
> class TimeSheet:
> department = string
> engagement = string
> date = datetime.date
>
Quoth Robocop :
> Hello again,
> I've found myself stumped when trying to organize this list of
> objects. The objects in question are timesheets which i'd like to
> sort by four attributes:
>
> class TimeSheet:
> department = string
> engagement
Hello again,
I've found myself stumped when trying to organize this list of
objects. The objects in question are timesheets which i'd like to
sort by four attributes:
class TimeSheet:
department = string
engagement = string
date = datetime.date
stare_hour = datetime.time
M
On Jan 28, 4:37 am, John O'Hagan wrote:
> On Tue, 27 Jan 2009, Reckoner wrote:
> > I'm not sure this is possible, but I would like to have
> > a list of objects
>
> > A=[a,b,c,d,...,z]
>
> > where, in the midst of a lot of proc
On 2009-01-29 18:22, Reckoner wrote:
I haven't looked at Enthought in awhile. I want to avoid having to
installing the entire Enthought toolsuite, however. Would I have to
do that for Traits?
No, Traits can be installed by itself unless if you want its GUI capabilities.
http://pypi.python
27;m not sure this is possible, but I would like to have
> > > > > a list of objects
>
> > > > > A=[a,b,c,d,...,z]
>
> > > > > where, in the midst of a lot of processing I might do something like,
>
> > > > > A[0].do_something_wh
On Jan 28, 10:17 pm, Peter Wang wrote:
> On Jan 27, 3:16 pm,Reckoner wrote:
>
>
>
> > I'm not sure this is possible, but I would like to have
> > a list of objects
>
> > A=[a,b,c,d,...,z]
>
> > where, in the midst of a lot of
On Jan 27, 3:16 pm, Reckoner wrote:
> I'm not sure this is possible, but I would like to have
> a list of objects
>
> A=[a,b,c,d,...,z]
>
> where, in the midst of a lot of processing I might do something like,
>
> A[0].do_something_which_changes_the_properties()
&
On Wed, 28 Jan 2009 11:06:21 -0800, Reckoner wrote:
> thanks for your reply.
>
> For the second case where
>
>> class TaintThing(object):
>> parent = A
>> def __init__(self, obj):
>> self.__dict__['_proxy'] = obj
>> def __getattr__(self, attr):
>> return getattr(self.
On Jan 27, 9:46 pm, Steven D'Aprano
wrote:
> On Tue, 27 Jan 2009 13:16:36 -0800, Reckoner wrote:
> > I'm not sure this is possible, but I would like to have a list of
> > objects
>
> > A=[a,b,c,d,...,z]
>
> > where, in the midst of a lot of proc
On Jan 28, 10:39 pm, Reckoner wrote:
> On Jan 28, 9:16 am, koranthala wrote:
>
>
>
> > On Jan 28, 5:42 pm, koranthala wrote:
>
> > > On Jan 28, 2:16 am, Reckoner wrote:
>
> > > > I'm not sure this is possible, but I would like to have
>
On Jan 28, 9:16 am, koranthala wrote:
> On Jan 28, 5:42 pm, koranthala wrote:
>
>
>
> > On Jan 28, 2:16 am, Reckoner wrote:
>
> > > I'm not sure this is possible, but I would like to have
> > > a list of objects
>
> > > A=[a,b,c,d,...,
On Jan 27, 3:16 pm, Reckoner wrote:
> The trick is that I would like A to be mysteriously aware that
> something about the object 'a' has changed so that when I revisit A,
> I will know that the other items in the list need to be refreshed to
> reflect the changes in A as a result of changing 'a'
On Jan 28, 5:42 pm, koranthala wrote:
> On Jan 28, 2:16 am, Reckoner wrote:
>
>
>
> > I'm not sure this is possible, but I would like to have
> > a list of objects
>
> > A=[a,b,c,d,...,z]
>
> > where, in the midst of a lot of
On Jan 28, 2:16 am, Reckoner wrote:
> I'm not sure this is possible, but I would like to have
> a list of objects
>
> A=[a,b,c,d,...,z]
>
> where, in the midst of a lot of processing I might do something like,
>
> A[0].do_something_which_changes_the_properties()
&
On Tue, 27 Jan 2009, Reckoner wrote:
> I'm not sure this is possible, but I would like to have
> a list of objects
>
> A=[a,b,c,d,...,z]
>
> where, in the midst of a lot of processing I might do something like,
>
> A[0].do_something_which_changes_the_properties()
&
On Jan 27, 3:16 pm, Reckoner wrote:
> I'm not sure this is possible, but I would like to have
> a list of objects
>
> A=[a,b,c,d,...,z]
>
> where, in the midst of a lot of processing I might do something like,
>
> A[0].do_something_which_changes_the_properties()
&
On Tue, 27 Jan 2009 13:16:36 -0800, Reckoner wrote:
> I'm not sure this is possible, but I would like to have a list of
> objects
>
> A=[a,b,c,d,...,z]
>
> where, in the midst of a lot of processing I might do something like,
>
> A[0].do_something_which_change
On Tue, Jan 27, 2009 at 1:16 PM, Reckoner wrote:
> I'm not sure this is possible, but I would like to have
> a list of objects
>
> A=[a,b,c,d,...,z]
>
> where, in the midst of a lot of processing I might do something like,
>
> A[0].do_something_which_changes_the_pro
I'm not sure this is possible, but I would like to have
a list of objects
A=[a,b,c,d,...,z]
where, in the midst of a lot of processing I might do something like,
A[0].do_something_which_changes_the_properties()
which alter the properties of the object 'a'.
The trick is that
Andreas Müller:
> is there a construct like
> list.find (10, key='ID')
Given the current Python a syntax like this is more probable:
somelist.find(10, key=attrgetter('ID'))
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
En Thu, 23 Oct 2008 05:23:51 -0200, Andreas Müller <[EMAIL PROTECTED]>
escribió:
(Python 2.2.3 if this is relevant :-)
I have a list of objects with, lets say, the attributes "ID", "x" and
"y". Now I want to find the index of list element with ID=10.
O
Andreas Müller:
> is there a construct like
> list.find (10, key='ID')
You can create yourself a little convenience function, or you can use
something like the following. First some testing code:
class C:
def __init__(self, id):
self.id = id
def __repr__(self):
return "<%s
Hi!
(Python 2.2.3 if this is relevant :-)
I have a list of objects with, lets say, the attributes "ID", "x" and
"y". Now I want to find the index of list element with ID=10.
Of course I can loop through the list manually, but is there a
construct like
list.fin
On Jun 2, 8:36 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> Still nitpicking: using a generator expression in this case has no
> advantage. The first thing that str.join does is to create a list out of
> its argument (unless it is already a list or a tuple). In fact, a list
> comprehension
En Mon, 02 Jun 2008 18:56:08 -0300, jay graves <[EMAIL PROTECTED]>
escribió:
On Jun 2, 4:02 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
I think what you want is:
def write_err(*args):
from sys import stderr
stderr.write("\n".join([str(o) for o in args]))
Slight nitpick. If you are
On Jun 2, 2:56 pm, jay graves <[EMAIL PROTECTED]> wrote:
> On Jun 2, 4:02 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
>
> > I think what you want is:
> > def write_err(*args):
> > from sys import stderr
> > stderr.write("\n".join([str(o) for o in args]))
>
> Slight nitpick. If you are usi
t;.join([str(b) for b in objs])+"\n")
Gary Herron
What's
the simplest way to fix this? In essence, I need to cast a list of
objects to a list of strings. I'd like to do just "str(objs)" but that
(obviously) doesn't quite do what I need.
--
http://mail.py
On Jun 2, 4:02 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> I think what you want is:
> def write_err(*args):
> from sys import stderr
> stderr.write("\n".join([str(o) for o in args]))
Slight nitpick. If you are using version >= 2.4 you could use a
generator expression instead of a list
ot; ".join(objs)+"\n")
but I lose the property that the function works on any object. What's
the simplest way to fix this? In essence, I need to cast a list of
objects to a list of strings. I'd like to do just "str(objs)" but that
(obviously) doesn't quite do w
js)+"\n")
but I lose the property that the function works on any object. What's
the simplest way to fix this? In essence, I need to cast a list of
objects to a list of strings. I'd like to do just "str(objs)" but that
(obviously) doesn't quite do what I need.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks so much everyone! That works great, & (presumably) is way
faster than the way I was doing it--
--
http://mail.python.org/mailman/listinfo/python-list
Paddy wrote:
> On Apr 9, 4:04 am, Jason <[EMAIL PROTECTED]> wrote:
>> Hi folks--
>>
>> Basically, I have a pressing need for a combination of 5.2 "Sorting a
>> List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects
>>
On Apr 9, 4:04 am, Jason <[EMAIL PROTECTED]> wrote:
> Hi folks--
>
> Basically, I have a pressing need for a combination of 5.2 "Sorting a
> List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects
> by an Attribute of the Objects" from
On Apr 8, 8:26 pm, "David Harrison" <[EMAIL PROTECTED]> wrote:
> On 09/04/2008, Jason <[EMAIL PROTECTED]> wrote:
>
> > Hi folks--
>
> > Basically, I have a pressing need for a combination of 5.2 "Sorting a
> > List of Strings Case-Inse
On 09/04/2008, Jason <[EMAIL PROTECTED]> wrote:
> Hi folks--
>
> Basically, I have a pressing need for a combination of 5.2 "Sorting a
> List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects
> by an Attribute of the Objects" from t
Hi folks--
Basically, I have a pressing need for a combination of 5.2 "Sorting a
List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects
by an Attribute of the Objects" from the Python Cookbook.
My first guess isn't working:
import operator
def sort
Nico Grubert wrote:
> Hi there
>
> I have a list of dummy objects which have the attributes 'location',
> 'name', 'gender'.
> Now I want to rebuild this list in order to avoid redundancies on
> objects with the same 'location'.
>
> Example:
>
> #---
Hi there
I have a list of dummy objects which have the attributes 'location',
'name', 'gender'.
Now I want to rebuild this list in order to avoid redundancies on
objects with the same 'location'.
Example:
#--
class Dummy:
pas
Wow Paul, you have given me much to chew. I'll start testing it in my slow
way -- it looks so simple!
Thank you.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Paul,
I quickly slapped your example into a py file for a first-glance test and
the first part works, but the second gives me the error below. Could I have
an old version of pyparser? I will dig into it anyway, just being lazy :)
code:
from pyparsing import *
frame = Literal("#")
tween = Word("-"
Wow Paul, you have given me much to chew. I'll start testing it in my slow
way -- it looks so simple!
Thank you.
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 5, 3:00 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
>
> I have glanced around at parsing and all the tech-speak confuses the heck
> out of me. I am not too smart and would appreciate any help that steers
> away from cold theory and simply hits at this problem.
>
Donn -
Here is a pyparsing ve
Hi, I really hope someone can help me -- I'm stuck.
I have written three versions of code over a week and still can't get past
this problem, it's blocking my path to getting other code written.
This might be a little hairy, but I'll try to keep it short.
Situation:
I want to pass a string to a
his is not clear to me how can be implemented. I thought of creating
>a class with the data structure, and creating a list of objects of
>that class, each one containing one line of data from the "database".
>
>Any thoughts or suggestions?
>
>Thanks!
>Eduardo
>
&g
.
>
> This is not clear to me how can be implemented. I thought of creating
> a class with the data structure, and creating a list of objects of
> that class, each one containing one line of data from the "database".
>
> Any thoughts or suggestions?
Python 2.5 ships w
On 3 oct, 22:01, MindMaster32 <[EMAIL PROTECTED]> wrote:
Hi,
Maybe PyDbLite (http://quentel.pierre.free.fr/PyDbLite/index.html) is
what you need : a single Python module, compatible with Python 2.3+,
that lets you manipulate data in memory
You can manage a database like this :
import PyDbLite
d
Michael Bentley wrote:
>
> On Oct 3, 2007, at 1:01 PM, MindMaster32 wrote:
>
>> I am writing a script that has to read data from an ASCII file of
>> about 50 Mb and do a lot of searches and calculations with that data.
>> That would be a classic problem solved by the use of a database
>> (SQLite
and working with datafields.
>
> This is not clear to me how can be implemented. I thought of creating
> a class with the data structure, and creating a list of objects of
> that class, each one containing one line of data from the "database".
>
> Any thoughts or suggest
creating
a class with the data structure, and creating a list of objects of
that class, each one containing one line of data from the "database".
Any thoughts or suggestions?
Thanks!
Eduardo
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] (Alex Martelli) writes:
> Stefan Arentz <[EMAIL PROTECTED]> wrote:
>
> > Miki <[EMAIL PROTECTED]> writes:
> >
> > > > steps.sort(key = lambda s: s.time)
> > > This is why attrgetter in the operator module was invented.
> > > from operator import attrgetter
> > > ...
> > > ste
Stefan Arentz <[EMAIL PROTECTED]> wrote:
> Miki <[EMAIL PROTECTED]> writes:
>
> > > steps.sort(key = lambda s: s.time)
> > This is why attrgetter in the operator module was invented.
> > from operator import attrgetter
> > ...
> > steps.sort(key=attrgettr("time"))
>
> Personally I prefer the a
Miki <[EMAIL PROTECTED]> writes:
> > steps.sort(key = lambda s: s.time)
> This is why attrgetter in the operator module was invented.
> from operator import attrgetter
> ...
> steps.sort(key=attrgettr("time"))
Personally I prefer the anonymous function over attrgettr :)
S.
--
http://mail.pyt
> steps.sort(key = lambda s: s.time)
This is why attrgetter in the operator module was invented.
from operator import attrgetter
...
steps.sort(key=attrgettr("time"))
HTH,
--
Miki <[EMAIL PROTECTED]>
http://pythonwise.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 07 Sep 2007 06:57:35 -0700, cjt22 wrote:
> I have a step class and store in a list step instances
> A step instance contains variables: name, startTime etc and startTime
> is stored as a string %H:%M:%S
>
> What I would like to do is to be able to sort this list of objects
tance contains variables: name, startTime etc and startTime
> is stored as a string %H:%M:%S
>
> What I would like to do is to be able to sort this list of objects
> based on the startTime object so that the first item in the list is
> the object with the earliest Start time and last i
tance contains variables: name, startTime etc and startTime
> is stored as a string %H:%M:%S
>
> What I would like to do is to be able to sort this list of objects
> based on the startTime object so that the first item in the list is
> the object with the earliest Start time and last i
as a string %H:%M:%S
What I would like to do is to be able to sort this list of objects
based on the startTime object so that the first item in the list is
the object with the earliest Start time and last item is the object
with the last Start time.
I belive my key has to be = strpTime(step.sTime
"Steve Holden" wrote:
> Steven D'Aprano wrote:
> [...]
> >
> > Forth method: create identical gazelles, then modify them:
> >
> > list_of_beasties = [Gazelle(defaults) for i in xrange(1000)]
> > for i, beastie in enumerate(xrange(1000)):
> > list_of_beasties[i] = modify(beastie)
> >
> N
On Apr 19, 9:18 pm, Paddy <[EMAIL PROTECTED]> wrote:
>
> # create a list of instances
> gazelles= [ Gazelle() for x in range(5)]
>
Nice. I knew there had to be a way to use a list comprehension, but I
couldn't figure it out.
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
[...]
>
> Forth method: create identical gazelles, then modify them:
>
> list_of_beasties = [Gazelle(defaults) for i in xrange(1000)]
> for i, beastie in enumerate(xrange(1000)):
> list_of_beasties[i] = modify(beastie)
>
Nope, 'sorry, that's Python a's well. Forth u'se
<[EMAIL PROTECTED]> wrote:
> Howdy, a (possibly) quick question for anyone willing to listen.
> I have a question regarding lists and Classes; I have a class called
It looks you don't really want what you're saying: you appear to want a
list of INSTANCES of one class, *NOT* a list of CLASSES. E.
These methods work. I didn't think I could create a list of objects
like that, however, I stand corrected.
Thanks for your quick (and helpful) responses!
On Apr 19, 11:22 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Thu, 19 Apr 2007 19:58:35 -0700, datamonkey.ryan
[EMAIL PROTECTED] wrote:
> Howdy, a (possibly) quick question for anyone willing to listen.
> I have a question regarding lists and Classes; I have a class called
> "gazelle" with several attributes (color, position, etc.) and I need
> to create a herd of them. I want to simulate motion of individu
On Thu, 19 Apr 2007 19:58:35 -0700, datamonkey.ryan wrote:
> Howdy, a (possibly) quick question for anyone willing to listen.
> I have a question regarding lists and Classes; I have a class called
> "gazelle" with several attributes (color, position, etc.) and I need
> to create a herd of them. I
On Thursday 19 April 2007, [EMAIL PROTECTED] wrote:
> Howdy, a (possibly) quick question for anyone willing to listen.
> I have a question regarding lists and Classes; I have a class called
> "gazelle" with several attributes (color, position, etc.) and I need
> to create a herd of them. I want to
On Apr 20, 3:58 am, [EMAIL PROTECTED] wrote:
> Howdy, a (possibly) quick question for anyone willing to listen.
> I have a question regarding lists and Classes; I have a class called
> "gazelle" with several attributes (color, position, etc.) and I need
> to create a herd of them. I want to simulat
[EMAIL PROTECTED] wrote:
>
> However, Python doesn't support pointers
As I understand it, every name in Python is a pointer.
class Gazelle(object):
def __init__(self):
self.x = 0
g_list =[]
for x in range(10):
g_list.append(Gazelle())
for g in g_list:
g.x = 10
print g_list[
Howdy, a (possibly) quick question for anyone willing to listen.
I have a question regarding lists and Classes; I have a class called
"gazelle" with several attributes (color, position, etc.) and I need
to create a herd of them. I want to simulate motion of individual
gazelles, but I don't want to
Raymond Hettinger wrote:
> Azolex:
>> Let's push the diagnosis a bit further : the aversion to the keyword
>> "lambda" has to do with the fact that it ignores the english word used
>> by all non-geeks to convey the meaning, eg "given"
>
> Right. However, Guido has said that lambda is here to stay
[Noah]
> I suggested the above because it wasn't obvious to me how one would
> pass the arbitrary set of attributes to the lambda expression (and I
> envisioned them being specified as strings in this case, since the set
> of attributes will be coming from a web form).
>
> So what about the followi
Azolex:
> Let's push the diagnosis a bit further : the aversion to the keyword
> "lambda" has to do with the fact that it ignores the english word used
> by all non-geeks to convey the meaning, eg "given"
Right. However, Guido has said that lambda is here to stay,
so it's time to get over it.
R
Raymond Hettinger wrote:
>
> The cult of lambda avoidance has lost contact with reality. [...]
> Lambda avoidance is rooted in two things, an aversion to the keyword
> name [...]
Let's push the diagnosis a bit further : the aversion to the keyword
"lambda" has to do with the fact that it ignore
I'm sure my avoidance of lambdas as due as much to laziness as
adherence to principle. This is a good opportunity to learn about them.
I suggested the above because it wasn't obvious to me how one would
pass the arbitrary set of attributes to the lambda expression (and I
envisioned them being spe
Kent Johnson wrote:
> Scott David Daniels wrote:
>> Kent Johnson wrote:
>>> In Python 2.5 you can do this with operator.attrgetter():
>>> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey'))
>>
>> Note: this is also available in Python 2.4
>
> No, the ability to specify more th
[George Young]
>> For multiple keys the form is quite analogous:
>>
>> L.sort(key=lambda i: (i.whatever, i.someother, i.anotherkey))
[Noah]
> If you are lambda-phobic (as I am) this should also work for an
> arbitrary set of attributes:
>
> attrs = 'attr1 attr2 attr3'.split()
> sortlist = [[getat
Scott David Daniels wrote:
> Kent Johnson wrote:
>> In Python 2.5 you can do this with operator.attrgetter():
>> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey'))
>
> Note: this is also available in Python 2.4
No, the ability to specify more than one attribute name, making
Kent Johnson wrote:
> In Python 2.5 you can do this with operator.attrgetter():
> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey'))
Note: this is also available in Python 2.4
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
gry@ll.mit.edu wrote:
> For multiple keys the form is quite analogous:
>
>L.sort(key=lambda i: (i.whatever, i.someother, i.anotherkey))
>
> I.e., just return a tuple with the keys in order from your lambda.
> Such tuples sort nicely.
In Python 2.5 you can do this with operator.attrgetter()
1 - 100 of 107 matches
Mail list logo