Python para impacientes

Reativa

Está curtindo os conteúdos da Reativa? Quer que a gente te ajude a ser um dev melhor? Deixe seu melhor email aqui.

Python tudo sobre Generators

January 05, 2020

Glossary of Generator Produce value via generator Unpacking Generators Implement Iterable object via generator Send message to generator…

Python tudo sobre Sets

January 05, 2020

Set comprehension Uniquify a List Union Two Sets Append Items to a Set Intersection Two Sets Common Items from Sets Contain b contains a a…

Python tudo sobre novidades no Python3

January 05, 2020

============== is a function New in Python 3.0 PEP 3105 - Make print a function Python 2 Python 3 String is unicode New in Python 3.0 PEP…

Python tudo sobre segurança

January 05, 2020

Simple https server Generate a SSH key pair Get certificate information output: Generate a self-signed certificate output: Prepare a…

Python tudo sobre Testes

January 05, 2020

A simple Python unittest Python unittest setup & teardown hierarchy output: Different module of setUp & tearDown hierarchy output: Run tests…

Python tudo sobre Funções

January 05, 2020

A function can help programmers to wrap their logic into a task for avoiding duplicate code. In Python, the definition of a function is so…

Python tudo sobre Arquivos e I/O

January 05, 2020

Read a File In Python 2, the content of the file which read from file system does not decode. That is, the content of the file is a byte…

Python tudo sobre Future

January 05, 2020

Future statements tell the interpreter to compile some semantics as the semantics which will be available in the future Python version. In…

Python tudo sobre C Extensions

January 05, 2020

Occasionally, it is unavoidable for pythoneers to write a C extension. For example, porting C libraries or new system calls to Python…

Python tudo sobre Style

January 05, 2020

Naming Class Bad Good Function Bad Good Variable Bad Good Acesse a Referência original 1: Acesse a Referência original 2:

Python tudo sobre Typing

January 05, 2020

PEP 484, which provides a specification about what a type system should look like in Python3, introduced the concept of type hints. Moreover…

Python tudo sobre SQLAlchemy

January 05, 2020

Set a database URL output: Sqlalchemy Support DBAPI - PEP249 Transaction and Connect Object Metadata - Generating Database Schema Inspect…

Python tudo sobre Asyncio

January 05, 2020

======= asyncio.run New in Python 3.7 Future like object Future like object other task Patch loop runner Put blocking task into Executor…

Python para iniciantes

January 05, 2020

============ The main goal of this cheat sheet is to collect some common and basic semantics or snippets. The cheat sheet includes some…

Python tudo sobre Listas

January 05, 2020

The list is a common data structure which we use to store objects. Most of the time, programmers concern about getting, setting, searching…

Python tudo sobre Classes e Objectos

January 05, 2020

List Attributes Get Instance Type Declare a Class Equals to Has / Get / Set Attributes Check Inheritance Get Class Name New and Init will…

Python tudo sobre Dicionários

January 05, 2020

Get All Keys Get Key and Value Find Same Keys Set a Default Value returns its default value if key is not in the dictionary. However, if…

Python tudo sobre Unicode

January 05, 2020

The main goal of this cheat sheet is to collect some common snippets which are related to Unicode. In Python 3, strings are represented by…

Python tudo sobre Concurrency

January 05, 2020

Execute a shell command Create a thread via “threading” Performance Problem - GIL Consumer and Producer Thread Pool Template Using…

Python tudo sobre Sockets

January 05, 2020

Socket programming is inevitable for most programmers even though Python provides much high-level networking interface such as httplib…

Python como usar o average_by

January 04, 2020

Returns the average of a list, after mapping each element to a value using the provided function. Use to map each element to the value…

Python como usar o every

January 04, 2020

Returns if the provided function returns for every element in the list, otherwise. Use in combination with and to check if returns…

Python como usar o min_n

January 04, 2020

Returns the minimum elements from the provided list. If is greater than or equal to the provided list’s length, then return the original…

