« first day (4488 days earlier)      last day (452 days later) » 

2:50 AM
@PM2Ring thanks for the answer!
@KarlKnechtel browsing a bit has suggested that it's pretty complicated to do this on windows, better to just have a GUI do something analogous
 
 
9 hours later…
11:27 AM
when defining a function, i'd like Pycharm to suggest to me the available methods on the arguments. so for example, if function1(list1) takes a list, i'd like pycharm to suggest .append() when I write list1.ap within the function
is the only way to do this to define default values?
i wasn't liking this solution for the case where my function would take objects as arguments, leading to the possibility of accidentally creating new objects
 
Use type annotations. def function1(list1: typing.List[str or whatever]):
 
oh didn't know about those, thank you!!
 
ah, IDE support probably has a lot more to do with people asking weird questions about forcing the type system to handle weird and complex cases (as opposed to mypy etc)
I say "the type system", but I mean like... the "typing mini-language" implied by the typing module? I guess?
 
What's the difference?
 
cool, type annotation works inside loops too
 
 
5 hours later…
5:07 PM
Hello, i try to write in an mp3 an audio stream with this command:
self.p1 = Popen(['ffmpeg','-y','-loglevel','quiet','-i',self.current_item["stream_url"],'outputfile.mp3'])


When i run:
self.p1.terminate()

then i run
os.remove("outputfile.mp3")

but this error happens:

[WinError 32] The process cannot access the file because it is being used by ano
ther process: 'outputfile.mp3'

Any help?
 
What's self.p1.returncode after the terminate()?
If it's None, it's still running
 
When i use Popen for radio url check for 10 seconds it is 0, but when i use Popen to write the audio stream to file it is None.
so self.p1.wait() may help in this case?
 
Probably
 
error still happens
i also use psutll to stop the process but no pid found error happens...
 
5:23 PM
Huh, weird. Maybe it'll work after a short time.sleep(), but at this point idk
 
Are you sure there isn't yet another process reading that file?
 
yes the only code that create this file is the Popen command.
I use it first to check if the stream_url is correct for 10 seconds and the i use it to have some pydub.AudioSegment slices to play in pyaudio.
It's play the stream but when i decide to play a local mp3 file (and delete outputfile.mp3) the permission error oqquers.
 
Could be the antivirus I guess
 
Hm, i use Avast
let's turn it off for a while.
i deactivate all the shields for 1 hour, but the error still happens.
If i use stdinput to type CTRL+C may solve the problem?
 
Sending something to stdin won't make the process exit, so no. And if you actually properly send it a keyboard interrupt... probably still no
 
5:43 PM
in windows 11, python 3.10+ i didn't have this problem, but in windows 7 python3.7 i have :\
Also, in outputfile.mp3 dir they are crated some this like: ffcache1Apgjk with no file extension everyone is 128Kb
 
6:40 PM
Closed
 
7:10 PM
stackoverflow.com/questions/33054527 The title on this canonical is clearly wrong; no writing to a file is evident in the MRE. Maybe it got edited away at some point?
It looks like the code never involved writing to a file, and "when writing to a file" was erroneously added to the title in 2017... by Martijn. Oof.
 
@KarlKnechtel It looks like the Q&A accumulated all sorts of file-related answers (and one for sockets...?!?) over the years. I've added the "file" back into the title, but hopefully this variant fits the content better.
Sadly, there's also at least one answer using the readlines bad advice...
 
 
1 hour later…
8:28 PM
yam it.
@MisterMiyagi they're just giving various examples of the setup for the problem. But the provenance of the data doesn't matter; what matters is that a bytes value is being compared to a string literal
oh, I do see an answer about file.write. But that came after the title edit
also there's something about writing csv files that has a barely comprehensible addendum suggesting "never mind this doesn't work"... at +34
(well, now +33)
 
 
1 hour later…
9:41 PM
@MisterMiyagi not sure what you mean there. The .readlines call is in the question example.
 
10:36 PM
er actually it should probably be dupe-hammered
min by attribute is straightforward
 
 
1 hour later…
11:38 PM
Jan 19 at 20:23, by Aran-Fey
I would suggest not to approach this with a "I'll only learn what I need" kind of mindset. If you're going to be programming, you should properly sit down and work through a tutorial. That's far more productive than doing little experiments like elements(i) and elements{i}
@Aran-Fey are there any specific tutorials on Python that you would recommend?
 

« first day (4488 days earlier)      last day (452 days later) »