« first day (2432 days earlier)      last day (2515 days later) » 

4:00 PM
even now, and its because I find django docs slightly better
 
you already have a software background though, right? that is part of the downfall of jumping in to django when not having done any development I find.
 
I was working a bit on smaller projects (non django), but most of my experience is web (django and flask)
 
PyCharm question for you lot. It seems like it is not reading the dependencies in my setup.py, so I'm getting warnings that it is not listed in my requirements. Before I go digging on the bug board. Anyone else experience this one?
@marxin So yeah. I am totally not surprised with quickly finding your way around Django. Good on you for warming up to it. :)
 
I wont help, vim user here
I must admit that with flask, I ended up having very similar structure to django :)
slightly different
 
@marxin "You must call .is_valid() before calling .save()." if I call is_valid() it doesn't work (of course) because "game" is not set yet
 
4:10 PM
one thing however. Almost all of my projects have no front-end web client. I'm mostly designing API's and middleware. Most apps that have a web interface might have been built with node, some JS framework that talks to one of the middlewares/backends that I worked on. With that separation, it kinda helps with my gravitation towards non-django for my solutions.
 
@marxin maybe I can use this, now I'll try stackoverflow.com/a/4108318/232194
 
@idjaw yeah I wanted to mention that as well. in rest like interfaces flask and django become really similar, especially using these most popular libraries (DRF for django and one for flask, I dont rememeber name atm)
@genesisxyz thats not the best solution. if you could paste your code I can help you
if you want to research on your own, search for perform_create in DRF docs and there is an example with user, you would use the same method to populate game
 
@marxin I tried the tutorials with the User but I couldn't figure it out, there is an official (I believe) tutorial that creates a HTMLRenderer but it didn't work for me, what am I trying to do is to have an endpoint with a sub-resource, because the model that I have has some foreign keys and it makes sense to me to have sub-resources
 
@genesisxyz try this one pastebin.com/7GYttv46
 
@marxin "Cannot assign {id}: "PlayerInGame.game" must be a "Game" instance." - I need to get the value, I try
 
4:24 PM
@genesisxyz no, try replacing serializer.save(game=... with serializer.save(game_id=...
 
@marxin now it doesn't crash but it says "This field is required" in the JSON response
 
which field? game?
did you notice read_only_fields list I've added to meta in serializer?
 
@marxin yes, I needed to remove the read only for game because it was complaining
 
no it has to stay read only
it means that its not populated from json
this is what you want in this case
 
@marxin "TypeError at /api/games/{id}/players/
Got a `TypeError` when calling `PlayerInGame.objects.create()`. This may be because you have a writable field on the serializer class that is not a valid argument to `PlayerInGame.objects.create()`. You may need to make the field read-only, or override the PlayerInGameSerializer.create() method to handle this correctly."
 
4:29 PM
I think if you are going to work together on this problem, it would probably be best to do this in your own room. It's been done in the past. I've done it too.
Could help hammer out the details if both parties are OK with that.
 
for me its fine
 
@AndrasDeak Ok you win. I'm reading the whole python 3.6.1 documentation. I hope you're happy you bastard :)
 
morning everyone
 
@corvid dont scare people
its time to go home
soon
 
mid day for me :(
 
4:39 PM
UK
I'm gonna go with UK
 
wait....I thought the crow was on the east coast
speak crow....what sorcery is this
 
DSM
Duh. Crows can fly.
 
Was on west coast for a bit
 
I meant @MooingRawr
 
today is my day off, need to find a good game to play
 
4:44 PM
dr mario is good
 
@DSM He still hasn't denied the flying thing. So, your statement holds.
 
5:05 PM
Cbg
 
cbg
 
@MiguelAlberolaCano you couldn't make me happier :P
I hope you meant "tutorial"; that should suffice and is much more usefully structured than the actual docs (which are also great, but less for learning the basics)
@corvid flappy bird
 
@AndrasDeak A few months ago it would have been impossible for me to even get myself to start such a long chore. Learning python might just be my first medium-sized achievement in life :)
 
FWIW it's a very good one at that:) Have fun, and we're here if you need any help
 
@AndrasDeak Yes I meant the tutorial. I skimmed 'learning python the hard way', which I assume is python's equivalent to w3schools haha
 
5:14 PM
oh no no no no no not that :P
 
It's the equivalent of w3schools in that it's popular despite being riddled with problems, yes
 
My 3 days of learning javascript half a year ago paid off!
Never again
Now I love python
haha
By the way, what's "Dive into Python 3"?
 
Reading the official tutorial is useful. Reading the language reference is useful if you can stay awake, but don't worry too much if you can't. Reading the entire library reference is not useful. Skimming the library reference table of contents for libraries that look neat to you is useful.
 
@MiguelAlberolaCano I don't know but I'd try clicking the link ;)
 
Also I do appreciate that terrible book of 'learning python the hard way' since it was pretty damn easy and I got plenty of confidence from it. Also I ALMOST got rid of that pesky print stuff habit haha
 
5:18 PM
does "pesky print stuff" stand for "python 2"?
 
Just keep an open mind. And by that I mean, when you read something that contradicts LPTHW, be prepared to abandon your preconceptions.
 
at least there's a py3 version of LPTHW now (for better or for worse)
 
Hmm, I've never appreciated that side of it before. Many find its tone demoralizing at times, but if you're confident enough, "this is hard? Heh, I must be great" could come to mind
 
@AndrasDeak Yes. print() all the way!
@Kevin I only skimmed it, don't worry :)
 
anyone here use google fi by any chance?
 
5:19 PM
@KevinMGranger I mean, the python 3 tutorial looks way more attainable now that I know what is raw_input() for!
 
That thing with the weather balloons? I don't think they're doing that around here
 
By the way I should read the python tutorial...
 
Me too. :P
 
I feel the need to point out that putting parentheses around your print statements in 2.7 will not give you the same behavior as 3.X:
c:\Users\Kevin\Desktop>py -2
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(1,2)
(1, 2)
>>> ^Z


c:\Users\Kevin\Desktop>py -3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(1,2)
1 2
Unless ofc you import from the future
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> print(1,2)
1 2
>>>
 
Who uses python 2 anymore?
 
5:23 PM
from __future__ import phil
 
I assumed you did, since you were talking about raw_input, which doesn't exist in 3.X
 
DSM
Is there an official emoticon for "eyeroll"?
 
Dear Unicode consortium, please implement basic animation functionality.
 
5:27 PM
eye roll ^
(it's a cookie; sorry for advertising falsely)
 
* for effort
 
Kevin M's comment about context is correct in that the message itself can be seen differently.
Especially since this is a public chat, we should just be a little extra careful with some of the messages as they can be interpreted differently and for the negative
 
Oh
Ok
Thanks :)
 
@idjaw - just back from lunch, noticed your comments about writing REST apps without UI front-ends - have you looked at falcon? I did a REST server last year using it, was super easy, middleware if you want it, but you can use your own decorators if you like. ("middleware" is a terrible term for these decorators, if you ask me)
 
5:43 PM
@PaulMcGuire Thanks. Haven't heard of falcon, actually. Taking a look at it now
 
But falcon is already stripped down without views and templates, and just does the REST stuff
 
yeah, easy to get flagged, and flags are seen by 10k+ rep users all across chat with no context
 
While we are sharing. I posted it here a few days ago, but I was introduced to hug too.
 
if it gets deleted by offensive flags, you get 30 minutes auto-suspension
 
@DSM Cows can fly too :D
 
5:47 PM
@idjaw - hmm, I like the API versioning flags in hug, we were just discussing that here at the office a few weeks ago
Does that translate to HTTP headers?
Or part of the endpoint URL?
 
Unfortunately, I have not officially used it yet, so I can't say. I was introduced to it, and read through some of the documentation and had the exact same "like" for the API versioning :)
 
DSM
I'm considering getting the intern to play around with it. #delegation
 
