On Mar 14, 4:52 pm, "Samuel" <[EMAIL PROTECTED]> wrote:
> On Mar 14, 9:48 pm, "Drew" <[EMAIL PROTECTED]> wrote:
>
> > This is interesting behavior, but may not be what the original poster
> > intended.
>
> I am the original poster :).
>
> > If I understand correctly, this means that if more than on
On Mar 14, 9:48 pm, "Drew" <[EMAIL PROTECTED]> wrote:
> This is interesting behavior, but may not be what the original poster
> intended.
I am the original poster :).
> If I understand correctly, this means that if more than one
> object shares the same id, only one copy will be created in the di
Drew wrote:
> On Mar 14, 4:52 pm, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
>
>> res_dict = dict((r.get_id(), r) for r in res_list)
>
> I'm using Python2.5 and it seems that this only gives me a hash with
> the first id and first record. Am I doing something wrong?
>
class Person():
On Mar 14, 4:43 pm, "Samuel" <[EMAIL PROTECTED]> wrote:
> What this does is it maps the id to the object. In your case, you only
> have one id.
>
> -Samuel
This is interesting behavior, but may not be what the original poster
intended. If I understand correctly, this means that if more than one
ob
On Mar 14, 9:32 pm, "Drew" <[EMAIL PROTECTED]> wrote:
> I'm using Python2.5 and it seems that this only gives me a hash with
> the first id and first record. Am I doing something wrong?
Try this instead:
>>> class Person():
... def __init__(self):
... self.id = 5
...
>>> mylist =
On Mar 14, 4:52 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> res_dict = dict((r.get_id(), r) for r in res_list)
I'm using Python2.5 and it seems that this only gives me a hash with
the first id and first record. Am I doing something wrong?
>>> class Person():
... def __init__(self):
On Mar 14, 9:52 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> res_dict = dict((r.get_id(), r) for r in res_list)
>
> or if you have to be compatible with older python versions:
>
> res_dict = dict([(r.get_id(), r) for r in res_list])
Yep, that works. Strange, I was sure I had tested the lat
Samuel wrote:
> This does not work:
>
> res_dict = dict([r.get_id(), r for r in res_list])
This does:
res_dict = dict([(r.get_id(), r) for r in res_list])
--
http://mail.python.org/mailman/listinfo/python-list
Samuel a écrit :
> Hi,
>
> is there a short version for this?
>
> res_dict = {}
> for resource in res_list:
> res_dict[resource.get_id()] = resource
>
> This does not work:
>
> res_dict = dict([r.get_id(), r for r in res_list])
res_dict = dict((r.get_id(), r) for r in res_list)
or if you ha
Hi,
is there a short version for this?
res_dict = {}
for resource in res_list:
res_dict[resource.get_id()] = resource
This does not work:
res_dict = dict([r.get_id(), r for r in res_list])
-Samuel
--
http://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo