Python Forum
function with 'self' input parameter errors out with and without 'self' called
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function with 'self' input parameter errors out with and without 'self' called
I think Yoriz's solution is good if your method uses event when an event argument is provided. I don't like so much as a way to make your function callable with zero or one arguments. I don't like the idea of twisting the function arguments to fit the vagaries of who may be calling it. If you wanted to make everyone happy you could do this:
def updateMainTasks(*_):
This allows for zero or more position arguments, all of which are unused. Such code is best avoided unless you really need it.
If you want to make everyone happy only use an event handler as an event handler with the correct parameters.
If you want the same functionality that happens in the event handler create a separate function that does what is required and call that function from the event handler function.
In my earlier example updateMainTasks(), with no arguments, is the function that does what you want done. The lambda expression creates the event handler function, with the correct arguments, that calls updateMainTasks().

Possibly Related Threads…
Thread Author Replies Views Last Post
  input function question barryjo 12 141 Today, 12:11 AM
Last Post: barryjo
  Problem with input after function luilong 10 928 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 749 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 498 Oct-06-2021, 09:39 AM
Last Post: menator01
  [SOLVED] Input parameter: Single file or glob? Winfried 0 447 Sep-10-2021, 11:54 AM
Last Post: Winfried
  Input function cutting off commands at spaces. throwaway34 3 861 May-12-2021, 06:40 AM
Last Post: throwaway34
  Defining a function with input abcd 5 1,294 Feb-21-2021, 02:34 AM
Last Post: NullAdmin
  What is this formatting called? Mark17 2 705 Dec-14-2020, 08:42 PM
Last Post: snippsat
  Function with array input Gerkamspiano 5 953 Dec-01-2020, 08:48 AM
Last Post: Gerkamspiano
  calling a function and argument in an input phillup7 3 1,135 Oct-25-2020, 02:12 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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