« first day (3106 days earlier)      last day (2065 days later) » 
00:00 - 16:0016:00 - 22:00

16:00
in templates/ex.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Example</title>
</head>
<body>
    {% include url_for('this_place') %}
</body>
</html>
myapp/this/place comes back just fine. But I get jinja2.exceptions.TemplateNotFound: /myapp/this/place
when I go to /myapp/ex
The πth dimension, where all fractal muses reside, has not intersected with our own reality in some time. Perhaps integers are passe' over there.
"Sorry, discrete beings are Out this season. Let us know if you discover that each of your atoms are themselves tiny universes, and then we can talk"
Fun fact: the volume of the π dimensional unit sphere is π^(π/2)/[π/2 Γ(π/2)]
Fractional dimensional ball?
Yup
(Of course really it's just the analytical continuation of the volume for integer dimensions)
16:26
Oops, you dropped your Ikea hexwrench tool into that equation. Here you go: Γ
rb^² folks
rbrb @AndyK
@piRSquared {% include url_for('this_place') %} - what are you trying to do there?
url_for is to generate urls for the client
and {% include %} includes a template; it does not make http requests or call view functions
what is your actual use case?
I'm trying to fetch the html that is returned from the function this_place and embed it in my template. I thought making it accessible via a path app.route('/this/place') would make it easier but now I'm not sure.
something common you want to use on all pages? then define a contextprocessor function that returns the data you want (e.g. {'mymenu': ...} if you want a dynamically generated menu everywhere). then simply use {{ mymenu }} in your base template (or whatever other you need it in)
render_template('ex.html', whatever=this_place())
if you just need it in one place
then just use {{ whatever }} in your template
16:37
ahhh
that makes sense. trying now
Beautiful! Thx
wim
wim
17:30
which RO is removing stars? this had like 3 yesterday chat.stackoverflow.com/transcript/message/45964579#45964579
can you cut it out? just let the starboard do its thing organically
is in an operator? eg 's' in 'asp' What's the term I'm looking for?
Excellent, thanks :)
18:19
Hmm so I have a Class class with an attribute which is a list of Student objects, and I want to do for student in instance_of_Class: print(student.name). This works:
def __iter__(self):
    for student in self.students:
        yield student
