Python Forum
Python Naming Error: List not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Naming Error: List not defined
#1
I have begun working on a new function, I will keep things simple by not detailing the full scope of the function, which would be uneeded information for this question.

I created a function which was to simply place a list object inside of another list object. The problem I am having is that even though the list object appears in the parent list, when I try to call it by name, python tells me the list is not defined.

def date(D):
    """This function takes a list(date), and indexes it in another 
    list('List_Of_Dates')."""
    List_Of_Dates.append(D)
    D=[]

>>>date("March_13_2018")
>>>List_Of_Dates
[[]]
>>>March_13_2018
[error][/error]***NAME ERROR***: March_13_2018 is not defined.
From the output of the python interpreter, I can tell that my function is actually creating a list and appending it to List_Of_Dates. The problem seems to be that my name assignment "March_13_2018" is not being attached to the list object, what I get is a "nameless, or undefined" list.

How do I map the name of the list that I pass through my function, so that the list that's created has that name?
Reply
#2
(Mar-13-2018, 07:37 PM)Intelligent_Agent0 Wrote: so that the list that's created has that name?
Why would you care what the function's internal variable name is?
While it's possible, that's a very wacky thing to do, like putting square tires on your car.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 512 Nov-23-2023, 02:53 PM
Last Post: rob101
  naming entities(city abbreviations) tirumalaramakrishna 1 1,198 May-06-2022, 11:22 AM
Last Post: jefsummers
  [variable] is not defined error arises despite variable being defined TheTypicalDoge 4 2,042 Apr-05-2022, 04:55 AM
Last Post: deanhystad
  Error 'Contour' not Defined DaveG 3 2,283 Mar-13-2022, 03:29 AM
Last Post: deanhystad
  Getting "name 'get_weather' is not defined error and no json_data returned? trthskr4 6 3,528 Sep-14-2021, 09:55 AM
Last Post: trthskr4
  Python Error List Index Out of Range abhi1vaishnav 3 2,237 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  Python Style and Naming Variables rsherry8 3 2,170 Jun-07-2021, 09:30 PM
Last Post: deanhystad
  Error when refering to class defined in 'main' in an imported module HeRo 2 2,331 Apr-13-2021, 07:22 PM
Last Post: HeRo
  Naming the file as time and date. BettyTurnips 3 2,887 Jan-15-2021, 07:52 AM
Last Post: BettyTurnips
  Why does lambda throw 'name value_o is not defined' error? karabakh 3 2,123 Dec-14-2020, 05:45 PM
Last Post: karabakh

Forum Jump:

User Panel Messages

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