« first day (3435 days earlier)      last day (1738 days later) » 
00:00 - 14:0014:00 - 00:00

14:00
who is your target audience?
You can use multi-line string literals as 'real' block comments, but AFAIK they're really discouraged.
@Peilonrayz see Kevin's use case: injected in the middle of a statement
The situation that prompted me to ask this is this question, where I seek to avoid being well-actuallied by future commenters
unsurprisingly the source is an XY problem
@AndrasDeak Where'd Kevin specify the usecase?
14:03
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
7 mins ago, by Kevin
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"
Or I simply navigate to line (beginning of list literal + N) in my IDE
Ah, I didn't notice that
"Python cannot have comments inside an expression" would at least be technically correct
which should protect you from evil internet lawyers.
Not true:
x = (1 + # use 1-based offsets
     zero_based_index)
14:05
comedy option: ("this is the comment" if False else actual_code_goes_here)
Hmm, much to my surprise I see that the bytecode assembler does not optimize x if False else y into just x
Wow... anyone fancy a rabbit hole ?
@PaulMcG I have to consult the grammar rules, but IMO the comment is technically not part of the expression. It is just part of the line.
@Kevin YAGNI I guess
class BlockComment:
    def __init__(self, *args, **kwargs): pass
    def __add__(self, other): return other
Gotta maintain backwards compatibility to previous versions of Python where you could reassign the boolean literals ;-)
14:09
@Kevin If anything I would want it to optimize to just y
@PaulMcG alright, who am I kidding? you win this time, good internet lawyer!
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.
If the user does False = True, you gotta be ready
@PaulMcG Good idea. I'm putting you on the optimization committee.
@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!"
14:15
if x > 0:
    pass
elif True:
    pass
else:
    pass
@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)
As long as you don't go to the extreme like ^^^ because you might need them later so might as well just put 'em there for now :)
The ol' "You Are (maybe) Going to Need It" principle
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)
I can imagine a programming language with mandatory else after every if, since it makes the parser logic slightly easier
It's one possible solution to the Dangling Else Problem
14:37
done
:48841657 don't delete done requests, they're good for accountability
if there were noisy we could move them elsewhere
OK sorry. Just thought it would clear up chat a bit better
timezones are a headache in a global app man. casual bugs...
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
Is time delay while being transmitted something to be worried about, when doing that? @shad0w_wa1k3r
14:41
What's the answer to that question? "Use the direct url to the file instead"?
@Aran-Fey Yes, or possibly "use git to get stuff from git repositories"
@Simon not in my case at the very least because server execution (& thus only server time) is what determines if request goes through or not.
@Kevin hammered
Case closed, probably
14:50
@shad0w_wa1k3r Ah, that's very fortunate. :3
I saw a post trying to account for server time, within milliseconds, and it looked horrible.
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?
15:05
SELinux?
Ubuntu
15:26
@shad0w_wa1k3r. Sounds easier tbh. All you need is one user, with automatic time off, and the year set to 2096,for everything to break
cbg all
Cabbagerinno
To whom it may concern (and can do something about it): does not have automagic syntax highlighting for Python, so code in questions with only that tag doesn't look pretty. Can u fix, pls?
[seen at 11:33 AM]
@MattDMo no. But no questions should have only that tag.
15:39
bug reports like that should be posted on Meta-SO, nothing anyone of us here can do about that. We aren't SO staff
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
@Aran-Fey Moderators can change the value
@Peilonrayz uh, no
can they?
not sure what "value" you're referring to
Yeah, the syntax highlighting one
15:43
meta link please
I don't really have a link, but I reported it and a mod on CR changed it, and can verify the value. They said in comments so it a bit hard to link to
ah
that's unexpected, but great I guess
I maintain my stance that if a question is missing syntax highlighting it's an awesome symptom that it needs to be retagged
@Peilonrayz are you certain it was a mod and not staff?
@AndrasDeak 99.99%
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
15:45
@Kevin smoking gun, thanks
it's not like SE to expose something like that to mods
This also tells us that Meta is an effective* channel for getting highlighting added
(*i.e. more than 0% effectiveness)
anything that mods can do has effective channels via flags or meta
Closed
15:50
@AndrasDeak I agree with this tho, we don't have syntax highlighting on python-3.x because of this.
meta.stackoverflow.com/questions/370187/… indicates that pleas to add highlighting to older versions of Python has been successful
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.)
Perhaps I'll write up a Meta post, while I'm here
@PaulMcG using ExitStack, I presume? ;)
0
Q: Python syntax highlighting for questions tagged [python-3.8]

KevinPython 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.

