« first day (4942 days earlier)   

12:10 AM
@user10478 Ok, can you post the link? or a snippet of your code? I'm curious
Update: the shortest syntax for log2 is: sympy.log(x, 2).evalf()
 
12:40 AM
HI, how to read all items in listbox as a text file and display evry file contents into different sheets in excel using python tkinter
 
I would start by thinking about the logical steps involved in solving that problem, and deciding the specific requirements for each.
 
Someone help me abut this, im new to python tkinter, need to automate few things so looking for your kind help on the same
 
If you are new then you cannot expect to be able to do everything that you can think of doing. As a programmer it is necessary to learn fundamental problem solving skills first.
Please also read the room rules; we do not want links for recently asked questions.
 
Yes i have coded half of my program, and looking for a small help. you can chk that out from my post
 
It is not possible to "help you" on Stack Overflow because it is not a discussion forum. To get an answer you are required to ask a question that meets the site's standards, as described in How to Ask and on the site tour. I also advise you to read: Advice for non-native English speakers
 
1:16 AM
There is no MRE in this question: stackoverflow.com/questions/66629641/…. Can someone close it, please?
 
1:53 AM
@smci Yeah, this page (carpentries-incubator.github.io/python-text-analysis/…) actually has the same info and more. Here's the code I've actually run (hastebin.com/share/ocawodiyod.python). Notice that because female - woman is about the same as male - man, the first expression outputs only 2.8631563, while the second expression doesn't roughly cancel in this way and outputs 10.555002. Then most_similar() returns nearby words.
 
 
3 hours later…
5:22 AM
@Marco this is such a common issue with machine learning questions on the site. Often it's not possible to make an MRE for such complicated cases because it'd end up being hundreds of lines long. However it does seem that they detailed the API usage enough that someone might be able to check it against their own implementations to see whether it reports different values
I feel like there's a canonical on meta about why data science questions just don't work on SO somewhere but I've not had my morning cup of tea yet so I'll hunt it down shortly :)
 
5:40 AM
Huh, now I have started drinking my tea I see that it's really old and only has a "same here!" answer. Indeed it should be closed
 
6:24 AM
@Marco That's a new rep-25 user. First tell them what an MCVE is and that they need to add it (more "welcoming"), instead of just closing it without warning. I added a comment saying that.
@roganjosh Well anything where a full MCVE would need 20-1000 lines can be painful to generate MCVE for. Esp. in this case they're only asking about why the logging syntax seems to mismatch, not the model, parameters, accuracy etc. itself.
@roganjosh The power of tea ☕️. Douglas Adams would have approved.
 
 
6 hours later…
12:26 PM
any good intro to arrays in python?
i don't get this syntax:
listt = [1,2,3,4]
listt[2] = [8]
listt[2:2] = [7,7]
 
start by not calling them arrays but lists
 
i get that the second is inserting elements only, not the array itself, but doesn't seem intuitive ?
says array methods' in the docs
what do you mean @ThiefMaster?
 
but [...] creates a list. not an array from that particular module
 
are list and arrays different things in python ?
they seem the same in the docs
 
they are different things. the module from your link is something you'll almost never use
and you'll have an easier time understanding your code snipped from above if you look at the list after every step:
>>> listt = [1,2,3,4]
>>> listt
[1, 2, 3, 4]
>>> listt[2] = [8]
>>> listt
[1, 2, [8], 4]
>>> listt[2:2]
[]
>>> listt[2:2] = [7,7]
>>> listt
[1, 2, 7, 7, [8], 4]
foo[2] = ... assigns to a single element, so you end up with a nested list
 
12:32 PM
that's what i expected at each step thoguh
 
foo[2:2] is a slice containing the 3rd element, so now you replace a slice with another list -> you replace the (single-element) list that contains the 3rd element, with a new list containing [7, 7]
 
my point is just that i don't get why a[2:2]=[1,2] inserts the elements 1,2
 
see my last message ;)
 
yes but you are adding a bit which isn't very clear
i think the problem is that a[2:2] means something else when on the left or the right of the equal sign
 
Depends on how you look at it. You can certainly argue that it means two different things, but then a also means two different things depending on which side of the equal sign it's on
 
12:45 PM
i see
can you expand? I'm new to python
 
a on the left side of the equal sign means "store the value here". On the right side it means "get this value"
Same thing for lists. On the left side a[2:2] means "store the values between 2 and 2" and on the right side it means "give me the values between 2 and 2"
 
