« first day (2199 days earlier)      last day (2743 days later) » 
00:00 - 16:0016:00 - 00:00

12:03 AM
I'm running Django 1.10.2 with REST Framework. I have the django.contrib.staticfiles middleware loaded. When I issue an HTTP HEAD request for a static resource, it sends the body anyway, in violation of the HTTP RFC. This looks like a bug to me, but I'm new to Django, so I want to check with someone else before I create a ticket.
Can someone confirm this behaviour?
For quick copy pasting: curl -v -o /dev/null -X HEAD http://localhost:8000/static/download.pdf
 
 
4 hours later…
3:47 AM
What's the difference bw

for i in range(k):
nums = [nums.pop()] + nums

and

for i in range(k):
nums.insert(0,nums.pop())
 
4:42 AM
literally nothing
 
 
2 hours later…
6:17 AM
@JakeWaitze very incorrect
@doodla the first one creates a new list, the second one modifies an existing list
however both of them are bad' examples. Inserting to beginning of list is slow; you should use collections.deque for a datastructure that has fast insertion into the front of the "list"
 
6:35 AM
I edited the tutorial page a bit
 
7:09 AM
> I am learning python using Learn Python the hard way. It says about "Inside out" technique, I couldn't find anything about it.
cbg all
 
@vaultah rly where?
ah google is so fast: D
 
ah, you mean the question?
 
@vaultah added comment
The inside out probably means the same thing as "backwards". If you want to learn Python the easy way, and learn Python 3 while doing so, I suggest you check out the Creative Commons licensed books at inventwithpython.comAntti Haapala 1 min ago
 
upvoted
I haven't checked out any of those books tho
 
"To help there are extra credit to solve a puzzle and learn something cool."
@vaultah they're good, the Automate boring stuff with python has lots of immediately useful general material for kind of office automation, using Python 3
@vaultah see for example the regex page: automatetheboringstuff.com/chapter7
 
7:26 AM
guys
answer this question please for 200 bounty. I don't want to waste it.
 
As for the terms used in LPTHW, well, usually you will not find anything relevant as the book heavily uses ad-hoc metaphors invented by the author. — Antti Haapala 6 secs ago
@khajvah don't know what to answer :D
 
@AnttiHaapala it teaches to match email with regex :( but to be fair, it does say that the regex presented "won’t match every possible valid email address"
 
@vaultah and it is for extraction
which is better than validation
 
@AnttiHaapala meh. I will answer myself and waste 200 internet points.
 
@khajvah well, idk what the answer is :D
 
7:28 AM
@AnttiHaapala I found the problem
it is inside the application code. Posted the leak
now I need something to accept
 
@khajvah you should have a DI system for the singleton cache...
 
what's DI system?
 
dependency injection system
 
@AnttiHaapala You can post an answer with a high level solution
 
you do not "obtain the cache instance", everything is "given to you"
 
7:30 AM
:)
 
IDK how to solve it nicely in django? though
 
it's not Django oriented
I tried to minimize Django-specifics from my code
@AnttiHaapala At first I made a singleton cache but didn't know how to pass it around
 
what I mean is that in Pyramid, say, this is a way easier problem.
 
imagine a non-Django GUI application
I just need the caching module and the mechanism of passing it around.
I will worry about Django
 
no, even so
the "non-django gui application" is hard...
because the pattern of dependency injection is not common in Python (unfortunately)
 
7:37 AM
how do you do that in Pyramid?
I can copy that
 
I do it completely differently, that is not a common pyramid pattern really, but it builds upon it.
a sec...
or a minute
 
:)
 