Class.students being the list of students. But is it the best way, do I need to implement __next__ etc?
IIRC __next__ is only necessary if your __iter__ returns self
I almost never bother to make the class itself into a generator. I use the pattern that you're using now.
... Although I think you can do it in one less line with yield from self.students. 70% sure you're allowed to yield from a sequence.
@Kevin That works, but yield student from self.students and from self.students yield student` didn't. Which seems rather obvious now, as the variable is unnecessary, but I'd read a student inbetween where you wrote yield and from.
The primary hint that yield x from y is not valid syntax is that x is never bound to a value
@Kevin it is not working because IIRC it is not a valid syntax
@toonarmycaptain what you are looking for is something like:
>>> class C:
...     def __init__(self):
...         self._students = 'Tom', 'Jerry'
...     def __iter__(self):
...         yield from self._students
...
...
>>> for student in C(): print(student)
...
Tom
Jerry
as you can see it is yield from iterable not yield item from iterable
it is not a for (as in a loop, generator expression or comprehension)
btw cbg all
18:35
@Kevin Yup :)
I think we were all on the same page, but it's good to get independent verification
for some reason I didn't see your last comment
I had to refresh the page
yup we are
:D
sorry being captain obvious then
;)
That which is said two times is true
indeed!
@PeterVaro Apology accepted, Captain!
18:37
why thank you :)
It's been a while. Hope you're doing well.
yeah, things are turned out pretty fabulous -- but tbf I just got bored of SO
I will even leave the C room within a week for good after making and leading for 5 years
:)
how things with you?
I really only commented because, reading-wise in my case here, yield student from students, which is what I'd misread, reads much more nicely than yield "something which I don't mention it could be indexes or late work or actual assignments, who knows?" from students...
the other day I wanted to append something into your list -- as I used to do it
Just fine. As soon as I hit 100k reputation I'm going to become a woodland hermit.
18:40
are you still interested in lesser known yet marvelous movies @Kevin?
Yeah, tell me about your marvelous find.
@toonarmycaptain you have a Class class? That seems like it could be confusing, why not classroom or course or something?
@Dodge Well, not that this hasn't been discussed before... But, for instance, classroom is something I'd not thought of, but it grates because it's the wrong noun, and a class might never all meet in the one room, and at least in my wife's case, she teaches an Algebra I course to several periods/classes.
@Kevin not perfect by any means, but when I decided I'm going to watch it little did I know, that it is actually hungarian! I'm kind of proud of this one as it is rather unique in many ways -- and one of the few movies that are dubbed in english by hungarian actors originally, so foreigners can watch it as well without subs. It is called Ruben Brandt, Collector and I give it a solid 8.1/10
The story could've been a bit more complex (hence my -2) but the visuals are kind of making up for it
@Dodge But in context it's not really confusing, I mean you're defining a class Class but then you're doing Class.students, Class.name, Class.average, Class.weighted_average etc. You're not really expecting to see the class keyword in your modules/logic anyway, right?
18:47
Hmm, interesting character design. Feels a little Art Deco
@Kevin cubism at its best
@toonarmycaptain Well, you're not doing Class.students unless students is a class-level attribute rather than an instance attribute. More likely it'll end up being the_class.students or something.
It does mean that you don't get to use the low-effort naming pattern of "instances have the same name as the class, except lowercase". I can do fred = Fred(), but you can't do class = Class()
@toonarmycaptain It has confused me in trying to parse what was happening initially in the discussion here. (But I am probably easily confused) I think period and class could be interchangeable. I think documenting the functionality of Class classes might be challenging.
wim
wim
@Kevin more pythonic would probably be return iter(self.students)
@wim why are you considering that more pythonic?
18:50
Oh yeah you have to instantiate the Class class so it will probably be called something else anyway
wim
wim
@PeterVaro cuts out the middleman
(making a generator which only yields from the iterator that self.students is already providing)
@Kevin You're right. But _class or class_ functions. Currently I have new_class because I haven't hooked it into the rest of the logic yet (I was using a nested dict before) and was planning on using something like current_class, loaded_class or subject_class
(maybe better known.. I don't know really..)
PEP 8 recommends single trailing underscore to avoid collisions with keywords, incidentally
@Kevin What does it recommend when the module the class is defined in is for that reason already called class_.py
18:56
I don't think it forbids variables from having the same name as the module they live in. On the other hand, I've spent too many hours of my life explaining how datetime is different from datetime.datetime
It tends not to be a problem for me since I almost never define instance variables in modules. Classes and functions are enough for me.
@Kevin Fair enough :)
Obligatory cabbage
But maybe I'm being too narrow-minded in thinking only about variables defined inside the module. What if my main code looks like import class_; class_ = class_.Class()? Now I've overshadowed the module name.
Summer's coming; there can't be enough shadow
19:13
I wonder if built-in modules fractions and sets decided to pluralize their names for this reason
But then what will I name my list of set objects???
@Kevin That's fair, but I haven't been doing that, so hopefully it won't be an issue. I've been doing from dionysus_all.class_ import Class - but I will make a note somewhere that this needs to be warned about in docs.
@Dodge This is my work-in-progress if you're curious. You can tell me if the documentation is less clear to you than it is to me.
19:31
cbg
wim
wim
be pragmatic and use StudentGroup or something dumb like that
@Kevin sets?
Yeah. It's deprecated in 2.6 and 2.7 and just gone in 3.X, but what if I fall through a time portal to the era of 2.5?
My priorities will be 1) reinvent penicillin 2) hammer out this naming conundrum
wim
wim
19:54
huh TIL there is sets module in 2.7
LMAO it's just a class with a dict in it self._data = {} github.com/python/cpython/blob/2.7/Lib/sets.py#L412
If it's dumb and it works, it's not dumb
wim
wim
refreshing to know that even Guido's code from 17 years ago looks like some 👋 New contibutor. Be nice style Python
Back in the day when, if we wanted a set, we used a dict with values of all 0
20:21
@PaulMcG cbg :)
20:33
@toonarmycaptain Looking at that, you’ve made things fairly clear. I still posit that a refactor will save you many discussions and questions in long run.
@toonarmycaptain cbg (as I'm just about to head home for the day)
@Dodge Maybe. At this point it's designed as aninstallable application, rather than a package, so it's not like others are importing and using AFAIK. I haven't moved to beta or 1.0 either, so if a better term is suggested, then that's not hard or breaking anything anyone already has, if anyone is using it. Converting to OOP is a breaking change the format by which data is stored anyway, so.
@PaulMcG rhubarb then :) I am minutes away myself.
20:54
Before I go...(when) will the python 2.x tag be removed from this room?
not before the EOL and maybe not for a while after that (we haven't discussed it)
I imagine python 2 code won't magically disappear from the face of the Earth any time soon
21:17
rbrb
00:00 - 16:0016:00 - 22:00

« first day (3106 days earlier)      last day (2065 days later) »