Python como usar o initial

January 04, 2020

Returns all the elements of a list except the last one. Use to return all but the last element of the list. Acesse a Referência original…

Python como usar o min_by

January 04, 2020

Returns the minimum value of a list, after mapping each element to a value using the provided function. Use with to map each element to a…

Python como usar o cast_list

January 04, 2020

Casts the provided value as a list if it’s not one. Use to check if the given value is enumerable and return it by using or encapsulated…

Python como usar o is_anagram

January 04, 2020

Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters). Use to remove…

Python como usar o sum_by

January 04, 2020

Returns the sum of a list, after mapping each element to a value using the provided function. Use with to map each element to a value…

Python como usar o factorial

January 04, 2020

Calculates the factorial of a number. Use recursion. If is less than or equal to , return . Otherwise, return the product of and the…

Python como usar o degrees_to_rads

January 04, 2020

Converts an angle from degrees to radians. Use and the degrees to radians formula to convert the angle from degrees to radians. Acesse a…

Python como usar o max_n

January 04, 2020

Returns the maximum elements from the provided list. If is greater than or equal to the provided list’s length, then return the original…

Python como usar o values_only

January 04, 2020

Returns a flat list of all the values in a flat dictionary. Use to return the values in the given dictionary. Return a of the previous…

Python como usar o last

January 04, 2020

Returns the last element in a list. use to return the last element of the passed list. Acesse a Referência original 1: Acesse a Referência…

Python como usar o all_unique

January 04, 2020

Returns if all the values in a list are unique, otherwise. Use on the given list to remove duplicates, use to compare its length with…

Python como usar o similarity

January 04, 2020

Returns a list of elements that exist in both lists. Use list comprehension on to only keep values contained in both lists. Acesse a…

Python como usar o bifurcate_by

January 04, 2020

Splits values into two groups according to a function, which specifies which group an element in the input list belongs to. If the function…

Python como usar o flatten

January 04, 2020

Flattens a list of lists once. Use nested list comprehension to extract each value from sub-lists in order. Acesse a Referência original…

Python como usar o curry

January 04, 2020

Curries a function. Use to return a new partial object which behaves like with the given arguments, , partially applied. Acesse a…

Python como usar o compose_right

January 04, 2020

Performs left-to-right function composition. Use to perform left-to-right function composition. The first (leftmost) function can accept…

Python como usar o average

January 04, 2020

Returns the average of two or more numbers. Use to sum all of the provided, divide by . Acesse a Referência original 1: Acesse a…

Python como usar o union

January 04, 2020

Returns every element that exists in any of the two lists once. Create a with all values of and and convert to a . Acesse a Referência…

Python como usar o max_by

January 04, 2020

Returns the maximum value of a list, after mapping each element to a value using the provided function. Use with to map each element to a…

Python como usar o capitalize

January 04, 2020

Capitalizes the first letter of a string. Capitalize the first letter of the string and then add it with rest of the string. Omit the…

Python como usar o unique_elements

January 04, 2020

Returns the unique elements in a given list. Create a from the list to discard duplicated values, then return a from it. Acesse a…

Python como usar o median

January 04, 2020

Finds the median of a list of numbers. Sort the numbers of the list using and find the median, which is either the middle element of the…

Python como usar o fibonacci

January 04, 2020

Generates a list, containing the Fibonacci sequence, up until the nth term. Starting with and , use to add the sum of the last two numbers…

Python como usar o function_name

January 04, 2020

Given a predicate function, , and a string, this curried function will then take an object to inspect by calling the property and passing…

Python como usar o kebab

January 04, 2020

Converts a string to kebab case. Break the string into words and combine them adding as a separator, using a regexp. Acesse a Referência…

Python como usar o clamp_number

January 04, 2020

Clamps within the inclusive range specified by the boundary values and . If falls within the range, return . Otherwise, return the…

Python como usar o digitize

January 04, 2020

Converts a number to a list of digits. Use combined with on the string representation of and return a list from the result. Acesse a…

