« first day (2321 days earlier)      last day (2852 days later) » 
01:00 - 20:0020:00 - 00:00

01:30
neat
assertEqual will call assertDictEqual
thank you Python 3
\o/
 
2 hours later…
04:00
Cabbage :-)
04:53
@Tokencodingnewbie looks good so far
Now it's time to translate that into code
05:29
cbg
wim
wim
@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
@wim so, I can just do assert this == that?
even for dicts?
wim
wim
yep. much more pythonic
awesome.
would rather do that tbh
Thanks for the slap
:)
why is there no big push to not use self.camelThing?
wim
wim
there is
not many projects bother with unittest runner these days
I don't know why cpython still does
05:40
I want to find some documentation on this
wim
wim
It's not exactly new
imagine you have a function that has an assert statement in the code object
>>> ast.dump(ast.parse('assert dict1 == dict2'))
"Module(body=[Assert(test=Compare(left=Name(id='dict1', ctx=Load()), ops=[Eq()], comparators=[Name(id='dict2', ctx=Load())]), msg=None)])"
you can use an import hook to rewrite any test functions at collection time
so instead of the line assert this == that you do instead myassert(this, that)
then you can make myassert as fancy as you want to provide a contextual diff on failure
here's a post from about 6 years ago when pytest added the feature pybites.blogspot.com/2011/07/…
05:55
Interesting. Thanks for the info. I wasn't looking up the right keywords. This is a good start
thank you!
cbg all
06:10
cbg
06:59
.@Github flagged my account: - No-one can see my comments - No-one can see my issues - No-one can see my reviews I work on Open Source.
Wli
Wli
07:47
Hi guys, to whoever helped me yesterday, I send you my regards everything works flawlessly.
@AnttiHaapala there are a few "sorry"-s missing from the official response...
brief cbg
@AndrasDeak wow indeed
that's some bad filtering really
.@github Ban me from the public view… but don’t remove me from a private paid org account. That’s incredibly disruptive.
@AndrasDeak Bert is one of the Pyramid + associated project core maintainers...
 
2 hours later…
09:44
Cabbage
@AndrasDeak Wow, not even one. Just “thanks”. Thanks for what exactly?!
what was the reason?
09:59
"sometimes good guys get caught in the web". Which is true, but a dozen heartfelt apologies are in order in these cases.
*net
10:52
Hey
 