In my Pyramid apps it works like this: every single application-level business object / service / whatever has a reference to the application registry object (it's like global config but pyramid can have several applications wired within the same process) - it is in .registry.
And every single request-scoped object has a reference to the request it was created for in its request attribute.
 
ok and specific objects get the cache from registry?
 
nope :P
yes, but cleaner
I have a black magic descriptor called autowired that upon first access to an attribute, wires in an implementation for the required interface.
so, if your class IndustryViews needed the industry cache, it would have
class IndustryViews(ServiceViews):
    industry_cache = autowired(IIndustryCache)
and then, all code would just access self.industry_cache and it would just work as expected :d
 
7:48 AM
oook, you have interfaces and implementations
but I got the idea
thanks
 
@khajvah the trick is how the autowired works...
 
@AnttiHaapala I don't know about the interface stuff but I expect it to get the implementation from registry?
 
it is as simple as it looks for a request on the instance, if it exists it is the current request, and it can be used for finding already created request-scoped services.
if there is no request property, then it must have the registry property, and it can only autowire application global service objects in there.
in your case, I'd declare the IndustryCache with
 
@AnttiHaapala this part is cool. Each request can have different registry?
I would have to do that with globals
 
@service(IIndustryCache, scope='application')
class IndustryCache(BaseService):
@khajvah well, each request has its own "local registry" of services that were created for that request
 
7:53 AM
@AnttiHaapala what else can scope be?
 
scope can be request.
 
I see
 
then it readily is bound to a request always, so you can use things like if self.request.user.is_admin.
 
cool architecture
I will steal some of the ideas
 
without having to do another bindings for injecting something like UserService.
the key here is that the request or registry is always passed in explicitly to the instance upon creation.
then, if you access self.industry_cache and it wasn't resolved yet, autowired descriptor will try to instantiate an instance of IIndustryCache - it will find out that IndustryCache is a factory for it, but it is a application-scoped service, so it will be created then once for the application scope, wired to the global application, and then autowired finds out that the industry_cache attribute needs to be bound to this instance on the IndustryViews instance.
and it just happens magically.
if you want to do unittesting, you can store your mock in it instead:
 
7:58 AM
damn, people can be really creative with code design
 
def test_industry_views(self):
     views = IndustryViews(MockRequest())
     views.industry_cache = MockIndustryCache()
this is copied from Java and Spring and Pyramid and Zope and whatnot
all those things that Django tries to stay away, "ewww"
 
ok I yet again think I am a shit programmer, thanks for that.
 
@khajvah not your fault
you've just not seen the good code
and django is notoriously bad exactly because it wants to do everything django way, stay in django etc...
 
@AnttiHaapala it's good. Every time I think I am shit, I become good in couple of weeks
and then the cycle goes on
@AnttiHaapala btw, do you know any open source stuff that I can look at?
 
you know how I was hitting my head against the wall when I read tweets that said that "what's Zope? I thought django was the first Python web framework"
my code builds upon pyramid, zope component architecture and pyramid services
everything I've done is in this file:
though I now noticed that it might still have a bug there
 
8:10 AM
> removed python 2 compatibility prologues, we're not python 2 compatible.
 
yeap
my code, why would I support python 2
anyway zca is damn cool and scary at the same time :P
@khajvah you should read this too: muthukadan.net/docs/zca.html
 
Sorry to bother you guys but was wondering if I could ask for a bit of help. I don't really think my question warrants a post, so I figured I'd ask here
 
oh nice, thanks a lot Antti
@ringo rule number one: don't ask to ask
 
@ringo cbg, room rules sopython.com/chatroom say that You do not need to ask if it’s okay to ask a question.
(which incidentally hints to me that perhaps you've not read the room rules yet :P)
 
Just thought I'd be courteous
 
8:13 AM
anw, go ahead.
your courteousness made a 10 line metachat here :D
that's why we say "don't ask to ask"
 
Without getting too much into the details of the exercise, I have a recursive function that outputs an integer value, but I need it to output a boolean value. I'm not sure how get it to do that
 
yes, yet there is such a thing as "too little details" what boolean value?
 
It wouldn't be so weird if I could just write another function, but given the circumstances of the assignment I don't think I should
 
just retun True, that's a boolean value :d
 
or bool(my_int)
 
8:18 AM
@vaultah lol didn't know it worked
 
if it needs to be a particular boolean value then perhaps use a condition, or if the condition is value != 0, use bool(value)
@khajvah hmm...
@khajvah perhaps you should read the python documentation a bit :D
 
It needs to return a boolean value based on the number the function computes
# Given a string and a non-empty substring sub, compute recursively if
# at least n copies of sub appear in the string somewhere, possibly with
# overlapping. n will be non-negative.
I got the function to calculate and return the value, but I don't really want it to return the value. I want it to return if the value is greater than or equal to n
 
@AnttiHaapala remember I learned python by doing DJango
 
@ringo no it doesn't.
@khajvah that's bad
 
@AnttiHaapala in Django, you would have global my_bool = True
and then modify that if needed
 
8:23 AM
I must say the chat ping is much nicer here on stackoverflow than on Chem.SE
Less alarming
 
it is like "learning to drive a car by sitting in a Mongolian taxi"
 
@AnttiHaapala It's not exactly true
though
 
@khajvah ...would you?
 
@ringo your function needs to only return bool.
 
in fact, my django-specific code is decoupled from the rest
 
8:25 AM
what you will give as an argument is a) the current position, b) the current number of matches and c) the string.
if current number of matches >= n for this recursion, return True, and collapse the recursion.
Otherwise recurse; and if you meet the end of string and current number of matches < n, then return False
 
