Reputation: 21
The service that I'm using has a from message type.
message EmailMessage {
EmailRecipient from = 1;
repeated EmailRecipient to = 1;
....
}
Here is the code snippet of how I'm creating a request for this service in my client.
email_message = eaas_pb2.EmailMessage(
from=email_recipient_from,
to=email_recipient_to,
subject=subject,
purpose=purpose,
plain_text_body=plain_text_body)
I run into a SyntaxError when using this because from is a Python keyword. So this exact problem has been documented for protobuf here. Is there a solution for this which doesn't involve changing the message declaration? gPRC docs don't mention anything about this.
Upvotes: 1
Views: 394
Reputation: 21
Using a kwargs dictionary solved it for me.
**{
'from': email_recipient_from,
'to': [email_recipient_to],
'cc': [],
'bcc': [],
'subject': subject,
'purpose': purpose,
'plain_text_body': plain_text_body,
}
Upvotes: 1