Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 23338

Python Morsels: Python Built-in Functions To Know

$
0
0

Which built-ins should you know about?

I estimate most Python developers will only ever need about 30 built-in functions, but which 30 depends on what you're actually doing with Python.

We're going to take a look at all 71 of Python's built-in functions, in a birds eye view sort of way.

I'll attempt to categorize these built-ins into five categories:

  1. Commonly known built-ins: most newer Pythonistas get exposure to these built-ins pretty quickly out of necessity
  2. Overlooked by new Pythonistas: these functions are useful to know about, but they're easy to overlook when you're newer to Python
  3. Learn these later: these built-ins are generally useful to know about, but you'll find them when/if you need them
  4. Maybe learn these eventually: these can come in handy, but only in specific circumstances
  5. You likely don't need these: you're unlikely to need these unless you're doing something fairly specialized

The built-in functions in categories 1 and 2 are the essential built-ins that nearly all Python programmers should eventually learn about. The built-ins in categories 3 and 4 are the specialized built-ins, which are often very useful but your need for them will vary based on your use for Python. And category 5 are arcane built-ins, which might be very handy when you need them but which many Python programmers are likely to never need.

Note for pedantic Pythonistas: I will be referring to all of these built-ins as functions, even though 27 of them aren't actually functions.

The commonly known built-in functions (which you likely already know about):

  1. print
  2. len
  3. str
  4. int
  5. float
  6. list
  7. tuple
  8. dict
  9. set
  10. range

The built-in functions which are often overlooked by newer Python programmers:

  1. sum
  2. enumerate
  3. zip
  4. bool
  5. reversed
  6. sorted
  7. min
  8. max
  9. any
  10. all

There are also 5 commonly overlooked built-ins which I recommend knowing about solely because they make debugging easier:

  1. dir
  2. vars
  3. breakpoint
  4. type
  5. help

In addition to the 25 built-in functions above, we'll also briefly see the other 46 built-ins in the learn it latermaybe learn it eventually and you likely don't need these sections.

The 10 commonly known built-in functions

If you've been writing Python …

Read the full article: https://www.pythonmorsels.com/built-in-functions-in-python/


Viewing all articles
Browse latest Browse all 23338

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>