-
Notifications
You must be signed in to change notification settings - Fork 76
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
Unable to run with python3 #39
Comments
There was one python 3 version which dislike foo = u"bar" works for you? If not, you can either remove all |
Edit: Just remove the "text"
#instead of:
u"text" Another option, compatible with all Python versions is to import the function pytg use to convert all strings to the right format: from pytg.encoding import to_unicode as u This will get any kind of string (byte-encoded or already unicode) correctly to utf-8 unicode (of the according native type Then do foo = u("bar") (wrap the string with |
You are correct. In my Python 3.2.3 interactive terminal, For the benefit of others, may I suggest that your Github README.md be updated to read "Works with Python 2.7 and 3.3" instead of "Works with Python 2.7 and 3"? I tried your second suggestion in an interactive terminal. But even the line
I'm not an avid Python programmer, so it sounds like I'm better off sticking with Python 2.7 for now, on the Raspberry Pi. |
# now just change the
u"stuff" #python 2 (and python 3.3+)
# to
"stuff" # python 3.0+
# or, after importing
from pytg.encoding import to_unicode as u
# to
u("stuff") # all pythons But I'll add that. Actually only the examples are not python 3.0-3.3 compatible, pytg itself is. |
I don't understand. The syntax error is not happening in my script or even the Now, assuming you meant modifying lines 33 and 34 in your encoding.py (replacing b'' with '' and replacing u"" with ""), this at least allows |
Ohh. |
Yes, that seems to do the trick. It's a workaround, at least. I removed lines 33-34 in
That solves the original error. But I just get the same error for DictObject instead. So I also removed lines 30-31 in
Now, everything works in the script that I built to use pytg. For your ping example to work, though, I must edit examples/ping.py and replace all uses of Thanks for your help! This is the first time I've ever worked with Unicode in Python, so I wasn't sure at first what I was even looking at or why the syntax errors were occurring. Now, to continue my Raspberry Pi project... :) |
Your welcome. I will update pytg as well as DictObject (and several other projects where I use that file) to reflect that. |
…g"```) at luckydonald/pytg#39 (hopefully!)
…luckydonald-utils```) . The file is almost the same, but changed to fix issue #39.
It should now be fixed. |
I am trying to use pytg with Python v3.2.3 on a Raspberry Pi (latest model, latest Raspbian), but I'm getting multiple
SyntaxError: invalid syntax
. Am I missing something really obvious? If your project is compatible with python3, then why is it complaining about python2.7-style lines of code?The telegram-cli is installed and works great, just typing commands via its command line. For using it with pytg, I am running it as specified in your documentation:
bin/telegram-cli --json -P 4458
What works:
python setup.py install
works finepython pytg/examples/ping.py
works great (Python 2.7.3)What does not:
python3 setup.py install
showspython3 pytg/examples/ping.py
showsThe text was updated successfully, but these errors were encountered: