The Wayback Machine - https://web.archive.org/web/20240723070203/https://www.geeksforgeeks.org/enum-auto-in-python/
Open In App

enum.auto() in Python

Last Updated : 22 Apr, 2020
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

With the help of enum.auto() method, we can get the assigned integer value automatically by just using enum.auto() method.

Syntax : enum.auto()

Automatically assign the integer value to the values of enum class attributes.

Example #1 :
In this example we can see that by using enum.auto() method, we are able to assign the numerical values automatically to the class attributes by using this method.




# import enum and auto
from enum import Enum, auto
  
# Using enum.auto() method
class language(Enum):
    Java = auto()
    Python = auto()
    HTML = auto()
  
print(list(language))


Output :

[,, ]

Example #2 :




# import enum and auto
from enum import Enum, auto
  
# Using enum.auto() method
class language(Enum):
    Cpp = auto()
    JavaScript = auto()
    Java = auto()
    Python = auto()
    HTML = auto()
  
print(list(language))


Output :

[,,,, ]



Similar Reads

enum.IntEnum in Python
With the help of enum.IntEnum() method, we can get the enumeration based on integer value, if we compare with normal enum based class it will fail by using enum.IntEnum() method. Syntax : enum.IntEnum Return : IntEnum doesn't have a written type. Example #1 : In this example we can see that by using enum.IntEnum() method, we are able to get the enu
1 min read
Adding new enum column to an existing MySQL table using Python
Prerequisite: Python: MySQL Create Table In this article, we are going to see how to add a new enum column to an existing MySQL table using Python. Python allows the integration of a wide range of database servers with applications. A database interface is required to access a database from Python. MySQL Connector-Python module is an API in python
1 min read
enum in Python
Enumerations in Python are implemented by using the module named "enum". Enumerations are created using classes. Enums have names and values associated with them. Let's cover the different concepts of Python Enum in this article.What are Enums and Why are they useful?Enumerations or Enums is a set of symbolic names bound to unique values. It can be
6 min read
How to Define an Auto Increment Primary Key in PostgreSQL using Python?
Prerequisite: PostgreSQL Python has various database drivers for PostgreSQL. Currently, most used version is psycopg2 because it fully implements the Python DB-API 2.0 specification. The psycopg2 provides many useful features such as client-side and server-side cursors, asynchronous notification and communication, COPY command support, etc. Install
3 min read
How to make a Python auto clicker?
In this article, we will see how to create an auto-clicker using Python. The code will take input from the keyboard when the user clicks on the start key and terminates auto clicker when the user clicks on exit key, the auto clicker starts clicking wherever the pointer is placed on the screen. We are going to use the pynput module here. What is Aut
6 min read
Auto Search StackOverflow for Errors in Code using Python
Ever faced great difficulty in copying the error you're stuck with, opening the browser, pasting it, and opening the right Stack Overflow Answer? Worry Not, Here's the solution! What we are going to do is to write a Python script, which automatically detects the error from code, search about it on Stack Overflow, and opens up the few tabs related t
3 min read
How to Build a Simple Auto-Login Bot with Python
In this article, we are going to see how to built a simple auto-login bot using python. In this present scenario, every website uses authentication and we have to log in by entering proper credentials. But sometimes it becomes very hectic to login again and again to a particular website. So, to come out of this problem lets, built our own auto logi
3 min read
PyQt5 – How to auto resize Label | adjustSize QLabel
During the designing of the GUI (Graphical User Interface) application there is a need to display plain text as information where label is used, but sometimes information text could be large or much smaller and it is difficult to use resize() method so have to auto adjust the size of the label according to the text, in order to do so adjustSize() m
2 min read
PyQt5 - Auto Adjusting Progress Bar size
In this article we will see how to adjust the size of progress bar. Adjusting size means setting the size of progress bar as much as it is needed, nor too big nor too small, just the size which can comprise all the text in it. In order to do this we will use adjustSize method. Note : Adjusting size will set the minimum required size. It doesn't dep
2 min read
PyQt5 QSpinBox - Checking if Auto Fill Background property is enabled or not
In this article we will see how we can see if the auto fill property of the spin box is enabled or not, this property will cause Qt to fill the background of the spin box before invoking the paint event. The color used is defined by the QPalette.Window color role from the spin box's palette. By default this property is false although we can change
2 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg