« first day (4283 days earlier)      last day (672 days later) » 

12:42 AM
duplicate, I wasted my hammer before searching stackoverflow.com/questions/72905502
stackoverflow.com/questions/72905489 I'd love to have canonicals for these sorts of elementary techniques, but I have no idea how to make them searchable
 
 
7 hours later…
 
1 hour later…
8:38 AM
stackoverflow.com/questions/72908714 Is there seriously not a duplicate for this?
 
9:01 AM
heh... doing that image probably took more time than asking than composing the question...
 
 
3 hours later…
12:05 PM
why is it if I splice this string at 0:20 and 20:34 it correctly splits it... wouldnt that mean it ends at character 20 and also starts at character 20 (so it should be getting a character at the end of the first one and start of the second?)
'[bg storage=staff06][ud time=2500]'[0:20] gives [bg storage=staff06]
'[bg storage=staff06][ud time=2500]'[20:34] gives [ud time=2500]
... wait does splicing start at 1 instead of 0? :|
 
It's slicing, not splicing, but no, it starts at 0.
But it's right-exclusive, like ranges.
Check list(range(0, 4))
 
what I mean is, shouldnt 20 be the same character?
 
@JasonBrown index 20? Yes. But :20 goes up to 19.
 
Slices are half-open intervals. That [a, x) merged with [x, b) is equal to [a, b) is the entire point.
 
Shame that slicing is such a rarely-used operation in python... otherwise it might be explained in the tutorial or in 50 bajillion other places on the internet
 
12:11 PM
This is all so that lst[:n] and range(n) have length n.
 
witchcraft!
 
im so confused... since [20] returns '[' but 0:20 is only going to 19?
 
@JasonBrown we can repeat it a few more times, or you could check it on a shorter list.
 
You might want to experiment with a sequence of numbers instead of an arbitrary string instead.
 
ok il try that, i don't know why i cant wrap my head around it, maybe its just too early in the morning lol
 
12:15 PM
@JasonBrown perhaps you need to read a good python tutorial
 
[0, 1, 2, 3][2] => 2 but [0, 1, 2, 3][2:] => [2, 3] and [0, 1, 2, 3][:2] => [0, 1]
 
Or let Miyagi investigate for you
 
These examples are just the free trial to a whole world full of typing fun!
 
Lol thanks I sorta understand... basically my brain has said fk it, it just works in a slightly odd way then what your used to xD im gonna go look up some more information on slicing
 
Not sure if it helps, but there is common way of showing this with indices at the start of each item. That usually helps folks when we teach it.
# Content
 H E L L O
0 1 2 3 4
# Indices
 
12:19 PM
Meh
That's as complicated as learning the rules. To me at least.
 
@JasonBrown also, if youre trying to compare indexing and slicing and making a mental model, something like [20] should be compared with something like [20: 35] or so on, you do yourself a disservice by comparing indexing with the "end" of a slicing operation.
 
I find it more helpful that one-based and right-inclusive XOR zero-based and right-exclusive make sense
 
@AndrasDeak--СлаваУкраїні And you haven't even seen the one with negative indices!
 
Its mostly that I don't understand why it wouldnt include the final character in the sliced data
 
the start index of a slice behaves exactly like indexing and its included. the end index of a slice is excluded. this leads to some very desirable properties
 
12:21 PM
@MisterMiyagi PBC FTW
 
@JasonBrown oh this one is easy, it makes "length" of slices directly correlate to end - start, and other such mathematical niceities
 
^ Thats what I was confused about.. It was just unexpected thats all
 
@JasonBrown Because then you loose the nice features of adjacent slices being complete and of the slice length being equal to the index difference.
 
eg [20:35] i will immediately know this slice will have 15 elements because indexes start with 0 and have been coded to be half open
once you learn the benefits, you see why this decision was made.
 
Im used to C# so I was comparing slicing a string to the equivalent of substring
 
12:22 PM
Good thing I'm waiting at the vet so I might as well be watching paint dry
 
