mCoding
mCoding
  • 117
  • 16 536 013
All 71 built-in Python functions
How many did you know?
A quick rundown of EVERY single one of the 71 builtin Python functions. Technically, these are not all functions, but these are the 71 callables that are listed in the Python docs as "Builtin functions". These are the global names that are available to call that you don't need to install or even import anything to use.
― mCoding with James Murphy (mcoding.io)
Docs: docs.python.org/3/library/functions.html
Source code: github.com/mCodingLLC/VideosSampleCode
SUPPORT ME ⭐
---------------------------------------------------
Sign up on Patreon to get your donor role and early access to videos!
patreon.com/mCoding
Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)
www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE
Want to donate crypto? Check out the rest of my supported donations on my website!
mcoding.io/donate
Top patrons and donors: Laura M, Jameson, Dragos C, Vahnekie, Neel R, Matt R, Johan A, Casey G, Mark M, Mutual Information, Pi
BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: discord.gg/Ye9yJtZQuN
Github: github.com/mCodingLLC/
Reddit: www.reddit.com/r/mCoding/
Facebook: james.mcoding
CHAPTERS
---------------------------------------------------
0:00 Intro
0:24 Math - bool int float complex max min divmod abs pow round sum
2:56 Collections - dict list tuple set frozenset
3:44 Strings - bytes bytearray str memoryview open
5:18 Strings - chr ord bin oct hex format input ascii repr
7:04 Iteration - iter next enumerate zip reversed sorted filter map
9:17 Iteration - all any range slice aiter anext
10:42 Debugging - breakpoint help print
11:16 Object - object getattr setattr delattr hasattr dir id
14:19 Object - hash len isinstance issubclass callable super type
16:29 Descriptors - property classmethod staticmethod
17:49 Dynamic - eval exec compile globals locals vars __import__
Переглядів: 42 950

Відео

