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

8:02 PM
ive seen rindex used once in about 1.5 years :P
 
I feel that this horse isn't dead yet. So...
Suppose `li` is an iterator that cannot be reversed and has no length. but does have an end. What is the most memory efficient way to do this? You have to traverse the entire thing to be sure.
 
yeah indeed. cheeky memory efficiency added in, i'd have just advocated for the dict
i think we just stick with the argmax like solution then, the enumerate was kinda nice
 
;-)
dict((x == 'a', i) for i, x in enumerate(li))[1]
 
okay that one got a chuckle out of me :P
 
@wim that's covered by his profile; beloved leader of Chinese Non-dictatorial-at-all Republic
 
wim
8:16 PM
@piRSquared not the most memory efficient because you're storing falses too
 
dict((True, i) for i, x in enumerate(li) if x == 'a')[1]
I think I'm being clever but that looks so dumb
 
wim
why do you want to use a dict so badly. it just seems like a way to obfuscate writing a for loop and a conditional
 
wait, the goal was to do it in the strangest way possible i thought, the easy ones were all taken :P
 
wim
for i, val in enumerate(li):
    if val == "a":
        idx = i
 
not like I'm writing production code here (-: Just stretching the 'ol noggin
 
wim
8:21 PM
^ It will be hard to find anything more Pythonic than that
it is pretty weird that str.rindex exists but list.rindex doesn't
 
it is weird
 
I'm done. Procrastination has been fruitless.
 
[idx:=ind for ind,val in enumerate(li) if val == "a"]
 
shame its creating that list though.
 
I guess that's too close to the equivalent max(filtered_idx) to explain the intentional weirdness
unfortunately this doesn't work:
>>> next((42 for ind,val in enumerate(li) if val == "a" if (idx:=ind) if False), idx)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'idx' is not defined
 
8:34 PM
"unfortunately"
 
I guess you need an existing name to pass as a second argument to next before it can do anything with the first, makes sense
 
wim
Feb 4 at 22:35, by wim
WRITE A FOR LOOP
 
Granpa's write for loops. All the cool kids know one-line programming is where it's at!
 
wim
8:52 PM
get off my lawn
 
I'm getting a new monitor with a resolution 108 x 76800 to accommodate my one line modules
 
9:13 PM
recursive functions are where it's at
@piRSquared it is 2019, after all. Who needs line limits????
 
9:30 PM
what is a clever way to count the whitespace at the beginning of a string?
 
for short strings count the len diff to the lstripped version? :P
 
that's where I went. (-: thx
 
oops, no, hold on
 
that counts all the whitespace
 
yeah, I originally wanted to put a next in there
 
9:33 PM
for long strings, len(re.match(r'\s*', your_string).group()) I guess?
 
sum(1 for _ in takewhile(whitespace.__contains__, string)).....
 
or re.match(r'\s*', your_string).end() if you don't mind that 99% of people have never seen the end() method before
 
hello
 
hello
 
looking up end method
 
9:37 PM
I am trying to plot some vectors in 3D. I want to plot them and then have some sliders that allow me to change their initial positions. I also have a constraint that allows me to to describe the position of all 3 in relation to a single parameter. I want to have a slider for that as well so I can see all 3 vectors change as i change this parameter.
 
I have an example of what I'm looking for here kind of
I tried making one in python with jupyter notebooks but it seemed kind of clumsy to set up with numpy, so i was wondering if there were better packages than just the jupyter interactive tools they offer
 
numpy has little to do with plotting
 
yeah that's how it seemed. i'm not sure what tool to use
 
you can use widgets with matplotlib which is the usual plotting tool, although it won't look as fancy
 
9:39 PM
/ the best way to do this
 
there are other plotting libraries such as bokeh or plotly which I'm unfamiliar with
Also matplotlib has a 2d renderer so interlocking 3d surfaces usually look bad.
 
@AndrasDeak hmm ok, i'll look into those. thanks
 
 
2 hours later…
11:27 PM
cbg
 
00:00 - 20:0020:00 - 00:00

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