Python Forum
How to pass value from method to function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass value from method to function
#11
I really don't understand your confusion. Your previous post show that you understand how to pass argument to a function.
your function signature should look like this

def list_length(single_method_list)

so it's name must be list_length as that is the name expected by the test case. It takes one argument - single_method_list. It must be instance of SingleMethodList class defined in another module (single_method_list.py file). Note that you should stick to the name of the class as given to you because the test case will try to instantiate variable s_list of this class.
Reply
#12
So the problem I am having, and now i have followed what everyone is saying, is that it is passing None to the function, so after testing, I get on all but the empty list test in my test suite
Unbound error variable 'first' referenced before assignment 
Which implies to me that it is completely missing tie if statements which I don't understand. when i run my original code, it does what I expect, yet take it out of the function and pass it to the function, and it all falls apart.

Have I not converted everything to python3 correctly?

Ah, I have a break through, thank you all for your help, I changed the range x was working on to 0, and another test was passed, it now only fails on an empty list and single item list which is what I was expecting it to do, as I had not written the code to deal with that yet. Thank you very much for your help. I think I nearly get it now.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to pass encrypted pass to pyodbc script tester_V 0 852 Jul-27-2023, 12:40 AM
Last Post: tester_V
  i want to use type= as a function/method keyword argument Skaperen 9 1,838 Nov-06-2022, 04:28 AM
Last Post: Skaperen
Question How to pass a method as argument in an another method? anilanvesh 6 2,725 Sep-30-2021, 10:18 PM
Last Post: deanhystad
  Regex - Pass Flags as a function argument? muzikman 6 3,578 Sep-06-2021, 03:43 PM
Last Post: muzikman
  Possible to dynamically pass arguments to a function? grimm1111 2 2,169 Feb-21-2021, 05:57 AM
Last Post: deanhystad
  Building a method name in a function ffgth 9 3,190 Oct-19-2020, 01:21 PM
Last Post: buran
  Do I have to pass 85 variables to function? Milfredo 10 4,281 Sep-26-2020, 10:13 PM
Last Post: Milfredo
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,551 Sep-07-2020, 08:02 AM
Last Post: perfringo
  Pass integers to datetime.date function florian 3 2,714 Jul-18-2020, 04:43 AM
Last Post: scidam
  How to pass multiple arguments into function Mekala 4 2,446 Jul-11-2020, 07:03 AM
Last Post: Mekala

Forum Jump:

User Panel Messages

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