« first day (3280 days earlier)      last day (1661 days later) » 
03:00 - 18:0018:00 - 23:00

wim
6:01 PM
dumb advice
unary op +counter does that already
I guess c += Counter() is the in-place version??
 
@wim Ah. That's a good rule. I may have broken it in Py2...
 
wim
it's not a rule in py2 afaik
and the runtime error transformation thing is pretty recent, maybe even 3.7 ..
 
That's what I mean. I wrote code that raises StopIteration and it ran & behaved like I expected it to.
 
Hi there
 
hello
 
wim
6:13 PM
@PM2Ring if you opt-in to warnings in your dev environment, you will see the deprecation warnings in a minor point release
vastly preferable to surprise breakage later on
 
Hmm, not sure whether my A* implementation is buggy, or I just picked a really bad heuristic function
 
6:30 PM
MemoryError
During handling of the above exception, another exception occurred:
MemoryError
During handling of the above exception, another exception occurred:
MemoryError
Darn
 
wim
can't handle memory error if you have no memory left roll_safe_meme.jpg
 
Is this in relation to your recent interest in stars? Are you pre-planning an epic space voyage?
 
wim
what means a billion? 1e9 or 1e12 ? serious question
 
I think it depends on whether you're in the US or the UK
I used to think of it as "a million million" but now I'd probably assume "a thousand million". Wikipedia is backing me up on this that 1e12 is "historic" in English (though historic has to be taken with a pinch of salt here because it's happened in my 31yr lifetime, at least for me)
 
yeah, and "long and short scales"
I understand billion as 1e9 (what we call a "milliard")
 
6:44 PM
If your concern is around how the UK, for example, would interpret "billion" and your audience has some numerical background, it's a safe bet to go with 1e9. To Joe Bloggs, 1e12 might be a natural assumption since "billion" is close to "bazillion" i.e. some phrase to mean an awful lot and they may remember the "million million" definition
It's a little hurtful to have to admit that the US led the way in making a more sensible unit here :P
 
This is about three degrees of separation from my recent interest in stars, although it would be hard to guess that without closely monitoring me in person for the last week
 
I demand my 1 phonecall to my lawyer
 
@Kevin so about 0.052 radians separation?
 
Depends on whether "degrees" here is a measure of angle, temperature, or college diplomas
 
Or in the sense of "7 degrees of separation"
 
6:52 PM
should've went with temperature
 
user11006952
How does one invalidate the cache of environment variables? When I change a value in my .env file (I use dotenv), my app doesn't load the new value in the .env file. getenv() docs doesn't mention anything about caching. Searching for generic "invalidate environment variable cache" does not provide useful results.
 
What OS are we talking? What is the app built in?
 
user11006952
MacOS but I use pipenv for virtual environment. The app is built in Python3.7 and uses the flask framework.
 
I've never heard of .env files, but there must be an application responsible for loading it and running your python program in that environment, right? What's that application?
 
@Pax and what is serving your Flask app?
 
user11006952
6:59 PM
I'm not sure how to answer that question. (greenbean here) wsgi?
 
The Flask dev server, doesn't watch env files for changes I don't think. It will load those variables once as part of config.py (or whatever your equivalent is).
 
user11006952
I use the package dotenv
 
I understand what you're using for reading .env but you need some server to actually respond to requests. That config file will only be read once when you first start the app
Taking a step back; how do you run your flask app?
 
As far as I can tell you need to call load_dotenv() at some point?
or does flask do that for you?
 
@wim I reckon in Oz that the short scale was more common by about 1980 among the younger generation, but many people who left school by, say 1970, would be likely to still use the long scale, even today.
 
user11006952
7:02 PM
@roganjosh How do I reload the config file? Quitting the server and running python wsgi.py again doesn't cut it. If I hardcode the value in my config.py, and run the server again (python wsgi.py) then it works.
 
What is in wsgi.py that actually launches the server?
That doesn't launch the app, that's an app factory
 
user11006952
(Sorry about that. I'm trying to format my response well =_=)
 
No worries :)
Take your time
 
user11006952
Okay. So yeah. App factory. Then app.run(host='0.0.0.0', ssl_context='adhoc')
 
user11006952
The app factory calls load_dotenv()
 
7:05 PM
Is this something you can play around with without causing issues? Like, if you set debug mode on, it's not going to be a security risk?
 
Any code the conforms to the convention of os.environ will not pick up changes to environment variables.
This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.
 
(for a small amount of time)
 
user11006952
@roganjosh Yes. It's just in my local computer.
 
@PM2Ring huh, well that's saved me some tests before I try debug on this end
 
user11006952
@PM2Ring Thanks. Maybe I'll check out os.environ docs to see if there's anything helpful there.
 
7:08 PM
Of course, a 3rd party environ package isn't obliged to do things that way. It may have been created precisely because the author wanted "live" environment vars.
But that'd be unexpected behaviour for most coders who were used to the usual way env vars behave.
 
