@roganjosh I think Don Knuth wrote a paper on it. It's pretty straightforward. Let D be defined as the set of all dogs on the beach B. If any dog in D is seen taking a dump on B, remove that dog from the set D and place it into the set T, also known as the trash. Perform this as a loop until either T is full, D is empty, or B is closed.
Well I want to incrementally build my code. I know lines 1-100 work but I dont want to run 1-100 everytime I want to test something. I like how in the interpreter interactive I can just redo the steps I want without having to rerun everything.
Yeah basically in a Unix system (Mac, Linux) if you have a python file and you want to add a line to it but you're stuck in terminal you can append a line of code to that file by running: echo [some line of code] >> [file.py]. Hope that helps.
And you can have multiple tabs of your command line open to make the workflow really simple.
@AnttiHaapala no errors! I did make 1 bad submit on part A because I accidentally forgot to change test data back into real data, but it was more a dumb mistake than an edge case
I was using the automated submission and ran the script but it submit the answer for the test case, whoops :D 60 seconds penalty
@AndrasDeak huh, well, I didn't flag it if that's what you were thinking.
Did anyone have solution for this DatabaseError: ODBC error state: 28000 native error code: 18456 message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user
I think the coding for today was a lot of fun, if a little tedious. At least i was lucky and didn't have to fiddle too much with off-by-one stuff, just mixing test- and submission-settings.
(I use Windows) I just found out that the python path that I use for Anaconda is not the same as the python path that I use for cmd; is this something I should change?
@alphacapture If you want you code execution to behave consistently, then yes.
But I'm not on windows, so I wouldn't know how to manage envs
Oh, just in case I wasn't clear, the environment should be set project-specific. You don't want one and the same python environment for all projects on your workstation.
Is there any reason to prefer changing one path vs the other? Right now my cmd python is in (a few folders nested within) my user's %APPDATA% folder, while my anaconda python directly in the folder containing all of anaconda3.
@alphacapture I can't say for sure if it's different on windows, but what you say doesn't make sense to me. Do you know about virtual environment handling?
Hola! Does anyone know how to create a type with typing that can be one of two str values, for example, only 'Cats' or only 'Dogs'. Something like: T = TypeVar('T', 'Cats', 'Dogs') except that this won't work because ```TypeVar`` requires type args.
That awkward moment when the OP picks the worst answer out of the bunch and resigns themselves to copy/pasting error-prone code hundreds of times :/ stackoverflow.com/questions/53670209/…
Putting the questions aside, is much being said about the answers that are coming out recently? I suspect the effect I mentioned actually does exist; new coder sees broken answer that resembles their initial code so they take that on the assumption it's correct.
Something has gone really wonky with my mobile view on the upvote comment button. It seems that some are randomly highlighted in blue even though I didn't press it, and it doesn't seem to have any pattern to which comments have it that I can see
A mixture of both. I agree with you that there is an issue of people jumping to things like itertools for newbie questions which is nonsensical IMO unless you prepend a solution they could hope to grasp. The other part of my question though is that there's all this fuss about low quality questions but I'm increasingly seeing very poor answers coming out
And I think they actually carry more weight in terms of issues for SO than the noise of poor questions
A bad answer, once accepted, is difficult to deal with, especially if the poster isn't all that invested to respond to feedback
The last couple of weeks put me on the main feed for an unhealthy amount of time while twiddling my thumbs. Thankfully I've finished debugging the long-running parts so I'm kept busy again :)
It just occurred to me that since implementing pathlib instead of strings for filepaths in my app, I am now using Path objects as dictionary keys. Assuming I'm not planning on altering those Path objects during the runtime, is this something that could end up biting me in the butt, or is it just in general a bad idea?
@roganjosh I appreciated being enlightened about such features, even when I was (more of) a newbie. There's a difference in saying 'use this itertools function' and 'here's how you do xyz by hand, which is pretty much what this itertools function does, but itertools is more efficient' - but to me that's the difference between a functional answer for the OP to drop into their code, and a good/complete answer on SO which benefits the community and educates OP rather than simply fixing OP's issue.
Yes, please don't think I was suggesting that you shouldn't be showing (potentially radically) different approaches, but there are people that literally just dump those and move on. The best approach would be to give something that you hope is comprehensible for their level and then give the alternate approach so that they can follow up if they choose
@toonarmycaptain it's probably not outrageous to say that 90% of my knowledge originates from SO exactly through that approach, either to my questions or in good answers to others. It always prompts me to follow up with my own research.
hi, say i have a string which has date and number in it, and a list of strings (len 100), now what i am trying is to find which among the list of strings is the best match for that..(not in terms of date and number but what it represents).. i have looked at nlp but its very broad for me (n i am new to this)..can anyone point me in the right..thanks direction..thanks
Good morning! Quick question....is it possible to write "age_df = df.columns[df.columns.str.startswith('AgeAt')]" but add "and not endswith('Flag')"? I've tried "age_df = df.columns[df.columns.str.startswith('AgeAt') and not df.columns.str.endswith('Flag')]" but get a ValueError
A general, but related, point. If you think .str methods in pandas are vectorized, they're not. I have seen a few cases now where list comprehensions run faster. I don't know whether speed is a concern but keep it in mind.
@iamklaus if I thought I could, I would have had a go by now :) Even when the room is quiet, during peak hours, plenty of people will be paying good attention to what is asked
I really don't understand what you are asking. I suggest that you take some time to think through your problem and figure out how to explain it to others in a clearer way.
It sounds like your question actually has nothing to do with the date and number you mentioned but more about determining the meaning of two sentences.
It's just not helpful for people to say "no, sorry, I can't help" but it doesn't mean the question is ignored. In this case you should look into providing an MCVE because, while the answer is probably outside of my field, I also don't properly understand the question
I think the additional whitespace isn't helpful visually, and given that the usual format without the type hint doesn't use spaces, I wondered if my opinion was shared.
I'd also prefer `def greeting(name: str): -> str` to `def greeting(name: str) -> str:` with the type hint after the colon, but I haven't played with typing return values yet.
Unless I'm bein very naive in my thoughts on a Friday, pretty much every other type of argument is to be operated on rather than being being used to operate on something else
I'm afraid if I continue to close large questions like this, I'll keep receiving more knee jerk reactions like this and this, followed by more mindless downvoting.
I would like to think that being the 10th top user of all time in the tag gives some credit to the actions I take in this tag, but not everyone would share the same opinion
@piRSquared yes, by one user who happened to be the OP of one of the other larger posts I closed (this one). The contents of the answer here are in my canon as well. But I'm having second thoughts. Did this closure make sense?
Again, high probability match. Not perfect, but it makes sense as a dup. That said, you still have to decide if you want the headache. Maybe you're ok with it (the headache that is) but the headache will come.
I've always found it funny how the line is drawn based solely on the number of upvotes even though meta explicitly encourages it it most threads I've seen: case 1, case 2 (by @wim, actually), case 3 on MSE; while this one suggests seeking input.
It is and always will be one big fat fuzzy mess. We'll be more successful navigating these issues by recognizing that we are all human and behave as such. Expecting everyone else to respect a set of rules that we think are right will only encourage resentment.
I guess that's hard to define accurately, and may be also subjective. But when I'm determining quality I'm thinking "does it work? even with edge cases? is it readable and easily understandable? is it making good use of the readily available stdlib or 3rd party tools?"
I came across some 100 questions yesterday that were merge questions, and about 20% of them were asking for minor variations or additions, like cleaning up columns, dropping duplicates, or some kind of aggregation after. I did not close any of them. Only ones that were fully covered by cases in my post have been hammered.
I did a lot of similar such cleaning up on pivot questions last year after piR's pivot canonical had come out. I guess it's not so much a conflict of interest if someone else besides the OP does it :D
It is identical work. But perception is different for sure.
@Arne I have the same question. After seeing it, I wanted to jump right in. But I'm afraid of wasting my time and effort. If it is a high probability of being a robust and stable way to package, I'm all in.
And @wim are we still waiting for packaging cannonical (-:
@Arne Fair question - I think you'll be ok, since Poetry uses the standard pyproject.toml file to replace the usual bunch of junk files. See PEP 518.
It does use a custom [tool.poetry] section in that file, which would mean you can not trivially switch to a different packaging app, but I don't see that as a massive deal breaker.
I enjoy using that piR question as a dup. It's one of the most comprehensive answers I've seen on the pandas tag. (And questions about pivoting come up so frequently)
But I'm always surprised at how difficult it is to find good duplicates for seemingly simply and frequently asked questions. Yesterday it took me about 10 minutes to find a duplicate for someone wanting to just .groupby().cumcount(), and I felt like the one I found was far from being the best post to tag.
What exactly affects google indexing here? I've never seen that coldspeed answer, and I always struggle to find PiR's canonical. It seems that the age of the post wins over recent activity?
I could swear to god I've just had "Not intending to sound rude" removed from a comment suggesting the OP read tutorials on working with files, and that part is gone
And I know it's noise, but since I've been warned about being rude, I now caveat stuff
But being warned about being rude and then getting caveats about my actual intentions also removed by mods.... unless I've hallucinated what happened here, that isn't right.
@roganjosh the welcoming wagon retrospective was quite interesting in that regard, with how new users actually see very little issue with rudeness as it is perceived by SO staff
Finally got round to looking at Martijn's offering to tear holes in. It's a little crushing when the guy makes out he doesn't know the library and still produces that kinda code :P
I need to know if there is good way to write logs in for Flask app at each component level, Right now there is this functionality available but does not seem to do work well: dpaste.com/2E6EZ6Z
Anyway, I'm backing out of that discussion because it's only going to come across as me pulling teeth from you. Stating problems, and not asking questions, just makes things a bit difficult because I honestly don't know what to suggest in this case. I find logging quite complicated/unintuitive, I guess, so this will probably only serve to confuse me more.