dude!
yes and give us the report too!
intern for room6
 
I'm still waiting for my coffee.
 
DSM's intern gives out coffee? Why wasn't I informed of this....
 
5:54 PM
Long waiting list.
May 3 at 17:50, by Kevin
The ROs demand coffee and after some resistance, the intern disappears. Three months later, he arrives at my front door, filthy and riding a llama. He hands me a stone-cold coffee. "That's the Americas down", he wheezes.
1.5 months to go.
 
we need to do something about this. This is unacceptable.
 
We could get him a second llama.
 
That llama needs to be stationed somewhere to maintain optimal llama speed
 
Or just make his llama an async llama
 
so it's an easy swap
I'm glad we have Paul to solve this one
We really need to learn how to be CEOs...we don't even need to be good at it: money.cnn.com/2017/06/13/investing/…
 
6:02 PM
May 3 at 15:46, by Kevin
If I was CEO I would release a lot of spurious press releases about my dog
 
why hasn't anyone made Kevin CEO of something yet.
Kevin, you can be my CEO
 
DSM
May 3rd was a very quotable day from Kevin.
 
It's pretty likely that yahoo was already so doomed, the only thing Mayer could have done was slow the bleed, which she sorta did
 
You could be CEO of Spurious Press Releases, Co.
 
Spurious Press Releases of America, Co. (SPARC)
 
6:05 PM
@KevinMGranger You do make a good point. It's hard to rejuvenate anything that Terry Semel touched.
He is another level of bad
 
When I wrote that comment I was thinking of the podcast Welcome to Nightvale, whose titular city's mayor would give frequent pointless press releases and then fade to invisibility before any reporters could ask a question.
Maybe that's why I'm not a CEO. Because I don't know how to become literally invisible.
 
6:21 PM
Mayor Dana Cardinal is way better
Though Pamela Winchell does give some great emergency press releases
 
I don't know, that election seemed rigged. But I guess I can't see all the glowing lines in the sky, planning everything for that little town.
 
You'll just have to talk to Steve
 
@KevinMGranger view spoiler
As a sidenote, the Alice Isn't Dead logo? One of the best that I've ever seen
 
what are you guys talking about?
 
6:26 PM
glares at link
@idjaw Have you never listened to Welcome to Nightvale?
If so, congrats on being one of today's 10k! And enjoy:
 
If the host's tone isn't doing it for you, just stick with it. He gets sassier as time goes on and it's great.
Orbiting Human Circus is great too. Couldn't get into Within The Wires though
 
@WayneWerner I have never heard of this before.
 
That's funny - I love WTW, but OHC is... fine, I guess.
@idjaw I'm so excited for you! You have like 160 episodes I think, ahead of you
my bad, transposed
107
It's so delightful and dark and hilarious and fun.
 
is it well narrated?
 
Very well done. It's a great listen.
 
6:33 PM
@KevinMGranger Yeah, I feel similar. view spoiler
 
I even got my daughter to start listening to it at 10
 
haha
that's awesome
 
7:25 PM
wow, that's really great narration. reminds me of this guy
 
7:36 PM
@Rawing that's awesome
 
he has more stuff on his official website, but that one's the best!
 
8:26 PM
Could anyone explain what's going on in this line of code:
verts = [0 for x in range(1000)]
It comes from this answer.
 
that's called a list comprehension
it's making a list full of 1000 0s
 
Why did he [the author of the answer] say that it's not efficient?
 
No idea. If you need 1000 zeros, a comprehension is the way to do it.
 
The question just asks for a list with a known number of elements, the zero part isn't necessary
 
DSM
It'll be a lot slower than list multiplication (relatively, of course -- absolutely it'll still be very fast.)
 
8:30 PM
Also note that they said "probably not efficient." But in this case, we should compare with timeit and dis.
 
I'll go read-up on this list comprehension stuff.
Hm, I wonder if the array gets resized and copied over 1000 times in this case.
 
In [4]: timeit list(bytes(1000))
5.93 µs ± 24 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

