Parsee
Parsee

Reputation: 71

Is using a method and binding it's return value to a variable acceptable practice?

For example, if I want to send a message:

message_sender = MessageSender()

sent_message = message_sender.Send("test")

Is it fine if i make that Send method return some data, for example the time at which the message was sent, and bind it to a variable so Ì can use that data later, or is this just confusing design?

If this is not acceptable, how should I do it? To clarify, I send a message using that code, and bind some data regarding that message to the sent_message variable.

Upvotes: 0

Views: 51

Answers (1)

John Zwinck
John Zwinck

Reputation: 249582

There's absolutely nothing wrong with what you're doing. Python's own socket.send() method returns the number of bytes written, for example: https://docs.python.org/2/library/socket.html#socket.socket.send

Upvotes: 1

Related Questions