« first day (3752 days earlier)      last day (1179 days later) » 

1:35 AM
@MisterMiyagi @CoreVisional: Just do for element in lst: .... Unless you actually need to also know the index of element (e.g. for printing message), then the best idiom is for element, i in enumerate(lst): ... See this answer
..in particular we don't needlessly declare iterators like C++/Java would. And try to avoid the special case where you want to insert/remove from the list How to remove items from a list while iterating?
 
Hey, is doing bisect.insort() better than having the whole list and calling sorted() at the end? In terms of time/space complexity.

Just curious
 
Did you test it?
 
@Dsafds you mean building a new sorted list with n calls to insort?
 
@AndrasDeak yes
 
What roganjosh said. And look at the respective time complexities.
And ask yourself why sorted wouldn't call insort n times if that's better in general
 
1:49 AM
@AndrasDeak I was talking about time complexity. Is there a diffrence between the two? If so which one is bigger
this is for interview purposes. not research
and curiousity
 
@Dsafds you have to research none the less
 
@Dsafds I think there's a tipping point where this just descends into stupidity and it'd be ok to call it out
The more I hear about programming interviews, the more I despair :'(
 
@Dsafds bisect.insort is better if you have a already sorted huge list and want to insert a new element, if you already have a long list and just want to sort, you can insert and then use normal sort
 
Have you tested/timed this, by any chance @python_user?
 
2:05 AM
no ,but I asked myself this for the same reason as Dsafds (interview purpose),let me see if I can link the page that told me this
 
It seems to me that vague figures are being thrown about like "huge". I'm just curious
 
this is the site , now how accurate it is I cant vouch for that but I use the site regularly
"This can be much more efficient than repeatedly sorting a list, or explicitly sorting a large list after it is constructed." is what the site claims, in case anyone doenst want to open the link
 
So, ultimately, it needs to be timed
 
I just took their word (which I shoudlnt) but during interview preps timing everything is not possible for me
but yes, it must be timed
 
I'd "love" to see my customers' faces when I explain that I got an O(N) solution but they'd need to wait an extra 3 secs over the heuristic
 
2:15 AM
do customers understand O(N)? in a place I used to intern all they cared was make it run without it failing, but we weren't dealing with huge data
 
bruh u dont need to time it for interviews. If you can give a reason to your complexity its fine.
 
no, of course they don't understand it
I was being facetious. I think it's sometimes silly that companies focus on this kinda thing in interviews, when the reality is so different
 
@Dsafds I have linked the source of my claim, up to you to accept or deny the claim I made based on that
@roganjosh this ^, but with more and more code challenge sites people are beginning to think so
I mean yeah O(n^2) bubble sort is bad, but no one will even write their own sort, and stdlib sort is usually all they need
 
@python_user the pinacle of stupidity (IMO) is that this update is even a thing:
Dec 18 '20 at 17:36, by PaulMcG
Job hunting update - I was allowed to retake my failed hackerrank coding test, followed by a 7-1/2 onsite-interview-over-zoom, which included 2 more coding tests and 2 "find the bug in this broken system" tests. I finally wore them down and they just gave up and gave me the job. Start Jan 4.
I keep finding pyparsing everywhere
But... yeah, best get the inventor to pass an online programming trial
 
yeah I remember telling Paul the very thing you said, before or after this, and Kevin and Paul had something to share on how interviews worked
Dec 7 '20 at 16:31, by python_learner
tbh you have pyparsing that is used by some top level orgs, why would they still bother you with DS / Algo?
I have grown to a point where I can use my own history in chat, laurel
 
2:23 AM
Fair question :)
And neato. I'll grant you a +1 on your Chat Effectiveness skill :P
 
:D melon, but grinding leetcode for interview prep is something that was not so effective for me, I could have at least learnt a new language by then
which will definitely be a lot better than solving a binary tree in O(h)
 
 
6 hours later…
8:29 AM
will deleting my un answered comments lead to some kind of ban?
 
@python_user comments on questions/answers? highly doubt it....comments are ephemeral and always treated as such.
 
comments on other questions
I read somewhere that deleing answers will lead to answer ban though I am not sure how or when it kicks in
 