hmm... I'll try it
Thanks for your help
 
so something like:
 def recurse(position, matches):
       if matches >= n:
            return True
       substring_position = string.find(substring, position)
       if position == -1:
            return False
etc...
that's like 33% of the needed code :P
 
8:57 AM
alright, since I have too much shit to do lately, I decided to live like a robot and plan everything down to every 5 minutes
 
That way madness lies
 
I will put in drinking sessions too
 
What happens when life intervenes? And things take longer than expected? Or a coworker disrupts you?
:D
You'll end up beating someone's head in with a keyboard and a copy of Clean Code.
 
@Withnail right now, I have so much shit to do I end up watching house of cards and doing nothing
 
Ah, that's a different problem.
 
9:01 AM
@Withnail run the evaluate function again
 
is there a way, in python2, to have it fail on open(unicode_string())?
 
@khajvah as a serial procrastinator, I found planning things out to the nth detail made things worse
as soon as i fell two or three behind, I fell into a 'fuckit, might as well watch house of cards' attitude
 
damn
my other plan is doing one thing per day
 
Having something like workflowy was similarly problematic, because it had everything on it, and where do you even start?
Well, I found bullet journalling helpful.
 
"I study this shit today only"
 
9:06 AM
Long term goals go in the month (or week) space, daily stuff in each day. Every day you carry over your things deliberately, or decide not to do them.
 
@FlorianMargaine can you elaborate? For example what is unicode_string?
 
The foregrounding of the to-do list really helped me. To-do software was traditionally where tasks went to die, for me.
 
@Withnail I find bullet journalling not very helpful with long tasks
 
@vaultah I mean forcing me to call byte() on unicode strings I would pass to open(), same behavior as in py3
 
I'd hazard that the task could be broken down, but:
 
9:07 AM
preparing a py2to3 migration...
 
@Withnail longer than 1 hour tasks with no clear outcome
 
with this stuff, it's a case of YMMV, I found it worked for me, for my problems.
A task without a clear outcome may not be a task...
 
yea but I can't break some stuff down to tasks
 
do you mean like "Study Astrophysics for 2 hours"?
(or equivalent)
 
yes
now I feel like I am wasting time on deciding how to plan
 
9:09 AM
Right, so 'study' isn't the outcome. Study is the process. The outcome might be "Be able to recite blah 5 equations after 1 hour"
The illusion of productivity. :)
 
alright I am out
bye all
 
productiverbrb
 
yeah, "study" isn't a task, "learn 5 pages" is probably a better way to go
if you learn more than 5 pages, great
 
