Welcome to Admin Junkies, Guest — join our community!

Register or log in to explore all our content and services for free on Admin Junkies.

Python How to Make Variable Names

Jason

Royal member
Bronze Member
Joined
Nov 3, 2022
Messages
1,446
Website
drummerlesson.com
Credits
31
Variables are very important in any coding language and first of all, we need to know how to name them.

The following are ways to name them:

Code:
Forum_Name = "Admin Junkies"

_1st_Member = "The Forum Founder"

ForumName = "Admin Junkies"

seo = "search engine optimization"

Jerry = "A new member"

SMF = "Simple Machines Forum"

Some of you can probably see a pattern. In fact, variables can only start with a letter or underscore and can only contain letters, numbers, and underscores and everything from start to finish is case sensitive.

Anyway, one popular way to make variables involves putting an underscore between two words. What might be the most popular style for single word variables?
 
What might be the most popular style for single word variables?

Um, just the single word, lowercase? Most languages have the convention that if they're a single word, it's lowercase and if it's a constant it's uppercase.

(The rules beyond that for two or more words vary with language, most languages accept both under_score/snake_case and camelCase for variables, some languages also have rules around PascalCase, and usually a project will decide which it is following as it goes along.)
 
Um, just the single word, lowercase? Most languages have the convention that if they're a single word, it's lowercase and if it's a constant it's uppercase.

(The rules beyond that for two or more words vary with language, most languages accept both under_score/snake_case and camelCase for variables, some languages also have rules around PascalCase, and usually a project will decide which it is following as it goes along.)
Bro Code was saying underscores were most popular for two-word variables.
 
Depends on the language and about a million other things, not to mention the project you're working on.

The code I wrote today has a huge mixture of snake_case and camelCase because some of it is destined for a database where the column names are generally snake_case for consistency (as not all database systems are equal about this) and it has different behaviours in Laravel depending on snake_case or camelCase around object properties as a result where it does some magic from one to the other under the hood.
 
I know this topic is mostly Python-related, but I have always been pretty fond of camelCase in JavaScript.
 
If you look at method names and such in JS, camelCase is the clear preference for methods, which means some people will follow it because “that’s what the language does“ and some will reject it to make “variables visibly different from methods”.

It’s funny how it works out.
 

Log in or register to unlock full forum benefits!

Log in or register to unlock full forum benefits!

Register

Register on Admin Junkies completely free.

Register now
Log in

If you have an account, please log in

Log in
Activity
So far there's no one here

Users who are viewing this thread

Would You Rather #9

  • Start a forum in a popular but highly competitive niche

    Votes: 5 21.7%
  • Initiate a forum within a limited-known niche with zero competition

    Votes: 18 78.3%
Win this space by entering the Website of The Month Contest

Theme editor

Theme customizations

Graphic Backgrounds

Granite Backgrounds