« first day (3134 days earlier)      last day (1808 days later) » 
00:00 - 20:0020:00 - 00:00

12:30 AM
cbg. What do do with this, the user wants to use a function (not class instance) to create and start a timer, without storing that object state anywhere... seems like a common error by someone new to OO. Should it be left open, closed-as-duplicate, or should we merely add some 'Related' link "When to use/wrap a class instance, and when to use a function?", if so which link is best?
...moreover the user is confusing (infinite) recursion in a function with storing state between calls... sounds like a trainwreck for long timer values.
...also, the concept of a callback.
...I should have been more precise "to start a timer on another thread, and assign it a callback".
 
 
3 hours later…
3:17 AM
H
Hey, I'm having trouble getting bokeh to work. Specifically, when I try to import from it, I get the message, "ImportError: DLL load failed: The specified module could not be found." I have tried updating Bokeh, Anaconda, and Python, and upgrading the Anaconda Navigator. I was trying this solution (stackoverflow.com/a/51947704/2364796), but I'm warned that 5 other things (including Anaconda) would be deleted along with Bokeh, which would be more likely to break than fix things.
As for the answer below it, I am already on a higher version of Python. Most other solutions to similar questions seem beyond the involvement level that I'm aiming for (probably shouldn't have to learn Process Monitor for something this basic). Can anyone help?
 
 
3 hours later…
6:45 AM
cbg. Is there any electronics group in StackOverflow?
 
cbg
@X4748 The network is called stack exchange, that might have tripped up your search. and yes, there is electronics.stackexchange.com
 
Thanks
 
no problem
 
7:41 AM
Saw a comment on an answer just now, regarding using generator expr vs list comprehension.
lst = [0, 500.0, 500.0, 240.0,1.0,-1.0]
lst = lst*500

%timeit min(n for n in lst  if n>0)
209 µs ± 17.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

%timeit min([n for n in lst  if n>0])
169 µs ± 5.33 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
The comment said generator expr would allow us to do the work in 1 pass instead of two. What im trying to understand is why it seems slower then. did i miss something?
 
I think it's because the generator is suspended and resumed hundreds of times, while the list comprehension just creates a list and is done with it. i.e. list comprehension has more overhead, but genexp has slower iteration
 
and the statement itself is valid, regarding 1 pass vs 2?
 
When using a pandas dataframe, how can i drop rows where one of the attributes' string starts with a certain character? .startswith is a string function while the dataframe returns series
 
ehhhh... kind of? You could say that the list comprehension iterates over lst and then min iterates over the list comprehension (2 passes) while the genexp only iterates over lst when min requests the next item... so that's kind of 1 pass, I guess?
 
for example df[df.Name != 'Alisa'] would work, but df[df.Name.str.startswith("A")] wouldnt
 
7:49 AM
@Aran-Fey ohh, i was so confused by that statement
 
# one pass?
for n in lst:
    n = f(g(n))

# two passes
for n in lst:
    n = g(n)
for n in lst:
    n = f(n)
 
funny that it's still slower then. but also not that surprising
 
^^ kinda like that
 
@mtbrands wait, that should work right?
could you make an mcve please? (reprex be yammed for all i care)
 
8:01 AM
turns out df[~df['Name'].str.startswith("A")] does work
 
mhm, cool
 
8:17 AM
Can anybody please help me?
https://stackoverflow.com/questions/56162754/finding-a-count-volumn-based-on-3-different-column-in-pandas?noredirect=1#comment98953104_56162754
with this
 
https://sopython.com/chatroom
 
the link says "Don't ask for answers to your recent Stack Overflow questions. Those who can answer are already watching the queue on the main site."
 
yes, yes it does.
 
8:59 AM
Very good.
 
A question regarding Pycon Cleveland 2019:
I was looking for this -- Pythonic Objects: idiomatic OOP in Python, but found no video/text.
Could anyone share a link or something?
Should I wait till they release video?
 
9:14 AM
@lmao not 2019, but this video gives a good summary on how to write classes in python
 
@Arne: Thanks a lot. Just found this, Luciano Ramalho - Pythonic Objects: idiomatic OOP in Python - PyCon 2019 - youtube.com/watch?v=mUu_4k6a5-I
 