My thinking was to try make FLASK_DEBUG relaunch the dev server and see if the issue persisted before trying to build a test here. Your statement would suggest no, because it would be in the same python interpreter, only the server reboots
 
user11006952
Thanks, guys! I restarted my virtual environment and that loads the new variables. It makes sense after reading this in the docs This mapping is captured the first time the os module is imported, typically during Python startup
 
user11006952
Which I realize is the same thing PM 2Ring said.
 
I wonder if reload will load it again.
import os
from importlib import reload
e = os.environ
reload(os)
e2 = os.environ
nope!
import os
from importlib import reload

os.environ['PAGER'] = 'dog'
print(os.environ['PAGER'])
reload(os)
print(os.environ['PAGER'])

# dog
# dog
 
@Pax Just to be sure, you said you're a "green bean" earlier and here you say "just my local computer". You know that --host 0.0.0.0 is your local network, not your computer, right?
 
user11006952
7:17 PM
Yes. I thought I could use them interchangeably!
 
If you're at home, you can find the local IP address of your PC and then try connect from a phone on (I'm guessing) 192.168.0.x:5000. You will be able to connect if you launched the server on 0.0.0.0 but not otherwise (which would be running on localhost/127.0.0.1:5000. This is assuming your phone is connected to the same router
If I run my test server on 0.0.0.0 at my factory, it's accessible to all 500 people connected to the internal network... should they happen to know I was running it
 
user11006952
Ah! That makes sense. I'm at home right now so unless someone else knows our Wi-Fi password, it won't be accessed by anyone else. But I wonder what is the alternative setup?
 
Both have their uses so there is no "alternative". But there is no need to pass -- host 0.0.0.0 if you don't want it accessible on your network
 
user11006952
Right! Thanks for the info.
 
If you want to access it locally, don't set it up on the network and access it from the same PC you're running it on with 127.0.0.1:5000
Side note: I think this might be Windows-specific because I can't imagine Linux UFW just allowing this by default but I don't have a test setup to hand
 
wim
7:28 PM
Is this legit big Oh thing or just hand waving? stackoverflow.com/a/11520566/674039
I have never seen a "constant" (?) subtraction from the n like that and don't really understand what it is supposed to mean
 
O(n) == O(n - some constant)
 
wim
I mean the fact is that removing from the start of a list is slow and removing from the end is fast, but is that big Oh notation in his answer really communicating that or no?
 
user11006952
I think big Oh is not meant to communicate how efficient "a part" of the algorithm is. It looks at the algorithm as a whole. It doesn't care whether it's efficient at the end. If there's a slow portion in the algorithm, then the algorithm is slow.
 
wim
@roganjosh .... what is the more sensible unit? and why?
 
@wim I think 1e9 is the more sensible unit (the US version). The explanation is more wishy-washy, but Western representation of numbers tends to add a comma after every 3 digits and that mentally represents, to me at least, some distinct change in scale that isn't captured by "a thousand million"
 
wim
7:35 PM
if bi- is the "two" prefix, then shouldn't a billion be two million?
 
My contribution to that question:
Though it may seem obvious, del and pop have three characters while remove has six characters. The sum of their associated ascii numbers are...
 
wim
what's a trillion? is that a million squared?
 
^^^ I'd argue that was more about semantics. The word "billion" just is, in the case we're discussing, so I'm choosing between the two definitions
 
@wim bi-llion is two lions. but actually llions, which is a really el-ly kind of lion.
 
user11006952
@wim Oh I get it now. It is communicating how popping from the end is constant time because i is the index. If the index you are popping is always the last one then O(n-(n-1)) were n is the number of elements.
 
user11006952
7:39 PM
O(n-(n-1)) == O(1)
 
@wim Well, now you do make it sound like the system makes sense if you shift the counted unit up by three orders of magnitude. "million" shares the origin with "mono", as in the base unit, "billion" adds another "1000" to the front, "trillion" another 1000, quadrillion another 1000....
 
wim
while searching for a two headed lion, i found a three headed lion shrugs
@roganjosh that's what I was thinking. but I don't know if its actually the historical reason or just convenient...
 
user11006952
@wim If it's not the last one, then it's contingent on n: O(n-[whatever index])
 
wim
I thought M in roman numerals is 1000 anyway
@Pax Right, but I've never seen big Oh used like that. It also doesn't really work so well in python when the i can be a negative number.
 
7:44 PM
@roganjosh whoa! I thought your people argued for million being the base unit and billion being two of those which would be 10**12?
 
@piRSquared No, I don't believe that to be the case and I'm currently reading around it
 
user11006952
@wim I guess in this case, i is the positive index of the element.
 
But that you just capitulated to the Merican way of doing it which is a billion being 10**9
ok, reading link
yeah!
"A trillion was 1,000,000,000,000,000,000, or the third power of a million. The US later adopted what became known as the short scale, which reduced a trillion to 1,000,000,000,000 (and a billion to 1,000,000,000), but the British retained the old system until the 1970s."
 
It's reassuring that my stab-in-the-dark about "million million" is being reflected in the article :)
That it's just a social thing where we wanted to think of really big numbers
 
@wim it is, mille = 1000, see millennium. But apparently mille > Italian mille (1000) -> mille+one == milione ("big thousand") en.wiktionary.org/wiki/million#Etymology
 
7:51 PM
Makes me wonder about the word "mile". It must have roots to 1000
 
I really doubt that
The imperial system of units is just utterly bonkers
 
Well shut my hands/mouth
 
fingers
 
"A thousand paces". Wow, people had freakishly long legs back in the day.
 
7:53 PM
IIUC pace == two steps
 
Right, well I'm slightly vindicated by the actual etymology
 
"1,000 double paces (one step with each foot)"
 
So "origins" in 1000, yes. "Sense", no
 
@piRSquared maybe
 
wim
not to be confused (one foot with each step)
which would be 0.19 miles :P
 
7:58 PM
I wonder how many chains that is
 
/rollseyes
 
cubic ounce per fortnight
 
I have to do work (-: rbrb
 
@AndrasDeak that seems awfully correlated. Are you sure it's not 1.034 cubic ounces?
 
8:39 PM
I'm wrong in my description here I think but in terms of wording. The change does fix the problem. I don't think "convenience method" is correct, I think it's a distinction about classmethods but I get myself tied in knots when it comes to SQLA. Without diving into the docs, should the implementation be obvious from the equivalence I linked?
As in, is there enough in the docs that I should be able to know the overall structure of how this is implemented? I want to get better at interpreting docs
^^ source* not docs
 
uff, I've got a heisenbug in my serializer. This isn't gonna be pretty.
 
wim
@roganjosh I have no idea what you're asking
Query doesn't require the session to be passed, but that's unrelated.
 
@wim is query a "convenience method" for Query?
 
wim
8:55 PM
hmm
I would call Query an inconvenience method for session.query ... ;)
 
I think my terminology is screwed up. I knew the problem but I don't think I know how to express it
 
wim
but I like to pass my session around explicitly, YMMV
 
@wim Well I have no real choice in my current project because I did a stupid thing and stuck with flask-sqlalchemy despite your advice. Bout sums it up
 
wim
haha
well, session.query returns a Query instance, and that is the usual way to make a query in SQLA (instantiating a Query directly is also possible, apparently, but I don't see that in the wild)
 
You could subsequently add filter conditions to it, no?
 
wim
9:09 PM
yeah
they don't actually hit db until results consumed
 
I do that a lot in my current code, so the instance is important, but I'd never create a Query object directly, only through .query
As long as I'm not getting my terminology badly wrong then I'll leave the answer as it is. I anticipated that "convenience method" was just gonna get shredded because I don't know the design pattern used
 
9:42 PM
@ReblochonMasque bet you can't access imgur so let me just copy the text from a post: "I asked my Chinese friend what it's like living in China. He says he can't complain" :D
 
oof, that joke is usually done with North Korea. That's super sad for China
 
first time for me
the reason why this is on imgur (along with a bunch of other related posts), beyond the HK situation, is probably vox.com/2019/10/8/20904433/…
 
hi! I'm new in Python, can I ask a thing here?
 
9:59 PM
I'm reading from file csv, and I'd like to create a lot of dictionaries made by header as key and the values as (of course) values
 
there's csv.DictReader for that
 
but I dunno how to update to the dictionary from a simple for the keys and the values
if I do a simple
from x in file:
 
"a simple" doesn't mean anything
 
  d=dict.fromkeys(x) # it does not make sense
 
If you want to alter the file and it's not huge, you will probably be looking at rewriting the entire file with the new data
 
10:04 PM
not sure what you're doing with fromkeys
 
I just want to read the first line (the header) and say: ok, all this are keys
 
DictReader does that automatically
 
is it a csv package?
 
it's a class in the csv module
I linked the docs earlier
 
Orange text means link in chat. But even without the link you must have seen "there's csv.DictReader for that"
 
10:08 PM
Ok thx so much! 'Cause my professor told us to not use pandas or similar, but I think I can use the csv one I hope
 
would be silly if you had to write your own csv parser
 
And using pandas for simple CSV work is a pet hate of mine
So I applaud your professor :)
 
there's not much to learn from pd.read_csv('file_name.csv')
 
I came from C, C++ and Java, so i have to figure out how it works
 
with the csv module you at least learn to read the docs carefully (or you end up with a bug that you'll likely never notice)
 
10:12 PM
yeah sure
So for now, thx a lot!!!
 
10:44 PM
Woohoo, my terrible spelling resulted in my first YouTube search with no results: plantaginates instead of plantagenets
 
03:00 - 18:0018:00 - 23:00

« first day (3280 days earlier)      last day (1661 days later) »