How to get the variable name itself in python

Use the python-varname library.

bash


pip install python-varname

python


from varname import nameof
var = 1
nameof(var)

output


var

Recommended Posts

How to get the variable name itself in python
How to get the files in the [Python] folder
How to get the number of digits in Python
How to get the Python version
Get the host name in Python
How to get the last (last) value in a list in Python
[Python] Get the variable name with str
How to get a stacktrace in python
How to check the memory size of a variable in Python
How to use the C library in Python
How to embed a variable in a python string
How to get the date and time difference in seconds with python
How to develop in Python
How to retrieve the nth largest value in Python
How to know the current directory in Python in Blender
How to use the model learned in Lobe in Python
[Python] How to output the list values in order
python I don't know how to get the printer name that I usually use.
How to get the notebook name you are currently using in Google Colab
I want to get the file name, line number, and function name in Python 3.4
How to get a list of files in the same directory with python
[Python] How to do PCA in Python
How to collect images in Python
Get the desktop path in Python
How to use SQLite in Python
Get the script path in Python
In the python command python points to python3.8
How to get started with Python
[Python] How to import the library
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
Get the desktop path in Python
How to handle Japanese in Python
[python] How to check if the Key exists in the dictionary
How to debug the Python standard library in Visual Studio
How to use the __call__ method in a Python class
I tried "How to get a method decorated in Python"
How to get all the keys and values in the dictionary
How to get a list of built-in exceptions in python
How to get into the python development environment with Vagrant
[Shell] How to get the remote default branch in Git
[Introduction to Python] How to get data with the listdir function
[Introduction to Python] How to use class in Python?
How to get and set the NTP server name by DHCP
[sh] How to store the command execution result in a variable
How to determine the existence of a selenium element in Python
How to access environment variables in Python
How to know the internal structure of an object in Python
How to dynamically define variables in Python
python / pandas / dataframe / How to get the simplest row / column / index / column
How to do R chartr () in Python
How to get all the possible values in a regular expression
python notes: Modularization: __name__ == How to use'__main__'
[Itertools.permutations] How to put permutations in Python
The 15th offline real-time how to write reference problem in Python
How to get followers and followers from python using the Mastodon API
The 17th Offline Real-time How to Solve Writing Problems in Python
[Python] How to get the first and last days of the month
How to judge that the cross key is input in Python3