Top 5 IDE Productivity Hacks That Will Save You Time Programming
Переглядів 25 тис.Місяць тому
Save time programming With all the tools available to us in modern IDEs, being a more productive programmer isn't about typing faster. Instead, knowing and taking advantage of powerful IDE features can automate a lot of the mundane and error prone tasks that waste your time, allowing you to get on with the good stuff. In this video we take a look at my top 5 IDE productivity hacks that save you...
What you need to know about Startup and Shutdown Events in FastAPI and ASGI Applications
Переглядів 9 тис.Місяць тому
Get started in FastAPI, Starlette, and ASGI! How do startup and shutdown events work in FastAPI, Starlette, and other ASGI applications? ASGI defines startup and shutdown events through the "lifespan" of an application, which it models as a connection between the server and the app. In this video we see the right way to do it in FastAPI, Starlette, and then understand the lifespan connection ty...
Async application classes vs. functions
Переглядів 10 тис.Місяць тому
To function or to class? According to the spec, an ASGI application is an async callable, but when we use FastAPI, Starlette, or other ASGI frameworks, that callable is hidden in plain sight. In this video, we see how it's possible to use an application class instead of a literal async def function, and we go over reasons for preferring the class approach. ― mCoding with James Murphy (mcoding.i...
Asynchronous Web Apps in Python
Переглядів 28 тис.Місяць тому
Building your future web app. Stop copy-pasting snippets to piece together a FastAPI app you don't really understand. Instead, buckle down and take the time to learn the fundamental building blocks that async web app frameworks in Python are built on top of. That way, you won't be stuck when there's no tutorial to copy from. ― mCoding with James Murphy (mcoding.io) Source code: github.com/mCodi...
Windows Command Escape Vulnerability - Critical CVE ... or is it?
Переглядів 25 тис.2 місяці тому
Critical! ... or is it? CVE-2024-24576 is a freshly reported 10/10 critical CVE affecting Rust, Python, and many other programming languages on Windows that, if exploited, can allow a malicious user to execute arbitrary code as the current user. The 10/10 rating is the worst severity that can be given to a CVE. However, of 9 affected programming languages, 5 have chosen to either not fix the CV...
Async for loops in Python
Переглядів 58 тис.2 місяці тому
Await for it! A deep dive into the purpose of the async for loop in Python. How to use the async for loop, why to use the async for loop, and how to write your own async iterators using both async generators as well as by learning the async iterator protocols and writing your own async iterator. We'll see an example ASGI app that computes the SHA256 hash of an uploaded file using Starlette and ...
The ins and outs of context managers and try-finally in Python
Переглядів 29 тис.3 місяці тому
You can't forget! Context managers (used with the "with" statement) and try-finally are both constructs in Python that help you ensure certain cleanup code runs even in the presence of exceptions. Becoming familiar with these constructs is important for developing good coding habits in Python. Don't put the burden of remembering how to do cleanup on yourself, use a context manager to let the ob...
Python Debugging (PyCharm + VS Code)
Переглядів 35 тис.4 місяці тому
Step by step through your program. Debugging is an essential and unavoidable part of programming. Everyone writes bugs, and we'd like to get rid of them. Print statements are fine to a certain point, but live debugging is usually a better option. With live debugging, you can step through your program one statement at a time, and set breakpoints at interesting places to stop, view, and interact ...
Modern Python logging
Переглядів 155 тис.5 місяців тому
A logging tutorial. At some point, print statements aren't enough. When that time comes in Python, you should reach for the builtin logging package. It may be old (committed in 2002!), but it is the standard in Python. Unfortunately though, it being so old means that it's full of stuff you shouldn't use, it doesn't follow modern conventions like PEP8 coding style, and many tutorials are vastly ...
How mathematicians prove something completely obvious.
Переглядів 16 тис.5 місяців тому
Zero, destroyer of things. We take for granted that 0 times anything equals 0. But why? You might think of counting numbers, but we use 0 for a lot of different systems like naturals, reals, modular arithmetic, function spaces, and in all these cases we still have 0 times anything equals 0. Something about 0 makes this happen in many different spaces. In this video we see the proof and discover...
Cloud Imports in Python
Переглядів 45 тис.6 місяців тому
Imagine and it is possible! Installing dependencies is such a pain! What if we could just point to a GitHub repo and just use whatever code is there? Python is a dynamic language after all, why do I need to install before running my code? Well with cloud imports you can eliminate the need for installing! Create modules on the fly without ever installing a thing! No need to mess with pesky virtu...
Bloom Filters
Переглядів 53 тис.7 місяців тому
Thanks to Hostinger: hostinger.com/mcoding Use coupon code MCODING at checkout to get an additional 10% off! Bloom filters are a simple probabilistic kind of set that exemplify how using probability to your advantage can result in huge performance wins at scale. By giving up some of the flexibility of a full set interface and even getting the wrong answer to "is this element in the set?" on a s...
Actually, you CAN divide by zero.
Переглядів 254 тис.7 місяців тому
Yes, it's possible! You've probably heard that you "can't" divide by zero, but why not? As it turns out, adding in the inverse of a number is a well-defined process in math, similar to how you can add in the solution to x^2 = -1. The result is a new number system. In this video, we find out what happens when you apply this process to add division by zero. The result is a pleasant mix of surpris...
Python 3.12 is HERE!
Переглядів 156 тис.8 місяців тому
What's new in Python 3.12 Python 3.12 has just released! Let's take a look at all the new features! ― mCoding with James Murphy (mcoding.io) Source code: github.com/mCodingLLC/VideosSampleCode What's new: docs.python.org/3/whatsnew/3.12.html Faster cpython: github.com/faster-cpython/ SUPPORT ME ⭐ Sign up on Patreon to get your donor role and early access to videos! patreon.com/mCoding Feeling g...
Lambda in a Loop is a Code Smell
Переглядів 61 тис.8 місяців тому
Lambda in a Loop is a Code Smell
A forbidden Python technique to put ANYTHING in a dict or set.
Переглядів 54 тис.10 місяців тому
A forbidden Python technique to put ANYTHING in a dict or set.
Don't make this big O mistake!
Переглядів 40 тис.11 місяців тому
Don't make this big O mistake!
Why I prefer attrs over dataclasses
Переглядів 62 тис.11 місяців тому
Why I prefer attrs over dataclasses
type(obj) vs. obj.__class__ in Python, and changing an object's class.
Переглядів 23 тис.Рік тому
type(obj) vs. obj. class in Python, and changing an object's class.
Python's collections.abc | InvertibleDict
Переглядів 45 тис.Рік тому
Python's collections.abc | InvertibleDict
unique_ptr is NOT just for heap allocations | custom deleters
Переглядів 12 тис.Рік тому
unique_ptr is NOT just for heap allocations | custom deleters
How to check whether a file exists in Python
Переглядів 28 тис.Рік тому
How to check whether a file exists in Python
unique_ptr: C++'s simplest smart pointer
Переглядів 41 тис.Рік тому
unique_ptr: C 's simplest smart pointer
Python's ternary operator
Переглядів 39 тис.Рік тому
Python's ternary operator
21 MORE nooby Python habits
Переглядів 113 тис.Рік тому
21 MORE nooby Python habits
str vs bytes in Python
Переглядів 77 тис.Рік тому
str vs bytes in Python
Intro to async Python | Writing a Web Crawler
Переглядів 74 тис.Рік тому
Intro to async Python | Writing a Web Crawler
Extending Python's Number hierarchy
Переглядів 29 тис.Рік тому
Extending Python's Number hierarchy
Fast pow! A general recursive power algorithm for more than just numbers.
Переглядів 39 тис.Рік тому
Fast pow! A general recursive power algorithm for more than just numbers.

