Jump to content


Photo

Chapter 4 P129: "unexpected Keyword Argument"


  • Please log in to reply
5 replies to this topic

#1 Xopher_Hatton

Xopher_Hatton

    New Member

  • Members
  • Pip
  • 4 posts

Posted 19 April 2012 - 02:00 PM

I think I did everything the way I was supposed to, rebuilt the module after changing print_lol and everything. But when I run the sketch program, I get this error:

Traceback (most recent call last):
File "C:\Python32\sketch.py", line 26, in <module>
print_lol(man, fh=man_file)
TypeError: print_lol() got an unexpected keyword argument 'fh'

It seems to be using my old version of print_lol that didn't have that argument. What stupidity have I committed?

#2 Xopher_Hatton

Xopher_Hatton

    New Member

  • Members
  • Pip
  • 4 posts

Posted 19 April 2012 - 02:23 PM

Just deleted old builds and rebuild it again. Same result. I know I'm doing something stupid, I just don't know what.

#3 Xopher_Hatton

Xopher_Hatton

    New Member

  • Members
  • Pip
  • 4 posts

Posted 19 April 2012 - 05:33 PM

OK, now I put in all the keywords, and now I get this:

Traceback (most recent call last):
File "C:\Python32\sketch.py", line 25, in <module>
print_lol(man, indent=True, level=0, fh=man_file)
TypeError: print_lol() got an unexpected keyword argument 'indent'

The function is defined with this heading, just as in the book:

def print_lol(the_list, indent=False, level=0, fh=sys.stdout):

So, stupid as what I did before was, this should take one positional and three keyword arguments, right?

#4 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 20 April 2012 - 12:34 PM

Can you post your code so we can take a look? Be sure to use the code tags (click on the <> button) to enclose your code and have it formatted correctly.

Thanks.

--Paul.

#5 Xopher_Hatton

Xopher_Hatton

    New Member

  • Members
  • Pip
  • 4 posts

Posted 22 April 2012 - 01:40 PM

There was actually nothing wrong with the code. It was that I hadn't properly installed the new version of my function, and it was still using the old version.

So yeah, it was me doing something stupid. Fixed now.

Thanks for your offers of help, folks!

#6 Aaron_Stone

Aaron_Stone

    New Member

  • Members
  • Pip
  • 2 posts

Posted 18 June 2015 - 08:39 PM

I am having the same problem. Can u help me out please




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users