473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1086

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

Similar topics

14
3156
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
16167
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
10272
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
1653
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
391
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
2336
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
1468
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
2580
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
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7321
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
7377
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...
1
5045
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...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.