#python-discussion
1 messages · Page 229 of 1
That is me
you guys know that feeling when you made your own programm and it finally works and you feel like you just invented science
noep
hai guys morning, anybody knows free hosting for cloud computing? i want deploy machine learning model but try at cloud free first
I got on a Teams call today with people in a different country in a different language and saved their day
Completely different company, a subcontractor of another division of my client
But they knew me by name
alr ill go work on my flask server
You know Teams shows your name 😉

they knew your name was 🐺🌈
you're a bully
It's nice to feel appreciated. For reals.

😼 🌈

Currently I don't have a goal 😅 but I want to take up python as a hobby
Ohkk I'll try to build toy projects can you give some examples for that?
Hey, i want Api keys to create an Ai assistant, can anyone tell me which best free API i could get for thinking, listening and speaking?
guys?
can you break down your question
ohh ok..ok
chatgpt
🥲
yea, you can also just use that
hmm, ok
@weak jasper Hmm I started with Rom hacking gameboy advance games. or a text editor so I could make an arm asm editor
Ohh okk, thanks
hi
Satire obviously
like actually how is this not all a bad dream
can someone tell me is it worth it to learn python from youtube? or i should buy an online course
snowflake offers 1 free mo and has intigrated python/training servers
why not do one of the free online courses first? mit, harvard, and others all have online classes
!res There are free online courses, like CS50
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
nice one already on going in this, but after 30days required is it gonna be rest and still be free or gonna be pay as you go?
It's up to you, they have both kinds of plans
oh sorry i missread that, you can rent 1 TB or use their flex plan, but after the first month you'll have to buy credits
I like their payment structure though, you wont end up spending much on normal usage, training an LLM would be costly. I doubt the $400 free credits would even cover it. Really will depend on how expensive your model is.
why did I think it would be okay to start another factori⚙️ run, when I'm supposed to be studying
I wonder if a shop that made a poster of your actual factory would make profit
every POST api endpoint must have something like a token?
So i should just complete the youtube video first?
because currently anyone can send stuff to that endpoint. and in my backend am just checking if userid in db then do some stuff in the db
Only if you don’t want it to be public
ah its a POST request that allows a user to update their profiles. i don't think that should be made public then...
even though the user id is like 32 character long and i get it from the current session user
how do you authenticate the user?
are you using flask?
i am using jwt, its a sdk given by supabase
but this particular request am making to a python backend with flask
my frontend has auth with supabase
i mean, your POST endpoint would be public if its exposed to the internet by any means
ye thats what am thinking but. the POST request is like this
```js
const { data: { user } } = await supabase.auth.getUser();
const user_id = user.id;
const reponse = await fetch("http://localhost:3000/api/update_profile", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
user_id: user_id,
leetcodename: leetcodename,
}),
});```
see the userid i get is from getUser() which gets 32 character userid from the current session
i was thinking whether this was safe
Anything you want secured needs an authorization and authentication flow to grant an access exception into it. The default should be to deny access. ((assuming your gateway is public facing))
oh, if its only on localhost, i think you're fine
i am assuming you do the auth flow before making this request
hm but when am hosting this, it probably will be a vercel serverless function. so that would be public..
so if instead am having a vps then can i do like this while deployment. like making my frontend only public and backend api run on the localhost of the vps?
ideally, if your python backend doesn't have any auth mechanism, it shouldn't be directly accessible by the internet.
you can't keep the javascript backend and the python backend separately in this case
ah i think would need to make something better in the backend than just checking whether the user with that userid exist in the db
I wanaa to learn numpy, pandas, matpolit in a quick good way.
And i was wondering Is there a specific book for that ?
"quick" and "good" rarely fit together. Do you already know anything about these modules?
only a bit ..
How to learn and understand python
I usually start with the site realpython for any intro to new modules
.rp numpy
Here are the top 5 results:
you can read python crash course book, it is good for beginners
I really recommend the book Automate The Boring Stuff, or if you want a free online course you can do cs50p
Ok thanks
if you need another help write it for us ..
No thanks
thanks
you can do mTLS with the javsscript side and the backend side.
can one help me understand how to install something to run an automation in a pc game ?
hm i just understood that this jwt token that supabase gives me can be used for authentication in the backend too. like just sending it as header.
then in the backend using supabase client for python i can get the user id from this token
am just new to this, trying jwt for first time
i mean you can send the jwt token to the python backend and do the updates there but essentially, that also means that any user with a valid jwt can directly talk to your python api
YAll anyone know how can I turn my tablet into windows
hm but isnt that much safer than what am doing now like sending user id in the request body.
and this token it refreshes right
so jwt is not safe either?
you can't probably.
jwt is an authentication mechanism, its doing exactly as intended.
Na there is way I was using some old app but I lost it now
if you want that only your js backend talks to python backend, you need a dedicated auth mechanism between them, such as mTLS
probably virtual machines, I don't know tho
ah i don't really have js backend, i am like
frontend - supabase auth - frontend calls this python flask api
the supabase sdk is what is common b/w frontend and backend
oh, then sure, use the jwt token
so after supabase auth, the frontend calls this python endpoint
that's exactly how you're supposed to do it
to make profiles
authenticate the jwt token w supabase admin sdk
ok i will do that now, thanks
Are you familiar already with defining your own functions?
yeah
the name args isn't necessarily important (although commonly used). What's important is the * before the name
it allows unlimited positional arguments in a function
def foo(x, y):
for example if I defined this function, it must receive exactly 2 arguments to be called
foo(5, 10) to call it for example
def foo(*args):
if I define a function like this, it can be called with any number of arguments
foo(5)
foo(1, 2, 3)
foo(1, 10, 100, 1000, 10000, 1000000)
these would all be valid
is that what args is?
!e
def foo(*args):
print(args)
foo(1, 10, 100, 1000)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
(1, 10, 100, 1000)
if I were to print out args, it's a tuple of the arguments received when the function was called
does it have to be named *args
print is actually a good example of this in action
no
.
I said that above
**kwargs is the same but with the = things
if you look at print, it works with unlimited arguments
I can print 1 thing, or 5 things, or 5000 things
!e
print('a')
print('a', 'b', 'c')
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | a
002 | a b c
oh cool
kwargs is similar, but the kw stands for "keyword"
so it allows you to provide extra keyword arguments that the function didn't otherwise have
the result will be a dict
!e
def bar(**kwargs):
print(kwargs)
bar(foo='bar', hello='world')
:white_check_mark: Your 3.14 eval job has completed with return code 0.
{'foo': 'bar', 'hello': 'world'}
(assuming everything passed in is numeric)
def add(*args):
res = 0
for i in args:
res += i
return res
or even just simply sum(args)
def add(*n1):
return sum(n1, n1)
theoretically can run?
how do you think you would call that function?
Yo wassup
you should try it out
What would n2 be here?
I'm learning python
which argument would be n1 and which would be n2?
I'm at strings
oh i forgor
You can only have 1 * parameter when defining a function
and it has to be beyond any other positional args
No, but not because of the function. That's just not how sum works
!e
def foo(*args):
return sum(args)
print(foo(10, 20, 30))
print(foo(1, 2, 3, 4))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 60
002 | 10
I don't quite get what you're trying to do
whats this used for
this is not
for positional, yes
any arguments after the * argument can be keyword only
foo(1, 2, 3, 4, c=5)
I could call it like this
a is 1
b is (2, 3, 4)
c is 5
have you seen sep and end in print before?
only a teeny tiny bit
sep no
that's exactly how it would have been defined
end yes
you can only use sep and end as keyword arguments
meaning?
!e
print('a', 'b', 'c')
print('a', 'b', 'c', sep='|')
print('a', 'b', 'c', sep='...')
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | a b c
002 | a|b|c
003 | a...b...c
if I want to use sep, I have to type sep=
sep = seperator
yeah
kewl
by default, print adds a space between arguments that it displays
but we can override it
end?
by default, print adds a newline afterwards. We can change end to use something else
so
print('a')
print('b')
print('c')
# a
# b
# c
each print goes onto its own line by default
!e
print('a', end='')
print('b', end='')
print('c', end='')
:white_check_mark: Your 3.14 eval job has completed with return code 0.
abc
oh wow
this prevents print from adding a newline
but yeah I couldn't just do
print('a', '')
meanwhile other langs have 2 different print functions 😭
it would have no way of knowing that '' is meant to be the end
space is the end
but when using *args, it has no way to differentiate what is meant to be the "end" and what is just an extra argument
that's why anything after args would be keyword only
so **kwargs?
def print(*args, sep=' ', end='\n'):
the definition of print would look something like this
.
that's something different
do u have to put the end in \n
print("Hi\n")
print("Hello!")
"""
Hi
Hello!
"""
no, it's the default
or r u doing it for neatability
look at my definition here. It has default values for sep and end
do you understand what default values are in functions?
ohh
Tell me the best resource from where I can restart learning python.
there is no "best resource"
but https://automatetheboringstuff.com is a good start
also what do you mean by "restart"
I did start learning python, but then I stopped due to some reasons now I want to start learning again
same
!res
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
kk
well , that site is a good start , its a free ebook
There are so many, that's why I asked which will be the best
Ohkk thankss I'll try this
Codestyle question:
What do you think of refurb rule 118 that suggest this code change:
sorted_items = sorted(stuff, key=lambda x: x[0])
sorted_items = sorted(stuff, key=operator.itemgetter(0))
I'd be fine with either tbh
itemgetter is supposed to be a very minor performance improvement, but personally I think the lambda is way more explicit and clear when reading
In this case I would argue the lambda is simpler code. (albeit slower, if that matters)
I'm more exchanging:
lambda x, y: x+y
operator.add
hii guys if someone could tell me the resource for learning numpy
i am in a learning phase so i want something which is more explanatory
Here are the top 5 results:
thnx buddy
Websites like learncpp.com for python?
I'm not familiar with the site but what do you like about it?
Ok any website that teaches python correctly works
Maybe books if they arent too large
For books, I think Automate The Boring Stuff is a great intro to python
good morning!
python is lot less confusing and not as complicated to understand as C++ , so there isnt really an "equivalent" of learncpp i would say
any good enough website should work . As fashoomp said, https://automatetheboringstuff.com is a good one
realpython is also good if you want to learn about specific topics , like classes or smth
and for documentation like cppreference , there is docs.python.org
it's a whole language, there's going to be a lot to cover
Sorry my internet is slow so this msg duplicated
Thank you sir
AtBS isn't nearly as comprehensive as learncpp
but it should be a good introduction
I see
and a byte of python is also nice to add on the side to anyone that have prvious language experience
👍👍👍
And don't over think it. Pick something. Run with it unless you hate it.
At some point you'll have all the basic stuff down fine (variables, types, if, loops and classes) and you will just pick and choose where you go from there.
if you know C++ , you can pick up python , at least the basics and an introduction of most topics, in like 2-3 days
Thanks much guys🙂
What percent of people do y'all think cheat on technical interivews?
thats not a question you can really measure
I can say at least 60%
if there are developers on a technical interview, you will not get away with lying
(For online assessments)
so anyone doing those interview as a developer would say that nobody lies
and a non developer interviewer, how would he know that someone is lying, so i think he cant measure that
yeah its harder to tell in live interviews
for online assessments you can easily get a lower bound
what is a "non live" interview
and my experience developers think they are worse than they are
like hackerrank, leetcode, etc.
so they tend to do the opposite than lying
thats not an interview
dont you still have to share your camera and be on a call with them ?
I meant online assessments
oh
.
why does lying on an online assessment mean?
do you mean that you say you know X without knowing X ?
looking up the answer to a question
thats why I said cheating
oh i missed that
if your candidate can cheat, you failed on your assessment
you need bounderies to judge a candidate
Yeah fair, thats basically any OA atp
and if you dont have that, you should not be interviewing
even in live interviews its kinda hard to tell these days with Cluely and stuff
but it comes down to bounderies
and if you dont have that, you are a poor interviewer
wdym by boundaries
a boundery is something i make and control so that you do not have to do anything
not following what you mean there
if someone cheats by performing something way beyond their capabilities, I'll find out the moment I ask them questions about their code
if i want to judge your comptetency, i have to make sure i can without you having to do anythiing about that
i think a good interviewer will still be able to figure out if the candidate is cheating or not
its really not hard to tell if someone is cheating when you can look at their face , look at their body language , their speech
i would ask questions that does not allow cheating @prisma dove
hi
if i make an assignment that lets the candidate cheat, then that is my own fault
Can you give an example of an assignment that doesn't allow cheating
yes, i can take the candidate in a room and talk to them about something they have built, have them explain something technical so that i can underrstand how they made it
"tell me about your project , tell me one roadblock you faced and how you managed to get around that "
"explain your technology choosing decision when making the project"
i can setup a video call where we do the same
```Important: A callback can be an async function and it runs synchronously during the processing of the changes causing the event. You can easily create a dead-lock by using await on a call to another method of the Supabase library.
they say not to use another supabase function on one callback why
look if the candidate is determined enough , invests more time in cheating rather than learning , like , its not fully impossible to cheat in online interview
but again , there is no point in that , you will be caught later on anyway
@prisma dove do you have a reason for these qeustion ? anything specific ?
no, just observed the lower bound for % of cheaters in our OA was 60% and thought it was interesting
OA ?
online assessment
so you have some way of telling that people are cheating?
how do you know they are cheating ?
i see.. so an mdash checker
Ask a question that can't (realisitcally) be answered without cheating
Isn't this javascript?
the ol' AI honeypot
yep
precisely, you make it like one tiny part of the assessment so they don't waste time on it
What's an example of that?
ask about a random detail of a random python PEP or something
I can't imagine something that AI would be better at than an experienced coder
ahh ok so something hyperspecific
works pretty well lol, although I worry it does encourage people to cheat
Yeah one of the standard ones
i remember we needing to download some specific app, install it and give our assessment through that app , i dont remember the name of the app
that's a pretty good trick for AI. A human might be "are you seriously asking me that?"
Yeah thats kinda the logic, anyone experienced should be able to recognise it as a honeypot, people blindly copying from an LLM wouldn't relaise
yeah, and you can also use statisitcs to estimate it
I'd guess that if you await some other method, you'll wait forever because the event loop never gets to processing it because it's processing your callback. Which is blocked...
because you might answer one honey pot question, but not five from five seperate areas if you only have 0 work experience
It's not a multi choice or anything lol, if you get this right you're cheating or you are 0.00001% of the population which ig is just a risk you have to take
though, i still think you should not make a test that people can cheat on
I mean you gotta weed out people before taking the time to do a live interview
can't be conducting 100k+ interviews
that is a hard problem to solve, and once you want to filter out, you have make those tests
but when i say candidate in this context, that candidate has already been filtered
I've caught a fair number of cluely users in live interviews lol
always a little akward
the most popular role in tech probably have 6-8 interviews before the real one
also on site interviews
hm so my callback tries to await another method then it should continue executing and when the awaited stuff is finished it should execute that... i dont get how it will be blocked
yeah we don't do onsites but thats obviously ideal these days
are all possitions remote?
mostly
then that is fair
thats gonna be hard when the person is fully remote xd
a remote worker have more to prove than an on site worker
it is what it is
i wonder at what point interviews will require a "setup facing" camera too 😂
i know places that does that already
oh wow
even getting them to share their screen isn't enough these days 🥲
also that awkward moment when the candidates shares a specific window instaed of the full screen and you have to tell them to share the full screen 😂
faxxxx lol
I think it says you've being called synchronously. So if you await something, you're still blocking the event loop - it doesn't run until your function returns.
I'm not a a JS person, but to me saying "synchronously" it means the event loop's waiting for you. If you wait, it's still blocked.
I presume it's not like Python async stuff which doesn't really do this.
@visual juniper do you ask them to open their task manager?
oh no , i dont interview people
im a junior lmao
i do interviews
ah yeah, its a little invasive but I can end about 10% of interviews early by doing that 😭
but i have seen some onsite interviews at our startup
the answer is no i dont have them open their task manager
task manager would be crazy tho 😂
yeah I see Cluely and interview coder all the time lol
if someone asked me to do it , i probably would but it would be funny as hell
now that i think more about it , it is really hard to be 100% sure if the candidate is not cheating in an online interview xd
Yeah its easy to tell when someone is using a second monitor or has someone helping them, for those hidden to screenshare techniques I have to employ some special tricks..
e.g. just rapid fire some easy questions and watch for delay
work simulation interviews will give higher signal I think
with access to the regular tools you would have
If it was up to me the way we did interviews would be completely different, but we have growth targets so can only push back so much :/
how would you change it?
We had a better interview before imo, technical first questions where we ask questions where only someone genuinely immersed/passionaite about the language would pass (or if they were cheating, this was pre cluely and stuff)
Second round, we would get them to compare a couple different code samples, point our pros and cons and pick which was better, as well as debugging/fixing some long-form AI generated code (with access to the internet and such)
This is a job where you need pretty good language specific skills, not just general SWE
sounds like a good upgrade to the existing system
well, thats what we had before 🥲
then you did a downgrade! 😄
got told we weren't hiring enough people, had to drop the bar to the floor
maybe this is a rare situation in this recession 🤣 its a growing industry..
hire on a low bar means you have to set aside time for traning
Happy Birthday to Guido
i see so in this case it do not work like normal event listener i think. when i try to await something in a synchronous function it can cause problems. so they might be just saying this event listener is synchronous
remember to set your security rules properly if you use supabase lol
its very easy to expose a lot of sensitive data with it
Wait, really?
yeah am using it for auth, other tables are got through backend
i mean backend has admin key
oh you can't just do the auth in the backend
maybe I'm not zoomer enough for this tech
Fuck, you're serious. I share bd with the goat himself! 😮
happy birthday
it was easy with the publishabale key to do it in the frontend
i think they have RLS or something like that for auth tables by default
yeah I've just seen some 💀 stuff with it before lol
like no security on a table for identity verification documents
Yes, that sounds right to me.
Important: A callback can be an async function and it runs synchronously during the processing of the changes causing the event. You can easily create a dead-lock by using await on a call to another method of the Supabase library.
Its specifically talking about awaiting something from supabase btw not just awaiting a method right?
maybe some supabase methods wait for other callbacks to complete? just a guess
so then your callback is waiting for something, and that thing is waiting for your callback to finish
I think the ciritcal thig is this bit: "it runs synchronously during the processing of the changes causing the event"
So you can't await something else, because you're blocking things.
that doesn't make a lot of sense to me, shouldn't the callback be called once its done
e.g.
```py
def my_route(main_function_that_does_something, callback):
await main_function_that_does_something()
await callback()
theyre describing it like
```py
def my_route(main_function_that_does_something, callback):
task = asyncio.create_task(main_function_that_does_something())
await callback()
await task
But then I wouldn't call this a callback
huh, sqlalchemy commit can only handle 50k rows at once, unless I'm just doing something else horribly wrong
(ignore the fact inserting >50k rows at once waas already a mistake)
Yeah nvm I was remember another project where I commit automatically in the session DI, I just wasn't commiting 🧠
Does StreamWriter support concurrent writes inherently or do we need to use Mutexes? For example when multiple coroutines use the same StreamWriter to send data
should be
def my_route(main_function_that_does_something, callback):
async with asyncio.TaskGroup() as tg:
tg.create_task(main_function_that_does_something())
await callback()
How can I simply find the try/except that wraps my code? Can breakpoint() + bt help with this?
why do you say there's a try/except wrapping your code?
feels like ELIZA
Because I don't see the timeout error from subprocess.Popen.wait() so I think it's catched.
I'm debugging a defunct subprocess
I use this line when i want to see the callers of a particular line:
import inspect;print("\n".join("%30s : %s:%d" % (t[3], t[1], t[2]) for t in inspect.stack()[99:0:-1]))
👍 Found at least 2 try/except keyboardinterrupt 😊
mm interesting, does this go up the call stack from the function where a certain line resides?
sites like resend need me to have a custom domain inorder to set up a smtp server?
i mean, an email ID cant be an ipv4 address now can it
you would need a domain name
ah
so what the actual use of these sites like resend. i mean i can just host my own smtp server like http right
because in supabase for custom smtp i see they suggest resend
i do have a personal .me domain, but this is a group project...
maybe it helps with the smtp server part, i havent used resend
you can just host your own smtp server on a network where you also have a domain name registered ofc
registering a new domain cost money isnt it, i was hoping that sites like resend allowed me to use their domain
it does, but you can find some for fairly cheap
is the project hosting an smtp server or do you just need a group email ID?
hm but i cant see that, inorder to add an email i need to own a domain in resend
@proud escarp yes,but I'd use "%s:%d:%s" % t1 t2 t3 format as that gets picked up default by vim qflist
i believe cloudflare has decent prices
https://domains.cloudflare.com/
a domain in resend?
this is just like a sign up confirmation email, idk whether we will be ready to pay for this
like myapp.resend kind of domains for free
for sending emails
oh, to work with resend you need to specifically buy a .resend domain?
no i was asking whether i have to do that, in resend i can only see option to setup my existing domain with it
im not sure, havent used resend
there is also gmail which offers this i think, i remember doing that like few months back
i had to register a app or something
in google
What is it you want to share? Code?
So that everyone can easily read your code, you can paste it in this website:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
you can in #1035199133436354600 or use the paste site
i pasted it in python help
Why do you skip the 0th item?
[99::-1] includes 1 more item
hmm, i guess because I know where I put the line
can any of you find it and suggest?
Oh, right 😅
Guys, my english is not that good. Please help clarify the meaning of the word "transaction" in the sentence below:
"A company’s “operational systems” are those systems needed to execute the company’s daily commercial transactions and all subsequent data processing needed to complete business obligations."
To my understanding, "transaction" means, in this context, a "deal"
Is coding with AI really a big deal? I'm new to coding (around 1 week in) and I'm ngl is making codes with ai bad? Cuz I've never coded w it and when my dad showed me smth and used AI I was confused then he explained that nobody actually remembers function that well and coding with AI is okay and coding is actually all about problem solving.
so I wanna hear some opinions on should or shouldn't I use ai to code?
Its very easy to get carried away when u use AI
it is very eager to solve your problems for you rather than helping you learn how to sovle them on your own
any exchange of money/goods/services would be a transaction
while it can be useful in some cases
when you are learning , imo , it is better to not use AI at all as there are other source for you to learn , especially for coding , there are countless resources and a lot of them are good
not to mention , AI can be misleading , wrong but you wouldnt know because you are learning some thing you have no idea about and chatgpt is very good at sounding like it knows what its doing
coding is actually all about problem solving
using AI to write code for you, as a beginner, will result in you being weaker at problem solving
if something feels "very easy" to do , you have to be aware of what you are paying for that
using AI feels easy , but you are sacrificing your thinking process , your ability to try and come up with solutions
Yea but just for functions and stuff like that what do I do?
Not to fully make the code yourself
I mean not to fully use ai
shouldnt you be the one who writes the functions ?
what do you exactly mean by "for functions and stuff"? what does using AI for that look like?
i assuemd they mean like " what if i get AI to write small functions but not the whole code "
Like getting small parts done with ai aka breaking ur goal to like a flowchart and then building step by step with ai
Yes
dont do that
Why not
writing those functions is part of learning
Hmm
lets say you have to find maximum number in a list
you can get AI to write that code for you , but its such a basic thing that you really should know how to do it yourself as a beginner
okay so learn it but can I still use ai for stuff I don't know
you will be robbing yourself of opportunities to develop your problem-solving capacity.
okay I get it I think
i think it should be the opposite way
you should use ai for the things you are already good at, so you can focus more on the things you havent mastered yet
all shortcuts to learning come at some cost, even if it isn't apparent immediately.
see the thing with AI is , its a prediction machine , it is not a "teacher" , it is a chatbot
its primary goal is to make you feel good and addict you to using it
That makes sens
Okay
its like handing a calculator to a 1st grader who is learning addition
vs an engineering student who uses calculator to save time
man all this coding looks so scary man 😭
again, what does that mean? you're new to programming, so programming itself is "stuff you don't know", therefore it is fine to use AI for it?
why is it scary
Okay I understand you guys explained it very well ngl
Idk man its like hard to learn all these functions and remember it and then also adding them to each other and stuff
its scary because you dont know about it yet
once you learn it , it wont be so scary anymore
i need that an engineer rn to help me with my calculator
let me pull out my calculator and help you with that rq
It's normal to feel this way. It's hard, there's a lot of things, and you don't know what you need to remember or what's important.
It gets easier.
(actually no, it doesn't get easier, you just get better at accepting that you can't remember everything)
you just get better at using google overtime
okay I'll just try to learn as much as possible
ive been using prompts with ai to build some local programs , feeding back the error and trying to solve the problems, for most simple things its okay, but now im working on something, still simple but no room for error and im having a hard time getting itt right
My script subprocess handling is a mess.
While the script does
proc.wait() a signal handler notices ctrl-c and starts to do proc.terminate() simulatenously. I doubt that this is a good idea.
hello guys
hi
it makes sense to do that
this is python related, as I'm gonna code it in python, but do you a discord bot, which can switch the server icon every something minutes or hours would be cool?
and change the icon for a event, like shecudle the timing to change the icon
actually that would make it pretty hard to find the server 😅
server icon serves a purpose as a quick identifier
Does it? Hmm. I'm having a problem that the other process is stopping but then hanged as <defunct>
I think there's a system like that for this server
I understand but Python changes their icon every season so it would be cool to schedule.
you should always clean before you close your program
what if the process keeps alive and is just kept there dangling, polluting the system?
it's not for all servers though, you need to host the bot and maintain the bot, that's the problem
Don't think of it as "learning", but "doing". The more you build, the better you'll get.
ah, right, you're looking to make a more general version of it
well you said every few minutes or hours and that is too often i think
having a schedueler is definately nice
also afaik the server makes sure the logo is still very prominently identifiable even through the theme
https://paste.pythondiscord.com/VBPQ try this game and rate i from 1 to 10
yes.
Sure, that's what we want to achieve. But it in this case after the subprocess proc goes defunct , I'm not sure how to get out of the softlock in main process (the python script).
you can use exit(), or you could just return from the main
well I can clearly see that.
Sounds like they just want a Cron job or something similar, no?
I think the schedule command would be coool though 😎
it could even have a dashboard??
similar concept yeah
the bot doesnt even need to be active all the time , it can just wake up when needed , change the icon and go back
The python script has a for loop, running for 1 minut(!!) doing .poll() to see if the subprocess is done. The subprocess is done but the python doesn't see it because it is there as defunct 🤔
Hey if i made a chatbot using api . what is my coding rating / 10
well what API you gonna use?
shows that you know how to work with a HTTP API
also using a API is fine, because producing an LLM is very hard.
I used open router's api with mistral ai model
can you show the code in question?
??
how much is it per 1m tokens?
well expand you knowledge
I don't know exact much but yeah i used is a some and it's bill was around 0.05 dollars or something ig
is python crash course book could for learning python
really??
I mean if you wanna spend the money that's fine, you can also use online crash courses
could you send the link please?
You wanna try the bot
i have soft copy of it
I'll have to try and extract and minimize from a monster 👾
bot or api?
I was planning to use DeepSeek AI as it's got 700B params and it's $0.2 per 1m tokens
api
it was a education only bot so restictions
please
like the website
from where have you learnt python
you can use any model chatgpt deepseek or others
idk why is this happening... i was getting CORS error suddenly then just closed all server and vscode.
tried again now no CORS
am on development
I'm tryna work with cors for my discord bot dashboard
https://openrouter.ai/settings/keys
Here try making a key
I still tryna figure out how to do the login system 😭
127.0.0.1 - - [31/Jan/2026 18:41:28] "OPTIONS /api/update_profile HTTP/1.1" 200 - 127.0.0.1 - - [31/Jan/2026 18:41:31] "POST /api/update_profile HTTP/1.1" 200 -
what is this OPTIONS
according to yu all what is the best way or resource to you learn python
whats the hinting for the exit dunder?
either pay a course or use online videos
what ??
so like BroCode for example
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Automate the boring stuff with python and CS50P, decent starting point
thanks
Hey guys do you wanna try the student question only bot i made using openrouter's api?
, exception_type: type[BaseException] | None
, exception: BaseException | None
, exception_traceback: TracebackType | None
?
There's really no need to use paid courses for learning some basics of python
i have automate.. too as soft copy
It's also a good starting point, read through the book and write all the code yourself there. after you have finished one, look for next ones
https://summer-semiresinous-ruth.ngrok-free.dev
made for school project
stupid school
who are you
Bot Avatar Image
I am Mentor Bot. How can I help you today?
what is mitochondria
Bot Avatar Image
Mentor Bot: Mitochondria are organelles in cells. They produce energy (ATP) through respiration. Called the "powerhouse" of the cell. Found in most eukaryotic cells (plants, animals, fungi).
elaborate
Bot Avatar Image
I cannot elaborate. Please ask a specific academic or student mental wellbeing question.
i asked these all questions to the ai bot
the mitochondraia and elaborate are my questions
yeah buddy it cannot connect to the previous question so it doesn't take it as
- what is mitochondria
2"what is mitochondria" + "elaborate"
but - what is mitochondria
- just"elaborate" and then it is held back by restictions
does anybody here know a good yt playlist or a book to teach how to properly structure code, like how to separate my project to multiple files and my code into sections, just for the sake of increasing the readablility of my code and easiness of editing or changing stuff
I can suggest some extensions if you use vs code
guys how would I make a discord bot with a dashboard?
they structure the code
good work
its good.
Thnks buddy . btw i am just 14
i was actually looking for a source that explains the principles more than a tool that does it for me, i use vim btw
that's good
You would have the bot, and a web interface (maybe flask, FastAPI) as example and share the data from bot to the we service in way you want
yeah i don't really have knowledge about vim , sorry
what happened
np, thank you:)
it's hard to teach, since it depends on many factors
because i just hitting those tabs and now i think am vibe coding
deleted copilot now
what about login system? and then how to change guild settings?
it reads my mind... and also gives wrong stuff
are you talking about gihub copilot or micrsoft copilot
Yeah i feel it too
*github
You would set the login up yourself, and settings could be managed by maybe a database that's updated from web -> read by the bot
i m sure there is a good source somewhere
github is owned microsoft
Ig he/she is talking about the location where you used it .
like in browser or compiler
i used it in vscode which is also owned by microsoft
how can i use copilot inside a compiler
i don't think so. it just takes practice
makes sense, should the API change the settings?
Man @terse portal is new .
yeah, anyways thank you:)
Well, if you want to use that as edit point, you probably can do that but the bot would basically apply the changes actually
Btw any coder other than python too
When you start to learn design patterns and how to properly structure data it becomes something you’ll start to develop in your code bases. If you want concrete structuring then you can always look into stuff like MVP
I'm just wondering how the data that needs to be changed will be sent...
Lol 😂
Probably a shared database, bot/API can both read it
sorry for that
i 'll save that to come back later, thank you
@white knot so which ai are you planning to use now
no shared database makes sense. from the client side how will I send the data that needs to be changed?
I don't quite understand what you are asking, client being the dashboard/API/bot?
how will I send the data that needs to be updated in the datbase to the API? will I add headers or will I just use tags in the URL?
errr, I'm thinking it more like this:
web interface, this is the place with UI, where you make changes to guild or something.
-> web updates the database with new data "update table with these values for this guild"
-> bot reads the database every now and then, and reads the table + checks when last edit, apply the changes based on that
-> now the guild settings are updated
You'll just have the bot and web/API being able to communicate via the same database
If it's http protocol
that is a good idea as well.
I mean how would normal JS change the dB?
about the return of the exit dunder, True means to suppress exception or False
the API is on the backend, such as FastAPI and is running just like your bot does. JS would be "basically" what the user sees. You can also just have fastAPI serve HTML documents if you don't need full-on fullstack there
i mean I would need a full on full stack as I need it to be fast
```py
students=[]
def add_student():
try:
name=input("Enter name of the student: ")
marks=int(input("Enter marks of the student: "))
student={
"name": name,
"marks":marks
}
students.append(student)
print("Student added successfully")
except ValueError:
print("Marks must be a number")
can we not just use ``students`` instead of ``student`` for adding the names?
So you want a dedicated backend, and a dedicated frontend?
What is bot here bro I didn't get
What is bot here ?
yes
it's fine with me, hosting can be expensive but I'll do anything to make something good
how do you want the combination be like? You can do python+js framework or something without python backend, there are many ways to do it so it really depends ™
I'll explain the teach stack.
discord bot
im soon confused on how to change the guild settings
it's puzzling me a lot
I haven't done frontend dev and my experience is limited, so I can't really tell you what is best for the frontend part.
backend is more fun to be fair lol
What's "normal html" in this decision?
I think it's the most cool part as it's the core of the whole system, the frontend is cool when it's modern
no framework
What kind of app?
how do you normally do it with the bot? You change the value of something, basically, right? Now, you get the value from the database
Where does the database get the values from? Toggles, userinputs or whatever you want, and that's from the web part
web -> db -> bot
it still needs to be reactive
so if I did it normally I would get the data from the database, if I were to change it, I would change it immediately
so you can either craft it yourself or rely on frameworks. one's easier
I'm wondering if an issue could be that my other process doesn't stop within the 0.25 seconds defined by subprocess.Popen._sigint_wait_secs
framework is easier for sure
like tailwindcss, I just find react a pain in the but sometimes
But what are you trying to build?
a discord bot
Why do you need a web interface?
with a dashboard which updates itself constantly, i'm guessing
I'll tell you why
. here's the start
What's the dashboard do?
if it does stuff like display server stats on a web UI, it needs to be reactive
it's a icon manager bot which changes the icon every so x minutes/hours, you can schedule icon changes etc
if it's just basic config, it's fine otherwise too
I'm giving very basic info but I've got a lot more features in the back
!e
Can we write a route in a discord bot
API route??
Basically every discord bot connects or handshake with discord server right?
I have no clue what you are talking bout
all a discord bot does is connects with the discord api
does it
Why’s merging a big change to main for the first time in a 7 person group project so scary
Because you should make changes smaller 🙂
Because you see it as a risk of being humiliated if it goes wrong. But.. If you resolved your merge conflict first in your branch, checked things, tested, then you should be fine. (probably, I didn't see your code)
Well I mean it was only 600 lines, it’s just my first ever time doing something in a group, I’ve only ever worked solo
All works though no issues
Just scary
Do you have pull requests or peer reviews?
I am looking for api developer
who can do api resgistration for instagram and must be ios endpoint
use a hiring website. not discord.
We was going too, but main group member decided not too 😂
Anyone can merge to main
XD
It’s for a university coursework and they deemed it not necessary
you can't learn really without being humiliated
Then maybe just ask one team mate to do a sanity check on your work if you are unsure. "Hey, I think I'm ready to merge this in, is there anything I should check first?"
what is | in python?
Can you give the context here?
anyone will laugh at you for doing something wrong so if you don't wanna learn it means you can take the fact of embarrassment
no, it connects to the gateway, which starts a websocket connection
he means the symbol for the channels
There is no I in python. Or team. 😉
So does that mean we can write an api route in discord bot
for example: variable: type1 | type2
It depends. For int it could be a bitwise OR, for a set it could be the union operator, or for float it is undefined. Also you can overload operators for any class however you like, so theoretically it can have an arbitrary number of meanings
Oh, that's type-hinting
no, you don't run the API
making mistakes is definitely an important part of learning, but that isn't quite the same as being humiliated. It is probably better to be in an environment where you feel like you can make mistakes without being made fun of
maybe make your own API and run it alongside the bot
Yeah only websockets connection nothing other than that
Sorry, I was making a bad joke. But what you are showing me is saying that variable1 may contain a value of type1 OR type2. So it's "or". Or a union. It's the same as Union[type1, type1]
py print(f"Name: {student["name"]} | Marks: {student["marks"]}")
I saw that symbol here
Here it's just a character in a string
oh okk
that's for sure, my school is thankfully like that, a non toxic learning environment
I know
ohh, sorry, your weren't the original asker.
make your own API and run it alongside your bot
I remember my 11th and 12th grade informatics (= computer science) teacher almost always wearing a t-shirt saying "proud to fail early"
They raised you well.
well that teacher really understands life
that is the true definition of learning
exceptionally well, you could say
Do people consider using fastapis or django if they have node js working fine and has good synergy with the data stuff
Those are all valid choices. Which one you choose may depend on:
- Which stack you and your team know best
- how much code you already have written in one stack
- preference.
Or if there are other libraries you plan to use that are only in python or only in node. Those types of concerns.
Other than that you can choose which language you want to right doesn't matter much
FastAPI is very nice, imo, but it's just the API part of the stack, not database. So you'll need more. Django is more full featured and deals with databases and other application structure. Node is just a runtime like python, so.. I don't know what frameworks you are using there.
Different languages are good at different things
Just like different frameworks
it is a good idea to understand what you rlanguage and framework are best or worst at, and compensate appropriately. Changing languages mid-project is a recipe for failure, but that doesn't mean all parts of a project have to be the same one. It's just tradeoffs.
I mean I recently started using Express and learned javascript like I feel writing frontend react code in js and I don't want to switch to python
But I love writing code in python before
But after js,I feel js is better for full stack web development
Flask is excellent for a barebones, simple setup in python. Django is good if you want a lot of features and power and want the optimized guidelines it provides
Python as a language is very powerful and very flexible, but doesn't perform as well as rust or go
Javascript is the same language you will use for your frontend
well, for frontend you'll need some javascript either way. If you like react, you can keep your react. Your backend can be python
"Full stack" is one of those things that's, how do I put it
Jack of all trades master of none
I should know, I am one. Frontend, react, mid-end, some networking, deployment, backend, databases
There is simply too much to know to properly advance and specialize
You'll find us all saying python becasue this is a python discord. But I have done JS backends in the past and would again. It can be a very capable runtime, lots of libraries, etc.
The answer is you should know what you are doing and why
where T-shaped?
It costs nothing to write a very small demo as well and launch in both language options, to understand how they actually work
breadth in lots
depth in few
I'm H shaped.
javascript gets the advantage in full stack because it theoretically reduces the amount you have to learn
it doesn't by that much, actually, but the idea gets a lot of weight
me, looking at my tab with chatgpt open: this post can't stop me because i can't read
Not saying it won't work in the future, but if AI worked windows would be a lot more functional right now than it currently is
Also, you can share some code between front and backend in .js. I have in the past.
src/
client/
server/
common/
Where common has some things that could be used in both places. The same validation library both for instant feedback on the frontend, and also verified the API payload on the backend.
you can even use JS for infra provisioning and configuration
@.@
That's great we can't be doing with python
guys finally i learn nosql in my college
It'd be lovely if browsers shipped a friggin python runtime
Annoyed at adobe and oracle for ruining that space
Python is built for ai models ngl
It can be great. But it also requires discipline to know what code can be shared. Also it can sometimes require changes both on front and backend to keep them in sync, etc.
Sometimes a clean separation can be better. (But it worked for me when I did it)
python is build for everykind of work
cool
(pyodide pyodide pyodide)
Now if only I didn't have to send over an xxmb runtime every time
Router stuff right?
Can't even cache cdn's anymore because google and advertising companies are evil
Who owns Cdn?
What about router stuff? I had a separate frontend and backend routers. The frontend router had different concerns, like encoding which tab the user has selected, while the backend router was just RESTful based on the resources/models.
It's a type of service, there are a lot of companies that offer them
ultimately, shockingly, it turns out frontend and backend are two different problem sets that have different solutions and are solved with only moderate coupling between the two
It's called system design
Of course. Some shared concerns (because they work together), some different concerns (because they have different responsibilites). I was trying to convey that already.
wdym?
CDN urls are no longer cached cross-site
If mywebsite.com accesses jsdelivr.net/jquery, when you later go to notmywebsite.com that requests the exact same resource, it will not be cached and will be deliberately duplicate-fetched
Cdn are just our choice
This is because of cache-based tracking attacks by large advertising networks using this to determine which websites a browser had visited before
for those who use pdb
do you do
python -m pdb script.py
or just run normally? does it even matter if you are using breakpoint()s?
Which, notably, you as a website owner didn't even have to opt into. An advertising company could hit like 15 different cdns and cross-reference them against a list of common websites that hit the cdn's for natural purposes. Even worse with rapid iteration adding more bits of information to the process.
I just use breakpoint()
Do we have any websites that have news like these ,I mean today tech news
Theoretically, ten years ago, if python wanted to take over the internet all we would have to do is have someone host one copy of the runtime and everyone access it. Then only the first time would the file be downloaded and python would be nearly as fast as javascript. But it doesn't work like that anymore.
So, you're talking about CDNs to host libraries for multiple sites/apps to use. That's one use. I don't like pulling my dependencies from a 3rd party CDN, I host them myself.
And my CDN takes the load off of my servers. So that my server doesn't have to serve that asset to each customer, the CDN can do that.
I just think of CDNs as part of my application, not a service to me as a user.
They were originally intended to be both
Sure. I think the case of saving a few milliseconds because two websites happen to use the same version of jquery is rare, though. These days most sites have their own bundles of .JS compiled with their code and dependencies.
You see, the thing was it wasn't a few milliseconds
Not only could you avoid the download--and js libraries were relatively as big back then as they are today, compared to internet speeds--you saved round trips
and round trips are murder on performance. You didn't have to set up connections, use bandwidth, handle TLS repeatedly. Remember that cdn's came in during the era of http 1.0, where everything went over a singular pipe and any blocking meant total blocking
I agree with everything you said. But I don't think it matters as much today as it did in the past.
But yea.. advertising and tracking ruin everything.
I mean.. round trips still matter, but that's solved with bundling.
PGP key hash
I would have linked you to a keyserver but they're all misbehaving for some reason
going to have to fix that I guess
ty
You're not wrong, but it is a major component of why we're stuck with javascript and optimizing libraries to be so small
Perhaps the most strongly hit component was fonts
Fonts used to be effectively free, because they were only downloaded once
but today we have serious concerns over FOUC and similar because they are always downloaded now
I want to download a previous version of macOS. I am currently on 13.43 and I want to upgrade to 15 is it okay to install it from App Store?
full-sized fonts are upwards of a meg these days, and you pay for that for every site that uses it
You'll hate this:
We have some shared assets that get served by our CDN on more than 100 domains. So if a user uses multiple of our sites and happens to need the same assets, they download them again.
yep
again and again and again and each time contributing to load and wait times
Fontawesome's website weighs 20mb
recaptcha.js is 1mb, and I have to keep fucking downloading it with every website
Some of the assets are customer-specific, and we have good reasons to use their domain (like media). But.. thinking about this, I might be able to have some things like fonts move to a shared domain..
Don't.
Historically, having them on a shared cdn was faster
today, serving them from the origin domain is faster
I won't, becasue I don't care that much and have more important things to do. But .. is fun to think about.
Right now with http3 the main source of latency is the waterfall (as always...) but also connecting to other domains. Keep in mind that each domain that you have to connect to naturally waterfalls behind the user's dns, which has gotten slower over the years
good point
Eg:
- dns mywebsite.com
- connect to mywebsite.com
- TLS mywebsite.com
- Fetch page
- parse page
- dns static.mywebsite.com
- connect static.mywebsite.com
- TLS static.mysebsite.com
- fetch content
- dns mycdn.com
- connect mycdn.com
- TLS mycdn.com
each of these is a minimum round trip
Hi Bast
For most users, probably between 20 and 80 ms
hey
240 to 960ms of delay just in round trips, no matter how fast you serve
I ripped out the extra TLS lookup but it didn't really affect my time 🙁
o/
hello hi howdy
F
I want to download a previous version of macOS. I am currently on 13.43 and I want to upgrade to 15 is it okay to install it from App Store?
We do pay attention to optimizations. For example when we have to connect to another domain (and we do a lot for all the various chatbots and bullshit our customers want on their site) we use the head elements that pre-connect. Other such things. Also we pay attention to google's core web vitals for our sites.
Wait what
Why do you have to download an older version if you're trying to upgrade?
I dont want macos 26
oh
No that's not a thing that I know of
If you are just upgrading, upgrade from the settings panel in macos. It'll tell you you have updates to MacOS.
I meant -- I don't think pinning to specific releases is a thing
The updater is always going to download the latest
Download and install current or previous versions of the Mac operating system on compatible Mac computers.
Ik but only 26 is avaliable, not prev versions
are you guys mac users?
But we're programmers, what do we know
I am a sysadmin, but a Windows one
The Macs in my env are always broken
Jinx
I am on a mac right now. I am an everything user.
the onces who are suggesting me
this is a python channel not a mac channel
you should not be surprised to be getting limited help in the wrong place for your question
yeah but programmers, not for this quesition toh.
Sir, this is a Wendy's
hmm so any suggestion lol
I linked you a guide that allows you to install whichever version of macos you want, provided apple still provides it. I have no idea how you would go around it if apple doesn't want to provide it anymore

Sometimes I swear I'm just speaking into the void
Oh you didn't see that this channel was renamed?
yea.. my suggestion is look at Bast's link above.
yeah docs
same thing there true
can install from app store as well
thanks anyway
I'm so confused
yea.. that link answers their question perfectly.
have you heared about clawdBOT?
everyone has heard about clawdbot the last few days.
Their social media site is kind of funny not gonna lie
also so true
I'm over here actually auditing dependencies for trust
and they're just like
"ai, go download instructions from another ai. Also here's my banking info"
How deep do you go?
Depends on project requirements /slop
Depends on the use case and source
I don't audit django, for example, but if someone has a dependency on here I haven't heard of before I actually pull down the pip files to unpack them
I've got actions/dependency-review-action in CI and Snyk and stuff
I'm mostly good at sanity checking changelogs
I tried looking at the actuall diff of every dependency in the tree but that was WAY too much effort for a poor solo dev
Have you been to https://inspector.pypi.io/ ?
yes
based
Which book is better for learning python: automate the boring stuff with python or phyton crash course
they are both good. Look at both and use the one that appeals more to you. they have different approaches.
Which you prefer o
tbh, i have never read either
hi
Me: why is my laptop so slow??
Me: closes 4 youtube tabs and 3 web blog tabs
Laptop: suddenly performs a thousand times better
Have you tried getting a laptop made this century?
i think automate the boring stuff is better but it has some unholy code and the author plugs his modules without disclosing they are his and not really used at all
also i dont really like the code snippet format
it's called to copy paste iirc
oh, the website changed
It is : )
how much ram you got?
more than 16gb
nvm, it's the second edition
```py
➎ if text[7] != '-':
return False
for i in range(8, 12):
➏ if not text[i].isdecimal():
return False
➐ return True
@jagged belfry you mentioned earlier that DNS had gotten slower, why is that?
i only got 8gb 🥀
im saving up for a new laptop this year though!
Everything is so bloated these days
im going to buy the one with the best specs i can
Good luck. Tech market is on six types of fire, spinning in a tornado, and diving into the dumpster to really kick it off
Changed interests

yep, what a bad time for computer parts to raise prices
yeah really happy I bought my desktop before the massive price spikes
when it's MY turn to be an adult
what do you mean?
which modules?
||i just hope the AI bubble pops and manufacturers go back to focusing on the consumer market||
it's finally showing cracks, you might be in luck
although companies aren't caring about regular consumers as much now
hello guys.
It's a mix of things, although I don't have hard data so I could be wrong here:
- transition to secured dns adding 1-2 round trips
- a change in networking focus on throughput for streaming increasing base latencies (in the united states in general)
- companies taking advantage of being able to intercept dns and inject their own responses (comcast, etc)
- google starting to fail to care about their DNS
- more complex DNS requirements due to the proliferation of cdns
- more complex dns responses due to HSTS and similar
these ones i can remember
https://github.com/asweigart/humre
https://github.com/asweigart/bext
https://github.com/asweigart/pyperclip
to be fair pyperclip is actually used alot i think
but that regex one i would rather just learn normal regex instead since its universal
bext can be replaced with blessed today, I think, although it's existence is reasonable for the time period the book was published in
i see: he has helpers for his pedagogy, and you think he should be clearer that they won't be used beyond the book.
I don't mind much that a python book suggests it's own "make easier" modules. That's pretty consistent for learning books, because you want to smooth rough edges to learn before you can solve said rough edges properly
how do i check that two mocks were called but in a specific order?
The value of being able to actually do cursor and color in a terminal without explaining ascii codes is quite high
hmmm ok
TLDR: make one parent mock object and then check .calls
hey I wanted to make white noise or any color noise generator in python for fun what library should I use for the sounds
Ooo cool we had AWGN in college to learn but idk about any libraries,are u perhaps using it for background focus?
nope just as a project I don't know any libraries for making sounds
That's a cool question.. Hmm
depends how nitty gritty you want to get with the maths. you can generate awgn with numpy, color it by multiplying the noise with the square root of your desired covariance, and then play it with say pyaudio or python-sounddevice
https://docs.python.org/3/library/wave.html
I've done some basic audio generation with just the stdlib
librosa should have high level ways of both generating and playing sounds, since it's a sound signal processing module
ty
Now I'm just curious about doing this with a buffer or something
sounddevice and pyaudio should let you play numpy arrays directly
do I need to make it a file
make what a file? the noise you want to play?
yeah
no, you don't need to
you can if you want to play the audio in say windows media player or vlc
okay it seems like that for some reason
you can directly play your list/tuple/numpy array into the "output audio stream" though
exactly what i did used the get function and suffix
but because i didnt want to set a unicode for all possible file types i used ai to do it for me file_icons: dict[str, str] = {
# General / categories
"directory": "\U0001F4C1", # 📁
"text": "\U0001F4C4", # 📄
"pdf": "\U0001F4D5", # 📕 etc it goes on for another 50 more file types xd
each one that exists
like for smth like this id argue its totally fine to use ai it saves me a good 15-30 mins of finding a unicode for each file type
what lakmatiol linked you to is only for writing and reading files, as far as i acn see
your file liike object already has that, it is part of pathlib
man I have no idea what I'm doing
print(dir(file)) to see everything it has
https://python-sounddevice.readthedocs.io/en/0.5.3/usage.html this has examples
mode_and_position: dict[int, tuple[int, str]] = {
stat.FILE_ATTRIBUTE_DIRECTORY: (0, "d"),
stat.FILE_ATTRIBUTE_ARCHIVE: (1, "a"),
stat.FILE_ATTRIBUTE_READONLY: (2, "r"),
stat.FILE_ATTRIBUTE_SYSTEM: (3, "s"),
stat.FILE_ATTRIBUTE_HIDDEN: (4, "h"),
}
for key, (index, char) in mode_and_position.items():
if file_mode & key:
mode_attributes[index] = char eivl also made my mode better not just plain old if statements this is more flexible
Yes, I had a setup where I was just playing the file every time.
are you familiar with pulse code modulation and sampling? that's probably a good place to start. otherwise you'll struggle to even make the files
no
digital sound is finicky
There are other ways to do this that don't involve files
where do I learn that
read through the link i sent you, it has examples and explanations
oh
u talking bout get and suffix right? get is a awesome suprised i haven't used it yet dict.get(key, default=None) so useful 😅
depending on how complicated what you want to do is, in university 😛
okay so when I play a np array what happens and why I really don't know what to ask I don't know what I'm doing
Where should I ask for vscode extensions uploading related issues?
ok so. you computer does not understand sound as it occurs in the real world. real world sound is a pressure wave that varies with time. your computer can only work with things like arrays and lists. so what the computer will do make an array/list where each entry represents the pressure at the specific time instant that the array/list index represents
commonly, for reasons you would learn in uni, sound and music are "sampled" at 44100 hertz, meaning that each index in your array/list represents a time duration of 1/44100 seconds
so you can make, say, a numpy array of length 2*44100. you can tell python-sounddevice to play this array with a sampling frequency of 44100 hertz. and this will produce 2 seconds of sound generated based on the values inside that numpy array
if you want to do stereo sound, you would need 2 vectors: one for the left speaker, one for the right speaker
okay this makes more sense
oh yeah stereo is there like a bash cmd to tell if I have stereo or mono gosh I'm so dumb
the intro in the link i sent you talks very briefly about some of these concepts
you have to keep in mind the real world phenomenon you want to represent. the easiest example is generating a sine wave, which your brain interprets as a "beep" sound
perhaps something like
i would skip the position in the dictionary, use enumerate() and just do
mode_and_position: dict[int, str] = {
stat.FILE_ATTRIBUTE_DIRECTORY: "d",
stat.FILE_ATTRIBUTE_ARCHIVE: "a",
stat.FILE_ATTRIBUTE_READONLY: "r",
stat.FILE_ATTRIBUTE_SYSTEM: "s",
stat.FILE_ATTRIBUTE_HIDDEN: "h",
}
for index, (key, char) in enumerate(mode_and_position.items()):
if file_mode & key:
mode_attributes[index] = char
```instead, you just have to remember that the order the entries appear in the source code for dictionary is important now
import numpy as np
sampling_freq = 44100
dt = 1/sampling_freq
seconds = 3
Nt = 3*sampling_freq # number of samples for the desired sound duration
fc = 500 # frequency of the generated tone in hertz
tone = np.sine(2*np.pi*fc*np.arange(Nt)*dt) # array with the tone samples
# and now you can feed this into python-sounddevice to play the tone for 3 seconds
!kindlings
The Kindling projects page contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
pretty much every speaker is stereo nowadays
how do i calculate the amount of messages sent per day from start date to end date
currently i have a timedelta of the difference but idk how to continue
I am having trouble launching my python app from another MacOS Desktop app. I think it's related to DYLD_LIBRARY_PATH but am not certain. More info in my thread: #1467202160277323776 message
(The one and only time I'll post my thread here. Hope this is OK)
What kind of data do you have?
message count, start date (YYMMDD) and today
i think i finally have the difference in days
In what? A dataframe?
are you asking about a file or about hardware?
A dictionary?
ah this didnt work for me cause i didnt use enumarate but why not just keep the index in the dic i like knowing where its supposed to know idm (0, d)
im trying to find out how many messages a discord user sends a day "just as is"
just as values in my head, or more specifically my python REPL
if file that would be part of some metadata
for a totally raw stream you mostly don't know
I'm asking: What data type is this data in?
I DONT KNOW, ANY
i guess datetimes and timedeltas?
anything that will work?
iirc a common way to encode multi channel raw audio is to just interleave the samples
If it's a dataframe, then it'd be: df[(df["date"] > startdate) & (df["date"] <= enddate)]
&, no?
If it's a list, you could use a loop like: ```py
for d in mydates:
if d > startdate and d <= enddate:
mycount++
Proper expressions are left as an exercise for the reader.
for index, (key, char) in enumerate(mode_and_position.items()):
but il do it cause its more clean