@expressjs123 This is not your playground. Please respect the inhabitants of this room who might have better things to do than entertain you. Go browse reddit.
@ChrisP Those design questions, e.g. "What prioritries should i use", look distinctly like decisions that you have to make. The rules 2. and 3. mean there are many cases that have no single well-defined solution, and many cases that have no solution at all. We cannot tell you what you want to happen in these cases.
@Kevin I keep wondering... is there free lunch at your secret software fixing site?
Ah, here is this chat room. I thought I imagined this thing exists. Would someone lend a reopen vote to this matplotlib problem? Possible bug identified. stackoverflow.com/questions/64561779/…
Is there a link to this chat room on SO? If it were not for MisterMiyagi's user profile, I wouldn't have found it. Or maybe I just need reading glasses.
Thank you for reopening, btw. I was working with the user for the last day to narrow down the source of the problem.
@Mr.T Thanks for working with the user. ;) Got the notifications from following the question, so the frustration from lacking reopen votes was very relatable.
@Mr.T no. It gets suggested every now and then but there are more cons than pros. At least with the new "follow" feature you can opt in to that on a case-by-case basis.
@Mr.T with 5k rep I'd think you'd have noticed by now if this were a feature :P
It's interesting to see that two prolific voters are following questions voted on - that must be quite a list. Do you unfollow after a while? I only follow questions that I find answer a repeated question that I can't commit the answer to memory for (for whatever reason)
again, coverage does not run unittests. It runs applications. If your "coverage command" says "Ran 0 tests", then you ran an application that attempted to run tests but did not find any. Investiage that application, not coverage.
It's super annoying my colleague is throwing a lot of 404 when something is not right, but mostly they should be 403 or other codes. And it makes it hard when testing to tell if I mistyped something or if 404 is a supposed error code. Is there a good reason to throw a 404 on a url that actually has a view associated with it?
@AndrasDeak lol, it's a codebase that was develop by a sole developer in the last 3years. I am just starting to unravel it. But so you would agree that this shouldn't be like that, good.
Call it O(num_tokens ^ (num_rules ^ k)), where k is an abstract "branching factor" between 0 and 1. I think I can compose a grammar with ten times as many rules, but with a much lower k.
@Hakaishin I'm an end user of web dev. But yeah, "you don't have permission to view this" sounds like 403 rather than 404 to me. Although my main background comes from http.cat
@ParitoshSingh Yeah, using a sentinel value is probably what I'd go with if I was dead-set against using a separate boolean flag. I do really dislike flags if they're not mandatory...
I wonder how hard it would be to write a grammar guaranteed not to have any superfluous parens. So square(1+1+1) rather than square(((1+1)+1))
Maybe if I take a page out of python's book and have separate add_expr and mult_expr...
I don't think you can do that without serious black magic. As far as python is concerned foo(4) no longer exists in this form by the time the print function is called.
I've experimented a little bit with inspecting the call stack so a function can see how it's being called. It's easy to get the upper frame object, but it's hard to find the code object corresponding to the function call, and AFAICT impossible to recreate the exact syntax used by the caller.
As a simple example, after compilation to bytecode, the expressions f(1.5) and f(1.50) are 100% identical. There's no way to tell how the float literal was originally typed.
Similarly, f(x + y) and f(x+y) are indistinguishable
If you can find the ast node corresponding to the function call, then yes, there will be a Number node with a value that contains 2 or 3.
finding the ast node falls under the "hard" category. Last time I tried, I was able to find all nodes in the code object corresponding to the function call I cared about, but if there was more than one, I couldn't figure out which one was executing.
Hey guys, I am always in a dilemma whether I should name my class "Calory" or "CaloryCalculator" (in a calory calculation webapp), "Temperature" or "TemperatureScraper" (in a webscraping program), if you understand what I mean. Is there any guideline?
I just want to trace some recursive functions thats all, laurel, saw this github.com/Bishalsarang/Recursion-Tree-Visualizer but felt overkill so I wanted to make my own low level print version of it
Funny I was going trough similar issues. I think for smaller projects it should be Temperature and for larger TemperatureScraper. Because you don't have to repeat yourself a lot. But in biggger projects naming issues might become more of an issue, I guess. So I would go with the shorter one
TemperatureScraper seems to be the same like naming a list something_list or a tuple something_tuple and I hear thats Hungarian notation and its not used in python
I might make a class called Temperature if I wanted to store data about a temperature and that's it. So it would perhaps have a value attribute and a unit attribute. I might make a class called TemperatureScraper if the class' main goal was to scrape a value out of a webpage and return a Temperature object.
<span> "Air is 19 Celsius degree"</span> If we name the class that scrapes "19" "Temperature" then how do we name the superclass of Temperature which scrapes the span content "Air is 19 Celsius degree"?
@AndrasDeak what's a good solution then? Should I have a class that extracts the number "19" from "Air is 19 Celsius degree", or do that in a method of Temperature?
"create a custom function so doing my_print(foo(4)) will give the same result as print(f'{foo(4)=}')" is this worth asking in main or will I get downvoted?
@python_learner it will be downvoted because SO is not a code writing service. Find someone who's bored on reddit, or pay someone for a quick consulting gig.
@multigoodverse I wrote exactly one scraper in my life, so I'm not the one to tell. That being said, I would probably separate the scraping logic from the parsing logic. Once I have the page I can parse whatever I want in it. And yes, I would start with parsing out the full string, and then using that result to extract the number. And I would probably use zero classes to do the parsing, unless there's additional state to be considered (like some kind of config that determines what to extract)
@Kevin What if the class has both responsibilities you mentioned? So, the class's responsibility is to get as input the country, and the city as strings, create the URL, make the request to the webpage, and return the temperature. So, it does both contain data and does scraping.
If you are using a library what do you find more convenient a method for doing different things or a boolean? Like I wonder if I should do: get_notifications(active_only=True/False) or make two methods one get_notifications and another get_active_notifications
I know of a high profile python user who is a member of that discord, davidism (sorry if I spelled it wrong) he is associated with flask if you are not aware
@python_learner You need Macros for that (or at least something that is equivalent). Haven't used it myself, but the MacroPy library looks very mature and useable.
I recommend against manually mucking with the AST, it is notoriously unstable between Python versions and has a poor API.
Basically I treat two expressions as equivalent if they contain the same number of operators and operands, and have the same numerical solution
Basically memoize_rpn_generator is responsible for putting only one of each in the cache
I'm being quite lazy by not bothering to evaluate expressions whose intermediary values might be non-integers, for example (1 / 2) * 2. It just so happens that there are always solutions with only integer intermediary values, but I know for a fact there are other puzzles of this nature that don't guarantee that.
I'm also cutting off factorial if it gets remotely large. I think that's safe here because it's hard to get back down to a small integer from an astronomically large number, given a finite number of operands and an unlimited number of operators
So it's very unlikely that there are any solutions with huge factorials
The needle is pointing between "it's complicated" and "yes"
To use imprecise terms, I'm touching every component of every possible solution, but I'm not combining all of them. If I knew more about group theory I think I could give a more lucid answer.
So basically you need to only evaluate the sub-expression for equality, because once you know that a and b have the same value, you know that a + c and b + c are the same?
Seems like exploiting the algebraic convergence of the application of the functor between latices of homological computations and their representatives.
At least, that should keep people confused long enough to kill the alligator and run.
Hey everyone I have a numpy array NxN. And i want to have the sum of the elements of opposite diagonal(top right to bottom left). Is that possible in a nice one-liner? Thanks in advance
@roganjosh hey man just a quick one back from our discussion the other day why would one send a form using ajax what would be the aim doing this? At first I considered it but then noticed that was unneeded as it is rather simple to submit multiple forms using a single wtforms submit button, while validating it with a separate .validate() method from the library and I am curious as to the benefit of submitting through ajax
Pretty much the same as every other purpose of AJAX :P
In order for Flask-WTForms to clear all the entries on a form submission, it expects a redirect. Well that's all well and good, but what if I have other content on the page that's really heavy to load and has nothing at all to do with what's being entered in the form?
Ahh lol ok I see hmmm might be fun to work on and see how i would go about it with wtf i believe if you were to send the details back via ajax as a success surely you could just use the .empty() jQuery method to clear the fields
Same can be said about dashboards. Maybe you have a set of high-level summary graphs that are the result of aggregating millions of records and making a pie-chart that people seem to think is pretty and informative (bonus points if it fills itself in a 360deg sweep rather than appearing whole when you land on the page btw)
Think I may play and see if there is a nice way to do this... p.s if I were to be trying to get a graphical representation of a 'cell spreadsheet' similar to excel with single cells being coloured as filled time slots which library would be good for forming this
@Kwsswart mmm, I hadn't thought of that. I don't think I like the idea of clearing out a form filled by the backend on the frontend, but I can't say for sure until I meditate on it. Still +1 for suggesting something I hadn't considered
Double bonus points if the user can disable those juicy animations in their user preferences. I know of at least one industry pro with real sensitive motion sickness, who rejoices whenever they can get simple static text and images
@roganjosh used this for this ajax call the other day and works nicely although only for a single field in this case before filling the field with new data to clear it then on flask side it checks the new data entered on submit dpaste.com/CALHMH8MZ
@JonClements True, and I did find a way to clear the form out on the backend after a successful submission. My argument all along was just me thinking "why am I even bothering with this extension?" so that's why I dropped it
oooo yeah... cursor has to leave a trail behind and the midi has to be a really annoying theme tune to something no one links and then you've got the recipe for a perfect site!
@Kevin I don't think so, cc @roganjosh. Your link asks for the antidiagonal, which is a well-defined thing (starting from top right). The other link wants an arbitrary antidiagonal with a shift, I think
I mean they are related and I guess the latter contains the former as a special case, but I'd have to look real hard on the answers to make sure that a dupe in that direction doesn't lead to loss of better specialized answers
And, as you may guess, I will not look real hard now :)
I'm on hour three of testing set intersections between any vaguely numeric values across two spreadsheets of data that were pulled from a database. So far, 0 matches in every pairing. It's gonna be a long night. :'(
This image is a distraction, isn't it. When I look up, I'm going to see a scarecrow dressed like you where you were standing, aren't I. You're already three towns over, aren't you.