« first day (3262 days earlier)      last day (1677 days later) » 

3:40 AM
cabbage
 
 
4 hours later…
8:07 AM
6am: Woke up and answered a question about metaclasses on reddit
10am: Spent 40 minutes struggling to figure out a simple percentage calculation
 
#relate (except for the metaclasses part, I don't see myself answering those kinda questions)
 
Question: "If the dry weight of a potato is X kilograms and you submerge it in water until the water content is 98%, how much will the potato weigh in total?"
Me: *brain explodes*
 
cabbage
Rugby is on!
 
8:24 AM
@Aran-Fey is it X/0.02?
 
I don't know!
(yes, yes it is)
apparently my solution was tested against randomly generated test cases... the first submit failed a test, the 2nd submit didn't. So I guess they have borderline incorrect code added to their collection of solutions now.
 
stackoverflow.com/questions/58038482/… I guess too broad? "Why do these unrelated pieces of code take different times to run?"
 
@wim neat. Can't wait for the "why did my frozen dict lose its order?" questions though
 
8:48 AM
@roganjosh heh, yeah
 
wrestled with my kotlin solution for 20 minutes before realizing the test cases are broken, not my code. Maybe it's time to find a different coding platform
 
9:06 AM
We've had a fun Brexit-y week where I'm working. Apparently, No Deal would mean that we need our distributor's address on every item we export. Marketing have apparently known about this for quite a while, but it was only just revealed that they have so far not changed a single piece of packaging (we have ~600 different packaged products)
But it's fine, they have a brilliant solution. We can just get people to put sticky labels on each product. I mean, we have 1 machine that makes 700 bags a minute. How hard can it be?
 
@roganjosh BoJo has it covered, fam
 
1 machine out of around 50. I expect the army will be dispatched to our aid
@AndrasDeak Sure, and it's a good opportunity for our staff to show real British manufacturing skills. I bet a single person can cover it, it's just getting the windmilling arms in sync with the machine. There'll be teething problems for sure
 
@roganjosh nice. Because if they did change it and there was no no-deal it would've been devastating
 
It would have been pretty cost-neutral. Having the printed address would not do any harm, and we could have a phased transition, keeping the un-addressed stuff as home trade
 
Closed
Seeing "chris p bacon" never fails to bring a smile to my face. I can't help but laugh along with the news presenter
 
Haha, poor guy
 
10:02 AM
@Kevin good news: 3k warriors reuters.com/article/us-usa-area51/…
 
10:13 AM
I guess that includes the festival. 150 at the door.
 
10:49 AM
Long, detailed answer about metaclasses: 1 point
Complaint about reddit formatting below said answer: 3 points
Reddit voting is forever a mystery
 
One would have thought that your SO contributions would have been good training
Scan the main feed: 0, 0, 0.... 7 answers to this
Thinking is hard work :P
Then again, I shouldn't be wafting that under your nose since you're in recovery from the main feed. My bad!
 
11:15 AM
8 now. Ugh
 
12:07 PM
I seem to have built up some kind of resistance to low-quality messes
...but the OP's comment on my reddit answer is making me wish I'd kept my mouth shut
me: "`object` is a superclass of every class"
OP: "does that mean every class is a subclass of `object`?"
 
Watch the chris p bacon clip and move on :) I don't doubt you gave them some good advice, there's no need to follow up on comments that don't make sense.
 
12:51 PM
Well... this is an interesting way of complicating things...
 
Sometimes, you just need to nod vigorously when telling something to someone that doesn't sit well with their beliefs so far.
 
1:29 PM
python allowing that optional trailing comma in sequence literals is an awfully underappreciated feature
>>> var POWERS = mapOf('w' to 4, 'p' to 3,)
error: expecting an argument
var POWERS = mapOf('w' to 4, 'p' to 3,)
:(
 
1:59 PM
This is a nice article weighing pros & cons of Docker and Shiv - mattlayman.com/blog/2019/python-alternative-docker
 
2:30 PM
@shad0w_wa1k3r I got half way and gave up. That is nothing (to me) but marketing
 
@roganjosh Hmm, I found it helpful. Wasn't aware of such a thing in the first place. It (shiv) looks okay, but I saw the version as 0.0.24 or something and I felt I shouldn't bother yet.
 
It reads like an infomercial "aren't you sick of having to do this?" And "but I'm not pushing an agenda" (quotes are paraphrased)
 
might as well skip to the bottom. What got me interested was you could use it with Django.
 
In the Flask Mega Tutorial he shows deployment on docker. I suspect you can do similar with Django.
That blog smells of ulterior motives to me, but that's just me
 
2:52 PM
I read further and it gets my stamp of "Nope". Yeah, it's tough to deploy onto the web, I've been through it as I assume you have, but there's just too much cruft in that article to be credible for me
 
Hello was wondering if someone can help me with the subprocess module related issue I have. I am attempting to run a ffmpeg command using python subprocess which once executed takes a while to run, until the defined video is completed converting. Is there a way to look at the command line outputs that are generated while ffmpeg is performing conversion?
 
As long as you don't set stdout=PIPE you'll see ffmpeg's output
well, in ffmpeg's case it's probably stderr=PIPE
 
So this is my code:
VIDEO_FILE = "input.mkv"

command = ["ffmpeg", "-i", VIDEO_FILE, "-y", "-c:a", "copy", "-c:v", "libx265", "-crf", "28", "output.mp4"]

p1 = sp.run(command, capture_output=True, text=True)

print(p1.stdout)
stdout will not print, until the command is run
 
Any reason why capture_output is True?
 
I learnt from a tutorial, that by setting capture_output to True you can access what the console returns using stdout
That is where I learnt from
 
2:58 PM
Right, but you don't want to access the output in your code, do you? You just want it to print to the console
 
I would like both, capture and print
because I want to try and work out how long it would take to complete conversion
for which I need to capture the outputs
 
That is... a little difficult
 
Oh :(
 
If I remember correctly, something like this should work
process = subprocess.Popen(cmd, stdout=PIPE, stderr=STDOUT)

output = []
for line in process.stdout:
    output.append(line)
    print(line)

process.wait()
 
Well i was hoping, if i could capture the stream of outputs, then work out how long it may take to complete and print that instead of the custom output
okay thanks alot @Aran-Fey, i will try that out now :)
I get PIPE is not defined?
 
3:03 PM
subprocess.
 
is it subprocess.PIPE?
oh cheers :)
ah for some reason, its stopping to output at:
`b' Stream #0:1: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s (default)\r\n'`
Its not showing this bit, which I think I need:
frame= 329 fps= 35 q=-0.0 size= 768kB time=00:00:14.24 bitrate= 441.8kbits/s speed=1.49x
 
