PEP 8 doesn’t explicitly list a naming convention for function parameters, but 
every example shows them as lowercase, even though the function doesn’t modify 
them.

See also the Python tutorial ( 
https://docs.python.org/3/tutorial/controlflow.html#defining-functions ), which 
also shows all parameters as lowercase.

I’d personally find it weird to see an all-cap parameter (Why are you 
yelling?). I expect ALL_CAPS to be hardcoded values.



From: Python-list <python-list-bounces+gweatherby=uchc....@python.org> on 
behalf of dn <pythonl...@danceswithmice.info>
Date: Friday, November 11, 2022 at 3:56 AM
To: 'Python' <python-list@python.org>
Subject: Argument name should be lowercase
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

PyCharm is warning against using an identifier of all upper-case letters
as a function's parameter, saying "Argument name should be lowercase".
(weak, code smell)


The application consists of three+ files:
- configuration
- mainline script
- module of workbook functions

The mainline reads the configuration parameters to set the application's
environment. All of the config/settings are constants. Some of them
appear as a dictionary (PRICES_WORKBOOK) defining a workbook's
(spreadsheet's) parameters, eg the filename, which work-sheet to use, etc.


The mainline calls the relevant functions from within the module,
as-needed:-

import prices_workbook as pw
...
product_prices = pw.build_product_prices_dictionary( PRICES_WORKBOOK )


The module's function definition is:

def build_product_prices_dictionary( WORKBOOK_DEFINITIONS:dict )->dict:
...
     price_array = xl.iget_array(
         file_name=WORKBOOK_DEFINITIONS[ "file_name" ],
         ...

(the function def is flagged, as above)


A quick scan of PEP-008 failed to yield anything relevant. Why is this
frowned upon as poor Python, or a matter of style?

Yes, a dict is mutable, but the upper-case denoting a constant indicates
that none of its values are to be changed by the programmer.

As far as the function is concerned, the dict and its contents are
constants.
(but the dict can't be treated as a global ENV[IRONMENT] object, because
it has to cross into the module's namespace)


Is passing the dict as an argument/parameter considered to be
incompatible with its designation as a constant?

Perhaps the style should be more enum-like, ie the dict's name in
lower-case, with the key-named in upper case, eg

     workbook_definitions[ "FILE_NAME" ]


Am not particularly concerned by the IDE raising this as a 'problem' -
will quite happily ignore and carry-on; but am curious as to the logic
behind the analysis - and why it doesn't come readily to mind.

Advice, comments, critique welcome!

--
Regards,
=dn
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!h56Cia7ERYDmxaCnEo0k9hfXz-mTJrz43UqHjbfhwLjutjhQE1QU975lUXTBf38la5kXAkBHdzyzOY4XAObbAPOa-ebC-HNY$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!h56Cia7ERYDmxaCnEo0k9hfXz-mTJrz43UqHjbfhwLjutjhQE1QU975lUXTBf38la5kXAkBHdzyzOY4XAObbAPOa-ebC-HNY$>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to