lol I appreciate the help in understanding it =)
I mean my code did work I just didn't know why it worked, and thats never a good sign ;)
 
so far im enjoying the ease of python though, its a lot better then I had expected honestly. I still prefer c# when I'm making anything really complex but i find it really good to prototype and for automating things.
 
The only thing that put me off python (beside the hype) was whitespace.
 
Just read up on the formal definition of slicing and it's, like, totally not helpful. Slice syntax constructs slices with a tangent on how slicings and expression are formally indistinguishable.
You have to separately look up builtin sequence types to learn what slicing actually does.
 
12:30 PM
Or, you know, read a tutorial.
 
There's something on slicing in an early part of the Python tutorial but it certainly wouldn't have helped much for this conversation.
 
you know, i distinctly remember reading an excellent article about why python slices were chosen this way, but it's like its now disappeared off the face of internet, or my google fu is not up to snuff. said article had considered 4 cases, with zero indexing and 1 indexing and half open or fully closed ranges
There were some really important points about why choosing the wrong kind of system would lead to a lot of +1 or -1 type of operations, and that often leads to off by one errors
 
I mean it seems like a smart way to do things, I just wish they made it a bit more obvious quote from python docs note (5): 'so on, stopping when j is reached (but never including j)' Just make the 'never including j' more obvious damnt lol
its from note 5 on the link from MisterMiyagi
 
oh it might have been that, or perhaps someone taking the same type of logic and writing a post about it. that approach is essentially it
but yeah, tl;dr slices are cool, and google fu helps save lives
 
12:39 PM
now i just need to figure out how im gonna fix my loop so it stops out of indexing my string lol... stupid string
 
Possibly controversial opinion: you can avoid 90% of slicing-related mistakes, by finding a different approach that doesn't use slicing.
 
Lol but slicing seemed so simplistic :)
 
I find that str.split, str.partition, and the re module do a good job of replacing slicing in many scenarios
 
uhg I still hate regex...
 
Valid.
 
12:42 PM
not that its not amazing im just so terrible at writing it lol
half the time I just do google fu to find someone who has a similiar or the same need for regex and just edit that slightly
the other half the time I give up :)
 
Use the other other half of the time to use a website called regex101.com, it makes your life easier if you ever need to work with regex.
 
I, too, am terrible at writing regex. But it's useful to write even very small and simple patterns. For example, finding all groups of consecutive digits in a string only requires a three character pattern:
 
fair, I have used that in the past and it does help quite a bit, just sometimes its not enough as I basically end up trial and erroring it till it works either way
 
>>> re.findall("\d+", "I have 200 apples, and I gave 33 to my friend")
['200', '33']
 
How could you! I thought we were going to share equally Kevin!
 
12:46 PM
Lolol ya thats about the most regex I can figure out
I might start saving all my regex to a text file so I can just look them up whenever I need them xD
 
I need the extra 167 apples to cover operating costs. Apple carts don't paint themselves ya know
 
thats what inflation is for, you share equally then charge twice the price for the rest :P
btw whats everyones preferred ide for python... currently Im just using VS 2019
need one that shows syntax, lets me watch variables, and handles breakpoints. Id prefer something faster then vs2019 though
 
I like PyCharm, but it handles like a zombie horse pulling a boulder.
 
spyder if im lucky....some kind of browser text editor with syntax highlighting that doesn't even understand python if im unlucky...lately ive been very unlucky...
 
12:55 PM
oo spyder looks sweet
 
>>> import re
>>> s = '[bg storage=staff06][ud time=2500]'
>>> re.findall("\[.*?\]", s)
['[bg storage=staff06]', '[ud time=2500]']
>>> re.findall("\[(.*?)\]", s)
['bg storage=staff06', 'ud time=2500']
>>> re.findall("\[(.*?)=(.*?)\]", s)
[('bg storage', 'staff06'), ('ud time', '2500')]
A few more regexes.
 
im definitely going to switch to spyder when I next need to relaunch my editor. Also Thanks Kevin =D
 
