On Aug 28, 2:41 pm, brad <[EMAIL PROTECTED]> wrote:
> Carl Banks wrote:
> > Out of curiosity, what does a true multimap solve that a dictionary of
> > lists not solve?
>
> Nothing really. I went with a variation of the suggested work around...
> it's just that with Python I don't normally have to u
Carl Banks wrote:
Out of curiosity, what does a true multimap solve that a dictionary of
lists not solve?
Nothing really. I went with a variation of the suggested work around...
it's just that with Python I don't normally have to use work arounds and
normally one obvious approach is correct:
On Aug 27, 1:52 pm, brad <[EMAIL PROTECTED]> wrote:
> Mike Kent wrote:
> > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
> > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> k = {}
> k['1'] = []
> k['1'].app
On Aug 27, 1:38 pm, brad <[EMAIL PROTECTED]> wrote:
> castironpi wrote:
> > I don't understand what a multimap does that a map of lists doesn't do.
>
> It counts both keys individually as separate keys. The Python workaround
> does not... see examples... notice the key(s) that are '4'
>
> Python ou
Miles wrote:
That's what a multimap is.
iirc, a C++ multimap provides a flat view of the data, so you need to
provide custom enumeration and iteration methods as well.
--
http://mail.python.org/mailman/listinfo/python-list
castironpi wrote:
I don't understand what a multimap does that a map of lists doesn't do.
It counts both keys individually as separate keys. The Python workaround
does not... see examples... notice the key(s) that are '4'
Python output (using the k = [] idea):
Key: 4 Value: [[13, 'Visa'],
On Aug 27, 12:52 pm, brad <[EMAIL PROTECTED]> wrote:
> Mike Kent wrote:
> > Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
> > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> k = {}
> k['1'] = []
> k['1'].ap
brad wrote:
> There is only one '1' key in your example. I need multiple keys that are all
> '1'. I thought Python would have something built-in to handle this sort of
> thing.
>
> I need a true multimap ... without making K's value a list of stuff
> to append to.
That's what a multimap is. If yo
Mike Kent wrote:
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
k = {}
k['1'] = []
k['1'].append('Tom')
k['1'].append('Bob')
k['1'].append('Joe')
k['1']
['Tom', 'Bob', 'Joe']
brad wrote:
Recently had a need to us a multimap container in C++. I now need to
write equivalent Python code. How does Python handle this?
k['1'] = 'Tom'
k['1'] = 'Bob'
k['1'] = 'Joe'
Same key, but different values. No overwrites either They all must
be inserted into the container
brad wrote:
> Recently had a need to us a multimap container in C++. I now need to
> write equivalent Python code. How does Python handle this?
>
> k['1'] = 'Tom'
> k['1'] = 'Bob'
> k['1'] = 'Joe'
> ...
>
> Same key, but different values. No overwrites either They all must
> be inserted into
On Aug 27, 9:35 am, brad <[EMAIL PROTECTED]> wrote:
> Recently had a need to us a multimap container in C++. I now need to
> write equivalent Python code. How does Python handle this?
>
> k['1'] = 'Tom'
> k['1'] = 'Bob'
> k['1'] = 'Joe'
> ...
>
> Same key, but different values. No overwrites either
Recently had a need to us a multimap container in C++. I now need to
write equivalent Python code. How does Python handle this?
k['1'] = 'Tom'
k['1'] = 'Bob'
k['1'] = 'Joe'
...
Same key, but different values. No overwrites either They all must
be inserted into the container
Thanks,
Brad
13 matches
Mail list logo