ah, right, ffmpeg overwrites the previous line
in that case I have no idea how to do it
 
oh okay, thanks for the help :)
 
recbg
@SShah no the problem is that it isn't outputting that necessarily to a file*/*pipe while it might show that on terminal
 
3:20 PM
@roganjosh yep, agree that there was quite a lot of content that one could skim and it wouldn't make a difference
 
@shad0w_wa1k3r It's enough to believe there's an agenda from the outset :) What's posted after might be factually correct, but I can't shake the intro
 
3:39 PM
@AnttiHaapala hi sorry i am back, I do appologise, I am not quite sure what you mean, yes it outputs to terminal when I manually run the command on a windows command prompt. But from the code that @Aran-Fey gave me, it is not outputing even though the code includes print(line)
 
it's because looping over file object (like for line in process.stdout) yields whole lines, but ffmpeg doesn't output whole lines - it keeps overwriting the previous line with \r and without printing a newline at the end
 
ohh right so I need to find away to make it look back at the previous line then
Thanks that makes sense @Aran-Fey
 
4:03 PM
Thanks alot @Aran-Fey, I found a solution now :). incase your interested I found it from: stackoverflow.com/questions/2715847/…
this is the code that seems to work for me:
`with sp.Popen(command, stdout=sp.PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
print(line, end='')`
Never mind :(
its not working, that was showing me the actual command line output
 
Try with stderr instead
 
4:23 PM
stderr=STDOUT
 
4:35 PM
Can someone help me find how to install ev3dev2 library?
nm
 
 
4 hours later…
9:05 PM
I am trying to learn python. Can anyone help me with a Syntax error problem? I pasted the code on pastebin: pastebin.com/EHYaxDr6 . I run this under python2.7 and get a syntax error on "return command = "
 
@LucasTaddeus [m.group(1)](m) is the issue
you're returning a dict, what do you expect that bit to do?
(the whole thing looks wonky to me but you can return a dict of lambdas)
 
I am matching a regular expression, I expect m.group(1) to be a character. I want to declare a dictionary in which lambdas are indexed by the characters in the code and returned when [m.group(1)] is resolved. Then I want to execute that lambda and receive the object the lambdas return (e.g. parse_add_update(m) will return a tuple when executed, etc)
 
Straight up, I can't help with regex, but you've packed too much into your return
 
To try a clearer explanation, I am creating a dictionary statically in which the keys are characters and the values are lambda functions. Then I dynamically resolve the lambda that is associated with the character returned by m.group(1). Then I execute that lambda with parameter m and the return should return what the lambda returns
This is trying to emulate a switch-case, like in here
1719
Q: Replacements for switch statement in Python?

Michael SchneiderI want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not appear to have a switch statement. What are the recommended Python solutions in this scenario?

 
right, but [m.group(1)] I guess is indexing a dict, which you can't do
 
9:14 PM
It is the third answer
Say m.group(1) is 'a'. Then [m.group(1)] should return parse_add_update
 
Right, ok, I need to go back to the drawing board. I don't think I've seen such a thing
 
Then I want to execute that with argument m (e.g. (m)) and store the return value in command
 
That looks like horrendous Python to me, but it has an awful lot of upvotes so I'm left confused
Ok, it looks like I'm wrong. Where is the syntax error pointing to?
 
The assignment line, the part where command =
 
Sure, you can't make an assignment in a return
 
9:29 PM
Does it not execute the assignment first and then return the command?
 
so make result = ... and then return result
@LucasTaddeus no. I'm not sure I follow the mental model you have. What would the point be in allowing assignment in return when the result is going to be assigned to the caller?
 
9:46 PM
Just a semantic note that what is returned is a command
 
No it isn't. What you're trying to return is the result of a function call
(m) calls the function
In any case, I suspect this is better answered by others in this room. I responded because I happen to be online and others aren't. I don't like the switch translation you've linked to but it obviously is a thing; it's not something I've seen in the wild, though, so I suspect the perspective might be a bit off.
 
10:03 PM
The result of the function call is a command object. You cannot see it because i did not paste the entire code. It was just supposed to serve as a mental note
thanks for the help, you did help me move forward and I appreciate that
 

« first day (3262 days earlier)      last day (1677 days later) »