Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I am writing a program in python which contains many constant variables. I would like to create a file which will hold all these variables like .h file in C that contains many #define. I tried to use config parser however I didn't find it easy and fun to use.

Do you know a better way?

1 Answer

0 votes
by (106k points)

You can do something which is using a method:

def MY_CONSTANT(): 

return "Whatever"

Now, in theory, calling MY_CONSTANT() acts just like a constant.

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...