@AndrasDeak Cool! I just had a look at the code... My Python coding style has improved a little since 2011. :) I've converted the program to Python 3, but there are a couple of mysterious lines that could do with better commenting which I'm currently trying to decipher. It's not a big program, but I would like to make it a little more readable. The majority of the variable names are one or two characters. :oops:
In the mean time, here's the original article that I used to extrapolate my code from. craftster.org/forum/index.php?topic=341241.0 As you can see, the crocheted spheres look pretty good.
This list slicing question was closed as a duplicate of a more broad question that includes slicing generators. Is it worth reopening, or is the question too useless to matter?
@Aran-Fey The dupe target is too broad, but I guess it's nice to mention islice. I don't think it's worth re-opening, and it already has adequate answers of its own. FWIW, the OP is still active.
I have absolutely no idea how to do this, and therefore don't know where to ask, so I'll just try here and see if anyone has any ideas. We have (IMO) too few Autocad licenses at my work, so I have to just randomly try to open it and wait for someone to close their session. This is obviously slightly annoying. Is there a way to send a request to the license server every 5 minutes or so, to check if there's an available license, without actually opening Autocad?
@StewieGriffin You could check if they have an web API or something, there are a couple Autocad python libraries out there, but I'm not sure / confident if they might have something like this built-in.
And then there's GUI automation that may try, so that at least it's automated, instead of manual checks. Not so sure about that as well.
Dilemma: the type-annotation tag description sounds like it's a Java-specific thing, and the annotation tag description specifically says "annotations are things that can't be expressed by the type system", so neither is really a good fit for python's type annotations
I am first time trying out python unit tests referring to this article. I have PyDev plugin installed in my Eclipse.
My test_hello.py looks like this:
import unittest
class TestHello(unittest.TestCase):
def test_abc(self):
print("Test!!!")
result = True
self.assertE...
I was so confused :/ Originally, they defined the function below the for loop so I guessed there may be an issue. Then they edited that, leaving nothing left
@user2357112 aaaarghh, yes! I forgot about that didn't I. I now added it to my proper TODO backlog. Do keep poking me, that's important.
@davidism: remind me where the Werkzeug asyncio discussion is taking place? I found vorpus.org/blog/… and a lot of the exposition there is important background info for anyone attempting to write fundamental asyncio-based libraries.
@AkhilAlexander Hi Akhil. Please note that the forum rules suggest that longer blocks of code should be pasted into something like a pastebin and linked to in this room. It will also be easier for you to keep the code formatting to help with readability
I don't agree that this should be put on hold: the OP posted code several minutes before the last vote was cast: stackoverflow.com/questions/52625673/… But they got a useful answer, so I guess there's no need to re-open it.
@AkhilAlexander I'm not clear on how that relates to what I said? Currently we're looking at sections of your code that have been chopped out. An MCVE and traceback will remove ambiguity here because I think you're misunderstanding what I was trying to say
haha you should have seen what this OP was asking for yesterday request after request, after he was put on hold I solved his problem like 3 steps deeper than question, no accepted answer smh YAM
Yeah I see the ninjas comment I have an answer @PM2Ring
@PM2Ring I stand by my solution and thanks for the backup haha
@PM2Ring I think OP just confused everyone with his failed attempt to create a way to compare elements of both lists, makes it appear as if he wants some list of all elements as independent lists, he just is confused I believe
Yes he's confused. This is what's known as an XY problem. He really wants to do the comparison (X), but he's got a crazy theory that he needs to do that list-wrapping stuff (Y) in order to do the comparison.
"cant use zipping for this project" Grrr. Why didn't he say that in the question? I hate questions with stupid restrictions like that, especially when the OP doesn't bother stating them from the outset, but only reveals them drip by drip.
I mean, I understand teachers placing such restrictions when they're trying to teach a specific concept, but it gets yamming annoying when you post a nice Pythonic answer, and the OP keeps adding extra conditions that invalidate your code.
yeah stupid but now martin upset at OP but not taking back his downvote lol he judged my post on his missinterpretation of OP , where I interpreted it properly ... hmmm
@PM2Ring just formed the tuples with list comprehension isntead
@vash_the_stampede I remember seeing a very similar question a few weeks ago. I guess it could be a common homework assignment. I don't blame you for putting it off, it's a stupid problem. :)
@vash_the_stampede It's a messy problem. I think using Counter to identify dupes is good. And then I'd use itertools.groupby to identify groups of identical items. And you can copy the keys of the Counter to a set so that you can test if a replacement number is ok. You can't use the Counter itself, because you need to update that set with each replacement number.
@PM2Ring okay but either way its going to be multiple steps, I was just making sure there wasnt a 1 or two line solution i was missing , and i was mentioning this question stackoverflow.com/a/52617780/10255652 not that homeowrk one forgot to paste link
@vash_the_stampede That's another messy one. But yeah, you're current approach does too much work. Let me think about it...
b = [[1,2,3], [1,2], [3,5], [2,3,4], [2,3,4], [3,4,5], [1,2,4,6,7]]
result = []
for u in sorted(map(set, b), key=len, reverse=True):
if not any(u <= v for v in result):
result.append(u)
print(result)
It's annoying because he's using lists instead of sets. And I suppose he probably wants to preserve the orders of the b list. But that's easy to fix with a final pass.
The code will be just as long, if not longer with my approach but I'm shooting for timings. Then again, I might just be imagining I have a faster solution. Tense times.
Would it be stupid of me to attempt to secure my APIs using libraries such as flask-jwt-extended instead of using some paid, off-the-shelf solution such as OAuth? In your professional opinions..
@Aran-Fey you've beaten me on timings so I won't post my answer since the code is like some swamp monster. %timeit aran(sample) 2.28 ms ± 25.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) %timeit my_approach(sample) 3.86 ms ± 68.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
But there's an issue comparing to the original approach, I need to figure out how to push it through timeit
I may actually have been better looking backwards rather than +1 but that really just pushes the problem to the start of the loop which is kinda cheating
@vash_the_stampede laugh all you wish, it's still 57 times faster than the approach by Rakesh and that's on a list of 4000 numbers :P
I've upped the test size. Mine took 1 sec to complete. I have a feeling I will have to give up on testing Rakesh's at this scale :P We're already at the 3 min mark
It's a very lazy day :-| I had the weirdest dream last night. I wanted to buy cigarettes and the labels were "requests" "OpenCV" and "Click" then for some reason I thought "click" was menthol and I bought it :-|
Anyone have advice on what to do when your dup-closing is immediately (or shortly afterwards) reversed by another gold badge holder without comment? It's happening repeatedly with the same person (you can guess who).
Dup-finding is time-consuming and I don't like it when it's not appreciated / reversed without comment.
@AndrasDeak, I'd rather not bring to Meta if it can be avoided. Because it's only one individual and I don't want to turn this into a me vs him/her. There's no flag for this, so going to comment and, if no response, keep a log + bring to Meta.
@vash_the_stampede if you can do something it's great and shows you being very intelligent, but those books spread the mindset that anyone can learn a programming language in 21 days which is clearly wrong. It's almost like beauty products, wear this and everyone will love you!
@Mirv this is not the first time, so: are you aware you can post directed replies to chat messages? Like the one I just posted. These make it much easier to understand context.
@vash_the_stampede yeah, couple of your previous replies might not link the previous comment correctly, so hard to follow, even for the one who was pinged.
@vash_the_stampede Many moons ago, we noticed that every now & again we'd get odd questions from people who had some strange ideas about Python & about how to approach coding. Of course it's to be expected that some people will develop strange notions, especially if they're teaching themself.
But rather than just random weirdness we noticed this consistent pattern of shared weirdness, like they were from a bizarre parallel universe, with different Python syntax. And different laws of logic. Eventually, a pattern emerged: these people were all learning from Learn Python The Hard Way!
There's a "reply to this message" option in the context menu of messages here in chat and in the transcript. The starboard is the exception where this is missing, but you can copy the message URL and put the colon and the ID in front of the message manually to get the directed reply
The general recommendation (which I never follow myself) is to have a separate virtualenv for each of your projects so that your dependencies are clean and don't conflict. You can install packages globally into a system interpreter instead, and you can point PyCharm to use that interpreter instead of a virtualenv.
Well, I posted an answer to that hierarchical dictionary parsing question. I don't expect to (or want to) win the "accept", but hopefully the OP (& perhaps some future readers) will get some benefit from it.
There was a classic question an hour ago: Which one is best python or pycharm? (10k+) It was short, so I can quote it here in full: "In coding which version is good for easy coding python with version 3.7 or pycharm?"
I'm trying to make a Flask template app to use as a starting point in my projects and it's become a full project itself. Every time I get one thing in, "oh, better add a copy/pastable function for pagination. Yeah, I better throw some email support in there too" :/
IT needs to hurry up and send me the data I need so I can get back to my actual current project
True, and it's reinforcing it in my head along the way anyway. There are other templates available, but I kinda think that's cheating when I could use it as a learning exercise
@jpp I close-voted, but the OP self-deleted. You can't actually use rubbish like that as a dupe target: it has to have at least one answer. The exception to that rule is if the OP posts a dupe of their own closed question.
@jpp There are numerous questions tagged Pycharm where the fact that the OP is using Pycharm is completely irrelevant. Eg, stackoverflow.com/questions/52624391/…
@PM2Ring, Fair enough. Yep, I have no doubt PyCharm has been misused throughout. It would be nice to have a canonical link to post to about "language vs IDE" (this could be a cross-language one). Likewise about shadowing built-ins, I haven't found an all-encompassing canonical.
So instead of typing I can just Ctrl+C, Ctrl+V in comments.
@jpp Oh, ok. Yes, it can be good to link to stuff without actually dupe-hammering. Especially if the question is something that we really don't want to keep.
And regarding shadowing built-ins, that's often an incidental issue to the OP's main problem, so a shadowing canonical is rarely going to be used as a dupe target. And it would be useful to link to it in a comment on answers that shadow built-ins.
Random question popped into my head. Is there any consideration to be made regarding storage location of login hashes? For example, is there any benefit to be had by keeping them in an entirely separate database to the app data?
The app database clearly has a larger surface area so seems more likely to be breached by some loophole, but the passwords would still be hashed. Or would they likely focus on hacking via the login/authentication mechanism, which means it was wasted effort?
Not much benefit to keeping them in a separate db. I mean there's some, because in theory you could ultra-harden that server, but if you're properly salted & hashed then there's not a lot of risk to letting those be compromised with the rest of your database
I recently read a SO Meta post (maybe linked here by Andras) saying that it's not the job of the LQP review to delete technically incorrect answers, or answers that don't have much value. If the answer has zero useful content, or it's just plain incomprehensible, then sure, nuke it. Otherwise, let the voting process take care of it.
I've just written a unit test for an end point I've made but I'm a little unsure how I can pass a bearer token along with the request? The current unit test for unauthorized access looks like
@Aran-Fey text rotation seems correct/best to me. I printed out the page and rotate it 2*pi/3 rad turns, the text is always upright and horizontal on the left side of the page.
according to the docs "As of 2015, it is believed that 32 bytes (256 bits) of randomness is sufficient for the typical use-case expected for the secrets module." ... is this still the case?
@wim I asked this once, and someone in our class said nothing was secure enough for them. a few days ago chrome asked me if I wanted it to just come up with a password and store it for me, so I was thinking about how secure passwords can be
@Sam so you're expecting your status to be that? Anyway, that's a good sign, you can print everything and check then. "requests" is so well documented, I really like it.
Nope. I'm making a unit test for a secured end point so my unit test consists of registering a user, logging them in, extracting the bearer token, and trying to access said end point with the token
"i need coin change result likes (minimum coin, counter, [coin change list]) if input=63 (3, XXXXX, [21, 21, 21] please complete 'make_change', here are main code and testcode" - OP
@AnttiHaapala and @wim Yes, that was what our professor said. I think my classmate was referring to what @wim also said, about the bugs in the implementation.
@AndrasDeak oh, man. There's a new user that would totally snare me in my own serial downvoting heuristic. I concede on our debate a couple of days ago where I said it should be a mark on your account.