16:02
wait, if Py3.8 is out for seven months, when will Py3.9 hit us?
Oops, October wasn't seven months ago... Silly of me to assume that oct == 8
@MisterMiyagi The 3.7 era was 16 months long, so... Feb 2021?
Exercise: trawl through the Python "what's new in..." docs and/or the aggregated history to determine the lifespan of each release
@Kevin aw man… considering that we're still on Py3.6 here, that's, what, 2025 to full adoption?
I'll be busy kicking youngsters of my lawn by then!
@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.
I fully expect some users to stick with 2.7 for the rest of linear time, so full adoption is only a pleasant dream
well, there's tauthon for the poor souls that can't let go
16:13
It's like asking "when will the spaceship cross the black hole's event horizon?". Nature conspires to prevent such a thing from ever happening
which, surprisingly enough, does not overlap with my peer group this time
Another common element of space travel and programming: spaghettification
apparently, talking about black holes in French is harmful to minors
@PaulMcG that's refreshingly unsophisticated.
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 wouldn't mind with *cms as names being a thing, where cms is lazily iterated and each element entered.
* unpacking is a special case for calls, after all, why not let it do The Correct Thing for with statements as well?
speaking about context managers: Is there a reason why __exit__ receives exc_typ, exc_val, tb instead of just exc_val? Seems redundant.
16:40
@MattDMo Your activism has paid off -- 3.8 questions are now auto-highlighted
Why default install dir for python windows in buried deep in users/../appdata/programs
Isn't it better to be C:/Python38?
@Zeta.Investigator You did a user rather than a global install
I put mine in C:/programming/Python38
No by default it suggests that
@Kevin There shouldn't be space in it right?
What do you think about using Chocolatey to install it?
16:49
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
3
@Zeta.Investigator Depends, do you want every user on your computer to be able to use it?
None of my programming-related work ever goes in "c:/program files" if I can help it
I have mine in "C:\Program Files\Python\x.y.z\" and it works fine.
@Peilonrayz Yeah but actually I'm setting up a new system and I want to stick to standards as close as possible
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
16:55
Hello
Is there a reason why many of python functions are global? For example:
Greetings
len("string") instead of "string".len() or just "string".len or just "string".length
Guido probably thought that was nicer
I have a strong feeling of deja vu so I suspect we've discussed this exact topic in the past. Can't find anything relevant in the search menu, though.
1 demerit to search for taking my query, ".len", and returning results that contain "len" with no preceding dot
it's not like SO users might be talking about code
16:59
"We" as in this room or "We" as in me and others in this room?
probably both
@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))
hmm i don't recall, i aplogize if i asked before
"We" as in me and at least one other person
@MisterMiyagi interesting
17:03
len also has the advantage of being easier to use with higher-order functions (like sort(key=len))
ah
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
also is there a reason why my ide always yells at me for captial letters in my varible names? is that discouraged or something?
yes, we prefer snake_case except for classes
consult python.org/dev/peps/pep-0008 for variable naming conventions. TLDR: yes, caps are discouraged in regular variables.
17:12
python so strict/opinionated
every language has a style guide
not JSy enough I guess ;)
But see also python.org/dev/peps/pep-0008/… which essentially says "ignore these rules if you think you know better"
but it's usually the opposite of "strict"
they should've qualified that with "and you're not a beginner"
I thought I knew better for a long time
17:14
Why version 3.7 is shown higher than 3.8? What is the latest stable release?
@Aran-Fey "unless you're Aran-Fey"
I continue to write lines of code with more than 80 characters >:-)
@Zeta.Investigator check the release dates
@Kevin Remember that some PEPs are from more civilised times.
17:15
it's listed under "stable releases" so...it's stable
both 3.7 and 3.8 are getting micro version updates
It's confusing...Should I stay away from 3.8?
ok thanks for the help, be back soon. Still in the Google everything phase of learning this lang
@Zeta.Investigator no, both 3.7 and 3.8 have supported stable releases.
still liking js better tho
adios o/
I've been using 3.8.0 for fiveish months and haven't had any problems
17:17
see you later
Guys, I noticed a flaw in the room rules. Saying "I like JS better than python" isn't a bannable offense for some reason
7
I liked JS enough to put half of its DNA into KevinScript
I must be influencing room policy with my JS-sympathy
@Aran-Fey isn't liking JS already enough of a punishment in itself?
hmm, good point
functions-as-expressions are cool and => is more concise than lambda
17:24
isn't lambda technically functions as expressions?
Revision: (functions-containing-statements)-as-expressions are cool
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.
What exactly are these blocks you're referring to? A quick google search didn't come up with anything useful
Pure expressions can be very good and useful, but I think this town is big enough for both pure and impure languages
@Aran-Fey imagine : not being some syntactic quirk of for, while and other statements, but an actual declaration.
17:30
Related reading: en.wikipedia.org/wiki/…
it basically means you can declare a block of statements at arbitrary points and pass it around.
for example, you could implement your own with statement with them
 # note: no with or other statement
 open("/danger", "w") do f
     println(f, "Hello")
 end
NB: it took way too long to find even a basic example for this. :/
I'll keep that in mind for KevinScript 2
17:46
jeez...why is there a python alias in win10?
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.
@Kevin do any programmers still use windows?
I do, so yes
what do you use for terminal?
cmd
17:52
but cmd doesn't have all the commands
@Manik cmder + msys64
msys2 provides pacman
The only command I need is python.exe
@Manik cmder provides ls, cat, git, less, vim, even ssh...you can install your desired packages with pacman
kevin using os module?
Sure, sometimes
17:56
@Zeta.Investigator i'm not going back to windows ever ubuntu or macOS for me
so what are we even talking about?
cmd, by definition, has all the commands
does it have chmod, sudo and stuff?
it has all the commands that it has
Unsurprisingly it doesn't have all the commands that a bash shell does. But bash doesn't have all the commands that cmd does, I'm sure.
arguing against cmd in a way that suggests shallow understanding and adding "you're not going back" ruffles my feathers
Windows has a rather different security model than Linux so it wouldn't make much sense for it to have chmod or sudo
I do wish there was an exact equivalent of cat, sometimes. type and >> get me 95% of the way there, but it's not always straightforward
18:13
linux is best for programmers i think it gives you freedom to do anything but i'm a newbie so i might be wrong
@Manik okay, thank you for your valued input
user image
5
<eyes @JonClements suspiciously>
@roganjosh :D
Gonna keep an eye on the room rules just in case :P
New policy: if I suspect someone is touching their face, I'll kick them
"Take this opportunity to reflect and also wash your hands"
18:18
"Reach out and touch ... face"
...is how I used to mishear that song by Depeche Mode for the longest time.
Relatable
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
@IljaEverilä Ha! That made me LoL
@roganjosh REVENGE AT LAST HUMANS! :p
... it's as I feared!
18:23
@roganjosh I'm semi reminded of the end scene of Lucky Number Slevin :)
Is that in the barn? It's been so long since I've seen it, not sure I'm even thinking of the right film :S
it's about that kid and stuff
it has horses I think
Ah yes, it's all coming back to me now :P (I don't know whether Celine sang about face touching)
Bloomin' good film - might have to watch it again at some point
and quite a funky main theme
18:44
what's up?
Cbg Aaron
@AaronHall 'ello 'ello
I'm working with mypy, what an interesting project...
19:01
It's being added to an open source python package for working with Nix.
Ahh... Nix is your new fascination at the mo' isn't it? Think I've seen you tweet a few times 'bout it
Yes indeed. I'm streaming as I work, first time, not sure if it's working right though...
19:18
demonstrate recursion by watching your own stream on stream
cbg guys! How has been your day?
@AaronHall How is your turorial coming ?
My telecommuting schedule has been doubled from once per week to twice per week. I am now 33% more impervious to viruses.
Apparently it's essential that I come into the office on Tuesdays and Thursdays, because I need to be present during the biweekly conference call
makes sense
19:31
Ahh... conference calls that only work in offices... if only we could work out a way that conference calls can be across many locations at once...
A conference call I had ~3 years ago with 103 other people must have been a dream :)
I presume you all just stood in a queue according to local custom
To be fair... it was slightly chaotic as who got to share screen and take the microphone...
I can imagine. Imagine interviewing 103 worms in a can...
Or maybe for those really pesky humans, I can instead pour that can into their head cones :) muhahahaha muhahahhahaah muhahahahha
20:07
@superv not too bad; no fire-fighting :) yours?
@roganjosh Good, Thanks for asking. Watching a tutorial on Django REST API. How is the UK wather today?
@JonClements if you're gonna subject us to this misery, at least make it useful. Can we have it as a receiver dish for unlimited interwebs?
@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
hahaha, how does that even happen?
20:14
"20% discount. Today". I got flustered!
@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
@superv well, it's not torrential and only conveniently started when I finished work
For what it's worth, I have enough different seeds to dramatically expand the Salad vocab :P
Fair enough. Are you the one in charge of adding the vocab?
ah, the ol' "limited time offer" trap
@roganjosh you need to go to some ninja training programme. Iron up your will or something.
20:18
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!
resistance is futile
is there a way to ignore users on SO? one of the language-meta-question people is really pedantic, but I haven't found a button to turn them off.
@MisterMiyagi on main? Only in wetware.
@roganjosh can't tell if serious...
Photo evidence when I get home. This is real
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
20:27
@Aran-Fey Why do you do that? Just curious?
I wrote it for someone else, actually
I don't visit SO at all anymore, so I have no use for it :P
@Aran-Fey It was answer comments. They kept deleting and reposting basically the same thing with minor adjustments over and over.
@Aran-Fey Okay.
I'd consider the wetware option, but my trained killer rabbits aren't trained yet, nor willing to kill either.
@MisterMiyagi just wait 20 minutes before dismissing the notification
20:31
@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.
@roganjosh muhahhahahahaha muhahahahaahhah muhahahahahaha
Can't wait to see if Nish Kumar wins tomorrow on Osman's House of Games
breaking off for today - rbrb
@AndrasDeak I won't lie, your distant serenity is inspiring.
same here, rbrb all
rbrb, guys
20:34
Oh, rbrb you guys
@JonClements look what your laughter has done!
/me grins... Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn...
I knew it. Captain Crunch will send you back from whence you came!
(Oh, Mintberry Crunch). I've not watched South Park for too long :/
Wow - interesting answer - return print... ummm
20:51
def max, max = and a builtin. Some impressive stuff going on
21:20
Anyone fancy trying to explain the many things wrong with this attempt?:p
even the comment is wrong. lol
Well... I think I know what they're trying to say...
but they're not saying that
that's not the answer, Miyagi
that ^ with python
ooh, puppy has a 3.x hammer, nice
added the real dupe target ;)
if you replace x with the index in .pop(x) it starts working
not sure how accidental that is, though...and I don't feel like thinking about it
also thanks for the retag
21:25
twitchy trigger finger. :/ I think you can remove the initial dupe target.
Well, it's good for OP to read. It only works by accident (removing and replacing to the front)
I suspect if they appended instead, or just popped, it would be buggy
It's a shame they can't just use .sort(key=lambda n: n % 2)...
22:03
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
Fingers crossed :) Tell them about your plantation project.
have you set your profile such that anyone can contact you, then?
22:18
@roganjosh ahh well... I've sent you a connect... I'll happily oblige you with junk :)
@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()
I think britbox has a slight issue with categorisation...
@X4748-IR MCVE about it not working, please
>>> chr(ord('\n')) == '\n'
True
22:29
@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.
@AndrasDeak I think so. Originally I thought it was hidden and still got messages, so I'm not sure I understand the visibility rules :P
@AndrasDeak I don't know why I'm not getting the line breaks...
@X4748-IR hence my request for an MCVE
@JonClements added on the proviso that there's no head-cone stuff :)
@X4748-IR please don't add code and text as images
22:31
@roganjosh lol... congratulations - you are now one of the elite! :)
and there's no code there...
Jul 18 '19 at 17:42, by Andras Deak
27 mins ago, by Kevin
@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.
Coronavirus does wonders for networking, oddly. I'm having conversations about glucuronides in the pub. Suddenly people want to know science.
@AndrasDeak I'm sorry. What do you mean by MCVE?
@AndrasDeak Ok..!
@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!
@X4748-IR better, but there's no input to make it C for Complete
Create a file. It takes a file path as the input.