spyder also does have a slow initial startup though (infinitely better than pycham but its there.) if that's not a deal breaker then you might like it, once its loaded it runs well
 
wait would those still work if there was random text between the [tags]? eg my strings are more like this:
'[Tag1=staff][tag2=555]Hi there Im a string thats[color=blue]a pain in your ass'
 
This is a fairly accurate depiction of how I work with regexes in my own project -- I start with a simple one, and incrementally add bits to it so I get output in a more convenient format. From "get the key-value pairs" to "get the pairs without square brackets" to "capture the key and value in different groups"
@JasonBrown Sure. Unless the random text contains square brackets. Then you're doomed.
 
1:02 PM
lolol well it SHOULDNT contain square brackets but you never know when your parsing files you didn't write you can only look through a handful of lines and then hope that you notice it if your program errors lol
again thanks for those =)
il end up using them when I switch my code to handle multiline situations where its not one string with tags per line and its tags on bunch of lines then a string over 3-6
 
Parsing data you didn't write, using rules that nobody bothered to write down, and you can't blackmail the original author into helping you... This is the classic plight of the programmer
 
Lolol I like the 'blackmail' portion of that xD
 
VsCode with the built-in jupyter support is pretty nice imo, allows you to quickly test and debug without actually having to program in notebooks
 
I think ive used VsCode in the past I remember it being pretty responsive but i remember telling myself that it was somehow lacking lol
 
I kinda like
>>> import re
>>> s='[bg storage=staff06][ud time=2500]'
>>> [el.partition('=')[0::2] for el in re.findall("\[(.*?)\]", s)]
[('bg storage', 'staff06'), ('ud time', '2500')]
 
1:07 PM
The refactoring options are kinda limited, but working on VMs and docker containers with it is a breeze
 
@0x263A Reasonable. Alternatively, to continue my "no slicing" philosophy:
>>> [el.split("=", 1) for el in re.findall("\[(.*?)\]", s)]
[['bg storage', 'staff06'], ['ud time', '2500']]
 
proceeds to save all these useful regex lines
 
As payment for my consultancy, you must contemplate the concept of trees for at least 15 seconds today
 
@Kevin yea that's better
 
... :| damn a whole 15 seconds?
 
1:20 PM
We could discuss an installment plan, but there would be interest. You'd probably have to contemplate trees for one second per month for the next 30 months.
 
hmmm... that sounds better as long as I dont have to show my work xD
damnt... Lol I zoned out too much last time I was programing and ended up using comparators instead of setting the variables... was trying to figure out why the heck I kept getting repeating output in my text file xD
 
2:19 PM
This seems quite astounding to me. Zip files don't contain metadata for the compression ratio? From here
 
en.wikipedia.org/wiki/ZIP_(file_format)#File_headers mentions "compressed size" and "uncompressed size".
I'm fuzzy on the terminology here. Is there a difference between compression level, and compression ratio?
 
Makes sense to me. If that information isn't needed for decompressing, why store it? Most people aren't interested in that
 
Unfortunately we are because we can't know a priori if it's about to consume the whole disk space of the docker container and crash. That's a support ticket :/
But that link to wiki has spurred me on to find this. Thanks!
 
@Kevin I think "compression level" is the user telling 7zip how much effort it should put into the compression, and "compression ratio" is compressed_size / uncompressed_size
 
2:35 PM
en.wikipedia.org/wiki/Deflate#Duplicate_string_elimination says "Searching the [text that will be compressed] for duplicate substrings is the most computationally expensive part of the DEFLATE algorithm, and the operation which compression level settings affect." That would partially explain why you can't tell what compression level was used just by looking at the compressed output.
You can examine the stream and see that it identified N duplicate substrings. But this outcome could happen when the input has few duplicates, and the algorithm tried very hard to find them; or when the input has many duplicates, and the algorithm did not try very hard to find them.
Hmm, I wrote "partially explains" because I thought there had to be another piece of the explanation, but I think this pretty much covers it
 
 
3 hours later…
5:33 PM
@ParitoshSingh o rly? :P
a = list(range(30))
print(a[20:35])
 
