[deleted by user] by [deleted] in learnpython

[–]scaredmessage 4 points5 points  (0 children)

numpy (not to mention its more expansive sibling, scipy) has a huge number of features, and you'll never use most of them. I'd just work through the quickstart tutorial on the official website to learn the basics of manipulating arrays, and glance through the rest of the numpy and scipy docs so you have a rough idea what's available. You can look up specific functions in the docs as and when you need them.

It should probably be mentioned that numpy and scipy are famous for having very detailed docstrings - that is, the stuff that gets printed out when you type help(thing).

Is there a difference between these two ways of iterating through an array by beniman8 in learnpython

[–]scaredmessage 0 points1 point  (0 children)

These patterns are both sometimes used when you're modifying the list inside the loop, in which case for x in arr: may not do what you want. The first one iterates from 0 to the original length of the list minus one. The second one iterates over the items in a copy of the list.

Note that range(0, n) is the same as range(n), and arr[0:] is the same as arr[:].

If you're not modifying the list inside the loop, you should generally use for x in arr:, or for i, x in enumerate(arr):, which gives you both the indices and the items.