Python como usar o compose

January 04, 2020

Performs right-to-left function composition. Use to perform right-to-left function composition. The last (rightmost) function can accept…

Python como usar o decapitalize

January 04, 2020

Decapitalizes the first letter of a string. Decapitalize the first letter of the string and then add it with rest of the string. Omit the…

Python como usar o filter_unique

January 04, 2020

Filters out the unique values in a list. Use a to get the count of each value in the list. Use list comprehension to create a list…

Python como usar o shuffle

January 04, 2020

Randomizes the order of the values of an list, returning a new list. Uses the Fisher-Yates algorithm to reorder the elements of the list…

Python como usar o count_by

January 04, 2020

Groups the elements of a list based on the given function and returns the count of elements in each group. Use to map the values of the…

Python como usar o max_element_index

January 04, 2020

Returns the index of the element with the maximum value in a list. Use and to get the maximum value in the list and return its index…

Python como usar o palindrome

January 04, 2020

Returns if the given string is a palindrome, otherwise. Use and to convert to lowercase and remove non-alphanumeric characters from the…

Python como usar o in_range

January 04, 2020

Checks if the given number falls within the given range. Use arithmetic comparison to check if the given number is in the specified range…

Python como usar o group_by

January 04, 2020

Groups the elements of a list based on the given function. Use and to map the values of the list to the keys of an object. Use list…

Python como usar o spread

January 04, 2020

Flattens a list, by spreading its elements into a new list. Loop over elements, use if the element is a list, otherwise. Acesse a…

Python como usar o head

January 04, 2020

Returns the head of a list. Use to return the first element of the passed list. Acesse a Referência original 1: Acesse a Referência…

Python como usar o is_divisible

January 04, 2020

Checks if the first numeric argument is divisible by the second one. Use the modulo operator () to check if the remainder is equal to…

Python como usar o byte_size

January 04, 2020

Returns the length of a string in bytes. Use to encode the given string and return its length. Acesse a Referência original 1: Acesse a…

Python como usar o transpose

January 04, 2020

Returns the transpose of a two-dimensional list. Use to get the passed list as tuples. Use in combination with to create the transpose of…

Python como usar o compact

January 04, 2020

Removes falsey values from a list. Use to filter out falsey values (, , , and ). Acesse a Referência original 1: Acesse a Referência…

Python como usar o n_times_string

January 04, 2020

Prints out the same string a defined number of times. Repeat the string times, using the operator. Acesse a Referência original 1: Acesse…

Python como usar o rads_to_degrees

January 04, 2020

Converts an angle from radians to degrees. Use and the radian to degree formula to convert the angle from radians to degrees. Acesse a…

Python como usar o sample

January 04, 2020

Returns a random element from a list. Use to generate a random number that corresponds to an index in the list, return the element at that…

Python como usar o offset

January 04, 2020

Moves the specified amount of elements to the end of the list. Use and to get the two slices of the list and combine them before returning…

Python como usar o map_values

January 04, 2020

Creates an object with the same keys as the provided object and values generated by running the provided function for each value. Use to…

Python como usar o is_odd

January 04, 2020

Returns if the given number is odd, otherwise. Checks whether a number is even or odd using the modulo () operator. Returns if the…

Python como usar o all_equal

January 04, 2020

Checks if all elements in a list are equal. Use and to compare all the values in the given list. Acesse a Referência original 1: Acesse a…

Python como usar o longest_item

January 04, 2020

Takes any number of iterable objects or objects with a length property and returns the longest one. If multiple objects have the same…

Python como usar o is_even

January 04, 2020

Returns if the given number is even, otherwise. Checks whether a number is odd or even using the modulo () operator. Returns if the…

Python como usar o split_lines

January 04, 2020

Splits a multiline string into a list of lines. Use and to match line breaks and create a list. provides similar functionality to this…

Python como usar o difference_by

January 04, 2020

Returns the difference between two lists, after applying the provided function to each list element of both. Create a by applying to each…