2 hours later…
12:49
recbg
ola!
i need some advice on a time series regression i need to run
any ideas and or direction you can guys can point me in?
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
13:23
@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.
oo okay, thanks @AnttiHaapala i will look into that thanks
rb folks
crazy morning
cbg folks
I mean
see the morning was crazed
13:51
morning everyone
I need to submit a PR to an open-source repo, is there any practice of how to do it?
It depends from org to org, IF they have any such "practice" they recommend.
Also, the hosting platform for the open-source repo makes some difference.
14:16
\o cbg
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.
@Leruce pop as in you are removing something im assuming ?
Yea pop when I have reached a terminal state and now going back. I think I may have misunderstood my approach.
@corvid assuming GitHub: fork repo, clone fork, make branch, commit, push, make pull request.
I feel like my style isn't matching up with theirs :\ it's a much requested feature add though
14:25
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.
also awful SQL injection answer
@davidism Awful questions with awful answers... I hope people don't put blind faith on such SO answers.
Oh the person requested a chat with David, how I wonder how that chat will go....
It won't, I don't respond to those.
@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.
cabbage
14:39
\o cbg blue BR, how goes it
Day's been quite bad, One of my bug fixes broke another piece of code. Managed to fix it, though. How bout you?
cbg \o
or perhaps not yet
@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
14:57
@corvid go for it then, just keep in mind that libraries can't always update to the latest and greatest.
does anyone know how you return xml data as a response to an ajax request in django from views.py
You generate XML, then return a response containing it with the right content type.
Just like you return any other response.
the request needs to be done so that the page is not reloaded when the data is sent back
so do i still specify the html file to open even if i want it done that way?
You do whatever you want your view to do. What does "specify the html file to open" have to do with generating XML?
If you mean use a template (which is text, not HTML), then yes, you can still render templates.
15:12
when i normally do a response i do it this way
return render(request, 'home/NewsHome.html', context)
i want to get the following
r = http.request('GET', 'http://feeds.bbci.co.uk/news/rss.xml')
xml_news = r.data
and return the xml_news data as XML in a return statement but it isnt working
thanks for that, but i still cant find where it shows me how to pass back xml data
i dont want to pass back string data
etc
Yes you do. XML is a string of data.
so you send it back as a string
not xml?
All data is either string (text) or binary. "XML" just means "an XML parser can parse this string".
15:21
Phew, my production environment stopped catastrophically crashing.
okay thanks for explaining apprecaite it
Now I've got time to breathe... At least until my boss comes in and says "actually it's still broken after all"
@Kevin I was watching an anime called "Chaika" and the plot seemed vaguely like something you described years ago.
Although I couldn't find a conversation about it.
Anyway, would recommend, it's better than its description and style suggest.
Googling... Ah, yeah, I've heard of that one before. Never watched it though.
Good humor, actual characters, some interesting story ideas. Still pretty generic, but worth the watch.
Been watching anything lately?
15:25
I'll move it up my priority list.
Most amusingly, it turns out that "Chaika Gaz", the name of the main character, is actually a model of Russian car.
DSM
DSM
Morning cabbage for all!
Let's see... I watched the first three episodes of "Interviews with Monster Girls", which is nice.
cabbage
cbg DSM
15:28
@davidism, on the bright side, the purpose of this PR is to update the library to the next major (breaking) release and fix all the problems
@Tokencodingnewbie you should probably ask a question on the main site. Be sure to explain in detail where your tests go wrong
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.
It's a faithful adaptation of the manga, and I feel like it gains just a little something by being animated.
How would i go about doing that?
DSM
DSM
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.
15:30
Me me me
I've been watching Dragon Ball as well. Still waiting for these guys to show up:
Only the purple guy has made an appearance so far.
@ThomasWard the sh module doesn't have a git function, it's just some magic that generates shell commands.
It's not doing anything special for git.remote.update.
@davidism Right, but I have to write a corresponding 'compatible' wrapper for a Windows environment for a project
before we all sacrifice me for Windows + Python this is a workplace where I have no choice :P
Oh... Google tells me that the other four guys are just fan characters. Not sure if disappointed.
@davidism the 'company' is trying to get something woriking on Windows but it relies on the sh module which won't work on Windows
so i have to come up with some way to make a git.remote.update() command work without using sh's voodo to do it
15:33
I figured something was up when all of the Gods of Destruction convened together and none of them looked like that.
DSM
DSM
@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.
Aug 16 '16 at 20:58, by davidism
Jun 14 at 16:11, by davidism
May 27 '15 at 18:48, by davidism
May 19 at 16:27, by davidism
But the real answer is to use Linux.
@davidism pbs is no longer maintained...
@ThomasWard does it work? Then it doesn't matter.
15:34
what's up room6
cabbage time
plumbum is maintained, as far as I'm aware
grumbles something about not liking deprecated / unsupported modules
hee hee plumbum
@ThomasWard it's not deprecated, it just hasn't had a release
You should really drop that opinion of libraries.
Sometimes, they're just done.
Anyway, I gave you two options.
DSM
DSM
The last commit for plumbum was 3 days ago and mentioned 3.6, so that's encouraging.
15:35
@davidism would it help if I said this isn't my choice to determine what to use? I'm low on the pecking order :P
but i agree with you otherwise
3 days ago and 3.6? That's pretty darn fresh
Anyway, you never really asked a question. What doesn't work about calling git remote update?
DSM
DSM
I'm porting one of our libraries from 2.7 to 3.6. f-strings 4tw..
nice!
I just removed py27 as a requirement in one of our projects. Gone from travis and tox \o/
@davidism ideally, nothing. the bad thing: trying to NOT have to rewrite the entire project to use strings instead of function calls
15:36
Also, the answer will basically boil down to "do whatever those libraries are doing, just not with those libraries"
If you want to do what a library does, then you have to program that. What other answer were you expecting?
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.
Yeah, I think that's all it does in the base library, it's mostly a hook for libraries, although none of them really use it consistently.
Usually, your code shouldn't care whether it's testing or not, if you set up the request context, fixtures, etc. correctly.
Right. I went down this path because I couldn't tell the difference when toggling it at all, and my test framework is configured properly.
flask-testing caught my eye, but I honestly don't see the advantage of installing another package for that
I just use straight pytest to do my testing. Setting up fixtures is really straightforward.
great. OK.
This is all for confirmation that I'm not missing anything obvious in my reasoning with not wanting to install this extra stuff
thanks
15:51
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.
ah awesome. Thanks. I'll do that.
guys a quick question again sorry
function upon_success ( xml ) {
$(xml).find('item').each(
function (index) {
$("#AllNews").append('<li>' + $(this) + '</li>');
});

}
im running this
and its printing the data on the browser
ok? That's js
as:
object Object]
[object Object]
[object Object]
Did you mean to post this in the Python room?
15:56
Maybe it will tie back in to Django at the end.
o crap forgot about that
let me find a javascript room
Haha, or maybe not.
Hmm, now I'm curious if js has an equivalent of __repr__. Maybe I'll go eavesdrop in said js room.
DSM
DSM
You may bring back the answer but only translated into a Python-equivalent function, like you always do for your C#. :-)
I'm trying to figure it out myself but I'm hampered by the fact that console.log has spontaneously stopped working in firebug
I guess I'll just throw mystring, that's fine... Sheesh.
Ok, I think I figured it out. To get the js Python equivalent of Python's __repr__, you only need to implement function toString() def toString(self):
Hmm. Translating the solution into its Python equivalent is... Unhelpful.
DSM
DSM
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..
16:09
Yeah, English sorely needs a set of optional qualifiers that let you be as precise as you care to get.
Normies could keep using the regular syntax, and technical types like us could banish ambiguity where necessary.
The js room has decided that it was an XY problem all along, so I'm probably not going to discover if my solution to Y was correct/useful/idiomatic.
Why don't you ask if they have a __repr__?
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"
oh this might help, Kevin for that repr: stackoverflow.com/questions/24902061/…
"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
DSM
DSM
#isomorphism
16:17
@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
isn't that what pdb gives you?
and ultimately, PyCharm gives you the neat UI tools to make it easier to use
@Kevin Yes.
class Test:
    def __repr__(self): return 'repr'
    def __str__(self): return 'string'