9:34 AM
morning
 
user7437554
Hi
 
user7437554
with open ('valen.csv', 'r') as infile, open('valen_depu.csv', 'w') as outfile:
    for line in infile:
      if 'theta' in line:
	    start=0
	    while start<20:
		  outfile.write(line)
		  start+=1
 
user7437554
is it too bad? It does not work
 
+= 0?
yesterday, by Andras Deak
"The output is weird", "it doesn't work", "there is an error" is never sufficient information. How is the output weird? When it doesn't work, is there an error? Does it produce nothing or something wrong instead? What is the error message? What is the expected output? Put together a minimal example if necessary. That makes it easier for others to help you.
 
user7437554
Here it doesn't work means it prints no output in outfile
 
9:43 AM
What's the content of valen.csv?
 
user7437554
uhmm a few columns of data, first column strings and then numbers
 
and none of them contain the word "theta"
 
user7437554
yes, that's right :(
 
@santimirandarp Why do you want to write 20 copies of the same line?
 
user7437554
what I really want to do is to copy 20 lines from the first
 
user7437554
9:47 AM
I know this copy 20 lines of the first
 
user7437554
but can't find a way to do that
 
Well if none of them contain "theta" then surely it's clear why no output is written?
 
user7437554
yes, that's clear
 
user7437554
I've changed it to the proper word
 
user7437554
is it possible to write the next 20 lines?
 
9:50 AM
@santimirandarp Do you mean that if a line in valen.csv contains theta, then you want to copy 20 lines, including the "theta" line from valen.csv to valen_depu.csv ?
 
user7437554
that's it
 
@santimirandarp Ok. And after that block of 20 lines, do you want to check for theta again, and write more lines?
 
user7437554
By now, just once
 
user7437554
im trying to extract the first block containing theta in some messy files
 
user7437554
I don't know if lines can be enumerated from the one containing theta
 
9:56 AM
@santimirandarp Ok. That's not too tricky. But I won't write any code, since I'm on my phone.
 
user7437554
no worries, but do you have any advice so i can think of it?
 
You can use enumerate for this.
You can do stuff like:
for linenum, line in enumerate(infile):
But I'll let someone else fill in the details. ;)
 
very new but confused, brain fart (no repro) stackoverflow.com/questions/56165831/…
Asks how a plotting library computes the input
 
@AndrasDeak Self-deleted
 
10:13 AM
Yup
 
Reprex sounds like the brand name of a competitor to Durex. ;) — PM 2Ring 3 hours ago
Also, reprex reminds me of Ruprecht from the movie Dirty Rotten Scoundrels.
 
cbg
@PM2Ring Lol :-)
 
Poor Paritosh being forced onto meta :P
 
10:29 AM
heh, you saw that huh :P yeah, i suppose if it ended up staying in, and i didn't try to atleast raise my concern over it, i'd not be very happy with myself at the end of it all.
 
Practice safe hex, don't forget the Reprexâ„¢.
 
@Arne: Thanks, as always you suggested a gem of a video, learned a lot...
It isn't a class if it has just 2 methods, one of which is init !
 
@lmao Just a tip, you should go to the message you're replying to, put your cursor on it, look left, and click on the arrow, then hit "reply to this message", and start typing, so users know which message you're responding to, how do you know?, click on the funny arrow on the left and see, like i do
 
: @U9-Forward: Sorry, got it.
Will do as you suggested :)
 
@lmao Thanks, P.S. no comma needed lol :-)
 
10:36 AM
@U9-Forward comma: Between sorry and got it?
 
Sorrym i meant colon
And don't need to call me twice, i do one here
 
@U9-Forward Oh, got it Sir!
 
@lmao Thanks, there you go!
 
@U9-Forward :-)
 
P.S. no need everytime :-)
 
10:39 AM
:P
 
:-)
 
11:05 AM
Had some complains on one of my answers... decided to delete, the best option.
I edited but still complains, so best to delete
 
11:48 AM
rbrb
 
12:17 PM
Just spent five minutes looking at docs.python.org/3/library/struct.html#format-characters trying to figure out how to convert packed data into a bytes. I am dumb.
(For those unfamiliar with the module, struct.pack already returns a bytes)
 