(i suspect he's gone, but yes - and how do you know you've learned 5 pages? Easier when it's quantifiable stuff, or things with defined outputs like being able to do a proof. Thing to think about, rather than an unhelpful question.)
 
9:50 AM
cbg
@Withnail what life :D
 
@AnttiHaapala Thanks. I was asking because leetcode was accepting the insert answer and rejecting the other one. And not even that the solution was inefficient. But that the output was different. It's bugged, I guess.
 
If it's defined in a function, there's a huge difference
brief cbg
I mean, if nums is an input parameter which should be changed on output, then only the mutating version (that doesn't rebind the name nums to a local variable) will work
 
10:11 AM
I agree, but this question is worded vaguely in a way that attracts people who are actually looking to use min() and max() instead of to find the maximum or minimum integer allowed. Is there some other way to guide people in the case they're here and get confused? — JxAxMxIxN 14 mins ago
I would suggest editing the question, but it seems pretty clear to me
what do you think?
 
interesting...
'"really the last good system programming language was C"
"Industry got to choose between Smalltalk and C++, and the choice was made by those people who didn't want to learn what OOP was all about"
 
10:50 AM
wow, just wow.
this is how you "deal with those pesky terrorists"
 
user6568562
Saudi Arabia reminds me of that lawyer played by Sean Penn in Carlito's way
 
so would it be time for the US to stop buying this damn oil
 
user6568562
I don't think so. I think this would be time to sell them even more missiles
 
stupid Finland sold weapons to Saudi Arabia, yet again...
 
user6568562
I imagine the Saudi goverment is yelling to the US, while bombing : "Dad, are you looking ?"
 
10:57 AM
even though it is against the law
according to law, arms exports are not allowed to countries participating in a conflict
... "except under special circumstances" as in "oh, but it is good money"
 
user6568562
But this should make you wonder why Western countries have to deal with refugees when Saudi Arabia et al have the means to build gigantic golf courses in the middle of waterless deserts and bomb neighboring countries for democracy purposes
 
user6568562
I don't mean to change the subject, but I can't not think it
 
"democrazy" you say
because Saudis are damn good with this democracy thing. World-famous for it.
 
user6568562
Oh yeah, I forgot that
 
"forgot" :D just by accident
easy to forget
(now reading on Swedish nuclear weapons program)
 
user6568562
11:03 AM
That Sea ice won't melt itself you know
 
user6568562
I'm wondering Antti, did you have to deal with money in the programs you wrote ?
 
nope, not yet
neither have I dealt with physics
just some percentages and probabilities...
and coordinates...
 
user6568562
Still seems like some fine headache-based activities to me
 
you never compare probabilities exactly,
it is always "above or below limit"
same for gps coordinates -
the GPS system has error margin much larger than the error of floating point
 
user6568562
Oh I see your point
 
11:10 AM
@randomhopeful double precision floating point in gps coordinates would have micrometer precision on surface of earth.
so "good enough"
 
user6568562
Good enough, indeed : D
 
same for dec64 too
the point on dec64 is that it has all the precision that double64 would have
 
user6568562
cbg
 
user6568562
11:13 AM
@AnttiHaapala That's what I thought I understood, as well
 
it is more expensive to implement in hardware
it does have more complex error behaviour
but otherwise it would be good enough for both physics and business, as a compromise
or this:
In computing, decimal64 is a decimal floating-point computer numbering format that occupies 8 bytes (64 bits) in computer memory. It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations. Decimal64 supports 16 decimal digits of significand and an exponent range of −383 to +384, i.e. ±0.000000000000000×10^−383 to ±9.999999999999999×10^384. (Equivalently, ±0000000000000000×10^−398 to ±9999999999999999×10^369.) In contrast, the corresponding binary format, which is the most commonly used type, has an approximate range of ...
 
user6568562
@AnttiHaapala How complex is its error behavior ?
 
well, it is more complicated to implement in binary hardware for sure
 
user6568562
I see, thank you dude [ :
 
user6568562
For now PEP 327 is here to reassure : D
 
11:51 AM
How can I determine if string contains any text? And non whitespace characters? Because '\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x‌​08\r\n'.isspace() returns False
 
 
1 hour later…
12:51 PM
cbg
 
Good Sunday (morning) cabbage!
 
user559633
cbg
 
@VeeeneX if the name is any indication, isspace should only be True if the string is space
if you want to know if it contains space, you should check each character, or maybe search for everything that you consider whitespace in the string
 
So, I have a semantics question: Is a wrapper around a public web-based RESTful API considered a library? Because I'm not writing the API itself, I'm just allowing easier access via Python.
 
user559633
Yeah, probably. If it's meant to be used by other scripts/programs
 
12:57 PM
google calls it a client library developers.google.com/api-client-library/python
so yeah
 
cabbage
The OP has commented that a particular question is a dupe. But I don't think it is. Can anyone confirm? stackoverflow.com/q/40199689/4099593
 
1:15 PM
@vaultah Why is Google only indenting their code by 2 spaces? PEP8 shame! Shame!
 
They want to save space(s) B)
 
they break their own style guide, not just PEP8 :D
 
I just used Firebug to edit the page's code, so now it looks nice :)
 
1:47 PM
I've got 3 dupes for that, waiting for OP to clarify, but they aren't
 
> I would never down-vote a first time poster either.
 
too bad ^
wait, full quote:
> That wasn't me. I would never downvote a first time poster over something so petty
not the same meaning
 
well these are different comments
it's fun to watch people attributing my downvote to someone else, heh
 
We can use this as dupe stackoverflow.com/questions/8270092/… if OP replies that replace solved their issue
 
2:54 PM
@Antti Perhaps between the two examples, there is a difference in efficiency, and perhaps you are right that in a circumstance with a large amount of data, you would want to use something more efficient such as collections.dequeue, but that was not the question that @doodla was asking. Hence, calling my response "very incorrect", is actually...plain old incorrect of you. He was asking a question regarding the output of his examples, not the efficiency
@doodla, regarding the output, it is the same. The website you were using for testing yourself likely was only testing for one of the two answers
So for questions like that you need to consider what the most likely thing another coder may have done
Using @Antti's advice:
from collections import deque
d = deque(nums)
[d.rotate() for i in range(k)]
 
i am not sure how to make code formatting in this chat
 
@JakeWaitze the difference between "modifies original" vs "creates a new one" is very significant
 
not in output, especially if you're setting the original variable to the newly created list, which is essentially a modified version of the original
creating a new list there is bad for resources
but the output is, the same
which was his q
efficiency was outside the scope of his q
and often times you may just begin to confuse a newcomer if you start to brigade them with higher concepts
 
the question was very much "what is the difference between the 2" and you said "nothing"
 
3:05 PM
perhaps that answer was too terse
either way,
 
with that logic, if at your workplace they train you to a new job, or they find another to replace you in a new job, then there is not much difference :D
 
it seems odd to me that there are so few users chatting on SO
no no...
a workplace is a workplace
you should expect everybody to be operating at the highest levels
 
from the workplace's perspective it is perhaps the same whether they train you for a new job, or they make you redundant, get a new person and train him/her to the new job, but from the perspective of those others who are bound to you, it matters a lot.
that's why dict.clear() exists even though you can always make a new dictionary.
yet someone even asked that as a question: stackoverflow.com/questions/369898/…
 
i'm not sure that's the reasoning i would give for why dict.clear() exists, but alright
but yes, i do agree that everybody should be operating at the highest levels at a workplace.
oh, i'm mistaken. i thought you were saying dict.clear() exists for a different reason, but I read what you linked now.
 
3:23 PM
cbg
 
hey @AnttiHaapala what's the good word today
 
@idjaw angular
 
@AnttiHaapala cool. Personal project?
 
no, work
before I tried it, I was "meh" but now I realized its immense power when I added filtering to a table...
zero code in javascript, and I have automatic filtering of objects with textbox and none of the crap that JQuery DataTables is
 
3:32 PM
Hi everyone. Anyone want to help me?
 
*resists the instinctive urge to answer*
 
Build a cube-shaped mesh using the half-edge data structure.
 
nope
it's sunday
I'm still drinking coffee
 
@Mike cbg, please read the room rules: especially the part about not having to ask if it is ok to ask...
 
are you asking us to write one up. Or is that what you are trying to do, and you are having difficulty in your implementation?
 
3:34 PM
@idjaw yes sir i have problem with implementation.
 
le Gogh speaks my thoughts
 
Le Gogh is wise in his earless knoweldge
 
@AnttiHaapala Sorry Sir.
 
Antti, can I call you sir from now on?
 
@idjaw do you have a doubt?
 
3:35 PM
i am only 18 years old.
 
@idjaw Sir, can I call you sir from now on, sir?!
 
@Mike It's all good :) Show an example of what it is you are having difficulty with
 
fixed it for you
 
@Mike that is entirely irrelevant, for better or for worse:)
 
@AnttiHaapala LOL!!
 
3:36 PM
I did not sleep for last 2 days. I am in china time is 11:35 pm.
 
*sigh*
 
Monday need to submit. No body helping. So i just think try on stackoverflow.
 
@Mike Just note that asking the same post in multiple (unrelated) rooms is not quite the right way, here.
 
nice catch
 
@BhargavRao sorry. ok i now i just use this room.
 
3:37 PM
@Mike I am a Finn, not a Brit, Canuck, Yankee or any such thing. If you wanted to be polite by calling me sir, then please do not call me sir :D
 
although it's nice that you haven't asked anything specific in any of the rooms
 
@AnttiHaapala ok :)
 
if you wanted to ridicule me by calling me sir, then please do continue :D
 
anyway, I'll step back and let the kinder folks interact;)
 
King of Oulu is more like it
His royal majesty of Oulu. First of his name
oh oh I got it!!!
Herra
do I win?
 
3:39 PM
Suomi Mainittu
 
lol :D
 
Perkele
 
what have I done...
 
you asked for this
 
unleashed monsters here...
 
3:40 PM
:D
unleash the Kannadians
 
unleashed Simo Hayha
the master of them all
 
::
^ there you go
 
00:00 - 16:0016:00 - 00:00

« first day (2199 days earlier)      last day (2743 days later) »