to say is wrong i think is a bit too much, its just a different type of
usage, this type of sintax is extensively used in numpy arrays (extended
slice came from numerical python), just asking why not extend the sintax to
python list. (not sure if you can use None as in the code i posted in numpy
but numbers are ok). I was just rewriting some numpy code in pure python (no
numpy for python3 yet), personally i think the pure python way is just ugly
and more expensive.
On Fri, Jul 2, 2010 at 10:55 PM, python-list-requ...@python.org wrote:
Send Python-list mailing list submissions to
python-list@python.org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-list
or, via email, send a message with subject or body 'help' to
python-list-requ...@python.org
You can reach the person managing the list at
python-list-ow...@python.org
When replying, please edit your Subject line so it is more specific
than Re: Contents of Python-list digest...
Today's Topics:
1. Re: Why defaultdict? (Steven D'Aprano)
2. Re: why python don't support extended slice direct
assignment for lists? (Shashwat Anand)
3. Sorting dicts inside dicts (abhijeet thatte)
4. Re: The real problem with Python 3 - no business case for
conversion(was I strongly dislike Python 3) (Shashwat Anand)
5. Crash in PyThread_acquire_lock (moerchendiser2k3)
6. Re: why python don't support extended slice direct
assignment for lists? (MRAB)
7. Re: Sorting dicts inside dicts (MRAB)
8. Re: tp_richcompare vs tp_compare (Aahz)
9. Re: The real problem with Python 3 - no business case for
conversion(was I strongly dislike Python 3) (Aahz)
10. Re: Anyone using GPG or PGP encryption/signatures in your
Python apps? (Martin Manns)
-- Forwarded message --
From: Steven D'Aprano st...@remove-this-cybersource.com.au
To: python-list@python.org
Date: 02 Jul 2010 23:59:52 GMT
Subject: Re: Why defaultdict?
On Fri, 02 Jul 2010 04:11:49 +, Steven D'Aprano wrote:
I would like to better understand some of the design choices made in
collections.defaultdict.
[...]
Thanks to all who replied.
--
Steven
-- Forwarded message --
From: Shashwat Anand anand.shash...@gmail.com
To: Robert William Hanks astroultra...@gmail.com
Date: Sat, 3 Jul 2010 05:32:31 +0530
Subject: Re: why python don't support extended slice direct assignment
for lists?
On Sat, Jul 3, 2010 at 4:54 AM, Robert William Hanks
astroultra...@gmail.com wrote:
why pure python don't support extended slice direct assignment for
lists?
today we have to write like this,
aList=[0,1,2,3,4,5,6,7,8,9]
aList
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
aList[::2]= [None]*len(aList[::2]) #or do the math by hand, what's
not always possible
Can you show me a case where it really is cumbersome.
aList
[None, 1, None, 3, None, 5, None, 7, None, 9]
why not accept syntax like this for extended slice
aList[::2] = None
when let's say, the left side is a list and the right side is bool, int or
float.
the laborious [nunber]*len(aList[::2]) seens to me less readable when you
want to set lost of items of a list to the same number.
Also correct me if i am wrong, calling len() and building a list to this
kind of operation seems a waste.
aList[::2]
[0, 2, 4, 6, 8]
Which means you are doing [0, 2, 4, 6, 8] = None, which is plain and simple
- wrong. How will you define the legitimacy of this statement.
What you are basically doing here is,,
[None]*len(aList[::2])
[None, None, None, None, None]
aList[::2]
[0, 2, 4, 6, 8]
Setting [0, 2, 4, 6, 8] to [None, None, None, None, None], thereby
operating on two similar data structure (here list)
Just want some feedback.
Just my thoughts.
~l0nwlf
-- Forwarded message --
From: abhijeet thatte abhijeet.tha...@gmail.com
To: python-list@python.org
Date: Fri, 2 Jul 2010 17:17:36 -0700
Subject: Sorting dicts inside dicts
Hi,
I have a huge dict structure like below:
*
{'module':{'reg_dict_0':{'name':'abc','reg_addr':'2004'},'reg_dict_1':{'name':'xyz','reg_addr':'2002'},'reg_dict_2':{'name':'pqr','reg_addr':'2008'}}
*
Module dict and reg_dicts contain many elements than shown.
I want to sort this 'module' dictionary as per 'reg_addr' element in every
'reg_dict'.
There is no relation between 'reg_dict' suffix and address. So, reg_dict_0
can contain reg_address = 2000/72 (any number)
I do not want output in a list format as the actual dict size is huge which
I want to use based on key value pair.
So, I want output as :
*
{'module':{'reg_dict_1':{'name':'xyz','reg_addr':'2002'},'reg_dict_0':{'name':'abc','reg_addr':'2004'},'reg_dict_2':{'name':'pqr','reg_addr':'2008'}}
*
*
*
Is it possible to sort the things? What I guess is Python stores dicts in a
tree like structure but I am forcing