Whenever Jeremy displays a list in a notebook cell, it includes the length of the list (which is very handy). For example:
(#421) is the number of items in the list.
I probably missed this somewhere, but how is this accomplished? Is this a notebook extension, or does fastai monkey-patch the
__repr__ of Python lists, or something else?
It is accomplished using a separate data structure known as L which has all the functionalities of Python lists and much more. Check out my article on it here: https://towardsdatascience.com/upgrading-python-lists-35440096ec36.
Ah, thanks. I saw it mentioned in the lesson or notebooks but didn’t realize it replaced regular lists as well. I’ll check out your article!
EDIT: When I looked at the fastai code earlier, I thought it returned a regular list from
get_image_files() but I misread. Now I see it returns an
L(...) of that list. That makes sense.
They’re using L in a lot of places this time It’s nice
Hi dipam7 hope you’re having a jolly day!
Great post, concise, clear, short and very useful, I hadn’t realized it was so useful!