Question

In Python, I saw a class definition as the following:

from protorpc import messages

# Create the request string containing the user's name
class HelloRequest(messages.Message):
    my_name = messages.StringField(1, required=True)

What does messages.Message mean?

Was it helpful?

Solution

from protorpc import messages
class HelloRequest(messages.Message):

Is just another way of spelling:

from protorpc.messages import Message
class HelloRequest(Message):

Or even...

import protorpc
class HelloRequest(protorpc.messages.Message):

That is, HelloRequest derives from the Message class in the messages submodule of the protorpc package.

OTHER TIPS

Basically, HelloRequest comes from the a class named Message in the messages submodule of a specific group named protorpc. What your calling an argument is not an argument. It simply says that HelloRequest is using messages.Message as its start class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top