« first day (4090 days earlier)      last day (1083 days later) » 

00:54
leave = (w for wl,ww in [(bridge,0)]+wagons for w in [0]*(wl-1)+[ww]) my eyes :/
There has to be cognitive burden for the person that suggested that maintaining their own code. I've gone through their answers and they all follow this theme but they have a lot of rep off the back of it
01:48
This is probably a bit late, but Happy Boxing Day to all you Commonwealth folks!
 
5 hours later…
07:17
@roganjosh Some people are just incorrigible. FWIW, I doubt that person has a lot of actual programming experience under their belt. Have you seen their website? Gives me the impression of an overly enthusiastic teen
But of course the world likes to prove me wrong, so there's a decent chance it's a dude in his 40s who's been a programmer for 22 years
07:35
Hi folks
08:24
Hi everyone, looking for some help running a .py file as executable on Windows. I put a #!/usr/bin/env python3 at the top of the file and got syntax errors until I cleared the file and simply left a print(sys.version) and it showed 2.7.1... I have that one along with 3.9 and 3.10 installed on my machine and the PATH only includes the 3.9 one... I'm stumped...
Right click -> Properties -> Opens with -> python 3
Shebangs don't work on Windows, it just uses the default program to open it
I was hoping to use as a scheduled task, but as I am writing this a scheduled task I made with a full command (i.e. python prog.py) just happened and worked so I guess it's not worth wasting my time...
@Aran-Fey But shouldn't it depend in some way on the PATH? I made sure it doesn't have Python 2 at all...
Nope. How would Windows decide which of the programs on your PATH it should use?
How does it know from the shebang? There is no /usr/bin/env in Windows (as far as I know)...
...it doesn't use the shebang
08:40
Ok I just ran the file without the first line of the shebang and it ran exactly the same... So Windows simply ignores this line??? How does it know to use python to run it at all? Nevermind the version...
(by running I mean just prog.py, without the python before it)
@Tomerikoo Yes, the shebang has no special meaning to windows.
IIRC windows matches programs to files based on the file extension only.
So in your case it knows that Python 2.7 runs .py files and that's what it's going to do.
OK... I didn't know that... Wasn't mentioned in the questions I found here...
I did find a env variable called PATHEXT but it doesn't have py...
Ok now I did find this answer and found the Windows settings for file association by type (extension), but it just shows python.exe is associated with .py and I can't know of which version it is and trying to change it only shows two options: Another python.exe and "search in Microsoft Store". bahh frigging Windows...
 
