« first day (3293 days earlier)      last day (1647 days later) » 

wim
3:02 PM
@Kevin pretty difficult actually and platform dependent. e.g. you can't have a filename on windows called AUX ... ¯\_(ツ)_/¯
Linux lets you have any old filename, as long as it doesn't have a /
 
or a null byte
 
wim
you can even have filenames like - and *, which you have to be careful when handling ...
 
everything else is fine though
 
Yeah, I think I'm doomed to fall short of perfection no matter what I do
 
@Kevin but you are the Kevin... surely that's not possible! :(
 
wim
3:04 PM
perfection is the enemy of good
 
Ok, I'm not falling short of perfection, I'm asymptotically approaching it ;-)
Let us charitably ignore all of the times I move away from perfection, sometimes at a vigorous sprint
 
something fishy is going on...
 
@wim nah... Perfection is a really rubbish board game
 
ok. i've got a weird dependency issue here:

flask_testing.TestCase has a "create_app" method. some package in [code i didn't write, but have to use] also has a "create_app" method, which uses flask's original. i'm creating a pytest fixture—which needs to use the _other, non-flask_ create_app method.

this works as intended: from [whatever] import create_app. then i use the method in the fixture
now, when i use that fixture on a test which inherits from flask_testing.TestCase—I get a not-implemented error (which ultimately leads to: pytest is using the original TestCase.create_app() method, and not the method that i import in the pytest file)
 
3:11 PM
import it with an alias (from [whatever] import thing as otherThing). And use the alias in the test case
 
on the other hand (here's the weird [i think] part):

if i make _another_ class (call it BaseTestCase) whose base class is flask_testing.TestCase, and import [whatever].create_app in the file containing BaseTestCase, then use the fixture as i did before, everything works well
i tried that, but still got the same error! (???????)
i thought the alias-being-ignored thing was especially weird
 
do the thing that I would never recommend - import from within the test function I think you fixed it with the subclass
 
i did, technically, but i've got to figure out why. it irks my sensibilities to have a subclass which has zero functionality :(
 
I agree entirely. Sadly, this is out of my wheelhouse. So, I will be about as seful to you as a doorknob... but I'm all shiny, though :P
 
if only i had a door D: D: D:
 
3:25 PM
a door, a door, my Kingdom for a door!
 
wim
how do you over-ride the syntax highlighter again? I need to put C code in a Python answer here
 
```lang
code
```
I think ^
> The opening fence can be followed by a syntax indicator. On Stack Exchange, this can be a Prettify module name (e.g. lang-cxx) or a tag for which syntax highlighting has been configured (e.g. c++). ```none disables syntax highlighting.
<3 code fences
 
wim
so lang-C ?
 
@AmagicalFishy FWIW create_app is used in the tutorial, and AFAIK (don't trust that at all) is somewhat a convention when using the app_factory pattern with flask?
 
that may be why the original programmer used 'create_app' as the name of the method, yeah
 
3:29 PM
@wim or just C, yeah
 
wim
grr
finally got it, it was lang-c.
 
heh
 
user11867329
@MisterMiyagi I might steal your Profile Picture.
 
wim
> Take a slice of the tuple pointed to by p from low to high and return it as a new tuple.
 
What's wrong with that? It'll hardly return the same tuple
 
3:43 PM
Is this about tuple interning? And does it really matter if it's a new tuple or the old one with another reference?
 
wim
Well, it matters if the docs demand that a new tuple is returned.
@AndrasDeak No. It's not interning.
An intern means you maintain a registry of tuples and you dig an old one out of the intern
 
sorry, I never got the hang of interning vs caching
what would caching be then?
 
wim
I think they are fairly synonymous but when I think of interning it may be pre-loaded like "here's one I prepared earlier" whereas caching is more like "well now that I did all that work, may as well keep this one around in case we need it later"
 
cbg
 
cbg
my understanding is:

caching: I've used this before, and I'll probably need to use it again
interning: I'll probably need this at some point. So I'll cache it before it's even been used once
 
3:58 PM
ah, thanks
 
I wouldn't count this as interning though:
z = (1,2,3)
id(z)
4503813360
id(z[:])
4503813360
z = z*1000
id(z)
140304720650264
id(z[:])
140304720650264
I usually think of interning for frequent values, like all the ints from -5 to 256, or the empty tuple, or all single ASCII characters.
 
wim
Yeah I wouldn't call that interning neither caching
 
isn't that just some peephole optimization?
 
wim
optimization, yes. not peephole.
 
Or is that exactly wim's point regarding the potential docbug? An edge case?
 
wim
4:07 PM
yes that is my point about the alleged doc bug. it's not a new tuple.
 
I was just referring back to @wim's original post, that it does not always return a *new* tuple.

Kevin'd
 
okay, thanks
 
wim
peephole is a compiler optimization. this is a runtime optimization.
 
ah!
 
But when it's the empty tuple, that looks like interning:
>>> id(z[0:0])
4487585864
>>> id(z[0:0])
4487585864
>>> id(())
4487585864
 
wim
4:09 PM
yep, empty tuple is interned
 
morning cabbage
 
wim
looks like there is a big tuple intern, actually: github.com/python/cpython/blob/…
but the slice thing is not related to that
> The following function breaks the notion that tuples are immutable
looks like CPython might resize a tuple in-place, if it sees that there is only one reference to it hanging around
 
strings are also sometimes mutated if there is only one reference to them
 
wim
I can not figure out how to get into that code path though
>>> z = (1,2,3)
>>> id(z)
140737352822720
>>> z *= 2
>>> id(z)
140737353132640
 
try z /= 2
 
4:21 PM
⁽¹,²,³⁾
 
wim
heheh.
 
try to add another assignment call before doing the multiplication
z = 1, 2
y = 3, 4
z *= 2
 
4:52 PM
do you sweet and sexy folks use a lot of pytest?
i'm wondering, if i have something defined within my conftest.py outside of any fixture definition
will that thing be instantiated only once?
 
Is pipenv a replacement for venv and requirements file approach?
 
say:
app = [result of some complex function]

@pytest.fixture(scope='session')
return app
will the complex function which returns "app" run every time a test runs, because it's defined outside of the fixture?
 
module-level code only runs once
 
:nod: tyvm
 
ugh, I booted windows like 10 minutes ago and have already used 3 swear words since then
 
4:57 PM
why are you using windows 10 for anything but playing videogames
 
@AmagicalFishy Try it and see? Put a log or print statement in there? Why do you need to define it outside of the fixture def? I've never used the fixture scoping feature, but I would assume it would keep it for the session if it's scoped as such?
 
why are you using windows for anything but playing videogames!?
 
I got tired of linux crashing when I try to suspend
 
oof. i can't keep the difference straight between suspend, sleep, and all those other ones
but i've heard one of them causes problems (suspend, probably)
 
all of them do, at least on my PC :(
 
5:01 PM
@toonarmycaptain i could actually just use a fixture-within-a-fixture now that you mention it
my computer's actually been pretty tame when it comes to sleeping/suspend/etc. (or, at least the ones i use). i wonder if problems are distro-specific
 
the problems are most likely hardware-related I think
I've had these problems on both arch and fedora
 
ah. i'm using arch. lemme try to suspend it and see what happens
suspending to RAM worked like i'd imagine it should!
suspending to disk... i uh... can't actually tell if it did it, or if it just shut down my computer :D
 
Windows has never had any problems entering sleep mode (except when I had a b0rked motherboard), but linux randomly leaves the fan(s) turned on and then dies when I press the power button
I should probably find out if it's the CPU or GPU fan or both
 
oh, weird
 
@Aran-Fey Mine are :) Of course I managed to squash the corner of my laptop soon after I got it, so I believe the hinge is not/mis-registering opens. Of course with the power button being a little dodgy and my being impatient...waking from sleep/hibernation on purpose not eg while the machine is closed and in a bag both seem predicated on planetary alignment, whichever OS I use.
 
wim
5:10 PM
@Aran-Fey actually it is possible (and fairly easy) for it to run twice if you structure your tests/package poorly
runs once as "mypackage" and once as "__main__"
 
how would that happen?
oh, you mean if a file imports itself?
 
As I execute this fifteen-minute-runtime program for the fourth time, I suddenly have a great deal of compassion for every SO user that ever asked "How do I make [third party library] run faster?"
C'mon BeautifulSoup, you shouldn't be the bottleneck here. That title should belong to requests, on account of my tin-can-quality internet connection...
 
BS is pretty dang slow
 
wim
it happens with namespace packages for example github.com/pytest-dev/pytest/issues/2541
 
I also feel compassion for everyone who ever asked "how can I get the data I want from this html by using regex?". All of my pages have similar structure, so maybe...
 
wim
5:15 PM
and it can happen with regular packages too
 
Hmm. But surely the conftest.py only runs once?
 
wim
yeah. it should do.
I actually don't really like the way pytest does its test collection
it prepends or appends to sys.path to import test modules (depending on the --import-mode option)
that in itself is not so bad, but it doesn't undo the sys.path mutation afterward.
IMO the test modules importing should be context-managed
 
@Kevin Honestly, I never understood why people are so vehemently opposed to using regex to extract data from HTML. Sure you can't parse HTML with regex, but extracting specific data is often very much within its capabilities.
 
Yeah. It's only because of the extreme meme power of the Zalgopost that regex is warned against as often as it is.
If that question had been answered with a clinical tone, it would have five upvotes and nobody would remember it
 
perhaps that would've been for the best
 
5:23 PM
I think the Zalgopost itself is very good*, but I'm pretty tired of it being used as a bludgeon against mostly unrelated problems
 
wim
@variable it attempts to be. the cure is worse than the disease, though.
 
(*not necessarily in terms of "a good SO post" but certainly in terms of "interesting literature")
 
Today I am annoyed by "Do you want to do this optional thing? [y/N]" dialogs that patiently wait for me to press something instead of silently doing said optional thing in the background until I cancel it
 
I'd like to add a rider to your annoyance, that grep -r "foo" silently blocks indefinitely until I notice half an hour later that I should have done grep -r "foo" *
I'm not even sure what the first command is supposed to do. Is it waiting for a list of filenames via stdin? It ignores all of my keystrokes except ctrl-c, though.
 
hmm, grep -r "foo" produces some output on my machine
 
wim
5:29 PM
me too, on GNU grep 2.20
 
:-(
 
check OS/grep version late to the party
 
wim
   -r, --recursive
          Read all files under each directory, recursively, following symbolic links only if they are on the command line.  This is equivalent to the -d recurse option.
 
It says I'm using "GNU grep 2.5.4"
 
2.20? I've got grep (GNU grep) 3.0 despite being on windows
 
5:31 PM
I misremembered -- it does accept my keystrokes, and outputs the search string whenever I type something that matches.
 
wim
you're on windows too?!
 
Me too xD
 
So it is scanning stdin, which explains the mystery, but I'm still annoyed
 
@wim temporarily
34 mins ago, by Aran-Fey
I got tired of linux crashing when I try to suspend
 
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
 
5:32 PM
Although I'm sure I'd be on Windows far less often if I didn't have to be for work.
 
wim
what do you get for grep --help | grep -- "-r"
 
That said, they locked down the print server I need Windows for such that my personal laptop only works on it some of the time, and then only when on ethernet, so...maybe I don't need to be on windows after all.
 
Aran-Fey@DESKTOP-SJGQDQ8 /d/U/A/Desktop> grep --help | grep -- "-r"
  -E, --extended-regexp     PATTERN is an extended regular expression (ERE)
  -G, --basic-regexp        PATTERN is a basic regular expression (BRE)
  -P, --perl-regexp         PATTERN is a Perl regular expression
  -e, --regexp=PATTERN      use PATTERN for matching
  -w, --word-regexp         force PATTERN to match only whole words
  -x, --line-regexp         force PATTERN to match only whole lines
  -r, --recursive           like --directories=recurse
 
wim
not you, the guy with the broken grep
 
Who, me?
C:\Users\Kevin>grep --help | grep -- "-r"
  -E, --extended-regexp     PATTERN is an extended regular expression (ERE)
  -G, --basic-regexp        PATTERN is a basic regular expression (BRE)
  -P, --perl-regexp         PATTERN is a Perl regular expression
  -e, --regexp=PATTERN      use PATTERN for matching
  -w, --word-regexp         force PATTERN to match only whole words
  -x, --line-regexp         force PATTERN to match only whole lines
  -R, -r, --recursive       equivalent to --directories=recurse
I'm guessing -r doesn't actually have an effect if I'm grepping over stdin. I just included it because I always include it in my actual greps
 
wim
5:36 PM
its weird that it would block and try to read stdin when told to recurse directories
 
I just wish it would print something like "waiting for data from stdin..." instead of just staying blank, which makes it indistinguishable from a grep -r "foo" * call that is merely taking a long time to find its first match
 
wim
well that wouldn't be the unix way
because somebody would be annoyed when piping the grep results on to some other process
most of the time it will not be connected to a TTY that someone is looking at when reading from stdin
 
6:22 PM
Is it possible to see the underlying database type of a model field in the Django ORM? Example, I have a UUIDField. In a Postgres database, this would map to the uuid type, whereas it would otherwise map to the char type. Is there any programmatic way to do something like this?
 
Huh, I didn't even know there was a specific type in postgres for uuid :)
 
wim
use the db_type method on the field
 
Thanks, just what I was looking for!
 
How does that work? I was wondering about the % used on the return, but for postgres, it looks like there's only 2 things in the dict
nm, I misread something along the way
 
While making a choice between writing module with functions vs module containing class and class functions, I am advised that module is like singleton. Is it really though? For Example: say flask api end point invokes a function from a module. Assume a function take 30 seconds to run. While running suppose another user inkoes the endpoint. Will the function call work or not? If it is singletons it wont
 
6:39 PM
I can't help from an OOP terminology standpoint but I'm not sure about your analogy. Flask should be launched in multiple, independent processes/threads, so yes, the same function would run for 2 different people in reality
 
A module is a singleton in the sense that you usually can't create multiple modules with the same name. If you do import math twice, the second one will just give you the module it created from the first one.
 
So then is it advisable to create modile with functions in class so that at each endpoint invocation I can instantiate the class and the function will the called from the new object
 
I don't think this has any bearing on whether you should design your module to use classes and class functions, vs designing your module to use functions. The only real issue is code at the global scope
#a.py
print("Hello, world!")

#main.py
import a
import a
In this project, when you run main.py, it prints "Hello, world!" only once
 
@variable I can't follow what you're asking
 
Multiple executions of a function call don't interfere with one another, even if they're being called in the same process and thread. Don't go out of your way to make your functions into methods if that's all you're worried about.
 
6:44 PM
Ok so each flask endpoint call invokes a new process/thread? I'm confused because on the flask app I have imported a module. And the endpoint calls function from module. Now I'm confused because what if 2 users call the endpoint, then will each get its own instance of the modules function?
 
Yes, if I'm interpreting your question correctly
You can edit for up to 2 minutes
 
What is this concept called? So I can read about it please
 
This is threading/multiprocessing (depending on how the server is launched)
 
The concept of functions not interfering with one another? I don't know if there's a name for that. That's pretty much how every high-level language works.
I guess you could read en.wikipedia.org/wiki/Call_stack to get an idea of what actually happens when a computer program calls a function
 
If you used multiprocessing, for example, to serve your application, the namespace will be copied across all processes when you start up. I'm not sure exactly what you're learning here, but possibly it's just "globals in web application are bad news"
 
6:49 PM
@variable modules, classes and singletons have nothing to do with concurrency. As far as all contemporary Python VMs are concerned, calling a function/method/object is the same.
 
Thanks for link. I understand your point that each thread/process will launch its own instance of the modules function.so there will not be a clash when diff areas of an application call the same function. Is there a concept of async in python (other than thresding)?
 
Sure. Python even has an async keyword.
I've never used it for anything useful, myself.
 
Does async work on the same process (thread)?
 
in practice, yes. in principle, no
 
You know about the limitations of the Global Interpreter Lock (GIL)?
 
6:54 PM
Keep in mind that processes and threads are different things. That said, I don't know whether async uses either one.
 
I am asking too many questiins. Thanks. Can you tell me if its the same process, then, If so then how does it handle 2 sequential calls to a long_running_function? I mean does 2nd call gets its own fresh instance of the function?
 
Python doesn't unless you configure it to. Is this actually a Flask app you're asking about or was that an example?
 
If it's all in the same process, then the only way to get long_running_function to execute in parallel with itself is if it's using threading. Both threads will execute the same code object, but they'll get their own unique call stack and collection of local variables.
So for practical purposes it's a new "function instance" although under the hood the function reference itself is the same
 
wim
@Kevin it does not
 
I was originally aaking about flask app. Yes. But you clarified that each endpoint call is handled as a new thread. So i understand that the new thread will have its own copy of the function and it won't clash with other parallel calls to the endpoint.
 
6:58 PM
There are very few instances where you actually need to care about the "identity" of a function
 
wim
coroutine concurrency is all within one process and the main thread
this has nothing to do with flask though
 
most async frameworks allow running (blocking) things in threads, though.
 
@variable but the app will be served by a finite number of threads
 
it's one of those topics that are difficult to explain correctly given rapid fire questions...
 
I want to qualify my assurances that multiple function calls don't interfere with one another. This is true if the function has no side effects, but if your function modifies nonlocal state, then interference is possible.
 
wim
7:00 PM
and very difficult to explain given flask's crazy design where you just import the "global" request object
 
If you create a list at the top of your program, and your function appends to and accesses that list, then an append made by one instance of the function will affect an access made by another instance of the function
 
By non local, assume you mean module level variables that are modoifed in the function? If So then it is safe to create functions in class? That way I am assured that each endpoint invocation will give me.a new instance.
 
@wim I'm not sure what point you're making? How do you think it should work?
 
wim
@roganjosh the request should be passed as an argument to the view
 
Module-level variables would be the most common category of nonlocal state, sure.
 
7:03 PM
Every view? Is it not easier as it is with a request context?
 
wim
yes, every view. because that's how you give functions access to state (you pass them as arguments)
 
Class level attributes, e.g. class Foo: X = 23, also count as nonlocal state, so putting all your stuff inside a class doesn't necessarily protect you from race conditions
 
I think we'll disagree on this, request is pretty handy. There are annoying corners trying to work in the request context, but the trade-off is pretty good
 
Ok thanks you
 
Hi guys, is anyone familiar with pandas?
 
7:07 PM
> I have created methods of reliable encryption, base64, hexadecimal, unicode, and a few methods I have devised myself.
 
wim
global variables seem pretty handy too if you don't know a better pattern
 
...and other hilarious jokes you can tell yourself
 
@Aran-fey
and @wim anyone of you familiar with pandas or time-series?
 
nope
 
Ohhh :c
 
7:08 PM
Please stop pinging people at random
 
wim
If you want to learn web development well, flask is probably the worst possible framework to use.
 
Ohh sorry about that
why's that wim?
 
@variable since methods can do anything a function can do (including accessing nonlocal/global state) using methods instead of functions gives no added guarantees whatsoever.
 
@wim This is getting into silly territory, no? At the point of there being big companies built on the back of Flask, it's simply a different approach that you find disagreeable?
 
Taking a function that alters nonlocal state, and turning it into a class method that alters only instance attributes of the self object, may defend against race conditions.
 
7:13 PM
@Dorki a few of us use pandas but we won't know if we can help or not until we see the problem. Please see the room rules and just ask the question
 
@Kevin so may taking a function that alters nonlocal state, and turning it into parameterised function that alters only attributes of the argument object.
 
And by "class method" I mean "method defined in a class" rather than "a @classmethod"
 
which are the only proper methods
 
@MisterMiyagi Agreed. Classes are not particularly more effective at preventing race conditions than other possible designs.
There's no magic going on behind the scenes
 
wim
@roganjosh I don't mind different approaches. I don't like bad approaches.
 
7:16 PM
I'm probably wrong but I'd rather you substantiate that than just saying it's bad
 
for the record, I never understood what is the advantage of having a quasi-global-thread-contextualised request instead of an argument. anyone care to enlighten me?
 
wim
What is a big website built on flask? I know big companies may use it for microservices (despite there being better options). I'm not aware of a big website built on flask though.
@MisterMiyagi There is no advantage. Only disadvantage. It's a "cool hack" if you like it, a bad design decision if you don't like it.
 
Just reiterating my Q. When multiple users call a flask endpoint which invokes a module's function, we are safe unless writing to non locals is involved. I thought that each endpoint call would give fresh copy of the module's fuxnton. But thanks for clarifying that non locals may be shared. What is this concept called again?
 
wim
mutable state
 
I still have no idea if flask uses a separate process for each user or not, for the record
 
wim
7:19 PM
it uses thread local storage
 
Flask doesn't, because it's not a server
 
@wim Not only mutable. But even assignments based on how the module is imported. Am I right?
 
I don't understand why this keeps coming up with Flask and not Django when I think they both use the same underlying dev server
 
wim
@variable that (assigment statements) is just another example of mutable state
@roganjosh why do you think they both use the same underlying dev server? that is plainly untrue.
 
It's just the werkzeug server?
 
wim
7:25 PM
are you confusing WSGI with werkzeug ?
 
Ok, I'm not sure I can substantiate that the dev servers are the same, but the point still stands that both are development servers
Nobody seems to talk about Django serving requests but Flask is forever seen as a web server
 
wim
flask is not a web server
 
<-- preaching to the choir here
 
When server starts, the imported module (containing variables and functions) is loaded in memory. Then at every invocation of endpoint, when the endpoint invoes the fucntion from the module, the same module from memory is invoked..
 
wim
"the point still stands that both are development servers" .... the point that one framework (ab)uses thread local storage and the other prefers to make dependencies explicit? That is a non-sequitur
 
7:31 PM
That was a side point: I don't understand why Flask is so often mistaken as a web server while Django is not
 
wim
oh, you are saying "Flask doesn't [use thread local storage], because it's not a server"?
 
Even if they don't share the same base dev server, the implementation of that server is basically the same and, as such, neither are recommended for production
 
@roganjosh Because Flask is more accessible and Django is not meaning Flask is more likely to be picked up by those who are more likely to make that mistake.
 
But you're yet to give me some example where Flask falls down
You know that I respect your opinion @wim :) But you've not given anything but bluster here
@piRSquared I suspect this is correct
 
When we do pip install CustomModule, then suppose the module is used in different python projects. Then is the module variables shared among all projects? Or is it shared in one project only?
 
wim
7:35 PM
A global request context is bad for all the same reasons that global variables are bad (difficult for testing, difficult for middleware, difficult for auth). If you don't think global variables are bad, then I don't know how to help you.
 
Right, and you've faced all these issues?
 
wim
Yes!
 
Does anyone know if there's a way to prevent IntelliJ from altering my sys.path?
I'm trying to run my project with a linux version of python (installed in msys2) but IntelliJ keeps adding windows paths to sys.path
 
wim
I've also maintained badly designed Django apps that try to replicate the flask model by injecting a thread local storage middleware.
 
(more accurately, it alters my PYTHONPATH, which the linux python then parses incorrectly)
 
wim
7:42 PM
The difference is, Django discourages that pattern in the first place (you'd have to hack it in yourself) whereas it's a fundamental part of flask's design from the GET-go (pardon the pun).
 
:P
 
I love that pun! Please make more, POST-haste
 
Please can I ask to answer my question about pip install and import module and sharing variables.
When we do pip install CustomModule, then suppose the module is used in different python projects. Then is the module variables shared among all projects? Or is it shared in one project only?
 
Why don't you try it and find out? Create two projects that import the same module and see if they're shared.
 
wim
unless you have a good reason to share state, you should use one virtualenv per project and pip install the dependency to your different development projects separately.
@roganjosh I dug up a relevant answer for you stackoverflow.com/a/1924524/674039
 
7:46 PM
I got this thought on my bed. So i cant try it out now. But will do surely tomorrow
But such this stop me from sleeping. And so I come here to ask the experienced.
 
wim
the accepted answer is basically a bad opinion, but the second answer is from Carl Meyer
 
Short answer: no, it's not shared. Long answer: there are one hundred different definitions for "shared" and each one has its own unique corner case.
 
I think maybe I'll just write an exe that rewrites my PYTHONPATH and then runs the real python executable...
 
wim
If you don't know who that is, well he's a pretty famous web developer. He was hired by Instagram to migrate their app (which is Django) from Python 2 to Python 3, for example.
 
I know the name. I'm trying to digest everything there because it looks like Armin made a post too
 
wim
7:50 PM
they server on the order of million requests per second, maybe the biggest Python website in existence.
Armin post seems deleted now. Maybe it's in the wayback machine?
 
Yeah, that's not filling me with confidence right now :P
 
@wim 4-digit SO user ID, 'nuff said
 
hello, do you guys have an example of how to use tqdm in a list comprehension?
 
What did Armin do? this is the post if anyone is searching.
 
wim
oh, thanks, I was trying to find it too
Armin is the original author of flask, but he seems to have abandoned the project entirely now
 
7:55 PM
@erotavlas I think the basic idea is to wrap whatever you're iterating over with tqdm.tqdm
 
I've not got to the end yet but it reads like the antithesis of Flask
 
wim
@roganjosh well, that's because flask was his april fool's joke
 
No kidding, this is interesting backstory :)
 
@AndrasDeak like this?

preprocessed_docs = [clean(i) for i in tqdm(documents)]
 
Yeah. Does it work?
 
7:57 PM
just restarted kernel... waiting for my documents
 
wim
Putting every bad design decision in the book into a web framework (called "denied") and then giving it some good marketing. Unfortunately, he didn't fix all the bad design decisions when releasing flask.
 
there's also tqdm for notebooks
 
@wim I think there's a reason it was deleted
 
wim
What do you think the reason is?
 
Ok, well, I don't know exactly where I stand here
 
7:59 PM
@AndrasDeak ok yes its working, thanks
 
Because it seemingly is an extrapolation from a joke that happens to be useful to me
 
What is the concept called where-in variables from a package that is installed on a pc and imported by multiple projects on the pc are not shared.
 
I don't think that has a name.
 
I have read about call stack. But it doesn't say about this concept
 
@wim I'm gonna argue that "if it gets the job done" I don't give a yam, and have to leave it at that, because I think that post casts more light on it all than the commonly-known April Fool's joke
 
8:05 PM
If i am not using venv, and installing package globally, what prevents the variables from being shared across projects? I am looking for a term for this concept.
 
wim
@roganjosh Well, that's ok. You probably don't hit the cases where the bad design will bite. There are plenty of functioning websites built on crappy technology like PHP
 
what would you guys recommend for versioning jupyter notebook scripts?
out company uses TFS so we have the option of using Git repos, currently our scripts are floating around across our workstations with no versioning and enforced backups
 
wim
Are you satisfied I have more than 'bluster'?
 
You didn't give a specific fall-over case, but I certainly can't defend my position beyond saying "It works for me" :)
 
wim
I maintain some flask apps that got too big in my job, and they are hell
so maybe I have an axe to grind against this framework for that reason
 
8:11 PM
In .net each application spins up on a new process. What about python want happens here?
 
wim
"It doesn't work for me" :)
 
One thing, though, it would be useful to know at what scale you find this breaks down
 
@variable I don't think this is a python thing. Independent processes can't access each other's memory, this is one of the fundamental responsibilities of an OS
 
wim
I also maintain Django apps, pyramid apps, falcon apps.. so I have a lot of experience with different frameworks and the pros-and-cons of each.
 
it takes conscious effort to do otherwise
 
8:13 PM
@wim @roganjosh I feel enlightened having skimmed the discussion and links. Thanks! That may inform future decisions of mine.
 
@AndrasDeak you're right provided the python project is an application. But on a developers system, assuming I am not using venv, and am installing a package globally via pip install, what prevents the variables in package from being shared across multiple projects on my pc? Any one typing import packagename will have access to read/write the shared value of packagename.vsrname? I am looking for a term for this concept.
 
@variable globally available module?
 
venvs and global installs are a red herring
it's not the module that contains the variables, it's the interpreter
if you import a module with a list literal in the global scope and then mutate that list you won't affect what gets imported by a completely different python process
 
@AndrasDeak ohk This is what I need to learn. Any reference please.
 
eh, I have none
 
8:20 PM
@toonarmycaptain yes it becomes shared across every proejct I do on that PC right?
 
Nothing prevents two "projects" (whatever that is) from sharing the same variables if you run both projects in the same process.
 
wim
@roganjosh it's not really about scale - scaling is mostly handled by the web server / load balancers etc. although it's true that choosing flask would limit your options for scaling somewhat (e.g. I don't think you could easily bring in asyncio or uvloop stuff if you're using flask as the web framework)
 
other than "why would importing foo.py and mutating a list from there suddenly change the contents of foo.py"
 
@wim But wouldn't you offload that via a Redis queue?
 
wim
no
I would use a redis queue for background tasks
 
8:23 PM
(I've spent almost my entirety of my programming life in isolation so I'm probably full of dumb assumptions)
 
wim
I thought when you are talking about scale you mean answering X requests per second where X is some big number
without your website starting to timeout or return 500's or whatever
 
Ok so when 2 instances of command prompt are running with Python command line. There are 2 separate processes and hence the variables from the imported package will not be shared among them. Ok.
 
Right.
 
@wim Sure, but I'm trying to understand the case where the web framework is the limiting factor here.
 
wim
I'm not saying it is
I'm saying it's full of bad design decisions, which causes weird bugs, and the "everything in one app.py file" gets users off on a bad foot in the first place and encourages ugly code
they end up with a tangle of dependencies and don't have the knowledge or the tools to restructure it properly
 
8:27 PM
@wim But there are patterns to overcome this
 
That absolutely isn't my design, everything has its own blueprint (which I'm not sure is how it was supposed to be used)
 
Flask design patterns
 
wim
django doesn't always have the best design decisions either (settings module, ORM) but the django-admin startproject mysite gives you a pretty idiot proof template for a well structured project. maybe beginners get a bit frightened by that structure, but it's probably better in the long run.
 
I have ~15 blueprints for each "topic" that my app deals with. Each has its own views/models/forms.
 
What is good source for flask starter tenplate
For flask api
 
wim
8:32 PM
I don't know, sounds like roganjosh might have some though ^
 
The flask mega tutorial is the best resource on it
It also covers just an API
 
This seems like it shouldn't happen. Does anyone have any idea what could cause this?
In [79]: page
<botocore.client.S3.Paginator.ListObjects object at 0x1114f5e10>

In [80]: page.__dict__()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-80-4912882dacfe> in <module>
----> 1 page.__dict__()

NameError: name 'page' is not defined
 
wim
If you're attracted to the apparent minimalism of flask and you like the request context trick, I can recommend cherrypy as a more mature alternative
 
Miguel also has a blog on other issues, and he's a smart guy IMO
 
@inspectorG4dget better not be freaky unicode characters or non-printables
are those exactly the same "page" words?
 
8:36 PM
cherrypy is more mature than Flask?
 
@AndrasDeak nothing like that. I'm too tired to pull off some prank like that right now
 
wim
@roganjosh yes
 
@AndrasDeak unless my keyboard is playing tricks on me
 
@inspectorG4dget could also be the result of copy-paste
 
negative. Hand-typed
 
wim
8:36 PM
it predates flask by about 8 years
Armin might have even got the request trick from cherrypy, I dunno.
 
Yeah, and where are all the questions on main? I think this is a pub discussion to be resolved when I'm next in the US, there's too much going on here :)
 
wim
less marketing/less attractive to beginners == less questions on main?
 
older == more-mature in programming?
 
wim
maybe older == less bugs or older == more bugs :) jury still out on that one
 
:P I guess we should be thankful that we don't have to follow the JS frameworks
 
8:49 PM
I'm not a fan of using regex where it isn't necessary. Is there something inherently wrong with my approach to this Q&A I'm not usually answering questions on the main tag (but here I am :-| )
 
@AndrasDeak seriously... any thoughts? I'd buy you a beer
 
@inspectorG4dget I don't like beer but anyway I suspect "your kernel is haunted" isn't worth one
I'd just try restarting everything...
 
@piRSquared Not sure if it's wise to assume that the leftmost parenthesis is always paired with the rightmost one. What about things like (a b) (c d)?
 
awwww maaan! :'(
Alright thanks :)
 
@Aran-Fey ack... yep you're right
I like to venture out from my comfort zone. I'll have to revisit that (or leave it alone)
 

« first day (3293 days earlier)      last day (1647 days later) »