8:56 AM
Comments are not treated the same as questions/answers. Comments are important to drive towards better q/as, but otherwise are treated as unimportant data. Deleting huge swaths of previous answers will probably get looked at, but if it's bad quality content, no one will care. OTOH if you start deleting answers that have upvotes, that means you're removing quality content from the site, which means it should stay.
 
thanks, I only delete answers in cases where OP really cared about fixing their code and not in an alternate / better approach I suggested
also these answers have no more than 2 upvotes :D
 
You shouldn't do that. This site doesn't exist to answer one person's questions for them. This site exists to create a repository of questions and good answers to them. While the OP might only care about their single piece of code, people who find the answer later give zero shits about OPs code and care about theirs.
 
I was told that but these are usually very specific questions like "I have json/list of X structure" need "json / list of Y structure"
 
sure, most questions don't become canonical/important, but people may still land there regardless. After all, if a question isn't a dupe (or the wording is different enough from a dupe) someone else may also ask the question in that same way.
Basically you should never delete your answers unless they actually contain bad information (or I guess if they contain duplicate information).
 
that is true, compared to when I started answering, now I dont go spend time for a low effort post, so that pretty much avoided the deletion
 
9:04 AM
@python_user I decided a long time ago that I'd rather be hired for what I am than what I could be. This makes interview prep a breeze, since I am prepared by being who I am. and also rules out places where they place too much emphasis on code tests.
 
@holdenweb this I can relate to an extent, I remember having to google "python interview questions" when I was seeking internships and after having worked with python now I dont need to do that anymore
 
I should add this was before the smile curve was on my side.
 
@holdenweb "and also rules out places where they place too much emphasis on code tests." it should be understood that this is a position of privilege that not everyone can afford.
 
I do understand that. And today's economic conditions disadvantage beginners, since jobs overall are scarce and employers can be picky. But anyone who works in an Amazon warehouse could tell you that's the way the world works at present.
 
yep yep. Also it's strange to me just how regional interviewing practices are. Here on the US west coast, I don't imagine that any job I get in the next 15 years won't have a coding test as part of the interview....
 
9:10 AM
It's been known for some time (centuries) that a plentiful supply of labour depresses wages and allows discriminatory and exploitative behaviours by employers. Which is why I stayed mostly out of the corporate world in my career. I chose to engage with it to earn a living, but not to be part of it, again reflecting a degree of privilege not available to many.
@alkasm I've started and run businesses rather than work for the man, but today's conditions appear far more difficult than those I faced, economically, and education is significantly worse and more expensive.
Just vow not to use testing when you get to be the hiring manager.
Having said which, Holdencorp does currently use testing for some positions, but mostly as a way of eliminating obviously unsuitable candidates early in the process. So I got in by taking a test. I agreed to do this only because the opportunity ran so parallel with so many of my interests and aspirations.
 
Like the original intent of fizzbuzz---it's not a problem where you really showcase prowess. You just show that you can program.
 
the new thing after testing is a "take home" project, I was once offered one but I later chose not to with the college work I had
its not that common at least where I am, but that is something that is also not great, I have heard reddit posts saying its basically a prototype for the companies new ideas
 
I've done one of those, to be quite honest it was a really fun problem, and I ended up getting an offer from the company.
And yeah, people like to say that on Reddit. In reality, I cannot imagine that ever being a good idea.
It's probably illegal, you don't write production-level code in one of those, and just writing the code to a well-specified problem is the easiest possible part of every programmer's job.
I highly doubt it really ever happens (though I wouldn't say it never happens)
 
9:26 AM
have to take it with a grain of salt I guess
 
From my experience it comes from good intentions. People would like to see you code but know that 1) one hour is not enough time to assess your skill, 2) people don't always do well outside of an environment they're productive in, 3) some interviewers might give you more information/less information depending on their whims, 4) coding on a whiteboard is not natural, 5) lets you look up documentation, ...
overall it's much more similar to a "normal working environment" than a whiteboard leetcode problem. And it is inherently more fair than those. OTOH they usually require a decent amount of time, and people will spend a lot more time polishing that code/overthinking it than they generally would so there's still some sort of imbalance..
 
they are all very great points, these take home projects simulate what you may work on, environment and the tech
 
comma.ai does 2 day paid micro-internships for candidates they like, and will give them an offer afterwards if they want to.
that's their interview process.
 