Change:
file_path = 'file_to_encrypt'
I have lots of files
@X4748-IR And which part is where you're saying that it doesn't work...?
@AndrasDeak Did you run the code? When I use chr, It doesn't get line breaks.
No, not yet. I'm trying to home in on the needle in your haystack.
22:42
I have a file like this:

Hello World

Foo

Bar

I store ord of each character in another file. When I read that file and I try to use chr it returns:

Hello World૦ooزar
OK, let me see
@X4748-IR OK, I can reproduce that. We're getting somewhere.
@X4748-IR look at your .cry file and tell me if you see anything weird
(using your hello world example)
@AndrasDeak Hmmm, You mean the fact that I've encrypted data?
I mean your encrypted data is wrong, and it's fairly easy to notice if you look at the encrypted file
22:52
I forgot to say, these are public and private keys:

keys = ((1591, 3233), (151, 3233))
@AndrasDeak Hmmmm...
Can you see something that's off?
I got it I think....
It's less than the original file's characters I think
yup, also some of the characters are weird
1512 2771 708 708 1161 1712 657 1161 1614 708 2620 151015101210 1161 1161 15101510606 2167 1614 15101510
here's how it should look like:
1512 2771 708 708 1161 1712 657 1161 1614 708 2620 1510 1510 1210 1161 1161 1510 1510 606 2167 1614 1510 1510
Why it happens... hmm... I have to try without encrypting once.
@AndrasDeak +1
for each line in the input file you write a space-separated list of numbers, but you're not putting separators between these lists
22:59
@AndrasDeak Exactly... thanks
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
Thanks again. It's fixed.
This is just the beginning. Feature versions will be changed ;)
@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.
@AndrasDeak +1 Right
00:00 - 14:0014:00 - 00:00

« first day (3435 days earlier)      last day (1738 days later) »