TypeError: input_Func() takes exactly 1 positional argument (2 given)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jory R Ferrell
    New Member
    • Jul 2011
    • 62

    TypeError: input_Func() takes exactly 1 positional argument (2 given)

    Code:
    neuron = Neuron(neuron1, random.uniform(1, 10), 3)
    
    my_Data = condition_Input(my_Data_1)
    
    output = neuron.input_Func(my_Data)
    I can't figure out why the sys keeps saying I have given
    two positional arguments in the method call to input_Func...
    I first start off with an list containing smaller lists.
    I sum all elements using condition_Input (which works, giving me the value I expect everytime) and then that summed value is assigned to the my_Data and passed as a single argument to the method call.

    What am I overlooking?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Try a print statement print my_data to be sure. You probably left out the self argument in the method definition. Look at this interaction:
    Code:
    >>> class A:
    ... 	def x(arg):
    ... 		print arg
    ... 		
    >>> z = A()
    >>> z.x("fff")
    Traceback (most recent call last):
      File "<interactive input>", line 1, in <module>
    TypeError: x() takes exactly 1 argument (2 given)
    >>> class B:
    ... 	def x(self, arg):
    ... 		print arg
    ... 		
    >>> y = B()
    >>> y.x("DDD")
    DDD
    >>>

    Comment

    • Jory R Ferrell
      New Member
      • Jul 2011
      • 62

      #3
      You called it! :P
      I've spent the last hour trying to figure out why a method call that had worked before (failed to save previous version and rewrote it)
      wasn't working now...
      Drove me up the wall.
      Thanks!

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        You're welcome. I've only made the same mistake a dozen or so times myself. :)

        Comment

        Working...