3 ms·
The problem is that the source code is often just a wrapper for another function... which you then have to read the source code for, etc, etc. I can't personal
by jeremysalwen 6y ago
The problem is that the source code is often just a wrapper for another function... which you then have to read the source code for, etc, etc.
I can't personally guess the type of the `id` argument to the hypothetical `add_item(id, qty)` function, but I would guess that the source code for that function would look like
def add_item(self, id, qty):
self._items.add(id, qty)
I would also note that python type hints can be
charge_customer(order_details: Dict[Product, int])
which is significantly more helpful than just knowing it's a dict.
- IgorPartola 6y agoWhy would you add the unnecessary level of indirection with the _add_item() method? And if your application uses standard IDs throughout then yes you can guess it :)
- kortex 6y agoThis happens all the time. Usually at api intersection boundaries. I do this a lot interfacing camera drivers in some flavor of C with C++ run times, so most gets passed through, but char* goes to string, pointers go to shared_ptr, etc. I also use it a lot at boundaries where the modality changes, eg going from local data structures to RPC, where the data shape is the same, but there is io and fault tolerance to deal with.