Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
when repr() fails
#7
(May-01-2017, 04:37 PM)snippsat Wrote: Your shell still has ascii as encoding.
You have posted different error about this before.
then i guess i didn't recognize them as the same

i did find the ascii() builtin function does what i wanted.  but ascii() does not exist in python2.  in python2 repr() does what i want, and in python3 repr() does not, while ascii() does. so i have to assume this be related, somehow, to the string concept changes between python2 and python3.  and, i guess i will have code that tests the python version (a module intended to work in both python2 and python3), maybe like this code that also removes the quotes:

foo = (repr(bar) if sys.version_info.major < 3 else ascii(bar))[1:-1]
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
when repr() fails - by Skaperen - May-01-2017, 02:25 AM
RE: when repr() fails - by wavic - May-01-2017, 07:29 AM
RE: when repr() fails - by Skaperen - May-01-2017, 09:34 AM
RE: when repr() fails - by volcano63 - May-01-2017, 07:30 AM
RE: when repr() fails - by Ofnuts - May-01-2017, 03:52 PM
RE: when repr() fails - by snippsat - May-01-2017, 04:37 PM
RE: when repr() fails - by Skaperen - May-02-2017, 03:54 AM
RE: when repr() fails - by snippsat - May-02-2017, 02:32 PM
RE: when repr() fails - by Skaperen - May-03-2017, 02:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Repr() function Valentina 3 3,515 Aug-22-2019, 11:28 AM
Last Post: perfringo
  ascii() (repr() in py2) Skaperen 1 4,001 Jun-05-2017, 10:32 PM
Last Post: Ofnuts
  str vs repr Skaperen 9 6,188 Jun-05-2017, 01:04 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020