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
#11
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.
Reply
#12
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.
Reply
#13
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().
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,033 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  Multiple variable inputs when only one is called for ChrisDall 2 491 Oct-20-2023, 07:43 PM
Last Post: deanhystad
  determine parameter type in definition function akbarza 1 587 Aug-24-2023, 01:46 PM
Last Post: deanhystad
  Function parameter not writing to variable Karp 5 947 Aug-07-2023, 05:58 PM
Last Post: Karp
  Couldn't install a go-game called dlgo Nomamesse 14 3,121 Jan-05-2023, 06:38 PM
Last Post: Nomamesse
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 11,038 Dec-26-2022, 08:48 AM
Last Post: ibreeden
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,091 Dec-25-2022, 03:00 PM
Last Post: askfriends
  how can a function find the name by which it is called? Skaperen 18 3,477 Aug-24-2022, 04:52 PM
Last Post: Skaperen
  Showing an empty chart, then input data via function kgall89 0 979 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 2,719 Jan-18-2022, 12:11 AM
Last Post: barryjo

Forum Jump:

User Panel Messages

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