snake_case combines words by replacing each space with an underscore (_). In the all caps version, all letters are capitalized.
Questions tagged [snakecasing]
41 questions
1049
votes
15 answers
What is the naming convention in Python for variables and functions?
Coming from a C# background the naming convention for variables and methods are usually either camelCase or PascalCase:
// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod()
In Python, I have seen the above but I have also seen…

Ray
- 187,153
- 97
- 222
- 204
605
votes
7 answers
JSON Naming Convention (snake_case, camelCase or PascalCase)
Is there a standard on JSON naming?I see most examples using all lower case separated by underscore, aka snake_case, but can it be used PascalCase or camelCase as well?

GeorgeU
- 7,819
- 8
- 26
- 38
144
votes
35 answers
How to convert PascalCase to snake_case?
If I had:
$string = "PascalCase";
I need
"pascal_case"
Does PHP offer a function for this purpose?

openfrog
- 40,201
- 65
- 225
- 373
25
votes
7 answers
How can I convert a camel case string to snake case and back in idiomatic Kotlin?
Looking for code that will do conversions like this:
"MyCamelCaseA" to "my_camel_case_a"
"AMultiWordString" to "a_multi_word_string"
"my_camel_case_a" to "myCamelCaseA" or "MyCamelCaseA"
"a_multi_word_string" to "aMultiWordString" or…

TER
- 1,313
- 2
- 12
- 14
16
votes
2 answers
What's the correct way to treat numbers in snake case?
If I want to write a phrase like "Column 1" in snake case (the usual C way of formatting identifiers that looks like some_function), do I insert underscore between a word or a number, like column_1, or not, like column1?
That may be a painfully…

Max Yankov
- 12,551
- 12
- 67
- 135
13
votes
4 answers
Using preg_replace() to convert alphanumeric strings from camelCase to snake_case
I have a method now that will convert my camel case strings to snake case, but it's broken into three calls of preg_replace():
public function camelToUnderscore($string, $us = "-")
{
// insert hyphen between any letter and the beginning of a…

Matt
- 6,993
- 4
- 29
- 50
8
votes
1 answer
Why are some Django methods PascalCase and others snake_case?
As far as I know, the convention is to use snake_case for method names, so why are some methods in Django PascalCase, e.g. Django's TestCase Class?

as8
- 93
- 4
7
votes
1 answer
Python + Flask REST API, how to convert data keys between camelcase and snakecase?
I am learning Python, and coding simple REST API using Flask micro-framework.
I am using SQLAlchemy for Object-relational-mapping and Marshmallow for Object-serialization/deserialization.
I am using snakecase for my variable names(according to…

Yoh0xFF
- 1,450
- 2
- 18
- 31
6
votes
2 answers
Change all keys in an array from snake_case to PascalCase
I want to replace all index keys in a array but I need to do it only with a function like array_map() (not with a foreach) and that's why it's a little hard for me.
Actual array:
$array = [
'mc_gross' => 10.17,
'protection_eligibility' =>…

ZoRo
- 85
- 2
- 6
3
votes
1 answer
Pydantic model parse pascal case fields to snake case
I have a Pydantic class model that represents a foreign API that looks like this:
class Position(BaseModel):
AccountID: str
AveragePrice: str
AssetType: str
Last: str
Bid: str
Ask: str
ConversionRate: str
…

Roy
- 398
- 2
- 12
2
votes
1 answer
How to compose snake case binding tag with go-playground/validator?
As title, since I'm a newbie to golang, I'm a little bit confused of the binding tag for some custom format.
For example,
there's a struct with a few of fields like this
type user struct {
name `json:"name" binding:"required"`
hobby…

ntutm0922
- 23
- 4
2
votes
1 answer
pylint3 Variable name "fl" doesn't conform to snake_case naming style (invalid-name)
According to this pylint-wiki, it seems that 2 letter variable names are ok:
Variable variable-rgx [a-z_][a-z0-9_]{2,30}$
But for some reason I get the following error:
Variable name "fl" doesn't conform to snake_case naming style…

OrenIshShalom
- 5,974
- 9
- 37
- 87
1
vote
0 answers
Use linker script to convert identifier from CamelCase to snake_case?
i am working on a C project using a snake_case syntax for naming my functions.
However, a lib i need to uses CamelCase for all of its function names.
To avoid doing a long header full of static inline definitions, i wonder if i could be possible
to…

Edhyjox
- 11
- 1
1
vote
1 answer
how to find out what case style a string is (pascal, snake, kebab, camel)
I want to write a program that outputs whether a string is styled in pascal case, camel case, snake case, kebab case, or none of them.
in the first line, we should take integer n from input. then, in the next n lines, we should take an integer k and…

Fateme
- 41
- 4
1
vote
1 answer
Regex expression for matching snake case
I'm trying to build a Regex expression for matching just snake case strings. I'm not really good at Regex. What I've built is:
([a-zA-Z]+)_([a-zA-Z]+)
But this isn't quite good because it doesn't match all the cases. I want to be able to add more…

Cătălin Avasiloaie
- 135
- 1
- 12