Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Compressing list[0], list[1], list[2],... into a simple statement

Unpack the list with the *args notation.

x = Classname(*listname)

You could use

listname = [1, 2, 3, 4, 5]

class Classname:
    def __init__(self, *args):
        print(args)

x = Classname(*listname)

Tags:

Python

List

Related

How do I remove the special characters within multiple lines in Regex? get rid of white border around option menu Cannot navigate to path using MemoryRouter while testing EF inserting values in table failed after some time How can I make tuples an instance of this class in Haskell? How to send a response card using AWS Lambda in C# Does Python forbid two similarly looking Unicode identifiers? jQuery - Bodymovin JSON not loading Why is the "move" keyword necessary when it comes to threads; why would I ever not want that behavior? Value of protocol type 'Encodable' cannot conform to 'Encodable'; only struct/enum/class types can conform to protocols Dealing with R8 + JvmStatic Annotation + Lambda in public API for Android Library written in Kotlin Is accessing an element of a multidimensional array out of bounds undefined behavior?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy