Python Forum
Python Style and Naming Variables
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Style and Naming Variables
#1
Please consider the following Python code:
def my_sum(array):
    ret = 0
    for i in range(len(array)):
        ret += array[i]
    return ret

array = [ 1,2,3,4]
print( "sum is " + str(my_sum(array)) )
In this case, the code analyzer from Spyder generates a warning because the name of the parameter and the name of
the global variable are the same. I do not see anything wrong with this. Is there something I am missing?
Reply


Messages In This Thread
Python Style and Naming Variables - by rsherry8 - Jun-07-2021, 09:00 PM
RE: Python Style and Naming Variables - by Yoriz - Jun-07-2021, 09:11 PM
RE: Python Style and Naming Variables - by snippsat - Jun-07-2021, 09:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  naming entities(city abbreviations) tirumalaramakrishna 1 1,248 May-06-2022, 11:22 AM
Last Post: jefsummers
  Naming the file as time and date. BettyTurnips 3 2,984 Jan-15-2021, 07:52 AM
Last Post: BettyTurnips
  naming conventions mvolkmann 4 2,160 Sep-28-2020, 05:51 PM
Last Post: Gribouillis
  Question about naming variables in class methods sShadowSerpent 1 2,015 Mar-25-2020, 04:51 PM
Last Post: ndc85430
  Dyanmically Naming Files ovidius 3 2,535 Jan-29-2020, 02:44 PM
Last Post: buran
  naming images adding to number within multiple functions Bmart6969 0 1,927 Oct-09-2019, 10:11 PM
Last Post: Bmart6969
  Sub: Python-3: Better Avoid Naming A Variable As list ? adt 9 4,031 Aug-29-2019, 08:15 AM
Last Post: adt
  Naming convention advice Alfalfa 5 3,342 Jul-21-2018, 11:47 AM
Last Post: Larz60+
  Python Naming Error: List not defined Intelligent_Agent0 1 14,310 Mar-13-2018, 08:34 PM
Last Post: nilamo
  Coding style questions -- variables Luke_Drillbrain 12 9,134 Apr-30-2017, 01:21 AM
Last Post: Luke_Drillbrain

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020