« first day (3023 days earlier)      last day (2149 days later) » 

21:01
How isn't it? They have the same effect.
@Kevin I kind of agree. But I can't think of a good alternative syntax for += that would be less confusing.
I'm confused.
wim
wim
aye, a += b is one of the most confusing ones
Hey, @wim Happy Australia Day!
wim
wim
cheers m8
21:03
@wim They have the exact same effect, and I always use +=, so I do not understand what the difference is.
@malan I suspect Kevin's whipping up a quick MCVE to illustrate...
wim
wim
I can say it took me years to really understand +=
@malan They don't always havs the exact same effect.
Also, @Kevin, Duff's device may look evil, but it helped them do serious graphic computations back when computers couldn't handle the traditional way of writing it.
wim
wim
this going in is probably what finally made it click
21:07
The added test? Reading.
wim
wim
are you printing it out, or are you gonna fax it to yourself for later?
Lol. I'm not understanding the significance. It looks to be testing the normal addition to the assignment addition but says they're always equal.
Terrible as this may sound, I am a hobbyist coder who doesn't read much of other people's code. So it takes me a while. I literally do not know a single other programmer irl.
+                self.assertEqual(inplace_result, regular_result)
+                self.assertEqual(id(inplace_result), c_id)
Am I wrong?
inplace_result has the same object id as the original. They don't test the regular_result against the original id, implying it's a new object.
Alright, well, I gotta rbrb to the post office to mail W2's. Will look into it later (and read everyone's responses to my thickheadedness).
rbrb all.
wim
wim
the first assert is testing that the counts are correct. the second assert is testing that it's an in-place operation.
without __iadd__ implemented, the first assert would still work but the second one would have fired
because += would fall back to x = x + y and rebind the name x
@wim I'm looking at the code. I'm just thinking to myself at what point in any of these functions is the C accelerator for the counter invoked?
wim
wim
you see the button called "Blame" up the top?
clicking that would have lead you to this: github.com/python/cpython/commit/…
i.e. it's invoked from .py code not C code
21:23
>>> class Bamboozle:
...     def __init__(self, val):
...         self.val = val
...
...     def __add__(self, other):
...         return Bamboozle(self.val + other.val)
...
...     def __iadd__(self, other):
...         return Bamboozle(42)
...

>>> a = Bamboozle(1)
... b = Bamboozle(2)
... print(a.val)
... a = a + b
... print(a.val)
... a += b
... print(a.val)
1
3
42
@malan ^
with an honest implementation __iadd__ would just do self.val += other.val; return self
ha, props for 42 being the answer.
wim
wim
the worst is this
>>> L = []
>>> def inner():
...     L += []
...
L is global variable right? wrong.
wim
wim
L.extend is the answer, but that's a wart huh
this is the ugly side of duck typing
@wim Do any linters give warnings if you try stunts like that?
21:29
@wim Ah, I see. Looking at all these fast path implementations is quite intriguing
@wim or global L or defining L=L...
22:07
Is there a trick to changing quote format to code format in questions?
Reversing the quote format seems to lose the whitespace
Test case (stackoverflow.com/questions/54373371/…) (I'm not asking for any action on that question other than how to fix the traceback)
no, I think that's a known pain point
I can copy into vim and delete the quote column if you want
Nah, I was just wondering if I was missing a trick
or just...delete the four chevrons manually
unqouting doesn't seem to kill indentation for me
I mean it was already broken as a quote
Then click {}
that's not "reversing the quote format", is it?
22:18
"Is there a trick to changing quote format to code format in questions?"
but then you said "Reversing the quote format seems to lose the whitespace" which I don't see
Sure, sorry. I meant it doesn't preserve something that's important to then convert to code format
I still don't understand, but OK :D
You can't simply reverse the quote format and then convert to code format
my claim is that you can
let me test on properly formatted code
22:21
Traceback (most recent call last):   File "preprocessing_tool.py", line 127, in <lambda>
    str(self.file_type.currentText()),   File "preprocessing_tool.py", line 302, in load_file
    self.pd_dataFrame = self.fr_fileReader.o_dataFrameObject.copy() AttributeError: >'NoneType' object has no attribute 'copy'
Now the line breaks are messed up
yes, but that's literally how it was as a quote
4 mins ago, by Andras Deak
I mean it was already broken as a quote
Aha ok
I will say that every time I've tried to do it, I've had the same problem
So, at a guess, 50 times? Are you sure the quote format doesn't do this?
No, but I stopped trying to test it when we agreed that the formatting was broken to begin with. Let me check.
Less easy to test :/
it messes up whitespace when you convert to a quote
it probably cuts up the lines with some guesstimated line width
once you have it as a quote, unqouting doesn't harm the whitespace
22:29
Appreciated
So it should be reversible if the OP posted the right thing in the first place
Single newlines don't matter in text markdown, so messing with that is arguably fair in a quote. But yeah, it could be done differently.
I certainly don't come upon such posts as often as people that use no formatting whatsoever. So it's not a difficult pill to swallow that it can't be automatically converted
I wouldn't be surprised if there was a six-year-old feature-request for this
22:57
My usual workaround is to put the stuff into a code block, and then put that into a quote block.
wim
wim
23:10
Our Software Dependency Problem .. excellent article, worth a read if you have the time
6
@PM2Ring yeah but we're talking about fixing broken OP posts
23:30
@AndrasDeak Understood. In that situation, I usually copy it into my own editor to repair it first, indent it, and then copy it back to SO & put it into a quote block. Of course, that's only possible if the desired indentation is obvious & unambiguous.
@vaultah I flagged it, and that disturbing avatar has now been replaced by a generic gravatar.
23:55
yup

« first day (3023 days earlier)      last day (2149 days later) »