Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77576

Re: Storing instances using jsonpickle

References (1 earlier) <mailman.13748.1409777587.18130.python-list@python.org> <46e782a5-b087-4f95-aadb-26e233bf5419@googlegroups.com> <5407A69B.3030707@mrabarnett.plus.com> <mailman.13761.1409807846.18130.python-list@python.org> <lubenp$gpg$1@dont-email.me>
Date 2014-09-05 15:08 +1000
Subject Re: Storing instances using jsonpickle
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13783.1409893692.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Sep 5, 2014 at 2:38 PM, Dan Sommers <dan@tombstonezero.net> wrote:
> On Thu, 04 Sep 2014 15:17:17 +1000, Chris Angelico wrote:
>
>> On Thu, Sep 4, 2014 at 9:39 AM, MRAB <python@mrabarnett.plus.com> wrote:
>
>>> The key of a dict could also be int, float, or tuple.
>>
>> Yes! Yes! DEFINITELY do this!! Ahem. Calm down a little, it's not that
>> outlandish an idea...
>
> Using floats is a bad idea.  Consider this python code:
>
>     dictionary = dict()
>     original = get_some_floating_point_value()
>     dictionary[original] = 'foo'
>     string_version = str(original)  # this is where things head south
>     duplicate = float(string_version)
>     value = dictionary.get(duplicate)
>
> Okay, so what is value?  Is it 'foo'?  Is it None?
>
> (Yes, I can fix this.  If I *know* that original is a float, then I
> could use original.hex() instead of str(original).)

There are issues with direct lookups, yes, but you can safely and
easily iterate over that dictionary, and that's going to have plenty
of use.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Storing instances using jsonpickle Josh English <Joshua.R.English@gmail.com> - 2014-09-03 13:32 -0700
  Re: Storing instances using jsonpickle Ned Batchelder <ned@nedbatchelder.com> - 2014-09-03 16:52 -0400
    Re: Storing instances using jsonpickle Josh English <Joshua.R.English@gmail.com> - 2014-09-03 15:30 -0700
      Re: Storing instances using jsonpickle MRAB <python@mrabarnett.plus.com> - 2014-09-04 00:39 +0100
        Re: Storing instances using jsonpickle Denis McMahon <denismfmcmahon@gmail.com> - 2014-09-04 01:11 +0000
      Re: Storing instances using jsonpickle Ned Batchelder <ned@nedbatchelder.com> - 2014-09-03 22:18 -0400
        Re: Storing instances using jsonpickle Sam Raker <sam.raker@gmail.com> - 2014-09-03 21:52 -0700
        Re: Storing instances using jsonpickle Josh English <Joshua.R.English@gmail.com> - 2014-09-15 12:30 -0700
      Re: Storing instances using jsonpickle Chris Angelico <rosuav@gmail.com> - 2014-09-04 15:17 +1000
        Re: Storing instances using jsonpickle Dan Sommers <dan@tombstonezero.net> - 2014-09-05 04:38 +0000
          Re: Storing instances using jsonpickle Chris Angelico <rosuav@gmail.com> - 2014-09-05 15:08 +1000
      Re: Storing instances using jsonpickle MRAB <python@mrabarnett.plus.com> - 2014-09-04 12:07 +0100
      Re: Storing instances using jsonpickle MRAB <python@mrabarnett.plus.com> - 2014-09-05 18:04 +0100
        Re: Storing instances using jsonpickle Marko Rauhamaa <marko@pacujo.net> - 2014-09-05 20:16 +0300
          Re: Storing instances using jsonpickle Ned Batchelder <ned@nedbatchelder.com> - 2014-09-05 13:30 -0400
            Re: Storing instances using jsonpickle Marko Rauhamaa <marko@pacujo.net> - 2014-09-05 21:04 +0300
              Re: Storing instances using jsonpickle Ned Batchelder <ned@nedbatchelder.com> - 2014-09-05 16:50 -0400
                Re: Storing instances using jsonpickle Marko Rauhamaa <marko@pacujo.net> - 2014-09-05 23:57 +0300
          Re: Storing instances using jsonpickle Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2014-09-06 00:18 +0200
      Re: Storing instances using jsonpickle Chris Angelico <rosuav@gmail.com> - 2014-09-06 10:20 +1000
      Re: Storing instances using jsonpickle MRAB <python@mrabarnett.plus.com> - 2014-09-06 17:32 +0100
      Re: Storing instances using jsonpickle Ned Batchelder <ned@nedbatchelder.com> - 2014-09-06 12:56 -0400
      Re: Storing instances using jsonpickle Terry Reedy <tjreedy@udel.edu> - 2014-09-06 14:27 -0400

csiph-web