Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print("users' IDs: {}".format(user.uid for user in users)) fails. #332

Closed
olemr opened this issue Sep 8, 2018 · 1 comment
Closed

print("users' IDs: {}".format(user.uid for user in users)) fails. #332

olemr opened this issue Sep 8, 2018 · 1 comment

Comments

@olemr
Copy link

olemr commented Sep 8, 2018

Following the example in order to retrieve a uid other than your own, this command fails:

>>> print("users' IDs: {}".format(user.uid for user in users))
users' IDs: <generator object <genexpr> at 0x7f976aa8afa0>

I suspect this is because user names in my chat list contains national characters.
Trying just:

>>> print (users)
[<USERs listed up til ... >, 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 13: ordinal not in range(128)

Running:

>>>import sys
>>>reload(sys)
>>>sys.setdefaultencoding('utf8')
>>> print (users)

luckily listed the user I wanted, and then hung my terminal window.

This command still don't work:

>>> print("users' IDs: {}".format(user.uid for user in users))
users' IDs: <generator object <genexpr> at 0x7f976aa8afa0>
madsmtm added a commit that referenced this issue Sep 9, 2018
The examples were using generator expressions instead of list comprehensions
@madsmtm
Copy link
Member

madsmtm commented Sep 9, 2018

This is really two issues:
The example is written wrongly, it prints <generator...> because we use a generator expression, not a list comprehension. The correct code is fixed in 08117e7:

print("users' IDs: {}".format([user.uid for user in users]))

The encoding errors are a duplicate of #302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants