Yeah. Usually when my code crashes as it processes element N of a list, I simply put a print(element[N]) statement around the problematic area. No exhaustive commenting required
Terminology poll. In JS, 2 + /*whatever*/ 2 is legal syntax. Python has no direct equivalent of this kind of comment. Fill in the blank: "Python does not have ___ comments"
I once needed a single addition to a series of processing inputs in a loop in a throwaway script. I ended up adding an if True: block the preserve the indentation for clarity :) But it felt dirty.
@AndrasDeak I've sometimes for testing done: for item in islice(some_iterable, 10) and then instead of removing the islice in case I want to twiddle/test again later, just changed 10 to None...
I do if True: every once in a while when I'm debugging. "Can't be bothered to craft input that will trigger this code path, so I'll just make it always trigger!"
@JonClements well yeah, but I didn't have anything like that. It was for loop in similar_inputs: do first_thing(); do_other_but_logically_similar_thing(one_other_input)
I remember one bloke I worked with swore to having an else block even if a do-nothing for every if because it "matched" up and meant he didn't have to add else later
umm... might need to put new batteries in the keyboard... (or do the old take em out - shake 'em and put 'em back in)
If we have a dupe target for "how do I scrape raw files from github? saving the contents of whatever/blob/master/whatever just gives me HTML", then stackoverflow.com/questions/60656268/… could use it
Not sure if that's the right thing to do anyway. Always trust / use server time. Implement client side time stuff only if you know what you're doing (probably not required in 99% of the cases)
I am trying to work my way through issues with os.seteuid for automated testing of file system access as performed from different uid/gid's. For some reason, running as root, I am getting a permission error when calling os.seteuid. Any ideas?
To whom it may concern (and can do something about it): python-3.8 does not have automagic syntax highlighting for Python, so code in questions with only that tag doesn't look pretty. Can u fix, pls?
One might hope that a present or past moderator would be able to pull some official or unofficial strings, but I don't think it's within their usual powers
And anyway they're probably busy putting out fires or roasting marshmallows respectively
Searching through meta for "syntax highlighting", I see meta.stackoverflow.com/questions/361897/…, where Martijn claims responsibility for adding lang-matlab highlighting to the "octave" tag
Fixed. Must call seteuid before calling setegid. If done using using_uid and using_gid context managers, then must be in using_gid, using_uid order. (Have since replaced all code using the two contextmanagers with a single contextmanager that internally does them in the right order.)
Python 3.8 has been out for about seven months now.
Can someone make the python-3.8 tag trigger Python syntax highlighting?
Note: similar requests for the python-3.4 tag, the python-3.5 tag, and the python 3.7 tag were successful.
@MisterMiyagi Nothing so complicated, just with using_gid(gid), using_uid(uid): yield. The contextmanagers themselves don't need to be yielded, as they are not referenced in the body of the contextmanager.
What would really be nice, is if with was extended to accept a tuple of ctxmgr [as varname] and then auto-construct the ExitStack as described in MartijnPeters' answer
I suspect that Python itself and the things that depend on it are usually smart enough to parse paths with spaces in them, but I'm paranoid enough to not leave it to chance
And anyway my program files directory is a dumping ground for a half decades worth of programs I installed and used once. Having a dedicated programming directory makes it easier to navigate manually
@JBis 1) doesn't block a len/length attribute/method. 2) is used by bool as well. 3) doesn't imply that length can be set 4) is in line with prefix operators ("length of x" -> len(x))
I'm not mad that we may be repeating a conversation, or anything. Half of our conversations are reruns. I'm just saying that, if you're really eager for ideas, there might be some buried in the transcript somewhere
unless you go the all-out route of SmallTalk and Ruby of having blocks, you are sitting at the kids' table.
@Kevin I realise this isn't exactly a widely held notion... but I kinda like the idea of expressions not having effects. Not without paying your toll in sweat and tears, at least.
For a long time, I have "implement a SmallTalk VM" on my ToyDo list. However, I'm still stuck at "implement a typed lambda calculus compiler", which got stuck at being bored by academic drivel.
HR today tried to make some form of policy if they think people are sick but it was nonsensical and basically would result in people being cast out of the factory in overalls with no keys for their car or home. Over lunch we came up with one more practical; shrink wrap them on a pallet and truck them out
@superv "rain". It's a safe bet to just say that. "How's the rain today?" Is probably a better phrase these days :P
I've never know it rain every single day for like 2 months now
I wouldn't be so bothered had I not got lost in a garden centre and bought £200 worth of stuff by accident... and can't really do anything with all the stuff I bought
@roganjosh omg! That must be horrible. Here we have a minute of sunshine, the next it start raining and other days are just plain grey :) How is the rain today? lol
No. That was... Jon's work. Oh crap, we're screwed. RO and inventor of the language we speak. He's played a long game but the Age of Pups is upon us! I'll diminish and head West
@AndrasDeak I've dug the trenches for carrots now and a 3m poly-tunnel for my lettuce. I have a 5-shelf mini greenhouse and a propagator... and my seedlings sprouted yesterday. It's way too late in the day to turn back now!
I wrote a userscript that hides questions from low-rep users, which could maybe be adapted to suit your needs. But it doesn't hide comments and answers, so not sure if that's very useful
@Aran-Fey I'm toying with that thought. All interesting questions lately have turned out to be carefully engineered honey traps to lure in over-motivated victims.
Hmmm. 2 days on LinkedIn with an updated profile and I've been contacted by an engineering company that I desperately wanted to work with when I graduated in engineering (it's an engineering company). No idea if anything will come of it, but it's not been the pile of garbage recruiters that I thought it might be
@superv I've just been sending pull requests so far. my live channel is at twitch.tv/aaronchall - if you want to participate, chat me your questions and let me know if the audio and video is ok... it's easier to describe what I'm doing when I have someone I know I'm describing it to.
How can I convert an integer Unicode value to a character? I've used char, but it doesn't work for line breaks. To be clear: I want to get the input value of ord()
@wim probably it uses calloc to allocate zeroed memory, which is mapped using mmap and the kernel cleverly then gives the same zero page mapped all over, and you pay a hefty price in paging interrupts when you start writing to it.
@X4748-IR At the risk of sounding like a broken record, an MCVE would be great
@X4748-IR with your previous history of confusing problems and lacking MCVEs I must ask you as a room owner to come back with this problem when you are willing to provide the information we ask for in order to help you. I will not waste our time here.
@roganjosh Ahhh... hope you've got a mate that after a few too many thinks he knows everything and will start disagreeing with you just because he can... otherwise - it's no fun!
so you need to print an additional space after each line during encryption
minor style note: you should consider using a context manager for opening your files so you don't have to .close() them yourself, which would also behave well in case an exception is raised
@X4748-IR OK, no problem. Now you might see how important an MCVE is. I should be able to see what you're seeing, which makes it possible for me to examine each individual part to see where the issue might be. General statements such as "chr doesn't work right" might be way off the mark if you misdiagnose the problem in a larger piece of code.