Re: New JSON encoding method proposal for custom objects
Hi, I think his goal is not to load the data back into python, but to use it to provide some kind of REST-Style interface. An example would be, if you have a class instance of a record of a movie, that it could be simply encoded and send over the wire to display. Without necessarily recreating the class on the other end. This would prevent any security risks from the deserialization. On Sun, Nov 29, 2015 at 9:40 PM, Denis McMahon wrote: > That's all well and good, but firstly you need to both dumps and loads to > work properly with json, and secondly there's no mechanism in json that > tells you what class of object you have. But I am not sure how useful that PEP/Change would be, assuming the code in Peter's response works. - Marco Kaulea -- https://mail.python.org/mailman/listinfo/python-list
Set Operations on Dicts
Hi, In one talk (I think it was [1]) it was described that sets are basically dicts without the values. Therefor it should be easy to apply set operations on dicts, for example: {'a': 123, 'b': 456} & {'a'} => {'a': 123} {'a': 123, 'b': 456} - {'a'} => {'b': 456} This if currently not implemented. Is there a technical reason that this is difficult or are there a lot of corner cases that make it not worth the trouble? I have not spend a lot of time on this, I just needed a feature like that and was surprised that it did not exists. - Marco [1] https://www.youtube.com/watch?v=C4Kc8xzcA68 -- https://mail.python.org/mailman/listinfo/python-list
Re: Set Operations on Dicts
On Mon, Feb 8, 2016 at 1:17 PM, Jussi Piitulainen < jussi.piitulai...@helsinki.fi> wrote: > I think nobody was quite willing to lay down the law on which dictionary > would take precedence when they have keys in common but different values > on those keys. Both ways make sense, and sometimes you want something > like arithmetic done to combine the values on common keys. > I don't expect this to be really useful. I only thought about using a set as a second argument. But that's an interesting proposal to only allow sets as the second > argument. Those particular cases may not be *too* difficult to express > as comprehensions, though still quite a mouthful compared to your > suggestion: > That is the restriction I had in mind. { k:d[k] for k in d if k in s } # d & s > > { k:d[k] for k in d if k not in s } # d - s > > That is basically what I did. But I expect this could be quite slow, since it has to take each value in s and perform a lookup in d. I would expect the pure set implementation to be more optimized. Also, what would be the nicest current way to express a priority union > of dicts? > > { k:(d if k in d else e)[k] for k in d.keys() | e.keys() } This seems like it might be useful for default configurations, as that is currently quite the hassle to do with `x = conf.get('x', fallback="default") -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
Hi, Haven't tried it myself, but pyforms[1] might suit your needs. - Marco [1] http://pyforms.readthedocs.org/en/latest/ On Sat, Feb 27, 2016 at 12:18 PM, wrote: > I have some VB forms with more than a hundred objects. If I cannot drag > and drop text boxes, list boxes, labels, etc., it will be too much work to > create that with several lines of code for each object. > Isn't there any good GUI IDE like Visual Basic? I hope there are some less > well known GUI IDEs which I did not come across. Thanks. > -- https://mail.python.org/mailman/listinfo/python-list