КОМЕНТАРІ

  • @marcgentner1322
    @marcgentner1322 13 годин тому

    love the full and simple explanaition. i use staticmethods when appling MVC structure to my api's from the user_model UserModel class i need only sertain methods from the UserModel class. so i can call whathever query method i need in my controllers.

  • @trueplexx
    @trueplexx День тому

    Howly cow, 3h of debugging because I wrote "handler" in my json instead of "handlers"

    • @mCoding
      @mCoding День тому

      Dang! Maybe a TypedDict type hint for the logging config would be a good idea to prevent those kinds of typos.

  • @DeepFriedOreoOffline
    @DeepFriedOreoOffline 2 дні тому

    I am not sure why it's a nooby mistake to write your own code when there's an existing algorithm. Sure, it can show inexperience in not knowing that there is an existing algorithm. But right before seeing this video I was watching a video reviewing a Ray Tracing engine. That engine used accumulate. The person doing the review was confused why the debugger showed that ~40% of the compute time of this extremely slow Ray Tracer was happening inside of accumulate, when the math itself was under 1%. So he replaced the function with a for loop and brought the render time from over 7 minutes, down to ~20 seconds.

    • @mCoding
      @mCoding 11 годин тому

      I think I know the video you're referring to, by the Cherno, right? I'm not sure why this has become a popular reference against the use of the stl, but that was very much an instance of the author writing code that the compiler was not able to optimize (with the optimization settings he used), not a problem with the performance of the stl. Basically he used accumulate where it does not make sense at all to use accumulate. The error is akin to sorting a vector and grabbing the first element to get the min and then complaining that std::sort is slow, when in reality sort is just not the right tool for finding the min. An important part of using tools is knowing which tool to use even when many of them *can* be used.

  • @Megaloblocks
    @Megaloblocks 2 дні тому

    1. wrong they are as readable or better readable?????

  • @its_lucky252
    @its_lucky252 3 дні тому

    x = 10 10x = 100 10x + 9 = x 9x = -9 x = -1 any number = -1

  • @SummerFrost23
    @SummerFrost23 4 дні тому

    1/ε → + ∞ Claiming n > 1/ε is saying we have number larger than infinity. Is the reasoning logical? You also mentioned " x approaches 1" , but not showing any proof " x equal one".

    • @Chris-5318
      @Chris-5318 4 дні тому

      That was gibberish. 0.999... := lim n->oo 0.999...9 (n 9s) = lim n->oo 1 - 1/10^n = 1. He did prove that final limit starting at 6:47

  • @lukebatty3209
    @lukebatty3209 5 днів тому

    Proofs like this are things math majors do to make them feel better about their degree choices

    • @Chris_5318
      @Chris_5318 4 дні тому

      It's basic Calculus 2 and is taught to the brighter students at high school. Calculus goes to at least level 8. I learnt properly (as per the video, using epsilon-N) in in the first or second term of the first year of my _Electronics_ degree course. It is that basic.

  • @hughcaldwell1034
    @hughcaldwell1034 5 днів тому

    I realised a little while ago that (in my accent) the name of the appliance chain Harvey Norman is a phonetic rearrangement of "horny Marvin". I also thought of the term "anaphone" for this, but apparently it was already taken by the music theory people.

  • @supernovaaust
    @supernovaaust 5 днів тому

    So .99r doesnt =1 because it isnt defined correctly. Understood.👍 Lets up the anti. Lets run two sequences at the same time and find the difference. Lets assume that 1.001r =1holds exactly true to the same principals. We start the sequence .99 and 1.01. the answer to the difference is .002 The difference between 1 and both of these "approaching to 1" now doubles....:The difference between 1 and1=0 It is impossible for something to equal something else if one value doubles and the other value has no change.

    • @Chris-5318
      @Chris-5318 5 днів тому

      What is 0.001r supposed to be? The rest of what you say makes no sense either. Both 0.999... and 1 are the unique number that is greater than every term on the sequence 0.9, 0.99, 0.999, ... and less than every term in the sequence 1.1, 1.01, 1.001, ..., so is 1. Hence 0.999... = 1. FWIW The difference sequence is 1.1 - 0.9, 1.01 - 0.99, 1.001 - 0.999, ... = 0.2, 0.02, 0.002, ... and the limit of that sequence is 0. Hence both of the original sequence have the same limit. (I've skipped a few obvious details).

    • @supernovaaust
      @supernovaaust 5 днів тому

      @@Chris-5318 " both .999... And 1 are a unique number" .999.... Is not a number. It is an infinite sequence. It has no value of itself and is incalculable. It can only be understood by series. As each step in the series, it will be .o1... From 1. As you have pointed out. What I have stated is that if .999... =1 therefore 1.001... equals 1 for both will have an equal algebraic result, that being .001..., and as you progress through the series all results will be equal. However, at each step in this sequence the difference between 1 and 1 is always 0 but the difference between.999... and 1.001... will always be .002.... The question is: If .999...=1 then why does the difference double but the difference between 1 and itself not? Surely, if .999... were =1 then we would not see one value double.

    • @Chris-5318
      @Chris-5318 5 днів тому

      ​@@supernovaaust 0.999... is a numeral that represents a number. It is conventional to say that a decimal numeral is a number. You are right in that 0.999... is simply a concise notation for the geometric series 0.9 + 0.09 + 0.009 + .... The "steps" of that series is the sequence 0.9, 0.99, 0.999, ... and *>>by definition<<* the limit of that sequence is the value of the numeral 0.999.... You: " therefore 1.001... equals 1" Me: 1.001.. has the value of at 1 + 1/1000. You haven't said what the ... is supposed to indicate. Did you mean 1.001001001... or 1.00111... or was it an abysmal attempt at 1.000...1? If the latter, then that is not a valid decimal. You: the difference between.999... and 1.001... will always be .002...." Me: No, it isn't. 1.001... - 0.999... = 0.001... e.g. 1.0012 - 0.999... = 0.0012. I have no idea what this doubling is that you keep referring to. Try to be clearer. I'm sure that I have actually dealt with what you really meant, even though you aren't capable of understanding me. FYI here are the two main definitions that you need: Definition: The sum of a series is the limit of the sequence of its partial sums (if the limit exists). Definition: Let {S_n} be a sequence of real numbers and let S be a real number. Then S = lim n->oo S_n means that for every real ε > 0 there is a natural N such that for every natural n > N that |S_n - S| < ε. The sequence of the partial sums of 0.999... is 0.9, 0.99, 0.999, .... The n th term is 0.999...9 (n 9s) = 1 - 1/10^n Therefore: [the sum of] 0.999... := lim n->oo 0.999...9 (n 9s) = lim n->>oo 1 - 1/10^n = 1 I can prove the last equality using the definition of limit if you don't accept it. Regards your 1.001... thingy. I'm sure that you really mean 1.000...1. The problem with that is that it cannot possibly be an infinite (AKA endless) decimal because it has a last digit. If we try to construct what I expect that you are thinking of, the sequence of partial sums would be 1.1, 1.01,1.001, 1.0001, ... whose nth term is 1 + 1/10^n. The limit of that as n->oo is 1, not 1.000...1, yet alone your 1.001... abominotation. Before you reply again, I suggest that you read the geometric series Wiki. Better still learn this trivial Calculus 2 math. I won't respond for at least 8 hours as I'm going to bed.

    • @supernovaaust
      @supernovaaust 5 днів тому

      I have to disagree that 1.0000...1 is not infinite as everytime you add a zero the number differs even though the final number remains same. What you say?

    • @Chris-5318
      @Chris-5318 4 дні тому

      ​@@supernovaaust Of course 1.000...1 is not infinite. "Infinite" means "endless". 0.000...1 has a last digit (at the end). Infinite decimals do not have a last digit at the end because they do not have an end at which to place or a last digit. I can't readily imagine what you think infinite decimals are about. I assume that the digit before the 1 is also the last 0. You can't have infinitely (AKA endlessly) many 0s and have a last 0 at the non-existent end. You haven't understood the most basic definition of infinity. You: "... everytime you add a zero the number differs ... " Me: Clearly you are thinking of the SEQUENCE 0.1, 0.01, 0.001, ... where every time you "add" a 0 the new term differ from the previous one (by a factor of 10). If I temporarily accept your abysmal 0.000...1 and the like, then surely 0.999... + 0.000...1 = 0.999...1 and not 1 and 1 - 0.000...1 = 0.999...9 and not the 0.999... that it is supposed to be (using your farcically faulty ideas). Whatever, you are wrong according to literally everyone that has learnt Calculus 2. That includes several million degreed mathematicians.

  • @alaham2590
    @alaham2590 6 днів тому

    thank to you for making this video and for your sense of humor :)

  • @revokr7954
    @revokr7954 7 днів тому

    What IDE do you use sir?

    • @mCoding
      @mCoding 7 днів тому

      This video is using CLion, which is a paid product by JetBrains

  • @CHeRKeSSS00
    @CHeRKeSSS00 7 днів тому

    #mcoding

  • @pancreasdragonheart9765
    @pancreasdragonheart9765 7 днів тому

    Silly question, but can this bitset hold any number? For example, what if there're 255 unique numbers and not 9.

    • @mCoding
      @mCoding 7 днів тому

      Yes you can have any number of bits (until you run out of memory). The typical implementation of bitset holds an array of unsigned longs (of size=ceiling of how many bits you want/8) that it accesses by calculating offsets and masking.

  • @Vynelox
    @Vynelox 8 днів тому

    3:59 fuck i'm guilty of this one

  • @DeclanMBrennan
    @DeclanMBrennan 8 днів тому

    It seems somehow appropriate that the numeral zero looks like a tiny ring.

  • @aryakvn6051
    @aryakvn6051 8 днів тому

    3:50 this ones gonna cause a lot of headaches.

  • @inspectahhh
    @inspectahhh 8 днів тому

    #pycharm

  • @five2112
    @five2112 8 днів тому

    I'm hoping to learn C++ and have a lot of experience in other languages, so videos like this which point out newbie mistakes are total gold. Thank you!

  • @96Prasanna
    @96Prasanna 9 днів тому

    #mcoding

  • @pedroarthurstudart1999
    @pedroarthurstudart1999 9 днів тому

    5:42-5:43 and a reference to Mincraft damage taking.

  • @vladimir0rus
    @vladimir0rus 9 днів тому

    6:37 x2 variable is not a garbage initialized. It is initialized with a pointer to int. So x2 is a properly initialized pointer.

  • @ScienceSpider-sigma
    @ScienceSpider-sigma 10 днів тому

    The real question is "Is infinitesimal equal to 0" which it isn't. An infinitesimal isn't really a number, it's just a concept of getting closer to 0, just like infinity is a concept of getting higher with no end

    • @Chris-5318
      @Chris-5318 5 днів тому

      No it isn't. Decimals can't represent numbers that differ from a real any a non-zero infinitesimal amount. Infinitesimals most definitely are numbers. e.g. they are elements of Robinson's hyperreal numbers and Conway's surreal numbers. You are confusing infinitesimal numbers with the concept of convergence. They are completely different things.

    • @ScienceSpider-sigma
      @ScienceSpider-sigma 4 дні тому

      @@Chris-5318 Ohh yeah, I agree 0.999999… Isn’t an actual number because it just shows a limit, not a number, but I think what people are thinking when they ask this question is that 0.99999… is an infinitesimal less than 1 and what they are really wondering is whether an infinitesimal is zero

    • @Chris-5318
      @Chris-5318 4 дні тому

      ​@@ScienceSpider-sigma 0.999... is a numeral that represents a number. Numbers are pure abstract - they only exist as ideas. The number that the numeral 0.999... represents is a limit. It is the limit of the sequence 0.9, 0.99, 0.999, ... and that is easily provable to be the same number that is usually represented with the numeral 1. Limits are numbers. I can't imagine what else you think a limit could possibly be. The n th term of the sequence 0.9, 0.99, 0.999, ... is 0.999...9 (n 9s) = 1 - 1/10^n. Altogether: [the value of] 0.999... := lim n->oo 0.999...9 (n 9s) = lim n->oo 1 - 1/10^n = 1 Zero is an infinitesimal. However, people commonly mean a non-zero number when they refer to infinitesimals. As I previously said, decimals cannot represent numbers that differ from a real by a non-zero infinitesimal. For example, if 0.999... was infinitesimally less than 1, then there would be no decimal for 1 - 0.999... or 10 * 0.999... - 9. There is an extended decimal notation, called Lightstone notation, that can deal with infinitesimals.

  • @Murderface666
    @Murderface666 11 днів тому

    A lot of people just inject what they believe is right, thinking everyone else is wrong. That is the mark of a noob. Its really only young programmers who think they know a more than the next man trying to change things. Like really? " " over std::endl? That's like picking up a grain of sand from a beach with chopsticks. How about focusing on "making something that works" instead of worrying about how "efficient" (a noobs priority and whatever that means) an algorithm is.

  • @MattDog_222
    @MattDog_222 11 днів тому

    #11 I try to avoid truthy-falsey in high level languages in general. I often find myself spending much more time and effort holding the edge cases of it in my brain's working memory while debugging than if it was just if `len(x) == 0`

  • @vazaubaev
    @vazaubaev 11 днів тому

    Its better to use cst: ua-cam.com/video/ASRqxDGutpA/v-deo.html

  • @victotronics
    @victotronics 12 днів тому

    10:06 in the destructor you test on `m_ptr` being non zero. Shouldn't that be a test for it not being nullptr?

    • @mCoding
      @mCoding 12 днів тому

      Great question! In C++, a pointer is not nullptr if and only if it is nonzero, so if (p) and if (p != nullptr) are semantically identical, although you may prefer to use one over the other for stylistic reasons.

  • @RichardFeynman2282
    @RichardFeynman2282 13 днів тому

    Seems you forgot about copyright() ;)

  • @juanodonnell
    @juanodonnell 13 днів тому

    nice. how can i check if it was created in memory or not?

    • @mCoding
      @mCoding 13 днів тому

      The only surefire way would be to read the C source code, but you can reason about it by putting in a really big number and checking to see whether you RAM usage goes up by a proportional amount 😉

  • @maxhansen5166
    @maxhansen5166 13 днів тому

    i understand this series is not exactly drawing a lot of views, but it would be great if you could continue it anyway.... it helped me a lot so far

  • @Jagi125
    @Jagi125 13 днів тому

    Oh, I cannot believe that I've never seen @property. I've been overriding __getattr__ and __setattr__ for quite some time...

  • @element1192
    @element1192 14 днів тому

    Providing rigorous mathematical logic isn't the goal of these simple "proofs", the goal is to convince the layperson who doesn't understand the sequence

  • @jj18
    @jj18 14 днів тому

    I'm two years late for the pycharm licence

  • @its_lucky252
    @its_lucky252 14 днів тому

    what if you just assume it's infinity? how many contradictions will arise?

  • @1apostoli
    @1apostoli 15 днів тому

    structlog

  • @DavidDLee
    @DavidDLee 15 днів тому

    I don't think that adding CST into the explanation of match was a good idea, if you wanted to discuss match

  • @Sluggernaut
    @Sluggernaut 15 днів тому

    Im sure it's been said, but for #30, we can have const int* const ptr4 = &x; which is a const pointer to a const int.