3 hours later…
11:54
@Aran-Fey Some of their answers are relatively advanced, just totally unmaintainable. I suspect they transitioned over from some heavily functional programming language
@Tomerikoo python3 instead of python would be a decent first step?
Windows actually doesn't have a python3 executable. They say py -3 over there, those weirdos
@roganjosh Where do you suggest doing that? Running python prog.py is fine - executes 3.9. the shebang with python3 still runs Python 2... I officially gave up
I even tried to follow Aran-Fey's first suggestion of the "Open with..." right-click which didn't seem to change anything as well, even after browsing and choosing the specific executable of Python 3.9
Oh, then perhaps I've misunderstood. I haven't actually ever used the Windows task scheduler but you said "(i.e. python prog.py)" so I assumed you could swap it out there for python3. As others have said, the shebang isn't going to help here
Just delete Python 2.7? (I'm kidding)
@roganjosh Ah no maybe I forgot to mention or wasn't clear, but the scheduler with python prog.py works fine. Doing where python gives 3.9 so that's not a problem. For some reason I decided it would be nicer to make scheduled task run the file instead of running Python with the file as the argument and got to this whole stinking mess...
@roganjosh To be honest, the only reason I have it installed on my Windows machine is to verify questions on SO which are specific to Python 2 (a rare occasion...), but I do like having it...
I was totally being facetious :P
Though it wouldn't be so explosive on Windows because it doesn't use python (I can't remember who in this room taught me that, but I was totally shocked)
12:09
need to remove last word from path and add new word to it (should support python 2.7)

str = 'home/ro/A_Python_Scripts/flask-auto/build'

newstr output as: 'home/ro/A_Python_Scripts/flask-auto/final'

remove build from str and add final at last

(Must be one line code)
What do you mean by "(Must be one line code)"? There's no reasonable reason to prioritise 1-liners over actual functionality
okay
string = 'home/ro/A_Python_Scripts/flask-auto/build'
print(string.replace("build", "final"))
__import__('os').path.join(__import__('os').path.dirname(str), 'final')
I suspect that's useless for any practical purposes, so you'll need to give more context
12:18
@roganjosh Its based on updating the path with custom folder directory path
@roganjosh Thanks
Another piece of brittle software all polished up. At least I didn't have to pretend I might try regex and then just disappear
Sometimes I like reading through the starred message history, and I just noticed the JS room has more than *eight*(!) times as many as the python room. Gonna take me a while to get back out of this particular rabbit hole. It's pretty deep, and I think both my legs are broken.
Don't worry about your legs, JS will just cast them for you.... I'll show myself out
Well, I hope those casts won't be minified. I imagine that would hurt
I've tried my best and all I can get is "Well, it does make (sp)linting harder" but that doesn't even meet my own standards so I'll probably need a couple of hours to respond
12:34
Don't let me drag you into the JS world. Stay in the python world where it's nice and cozy
I work with JS almost daily, so don't worry about that
By "work with" I mean "Probably botch something but I'm never quite sure if it might actually be idiomatic JS anyway"
Is there even such a thing as idiomatic JS? :D
These questions are too big for mere mortals
13:07
The python room is really great. Many people think it's toxic, but it's not, quite the opposite really. It's a warm place. Unsuspecting visitors are welcomed with open arms and given a nice tight hug that makes their eyes water. It's to die for. And then all the pressure is taken off.
 
2 hours later…
14:37
@Aran-Fey I'm not quite sure if there's a statement being made in that. I have come down on newcomers quite strictly (I do look at their posting history on main first, too). You're a decent barometer so is my approach annoying you? (I'm pretty sure you'd shout at me if it was but I'm unclear about the statement)
No statement, just a botched joke. I guess I made it too subtle after all
Just like my JS, then :P
This isn't the first time you've asked my opinion on your moderation practices, so I'll reiterate that I think you're doing fine
The only behavior I've found a bit problematic lately was my own :D
Hi how to access a url link in python mail script(MIMEMultipart) example:

send_link="/home/local/report/files"

email_body = """<pre>
Go to the path: <a href="send_link">send_link</a>
Thanks,
XYZ Team.
</pre>"""

msg = MIMEText(email_body ,'html')

output wanted as

Go to the path: /home/local/report/files (this path should be in url form)
Sure; that's appreciated. I do have to sense-check myself every now and then because I'm only trying to speak for the room
@ansh1 This looks so abstracted from the real problem that it's not sensible to answer
14:45
What does "in URL form" actually mean?
@MisterMiyagi in herf link format
... come on now
Are you trying to link to your own filesystem for a start?
@roganjosh Yes i need that path in link format. its server path
So you want a site that can link to arbitrary files anywhere on your system? Do you know what that means?
I'm reading the mime/email docs and they're doing absolutely nothing to help me understand anything. I'll have to pass on this one
14:49
@roganjosh that send_link="/home/local/report/files" path is actually a server path.
@ansh1 right, and what do you have set up to respond to that?
At the moment it looks to me like you think you can pass a URL to any arbitrary file on your server, and that's all kinds of "nope"
@roganjosh yes we have
Do I understand this correctly, you receive an email that contains the text <a href="send_link">send_link</a> and you want to replace this text with /home/local/report/files?
@Aran-Fey yes correct
"right, and what do you have set up to respond to that?" -> "yes we have". This is not going to help either of us understand
14:54
Ok. That seems like a strange thing to do, but I don't see anything inherently wrong with that
Output in mail should be like this

Go to the path: /home/local/report/files (this path in herf link format)
Would msg.as_string().replace('<a href="send_link">send_link</a>', send_link) be a reasonable solution?
It's href not herf. That's twice now you've been mistaken on that, and you're not answering my questions
Yeah, I don't know what href link format is. Can you just tell us what the output is you want?
@roganjosh oops ya typing mistake its href :-D
:53724025
<td>Go to the path:</td>
<td><a href="home/local/report/files">home/local/report/files</a></td>

instead I want to access using variable as send_link= "home/local/report/files"
so Go to the path: <a href="send_link">send_link</a>
15:03
What is serving this content? Flask/Django/Other?
It's looking very PHP-y
@roganjosh python send mail
This is my last go. There has to be a server that actually gives the content at a URL, right? You either embed the image into the email itself (which I don't know about) or you send an email with a href that hits a server to send the image
@roganjosh I am getting the content path from env variable and that content i need to send as email as with other details.
Flask/Django might be red herrings, it's more likely to be nginx/apache I guess
I don't think I can help on this, sorry
@ansh1 Hmm, well, not much I can say except I'm pretty sure you're gonna need a HTML parser like BeautifulSoup for that
15:11
@Aran-Fey Its just I need to pass the variable value to html body content as href
Easier: so Go to the path: <a href=f"{url_link}">send_link</a>
@roganjosh Okay Thanks let me try
Pretty sure they're receiving the message, not creating it
All I've done is use "f-strings".
...if it turns out that an f-string is indeed the solution I'm gonna be mad
15:16
@Aran-Fey But they're trying to build an email body?
I am so confused. I'm out
Go to the path: <a href=.format"{url_link}">send_link</a>

in .format will try
As far as I can tell, they're modifying an email body
@ansh1 That's not valid syntax. I don't think any of us are on the same page here
<td><a href={}""".format(send_link)+""">send_link</a></td>

this giving me error
Ok, this is silly
That isn't what I suggested in the first place, and between Aran and I, we don't even know what you're asking. Please take time to formalise a proper question
Or, just leave, I guess? After our efforts :/
15:28
Soon we'll have to start asking for an MCVE + 3 unit tests
I think an MCVE would be nice here. Your magic 8 ball might be stronger than mine; I still don't even know what we were really trying to solve!
Im trying to use this answer:
https://stackoverflow.com/questions/6996603/how-to-delete-a-file-or-folder-in-python

in order to delete my folder.
Im simply using
try:
shutil.rmtree("Folder")
except Exception as e:
print(e)
return
The problem is that if one file inside the directory is open, I will catch the exception but the deletion still occurs. What should i do in case that if a file is open, dont delete anything?
15:54
Not sure if this works, but maybe you can test if a file can be deleted with os.access. Run an if os.access("myfile", os.W_OK): on every file before you call rmtree
16:49
@Aran-Fey I'm not sure if it's ironic or just how things work, but 99% of the time when I take the time to write a test the answer falls out in front of me
@Eminem I'm actually not sure if that's possible. It may be possible to copy the entire tree to a temp dir, and attempt to delete -- if the deletion fails for any reason, copy all the files back and then remove the temp dir
@WayneWerner It depends on the problem, but sometimes it helps because it makes you look at the problem from a different angle. Throw out that tangled web of thoughts you've had in your head for the last 3 hours and start again with a new perspective
17:45
I've got a (workflow|ergonomics|layout) problem and I'm wondering if there's a clever solution... I'm trying to keep an eye on two windows at the same time. Window A displays a progress bar for an iterative process that crunches numbers for five minutes, then asks the user for feedback/input, then returns to crunching.
Window B is a complicated GUI that is quite cramped unless I run it in full screen. 99% of my time/attention is dedicated to window B, and I often forget to alt-tab to window A to see if it's waiting for my input.
If Window A is relatively small, you could put it into always-on-top mode (this requires an external program on Windows) and then tuck it away in some corner of the screen where it's visible but not in the way
My current solution is to position window A so that a sliver of its progress bar is flush against the bottom of my screen, and run window B in non-maximized non-full-screen mode, resized so it takes up the whole screen except for the bottom ~10 pixels. That's where I can see window A's progress bar. This works okay I guess, but window B loses 10 pixels of screen, plus about fifty additional pixels from the title bar etc which I can only hide when in full screen mode
Window A is medium sized. The progress bar itself is maybe 150x10 px, but there are various toolbars and menus that mean I can't make the window smaller than about 160x160 px without blotting out the progress bar entirely
You probably don't need me to tell you this, but you can also overengineer the whole thing and write a script that periodically checks program A's CPU usage (or window title or whatever) to find out if it's idle
The solution I'm imagining is an external program that periodically takes a screenshot* of window A, crops out the exact 150x10 px rect I specify ahead of time, and displays only that part in always-on-top mode
(*applying Dark Magick to get an image of window A even though it's 100% obstructed by window B. I'm 60% sure this is possible as long as it's not minimized.)
I suspect program A is busy even when it's idle :-p
It may or may not be mining bitcoins and emailing them to Slovenia whenever it's not doing reputable work
I have written code for window automation, but getting a screenshot of an obstructed window has proved too difficult for me. It must be possible though, because I'm pretty sure screen recorders like OBS can do that
18:03
GifCam takes screenshots of everything behind its own window, so there must be at least a little OS support for capturing semi-occluded windows.
Umm... doesn't windows support things like applets that can put a bit more detailed information in your system tray or similar?
Yeah, "toast notifications" and suchlike. I've thumbed through one or two libraries on pypi that help with that, although it's still not a painless process
"First, register your .ico file" -- my what now???
umm.... aren't toast notifications more pop-up like rather than static-y things
Yeah.
I was thinking about something more like the traffic monitor I've got there for instance... so if that's possible on windows - I'd have thought that'd work okay...
(then you wouldn't have to worry about windows as the info would be visible in the system tray...)
18:09
I do like the aesthetic.
I don't control the source code of Window A. In truth, it's a Firefox window. Maybe I can open it in Selenium and watch for changes in the DOM near the progress bar...
is it a plugin or just a page... eg: is there some websocket you can listen in on or some route you can use to periodically poll the page?
Much of the number crunching happens locally in the JS sandbox, but I think it dials home once a minute or so. Perhaps I can eavesdrop there. But then I might hear something like "the progress bar reached 100% 59 seconds ago", which is not quite the resolution I crave
sounds like you've got a bit of fun there then :p
I guess I can gather the progress bar percentages of each dial-home message and try to interpolate when it will hit 100%, whether it coincides with a dial-home or not
So program A is a website? That makes things easier. You can write a userscript that watches the progress bar with a MutationObserver and shows a notification with GM.notification
18:20
Ooh, I didn't know about GM.notification. This may be a very valuable piece of the puzzle.
Program A is indeed a website. My ideal solution would work for any kind of window, but if there's a solution that only works on websites, it's still a big win
19:03
Dec 24 at 16:49, by taylor.2317
hey, would someone please judge my code, if that's allowed and you're okay with doing so...
 
1 hour later…
20:04
@taylor.2317 Have you posted your code already?
20:23
@Aran-Fey Please tell me someone understood this, I spent half an hour on that. (Hint: pythons are constricting snakes)
As a previous owner of 3 constrictors, I can confirm that they do not have arms to hug with
Tarantulas, on the other hand, have plenty. Hugs all round.
Do spiders have arms? I thought they were legs
What's the difference between the two anyway? When a leg reaches level 5 in Grabbing Proficiency, it gains the "arm" prestige class?
They are legs, but I don't suppose it matters. They can hug your face
Precisely
My sisters (4 and 2) recently got guinea pigs and called one of them George. I went and found a picture of my first pet, also called George, which was a Chilean Rose
I also had Georgina, a Goliath Bird Eater, but she wasn't for hugging
That's one heck of a choice for a first pet
I blame Blue Peter, a long-running kids show
They had a Pink Toe tarantula on one of their episodes. So commenceth my menagerie
20:35
Can you, like, interact with a spider? Or do you just look at it from behind the glass?
With George you definitely could. It was never something you might consider to be affection, but it was interaction
The best pets I ever had for interaction (including the fact that I've have dogs and cats too) were rats. They're absolutely amazing pets and super smart
Ratty II used just just sit on my shoulder and watch TV with me
Isn't it a bit of a problem when your pets are too smart though?
@roganjosh Awww!
some bad joke about if search engines are down - you might at least be able to get your pets to "crawl the web"...
I think some people would recoil in horror, but I used to have Ratty running around on the bed while I was reading or something (they're actually really clean animals) and you only had to tap the mattress and he'd come running straight back. He was ace
If someone recoils in horror when they hear about your rats, don't tell them about your spiders :P
20:42
What about the Emperor Scorpions? Are they off-limits too?
(I hated them)
Just pure viciousness. And I could hear them every night clinking against the glass of the tank. They are not good pets
@roganjosh probably quite fancied the look of your rats :)
I think I've said before - once you get one or two exotic pets, you somehow end up being the dumping ground for everyone else's mistakes because word spreads. So I've had most exotic pets you could think of, whether I wanted them or not
I've just gone for humans... works nicely... get taken for walkies and fed and a free house... :p
Ha. Have you learned how to train the humans?
Ew, humans. I can't stand them, they're so obnoxiously loud
20:49
I think I've done a recently okay job... sleep on their furniture now and then without too many objections and they clear up my poop... so I think their training is not going too badly
@Aran-Fey no, do u want me to send it now?
Yeah, sure
I've just realised that Ratty II's bite mark has faded from my thumb :'( The only reason he bit me was because I had a plaster on and he bit through that. So, I still have the stupid "smiley face" from someone burning me with a lighter when I was 18, but I've lost the mark of Ratty II :'(
:53725983
That's way too much code to post here, upload that on pastebin or something
@taylor.2317 please see our room rules. Please post off-site and link back here
sorry, will do
Anyway... I'm going to watch the end of "Death to 2021" - the Charlie Brooker thingy on Netflix - have you seen that yet @roganjosh - quite amusing.... then get some snooze - got work tomorrow it seems... sighs
Charlie Brooker has new stuff?!
20:58
@Aran-Fey here
Ok, well that's my evening sorted. He gave up with <year> Wipe so I thought he was done with his reviews. Thanks for letting me know!
Gosh, that's got me quite excited. I do hope Doug Stanhope makes an appearance. He came to Manchester a couple of years back but I missed him :/
@roganjosh Think netflix.com/watch/81478916 should be a direct link? Not sure though...
Yep yep, got it, thanks :)
Ha, I can already see Philomena Kunk
Heh yeah... have to admit to being quite a fan of Diane Morgan... haven't been overly convinced on "Mandy" which is on iPlayer but it was mostly good fun
21:06
bbl
@taylor.2317
1. `if singer == "Harry Styles" or "Harry":` has a bug, it will always return True
2. You need to reduce the indentation. You have what, 8 levels of indentation in there? That's way too much.
3. You need to use more functions. Right now your code is an enormous 200 line long list of instructions. That's not good for readability. Code should be organized into small chunks.
4. You have lots and lots of duplicate code. You always do the same thing: Ask a question, take input, check if the input matches the correct answer, update the score. This is a prime example for code that sho
(see full text)
@Aran-Fey ok, thanks
"What is Harry's blood type?'" my goodness
@roganjosh B+ haha
I don't even know my own. Fandom is somewhat scary
21:16
@roganjosh I don;t know mine lol
I did used to know my blood type but now I can't be sure. I know that I can't be pumped full of that O stuff, so my bus factor gets extra tricky... but I probably should know this
I'm O-... O is definitely the most popular though in general though (O+ specifically) - I think you'd remember if you were A/B...
You'd think doctors would have invented a way to quickly figure out your blood type when you're already bleeding everywhere by now, but no
@JonClements I am one of them. I'm definitely not O but I haven't had my blood done since I was like 10 years old
I just know my blood type is O- because it's the "universal donor" type
21:26
I like your description of O being "the most popular". So mainstream, Jon
not the most popular... it's just the one that if you don't know what type someone is - it's safe to give everyone it
I know what you meant, I just liked the label :D
ahh okie dokies...
Avv
Avv
21:56
Hello guys
Hello :)
22:44
@Aran-Fey yh lol
@JonClements yup
23:09
@Aran-Fey they have
23:47
I went poking in github and found stuff I definitely wish I hadn't. The worst part of the xmas break is that I now need to contain this for over a week and still be a reasonable person on the other side :/ Probably time for sum Brooker/Cunk
Alcohol can help with that.
I've already been self-medicating. It's not enough :'(
Jan 4th is set to be a bonanza, though. I have my new role and it's probably going to hit like a train for the rest of the team

« first day (4090 days earlier)      last day (1083 days later) »