@idjaw if you are still using self.assertCamel shite at all then you've been living in a cave ..
you can just use plain old assert statements these days, a proper test runner will rewrite the ast in order to provide a contextual diff if/when that's necessary
hi guys can i ask a quick question, i was speaking to my lecturer today, i need to download the Top news items from a bbc website link and display them on a html page, using ajax / jquery to django but im a bit confused with what my lecturer said
he said the following: Hi, you shouldn't use template variables for this. The news items should be downloaded from the client via an ajax request. So, although you do need a view function to download the news items (using urllib3 for instance), this view function should be triggered by an ajax call from the client's br
browser.
i was wondering if anyone can explain to me what he means by this
@RhysCopperthwaite you can have a static html page that uses Javascript to load the data e.g. as JSON; returning json from django views, you don't need to use any .html templates.
@Code-Apprentice That's where it gets iffy, I can't seem to get it to pin point the coordinates properly. Everytime I think it's fixed a few tests later it shows ships on the board not matching the coordinates. What I wrote was my best guess at how to solve the problem and I just need some help on the logic because clearly it's very wrong/misguided.
Quick Question. When using Recursion in a Class's method. Does the data from the previous stacks stay intact when it goes pop everything when you still changing self.data_stuff? Something tell me i screwed up.
Style wise, I'd refrain from making any changes except to the lines you need to touch. Don't let your IDE clean up the whole file, use the same whitespace, etc.
@Leruce Your question is unclear. We need to see a MCVE. If you can fit it in a dozen lines or so you may post it here, otherwise put it on gist, pastebin, etc.
@davidism I can make a somewhat overhaul to reduce an entire 200-line file down to ~10 configuration lines, due to a new feature being introduced in one of the updated libraries
Hiya, Python guys. I have a question about Python, if you can answer it. I'm trying to write an equivalent to the 'sh' module's git functions that'd work with Windows, by using subprocess.Popen as the execution mechanism. The problem is, the sh module's git functions support git.remote.update and I'm trying to replicate this in my 'git' wrapper function.
The next time I think I'm such a good teacher that I can explain a misconception about encoding, I want someone to hit me with a Nerf(tm) bat until I come to my senses.
@Kevin: too bad, the joke would be impressive otherwise. So count me mildly disappointed. And this is coming from someone who's never watched any of either.
oh. davidism. I don't know if you caught a small thing I mentioned about Flask yesterday, but I was trying to go deeper on what extra functionalities Flask offered for testing, and noticed that there was a flag you can toggle through the config for TESTING = True. From what I see it is simply to propagate exceptions through the test_client. Is that pretty much it? That's pretty much the conclusion I drew as well from that.
You can look at Flask-WTF's test suite, which I rewrote in Pytest: github.com/lepture/flask-wtf/tree/master/tests. Or Flask itself uses pytest, although it's got a lot of baggage from accumulated tests and switching test frameworks.
That's actually useful to know. That the magic method is toString, I mean, not that the Python translation is unhelpful. I wish English had something like negative indexing, so you could be explicit about what previous statement you were referring to..
Speaking of ambiguity, I can never remember which of the letters X and Y refer to "the problem I have put forth", and "the problem that I should actually be trying to solve"
"You're asking for X but you actually need Y" and "You should be asking for X, but you asked Y instead" are equally valid expressions of the XY problem
@MooingRawr Oh, that's interesting. So toString only gets called when the object gets converted to a string. It would work in Rhys' case because he's doing "<li>" + whatever, which implicitly converts whatever to a string, but it wouldn't work if he just did console.log(whatever).
This is rather different from Python's print's behavior, which always invokes __str__. Uh, I think.
I wonder if Python has something like console.log where the output is not necessarily raw text. For complex objects, you can click on the "+" icon that appears and inspect its attributes dynamically.
I bet there's some fancy-pants IDE that does that. No luck for console users like me, I expect
@PM2Ring: oh, hey. I was reading an answer the other day and the voice sounded familiar.. when I got to the end of it I wasn't at all surprised to see you as the author. Very recognizable style. :-)
@Kevin Right! You're using console magic to expand everything you want to look at. But, this goes back then to using an IDE like PyCharm to get that UI goodness.
In [24]: hasattr(x.__class__, 'foo') and isinstance(getattr(x.__class_, 'foo'), property)
Out[24]: False
In [25]: hasattr(x.__class__, 'bar') and isinstance(getattr(x.__class__, 'bar'), property)
Out[25]: True
My actual X to this Y problem is "if I really were going to make an interactive object explorer, how would I know which attributes are safe to fetch without causing potential side effects?"
But even if I detect properties, there's always the chance that the class is doing something clever and/or stupid by overriding __getattr__.
I guess any class that does that, doesn't deserve to be interactively explored by my lovely hypothetical project.
I just spent the last 2.5 business days trying to figure out why Visual Studio was magically adding files to my project that it had no business adding.
For future reference, it was adding files to project A because project A depends on project B, which depends on library C, and project A also made some references to objects in library C, so VS was copying library C into project A without asking, rather than doing something like print an "unresolved reference" compile-time error.
@MoinuddinQuadri just finish lunch, I went for Chinese food, apparently I bought a super large combo meant for two people.... Did not notice until I brought it back to the office... :\
When you have one serving of Chinese food, you're hungry again two hours later. Lifehack: buy a large combo meal for two, which will incrementally fill you until the next meal time.
:\ Or I try to fit it in as a mid day snack before dinner, but something tells me that's unhealthy..... Maybe I will put it in my office's fridge and heat it up tomorrow
@MoinuddinQuadri I asked, no one wants it....
@Kevin I'm going to ping you in 2 hours to see if I'm hungry again :D RemindMe 2 hour
@vacky The closest thing we have to a "mission statement" is: we are willing to answer questions that don't quite meet the stringent quality standards of the main site.
So we'll answer opinion-based queries, and questions that are broad enough to have multiple valid answers, etc etc.
We'll still complain if you don't provide an MCVE when you could have, though ;-)
@vacky Typically anything but non-Python languages. We'll talk about books and food and movies, but we won't talk about PHP.
Other chat rooms may have different standards of quality and on-topic-ness. Stack Overflow gives each room a loot of leeway in terms of self-governance
@Kevin Ohh.... Kevin, that (from before about the other Kevin and PM wanting to create) web scripting language should be named PhP (Python help Problems, or something....) just to confuse people
People who visit during one of our off-the-rails moments might be surprised that we actually have a fair amount of technical skill floating around here, although it's room style to be self-deprecating instead of boastful.
> Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of CommonLisp PHP.
I'll stop being self-depreciating when my technical skill is finally evenly distributed enough to be able to answer "how do you transpose a numpy array?" without having to look it up.
transpose... never bother looking that up after many hours of using that skill in Final Fantasy....
I know nothing about numpy, even though I used it for last year's AoC.... I don't use it on a daily basis, nor have I had a project require or could use it. I wish to learn one day though...
Or maybe I'll be satisfied when I can answer "If my current working directory is <...>/a/b, and I want <...>/a/b/main.py to import <...>/a/z/mymodule.py, how do I do it without injecting values into sys.path?"
It occurs to me that these are things I could pretty easily look up, right now.
@DSM that reminds me, I'll hear a tutorial tomorrow about an interface to some hpc software in python. It runs through the REPL. In python 2. I'm already trying very hard not to ask whether they're planning to port to 3:D
(the interface is in python, not the hpc software)