« first day (3033 days earlier)      last day (2139 days later) » 

 
1 hour later…
02:57
If anybody used structlog ..any idea about custom log level issue with it (stackoverflow.com/q/54505487/6233947) ?
 
5 hours later…
07:42
@PankajSharma We don't discuss very recent (< 2 days old) questions in here.
 
4 hours later…
11:20
@coldspeed no roomba implies that the question is off-topic. Messing with answers to delete questions is a no-no
Close the question and delete that
Paz
Paz
11:46
Is anyone here familiar with tkinter?
i've defined __str__ and __repr__ in my classes to return string but when in jupyter it still shows as address on mem unless i do print or str. do you guys know what could be causing this?
Maybe a typo or other mistake
are you sure repr(obj) and str(obj) works as intended?
jupyter probably uses the former
Can you put the class def in a pastebin?
In [1]: class Foo:
   ...:     pass
   ...:
   ...: class Bar:
   ...:     def __repr__(self):
   ...:         return 'A shrubbery!'
   ...:

In [2]: Foo()
Out[2]: <__main__.Foo at 0x7fe75866a550>

In [3]: Bar()
Out[3]: A shrubbery!
that's ipython but I'd expect jupyter to be similar
 
1 hour later…
13:09
> django_1 | Fatal Python error: Cannot recover from stack overflow.
oops XD
cbg
Ahoy cbg
13:53
The following is a message for web devs who implement infinite scroll in a fault-intolerant way, such that a single failed AJAX call will cause the page to permanently refuse to load additional content, requiring me to refresh and scroll back down from the top, which may require a substantial number of additional AJAX calls: may you step on a lego tonight.
5
imgur again?
Tumblr this time.
hmm, I don't think I've ever looked at tumblr
If I were king of the internet, we'd still be using pages with "next" and "previous" buttons, and ideally one of those "1 2 3 ... 23 24 25... 123" link bars
with optional <- -> keyboard button support
13:56
Unf
My ideal web browsing experience never requires me to press any button other than Down or Right
hence optional :P
I like webcomics that support turning pages with leftrightarrows
hjkl or bust
much easier to go back a few years and binge read when you forget the story
I'm willing to accept "down and left mouse button", which is possible iff the page's footer is styled in a way that ensures the "next" link is always in exactly the same position relative to the bottom of the page
Common failure modes: next button is above a news box that has a dynamic height; next button is to the right of the "1 2 3 ... 23 24 25... 123" link bar, which changes size based on the log of your current page number; Some pages aren't as tall as my screen, so the button isn't aligned to the bottom of my screen, even though it's aligned to the logical bottom of the page.
Partial failure mode: next button is statically aligned as desired, but requires me to position my cursor in a manner that obstructs the page's content as long as I haven't scrolled down all the way
cbg
14:11
Five minutes later and I'm finally back to the spot I was in before. Here's hoping my Internet doesn't drop out for five seconds at the worst possible time. Again.
14:28
cbg
14:42
Tab and enter, for me. Can do anything with tab to highlight, enter to activate. On pagination, I've been moving more towards infinite scrollers and total elimination of pagination, plus movement away from arbitrary numbering of pages towards a continuation style, e.g. ordered descending on timestamp, "next" page is things with a timestamp < the last seen one so far. (Deals more gracefully with alterations to the result set, e.g. additions and removals, I've found.)
I don't mind infinite scroll pages, if they have:
- a "couldn't connect. Try again?" button.
- a way to bookmark my spot. Not just a permalink to a specific entry devoid of context -- I want to be able to continue browsing from where I left off.
- a strategy to mitigate the inevitable sluggishness that comes from my browser trying to render a page that's one mile tall
On a good day, I get 1 out of 3 of these.
order the content in paperback
The first is a must-have, I agree. Nothing worse than a helpful feature making your life harder. Second point is a tough one in practice; possible with ordered result sets. (Hopefully history.pushState updating an anchor reference wouldn't be too disruptive, but having to hit back to un-scroll seems weird.)
The last point was a substantial problem under IE, with its DOM proxy model and terrible memory management. Less so as long as you keep the individual rows "light" today.
Lastly, it's also really, really easy to implement infinite scrolling behaviour: github.com/bravecollective/forums/blob/… (I wanted to add culling of already loaded but older entries, never got around to it before the gaming group implosion.)
14:59
I suspect being easy to implement is part of the problem. Maybe I keep seeing these user-unfriendly implementations because the devs were able to bang out a minimum viable product in fifteen minutes
I have deployed a Django site with Gunicorn and Nginx. When I was testing the site locally, with the built-in Django server, I could see all server activity in real time but with a production environment, I don't. So how do I monitor the server activity in real time?
If it had taken them ten hours instead, then maybe they would have had time to think of additional user stories like the one belonging to "Kevin, the user whose broadband connection is a wet piece of twine"
@Dodge You mean ERROR logs or any (INFO / DEBUG) logs?
Locally you were basically watching django's built-in runserver output, you could do similar thing with gunicorn / nginx by watching their log files.
tail -f is your friend.
@shad0w_wa1k3r Good question. Just whatever is normally printed when one runs python manage.py runserverI've been watching the output for the past couple weeks and It is helping me debug
Cool cool, to watch log files will I need to implement that or just access something that is already being produced?
15:05
You can't get that on production unfortunately (or wherever DEBUG=False & you aren't running the server with runserver)
@Dodge Indeed, that's basically a combination of access and error logs. You might see where your error_log directives in your web server point.
If you're interested in error log reporting you could look into sentry.io, but mainly the log files from nginx (&/or gunicorn) should be sufficient, for everything else, try replicating the issue locally for detailed info (and comfort).
Ok, sounds good. Also will I need to flush these log files some time? Do they just get massive over time?
yes, you may find plenty of similar questions online w.r.t. log file flushing / periodic removal
Right, thanks
15:21
I would really like to use https://github.com/MagicStack/uvloop but it doesnt support Windows.

