9

Has there been a change in the way lambda functions work between Python 2 and 3? I ran the code in python 2 and it works fine, but fails in Python 3 which I am trying to port my code into in order take advantage of a 3rd party module.

pos_io_tagged = map(lambda ((word, pos_tag), io_tag):
    (word, pos_tag, io_tag), zip(zip(words, pos_tags), io_tags))

I have researched multiple questions on Stackoverflow and read a couple of articles such as this but still can't find the answer. Is there any resources that I can view?

kmonsoor
  • 7,600
  • 7
  • 41
  • 55
plotplot
  • 293
  • 3
  • 11

1 Answers1

9

Your problem is that you are using parentheses () with your lambda expression, which will confuse it. Try the following:

pos_io_tagged = map(lambda word, pos_tag, io_tag:
    (word, pos_tag, io_tag), zip(zip(words, pos_tags), io_tags))

Look here for more information.

A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76