473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Best way to emulate ordered dictionary (like in PHP)?

I am dealing with user profiles, which are simply a set of field-value
pairs. I've tried to many things to list, but for one, I tried creating
a wrapper class which inherits the dictionary and overrides the
iterator. Unfortunately I don't understand iterators enough to get this
working and before I waste any more time trying I figured I should
check wether there is a better way. I have run into a similar problem
once, and I resolved it by creating a wrapper class for the 'list'
class which overides the get_item method, checks for string parameter,
then accesses the appropriate item via a lookup 'list' contained within
the class which maps the string parameter to the index number (eh, it
just doesn't seem practical though). Now, I'e never used PHP, but
apparently, it's dictionaries retain the order in which the items are
entered and regurgitates them in that order when you iterate over them.
That is exactly what I want, but can't seem to get in Python. Any help?
Thanks in advance.

Apr 12 '06 #1
0 1083

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Leif K-Brooks | last post by:
I need to associate a string (key) with an integer (value). A dictionary would do the job, except for the fact that it must be ordered. I also need to look up the value for a specific key easily,...
61
by: /* frank */ | last post by:
I have to do a homework: make a CPU simulator using C language. I have a set of asm instructions so I have to write a program that should: - load .asm file - view .asm file - do a step by step...
210
by: Christoph Zwerschke | last post by:
This is probably a FAQ, but I dare to ask it nevertheless since I haven't found a satisfying answer yet: Why isn't there an "ordered dictionary" class at least in the standard list? Time and again...
8
by: Fuzzyman | last post by:
Sorry for this hurried message - I've done a new implementation of out ordered dict. This comes out of the discussion on this newsgroup (see blog entry for link to archive of discussion). See...
2
by: pyGuy | last post by:
I am dealing with user profiles, which are simply a set of field-value pairs. I've tried to many things to list, but for one, I tried creating a wrapper class which inherits the dictionary and...
22
by: bearophileHUGS | last post by:
>From this interesting blog entry by Lawrence Oluyede: http://www.oluyede.org/blog/2006/07/05/europython-day-2/ and the Py3.0 PEPs, I think the people working on Py3.0 are doing a good job, I am...
1
by: Fuzzyman | last post by:
After a break of almost a year there has been an update to `odict the Ordered Dictionary <http://www.voidspace.org.uk/python/odict.html>`_. The latest version is 0.2.2, with changes implemented...
8
by: Guy | last post by:
Is there a better way to search identical elements in a sorted array list than the following: iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count, aSearchedObject ); aFoundObject= m_Array;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.