Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (1.6k points)

What is the preferred way to name a function in Python?

Should I use the camel case?

Ex-

def functionName(); 

Or, Should I use underscores?

Ex-

def function_name();

1 Answer

0 votes
by (25.1k points)

PEP8 is Pythons official style guide and it recommends :

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

Although it won't make any actual difference in the performance of the code but it is generally recommended that you pick one style guide and stick to it

Related questions

+1 vote
1 answer
0 votes
1 answer
0 votes
1 answer
+2 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...