Python Forum
Passing variable to another function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing variable to another function
#8
Hopefully you guys can see this image. Apoligies about the massive watermark...I need an new cloud I think...
Anyways sorry Michael.
I was very hopeful that this was going to work.
Object oriented programming, sounds good, though perhaps a bit complicated for a big n00been00b like me but I thought well I'll just have to roll with it.
Unfortunately my first experience hasn't been great :(

Now what I did was to rename Database.txt to Database1.txt
Then I copied that file as Database2.txt

When I run the script, as you see, its giving: -

Quote:
Traceback (most recent call last):
File "/home/pi/Desktop/Pyread.py", line 47, in <module>
dat1 = Data_file("Database1.txt")
NameError: name 'Data_file' is not defined


And I definitely don't have the skills to troubleshoot this. Though I did try to replace Database1.txt with the full path name instead. Same error

I discovered debuggers in my attempt to solve this... when I run the debugger in Thorny, it seems to me that the class exists.
When the debugger gets to that line it shows
Quote:Name_________________Value
Data_File _____________<class'__main__.Data_File'>

[Image: rpi.jpg]
Reply


Messages In This Thread
RE: Passing variable to another function - by JonnyDriller - Feb-04-2020, 09:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable for the value element in the index function?? Learner1 8 919 Jan-20-2024, 09:20 PM
Last Post: Learner1
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 750 Nov-23-2023, 02:53 PM
Last Post: rob101
  Printing the variable from defined function jws 7 1,644 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  Function parameter not writing to variable Karp 5 1,171 Aug-07-2023, 05:58 PM
Last Post: Karp
  passing dictionary to the function mark588 2 1,101 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  Retrieve variable from function labgoggles 2 1,147 Jul-01-2022, 07:23 PM
Last Post: labgoggles
  Cant transfer a variable onto another function KEIKAS 5 2,048 Feb-09-2022, 10:17 PM
Last Post: deanhystad
  passing php variable to python file jerald 1 2,860 Jul-07-2021, 11:46 AM
Last Post: Larz60+
  Passing flags to python script, through a function xbit 4 4,187 Apr-20-2021, 06:32 AM
Last Post: ndc85430
  Please explain uncommon way of declaring and using variable [function.variable] esphi 4 2,516 Nov-07-2020, 08:59 AM
Last Post: buran

Forum Jump:

User Panel Messages

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