Python como usar o reverse_string

January 04, 2020

Returns the reverse of a string. Use string slicing to reverse the string. Acesse a Referência original 1: Acesse a Referência original 2:

Python como usar o keys_only

January 04, 2020

Returns a flat list of all the keys in a flat dictionary. Use to return the keys in the given dictionary. Return a of the previous result…

Python como usar o intersection_by

January 04, 2020

Returns a list of elements that exist in both lists, after applying the provided function to each list element of both. Create a by…

Python como usar o delay

January 04, 2020

Invokes the provided function after milliseconds. Use to delay the execution of by seconds. Acesse a Referência original 1: Acesse a…

Python como usar o deep_flatten

January 04, 2020

Deep flattens a list. Use recursion. Use with to check if an element is iterable. If it is, apply recursively, otherwise return . Acesse…

Python como usar o unfold

January 04, 2020

Builds a list, using an iterator function and an initial seed value. The iterator function accepts one argument () and must always return a…

Python como usar o count_occurences

January 04, 2020

Counts the occurrences of a value in a list. Increment a counter for every item in the list that has the given value and is of the same type…

Python como usar o bifurcate

January 04, 2020

Splits values into two groups. If an element in is , the corresponding element in the collection belongs to the first group; otherwise, it…

Python como usar o intersection

January 04, 2020

Returns a list of elements that exist in both lists. Create a from and , then use the built-in set operator to only keep values contained…

Python como usar o some

January 04, 2020

Returns if the provided function returns for at least one element in the list, otherwise. Use in combination with and to check if…

Python como usar o every_nth

January 04, 2020

Returns every nth element in a list. Use to create a new list that contains every nth element of the given list. Acesse a Referência…

Python como usar o initialize_2d_list

January 04, 2020

Initializes a 2D list of given width and height and value. Use list comprehension and to generate rows where each is a list with length…

Python como usar o difference

January 04, 2020

Returns the difference between two iterables. Create a from , then use list comprehension on to only keep values not contained in the…

Python como usar o most_frequent

January 04, 2020

Returns the most frequent element in a list. Use to get the unique values in the combined with to find the element that has the most…

Python como usar o filter_non_unique

January 04, 2020

Filters out the non-unique values in a list. Use a to get the count of each value in the list. Use list comprehension to create a list…

Python como usar o lcm

January 04, 2020

Returns the least common multiple of a list of numbers. Use , and over the given list. Acesse a Referência original 1: Acesse a Referência…

Python como usar o camel

January 04, 2020

Converts a string to camelcase. Use to replace any or with a space, using the regexp . Use to capitalize the first letter of each word…

Python como usar o chunk

January 04, 2020

Chunks a list into smaller lists of a specified size. Use and to create a list of the desired . Use on the list and fill it with splices…

Python como usar o tail

January 04, 2020

Returns all elements in a list except for the first one. Return if the list’s length is more than , otherwise, return the whole list…

Python como usar o snake

January 04, 2020

Converts a string to snake case. Break the string into words and combine them adding as a separator, using a regexp. Acesse a Referência…

Python como usar o has_duplicates

January 04, 2020

Returns if there are duplicate values in a flat list, otherwise. Use on the given list to remove duplicates, compare its length with the…

Python como usar o union_by

January 04, 2020

Returns every element that exists in any of the two lists once, after applying the provided function to each element of both. Create a by…

Python como usar o gcd

January 04, 2020

Calculates the greatest common divisor of a list of numbers. Use and over the given list. Acesse a Referência original 1: Acesse a…

Python como usar o when

January 04, 2020

Tests a value, , against a function, conditionally applying a function. Check if the value of is and if so return , otherwise return…

Python como usar o none

January 04, 2020

Returns if the provided function returns for at least one element in the list, otherwise. Use and to check if returns for all the…

Python como usar o zip

January 04, 2020

Creates a list of elements, grouped based on the position in the original lists. Use combined with to get the length of the longest list…