In [5]: timeit [0 for _ in range(1000)]
25.4 µs ± 1.03 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

In [6]: timeit [0] * 1000
2.2 µs ± 15.3 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
So the comprehension is slower than bytes or multiplication by an order of magnitude.
And multiplication is twice as fast as bytes.
 
I wonder if it's possible to have a dynamic condition in a comprehension, so it creates a dynamic number of elements that's not known at the beginning of the array creation.
 
Yes, it's possible.
 
[0 for _ in range(100) if random.random()<0.5]?
 
DSM
8:35 PM
Sure, that'll do it.
 
Comprehensions are just sugar for regular for loops (with a couple easy optimizations). They don't allocate the list ahead of time.
 
or [0 for _ in range(random.randint(0, 1000)]
 
But even the comprehension length for range(1000) isn't known ahead of time.
 
Hey all! I was hoping to get a couple more votes to undelete this question -- while it seems opinion based, there is a good answer here. (Yes, it's my answer -- that's why I could find it quickly. ;)
 
timeit.timeit.timeit.timeit.timeit.... how many times to timeit. before it can time it....
 
8:36 PM
Well now I'm saying that to the tune of Whip It. Thanks.
 
@EthanFurman so we want to undelete an opinion question to hammer it as another one?
 
@EthanFurman I don't know, I'd just VTC as dupe,
 
How will it be a good signpost, they seem to say the same thing.
 
The other one isn't opinion based -- it speaks to why we created Enum in the first place. This also happens to help answer Adam's confusion, and provides another way to find the better question/answer.
 
On duckduckgo your answer is the 4th result
searching for "Use of enum vs a “normal” class in Python"
 
8:39 PM
Oh, that's cool! :)
 
like, literally his title
 
Ah, in that case I won't worry about it.
 
we have a trillion duplicates of god-knows-how-many questions and nobody seems to be able to find them
 
Guess I should start doing searches to see if the good answers show up with the bad question titles. ;)
 
Nah, the OPs should be doing that :P
 
8:40 PM
True. But if they aren't, then I should before trying to reopen the dumb thing.
Thanks for the help, everyone!
 
@EthanFurman I'm happy to cast an undelete vote on that (and dupe-hammer it) if you think it'll really help people find your answer. OTOH, Adam's post is pretty generic looking, so I'm not sure that people will find it any faster in a search engine than they'd find the one you answered.
 
Thanks, but it looks like the search engines are doing fine without another duplicate question. A deleted question takes up less (cognitive) space.
 
Indeed. If it can be an excellent signpost then its good, but if it just adds clutter to a search results page then it's not so good. ;)
 
9:09 PM
@NickAlexeev verts = [0 for x in range(1000)] is very similar to doing verts.append(0) in a for loop except that the list comp uses a special LIST_APPEND bytecode, which is faster than calling the list.append method. In either case, the array that the list uses to store the (pointers to) the list items doesn't grow each time a new item is appended.
Instead, the list_resize function over-allocates each time the array size needs to be increased, using this sequence: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, .... You can read about it in the listobject.c source code. Even if you don't read C, the source code is well-commented, and you can learn a lot just from the comments.
 
 
1 hour later…
10:29 PM
I do not see __iter__()/__getitem__()/__next__() as attributes of object or type unlike __hash__ or__eq__. Are these not overridden methods?
 
AFAIK only iterables have __iter__ and __next__
>>> iter(object())
TypeError: 'object' object is not iterable
Both suggest that __iter__ is non-trivially defined, and if it's defined, you get an iterable. Similarly __next__ belongs to iterators.
 
11:29 PM
"".join(["what", "have", "you", "tried", ".", "com"])Pythonista 2 mins ago
rude, but lol
 
hehe :D
 
11:41 PM
@SterlingArcher Closed.
I posted this comment the other day.
Please don't scrap the Web, some people are still using it. — PM 2Ring yesterday
 

« first day (2432 days earlier)      last day (2515 days later) »