Is there a Windows alternative that speeds up asyncio?
@amcgregor Hey thanks again, tail -f ing the syslog on that server gives me a real time account that looks much like what I was hoping for.
Rhubarb
\o cbg
@Dodge - extension exercise, pipe all of your logs into Kibana and produce some nice graphs. ;-)
16:06
cabbage
@Dodge read up on logrotate
16:48
There's no way to make @property work as a class attribute, is there? Assuming I don't want to write a metaclass.
You can write your own @classproperty decorator - I wrote @_lazyclassproperty for recent pyparsing, to defer construction of large Unicode character range strings
@Dodge Glad you got it worked out! It never hurts to help.
17:22
I was trying to find a solution to How to create a static class property that returns an instance of the class itself? but if no fast-gunners have found it, it's probably not that easy to do
@Kevin That sounds potentially like a little bit of XY. Similar to striving for a "singleton" implementation in Python when "Borg" fits the object model so much better?
I read "static property" and my brain jumps to "descriptor protocol attribute on the metaclass", which is just a bit overcomplicated.
17:42
@Kevin Ah, I believe I dropped the hint there on how exactly to make @property work at the class level. Define the @property within a metaclass which will expose it at the class level, not instance level. Now that I have tested it, can confirm this works. s.webcore.io/d205b87688da/…
Nice work. It's more concise than what I imagined a metaclass-based solution would be. It's hard to beat wim's one-line approach unfortunately
18:01
@Kevin Updated to include a decorator explanation and example.
18:26
Hello, Wondering if anyone would be willing to provide me with resources they use to automate their Python code.
I currently have code in a Jupyter notebook that pulls data from a weather API (darksky.net) and sends me an email with important information. It works perfectly if I open and run the notebook, but I would like to automate it to run every week for a few days each week. I would rather not use Cron jobs since I may not always have my laptop on and would prefer to use something like Google Cloud or AWS. Any thoughts?
I have vaguely wondered how people do this, too.
I suspect the graybeard solution is "have a cron job on a computer that's almost always on"
Thank you. I completed a Kaggle learning in which code was provided that when uploaded to Google Cloud would pull your latest kernal run and reupload every day. I havent been able to replicate it using another example though. Learning here - kaggle.com/general/74038
Google tells me that AWS does have scheduled tasks.
Yep, when playing around with both AWS and Google Cloud I have always had trouble actually executing my code (even though it works in Jupyter Notebook fine). Always returns some error. Was hoping it would be as simple as upload jupyter notebook or .py and have scheduler run, but not that lucky
Have some suspicions that there are issues with using the darksky api or gmail api, but not been able to confirm
You can also export the Python code in your notebook as a separate script, I believe
18:37
Like download as .py file?
18:57
Yes, using "Download as" from the UI file menu.
There is also a command line option nbconvert
There are a couple of nice SO questions on this subject (which I just read)
thank you. I had a tough time finding them. Would you be able to share a link?
wim
wim
19:32
speaking of the class property stuff, what would you all think of dupe-closing and/or merging How to make a class property? into Using property() on classmethods? Seems exact dupe, and the latter is a more clearly written question with better answers to boot.
rominirani.com/… Currently going through this tutorial
wim
wim
hmm, although the top-voted answer is unfortunately broken. there are other good answers if you scroll down though.
19:48
Hi there. I have a little question. I am facing a weird problem when recording values in a vector return by a function while solving differential equations using scipy. All the vectors contain the correct values except the last one I added recently. I suspect the program to return the sum of the values step by step; have you ever encountered that? If yes have you a few hints to share?
Otherwise, I can as well show you my code but it will very hard to make it minimal as almost everything is linked.
hard to say without an mvce
@ParitoshSingh I just created a pastebin. So as I said everythin in the code is linked so it's quite difficult to make in minimal. But the only things I added are respectively in lines 43 (the whole line), 137 (uv), 141 (uv0) and 154. If you don't have the thermo.py package you can just replace the value line 62 by 2000. If I print the values of uv inside the function I get the values I am looking for. But if I print it outside (as shown on the graph) the values are increasing.
And I have no clue why it's not just recording the values in the vector.
20:09
@JoshJanjua Sorry for the delay, got pulled into a meeting. This one is pretty good: stackoverflow.com/questions/37797709/…
Hey guys, So I got an interesting one. I am running an ansible playbook to build an AMI. In that playbook if I install pip botocore, I can not SSH in to the AMI it creates. If I don't install botocore, I can SSH in. AWS naturally. Any ideas?
so, im afraid i dont understand any of that. @Hexacoordinate-C if it helps though, i would like to point out that none of the values match the outputs of the terms inside the function
and if your notation is any indicator, the terms inside the function is not uv, but rather d of uv.
@wim Only 2 votes difference now, between that top answer and the next..
try this pastebin.com/HN0MCfT4 @Hexacoordinate-C
@JoshJanjua apscheduler.readthedocs.io/en/latest — I'm a fan of APScheduler, though it does require a persistent process to be running. (Though you can fairly easily fall back on using cron to poll hourly, etc.)
20:25
@ParitoshSingh OK thank you for help anyway. Actually the function odeint is using a prediction-correction method to make the calculations and probably takethe average of the values or something that way. I didn't find all the documentation I wanted on this function. Also it is using adaptative step to make the solving of the ODEs which are here probably kinda stiff.
if it helps, i believe there was a newer function for solving, though it may end up doing the same thing, i dont know much about it. solve_ivp
its apparently recommended to use that anyways
@ParitoshSingh OK let see
wim
wim
@MartijnPieters only 1 now .. room 6 effect
Paz
Paz
I got an MVC question, is it valid if theres a big view with views inside of it? Like a window, with frames within it
Like, declaring other views inside a view
@ParitoshSingh well thank you very much. It's really strange to me actually but it does job remarkably. How did you get the idea to make a z[:-1]? And actually yeah it's recording the integral of uv alongside the length.. so it surely rises.
Glad to hear :)
as for that particular line, well i just get to things one step at a time.
when i used np.diff (after noticing the value differences were matching up) the result would be 1 shy of 100 values.
@davidism I'll be happy to reopen, what is the story?
(and hard to believe there is no pyparsing answer...)
@PaulMcG already reopened.
I've had two questions in the past day come up that were duplicates of it. The only reason it was closed was because it was a very brief request for a library.
The answers are good (even if they're not perfect), so I edited the question to describe the problem better.
There is a caveat from 2016 re: XSS about using BS and lxml - still valid?
20:41
Looks like the XSS comes from removing the tags thereby creating a new tag from the string around it. It would probably be mitigated by escaping the tags rather than removing them.
@ParitoshSingh interesting. Well actually I am probably using Python like a savage as I learned it all by myself to solve my chem problematics. I just make the effort to respect the PEP28 so that I ask question here without a minimal code and hopefully get some help from kind people :D
Hmm, that might actually be pyparsing-worthy...
wim
wim
@MartijnPieters While you're here.. I added support for user entry-points to aocd recently. Would you consider adding an entry-point in your code?
See github.com/wimglenn/… for context
I wonder if Markdown handles it. It does use an allowed list of tags, but I'm not sure how it removes them.
wim
wim
(funnily enough, it looks like you have the exact same bug I had for the 2017 Day 20: Particle Swarm)
21:08
@davidism I need to combine Markdown with Bleach, as Markdown generally permits inline HTML. Too much inline HTML. [This will depend on the renderer library in use, of course.]
Also careful with your input. Some Markdown-like text formatting engines advertise mixed HTML support (Markdown, Textile, …) but then perform impressively badly when handed, e.g., a word document saved as HTML. (Which ends up as a single line of code.) Totally a pathological case, but a real one, sadly.
Can anyone find a good dupe for this question?: stackoverflow.com/questions/54524352/…
my comment solved it for the OP but I'm sure there's already a good answer out there for handling your own exceptions...
21:28
@wim That'd require me to actually write a setup.py, and register on PyPI, and write a wrapper to execute my notebooks, and only those parts that are used to find the solution, and not the other bits I add to them.
That's not really going to happen, sorry.
21:57
@MartijnPieters Your setup.py can be literally one line: __import__('setuptools').setup() given a setup.cfg containing metadata. >:D
(See also: running your own pypi; a not-unusual task for corporate deployment scenarios.)
@amcgregor I know, that's the least of the work though.
Does anyone have any information or reference why the genexp evaluation time discrepancy gotcha exists? I figured the lazy binding worked the way it did because the genex works like the equivalent full generator, but this doesn't explain why the in part of the expression is bound on definition
Is there a performance reason why it behaves like that? Conscious choice or side-effect of something else?
@AndrasDeak a genexp body is basically a function.
You call the function by passing in the iterator. That produces the generator function objects you then iterate over.
So... you have to call it first and pass in the iterable, binding the iterable.
>>> dis.dis("(i for i in l)")
  1           0 LOAD_CONST               0 (<code object <genexpr> at 0x103d84f60, file "<dis>", line 1>)
              2 LOAD_CONST               1 ('<genexpr>')
              4 MAKE_FUNCTION            0
              6 LOAD_NAME                0 (l)
              8 GET_ITER
             10 CALL_FUNCTION            1
             12 RETURN_VALUE

Disassembly of <code object <genexpr> at 0x103d84f60, file "<dis>", line 1>:
  1           0 LOAD_FAST                0 (.0)
So the part I'm missing is that instead of def genexp(): ... the equivalent function is def genexp(iterable): ...?
@MartijnPieters I did that, and I could only figure that there's a function call going on, but that could've fit my original picture of "it's the equivalent generator, called"
MAKE_FUNCTION create a function object for the '<genexpr>' code object, and called, passing in iter(l).
22:07
so instead of
def gen():
    yield from l
@AndrasDeak yup. With the iterable traditionally named .0.
it's
def gen(l):
    yield from l
That's a hold-over from the first-pass implementation of list comprehenions in Python 2.
@MartijnPieters oooh, I've been wondering about that .0 but never thought to ask
let me check what nested genexen do
I'm sincerely hoping .1, .2, .3… for however many levels of nesting / chaining you have in the comprehension. I hope.
22:09
Ah, no, got that factoid about .0 wrong there.
>>> import sys, dis
>>> sys.version_info
(2, 6, 9, 'final', 0)
>>> dis.dis(compile("[i for i in l]", '', 'exec'))
  1           0 BUILD_LIST               0
              3 DUP_TOP
              4 STORE_NAME               0 (_[1])
              7 LOAD_NAME                1 (l)
             10 GET_ITER
        >>   11 FOR_ITER                13 (to 27)
             14 STORE_NAME               2 (i)
             17 LOAD_NAME                0 (_[1])
             20 LOAD_NAME                2 (i)
             23 LIST_APPEND
so this only applies to the top-level loop, right?
That's The old list-comp setup, with the _[1] name to hold the list object being built.
yeah, of course, since the nested loops can be affected during execution
That was quickly replaced with the list just being TOS and a LIST_APPEND opcode.
So the follow-up question: is it natural or a necessity that the function is defined like that ^ and not the way I expected?
22:12
@AndrasDeak it is entirely natural, because that fits exactly with how you'd have to implement a list / dict / set comp too.
@MartijnPieters huh, explicit STORE_NAME and DELETE_NAME, seems a bit weird
@MartijnPieters hmm, OK, I'll have to think about that. Thanks for the explanation
It's impossible to search for _[1] with either Google or the SO search engine, I traced down some weird issue with that still being referenced elsewhere.
It's surprising how hard searching code is. Didn't duckduckgo use to have a code search mode?
oh, that's nasty
22:17
And bingo, it was a bug report I wrote: bugs.python.org/issue32836
ha
and the trick is that .0 is not a valid name, right?
right. It's set in the compiler, which can damn well do as it pleases.
awesome, thanks
wim
wim
@MartijnPieters Yeah, understandable, especially because of the notebook thing. Would you accept a PR, if I could do it cleanly? registering on PyPI is not required (pip can be installing directly from github)
@wim it'll be a lot of work, I think. It depends on how clean the solution would be, e.g. how much the notebooks themselves can retain their flow.
22:31
@AndrasDeak I'm guessing there's a loophole via direct locals() access. >:D Something like locals()['_[1]'] which makes me feel all the dirty, writing it.
@amcgregor I don't think so
wim
wim
My goal would be to do it without modifying anything else - I'd be adding a setup with an entry-point only. I noticed most of your notebooks just print like "Part 1: answer" so I'll just scrape that from stdout, and monkeypatch out any plotting and stuff
but in the glorious age of python 3.8 we can use asspressions to refer to the previous element of the listcomp \o/ oh brave new world
hmm, wait, that might not help with having access to the "current partial contents" of the list comp
wim
wim
WRITE A FOR LOOP
for pete's sake, half of my answers on stackoverflow are basically "use a for loop" these days, and it's only gonna get worse...
can't wait 🍿
22:46
"Parsing a complex grammar? Use a for loop!"
Interestingly enough, that's precisely what my DSL does. (The whole code transformation process is a streaming unicode decoder at import time…)
wim
wim
the "one obvious way" to use pytz is basically bugged
when people complain about time or names or security I'm grateful for being in physics
no cows have been harmed by my work
Hi guys can u help me with this post: stackoverflow.com/questions/54489201/…
22:56
I do use Chuck Norris as an example on occasion...
@Mario hello
hey @AndrasDeak
@Mario I'm afraid your question is still quite unclear. Firstly what you have versus what you want to do aren't clear to me, secondly you have way too much code with a lot of parts that can probably be omitted. I'd try boiling down the code to a MCVE, that also helps clarify what you have problems with
man let em I explain you
no, no
your question has to be clear and self-contained
(I also don't have the time/attention span right now for you to take me through it)
then thanks for taking time
23:38
---> 18 while (data_val == 7) & (i < len(time_series)):
.......

getting the value error :
`The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(),
a.any() or a.all().` Reference question - https://stackoverflow.com/questions/21415661/logical-operators-for-boolean-indexing-in-pandas
yes, what's after while is presumably a bool array
boolean numpy arrays and its relatives prefer not to give you a single True or False value when you ask if they're True or False
when that happens either something you didn't expect to be an array(/Series etc.) is an array(/Series etc.), or you need to use any or all` as the error suggests, depending on what you want to happen
I just want it to iterate till the length of the data, and keep updating data_value.
that's OK but I don't know what your types are
i < len(time_series) is probably a scalar, so the issue is probably the first term
unutbu's answer seems clear enough though
Got it, had spotted it earlier, but had to go one step further. It was-
data_val = time_series.iloc[[i]] #returned a row of data
Then I selected column of interest-
data_val = time_series["awesome_column"].iloc[[i]] #returned a series
Just now I realized after this chat, I have to use-
data_val = time_series["awesome_column"].iloc[[i]][0] #returns scalar
why are you using [i] instead of i?
time_series["awesome_column"].iloc[i]
23:53
Thanks, there was no reason to use that, just what I saw first online. That's why my earlier codes were working fine without [0]. Thanks Andras
no problem

« first day (3033 days earlier)      last day (2139 days later) »