thats straightforward
"The best way to get an internship with us is to submit good PRs to projects on our GitHub"
 
that way your time isn't wasted, it's paid, you get to actually see what it's like to work there, and people see what it's actually like to work with you.
 
9:33 AM
fair enough, you still get to put that in your portfolio
 
Yeah if your company writes a lot of OSS, then that is a pretty awesome way to be able to see people's potential.
 
start ups are more relaxed and are modern when it comes to hiring, as opposed to the well established ones, my interview exp with startups have always been good
 
9:49 AM
@alkasm Pretty much.
Our test format is pretty straightforward (though other are using DevSkiller). We book a 2-hour slot, and at the start of the test we invite you to collaborate on a Github repo we've cloned just for your test. We see what you can do in two hours.
The repo has unit tests in it, one of which already passes. You make the rest pass. We also have adiitional tests we apply after the fact.
 
That's a cool strategy.
 
It doesn't take up too much a candidate's time, and they can do it where they're most comfortable rather than on a whiteboard under scrutiny. Many of our team are remote anyway.
 
The problem I generally have with the people I interview is going back and forth between "standardizing" the interview while also trying to interview people with specific, niche skills (computer vision). On one hand, there's gonna be some people better at the science aspect than the engineering, and there's different skills people will have in either of those that aren't necessarily intersectional.
Whenever the field gets into more specialized territory, really hard to make a bulletproof interview strategy.
At least from my (very limited) experience.
 
10:05 AM
Accept that not all hires will be successful, and have a humane policy for letting the poor choices fail early and leave. It's too stressful to aim for an impossible target, and unrealistic to boot. The number still left after 12 months employment would be a sensible metric.
This makes interviewing rather easier. It all takes the time of other team members for interviews, etc., so there's a cost-benefit balance to be struck too.
 
 
2 hours later…
11:47 AM
Agree with the discussion above - that sounds so much more sensible than doing a leetcode challenge
When I applied to Tesco as a contractor, I got given a coding challenge to do for a week that was somewhat around heuristics for solving a similar problem. It could never be construed as doing free work, it wasn't super prescriptive in how it was solved and I just had to submit my script and talk through it. As it happens, I actually misread the mathematical notation for one of the constraints and solved for the wrong thing, but still got the position (phew!)
 
12:36 PM
I don't understand why the pigeons need to be on LSD for this thought experiment but it has definitely made the whole thing more interesting
I think in all my analogies going forward, every living object will be on some kind of hallucinogen. If anyone questions why, I'll just stare intently and say "because it's critical for the setup"
 
 
2 hours later…
Sam
2:59 PM
Anyone familiar with this: making an environment using virtualenv and when using pip to install packages, pip is linked to a different version of Python? i.e. not the activated virtualenv environment :'(
 
Can you show a screenshot of the terminal?
 
@Sam why aren't you using venv?
 
Sam
@roganjosh Sure 2 secs
 
To show what you're actually using. I suspect, though I'm not great with Linux, that you might activate a virtualenv but then use pip3 or something, that isn't recognised by the current terminal and actually points to the system installation or something
Something something. That.
 
Sam
@AndrasDeak I've always used virtualenv as I'm quite fond of the virtualenvwrapper
 
3:05 PM
I've only had venvs use pip as the one corresponding to the venv
 
I've only had the same with virtualenv so that's why I'm curious to see the screen
They should be able to run which pip and which pip3 with the environment activated, right?
 
Sam
Ah I think I see what's going on
$ mkvirtualenv tst
New python executable in /Users/sam/.virtualenvs/tst/bin/python2.7
Also creating executable in /Users/sam/.virtualenvs/tst/bin/python
Installing setuptools, pip, wheel...
done.
 
2.7. Nice.
 
Sam
So its being created with 2.7 (default for Mac)
Whereas it should be 3.8
$ python -V
Python 3.8.0
(tst)
something has gone bang in virtualenvwrapper it looks like
Apologies folks
 
Thanks :)
 
Sam
3:09 PM
@roganjosh Note my intention is not to use this version ;)
 
No worries. Where did mkvirtualenv come from?
 
@Sam I guessed as much :P
 
Is it a bash script somewhere you can look at, or a binary?
e.g. which mkvirtualenv
 