packed data meaning strings?
 
String-ish.
 
ah. ah well, it happens :P
Im just happy there's proof Kevin is human too.
 
Some days I feel more like a trash goblin, so human is a generous label
 
12:36 PM
There is a project trash-cli in python, goblin in python.
And, there is a project lmao( Laundry Manager and Optimizer ) in python.
And there is uncle bob, future of programming, in real as well!
 
@ParitoshSingh That was my first though as well (Kevin's post)
I would wager that the only people who never feel dumb are truly dumb people
 
@Dodge That sounds like a version of "I know that I know nothing"
 
@Arne yup, and sort of the opposite of "ignorance is bliss"
> The identification derived from the cognitive bias evident in the criminal case of McArthur Wheeler, who robbed banks while his face was covered with lemon juice, which he believed would make it invisible to the surveillance cameras.
Ha! From @PM2Ring 's link
 
12:55 PM
All the half-joking messages I make about how incompetent I am are a nice release valve for my Impostor Syndrome
 
There was a similar story about someone that worked at a petrol station for years and got sacked. Feeling unfairly treated, he decided to rob them some weeks later. It happened that he was blind in one eye and decided that cutting only a single hole in his makeshift balaclava would make him harder to identify. It... didn't work out so well for him.
 
hehe
 
@Dodge It almost makes me feel sorry for the poor guy. Almost.
 
@roganjosh I actually agree with you, although it'd feel less satisfying. Not that I don't enjoy the well written word anyway.
cbg all
 
@toonarmycaptain I'm currently binge watching some Christopher Hitchens videos that I hadn't previously come across, so the appreciation of articulation is shared :)
 
1:09 PM
Is there a built-in way to turn "0b1.1" into 1.5? I lashed together a working approach but if the work has already been done for me, I'd prefer that.
 
1:20 PM
I'd assume no, python is spitting out all attempts at mixing decimals with binary, and all attempts to parse float/fractions as binary too. i dont think "0b1.1" is considered standard.
 
0x1.1 would work though
 
@Kevin I don't think so. But I'm curious why you have binary float strings.
 
@vaultah says invalid syntax
 
I mean there's a built-in way to convert 0x1.1
>>> float.fromhex('0x1.1')
1.0625
 
My mini-project for the day is a walkthrough of how doubles are stored in memory and what arithmetic turns those bits into numbers. The mantissa/significand represents a number in the range (1,2] and one can visualize its bits as a binary digit with an implied "1." at the front. e.g. 0b1000...(48 more zeroes) is understood to be 0b1.1000...(48 more zeroes).
Alternatively I could interpret the mantissa as an integer, and then add 2**53 to it and bitshift right by 53. (or 52? Curse these fencepost errors)
The "implied 1." is how they taught the concept in school so that's what I'm trying first.
Ultimately I would prefer whatever approach is more comprehensible to an average reader. Probably "interpret as int, then divide" is easier. Converting non-integers between bases isn't a trivial concept
 
1:32 PM
Nope
 
The average reader is probably not that interested in the fine details of how floats work, so you can probably assume your reader is already familiar with converting integers between various bases.
 
I would prefer the "implied 1." explanation
it is a pretty trivial transformation
 
I need a sanity check, please. I'm supposed to implement this function with pure recursion - no loops, no helper functions, no nothing - and I don't see how it's possible. Basically the function takes a string and an index as input, and then inserts ascending numbers between all letters of the string starting at that index:
addNumbersInString("Fahrzeug", 0) -> "1F2a3h4r5z6e7u8g"
addNumbersInString("Fahrzeug", 3) -> "Fah1r2z3e4u5g"
addNumbersInString("Es ist ein Test", 7) -> "Es ist 1e2i3n4 5T6e7s8t"
addNumbersInString("A", 0) -> "1A"
I can't change the signature of the function either
 
I think it's possible if you insert the largest/rightmost digit first
 
1:47 PM
But then the recursive call has no way of knowing whether that number has been there from the start or not
I can't pass a "stop index" to the recursive call
 
Seems fishy
 
