Python Forum
Passing argument from top-level function to embedded function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing argument from top-level function to embedded function
#3
So what is the code supposed to be?

In this example eval_value() is hidden inside Check()
def Check(file_name, mh_criticalval):
    test_file=file_name
 
    def eval_value(excel_sht, excel_col, mh_value):
       if excel_sht.cell(row=i, column=excel_col)>mh_value:
            cell_b=excel_sht.cell(row=i, column=excel_col).value='OK'
 
    eval_value(sht, 9, mh_criticalval)

Check('test.xlsm',1)
In this example Check() and eval_value() are both visible to the module and Check() uses eval_value().
def Check(file_name, mh_criticalval):
    test_file=file_name
    eval_value(sht, 9, mh_criticalval)
 
def eval_value(excel_sht, excel_col, mh_value):
   if excel_sht.cell(row=i, column=excel_col)>mh_value:
        cell_b=excel_sht.cell(row=i, column=excel_col).value='OK'
 
Check('test.xlsm',1)
In this example Check() and eval_value() are both visible to the module and are called separately.
def Check(file_name, mh_criticalval):
    test_file=file_name
 
def eval_value(excel_sht, excel_col, mh_value):
   if excel_sht.cell(row=i, column=excel_col)>mh_value:
        cell_b=excel_sht.cell(row=i, column=excel_col).value='OK'
 
eval_value(sht, 9, mh_criticalval)
Check('test.xlsm',1)
I'm pretty sure this last one is not what you want as it makes no sense. But none of the examples make much sense to me because I see no reason why file_name is passed to Check() and then isn't used for anything. What is the purpose of Check()? Did you cut out some code that opens a file and reads in a spreadsheet? If that is the case you will want to use the first example.
Reply


Messages In This Thread
RE: Passing argument from top-level function to embedded function - by deanhystad - Oct-15-2020, 03:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  The function of double underscore back and front in a class function name? Pedroski55 9 644 Feb-19-2024, 03:51 PM
Last Post: deanhystad
  mutable argument in function definition akbarza 1 471 Dec-15-2023, 02:00 PM
Last Post: deanhystad
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,074 Dec-25-2022, 03:00 PM
Last Post: askfriends
  passing dictionary to the function mark588 2 965 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  i want to use type= as a function/method keyword argument Skaperen 9 1,838 Nov-06-2022, 04:28 AM
Last Post: Skaperen
  Taking any 2d image and passing it to create a level iki_a_toure 4 1,015 Oct-19-2022, 06:35 AM
Last Post: iki_a_toure
  Exit function from nested function based on user input Turtle 5 2,896 Oct-10-2021, 12:55 AM
Last Post: Turtle
  Passing Argument Errors cosmarchy 6 2,430 Sep-29-2021, 06:09 AM
Last Post: snippsat
  Regex - Pass Flags as a function argument? muzikman 6 3,580 Sep-06-2021, 03:43 PM
Last Post: muzikman
Question Stopping a parent function from a nested function? wallgraffiti 1 3,669 May-02-2021, 12:21 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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