Sam
It's a handy abstraction over `virtualenv`: https://virtualenvwrapper.readthedocs.io/en/latest/

Yup - I'll take a look at the scripts, looks like its always pointing to 2.7
 
OK, but how did it come to be on your system? Any chance your pip install virtualenvwrapper used the wrong pip?
apt will also give you python 2 by default, python 3 packages are called python3-*
but using pip for everything is a lot more reliable in my experience
for instance you could have multiple python 3 versions which is not the case with apt-installed packages
 
Sam
3:12 PM
@AndrasDeak Installed via pip3 so it's on my global Python3 install. Now I can see the offender I can dig into it a little deeper.
 
OK
if you want to be extra sure, always use python3.8 -m pip install
 
Sam
Curious though Andras, why venv over virtualenv? I always assumed it was preference.
 
@AndrasDeak I wonder what that does if you have 3.8 as system python and 3.7 in a virtualenv?
 
that's my main reason, as it's always worked for me, but I don't have any non-trivial needs
@roganjosh what I wrote will always use 3.8 because a 3.7 venv will only define python3.7
if a 3.8 venv is active it might use that
 
3:15 PM
Ok, so I'm not sure that's "extra sure", just better?
 
(py3.8_main) $ which python
/home/user/virtualenvs/py3.8_main/bin/python
(py3.8_main) $ which python3
/home/user/virtualenvs/py3.8_main/bin/python3
(py3.8_main) $ which python3.8
/home/user/virtualenvs/py3.8_main/bin/python3.8
 
Well, I suppose that's equivalent to "extra sure" in many ways
 
@roganjosh it's extra sure because pip can still mean a lot of things
if you're not inside a venv then your best bet is using python* -m pip
using pip instead of python -m pip is how you get sopython.com/canon/131/… (well not that, but a bunch of "why is X not installed if I just installed it?" questions)
but if you're inside a venv then it doesn't matter
But since Sam was installing a package to create venvs with, I assumed that they didn't have an active venv when they were installing virtualenvwrapper, hence my suggestion
 
Sam
Looks like their is an equivalent wrapper for venv which is great for lazy people like me: pypi.org/project/venvwrap Gunna swap over to venv and nuke what I have currently. Thanks for pointing it out Andras.
 
no problem
 
3:24 PM
I like how it's the lazy tool that resulted in complications and a question here :p Total time-saver :)
 
Sam
It works a dream.... right up until I do an OS upgrade
 
"60% of the time, it works every time"?
 
Sam
Absolutely
Maybe the easiest thing to do is stick with 2.7. I wonder if anyone still uses that....
 
@Sam that seems like something someone threw together. Version 0.1 with 0 stars, background says "I didn't know enough about venvs (or bash scripting), so I spent a weekend learning/making this project. Its generally inspired by virtualenvwrapper. Instead of wrapping virtualenv, these functions support the built-in python venv. I think you can use virtualenvwrapper to wrap venvs since they're almost equivilent, but just using someone elses code means I learn less."
This doesn't necessarily make it bad, just a heads-up that it has different support than virtualenvwrapper
 
Sam
There must be some big orgs which still use python2
 
3:27 PM
There are some big orgs that still run on spreadsheets. I can't tell you which, but you'll have to take my word on that
 
Sam
I can tell you
NHSX
 
I can mentally list 4 more with multi-billion revenues. I can also tell you that they don't want that any more :P I think it's best to leave 2.7 behind
 
Sam
3:42 PM
They don't want what? Python2 or multi-billion in revenue :D
 
Lol, I walked into that @Sam, I'll give you that :)
 
@roganjosh op asks how to edit a question and you suggest and they delete :p
 
@python_user welcome to main
It's not a big effort on my part; [edit] (without the backticks I've used here to format as code) will auto-expand out into a hyperlink to the edit menu for their own question
 
does it? I didnt know that, then its not much work for you
 
Well, I say it's not much work, but I do actually read peoples' problems before commenting. So, it's still a waste of mental energy
 
3:57 PM
they say its not welcoming to new users, when its the regulars who have to deal with it
 
I'm afraid you've somewhat missed the bus when it comes to it being a debate topic and not a prescriptive rule. But this might be helpful
 
thanks for the link, there is so much I didnt know
 
