On 2022-04-03 23:17:04 +0200, Marco Sulla wrote:
> On Sun, 3 Apr 2022 at 21:46, Peter J. Holzer <hjp-pyt...@hjp.at> wrote:
> > > > data.get_deep("users", 0, "address", "street", default="second star")
> >
> > Yep. Did that, too. Plus pass the final result through a function before
> > returning it.
> 
> I didn't understand. Have you added a func parameter?

Yes. Look at the code I posted (it's only 9 lines long).

> > I'm not sure whether I considered this when I wrote it, but a function
> > has the advantage of working with every class which can be indexed. A
> > method must be implemented on any class (so at least dict and list to be
> > useful).
> 
> You're right, but where to put it? I don't know if an iterableutil package
> exists. If included in the stdlib, I don't know where to put it. In
> collections maybe?

Yes, that seems like the least bad choice.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to