« first day (2939 days earlier)      last day (2238 days later) » 
02:00 - 21:0021:00 - 00:00

02:34
Is anyone still online? I have a simply Python question that probably can be answered relatively fast.
02:49
Never mind. I was just being stupid.
03:37
cbg
im alive
miraculousy and i think forgotten most of what i know about python
 
2 hours later…
06:02
Friday cbg :)
06:23
Pre-tea Friday cbg. I make even less sense than usual until I've had a brew :)
06:35
Morning coffee cbg
@vash_the_stampede what happened?
 
4 hours later…
11:11
If one more person suggests that this is due to pandas not being installed I think I'll cry
11:57
cbg
cbg
Is there a canonical for parsing nested JSON? I seem to remember coldspeed making one in the last year and google searches are flooded with results. Not sure this counts
what do you mean? json just deserializes to lists, dicts and the usual primitive types
Exactly, but that isn't really covered in those answers. If people are starting from a point of struggling with it, those things should be stated. The answer I'm thinking about did it step-by-step of discerning the structure
The amount of times the [0] list index is the culprit is getting a bit frustrating
oh you mean a canonical answer. thought you were actually asking how to do it
Ah no, sorry. I should have been clearer.
12:10
he's probably had his cuppa by now
Ha, nice colloquialism switch :)
Cabbage
cbg, PM
Side note: I've had to put the kettle on now. Where I'm from, the mention of tea spreads like a yawn
cbg
12:14
Do the English actually drink English Breakfast Tea for breakfast?
Who fills the kettle up is quite literally a daily argument between the mechanical and electrical engineers.
oh, people have workdays today, right
I've written a few JSON parsing answers, eg stackoverflow.com/a/41778581/4014959 which has links to a few variations that I felt were sufficiently different to warrant their own answer.
In daily life we just tend to drink bog-standard PG Tips pyramid bags. Those kind of teas are usually on breakfast bars in hotels etc but I guess those in the south probably drink posher stuff
we have this thing that when holidays are on Tuesday or Thursday the holiday is joined with the nearest weekend, so that Monday/Friday is off (respectively), at the cost of making one of the Saturdays a weekday
12:17
The last link, show_indices has a very compact function to walk through a nested dict / list and print all the indices, and associated values.
@PM2Ring that's a quality answer but maybe a bit more involved than the type of questions I'm trying to close. Not sure. Are you closing others on that answer?
That second one definitely deserved more love :) I think I might use that one.
@roganjosh Sometimes, but quite often I write a custom answer & link it to that one. It depends on the OP's skill level, and the exact task they want to perform.
So at the end of that main answer I have links to other simpler answers, that may be useful as dupe targets, depending on the task.
That main answer is a bit verbose, even for me. ;) But I wanted to make things clear for people who are new to generators and recursion. If you've never used either before, trying to understand a pair of recursive generators that call each other can be a little daunting.
I think I'll prepare a bit of a pseudo canonical for my own uses, incorporate links to your second link. Then it's just a case of finding a suitable question to solve with it :)
If I get round to it and think I did a decent enough job I'll share it back with you :)
Or self-answer your own question, just to get it into SO and linkable
No worries.
12:30
I think that will be tricky on a JSON parse. I'm not sure people will agree that there's value in a self-answered question unless I go all out... and there isn't really enough source material to make it particularly interesting
I think half the battle with deeply nested JSON is that it's so easy to lose track of where you are if you're trying to figure out the key / index sequence by eye. I've seen heaps of JSON questions where the OP's basically got the right idea, but they messed up the indices. And of course mixing up int vs string keys, although of course any dict loaded from JSON must only have string keys.
Yep, so my suggestion is always to use jsonlint with any arbitrary length of JSON needed to get the repeating unit. It will still format it even if the snippet itself ends up being invalid. Also works with nested python objects
I think there are too many reasons why n00bs struggle with json to cover in a canonical. Common problems include:
1) I can't tell the difference between json and a dict
2) I'm incapable of figuring out how to access this specific value in a nested dict/list structure
3) My google skills are so bad that I can't figure out how to parse json
The only trouble I ever have with JSON is when the requirements are unclear. In its simplest form, the OP asks "how do I get the product id out of this?" and the data is a list of dicts, each one having a product_id key. The "the" implies he wants one, but there are a hundred.
So either 1) he wants any one of them, it doesn't matter which, 2) he wants a specific one, but didn't explain the criteria to us, 3) he meant he wanted them all.
When the data has more than two layers, take the cartesian product of these possibilities. Six layers gives you 729 possible interpretations.
I reckon I have a shot at netting a decent subset of the type of questions I'm thinking about. Unless we have something to point to, we're just swamping SO with customised answers all doing the same general thing to different specific cases. I don't see that as particularly helpful
On consideration, I guess that's all SO ever really does, but this feels... different
12:58
hold on, it's been edited
I'm not sure what that is now
13:10
Sometimes a bunch of examples is useful. In fact, a canonical that points to a bunch of examples is useful
Ooh this sneaky integer sequence started as (3, 5, 7, 9, 11...) but then around term 13 it does (... 29, 31, 31, 31, 33...). Nice try lulling me into a false sense of security, integer sequence.
@piRSquared no, that's a link-only answer
20k rant against SO, should only get worse in comments stackoverflow.com/questions/53119201/…
I think it wouldn't take too long where I find a question that I can touch on load/loads, JSON/Python object and issues with nested structures. That's the answer I will start to prepare. Then link to PM's scripts because one is already in my toolbox now :)
I wasn't sure whether I should have flagged that question for a mod
it was deleted by a mod and flagged (and deleted) as rude
@Kevin An exam in my past ask me to provide the formula for the following sequence (1, 3, 5, 7, ...) I provided n^4 - 10 n^3 + 35 n^2 - 48 n + 23
13:16
I'm guessing they'll be question-banned now to go along with the answer ban
which is the same thing as 2n - 1 + (n-1)(n-2)(n-3)(n-4)
@AndrasDeak Interesting. Not that I have passion for either side of this argument but I can swear that it was encourage to provide answers that summarize other answers. For arguments sake, you don't have to provide links only but the examples themselves and links to where they came.
I had a nice program that took a series of numbers and gave back a polynomial f that would generate those numbers for [f(0), f(1), f(2)...]. I liked to use it for SO questions that asked "what's the next number in this sequence?"
@piRSquared definitely not!
that's the most redundant thing possible
The next number it generated was usually some hideous fraction, which delighted me. Technically correct is the best kind of correct.
@Kevin That'll teach them to under specify their question.
13:21
we have duplicates exactly to fight duplicate answers
@AndrasDeak Good thing I never did that then eh? (-: I'll try to find whatever it was that led me to think that.
If a question could be conceived that merited a collection of examples from other answers, then the question was probably too broad to be of use anyway
@piRSquared yeah, that would be interesting, thanks
@piRSquared there's one for Regex IIRC but I think that's an exception and very old. Like some encyclopedia of regex answers
And also IIRC people started getting annoyed on meta about it being used as a dupe target because it covered pretty much everything imaginable so it was never suitable
While writing the program I wondered if it would be possible to make a version that produced a "nicer" series... The polynomials it uses now tend to return non-integers, and the series grows boundlessly. It'd be neat if it could produce a formula that generates only ints bounded in some particular range.
Regular old polynomials with positive exponents wouldn't be able to do this, but maybe if it incorporated trig or natural log or something, I don't know
13:25
You could use a decaying exponential? Or Taylor series equivalent.
2n - 1 + (n-1)(n-2)(n-3)(n-4) * e ^ (something_barely_negative)
This answer is similar but it's not the one I was thinking of which is literally just a list of hundreds of links. Or maybe it wasn't even regex
BTW!!! Got email back from SOTeam. They will! replace my mug. I can shove those tears back into the ducts of the unicorn that shed them.
I thought about adding together various sines of differing wavelength, which I'm pretty sure can produce any number sequence, but then it's perfectly periodic, which is a bit boring
what do you think is not boring? Random spike of "where the yam did that come from" sequence member?
One non-boring thing would be "doesn't repeat", but it'd be pretty hard to generate an infinite series of integers of bounded size without repeating.
13:33
I believe even a random number generator would have difficulty (-:
There are plenty of serieses like that, e.g. "the individual digits of the Champernowne constant", but the formulas tend to be kind of hairy
@Kevin Did it use Lagrange polynomials ? They're great for interpolation, but are generally hopeless if you try to use them outside the range.
\o cbg
Maybe. I worked out the math on a cocktail napkin, so it probably doesn't look exactly like anything you'd find in a textbook. I think I tried to find the polynomial of least degree that matched the data points, but I might fudge it in a couple places and get the almost-least-degree one instead.
But "generally hopeless outside the range" accurately describes the behavior of the Kevin Polynomials.
I believe the "hopeless outside the range" bit is feature not bug
Otherwise, you can concoct a ML model to predict the next member of the sequence as massive overkill
That would be quite funny
13:40
:) Lagrange polys are pretty straight-forward, and use the same trick as piRsquared's poly to zero out the unwanted terms.
For polys that are better behaved, see en.m.wikipedia.org/wiki/Chebyshev_polynomials
Ah ha, it was in my gists. I have zero memory of how it works, even while I'm looking right at it.
This must've been back when I still remembered how to do linear programming, since it mentions triangulation
2015?! wow
It's smart enough to get x^2 out of [0,1,4,9,16], so there's definitely some degree-leastening going on here
14:10
cabbage
14:21
cbg o/
14:56
Playing around with my local hosts file today in the hopes I can fix my intermittent DNS problems. I'm trying to get example.com to redirect to google. I thought 172.217.10.132 http://example.com would do it, but example.com loads as normal. Am I messing up the syntax somehow?
I think Windows requires a reboot for changes to take effect?
On my home computer I have Facebook's various domains redirected to localhost in order to make it slightly harder for them to gather my information. On the rare occasions that I want to log on, I can delete its entry from the hosts file and access facebook.com without rebooting. Occam's Razor suggests that my work computer would work the same way.
Changes to hosts should be immediate
But it used to always reside at c:\windows\system32\drivers\etc\hosts, but it was not there the last time I tried to mess with it
Scary theory: removing an entry from the hosts file doesn't require rebooting, but adding them does. This means that my efforts to evade Facebook's tracking doesn't work for the length of time between "when I log off of Facebook and restore the hosts file" and "when I happen to reboot for whatever reason". The latter occurring maybe once every two weeks.
Incorrect. I have successfully in the past added entries to hosts on Windows, and used them immediately without reboot
15:03
Highly mysterious. I'd ask you to add 172.217.10.132 http://example.com to your hosts file to see if you can replicate, but it sounds like your file has gone AWOL.
I can verify that c:\windows\system32\drivers\etc\hosts is where it's supposed to be
Aside: for all the flack we give users for vague question titles like "my code isn't working", I just googled "hosts file not working" and I would have been disappointed if there had been zero results.
Here's to you, stack exchange posters that make "[thing] not working" questions. ♫ real mean of genius ♫
Ah, now that I've added 127.0.0.1 www.example.com, it does the needful. I could have sworn I tried that already...
File history shows that I tried 127.0.0.1 wwww.example.com -_-
This gaffe, combined with the three typos in my last four chat messages, suggest to me that I should not be operating heavy machinery today.
Here's to you, Mr. ♫ "3-typos-in-the-last-four-minutes-guy" ♫ We salute you!
The next step is to direct www.example.com to its normal ip address, 93.184.216.34, and wait for my Internet connection to stop resolving urls, which happens about once every four hours. Then I'll see if I can visit example.com in my browser.
If so, then using hosts as a tiny local dns server may prove practical, at least for the small collection of websites whose ips I will gather ahead of time.
15:23
/sigh @ high rep gathering votes despite being inferior answer /back-to-work
Hmm. I blanked out the hosts file, but Firefox still redirects example.com to localhost. Internet explorer resolves the page as normal... Even when I restore the hosts file to its previous localhost-redirecting state.
Liberal usage of ipconfig /flushdns does absolutely nothing.
Sounds like a Firefox cache thing
Chrome is behaving identically to Firefox. In hindsight, I should have visited example.com in chrome with a blank hosts file first, before visiting it with a localhost-redirecting hosts file.
Now I can't distinguish between the two possibilities of "Both chrome and firefox cache the ips listed in hosts, putting them in independent application-specific stores" and "Chrome and firefox both refer to a system-wide cache of ips"
If I had visited the site in Chrome with a blank hosts file and it still resolved to localhost, then I would know that it's the latter
I guess I could start over with a website other than example.com. I just have to pick one that I won't cry over if it becomes forever inaccessible to me.
Typical off/on again answer: have you cleared the cache in Chrome?
15:37
How about the home page of a language I don't use... I'd nominate php.net, but I'm worried that there might be some horribly designed php pages out there that actually require php.net to be resolvable by the local system. Incredibly dumb, but, well, it's php...
Fortran.com it is.
not an official page but at least related
@roganjosh I did "clear browsing data" but I'm not confident that would do anything to a hypothetical ip cache.
What options did you set in there to clear?
I've had issues with some things being cached when I've been messing with templates, can't remember the options off the top of my head, but I'm pretty confident it's possible to clear anything at all that may have been cached
Just the defaults: browsing history, download history, cookies and other site data, cached images and files. The others I left unchecked: passwords and other sign-in data, autofill form data, content settings, hosted app data, media licenses.
Hivemind ledger
15:42
to me, "cookies and other site data" sounds like the best candidate for an ip cache. Counts as "other site data" if it counts as anything.
Yep, I think you can rule out a Chrome cache then
-> / tab , enter
wim
wim
meanwhile my linux box has been up for something like 570 days ..
Windows can run for 570 days easily. Except on my home PC where it turns on automatic updates automatically and reboots at 3am, no matter what I disable.
But thats just like how Linux helps protect the system from the user, so its totally a useful feature.
wim
wim
15:54
I haven't used Windows seriously for years, so maybe it's gotten better
It's pretty solid now
wim
wim
I remember reboot required because of installing software, and thinking...wtf??
Yeah, thats generally a lie
recommended, but not required.
You can use it anyway, I don't know what admin it does during the reboot but it's not normally necessary to run the program
wim
wim
15:56
is the registry still a thing? it was this vast dumping ground of keys and values which does magical things to the system and has apparently no sensible structure
And I only say "not normally" to cover my ass because I can't think of a single example
for what it's worth the few package managers I've seen all recommended restarting linux after an update
Yes, regedit. And no, I don't understand anything about it
If you were developing serious software I'm sure you would need to understand these things. Python --> 99.99% irrelevant (not to say that python can't make serious software, but things that you wouldn't use python for; low-level)
wim
wim
python does plenty of low-level stuff in linux
usually python 2.7, sadly
16:15
OS level stuff?
wim
wim
not really that low level
but reasonably important components like yum
I think that's the level where regedit becomes important in windows
Registering drivers etc
There's a couple of times I've had to edit some flags but I can't think of anything substantial
Welp, I broke fortran.com. Even after blanking the hosts file, flushing the dns, closing all the browsers, and rebooting, IE/Chrome/Firefox all redirect fortran.com to localhost.
I wonder what requests.get will give me...
It returns the actual page. Ok then.
Waiting for someone to tell this guy to install pandas.
They got a close vote instead. Don't know what that means.
16:28
I bet jquery would be useful there...
<facepalm> totally JQuery
Oof, I started following the csv tag, so many simple "how do I load this CSV file" questions with "no problem, just use pandas" answers!
16:47
@PaulMcG I can't use chat features at the best of times and now on a phone, but my comment about that exact issue made the starboard so... you're not alone in the despair
If you look at SQL questions, CSV will seem like respite
A recursive downward spiral of despair to make the previous tag palatable. I don't know what slots in between SQL and PHP tags, though, because my knowledge doesn't extend that far
Hey, here's a question on SO talking about browser-specific DNS caches. Great! But, oops, it's closed as off-topic. I guess I better close the tab without reading the answers. Oh well.
Darn my sterling adherence to my principles
Either read the answers or delvote the question, anything else is half-baked
"closed" doesn't mean that the answers are useless, it only means that it shouldn't have been asked in the first place
I know, I'm just being sassy because my jimmies are hyperrustled.
imagine it's on super user
17:04
Ah ha, tools -> options -> Privacy & Security -> Clear History... -> Cache fixes Firefox. I had previously abandoned the "try clearing the per-application caches" plan because I couldn't figure out how to do it in Chrome, but now that I'm sure there is a per-application cache, I might give it another shot.
Or maybe I'll just let Chrome and IE continue to have garbage ips in their cache because I don't care about them.
morning cabbage
your garbage ips are synced across your devices via the chrome experience
I tried clearing my cache in Chrome again, being careful to change the time frame from "one hour" to "forever", and it started resolving example.com properly as well. The Internet tells me that IE has a cache, but it can't be manually cleared, and I have to wait half an hour for it to drain out on its own @_@
17:23
Let's Play Good or Bad Idea:
class str_(str):
  def r(self):
    return f"\x1b[31m{self}\x1b[0m"

c = str_('Hello World')

print(c.r())
print(str_.r("I'm Red!"))
wim
wim
bad idea
One of the rules of the game that I failed to mention was that you have to explain your answer.
wim
wim
because there is no advantage over the simpler approach:
    def red(x):
        return f"\x1b[31m{x}\x1b[0m"

    red("Hello World")
Well now that you say it that way (-:
What do you expect to get from c.split()? Two strs or two str_s?
17:29
Yeah, I'd either make this a function, or make it a ColorRenderer class that doesn't inherit from str
wim
wim
anyway, there are already battle tested libraries for this stuff like colorama, termcolor...
Thx... googling now
Don't install colourama though
termcolor installed, thx
wim
wim
for a brief demo, execute at the shell: python -m termcolor.
17:38
@Kevin bah, the backwards duration of the clearing was a blind spot. The best way to deal with I.E. is to not deal with it. Internet Explorer users don't deserve nice things.
color
that's so funny, I meant to write "cool" but got distracted and wrote "color" instead
Yeah, IE can have its figgin placed upon a pike for all I care. But I included it in my diagnostics so I had one more data point to use when cross-checking my mental model of the problem against reality.
If I only had two data points, I might have drawn a line between them when really the true shape is an outline of a duck
"Mental model" and "IE" together completely changes the connotations of your statement
But imagine if IE's 30 minute cache just happened to clear at the same time as I cleared firefox's cache... Boy that would have confused me.
"So IE reads firefox's application-specific cache???"
Hoisted by the "post hoc ergo propter hoc" petard...
17:44
The weird thing about the Chrome duration thing is that I'm pretty sure I had Chrome open for less than an hour before I tried clearing it. So "clear last hour" ought to have worked.
^ agreed. Don't know what happened there.
Maybe choosing the "forever" option prompts chrome to say "well, I may as well cleanse everything with nuclear fire, even the stuff I don't usually touch during time-window-bound clears"
I might test this theory by adding another entry to my hosts file and then trying to get Chrome to forget about it by clearing the last year of data. If it stays cached, this implies that the ip cache is only cleared during Forever clears.
"Forever"? I thought it was "from the beginning of time"?
-forever
Let's see... The setting's actual name is "All time". I couldn't remember the precise wording.
17:53
I'm in an understaffed Windows corner of the ring so I need to be as pedantic as I can be to show we have skillz too
Unrelated. Just came up with a seed of a puzzle: while writing some code, you find that you need to use nonlocal x, even though you never assign a value to x after its initial creation. Why do you need to use nonlocal x?
Linux user describes an obscure situation without an MCVE... :)
wim
wim
@Kevin you're extending a list in an enclosure using +=
I award you the Plaque of Sneakiness, because one may argue that augmented assignment is not assignment.
wim
wim
pastebin blocked here
Is "because you want your code to throw a syntax error" a valid answer?
Perhaps, but there are lots of ways to throw syntax errors, so maybe "need" is a strong word when there are a million other alternatives.
but maybe you need a syntax error with the message "no binding for nonlocal 'x' found"
That just happens to be the exact character sequence necessary to buffer overflow hack the mainframe upon which the program runs, eh?
exactly!
18:10
Now I'm wondering whether the behavior described in the intended answer is guaranteed, or a CPython implementation detail. The documentation doesn't say that the nonlocal x statement causes x to appear in the locals() dict of the closest enclosing scope. That's what it does, as far as I can tell, but it could just as easily leave all the locals() dicts alone and do some extra name resolution magic on the backend.
Well, maybe not just as easily. If it was easy, maybe they would have done it that way. But it's possible in principle.
good question
Anybody who uses code like that in production probably deserves to get whatever behavior the environment chooses, so it's kind of a wash
Silly question: if someone has a name including whitespace (i.e. first name and surname by Western conventions), do you use @ and just strip the whitespace, but keep capitalisation, to ping them? I should know this by now, sorry :/. I can never remember. I don't understand why chat auto-completes the names in mobile view but the main site doesn't.
That's how I do it. I suspect the capitalization doesn't matter though.
I tested with Andras but forgot the result lol
He got pinged but i don't remember the convention I used
18:22
To the transcript! [batman-esque scene transition]
This was ages ago. "Well now you can test" is something along the lines of the convo
Just repeat the test. Only need someone with a name with whitespace to comment on a question/answer of mine that happens to have a name with whitespace
@roganjosh I just use the tab completion feature that SO offers
Tab completion in mobile view?
in chat or comments?
On main site. On chat it completes the name for me
18:30
I think both offer completions that you can tap on
I use the SE app rather than the mobile view in my browser.
@roganjosh You should be able to use the full site now on your Android phone. Use the "full site" link at the bottom of the page, but leave the browser's menu in mobile site mode.
postimg.cc/34PpPcpd totally a Tinder match thrown in. But you don't get that on the main site (not the match)
So, for all the poop features of chat, it gives you name suggestions of who you want to reply to. That doesn't happen on SO
sadly mobile chat doesn't support file uploads...but you can go to the full site link in the menu to do it.
You can't see the image? I put it on a free host
I can see it.
18:37
I see a link to the image
Clarification: I can see a link to the image and when I click on the link I can see the image.
@roganjosh You get name suggestions on the main SO site if you use the full site view. At least, it does in the Samsung browser. Give me a minute & I'll test it in Chrome...
on the full site you can upload images directly to chat...or is using that feature discouraged in this room?
I get suggestions in Chrome
and I think I'm in mobile view even
@Code-Apprentice you've missed my point mate. The name suggestions I've shown in that screenshot for who I want to reply to, they just don't pop up on the main site
Images have nothing to do with it, I was showing an image of my view
@roganjosh and I'm saying that I see suggestions on the main site
18:40
Yep, also works in Chrome.
Two phones and I get no suggestions other than in chat, and I'm using Chrome
Does "main site" in this context mean "the chat room when viewed from a regular desktop" or "stack overflow dot com, as opposed to chat dot stack overflow dot com", or some other thing
It's a bit confusing because there are 4 combinations. Full or mobile on the site itself, and desktop or mobile in the browser. And they all look different.
Main site is stack overflow to me
Chat is a subsid
my previous comments about images is a tagential comment to the main conversation about pinging autocomplete
18:43
We're going to need a punnett cube
I'll do an ip-dip-do to pick an example
I just picked some random question with existing comments ^
I'm talking about the main Stack Overflow site. The "full site" view used to be unusable on a phone, but the new responsive design makes it usable. You get name completion. And you can flag comments. Etc.
18:46
Hmm, TIL. We don't have this rhyme in my region.
So, on the main site, I get no suggestions
@roganjosh But did you click on full site down at the bottom of the page?
Why should I have to? But no, I didn't
@roganjosh Because that's what you need to do to get the full site. :) Sorry, I thought I'd explained that several minutes ago.
I'm signed in as me, the app is **** and I have to click to get features intrinsic to chat? :)
You did
18:55
I guess they did it that way in case the new responsive view was rubbish on some mobile devices. So you have to manually select from the 4 options I explained earlier.
It's surely a UX fail?
If you want commiseration about the shambles of the UI that we inhabit, you had me at "chat does this weird thing..." :-)
I don't buy that excuse on behalf of SO. If I want to edit comments in chat, I have to go back to Google and then re-join chat. I don't know enough about why that happens, but it's a mess
But I don't wanna rant. Maybe best to change subject? :)
I think of my behavior as less "excuse-making" and more "fatalistic resignation"
@roganjosh That is definitely weird. I've never had that problem in the Samsung browser. Let me try in Chrome... Ok Chrome is weird.
19:02
Lol. That phrase is categorised mentally with "the beatings will continue until morale improves" :P
I can confirm that Chrome yams up the Chat menu bar, but I somehow managed to make it work by random tapping a dozen times or so.
Has anyone else played Delta Rune, the new game(/demo) from Undertale creator Toby Fox? I played through it yesterday and I liked it. Like its predecessor, the actual rpg gameplay is fairly thin, but the writing is good.
@PM2Ring not just on chat. It's worse on the main site because I have to guess how to ping people
@roganjosh So didn't the full site work for you?
It's only a few hours long, which I felt prevented it from completely finding its feet thematically. I've heard murmurs about a continuation, which would correct that issue.
19:09
Maybe it's a version thing. I have Chrome 67.0. something
I'll have to test properly tomorrow, I'm playing pool half the time. But if I can do pretty much everything that my privileges allow, why can I not ping people in comments (with suggested recipients)?
The mobile site has lots of limitations, not just the lack of pinging. You can't see up & down vote counts, you can't flag comments, on a profile page you can't see when a user was last active. Etc.
When a user was last active is broken on the main site anyway
It's a meaningless value
Sure, but it's better than nothing. It's not totally meaningless, it's just not very precise.
Fake information is not better than no information
19:20
Cabbage all. I have an encoding problem
I think. I want to read an mp3 file and print it's contents, so far I have:
with open('sound.mp3', 'rb') as file: print(str(file.read()))
"contents" as in id3 tag?
If you want to know if a user was active in the last few minutes, forget it. But if you only need precision to the nearest day, it's fine. :)
@AndrasDeak No simply I need to print what the file contains in a string form
Hahaha. That must pain you to say, being in physics :P
@Simon you want to print the compressed contents of an mp3 file as text, mhmm
19:23
@Simon Why are you trying to print binary data as if it were text? That's generally not useful.
clear as mud
@PM2Ring I am trying to stream mp3 in browser by printing it (sending the nessesary headers)
I hope you're using python 2 with that
wim
wim
@user2357112 related to you? stackoverflow.com/users/225312/user225312
look at what str(b'asdf') really is
19:25
@Simon that makes no sense to me, mate
Why would you stream an mp3 by printing it?
@Simon Oh, ok. So that Python code is on a server. What Python version?
Oh yeah, I took that part for granted |[
Python 3.7
@roganjosh This should prove interesting if you are not farmiliar with cgi already cgi.tutorial.codepoint.net/hellow-world
@Simon In that case you can't use print. That's only for text.
19:29
So I can't put the raw binary from the mp3 file as text?
^ please see amended comment
@Simon nope, not interesting to me sorry. You're looking to serialize the data?
I haven't done any CGI stuff for a whlie, so I'm a little rusty. And I've never tried streaming audio, but I've sent binary image data successfully.
Laurel not at the moment, but I'll be sure to ask if I get into it :) @roganjosh
@Simon No, but don't despair. It's easy! :)
@PM2Ring That sounds very similar to what I'm trying to achieve
wim
wim
19:32
>>> source = """async def f():
...     yield
...     return 1"""
>>> parsed = ast.parse(source)
>>> compile(parsed, 'wtf.py', 'exec')
SyntaxError: 'return' with value in async generator
found another compile time syntax error to add to my collection (now 2).
You just need to work at a lower level than print, since that's designed to handle Unicode, and it will stuff up your binary data.
Any good sites I could read up on that (so far resourses have been very limited my end)
You need to use the .write method of the binary version of stdout.
sys?
And IIRC, that's sys.stdout.buffer
19:34
@Kevin The last RPG I played on a computer was King's Quest V Man that was good game...
I disagree, what practical use does that have, PM?
So, something like:
sys.stdout.buffer.write(mydata)
@wim Make that three:
>>> code = '''def f():
...     nonlocal x'''
>>> ast.parse(code)
<_ast.Module object at 0x7fe1b8f67748>
Ok I'm not really familiar with sys.stdout but a quick google looks like that might be the solution
19:41
Quick question: I need to iterate over items in a list that satisfy certain criteria. Is for item in (item for item in items if item.whatever): a reasonable/readable solution, or should I just if item.whatever: inside the loop like a normal person?
@TheGuywithTheHat if you have a loop anyway I'd put an if not item.whatever: continue to get it over with
Okay, thanks
@PM2Ring Getting somewhere now malformed header from script 'index.py': Bad header: ID3
Thank you, I'm on the right track
@roganjosh Um, it lets you output binary data to stdout in Python 3. It may not be a common thing on Windows, but on Unix-like systems it's common to pipe binary data from one command to another. And it's useful for old-school CGI, like what Simon's doing.
Here's a brief answer by Martijn on this topic stackoverflow.com/questions/31917595/…
I'll shut up then :P
19:51
@PM2Ring "old school" :p
wim
wim
@Aran-Fey thanks!
@Simon No worries. Looks like you need to make sure your MP3 data hasn't been mangled. Don't forget to open it in binary mode. :)
Apologies for the autocorrect mix up there
nice try
Yep, totally trying to subvert the rules of the room. You got me.
19:56
@Simon Yeah. Hardly anyone uses CGI these days. I reckon it's fine for simple tasks. But for anything more complicated it makes sense to use a proper framework of some description.
True enough. I just need that one thing, not a whole web page, I can just code that myself in html later
Anyway, it's better than a framework for learning purposes
@Simon Make sure you're sending all the proper HTTP headers, with \r\n line endings. If you try sending binary data without an appropriate MIME header, it won't work.
@Simon I agree. It's good to mess around with this stuff at a low level.
Yeah I double checked everything, it seems to check out. I was beginning to go over the mime type now.
the only MIME type I know is creepy
A few years ago, I wrote a very simple server in awk. It's totally insecure, and can only serve directory listings, text files, or simple image files. But it's only a couple of dozen lines for the whole program.
20:05
Is it possible that my mp3 file is a slightly different encoding, enough to change it from the standard MIME type (I am using the correct one looking at this table feedforall.com/mime-types.htm)
@PM2Ring The text-processing language?
I am using print("Content-Type: audio/mpeg\r\n\r\n") right now
20:19
@Simon That should work. But your browser may disagree. ;) See stackoverflow.com/questions/10688588/…
@Simon Yep. Awk is pretty limited compared to Python, but it's good at what it does. And it's generally at least twice as fast as Python.
awk is great
wim
wim
20:36
the gawk docs have some cool examples such as web servers and even a maze
@Simon Actually, you should be using the end arg of print to set the EOL characters, eg print("Content-Type: audio/mpeg", end="\r\n"), but the browser should ignore the stray \n, and modern browsers cope with simple \n instead of the proper \r\n sequence. But you must have a blank line between the headers and the data.
@wim Indeed. I built my Web server by modifying the examples from the gawk docs.
@PM2Ring Should be fine, I'm on Firefox
@PM2Ring Blasphemy! how about when it is compiled ;)
@PM2Ring Yes it doesn't make any difference, thank you for correcting me though
Python is always compiled, to bytecode. But awk is a simpler language, and its interpreter is fast.
More lightweight maybe?
Anyway I'm going to call it a day
20:52
Sure. It doesn't have to mess around with objects. Almost everything in awk is a string. And it's really good at processing strings.
afternoon cabbage
@Simon See ya.
this week seems to have dragged on
this new project isn't as exciting as I'd hoped it would be
@PM2Ring rbrb
I've never done async programming before, so this might be completely misguided, but I want my library to be usable both synchronously as well as asynchronously. Basically I want it to work like this:
def my_hybrid_func():
    do_some_stuff()

def do_some_stuff():
    sleep(1)
    print('done')

# this would take two seconds to complete
for _ in range(2):
    my_hybrid_func()

# this would take 1 second to complete
tasks = [my_hybrid_func.run_async(), my_hybrid_func.run_async()]
asyncio.run(asyncio.gather(tasks))
20:54
@Code-Apprentice What was the old one laurel
Is that a good idea, and is it possible?
02:00 - 21:0021:00 - 00:00

« first day (2939 days earlier)      last day (2238 days later) »