yeouch, that's below the belt :P
i shall amend my statement to say that the slice will cap out at 15 elements then
 
Probably a good job I wasn't around during the discussion to throw the spanner. I don't think it would have helped anyone in that case tbh
I've spent an inordinate amount of time today trying to work out how one of our tooling libraries can pull files from S3. The guy who wrote it now refuses to maintain it because... reasons, but aggressively promoted it to all new starters. I really don't want to use it but everything it does it opaque in the extreme. I have 8 tabs open trying to track that one bit of functionality
At one point there was talk of it being open-sourced. I grabbed my popcorn for its debut but then that idea was pulled. I would have loved to see it "float" on the open market. Sadly the guy that's started dismantling it into sane chunks will be leaving soon :(
I'm just going through the new package that he's working on (the one that got the main one pushed aside). It's got some golden, completely undocumented nuggets
from inv_opt.models.base import BaseAliasModel


class SourceTypes(str, Enum):
    redshift = "redshift"


class RedshiftConfig(BaseAliasModel):
    schema_: str = Field(..., alias="schema")
    table: str

    class Config:
        frozen = True
 
5:58 PM
Most useful enum I've ever seen
 
6:09 PM
I used v1 of this library and it was three scripts. Absolutely nothing has changed about its functionality but it's now at >10k LOC. All it does is give either a rolling window or an ever-expanding window looking at the error between your forecasted sales and actual sales
 
I wouldn't mind if it did something custom, but the KDE applied is imported from either sklearn/scipy and occupies maybe 4 or 5 lines of that code when it finally calls it. I don't know where it calls it, of course, because there's somewhere in ~100 modules
 
I suppose I could grep it, but there's a cathartic property of just opening files and shaking my head each time at how convoluted everything is
 
I hope you're also aware of git grep, saves a lot of trouble
 
6:16 PM
I could get at it if I really wanted. The guy who wrote this is the one that constantly shoots down my push for flask because nobody could possibly understand HTML/JS. Nobody can understand this library properly, so just perusing it reminds me that I really needn't pay any attention to his nonsense. It makes me feel better
The best parts are where he just straight-up renames numpy functions. There are "factory" functions that literally just return a new alias for the base numpy library API with a new name from a dictionary. That's it. I was trying to hunt an example down but I've started getting bored reading the code
 
7:17 PM
@Harshvardhan your website is by far the most impressive I have seen that's backed by R (or at least of those that I know are backed by R)
 