print(Test())
#output
string
OTOH, if there's no __str__ then str() calls __repr__, and there'll always be one of those, at worst, the inherited one from object.
DSM
DSM
@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. :-)
@idjaw True, you can inspect objects with pdb. But AFAIK you can't explore with just mouse clicks, so it isn't as cool.
@Kevin New project idea?
16:30
rb folks
We'll have to wait until we get a python-like language in the browser I guess. Any ideas on that, @Kevin?
@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.
@DSM :)
Oh nevermind, I thought KevinScript compiled to JS >.<
That's one of my future milestones :-)
16:33
@KevinMGranger We could write our own browser! With hookers and blackjack that used Python as the scripting language...
FWIW, there are things like Brython, pyjs and Transcrypt. There's some info here: infoworld.com/article/3033047/javascript/…
Hmm, is there any way to tell whether an attribute is actually an @property?
class Sprocket:
    def __init__(self):
        self.foo = 23
    @property
    def foo(self):
        some_expensive_function_call_goes_here()
        return 42

def is_property(obj, attribute_name):
    #???

x = Sprocket()
print(is_property(x, "foo")) #False
print(is_property(x, "bar")) #True
so.... foo isn't part of the property of Sprocket o.o?
wim
wim
you should be looking on Sprocket.foo not on x.foo
It's an attribute but not a property. I'm not sure if this is the formal terminology.
DSM
DSM
Maybe something like
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
DSM
DSM
Oops, typo on the first one. The right __class__ still gives False, though.
wim
wim
you also have to know descriptor protocol
because someone can chuck x.__dict__['foo'] = 'something else' on the instance
DSM
DSM
Oh, clever (if malicious) point by Antti there too. :-)
@Kevin AttributeError: can't set attribute for just your class (removing the some_expensive_function_call)
wim
wim
that's because he does self.foo = 23 in the init
i'm not sure why he wrote that
might be a KevinScript thing
DSM
DSM
16:48
I just swapped out the second foo for bar.
wim
wim
oh, right
oh that's why he did foo and bar, good thinking DSM
wim
wim
class Sprocket:
    def __init__(self):
        self.foo = 23
    @property
    def bar(self):
        # some_expensive_function_call_goes_here()
        return 42

