Default arguments with default values in Thrift Python client
python, thrift
Solution
It's not possible to define a thrift function with default value (well at least from my understanding after reading the thrift whitepaper)
What you can do, is to define a special parameter struct that let you omit some of the fields.
Example thrift code:
struct PostTweetParameter {
1: required Tweet tweet;
2: optional i32 x;
}
bool postTweet(1: PostTweetParameter param);
Then you can construct the `PostTweetParameter` with field `x` omitted.
Problem
I have Python client calls a Thrift service with some optional parameters like this: ``` bool postTweet(1: required Tweet tweet, 2: i32 x = 100); ``` If I tried to call this service from Python client without passing the optional parameter x, I get an exception: ``` TypeError: postTweet() takes exactly 2 arguments (1 given) ``` Any clues why I get this exception however it is optional parameter with a default value?