7:32 PM
stackoverflow.com/questions/72915814 List comprehensions are kinda scary sometimes. A question can simultaneously be answered by a one-liner, and need more focus.
@Hakaishin if you really want dry runs to be the default behaviour, my proposal: name the command in a way that implies that; make it incapable of actually doing the change; move that behaviour to a separate command; give that command a name which is the original name plus a suffix (so you won't hit it accidentally tab-complete it); optionally also give that version a --dry anyway
@MisterMiyagi I always struggle to find this essay for some reason. I think it's because I keep thinking it was by C. A. R. Hoare instead
 
"There is a smallest natural number" -- funny, I was reading a StackExchange question just the other day that mentioned an apparently long-lived controversy about whether 0 is a natural number.
> Inclusion of 0 in set of natural numbers;
This was included upto 2015 in advanced level mathematics in my country but now they say not to include it. When I inquired the issue from a Cambridge examiner , he told since there is no agreement regarding it, questions not asked related to that issue in their exam papers.
 
there are two commonly used definitions; regardless of which you choose, there is a smallest value.
 
6
Q: Importance of standardization of definitions of mathematical terms

Janaka RodrigoDon't we need to use internationally recognized standards in defining mathematical terms since differences in definitions play very much important role in finding a unique solution for a given problem and from where we can find those definitions ? Here are few examples Inclusion of 0 in set of...

 
I was taught to use "natural number" for one and "whole number" for the other, but I can't remember which term was intended to include zero.
which is why I instead just say "positive integer" and "nonnegative integer"
 
Clearly there are two smallest natural numbers, that each exist only half the time :-p
 
7:44 PM
surely it is something more like quantum superposition?
 
Infinite sets of numbers are an abomination anyway. All you need in programming is one and zero.
 
One and zero? So wasteful, haven't you heard of unary?
 
Zero isn't wasteful, it's carbon-neutral and contains no CFCs
One is hella wasteful, but since it's present in both binary and unary, it's a wash
 
I don't think that maintaining 0 is any different to maintaining 1? Too much hardware stuff for a Friday night
My understanding is that it still has to scan the state, like, constantly. Maybe it's more effort to maintain a 1 but that will pale in comparison to the general energy use?
<knows little-to-nothing>
 
7:59 PM
Electricity is black magic as far as I'm concerned
 
i.stack.imgur.com/MpX2g.png I feel like this really drives home the point that beginners really do conceptualize return as "returning a variable" rather than a value
 
please don't post screenshots of code :P
 
You mean some beginners?
 
especially code like that
 
some beginners, yes. Enough to explain why I have been ranting about it, and what I am planning to write up
 
 
1 hour later…
9:08 PM
I can't run that but surely assigning the result of shuffle is broken because it works in place
There are dupes for that.
 
I would say that is actually the only thing that isn't broken here. OP renames card_deck to shuffle; both are global names for the same now-shuffled list, which suggests confusion but doesn't actually cause a problem.
The problem is that OP appears to expect e.g. return foo to cause the caller to have a new local variable foo after calling.
 
@KarlKnechtel on a more philosophical level; how much do you think needs spoon-feeding to newbies vs. Having breadcrumbs for them to follow? How did you learn programming?
 
I learned programming as a child, more than 30 years ago; so I really cannot say very much about what the pedagogy actually was, how good it was or whether it would be applicable to older students or modern languages.
 
Pedagogy?
 
my basic conclusions about pedagogy so far:
1) everything worth teaching has a set of fundamentals that - for best results - need to be learned in a fairly specific order, without taking into consideration the student's opinions or goals
1a) this includes certain meta skills (for programming: reading error messages, not writing too much code at a time)
2) almost everyone gets this order wrong
3) most teachers either inappropriately discourage experimentation completely during this period, or else allow too much unrestricted experimentation / offer too little guidance
pedagogy = theory of teaching, basically
or method of teaching
I think the question of spoon-feeding vs. breadcrumb-trailing newbie question askers is a bit of a red herring. The issue is: the right way to solve the problem required action before they got to the stage of asking terrible questions on stack overflow.
A huge fraction of these questions can't be asked by a really well taught beginner. Partly because they will be anticipated and pre-empted, but mainly because they result from misconceptions that won't form in the first place.
 
9:23 PM
You can thank the explosion of online courses for that?
 
- mm, that is too optimistic. Students can appear to understand something (and move on to the next step) without actually understanding it.
oh, defintiely. To say there is no quality control would be an understatement.
 
"Too optimistic" from you is really something. I admire your perseverance:)
Even with our staff intake, I do try to explain why things are happening in the way they are before I give a solution. I've only been in the game for 7 years so there are gaps for me, too. But a good number are totally unresponsive to that info
 
"staff intake"?
 
New hires. Mostly grads from astrophysics or something
"Pass a dataframe to this method and.. it just works!". God forbid it doesn't
 
9:46 PM
does your hiring process not involve selecting for people with debugging skills?
 
 
2 hours later…
11:45 PM
@KarlKnechtel I miss being able to actually run code in interviews I give...last job had tooling for it, current job does not.
had a question that tended to result in slightly buggy code, making sure the candidate could debug that was useful.
 
then you can shake your fist if the candidate writes bug-free code
 
haha...it happened from time to time
 

« first day (4283 days earlier)      last day (672 days later) »