def is_property(obj, attribute_name):
    pass

x = Sprocket()
print(is_property(x, "foo")) #False
print(is_property(x, "bar")) #True
now it make sense..... baffle by the small details ...
17:03
cbg
@wim Whoops. Meant to write def bar there.
DSM
DSM
17:18
Psychic powers half-life 3 confirmed!
3 is a number, so I believe the data man
I'm glad DSM is here to provide timely Kevin-to-English translation.
Kevish?
It's true name exists outside of what can be expressed by the international phonetic alphabet.
Even a rough equivalent would require symbols for "making a shadow puppet in the shape of a dog" and "thinking fondly of the concept of petrichor"
18:14
ḵ̢̱̱͢e̱̱̲̱̱̪̱̱̿͐ͥv̷̱̗̱̱̱̙̱̅i̱͖̱̱͡s̱̺̱̱ͫẖ̦
Just shorten that to isinstance(getattr(x.__class__, 'bar', None), property) since None isn't an instance of property :)
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.
#sourgrapes
Could one do some sort of fancy introspection via the C api?
Or in the case of overridden getattr, can't you just use the instance dict unless it's slotted?
Yeah, I was just thinking "maybe I should stick to the __dict__"
\o cbg, how goes it ?
And then all the sudden, my visual studio code is completely different :|
@MooingRawr Great. It was another busy day at office. How about you?
re-cbg
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.
So basically @corvid I know that feel bro
18:55
Did you mean Visual Studio Code, or Visual Studio code?
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.
@MooingRawr I guess now you would be eating Chinese food in dinner as well.
Even better to share it with your peers. Later you may share their food when they have something nice ;)
:\ 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
wim
wim
19:00
Is there a Python lib for doing filesystem stuff similar to a linux find command? I hate os.walk.
Better ping me in 1 hour and 59 minutes instead, because that's the last time you can catch me before I leave the office
Hello Guys, I am new to this chat thing on stackoverflow. Can someone plz explain me what is this used for?
@Kevin Will do bud.
Chatting, mainly.
on any random topic?
19:01
@vacky We provide tips for catching Python in your backyard
@vacky What are IRC chat rooms generally used for ? Chatting, answering questions. Plotting to take over the universe mainframe. Mostly Python stuff..
@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 ;-)
@Kevin thanks for the explanation. That makes sense to me.
@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
19:07
^ It reminds me of the full form of Computer which I studied during my initial school days.
COMPUTER is Common Operating Machine Particularly Used for Trade, Education, and Research (Few pieces were missing in my mind. Googled it)
DSM
DSM
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.
@MoinuddinQuadri They had computers when you were in your initial school days? :D /joking
> Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of CommonLisp PHP.
3
... But I repeat myself.
@MooingRawr I am just 26 ;) I studied it during 6-7th class I guess. And at that time we had computers ;)
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.
DSM
DSM
19:14
I'd be curious to know what fraction of Python users use numpy non-trivially. Lots of the web guys might never need it.
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.
Looking it up is easy, but do you think you can retain the info?
Why do I need to retain the info if looking it up is easy?
I'm not even confident that this is the first time I've had this exact conversation.
19:24
@KevinMGranger got me... Maybe for interviews?
@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)
@AndrasDeak you can volunteer :D
probably takes less than 1 hour :P
I agree, probably a single call to 2to3...
well if they've got 100 % test coverage
what's a test?
19:38
ok forget it :d
I want gold in
only 400 more upvotes
19:57
OK this is weird, github doesn't load from hostel wifi
everything else does
@AndrasDeak dns issue?
or https blocked :?
no, github.com pings
and the url bar suggests that https works for gmail (?)
maybe my IP is blocked from github's side
01:00 - 20:0020:00 - 00:00

« first day (2321 days earlier)      last day (2852 days later) »