But if you pass a slice of the string instead of the entire string to the recursive call, then the "stop index" is just the length of the string
 
You can't pass a start index
 
so what you're saying is I need to calculate the value of the last number, insert it, slice the string, and recurse with the slice?
 
@Kevin oh, cool
Recurse with prefix rather than suffix slices?
 
1:50 PM
@Aran-Fey That's what I'm thinking
 
I guess that works
thanks
I've got 1 more, though: A function that takes a string as input and moves the character with the highest ASCII value to the beginning:
shiftMaxCharLeft("acbxdyfjzdmk") -> "zacbxdyfjdmk"
shiftMaxCharLeft("") -> ""
shiftMaxCharLeft("az") -> "za"
shiftMaxCharLeft("a") -> "a"
shiftMaxCharLeft("abcdefgh") -> "habcdefg"
This is how my university teaches recursion to first-semester students >_>
 
Horrible one-liner implementation of addNumbersInString: pastebin.com/CuxPYbx6
 
Now imagine that horrible one-liner as java code
 
I decline
 
a wise decision
 
1:57 PM
shiftMaxCharLeft is a real puzzle... I don't suppose max(s, key=ord) is allowed?
(Not that the solution is trivial even if that's permitted)
 
I don't think so, considering that it'd probably require a whole bunch of imports (and stuff the lecture hasn't covered yet) in Java
 
What should the result of shiftMaxCharLeft("azbz") be?
 
I'd assume "zabz". Unfortunately I only have those 5 test cases and nothing more (well, there is a rather unhelpful description in addition to the test cases)
 
Not exactly sure what to search for on teh internets, so here goes. How would I break this into multiple lines?
Cmd['gatk']['MarkDuplicates'][f'--REMOVE_DUPLICATES {rmd}']['--VALIDATION_STRINGENCY']
Oh, just new lines seems to work... That was too simple.
 
Just putting newlines may or may not work depending on context. Example:
 
2:08 PM
Hum, PyCharm doesn't see a problem with just breaking into new lines, but Python does.
 
x = [[[9]]]
#this works
print(x
[0]
[0]
[0]
)

#this does not work the way you might expect
z = x
[0]
[0]
[0]
print(z)
The results are 9 and [[[9]]] respectively
 
Looks like I'll have to assign each line individually, e.g.

x = Cmd['gatk']
x = x['MarkDuplicates']
x = x['--REMOVE']

... and so on
 
You can use the line continuation character, "\", to indicate that the expression isn't done yet:
z = x\
[0]\
[0]\
[0]
print(z)
Or you can just add a parenthesis.
z = (x
[0]
[0]
[0])
print(z)
 
@AndrasDeak They reversed the mcve change :D
 
@Aran-Fey Here's a horrible O(N^2)ish solution: pastebin.com/JVfgj5Zm
 
2:14 PM
@Kevin thanks, I'll give it a go!
 
Isn't that linear? You can assign shiftMaxCharLeft(s[:-1]) to a variable and then you only have 1 recursive call
Ah, lots of strings being copied though
 
... Oops. Yeah, assigning makes it faster.
 
My brain is so fried right now I can't even figure out how/why that works
 
@MooingRawr no? Just unfeatured the meta post?
 
2:30 PM
Meg is probably loving her new job right now. "Baptism of fire" is about the only thing that comes to mind
 
@Aran-Fey it has to be recursive? I'm assuming that is the point of the exercise?
 
Yeah
It took me an embarrassingly long time to convert Kevin's solution to Java
 
they teach you functional programming in Java? oO
 
Recursion is functional programming now?
 
zip(*[[1, 2], ['a', 'b']]) works in legacy Python? Right?
 
2:40 PM
@Kevin Thanks for doing half of my homework for me
@piRSquared Can confirm it works in python 2.7
 
thx
 
@Aran-Fey at least these kind of tasks I would not do via recursion outside of FP
 
EULA: by clicking on a pastebin link that I provide during a conversation about homework, you agree:
- that the contents comprise a spoiler
- that reading the contents may diminish the amount of learning you actually do
- that Kevin is not a bad person for handing you a working solution
Violators face a fine of 20,000 quatloos and up to ten minutes wearing the hat of shame
 
@MisterMiyagi just about every recursion tutorial task taught during courses is not a good fit for recursion.
 
What is the hat of shame?
 
2:46 PM
The only notable exception i can think of is tower of hanoi, which may or may not be skipped over in a course.
 
It varies from person to person. You have to construct the most shameful hat from the things around you.
 
The old "dunce" cone is boring. I hope it's more nuanced.
 
You could try to game the system and construct a hat that isn't maximally shameful given the available resources, but this too is a crime that earns you the hat of shame
If you don't want infinite recursive fines, you must make an earnest effort
 
can't I recursively get fined until the stack overflows and all my debt disappears?
 
along with half of the universe, yeah.
 
2:50 PM
I think the Universe can cope with more recursion than Python; Physicists among us might have a better explanation of what happens with an infinite number of hats being applied, but I don't suppose it will be comforting news
 
And the other half cant decide which half it is, so it has an identity crisis and it breaks down too.
 
3:03 PM
Finally getting sensible results for my float thinger: pastebin.com/VtZ8capw. Presentation still leaves something to be desired.
Hmm, my code thinks that 0.0 is represented in memory as 1 * (4503599627370496 / 4503599627370496) * 1/89884656743115795386465259539451236680898848947115328636715040578866337902750481566354238661203768010560056939935696678829394884407208311246423715319737062188883946712432742638151109800623047059726541476042502884419075341171231440736956555270413618581675255342293149119973622969239858152417678164812112068608. I don't think that's actually true.
I haven't bothered to add special handling for NaN and inf and subnormal numbers yet... But I didn't think zero was any of those. Maybe it is?
 
pretty sure it is
remember that floats store intervals like [1, 2) and half them
you cannot reach 0 that way
because of the leading 1.
 
Yeah.
 
I'm pretty sure that the leading implicit 1 is ignored for zero. According to en.wikipedia.org/wiki/… zero has all zeroes in the mantissa & the exponent
 
I think you're right. en.wikipedia.org/wiki/Denormal_number says "[in a normal number, ] the leading binary digit is always 1. In a denormal number, since the exponent is the least that it can be, zero is the leading significand digit"
Ok, accounting for denormal numbers, 0 is represented as 1 * (0 / 4503599627370496) * 1, which is correct
Whoops, now 1.1125369292536007e-308 is apparently equal to 1/2. Back to the drawing board...
 
3:28 PM
is there a web repl where I can test out Python 3.8?
 
Denormal numbers use an exponent bias that's one smaller than the bias used for normal numbers... So very sneaky.
 
@AndrasDeak Unfeaturing this after a day makes me think they are pulling this feature..... but I guess I could see what you mean by the meta post being featured too :\
 
3:50 PM
Interesting - NaNs are signified by having an exponent of 0b11111111111 and a mantissa starting with 0b1. The other bits of the mantissa are called the "payload" and are usually ignored. For instance, AFAICT Python just leaves those bits as zeroes.
But if you create a NaN via struct.unpack, you can specify whatever payload you want and Python will dutifully store those bits. I wonder if this could be used for steganography...
 
cbg
Looks like reprex is no longer featured. Since the changes still remain I can only assume they grew tired of receiving flak for it
 
That's my take on it
 
Shog9 said he'll have to think about it and get back to us.
 
4:07 PM
float thinger v0.1 is operational.
 
@MooingRawr unfortunately it's the latter
 
4:31 PM
All this hubbub over help pages... I mean... who even reads those?!
 
5:08 PM
@cs95 ¯\_(ツ)_/¯
I think I can one-up this site copyshrug.com
 
Please sign my petition to change the contents of all help pages to "Kevin, you're doing an amazing job and your efforts do not go unnoticed" because if nobody else is going to read the page it may as well provide some use to me personally
 
^ yeah but which kevin?
 
¯_(ツ)_/¯
 
There's only one Kevin, fragmented in time and space like a 4d zoetrope
 
@ParitoshSingh phantom limb syndrome?
 
5:13 PM
the site failed me. ¯_(ツ)_/¯
 
@roganjosh his limb escaped
 
¯_(ツ)_/¯ Depicts a one-handed subject shrugging while his friend (mostly out of frame to the left) also shrugs
Pan a little to the left: ¯_(ツ)_/¯_(ツ)_/¯
Yes, the friends tessellate infinitely to the left.
 
fooling myself into thinking i have friends. nice!
 
I didn't see the wider picture. Now it's a beautiful depiction of unity
 
I imagine a 4D octopus (generalize to n-pus) in which our current time slices through x number of limbs. If the subject n-pus is Kevin, then each slice of limb is a manifestation of Kevin in our time. My question is: What does the Kevin slice look like when it pushes itself into our time more fully? Maybe at the "body" of the n-pus.
 
5:18 PM
If I had 10000% more skill with image software I would tile the shrugers on a mobius strip
Nearly spit out my drink at "n-pus" there. This is going to revolutionize mathematics.
Presumably the junction of two tentacles would look like one Kevin splitting into two as if by cell division. Or merging together, depending on the direction of the arrow of time
 
wim
@MartijnPieters There doesn't seem to be a "slogans" section in latest version of wheel docs anymore (referencing this comment)
usually readthedocs hosts older tags of the docs but wheel doesn't seem to?!
@U9-Forward yes, you are learning young padawan
@Kevin interesting.
 
What do you call 10 cards?
... decacard
 
2 cards in binary.
ah :P
 
5:33 PM
>>> f = struct.unpack(">d", b"\x7f\xf8hello!")[0]
>>> f
nan
>>> struct.pack(">d", f)
b'\x7f\xf8hello!'
This is dumb and pointless but here it is
 
wim
in C there is a similar hack to hide stuff in bools
since it's store in 8 bits but only 1 bit is actually used, you've got 7 bits of fat to play with
 
Tired: booleans have two values, True and False
Wired: booleans have three values, True False and FILE_NOT_FOUND
Inspired: booleans have 256 values, 254 of which are implementation-dependent
 
5:49 PM
Bit 1 specifies truth. Bit 2 specifies beauty. 3 through 7 specify up/down, top/bottom, charm/strange, NTSC/PAL, and smoking/nonsmoking.
 
and then we can just use bits to save every piece of data we use instead... oh wait
 
wim
6:01 PM
showed it around WimCorp and got a few interesting links in reply
44
Q: What is the purpose of NaN boxing?

andijcrReading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit patterns, to use them as markers or pointers (the book mentions that WebKit uses this technique). I'm not...

8
Q: What uses do floating point NaN payloads have?

Jordan MeloI know that IEEE 754 defines NaNs to have the following bitwise representation: The sign bit can be either 0 or 1 The exponent field contains all 1 bits Some bits of the mantissa are used to specify whether it's a quiet NaN or signalling NaN The mantissa cannot be all 0 bits because that bit pa...

 
Hi everyone
I have a list
I want to find the first occurrence of an element from the back of the list
How do I do that?
Index of the first occurrence
 
Reverse the list and index it?
 
.rindex?
oh, that doesn't exist :P
 
rindex is just for strings right
yeah
yep, just reverse and find first index.
 
If I do reverse wont the index change?
for that particular element?
 
6:06 PM
it will
 
I need to get that index
 
it's probably not highly advanced mathematics to convert back the reversed index
 
yep. but some maths with the length should get it back for you.
 
Ok, then you'll need to calculate it by subtracting from len()
 
I half-jokingly nominate next(idx for idx in range(len(seq)-1, -1, -1) if seq[idx] == whatever)
 
6:15 PM
@RaphX please have a go and we can help out if it doesn't work
I've looked at this discourse again and I think help-vampires have made this a bit of an inhospitable place
 
wim
it's also first google result for "python list last occurrence"
 
@wim @piRSquared has a good answer there involving dictionary lookup. I would only add that using a dictionary is worth it if you have to do a "last occurrence" lookup multiple times. lookup = {li[i]: i for i in range(len(li))}
 
+1 on that post for a solution that doesn't involve "-1". Manual index math should stay in the stone age where it belongs
 
lookup = dict(map(reversed,enumerate(li))) while we're overengineering it
ah, that's what he did
 
6:28 PM
Like I said, it's worth it if you have to do a lookup multiple times
Otherwise, it uses linear memory which isn't worth it
 
@cs95 @wim I just updated with another solution stackoverflow.com/a/50801862/2336654
 
that's kinda the same as another answer there
 
shocking
 
is it? yam! I was looking for it
 
this overengineering is appreciated though, really.
 
6:35 PM
bah! your're right... that's better too
 
i wonder if we could make it worse. :P
yeah, enumerate atleast scores for readibility.
 
I thought we were doing that already
 
hungry rbrb
 
the lack of short circuiting bothers me though
 
I missed it. What was it?
 
6:37 PM
argmax on reversed something
(Paritosh linked an answer)
 
ah, hence the mention of short circuiting (or lack thereof)
 
wim
6:58 PM
I don't think the dict idea is good.
Also mine had a bug that went unnoticed, so glad to have this brought up actually
 
its good if you need to find last occurrence of multiple things, so there's some merit to it.
 
wim
@ParitoshSingh yes, good point
does this diff fail to render for anyone else ...? stackoverflow.com/posts/50801862/revisions
 
"With dict"
 
wim
yeah but it says "added 132 characters in body"
 
do rollbacks appear in that?
jw
i know it was edited to display the other argmax like solution.
would a rollback cause it to look like that?
 
7:17 PM
Hey so i'm trying to fix an issue with Python on my PATH from CmdPrompt but I'm unsure how to utilize setx correctly. apparently there's a " character on the end of my Python37\Scripts folder and its causing errors
 
ah, the glorious quoting rules of the Windows shell
there's probably also a " character at the start, isn't there?
 
nope just the end..
;C:\P_F\Python37\Scripts";
 
nothing to match it at the start anywhere? because that's just simply wrong if it really is standalone
 
Don't ask me I recently tried utilizing some IDEs other than IDLE and i've gotten some errors about it.
 
I usually just modify my environment variables using the GUI. Maybe you would have better luck that way.
 
7:20 PM
Unfortunately If i had been able I'd have just had it put python on the PATH during installation but we don't get to install our own software.
 
^ actually yeah, that too. avoid cmd while modifying path variables
well, you dont have to get to install your own software, can you change your own environment variables after the fact?
 
yeah i have admin privileges but IT gets bent out of shape if they aren't the ones to do the installation
 
ok all good. yeah, avoid setx, use the gui
 
alright, i got it finally. the GUI is a lot better
 
I wish linux had a GUI for changing environment variables...
 
7:26 PM
actually, iirc setx is a double nightmare to deal with on windows, because it writes to registry, which doesn't even show up on the gui path.
i vaguely remember a coworker garbled his installation of something because of it
or maybe it was a variant of setx
 
yeah setx /M PATH wil set something globally across the Machine..
 
yeah no, it was setx
 
7:45 PM
in regards to the last position of 'a': what about this len(li) - 1 - next(filter(lambda t: t[1] == 'a', enumerate(reversed(li))))[0]
 
)))) is just the right amount of brackets to be starting somewhere
couple more and we might start calling this javascript :P
or one of those other languages you only hear in legends. lisp or something
 
ouch (-:
 
:P to be fair, i know nothing of lisp except the xkcd
 
I think len(li) - 1 - next(i for i, v in enumerate(reversed(li)) if v == 'a') is more readable
 
aye, agreed.
though at that point, we really should just be using index
this would raise an error too if an element isnt present yeah?
i'd assume stopiteration
so we cant even argue for error-free experience.
(granted, if it ended up giving an answer, that answer would be grossly incorrect) :P
 
7:52 PM
You can supply a value to next's default parameter if you want the code to return a sentinel value instead of crashing if it can't find the value
You won't be able to use a paren-less generator expression, but [shrug emoticon]
 
Aah. nifty
len(li) - 1 - next((i for i, v in enumerate(reversed(li)) if v == 'a'), len(li))
now its like a ghetto find.
yeah, i can live with that. lists dont have a find so hey!
 
I could've sworn lists had a rindex method, but they don't
was that strings?
 
Yeah.
 
wonder how often that method has been called, ever
 
@wim removed during 5-minute grace period
 
00:00 - 20:0020:00 - 00:00

« first day (3134 days earlier)      last day (1808 days later) »