unusual string notation #16965
Replies: 5 comments 5 replies
-
The problem is that the >>> a=[\'Traceback (most recent call last):\',]
Traceback (most recent call last):
File "<stdin>", line 1
SyntaxError: invalid syntax with >>> a=['Traceback (most recent call last):',]
>>> Strings should be delimited with |
Beta Was this translation helpful? Give feedback.
-
I don't Marcus, but I do remove the single & double inverted commas as part
of the verbiage pruning & making it a savable text file, so maybe that is
forcing in the back slashes? Wish I could figure out why it only happens
sometimes!
…On Fri, 21 Mar 2025, 10:07 pm Marcus Mendenhall, ***@***.***> wrote:
By any chance, are you calling __str__ or __repr__ on your traceback
(indirectly, via str(traceback) or repr(traceback) , which would result
in the whole thing being wrapped as a string, requiring internal escaping
of the delimiters?
—
Reply to this email directly, view it on GitHub
<#16965 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBCWGIFNPNQKKSMACWH6L32VPXGFAVCNFSM6AAAAABZMSDZE6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENJXGYYDANY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
The list I posted at the start of this thread is the sys.print_exception(e)
style output my parser routine was working on when it crashed. My best
guess is it crashed because of all the dodgy backslashes. There is
something ouroborosy about an exception in an exception handler, I better
do a search to make sure there is no repr() in there.
…On Fri, 21 Mar 2025, 10:39 pm Marcus Mendenhall, ***@***.***> wrote:
Can you post the original, complete traceback by just letting the error
happen without catching it? Maybe some internal module is fiddling with the
text. If so, we can see what module might be causing this.
—
Reply to this email directly, view it on GitHub
<#16965 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBCWGPLEQRDEDTPSBDXD532VP273AVCNFSM6AAAAABZMSDZE6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENJXGYZTCOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I wish I had more dexterity as a snake charmer Marcus, upython frequently
bites me. Also I think ouroborosy is an adverb.
…On Fri, 21 Mar 2025, 11:38 pm Marcus Mendenhall, ***@***.***> wrote:
that post wins the linguistics award for turning ouroboros into an
adjective!
—
Reply to this email directly, view it on GitHub
<#16965 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBCWGLSKV4HBX7RVCH44JT2VQB2VAVCNFSM6AAAAABZMSDZE6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENJXGY4TQOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
If you put the escape character If you want to create this
If you're working with the REPL and enter a name of an object, the representation is shown. test = "Hello World" Now just put the name into the repl: test You'll see the representation of the object If you have an object like a list or tuple, the elements are also shown in their representation, even if you print the whole object: test = "Hello World"
my_list = [test, test, test]
print(my_list) # here with added quotes from representation
print(my_list[0]) # print the first object from my_list. It's not the representation. You should see this:
The first is the complete list, where all elements are printed in their representation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a little routine that attempts to strip the 'Traceback (most recent call last):' & other verbage from an except Exception as e: report and store just the line nos cascade & error in a file. To my great consternation this routine occasionally crashes when trying to cleanup some reports.
Today's offender has some sort of backslash apostrophe notation I'm unfamiliar with. Indeed if I try to set a variable equal to the list on the cmd line, with a view to trying the routine 1 line at a time to see where it crashes, I get an error straight up
Anybody know what's the deal with this notation & why it only appears occasionally in except Exception as e reports?
Beta Was this translation helpful? Give feedback.
All reactions