[New Code Suggestion] Follow PEP standards for method & variable names #82
Replies: 4 comments
-
This is good advice I will adopt going forward as I refactor code.
From: Jonathan Pezzino ***@***.***>
Sent: Monday, December 18, 2023 11:49 AM
To: NREL/GEOPHIRES-X ***@***.***>
Cc: Malcolm Ross ***@***.***>; Assign ***@***.***>
Subject: [NREL/GEOPHIRES-X] [New Code Suggestion] Follow PEP standards for method & variable names (Issue #81)
PEP prescribes snake_case for function/variable names rather than CamelCase. Example in, https://github.com/NREL/GEOPHIRES-X/blob/a18cd171ffeef01de93ccb46c96a00673ac582d3/src/geophires_x/WellBores.py#L242 InjPressureDropsAndPumpingPowerUsingImpedenceModel should be named inj_pressure_drops_and_pumping_power_using_impedence_model
—
Reply to this email directly, view it on GitHub <#81> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWGVYT4R57COYCUEKIRBB6LYKB6W5AVCNFSM6AAAAABAZ44H32VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2DOMJVGEZDEOA> .
You are receiving this because you were assigned. <https://github.com/notifications/beacon/AWGVYT4ZQMP3FULKTHHGSE3YKB6W5A5CNFSM6AAAAABAZ44H32WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHHUBIMPQ.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
Note:
|
Beta Was this translation helpful? Give feedback.
-
Another tip - when renaming/refactoring variables in PyCharm, select the name, right click, and select Refactor -> Rename. This will ensure that any references to the name in other files are also renamed, saving work and preventing breakage. (Once you are familiar with this functionality, strongly recommend defining a convenient keyboard shortcut and using that instead of clicking for the sake of efficiency.) |
Beta Was this translation helpful? Give feedback.
-
Yep, I found and used that tool a great deal during my last effort to objective SurfacePlants – sometimes, the tool will even suggest the PEP standard name for you.
The PEP standard is a bit confusing – methods and variables get snake case (the_is_the_variable_name) while other things, like classes, get camel case (ClassName not class_name). It took me a while to figure that out, but I think the code in the HIP-RAX branch now follows those rules for the code that I had to touch. I didn’t change many other classes.
From: Jonathan Pezzino ***@***.***>
Sent: Tuesday, January 16, 2024 12:21 PM
To: NREL/GEOPHIRES-X ***@***.***>
Cc: Malcolm Ross ***@***.***>; Assign ***@***.***>
Subject: Re: [NREL/GEOPHIRES-X] [New Code Suggestion] Follow PEP standards for method & variable names (Discussion #82)
Another tip - when renaming/refactoring variables in PyCharm, select the name, right click, and select Refactor -> Rename. This will ensure that any references to the name in other files are also renamed, saving work and preventing breakage.
Screenshot.2024-01-16.at.10.19.02.png (view on web) <https://github.com/NREL/GEOPHIRES-X/assets/4056124/996537d6-0928-44b2-8599-745a81da64df>
(Once you are familiar with this functionality, strongly recommend defining a convenient keyboard shortcut and using that instead of clicking for the sake of efficiency.)
—
Reply to this email directly, view it on GitHub <#82 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AWGVYT25DYVCBY6OUYZHO5LYO3AIVAVCNFSM6AAAAABB5IH6Z6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCNBXHAZTS> .
You are receiving this because you were assigned. <https://github.com/notifications/beacon/AWGVYT6PM23YEUF2DUQP25DYO3AIVA5CNFSM6AAAAABB5IH6Z6WGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAPRJX6.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
PEP prescribes
snake_case
for function/variable names rather thanCamelCase
. Example in,GEOPHIRES-X/src/geophires_x/WellBores.py
Line 242 in a18cd17
should be:
Beta Was this translation helpful? Give feedback.
All reactions