1

I have a function definition in a Python 2.x script which takes a tuple as one of its arguments, but 2to3 has no answers nor any of my searching on how to represent the same in Python 3.x

eg.

def blah(self, (string1, string2)):

Any help greatly appreciated

1 Answer 1

4

It's simple.

def blah(self, strings):
  string1, string2 = strings
  ...
Sign up to request clarification or add additional context in comments.

2 Comments

hmmm ... I am not sure that will work for me. I guess I should elaborate, I thought I could make it simple. I have code that defines the following: def blah(self, (string1, string2)): return blah2('help', (string1, string2)) and def blah2(self, name, string1=None): ... So if blah is only that 2 line def, how does your suggestion work in this context? (or am I missing the point) Sorry to not have elaborated the first time if this is now completely different scenario :(
The definition of blah changes to be def blah(self, strings): return blah2('help', *strings)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.