5:07 PM
is there a common name for a dictionary in python? naming a list or tuple or string as seq, so for a dict that would be?
 
I'd argue that seq is a poor name, if it's considered a "common name"
 
I am asking or a throw away script, I usually name them seq for sequence, I just want something to name a dict
 
5:22 PM
@Sam Still in use at Holdencorp.
But we're not a big org.
@python_user Choose a name that reflects its purpose. A dict of WHAT?
A dict of entries can safely be called entry_dict, but if you dont have an entry_list as well call it entries.
Unless, of course, you enjoy reading code that doesn't tell you what it's doing ...
Worst case, call it d then use your IDE to refactor the name - it saves a lot of time for a crappy typist like me.
Fallback testing for the doubly-mirrored 1.5 TB RAID-1 array is underway. I unplugged a drive and observe the system is now rebuilding the spare volume. With four drives I feel a bit safer from loss than before if this works. And the read speed should theoretically be 3x(disk speed). Assuming the USB-3 pipe is fat enough.
 
@holdenweb I named it d, but wanted to know if there was a common name in cases where you dont care, eg : a helper function that takes a dict as an arg and will return if a key is present in a dict or not, (lets assume some_dict.get(key, fallback) was not there)
 
If that's all it does, I see d as a perfectly fine name. You can always appease the purists with a type annotation on the dict argument :-)
 
5:39 PM
typing is something I need to get used to, but thanks for suggesting the right action for what I asked
 
For small pieces of code (the ideal kind) naming can be a bit meh, but remember: the person who will have ti understand this "throw-away" program is most likely you. So do yourself a favour and think about naming.
 
sound advice :)
 
Looks like the rebuild of a 1.5TB disk will take 6 hours. Now there's a good readon to use a hardware RAID controller when available!
 
 
2 hours later…
8:07 PM
I was looking for something else but decided to give this video a few mins... and what? "web scrapping" isn't just a typo; there's people making educational videos mentioning it? youtu.be/csG_qfOTvxw?t=146
 
His pronunciation may be "poor" (i.e. not native English) but he knows how to spell it fwiw.
 
Indeed, the spelling is correct, but I think the vocal phrasing was unambiguous (especially as I've listened to him up to that point mentioning different terms). It's just curious to me that it really does seem possible that there are two terms in use now
 
Sam
8:23 PM
@holdenweb I'd of thought it would of been the huge organisations on older versions rather than smaller. :)
 
The video does get more fun - "for sure you'll be using Pycharm, Jupyter or Spyder". I have failed :/
 
9:04 PM
Cbg guys, is it safe to say the comparison of a string and tuple will never return True?
 
@CoolCloud if you mean == then yes
 
Yes I meant that. Thanks !
 
 
1 hour later…
user12582392
10:54 PM
 W1 = parameters["W1"]
 b1 = parameters["b1"]
 W2 = parameters["W2"]
 b2 = parameters["b2"]
 
user12582392
that comes from an object like this: parameters = {W1:"hello", W2...}
 
user12582392
is there any shorter way to extract the keys?
 
user12582392
In javascript, we do: {W1, W2, b1, b2} = parameters
 
I don't think there's a direct analogue
 
you could only do something like W1, W2, b1, b2 = [parameters[key] for key in 'W1 W2 b1 b2'.split()]
the fact that this works in JS is the fault of JS ;)
 
user12582392
10:58 PM
it's very handy
 
user12582392
I'll keep it long then, thanks anyways
 
The temptation here is of course to start playing with globals(). I hope raising that hasn't given you ideas; I mention it to explicitly state that it's a bad idea
 
user12582392
I don't know what's that
 
Keep it that way :P
 
@Minsky good call. There are a lot of non-solutions and deadly sins on this thread (linking the appropriate answer): stackoverflow.com/a/18090853/5067311
 
11:00 PM
But on a serious note, if you search enough, you might find it recommended, so I thought it best to state that it's not a good approach at all
 
user12582392
@roganjosh thanks
 
user12582392
@AndrasDeak interesting
 
11:25 PM
could someone with open/close vote privileges reopen this one? it's been updated with the necessary info, for nearly 2 days now stackoverflow.com/questions/65837380/…
 

« first day (3752 days earlier)      last day (1179 days later) »