Update message.py #28

Closed
Hunter2807 wants to merge 1 commits from patch-1 into master
Hunter2807 commented 2021-08-29 11:09:36 +00:00 (Migrated from github.com)

Now, when doing

for word in message:
    print(word)

it will print all the words of the message, which are separated by a space!

Summary

It is a PR so that the discord.Message can now be used in a for loop!

Checklist

  • [x ] If code changes were made then they have been tested.
    • [ x] I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • [x ] This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)
Now, when doing ```py for word in message: print(word) ``` it will print all the words of the message, which are separated by a space! ## Summary <!-- What is this pull request for? Does it fix any issues? --> It is a PR so that the discord.Message can now be used in a for loop! ## Checklist <!-- Put an x inside [ ] to check it, like so: [x] --> - [x ] If code changes were made then they have been tested. - [ x] I have updated the documentation to reflect the changes. - [ ] This PR fixes an issue. - [x ] This PR adds something new (e.g. new method or parameters). - [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed) - [ ] This PR is **not** a code change (e.g. documentation, README, ...)
Gnome-py commented 2021-08-29 11:11:19 +00:00 (Migrated from github.com)

This seems massively unnecessary. If anything this should be yield from self.content although that is a stretch. Disapprove

This seems massively unnecessary. If anything this should be `yield from self.content` although that is a stretch. Disapprove
Hunter2807 commented 2021-08-29 11:13:46 +00:00 (Migrated from github.com)

May I know why do u think it is unnecessary?

May I know why do u think it is unnecessary?
Hunter2807 commented 2021-08-29 11:15:04 +00:00 (Migrated from github.com)

Also, yield from self.content would return every letter separately, not every word

Also, `yield from self.content` would return every letter separately, not every word
Gnome-py commented 2021-08-29 11:16:11 +00:00 (Migrated from github.com)

Weird behaviour for a default, in my opinion, this should be chosen in user code via for word in str(message).split() or for word in message.content.split(), and yes, I know it would return every letter, that is what for char in string does so why not for char in message

Weird behaviour for a default, in my opinion, this should be chosen in user code via `for word in str(message).split()` or `for word in message.content.split()`, and yes, I know it would return every letter, that is what `for char in string` does so why not `for char in message`
Hunter2807 commented 2021-08-29 11:18:22 +00:00 (Migrated from github.com)

Yes, but I don't really think a user would need every letter of the content separately, but instead he would be needing every word. I don't really think there is a use to return every single letter of the word. Can I know any one good use case, where a person will be needing every single letter? I can tell u a few in which the user will be needing every word in the message content.

Yes, but I don't really think a user would need *every* letter of the content separately, but instead he would be needing every word. I don't really think there is a use to return every single letter of the word. Can I know any one good use case, where a person will be needing every single letter? I can tell u a few in which the user will be needing every word in the message content.
Gnome-py commented 2021-08-29 11:21:00 +00:00 (Migrated from github.com)

Neither should be added, this should be left as is, being an opt in (via str(message) or message.content).

Neither should be added, this should be left as is, being an opt in (via `str(message)` or `message.content`).
Hunter2807 commented 2021-08-29 11:22:48 +00:00 (Migrated from github.com)

Well, I don't really think there is any harm in adding this as a feature. If that is your argument, then why str(message) is there? message.content also speaks for itself, as to what it does.

Well, I don't really think there is any harm in adding this as a feature. If that is your argument, then why `str(message)` is there? `message.content` also speaks for itself, as to what it does.
AlexFlipnote commented 2021-08-29 11:39:53 +00:00 (Migrated from github.com)

Just do message.content.split(), don't need the library to do a simple string argument for you.

Just do `message.content.split()`, don't need the library to do a simple string argument for you.
iDutchy commented 2021-09-01 02:29:56 +00:00 (Migrated from github.com)

str(message) exists because this is an extra feature, changing how you iterate over a string is a python builtin which should speak for itself more.

str(message) exists because this is an extra feature, changing how you iterate over a string is a python builtin which should speak for itself more.

Pull request closed

Sign in to join this conversation.
No description provided.