alright have the world's worst static site generator
@djsumdog arrays *and subscripts*!
(it doesn't actually matter what they are, the code just has to compile without syntax errors and then i can replace the code in the method on class construction)
- the ellipsis doesn't mean anything. it's a python object that has some purpose in math libraries i think. it's here just for the purpose of marking code to parse and turn into HTML
- those aren't lists (well actually one of them is - the [html] one) the rest are subscripts, like what you would use when you want to get the item of a list at a certain index.
- of course, python lists of nonexistent objects don't let you subscript them with random objects 10 times in a row, so if you ran this normally it wouldn't run. but in PageMeta i am replacing the render method with a version that converts the weird syntax into a string filled with HTML.
this happens on class construction (not initialization!) and before the method even runs. this works as long as the code runs long enough to get to the point where the code is replaced, which it does because the method hasn't run yet when the object is being constructed. all that needs to happen is for the code in the method to not have any syntax errors, otherwise none of the program will run.
@clacke @djsumdog yeah so if you override the __new__ method in the metaclass it will give you the class name, superclasses, and dict (dict being a dictionary of all class bars including methods). you can then find the method in the dict and then replace it before sending it to the metaclass's superclass (usually `type`)
@xnx38h This reminds me of really old CGI.pm stuff in Perl, you could nest formatting functions:
print p( ul( "one", "two", p("three is a paragraph") ) ); # etc
Code-soup hell, but it made writing stuff from the DB into a web 1.0 looking page simple.
@xnx38h Huh, never used Flutter, is it just for layout/UI elements?
@unlofl flutter is a mobile app development package. you write the layouts in with the rest of the code though. think android XML tags but they're all Dart object constructor calls
@xnx38h Fortunately/unfortunately, I've never done mobile development. But I think I get the idea, I've seen other systems for "E-Z layout design, then just attach your event handlers."
@xnx38h Yeah, curious, and that certainly seems readable.
But I've just gone from Perl to Python, so white-space sensitive and still using semi-colons is blowing my mind.
@bulkington i wanted to show off the fact that it was running python without having to access any local variables (because with the lazy way i'm doing it, i am evaluating everything surrounded by brackets in an empty namespace (there's no way to access the actual method namespace i think) and if it errors i convert it into an html tag)
@xnx38h if you get nasty with dunder variables, python functions can access the namespace of the calling context, but unless you’re writing a debugger, it is probably best not to.
@bulkington oh really? didn't know that, but it still wouldn't be able to access the variables that require parts of the function executing first
@bulkington i could interpolate the expressions into string literals, which would be the rational way of doing it, but then there would be no way of telling the HTML tags from the rest and i would have to come up with a less stupid syntax