#python_builtins_by_driscollis Suchergebnisse

#Python includes a function called `vars()`, which will return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute. Without an argument, `vars()` acts like `locals()` #python_builtins_by_driscollis 🧵🐍👇

driscollis's tweet image. #Python includes a function called `vars()`, which will return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.

Without an argument, `vars()` acts like `locals()`

#python_builtins_by_driscollis

🧵🐍👇

#Python has the useful `globals()` built-in It returns the dictionary implementing the current module namespace. For code within functions, this is set when the function is defined and remains the same regardless of where the function is called. #python_builtins_by_driscollis

driscollis's tweet image. #Python has the useful `globals()` built-in

It returns the dictionary implementing the current module namespace. For code within functions, this is set when the function is defined and remains the same regardless of where the function is called.

#python_builtins_by_driscollis

#Python includes several handy built-in functions you can use to work with class attributes. One such built-in is called `delattr` and is used for deleting attributes. I have never really needed this built-in myself, but here's an example #python_builtins_by_driscollis

driscollis's tweet image. #Python includes several handy built-in functions you can use to work with class attributes.

One such built-in is called `delattr` and is used for deleting attributes.

I have never really needed this built-in myself, but here's an example

#python_builtins_by_driscollis

#Python has a `bytes()` built-in that is closely related to its `bytearray()` built-in. 🐍🔥 The difference is that `bytes()` as immutable! `bytes()` has the same non-mutating methods and indexing and slicing behavior. #python_builtins_by_driscollis

driscollis's tweet image. #Python has a `bytes()` built-in that is closely related to its `bytearray()` built-in. 🐍🔥

The difference is that `bytes()` as immutable!

`bytes()` has the same non-mutating methods and indexing and slicing behavior.

#python_builtins_by_driscollis

Another great #Python built-in is `chr()` 🐍🔥 `chr(i)` will return the string representing a character whose Unicode code point is the integer i. Note: This is the inverse of `ord()` Below are a couple of examples: #python_builtins_by_driscollis

driscollis's tweet image. Another great #Python  built-in is `chr()` 🐍🔥

`chr(i)` will return the string representing a character whose Unicode code point is the integer i.

Note: This is the inverse of `ord()`

Below are a couple of examples:

#python_builtins_by_driscollis

#Python includes a `memoryview() built-in class. According to the docs, "memoryview objects allow Python code to access the internal data of an object that supports the buffer protocol without copying." #python_builtins_by_driscollis 🧵🐍👇


#Python includes two functions for creating sets. You are probably familiar with `set()`, so let's talk about the `frozenset()` built-in today! ☃️🐍 docs.python.org/3/library/stdt… #python_builtins_by_driscollis 🧵🐍👇


Another great #Python built-in function is `getattr()`. `getattr()` will eturn the value of the named attribute of object. If the string is the name of one of the object’s attributes, the result is the value of that attribute. #python_builtins_by_driscollis 🧵👇🐍


#Python includes the `complex()` built-in function, which will return a complex number with the value real + imag*1j or convert a string or number to a complex number Let's learn more about how `complex()` works! #python_builtins_by_driscollis 🧵🐍👇


Another great built-in #Python function is `callable()` According to the docs, `callable()` will return True if the object argument appears callable, False if not. #python_builtins_by_driscollis 🧵🐍👇


#Python includes a handy `filter()` function that is built-in `filter()` takes two arguments: 🐍 function - The function to call 🐍 iterable - An iterable of items to pass to the function #python_builtins_by_driscollis 🧵🐍👇


Starting in Python 3.7, the `breakpoint()` built-in function was added It is defined in PEP 553 and simplifies adding a breakpoint to your code #python_builtins_by_driscollis 🧵🐍👇


One of #Python's most controversial built-in functions is `eval()`. The main reason it is controversial is that it can be used to execute arbitrary code. #python_builtins_by_driscollis 🧵🐍👇


#Python includes a handy built-in function called `input()` that you can use to prompt the user for information. The function will read what the user types in and return it as a string #python_builtins_by_driscollis 🧵🐍👇


#Python includes a `memoryview() built-in class. According to the docs, "memoryview objects allow Python code to access the internal data of an object that supports the buffer protocol without copying." #python_builtins_by_driscollis 🧵🐍👇


Another great built-in function in #Python is the `ascii()` built-in You will learn about `ascii()` in this mini-thread! 🧵🐍👇 #python_builtins_by_driscollis


Did you know there is a handy built-in for #Python called `hasattr()`? It takes in the object and a string. The result is True if the string is the name of one of the object’s attributes, False if not. #python_builtins_by_driscollis 🧵🐍👇


Python includes a built-in callable named `bytearray()`. The bytearray class is a mutable sequence of integers in the range 0 <= x < 256. They return a new array of bytes #python_builtins_by_driscollis 🧵🐍👇


Starting in Python 3.7, the `breakpoint()` built-in function was added It is defined in PEP 553 and simplifies adding a breakpoint to your code #python_builtins_by_driscollis 🧵🐍👇


#Python includes an `exec()` built-in that is closely related to the `eval()` built-in. The difference is that `exec()` can take code blocks, but it always returns None #python_builtins_by_driscollis 🧵🐍👇


Keine Ergebnisse für "#python_builtins_by_driscollis"
Keine Ergebnisse für "#python_builtins_by_driscollis"
Keine Ergebnisse für "#python_builtins_by_driscollis"
Loading...

Something went wrong.


Something went wrong.


United States Trends