How to Return Multiple Values from a Function in Python

Understanding Functions in Python πŸ’‘ A Python function is a block of reusable code that performs a specific task. Functions help break your code into smaller, more modular and manageable pieces, which improves readability and maintainability. Python functions are defined using the def keyword, followed by the function’s name and a pair of parentheses containing … Read more

Python Return Nothing/Null/None/NaN From Function

Understanding Python Return Values In Python programming, return values play a crucial role in the functionality of functions. This section explains different types of return values and how they are represented in Python. Types of Return Values None: In Python, None represents the absence of a value. It is often used as a default return … Read more

Python Return Lambda From Function

How to Return a Lambda Function From a Function? In Python, you can return a lambda function from another function by declaring the lambda function inside the return statement of the outer function. The returned lambda function can then be assigned to a variable and used just like any other function, and it will have … Read more

Python Return Continue From Function

Can I return continue from a function? A function that contains a while or for loop can also use break and continue to abort the loop. If this would also end the function, the more Pythonic alternative would be to just use return. As a rule of thumb, you can end iterative repetition using break, … Read more

Python Return Context Manager From Function

Understanding Context Managers in Python πŸ’‘ Context managers in Python are a convenient and efficient way to manage resources such as file handles, sockets, and database connections. They ensure that the resources are acquired and released properly, reducing the chance of resource leaks. The with statement is used in conjunction with context managers to ensure … Read more

Python Return Class From Function

Can you return a class from a function in Python? In Python, all entities are objects, allowing functions to return not just numerical types like int, float, or complex values, but also collections (list, tuple, dictionary, set), custom objects, classes, functions, and even modules or packages. Let’s Dive Into Python Functions and Classes First πŸ‘‡ … Read more

Python Return Two or Multiple Lists, Dicts, Arrays, DataFrames From a Function

Python Functions and Return Statements Basic Function Syntax Python functions are a key element in writing modular and reusable code. They allow you to define a block of code that can be called with specific arguments to perform a specific task. The function syntax in Python is simple and clean. You can define a function … Read more

Python Return Key Value Pair From Function

Understanding Python Functions and Return Key-Value Pairs Python functions can return values, which allows you to retrieve information or the result of a computation from the function. Sometimes, you may want your function to return a key-value pair, a common data structure used in Python dictionaries. Key-value pairs help link pieces of related information, such … Read more

Python Return Generator From Function

Python provides the capability to create your own iterator function using a construct known as a generator. πŸ’‘ A generator is a unique kind of function. Unlike traditional functions that return a single value, a generator returns a special object — an iterator, which can produce a sequence of values over time. The key feature … Read more

How to Return a JSON Object From a Function in Python?

Return a JSON String Object from the json.dumps() Method The JSON (JavaScript Object Notation) format is widely used for transmitting structured data, especially between web applications. Fortunately, Python has several libraries for dealing with this data format, including the json module. The JSON format can nest data within β€œobject literals” denoted by curly braces. Like … Read more

Solidity Function Calls – Internal and External

In this article, we’ll take a closer look at function calls in general, specifically internal function calls in Solidity. It’s part of our long-standing tradition to make this (and other) articles a faithful companion and a supplement of the official Solidity documentation. You can watch my explainer video on the topic here—I’ll talk about function … Read more