indeed, that's why we didn't agree with the other commentator
however that doesn't explain why the array is unpacked @Aran-Fey
 
What's unpacked where?
 
destructured
 
I don't know which line of code you're talking about
 
12:48 PM
a[2:2] = [2,3]
a[2] = [2,3]
one vs the other
a[2] = [2,3] result it's expected to me, but not the output of the other
 
2 refers to an index, while 2:2 refers to a slice/range/whatchamacallit
a[2] = [2,3] means "store the value [2,3] at index 2 in a"
 
so ? i doubt that explains the result
you'd expect [2,3] being stored in a slice of a
not in the whole a
 
a[2:2] = [2,3] means "store the values 2 and 3 between indices 2 and 2 in a"
 
so it's not slicing anything
 
@MahNeh What does that mean? How is that "the whole a"?
 
12:52 PM
no item from the original a is missing
also, when there is a slice here is for which items to remove, not which items to keep
 
What did you expect to happen?
 
so in the right of the equal sign `a[2:4]` means to get item at position 2 and 3

on the left of the equal sign `a[2:4]`, means to remove elements 2 and 3 and put whats on the RHS of the equal sign at position 2.
is this a correct interpretation ?
(i'm testing it as well)
 
Yes
 
now i can say what I don't get
which is that i'd expect the full array in the RHS at position 2
 
Alternatively, 2:4 refers to the slice between indices 2 and 4. On the right side of the equal sign it means "give the values there", and on the left side it means "overwrite the values there"
 
12:56 PM
not the elements of it
 
So there would be no difference between a[2] and a[2:2]?
 
no, exactly
only if the index is different, say a[2:3]
imho that's more intuitive, but i guess that's just not how it is
 
Nope. If you use a colon, you refer to a slice of the list. 2:2 means an empty slice
 
yeah, that's not the problem anyways, but why the overwrite goes differently
 
It's better this way. You know for a fact that the operation some_list[x:y] will return a list, and not just a single item, no matter what the values of x and y are
I don't understand what difference you're seeing
 
1:01 PM
I think a[x:y] = [2,3] should place a list in position x, that's it
not the elements only
 
That's silly because the y is pointless then
 
it's not silly and certainly not pointless
you are removing elements from a
 
Oh, that's what you mean. Ok, I see
That would be reasonable, I guess. I don't see an argument against that kind of design
 
thanks for the discussion
are you learning python as well? @Aran-Fey
 
Yep. Still learning even after 10+ years! :P
 
1:09 PM
i see. i come from typescript, find it both simple and messy
i like it, but...takes effort
 
Simple and messy sounds good to me. You can't really ask for more than that, I'm afraid
 
TS is so much better though..
have you tried ?
types in python seems good though
 
Yeah. They both have their strengths and weaknesses
I almost started balding prematurely when I tried to achieve the equivalent of -> Self in TS once
And then I started balding prematurely anyways because of PyRight
 
I thought increased stress induces gray hair first? /s
 
Nah, you can get hair loss from stress way before it has time to turn grey
 
1:14 PM
I'm already too far gone :(
Left foot's already in the grave
 
do you mean -> this ?
 
I don't think that's valid either in python or in TS?
 
@roganjosh welp, already went from 3 up to 30 gray hair...I don't know if missing some hair is already sign of balding but I guess that's all for now
 
you can just use the name of the class
 
That's disturbingly similar to me. I've done well so far but this is the real crunch time to decide on whether or not I start dyeing it
 
1:18 PM
just change job
it turns back to colour
my last interview i asked the interviewer how much he sleeps
he refused to reply
 
@roganjosh Thought about that too, but didn't do it yet. I don't know why, just can't put my finger on it (yet)
 
There's only a snapshot window within which to make the decision! You leave it too late, it becomes obvious to everyone that you've started doing it and if you don't do it soon enough, you'll become the silver fox that was always waiting to burst forth from you :P
 
@MahNeh I would recommend you to check out: workplace.stackexchange.com Also, FYI, personal inquiries during an interview to whoever is interviewing you is obviously not a good idea (in general cases)
@roganjosh Haha, didn't think about it from that angle. Yeah, maybe it's a good time I start thinking about it hmm
 
@MahNeh people have different tolerances to stress and make wildly different decisions on what they are willing to do. During lockdown, I was doing 18 hour days, 6 days a week, purely so I didn't lose my mind. I was stressed as hell, but it'd be even worse to not do it when my mind would be left to itself.
 
i think people get trained to want to work too much
studies show all the bad things one can expect from working more than 40hrs a week
especially in the US
obviously part of it is due to neoliberalism
we could all live longer, have more meaningful lives, better mood, but uncle sam says no, not yet..
 
1:34 PM
This is unexpected. I thought you'd be pro-work, because more work means more Mah Neh
(I'm sorry, sometimes I just can't resist the puns)
 
Neh it's not read as Neeh
 
It reads as "money", albeit said with an accent I couldn't identify
 
it doesnt read as 'ney' mate
press the speaker
Can anyone recommend a nice python cheatsheet ? i'm searching but unsure
this is too basic imho datacamp.com/cheat-sheet/…
Isn't that cheatsheet wrong about mutating strings @Aran-Fey ? i think they aren't mutable ?
 
That already has numpy arrays in it, so it's already pretty "advanced". What are you looking for in the cheatsheet?
 
i think i search more for common errors of of a JS programmer going to TS
maybe that I should search
 
1:45 PM
@MahNeh Correct, they aren't mutable
 
ty @Aran-Fey
 
The big question is whether "mutate strings" means "strings are mutable in a programming sense". All of the methods do, indeed, mutate a given string even though they are immutable in themselves
 
I think "mutate strings" just means "don't use this cheatsheet".
3
 
If your standards are that high you might as well throw the whole internet in the garbage
 
is mister miyagi from dragon ball z @MisterMiyagi ?
 
1:53 PM
@Aran-Fey Okay. Running rm -rf /internet/* now...
 
do you mean from /www/internet XD
 
2:08 PM
/internet/www would be more logical since the www is a subset, not a superset
 
2:31 PM
@MahNeh These aren't cheat sheets, but they contain very useful info about Python's data model, which has some important differences to the data model you're familiar with in JavaScript / TypeScript.
Oct 17, 2019 at 8:44, by PM 2Ring
@djsmiley2k Have you seen and Facts and myths about Python names and values by Ned Batchelder? Also see Other languages have "variables", Python has "names" for a briefer version of the same stuff, with cute diagrams.
@Aran-Fey If you're doing stuff with light-years, please use the modern definition, which uses the Julian year of 365.25 days (of 86400 SI seconds). Google's Calculator uses an ancient pre-1984 alternative definition based on the tropical year.
Note that SI doesn't define any other time unit apart from the second. And even the second is a derived unit, defined as the inverse of 1 Hertz.
 
It is?
I thought kg s cd A K mol m are the basic units
 
Since the 2019 SI redefinition.
 
I'm too stupid to do the math, but I got 1ly = 9_460_730_472_580_800m from wikipedia
 
Unless I'm hallucinating. ;) Let me check...
 
2:45 PM
What next, redefine the kilogram?! :P
 
puts up an "I believe in cgs" poster
 
From physics.stackexchange.com/q/147433/123208 (this might be messy, due to MathJax)
Oh. It's a mess. I'll try again.
> That is, the second is actually implemented as a frequency standard: we use the resonance frequency of a stream of caesium atoms to calibrate microwave oscillators, and then to measure time we use electronics to count cycles at that frequency.
 
> The second will remain unchanged in its essence, but it is likely that the specific reference transition will get changed from the microwave to the optical domain.
definition changes but it stays basic unit
Phew!
 
@Aran-Fey That value is correct.
 
How the units are defined doesn't really matter to me. I have to define them in such a way that common calculations don't lead to type errors. For example, getting an error from electric_charge: Mul[Duration, ElectricCurrent] = amperes(5) * seconds(2) would be really annoying
 
2:57 PM
@AndrasDeak--СлаваУкраїні Yeah. We have much higher frequency (optical) atomic clocks now, that are several orders of magnitude better than caesium. But those clocks are still cutting-edge technology. I have an answer about that: physics.stackexchange.com/a/770976/123208
@Aran-Fey Understood. The Google Calculator is very impressive in its ability to handle a vast number of units in its calculations. It also has a bunch of built-in constants. So it's annoying that it screws up light-years, when it's otherwise excellent (AFAIK).
You can even do stuff like (mass of proton) * c^2 in electron-volts
 
Google Calculator?
This?
 
Yes, but you can just type a calculation into the Google search bar
 
Right
 
If it doesn't understand that you're doing a calculation, try wrapping it in parentheses.
 
@PM2Ring ^^ this?
hmmm
Got it
@roganjosh This is a relatively simple case of placing an MRE.
Thank you for helping to close the question! This was very useful for me because I will soon ask a question about the subject with MRE, and closing this other question avoids the possibility of my question being considered a duplicate.
@smci Ok, sorry, I forgot about that friendly request, thanks!
 
3:20 PM
@Marco Well, that OP hasn't been seen since 2021, so they're unlikely to add an MRE now. ;)
 
@PM2Ring yeah, probably! :P
@roganjosh This case is definitely not a complicated case, I can assure you.
@roganjosh "However it does seem that they detailed the API usage enough that someone might be able to check it against their own implementations to see whether it reports different values": but it's still not an MRE :(
@roganjosh I don't believe there is any impediment to posting questions about machine learning on SO, but there are certain rules for this, I believe that it basically needs to have MRE and that it includes a code.
 
3:45 PM
@Marco The problem is that the MRE needs to include both a piece of runnable code, and some suitable test data, and expected output. But ML usually needs a large amount of data, and it's not practical to paste that into the question. But it may be possible to include code that can generate some test data. Another option is to link to a repo of standard data, but such links may rot.
 
@PM2Ring Of course, there are cases where it is necessary to use specific data to reproduce, but I believe these are more specific cases.
And this definitely is not the case with the aforementioned question.
 
Yes, it's certainly trickier if specific data is required. But IMHO, such cases aren't very suitable for SO. But if the problem can be reproduced with generic data, then the question is more useful.
A question that relies on specific data is probably too localised. We want questions that are likely to be helpful to future readers with a similar problem. Problems that arise due to some quirk in the data generally don't fall into that category.
 
4:00 PM
Yes
Fair
 
 
3 hours later…
6:31 PM
Hello python chat, I need your help.

I am working on a discord bot and I recently realized that the moderation commands I added to it don't work without the bot having administrator, so I changed the oauth link on the website it is on and added a command to announce to every server it is in to kick and reinvite the bot. However, I keep getting this error:

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 124, in wrapped
I realized that the bot code stops working because one or more servers the bot is in does not have perms to send a message. How would I ignore those servers and ping the servers that I DO have perms in?
 
try: ... except?
 
#announce command
@bot.slash_command(name="announce", description="ping everyone in a server and send a message", guild_id=["1119428346485407744"])
async def announce(ctx, message):
    try:
        for guild in bot.guilds:
            await guild.text_channels[0].send(f"@everyone {message}")
        print(f"Successfully announced: {message}")
    except discord.errors.Forbidden as e:
        print(f"Bot ran into error while running announce command: {e}")
        pass
trying this code does not work, is there another way to do it?
 
That still interrupts the entire command. You want to skip that particular guild, not all of them
 
How could I do that then?
 
This shouldn't be so difficult. Your code literally only has two lines: 1) For every guild... 2) ...send a message to that guild. Which part of this code do you want to skip in case an error happens?
 
6:44 PM
I want it to not send the message at all
 
Right. The error happens when you send a message, and when it happens, you want to skip sending the message. So the part of the code that needs to be wrapped in a try...except is...?
 
I don't know
 
The first line, the 2nd line, or both of them?
 
I don't know which is why I came to this chat
 
I don't want to hand you the solution on a silver platter because it's been a long time since you started working on this and yet it still feels like you barely have a clue what you're doing. It is high time that you start figuring out basic concepts like error handling. If you don't, you're just wasting your and our time
 
6:52 PM
Because this isn't my job, I want it to be my job but it isn't the first priority of my life to learn how to code a Discord bot.
And how a teacher teaches someone is if they make a mistake the teacher tells them what it is and explains how it works.
 
I'm not your teacher.
 
@zoomingspeed why don't you post a question with MRE on the main site?
Even here it is necessary to post a question with MRE, something you didn't do.
Check the room rules: sopython.com/chatroom
 
I am banned from the main site, I have tried to fix my questions but nothing has been happening
 
Then post a question with MRE here.
 
The provided MRE seems fine to me, honestly
 
6:58 PM
And Aran, you are right, you aren't my teacher, but if I ask you for help for something and you just simply say "Nah, you should know what it is because it's that easy" then why did I come to you in the first place
I should just know what it is just because it is that easy?
 
@Aran-Fey Hmm, great, I thought it wasn't, sorry.
 
Every conversation with anyone in here that has done that to me instead of learning something I leave the chat annoyed
 
I have tried to make this educational for you and failed miserably. I don't know how I can help you at this point
I could give you the working code, but I don't have the faintest clue how I can teach you something
 

« first day (4942 days earlier)