#python-discussion
1 messages Β· Page 583 of 1
im actually new to programming. im learning flask rn
how so?
It makes more sense to write your intentions down instead of letting your IDE display it for you
the intention is already written, 0.0 is known to be a float
Its like having auto everywhere in C++ to me
Is var = 0.0 not clear about the intention?
i have no idea what are you talking about
we do type hinting for parameters to functions.
How do you know if I intended for it to be a numpy f32 or f64 instead though?
0.0 is a python float (double)
there's no numpy involved when I do var = 0.0
further, writing something like var: np.float64 = 0.0 does not make var a np.float64
I'm specifically passing it to functions that could differ with f32/f64 though. Thats why I'm typing it to make it obvious what the intended type is
if you've worked in java or C before, data types have to be explicitly declared, like:
int number = 4
Python automatically assumes its type int, because that's the closest to the number type:
number = 4
dyssyn2 is confused that we don't declare the type for the variable.
Yes but thats why you use a type checker to catch this
in python, variables don't have types. there's no assuming happening there
^ that too
If a python float doesn't accurately represent your type, then sure you need to specify. But, I don't see how that makes inferred types not make sense
i only know python and lil bit of js
they can change on the fly
for something to change it needs to exist. there is no "variable object" with a "type" field, a name just corresponds to an object (and objects do have a type field)
it makes sense tho
There's no downside to writing the specific type here (I'm writing a statistics package that takes numpy/pandas input and recasts etc, so some specificity here is good)
there is data to a type field, then the variable which is a pointer to that object then?
int? boolean? float? str?
what about them
the best C++ practice is to use explicit types when the deduced type isn't immediately obvious from auto (or if the explicit type is very unreadable)
I mean, it could be overly verbose if you can infer it pretty easily though. It may not make sense your very specific use case, but I thought we were talking generally given the starting question
what type annotation would you use in this case?
those are types of objects. objects have types. variables are merely names, and they do not have types bound to them as such.
what was your dumbest DUMBEST college/ school project idea?
Well I'm using the builtin float here but my func return is tuple[npt.NDArray[np.float64], npt.NDArray[np.float64], npt.NDArray[np.float64]]
oh, i dont know other languages other than python so,
do you have a link to the whole function?
being able to specify types on multiple declarations on the same line would be useful in many scenarios though
yeah, that's not possible. It's ok to take more lines
Work in progress but the return is for 3 variance arrays
they are objects in python. Variables point to the objects that have those types, but the variable itself is not the type. Its like a house address. The street address can be something like "123 easy street", but we have no way of knowing what building is there. The data types of "int, str, float" and more are equivalent to the buildings. The address is the variable name.
does work in progress mean it's not online yet?
yeah ty ty
yeah I'm porting an R library to python
it could still be online as a work in progress. Good for backups etc.
oh I'll publish it once its finished. I just started
should i know these stuff for like game dev or web dev or anything close to that?
Not necessarily. Its something that will come with time, in my opinion.
I don't have a lot of python experience so I'm still trying to figure out the syntax for this kind of stuff
what language do you have experience with?
C++, R, and python in the data science sense
R as in rust? if you experience in C++ then it should be a breeze to learn pythob syntax?
R as in R. Type hinting multiple declarations on one line isn't everyday python
Oh cool what is R used for?
statistics
if only someone had posted a link. π
In Go you can use both :D
var number int // Defaults to the 0 value.
var number int = 0 // Can be set right there.
number := 0 //Assumes the type, can only be used inside funcs. ```
You could break that problem down into something like this
#transform input into the right format
function byte_reader(filename):
with open(filename, 'rb') as f
return transform_format(r.read())
or into even more pieces like
function transform_format(byte_input):
#transform input into the right format
return new_format
function check_format(byte_input):
if(...some check...){
return 'xml'
}else if(...some other check...){
return 'json'
}
return 'default'
function byte_reader(filename):
with open(filename, 'rb') as f
contents = f.read()
found_format = check_format(contents)
return transform_format(contents, format)
integrated into a decorator for completeness.
def decorator(func):
def wrapper():
contents = func()
found_format = check_format(contents)
return transform_format(contents, format)
return wrapper
Python has a keyword function?
class ByteReader(Reader):
def read_file(self, f_loc: Path) -> bytes:
return f_loc.read_bytes()
def read_graph(self) -> bytes:
return self.byte_converter.convert_to(
self.file_reader.read_file(self.file_location)
)
class XMLToElementConverter:
def convert_to(self, raw: bytes) -> ET.Element:
return ET.parse(io.BytesIO(raw)).getroot()
definitely clarifies that.
um what is this?
Complicated stuff, hi
we are talking about putting together simple functions to make complex functions, and testing them
what kind of complex function?
this is crazy but what exactly is XML
extensible markup language
can it be used to store data
for example, in my case, I am reading a file as bytes (one format). I then have a function that converts raw data into a file format. I then have a function that puts the file data read, into a converter to the file format to read the file format.
Ya got it. You might break down each kind of format transformation into its own function too. like transform_to_xml(byte_input) since you will likely have have some condition in the converter that does a different kind of conversion for each type. Then you can test each conversion outside of the main converter function.
only the syntax is familier to me
it can
hi!
thanks man. I appreciate it.
can it replace json?
welp i only know flask currently, nothing else
I need some some json alternatives man
Was it hard to learn?
it can be used like json, but json is more widely used and probably not replaceable
SQL?
not really tho im learning btw
what are your specific requirements?
I'm assuming retrieval speed and stuff is the same
@turbid sigil by the end ya end up with 6 super duper no side effect functions and 1-2 ones that contain only thinks like reading file.
I don't want too much nested stuff
I feel like XML and dataclasses would go well together
Alo
β
okok, I'll commit to that function style for a majority of my work then.
i mean, xml will just look like a more verbose json
SQL π
XML is like a mix of HTML and json, imo
xml is taking the worst parts of json and combining them with the worst aspects of html
unless you explicitly need the perks of xml you should probably just use json (or toml)
lmao
re: xml; I kind of like node attributes π
i literally never heard of XML
I just looked up
XML can do data transfer, whats that supposed to mean?
Have heard the name, never used it tho.
are these things gonna affect me, im tryna learn web dev
for example, my senior project made an XML file output, and we sent it to our front end, and it was used for rendering a bpmn graph
wow my desktop literally does not work properly at all
I remember having to parse xml as raw text to figure out which version of xml a doc was using because microsoft's xml 1.1 parser would literally just crash your app if you tried to open a xml 1.0 doc and ask it what version of xml it was. (I might not have the version numbers correct)
it's just like json. you send someone xml and they can read it in whatever language they want
i think learning toml will get me the best ROI
its a good resource, it'll tell you what you want to know for web dev stuff.
the systemd network services fail to start on boot but start if i explicitly start them,
the wallpaper daemon starts at the wrong time on the first niri session after boot (it does work if i exit the session and then start again)
this is like, unbearable. i have been debugging this for multiple hours at this point
ohh
Poor guy
toml is nice for manually writing config files, not so much a data interchange format since it's not as popular. but you could use it i guess
Just sleep it. Uglier but functional is good.
thanks it actually gonna make my life easier now, good thing i recognise most stuff in there
Also, the network issues are weird
no problem man. enjoy!
yaml is a very popular configuration language
XML and JSON for collaborativeness
haha. i switched to useing i3 widow manager last year, and this sounds a bit like my environment from time to time. Still using it though and its great even when all the different version of randr and exec_always programs are not all that happy
how can something be worse in this regard than hyprland
like?? i like the scrolling feature of niri but i just cant make my computer start with it properly
is there a python library that renders stuff in any of these formats? (toml yaml json xml)
You can use scrolling in Hyprland btw
That's what I use
i don't mean render wait
python has json and xml libraries in the std library @brittle merlin
like generates*
i know
im going to nuke my desktop again tomorrow i swear
Go back to hyprland. New Lua config is dope af, you can literally script your config. :)
Also it has scrolling.
i am inclined to not use a graphical session at all after this tbh
or systemd
or arch
it's enabled and still?
Crashing out over minimal issues is crazy.
Those are not Systemd or Arch problems, since I use Systemd and Arch, and don't have those problems.

Maybe it is Niri conflicting with something, last time I tried it it had weird bugs.
But more graphical than functional.
people deal with things differently. They're probably doing specific use cases different from yours most likely.
try an AI generated hotfix, modify the startup behaviour or something
I mean, I doubt he messed with how Systemd starts the network thingy. Lol
Also Niri is pretty new
Not surprised it has bugs
That's why I'm still on Hyprland
yep i have no idea lol
i did because systemd-networkd-wait-online errors because my internet doesn't work before i start the bypass service (thanks my favorite government)
im not a snek
this is not snek stuff, so you're fine.

its operating systems stuff like windows
hi...
ohhhhh okay okay
...im so scared...
hello everyone
lol
bros another level of snek
i am, snek
i dont understand the awww-daemon problem at all though
So did you just
systemctl disable systemd-networkd-wait-online.service```?
like, it starts
but doesnt work?
ohh russia moment
Didn't it work with a sleep?
make a bash script dude
turns out it only worked if i re-ran the session after booting, but not on the first session on boot
bye guys i dont understand those stuff, im gonna go watch toy story now lol
you're saying this like i dont already have 4 of them
why you don't use a voice chat
enjoy the fullstack guide!
You know you can edit the .service so you change how systemd initiates the network thingy?
Also @turbid sigil
See, it's not a Systemd problem by itself, but on how he uses his network, he needs to bypass some stuff to use it. :b
I just don't like when people blame the wrong things. π₯
the systemd problem is that its really hard to debug
I have a question do you play slime rancher 2
Isn't journalctl made for that?
i have no entries in it because shit hangs and then just errors
I don't, I just really love ringtail slime. :)
(I want to buy it soooo bad).
I hope too
but then i can systemctl start zapret and it works??? like? what?
like why does manually doing everything work but nothing works automatedly
Print ("Hello world")
enable --now π£οΈ
can you send systemctl status zapret
here
bro
its empty on boot, just inactive (dead)
I'm may be forgetting something but did u enable this?
and then you use dinit
what does the unit file look like?
Have you
systemctl enable --now zapret?
yes, its enabled, it just doesnt work on boot
so zapret just hangs (with no stdout/err) when you start it too early?
damn how do u even see the logs for this
u have to use AI to decipher this unless uk grep
journalctl -u zapret -b
pro
originally its
https://github.com/bol-van/zapret/blob/master/init.d/systemd/zapret.service
but that didnt work
and it didnt make sense for me that it uses Type=forking
so i made it
Type=oneshot
RemainAfterExit=yes
because as far as i understand its like, a shell script that starts iptables stuff and nfqws and then just exists
@raven urchin teach me linux bro
Look at this
ExecStart=/opt/zapret/init.d/sysv/zapret start
ExecStop=/opt/zapret/init.d/sysv/zapret stop
looks like there's an actual zapret daemon, no?
../sysv/zapret is a shell script
and it runs if i run it manually π€· but the unit fails on boot
tbh im not sure what to do with the network-online.target either
it might not be reachable considering systemd-networkd-wait-online was timeouting
i tried changing it but nothing seems to work
sleep then run seems too brittle and disgusting
Maybe
systemctl edit zapret
[Unit]
After=network.target
Wants=network.target
And disbsle network-wait
I'm viewing this on phone and have no idea what this is
some sort of cheatsheet?
Yes.
It has some cool stuff
tbh my desktop might be cooked after everything i've done to it today
is it possible the changes they're making aren't persisting?
Lmao
Come back to Hyprland!!!
It's cooler now!!!
We have everything you need
Scripting config, scrolling layout, and anime girl wallpapers :kek:
that might've gotten it to work, atleast after a bare reboot rather than a poweroff
maybe its random too, who knows
Yayyyyy, really? :D
just edit the service file and config it to run after bypass service?
im not sure whats the purpose of the wait-online thing at all tbh
it doesnt seem useful on my setup
there's no point for network manager to start until all NICs are prepared
for example
Or, tell your DHCP client to boot after NIC is configured by the device drivers
I think it's more of a server thingy, because most set ups don't really need anything to wait to connect to the internet at startup, just servers.
Services that need an actual internet connection before they can start (like cloud backup daemons, etc.) declare After=network-online.target so they don't launch into a void. So, for me it kinda is basically useless.
@gleaming knoll this is a nice resouce https://systemd.io/NETWORK_ONLINE/
Which is the best?
start learning py from books or tuto videos
It really depends on what works best for you. I do best from something text based
!learn
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff β an online book (also available to purchase as a physical book)
- Harvardβs CS50P course β video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course β text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
Hey, has anyone ever coded anything in finance and quantitative finance? I have some question to ask about the topic!
ask your questions
Thanks
There's a few finance people here
Not very many quants tho
But no one can answer the question until you actually ask it
I was wondering if there are finance pads here, are you one of them by any chance?
pad?
Nope, I refuse to work with that many numbers
Thanks man
what game can i make as a beginner? ( in python)
Wsp
Guessing game
Mad Libs
Isnt guessing more simpler
if with numbers it's too easy, if with words that's just time consuming
U have to commit
twhat?
When people ask what they should implement to practice programming, I often say, Mad Libs. Itβs a game, so it might appeal to youthful minds, but itβs purely text-based, so it wonβt be overwhelming to implement.
yea but i'm suppose to code, not think of questions to put in quiz and putting lambdas one after another
Well it can be a secondary project
But I've never tried with words before
That's part of the programming
something like wordle would be fun and not time-consuming
true
It isnt only abt coding
hello
also makes you use and combine a number of early-stage concepts, so it's probably a good shout for a beginner
π
Well thanks for the idea
Libraries that went mad? 
yeah, like left-pad
What's the meaning of the name
!ban 1205209977052991598 racism
:incoming_envelope: :ok_hand: applied ban to @autumn kayak permanently.
pffft that was quick lol
now do i write it in normaly or with Tkinter
your wish
personally I don't like Tkinter π
Bruh
why?
the name derives from ad-libs
there are much better UI libraries for Python, there is no real reason to use Tkinter
ad-hoc?
first reason it's really easy
Well some people prefer it
Ohhhhh. Thanks. Learnt something new today
eh. I think the others (mainly Qt) aren't any harder.
that is true for almost anything
every day you learn something new
hello friends
at my age you forget something every day as well
I can't even remember a tkinter codeπ
Hi bipul
hello Aji Romson
1 gets in 1 gets out, fifo
says the guy who says "all people are nothing but tools" π₯ π
......
More like 1 and 3 by now
π€£
probably more LFU than FIFO
Is reading books like python crashcourse a good way to avoid the tutorial trap
oh true true, lifo
When we define class, it's actually object?
oh, you said lfu, i see, also correct
the way to avoid tutorial hell is by writing programs
classes are themselves objects, yes, but that can get confusing. it's ok to think of them as separate.
How do u know that yours writing the right thing
it's not about the kind of resource you use, it's actually about what you do outside the resource
i tried to create a lfu cache base (decorator) not long ago btw
you write it and see if it works. then you show it to others and get critique.
Some codes require understanding
also i found a problem, how do i print in 1 line 5 letters with some in different colors?
oh, I see what you thought.
I don't mean that you shouldn't read tutorials, not at all.
Ohk
I mean that whatever you read, the important thing is to make sure you're actually putting it into practice alongside the reading.
the important variable in avoiding tutorial hell etc. is whether or not you practice, not whether you read tutorials or books or watch videos
I can relate to that
https://github.com/textualize/rich would be useful
Spent a year watching only tutorials
i relied on dictionary being ordered
Okay
which, by the way, is why I think that the popularization of the term "tutorial hell" was a mistake
well i still didn't publish it so i won't give more details
way too many people just look at the name and come off with an entirely misguided fear
i think that its easier to just watch the tutorial videos
instead of downloading an ide, setting up a venv maybe
There is a default ordering for regular old dict, and that ordering is likely to never change, but that ordering shouldn't be relied upon. There is a OrderDict class in the stdlib that is there if you do want an ordered dictonary.
Well opinions differ
regular dicts are guaranteed to be insertion-ordered by the Python spec since 3.6
although, of course, insertion order might not be useful in your case
its not just an implementation detail iirc
its guarenteed to be ordered
I'm still not good with def
i think its objectively easier
watching videos is passive, actually writing code is active
whats easier:
a:
just watching youtubbe tutorials
bb:
watching tutorials and downloading an ide, creating a venv
but doesn't it mean everyone would have to install it first just to play my wordle/
also true
like, you dont need almost anything, to just watch the videos
I'm going to start learning python again from start
Why?
that probably (in my opinion) is the reasoning for the term "tutorial hell"
well, they would already have to install Python also.
as an alternative you can look up "ANSI escape codes for colors" and write them into your program manually.
Cuz there are some stuff I skipped
Isnt leetcode and the others also helpful
huh? for color text rendering?
-# /j
No, for developing skills
I get the reasoning
but I have seen so many beginners just look at the name, and they go away thinking that reading or watching materials labelled "tutorial" is a sin and they'll ruin their learning if they do that, or such nonsense. and then they're stuck because they don't know how to build anything that does real work, and they've disallowed themselves from using tutorials to learn.
I think your right, but I would have to look it up too. I didn't know its in the spec these days. Image all the thing that would break if they ever changed the default behavior from long long ago haha.
...but more importantly, relying on something that you have to guess about even if its in the spec is not a foundation I want to build on haha. But that is why OrderedDict exists. to make it explicit that ordering is important and relyed upon.
dict being insertion ordered has been in the spec since 3.7
I mean, for a narrow subset of programming skills. but if you are at the stage of "not good with def" as you said, I would suggest spending time on normal Python and building things with it before you grind Leetcode.
Hi, I'm Chris !
I used to learn many languages like The C family, HTML/CSS, Java, GdScript... But sadly, I can't really code and I want to learn python again.
Should I start from scratch?
Yh I agree
i see, makes sense i guess...
i think that for learning purposes tutorials can be fine as well, only if combined with actual active programming, as you've said
it's easier to just be passive, but eventually it leads to nothing
pretty recient all things considered π
!LEARN sure, why not?
Β» learn-python
Β» learn
!learn @soft coral sorry
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff β an online book (also available to purchase as a physical book)
- Harvardβs CS50P course β video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course β text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
What do people do since id is built-in? trailing underscore id_? but won't that feel 'hmmm nah' ?
if i am not wrong, id on types (User.id, Chat.id, SomeDbModelThatHasID.id) is popular?
Hii bye
not really, 3.7 is EOL since at least 2024
Hey Iβm reading some docs and ran into nested list comprehensions; have you guys ever encountered a real use case similar to: arr = [f"{i}{x}" for x in range(10) for i in range(x)]
id_ is fine.
huh, the fuzzy matcher doesn't do casefolding?
I have used patterns like this before myself more than a few times
Cs50 course is boring for me and I hate the 10hours + courses
you can still use id as an attribute
you've got a point i guess
there's other options in that list, too
May be its just me not feeling good about it
but that seems to me like a huge downpoint
slorb works, LEARN not smh
it's a common pattern so you'll be in good company
identity
Yeah, that overshadows built-in, though i like the idea of doing so and import builtins to regain the access as a trade-off, not sure if that's appropriate and recommended philosophy?
normally i'd use something else though
Programming ain't 4 me
π....My bad, i will stick to id_.
Coool, if I may ask for what ? Iβm trying to think of a real world example
!e no it doesn't
from dataclasses import dataclass
@dataclass
class Foo:
id: int
f = Foo(1234)
print(f, f.id, id(f))
Can't say until u try
:white_check_mark: Your 3.14 eval job has completed with return code 0.
Foo(id=1234) 1234 139878746204752
I am so sorry for asking, i just started 2 weeks ago. How hard is learning and mastering python. Kinda stuck at functions right
Don't try to make the smartest guy, I tried
that example unfolds into a nested loop that would be useful to create some kind of two-dimensional array.
.
for a custom class, with a param name as id will overshadow, right? 
Programming is not easy, Python isn't that bad. It'll take effort but it's not crazy difficult
you just said you wanted to get back into programming.
I still find learning python hard but I still try
if only they'd call it check_id
nope, it's in the class namespace, doesn't overshadow anything
get_id
#python-discussion message "I want to learn python again." this is your exact words.
id_of
So when we create instance from class, p1 = Product() Are we are assigning class object ? to variable p1? or some new object being created which is referance to class object?
Did you mean to make it rhyme at the end?
Yeah sql was way easier then python. Mind u this is my first real programm.
What do you say about this?
let us overshadow the built-in names, tell linters to disable inspection on this particular, and import builtins to regain the access?
I like this idea
lol I very much didn't
ok but why others programming languages tutorial aren't longer?
Lazy
A class is like a blueprint. When we do Product(), it is the actual construct of that blueprint
other programming languages have tutorials at least this long or longer.
they're just presented differently.
No
Product is the blueprint. Product() is the constructed object
I ain't
Some other tutorials focus on stuff specific to the language, not programming in general. The new-to-programming-and-python resources we have are longer because they also teach fundamental concepts like loops
Does not it's like function callable? and your calling something
@Helpers Hey, can I learn to code python here?
Hardworking = "success"
@soft coral ok, you need to tell us what you actually want, then.
CS50 is structured as a college-level introduction to Computer Science. so it is in the format of hour-long lectures and exercises.
there are other tutorials, with other formats.
yea but they are better and faster than python
then go learn one of those languages? you can learn anything you want.
It's nothing like a function, they just happen to share the calling syntax
Awesome thanks @pastel sluice !
I want to make games
You don't have to learn Python, but if you do want to learn Python we're here!
I am talking about cases such as this:
>>> class A:
... def __init__(self, id: int) -> None:
... self.id = id(id) # suppose i needed memor\
y address? not a good example i know!
...
I know the probability of such cases diffs but its not zero.
I want to learn
There's unity, godot, unreal and others
make the arg name id_, but the attr name id
Annoying = "Kiyotaka"
let's not please, we can be nice
But I can't really code
Why not use the hash value of the object as the UUID ?
Me too π but try
@soft coral no matter what language you pick or what kinds of programs you want to write, you'll have to learn how things work in some form.
Godot is pretty friendly and you can probably learn to code while you learn godot if you're specifically interested in games
you can do
self.id = __builtins__.id(id)
in this weird case
why complicate that much lmao
Nobody could code before they learned how to code. We all started from nothing.
if you don't like CS50, again, there are many other tutorials in different formats.
The Python MOOC 2026 is text-based, for example. Automate the Boring Stuff is a literal book.
@soft coral
Why is everyone says the same thing?
Is __builtins__ guaranteed to be always present?
yep
Lol sorry Iβm not sure what the context is rn
that's cool then
because she's correct
... because it's true? Like, this is just the reality of the situation
Bro the heck I know many languages
check_id = id
class A:
def __init__(self, id: int) -> None:
self.id = check_id(id) # suppose i needed memor\
Actually my mom was a programmer
Hi Shoomp :D
But also if you're interested in games specifically, I would especially take advice from Fashoomp. It's kinda his area. Also Infini has made some cool games
what are you here for?
And she probably didn't know how to code before she leaned how to code either
something like```py
class A:
def init(self, id_):
self.id = id(id_)
heyo
Right itβs a joke relax π
Bcz I can't code idk what I have
Well, how are you supposed to know something before you learn that something?
That's exactly my point
The resources we gave you will teach you how to code.
What was the joke?
The context is, id is a built-in name of python, but in lots of programs, id is a common name and could collide with the built-in id function and overshadow it. The suggested workaround is a trailing underscore after the name id + _ = id_. i kind of think it is not so pleasing (at least to me). So i was wondering how people work around it.
I think you are going to find some weird edge cases where you dont want to link the internal object id with internal python object id. If you need the id to be unique I would suggest the uuid class.
Hey.
I consider myself being PRETTY dumb. And even I am doing my best to learn how to code. Thanks to my efforts and the help of people at pydis, like shoomp, I've been able to create amazing stuff. ;)
Give it a try, if you truly are interested, you'd be surprised of what you can make with your own hands and mind.
What are we trying to do with this Id thing ?
U tried
wrong reply?
I've tried many fucking times
sorry I think it might have been the last one in that class id chain.
Both uses callable protocol; The parser does not apply a special grammar rule for classes versus functions when it encounters ()
Whats the difference between the internal object id and pythons internal object id i thought they were the same ?
π
What abt a 30mins vid that teaches you the basics
can just use uuid instead, but i don't use the builtin id so much that it would prevent me from naming some class attribute id
i think it's very rare to want your own id variable and also need the id() built-in.
Bro are you Satan?
What did you try exactly?
What did you make when trying?
What stopped you?
Yes. With things like strings and ints, we have the advantage of literals to make new objects. With custom classes, we use the calling syntax. We could still use it for builtins too. I can do int() to get 0. I can do list() to make a new empty list.
no me
Guys does it count if i type with my screen facing away and call it backend development
I donβt think satan would be that helpful tbh
Ummm
I am not good enough to do backend, I prefer fronted :kek:
Isnβt there a built in id like the hash object or something like that ?
hash and id are different things
Exactly. Classes are semantically different from functions, but they participate in the same callable execution model.
i wonder if the hash of a number is the same object as the original number...
Yeah, agreed; although it's rare, but chances are not zero. So I'm wondering in those cases, i would need to use the trailing underscore convention (id_) but i kind of don't like it.
I thought about the idea, let it overshadow the built-in id() and import builtins (or use dunder builtins) to access the built-in id(). I'd like to know your opinion on this idea.
if its under 2^31
there is the id that is the attribute to an instance of that class in your example, and id that python automatically generates and assigns somewhere to the internals of the class.
for the cached integers at least this should be true
for 2**31 it is not
Either could do the job I guess it depends what the use case where dealing with ?
How would you make a loop to make this shorter:
pi = [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9]
print(pi[0])
print(pi[1])
print(pi[2])
print(pi[3])
print(pi[4])
print(pi[5])
print(pi[6])
print(pi[7])
print(pi[8])
print(pi[9])
print(pi[10])
print(pi[11])
print(pi[12])
print(pi[13])
print(pi[14])
do you know how to use a for loop?
you can try a for loop
a = 5000
b = hash(a)
print(a is b) # False
wouldn't you do == ?
Uh noβ¦
equality and identity are not the same thing
The point is that it doesn't reuse the object. They are equal but not the same object
everytime you hash an integer it creates an object, wtf
waste of memory and performance
Oh i see. I was lost at context
in a set for every number there are 2 slots taken (its hash an the actual number)
Yeah ik, i didn't understand the context earlier
if you want I could teach you
56 bytes for every number in a set
just wait until you see what is the hash of -2 and -1
strongly linking the two will likely cause problems later in testing or around the assumptions that the internal python object id will always be unique. I'm unsure if that would be the case around threads, but its super likely it wont be true across processes i think.
why hash an int, it's already its hash
Ok
I'm pretty sure the hash is stored as a native integer. There's no reason to keep the hash as a Python int
Right equality being == and identity being βisβ; identity being the type and equality considering the specifics values ?
possible i guess
identity isn't the type, it's the object found at a specific memory
ints are not 56 bytes, and the internal hash doesn't end up being a Python int.
for 0-2^31 its true
Thatβs why data centers === no heating in winter
28*2 i did, but i understand that the internal hash is not using a python int
i see
hashing an int is checked in set for example, or on equality i guess
ned, when did you change colors
(a 64-bit int actually takes up to 36 bytes, not 28)
Interesting, like when you go beyond the GIl you can ran into these issue in multithreading apps ?
except I'm not there anymore!
definitely the object id can differ across processes. It's not a permanent thing.
Whats the hash of the hashes intβs ?
!e
print(10, hash(10), hash(hash(10)), hash(hash(hash(10))))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
10 10 10 10
why's that
Just a example where the mental models might not match up. And a case where you will find out after that class is loadbearing in your system and it will be hard to discover that is the issue and pretty hard to fix.
Maybe thereβs difference definitions for levels of abs cause the match case logic matches singletons True False by identity meaning the type right ?
Coool
same hash, interestingf
:)
exactly
π
Production products
Idk why "production ready" and phrases like that always seem funny to me
all you do is copy paste this every few days
you've said that a few times. Why are you telling us?
yessss
Me too
buzzword buzzword buzzword
there is no answer or reply to my message in couple days, lol
What do they keep saying
what answer do you expect?
what he said
Well it is deleted so im guessing a spam wall
if only i had the power of the mods to see deleted messages...
no I deleted it
if only i had the power of mods to react with emojis.
not quite a wall, but a standard "I specialize in [...] integrating AI and LLMs [...] production" self-promo
I don't think I understand. I think of the id you get back from the global id function like a memory address(I'm not sure if its an actual memory address)
But if I need to make a class that had a unquie id attribute I would do something like
@dataclass
... class Foo:
... id: str = uuid4()
...f = Foo()
f.id
UUID('68b90467-369b-4f39-a81b-4379c9ef6533')
id(f)
127181685461008
ya have your pick of like 8 uuid function. some are guaranteed to be unique some or just really really likely. some leak sensitive info.
there's no answer because we think you are looking for a job or a contract, and that's not allowed on this server.
this is not the place to look for job btw
Help ive seen that everywhere and it sounds like something ai bros or vibecoders would say
it is lol
thank you for your answer, I didn't know about that
Go look on LikedIn or something like that
strange, it's in the rules you agreed to when you joined.
!rule pay
you will have better chances of getting one outside of discord itself
At first i thought vibecoding was just being lazy and coding while watching netflix or something
i decided to use discord instead of AI, How to check if entry output (from tkinter) is of length 5 and then remove it?
But yeah using ai and not even checking it is crazy
Can I offer to pay with hugs if someone helps me at #1035199133436354600 ? 
int uses 30-bit digits, 64 doesn't fit in two thirties
someone will help, invest your hugs into something profitable
post your question
so make it 60 not 64
"invest your hugs" amazing line. π
you know my people, we are pretty good with financial stuff
That twisted quickly 
in 32 it uses 30, in 64 it can use 60
2**60-1 takes 32 bytes, 2**61-1 takes 36
uh i see, so its up to 30, then up to 60, etc
so there is also 60 bits used, until 2*60-1
most of the range of 64 bits
nooooooo, the linux mirror at github has disabled PRs. one of the funniest PRs was deleted. it was a guy fixing a "typo" and made a pr to make everything from long long -> long
Github uses Java..?
they should've made it loong instead of long long
I thought it was mostly written in Ruby
longong
and u128 would be looong
Ruby has long longs?
"had" π
I thought Ruby didn't have explicit static typing
Bananabun is talking about the Linux repo
correct
torvals/linux
Aura π£οΈ π₯
there were so many funny PRs there
Oh. They use long long instead of fixed width integers in the repository? Interesting
float i think 
long long is definitely not a float
Long long is an integer that's meant to be larger than a long int
then my next guess is A VERY LONGGGGG NUMBER
Guys i have my leaving cert computer science exam tomorrow it has a section C python based part where u have t9 code any tips
Ik the basics n like to use tab instead of space
But since it's C++ there's no guarantees on integer sizes
pretty descriptive
have you been studying python?
Yes a bit i wont lie n say it have a lot but I have
Ik loops n all but I still dont understand how functions work
https://web.archive.org/web/20260129030213/https://github.com/torvalds/linux/pull/1290
This is not the one I was talking about, but still funny
i'm not sure we can get you up to speed for an exam tomorrow.
my rec is to try doing as many problems as you can from: https://codingbat.com/python
Oh lol damn
Bet thank you
Yeah in modern C/C++ you don't really see it.. C and C++ don't guarantee the sizes of integers (it just has guaranteed minimum sizes relative to the smaller types). So an int on one system could be 64 bits, but could be 32 bits on another system.
o
can sm1 recommend a project to do as a python beginner
!print-return-gif
what exactly is ned?
@ nedbat
very_long
!kind
The Kindling projects page contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
longest
okay thankyou
long longest
The reason why varies due to CPUs and operating systems. It's convoluted. That's why we use fixed width integers instead (uint32_t for unsigned 32 bit int for example)
π
And someone said it's better to learn with low level instead of high level langs, what a dumb person... This sounds complicated.
i've heard this argument. I think the point is it helps you learn to build from the gorund up.
longest longest
#define tall int
#define grande long int
#define venti long long int
coffeescript
i claimed in here that i didn't understand C# correctly until i've learnt C
C++ is extremely large. Many people just use subsets of the language because of how vast it is. C grants more explicit control without abstraction, but has fewer niceties
thinking about it, in github issues, people tend to be nicer, compared to stackoverflow
High level is better for learning because you have simpler stuff to learn, and it's easier to digest.
there are complicated things at all levels and languages
perhaps. I have yet to see studies eitherway. Nevertheless, I learned python first (well, technically C++, but that was a mistake) and thought it was fun so I'm fine with whatever if that makes sense.
do you consider C# as higher level than C
yes
C# is closer to Java than C.
anything that is not asm is higher than C I believe
I consider C# a language. I don't know anything about it, just that C is preeeeetty low.
What about C--, or LLVM?
C--? π
well, i tell you that C# was hard for me, compared to C
C# was my first language, C second iirc
that doesn't imply that it's low-level though
Haskell Backend (iirc)
it implies in my opinion that higher level for first language not necessarily means easier
yeah, they are lower
I don't know anything about it. I can't compare it with anything.
oh, sure. I can agree with that.
it's great for beginners
It's amazing
It made me understand programming basics. :D
the thing with python is that it's not pushing you to use classes and namespaces
and letting you progress at your own pace, without many strict rules preventing you from starting
yeah
it's high-level, has easy-to-read syntax, not much boilerplate, and can do a ton of practical things due to its ecosystem
I just read up on classes
yea
What are namespaces
!zen namespaces
Namespaces are one honking great idea -- let's do more of those!
what π
its hard for me to define it
namespaces let you group names into a single entity, so something like a module acts as a namespace for everything defined inside it.
literally, a space for holding names.
a module in python for example, yea
Oh
dude... only now i understand not gonna lie
name - spaces, spaces for names
So like, a class and its methods count too?
yep
Yay
in python anything you do . is namespaces forwarding, if you understand what i'm saying
on names i mean
not 5.14
Okay yeah...
its a bit complicated topic though
basically it's regarding namespaces, what object you get in return, when you call for a name
Andrej Karpathy is joining anthropic 
who's that
AI researcher
openAI co-founder
i see

you need to stop using the class keyword for a while

is karpathy skills by chance related to this guy? heard of it
What is that
._.
Elaborate, please
Ever wonder how your instance methods get self implicitly without having you explicitly pass it?
_._
yea also part of the descriptor protocol
Ever wonder how @property makes a function an attribute without calling by () ?
you know quite a lot about the descriptor protocol
Why do you think i do not
thats right, property also uses it
Sure does
i didn't say u dont ._.
I just bad at explaining π
That's right 
_._
I know stuff but hard to explain, it just floats in my brain without language form
its an interesting topic indeed
if i'd show you an example, i dont think you'd understand it
or anyone else other than you
Hi
you need to learn it properly, in my opinion, in order to understand it
I forgot how the lookup for that happens
But the first time i learnt about it and used it β it was a beautiful experience of such a phenomenon
<@&831776746206265384> hey, where do we learn python guys?
please do not ping moderators for things like this...
You were told earlier to only ping that role if you need Moderator assistance
Well it can't get any weirder
!learn
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff β an online book (also available to purchase as a physical book)
- Harvardβs CS50P course β video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course β text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
!mute @tawdry bolt "3 days" maliciously pinging moderators
:incoming_envelope: :ok_hand: applied timeout to @tawdry bolt until <t:1779476629:f> (3 days).
IIRC, Because the function implements dunder get, the dunder get gets two positional parameters (instance: object | None, owner = None (basically the class/type)) which wraps the original function and pass it
i'm thinking about a simple example
do you know of decorators?
Yes
@tawdry bolt in case you didn't realize, this isn't a funny joke. Moderators get dozens of pings a day and your behavior contributes to mod burnout.
https://docs.python.org/3/howto/descriptor.html
Lemme read from here and try to teach
I don't really know how to write them properly, but I kinda know what they do.
Well that would surely teach him a lesson
@raven urchin i think this explains quite goodly
What do you mean by weird
Let's see
Nothing
Might also have lookup and other technical details which is good to know to understand
hi
π
hi the ultimate lifeform but faster
Yeah, "nothing".
Just like... All people are nothing but tools.
Hmmmm
Winning is everything
That's why I'm gonna win
class my_property:
def __init__(self, fn):
self.fn = fn
def __get__(self, instance, owner):
return self.fn(instance)
class a:
def __init__(self, name):
self.name = name
@my_property
def get_name(self):
return self.name
a_instance = a("jason")
print(a_instance.get_name)
With a dataclass, if I define a __post_init__ method, does that code run as part of the call to __init__?
In my use-case, the __post_init__ does some validation to make sure that the class is set up correctly, and raises an exception if not.
If I try/catch the call to MyClass(foo, bar, baz), I'll catch exceptions raised in __post_init__, right?
watch this, my_property is a simple implementation of a property
print("Hello, world!")
Age thing
it runs after init finishes
oohhhhh, that's really cool. I didn't know classes could be decorators.
when doing @my_property its like doing my_property(get_name), so it creates a property object
why the topic changed lmao
It runs after it runs as part of the __init__ finishes, as Robin says__init__. Calling MyClass() will raise all exceptions that __post_init__ raises
+1, and also instance can be None so you gotta have to account for when instance is None if i am not wrong
decorator is only a sugar syntax for : @a instead of a(b)
Anything that is Callable can be used as a decorator
yea thats correct, it can be None if its not called from an instance
Yup!
^pretty much
this calculator https://paste.pythondiscord.com/46IQ
decorators are syntactic sugar for:
@deco
def func():
pass
func = deco(func)
where deco can be anything callable
When defined on the class, it will be called by the generated
__init__(), normally asself.__post_init__()
hm
!e
from dataclasses import dataclass
@dataclass
class Foo:
field: object
def __post_init__(self):
print("post_init")
class Bar(Foo):
def __init__(self):
print("evil init that doesn't call __post_init++")
print("calling Foo")
Foo(1)
print("calling Bar")
Bar()
If i am already familiar with data science what i can start learning
Flask or node js for the backend
Me don't like those questions lol
I see, I thought it worked just for funcs
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | calling Foo
002 | post_init
003 | calling Bar
004 | evil init that doesn't call __post_init++
so after the my_property object is created, it gets fn with the inserted function
then on get it calls it with instance being the self of that function
Mine was simpler
post_init should exist for every object not gonna lie
its very useful
sadge it isn't
Why?
mainly for subclasses
it does have some self-deprecation that i kind of still agree with
of course (to the first message)
You can do it with a function, but sometimes it's easier with a class.
Lib/functools.py line 1021
class singledispatchmethod:```
Why u asking
say you want to add some logic to init, you're fucked
Cause I haven't heard anyone who does recently
yes
must implement init, with all arguments, call super
no
No I use butterfly
ik that reference!
and if there're overloads, you're fucked even more
damn it no embed perms
need to include all those in your class
Well see ya
Many people here program by themselves, or using AI as an aid, not as the main programming tool.
I see
Yh I use it for something stuff I don't understand
post_init should be for all classes to avoid this shitty problem
Maybe the people I work wit are different after all
and get is triggered when you look for that name, in that namespace
post init is a dataclass specific
There is still enormous number of people who program on their own
a_instance.get_name
^namespace ^name
That's definitely a self-inflicted problem with type hints. *args, **kwargs has existed since Python 2.0 and works just fine.
I see, now I kinda want to try :)
Source?
yea thats pretty much stupid
#bot-commands
Many of them are right here in the server talking to you
why?
what has that to do with anything i said
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# do what you would do in __post_init__
because only dataclas has it
that ruins the signature
are you for real
the whole point of __init__ is to initialize the object. dataclasses generates the __init__ for you

yea but post_init is still useful
normal classes have __init__ what's the point of having __post_init__ for hand written classes?
the idea of it
wyou can type kwargs at least wtih typeddict now
why?
for subbclasses mainly
dude i explained it all like 5 messages ago
It is a bit annoying, but since the superclass is specified right there, you can just go to the superclass and see the actual signature.
create an abc with a setup method
Why do other programming languages need new keyword to create a new of a object?
in python, dunder new is called by type's dunder call i guess?
There are also companies that simply can't allow an external AI-product to be used internally for producing code due to various regulations or policies, because it's a risk factor. In those cases they might I guess self-host an LLM, but I wouldn't know about that, I have heard somewhere that some companies do do that however.
...
I kind of confused
how
that's just how the other languages are. a conscious decision was made not to need that in Python.
what was your method for surveying all developers?
Ohh
I'm still not sure what the problem is, if we ignore type checking concerns.
maybe you'd wrap init to call it after its finished or something...
The people around me and in the previous firm
also because of python's brand of duck typing
it makes it really easy, classes are callable
thats the problem basically, a problem that shouldn't exist, dataclass already solved it
so you can call them
from abc import ABCMeta, abstractmethod
class MyMeta(metaclass=ABCMeta):
@abstractmethod
def setup():
pass
i see, not what i thought of though
That's what I meant: it was a totally fine solution, but then type checking came along and made it a bad solution because they didn't add anything to automatically forward a signature.
post_init
Then it would be required for any class the inherit MyMeta to define it's own setup method
solved
So now we need a runtime solution to a type checking inflicted problem.
why not though
The lack of underscore between abstract and method is concerning me 
generally if it's a 2-word phrase and not hard to understand at a glance it's fine to not use a _ between words. I think abstractmethod is pushing it by length alone, but...
go for it!

I don't have any ideas on what to make with it
We could instead fix the core issue and add something for forwarding *args, **kwargs. For example: if @typing.override is applied to a function with *args, **kwargs, then they are not assumed to be Any and Any, but rather to be the arguments to the parent method. This would also fix the same issue for methods other than __init__, along with not adding more stuff to the language.
I saw a cool example on the docs about a DirectorySize
that would just make it uglier to be fair, but a possibble solution
I write for a publication that is aimed at enterprise software developers. There's a lot of interest in AI for writing software, no question about it. There is also at least as much skepticism about it, and serious questions about how sustainable the whole practice is, and discussions around how generating tons of code on demand is actually a net burden and not an asset
its more of a solution if u need the arguments
but if you dont need the arguments, post_init is a pretty solid option
Iβm actually getting rage baited by type checkers right now. I try to write some nice clean match code, no type checker supports the narrowing. I try to write it using explicit instance checks, still no support. I end up having it write it in a much less clear form.
how generating tons of code on demand is actually a net burden and not an asset
Getting rage baited by a type checker? Lmao
make a cached property
Not just a type checker, all of them
Cached property?
Could u show the code with issue?
!doc functools.cached_property see also
@functools.cached_property(func)```
Transform a method of a class into a property whose value is computed once and then cached as a normal attribute for the life of the instance. Similar to [`property()`](https://docs.python.org/3/library/functions.html#property), with the addition of caching. Useful for expensive computed properties of instances that are otherwise effectively immutable.
Example...
a property that calculates the value once, and returns it from that point forward
!d functools.cached_property
@functools.cached_property(func)```
Transform a method of a class into a property whose value is computed once and then cached as a normal attribute for the life of the instance. Similar to [`property()`](https://docs.python.org/3/library/functions.html#property), with the addition of caching. Useful for expensive computed properties of instances that are otherwise effectively immutable.
Example...

Ohhhh, so like pop() for an attribute?
But without yanking it out
not really
a post_init with args and kwargs is also a valid option not gonna lie
What kind of narrowing? iirc match-case is good for exhaustive narrowing? We also have typing.assert_never() i think an example would be better

although that makes it less clean^
It's like
I think cached_property doesn't work for frozen dataclasses? Idk i think i had an issue once...
init gets the same arguments new is getting, its not a big stretch for post_init to get those arguments as well
think of it like this:
cache = {}
def my_propery():
if "res" in cache:
return cache["res"]
res = heavy_function()
cache["res"] = res
return res
it should. but will not work if you have __slots__
Oh i see, i did had slots=True
because defining __slots__ means that you have no __dict__
Well, I got more confused lol
imagine we have a very computation intensive function, instead of returning the result right away, we "memorize" which arguments returns which values, so if we get called again with the same arguments
cache is a dict
my property returns the "res" of cache if "res" is in cache
res = heavy func
cache["res"] is then set to res
and returns res?
i just realized something... i might be wrong about it, but i think i'm correct
we could just return our cached value, and no need to calculate something heavy again
there's a default for metaclass call....
it calls the new and then init
what if you override call (to also call post init if it exists)
(Also I realized fail_2 should have the not removed but the lack of narrowing is the same anyways)
Yeah, I get it that way, but I don't really get how you wrote it. Let me try it myself...
another option is for it to always exist
how to screen share please ? I want to go over python docs in VC0
and to always call it
23 should be just or instead or not if i am not wrong
And i don't think type checker is wrong? It just cannot prove that for first case the .content will be definitely a string
Can it?

For the first one? It should be. Either itβs ItemToken + content str, or StringToken, which is content str by default.
ItemToken(str()) never used like this, i haven't tried for attributes
It is a valid match usage at runtime: ```pycon
from dataclasses import dataclass
...
... @dataclass
... class A:
... item: int | str
...
... def foo(a: A):
... match a:
... case A(int()):
... print("int", a.item)
... case _:
... print("str", a.item)
...
foo(A(1))
int 1
foo(A("a"))
str a
I see
!e ```py
from dataclasses import dataclass
Item = int | str
@dataclass
class A:
item: Item
second: str
def foo(a: A):
match a:
case A(int()):
print("int", a.item)
case _:
print("str", a.item)
print(foo(A(1, "b")))
print(foo(A("a", "b")))
None?
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | int 1
002 | None
003 | str a
004 | None
No? You donβt need to provide every entry in a match, your first code worked as expected/the same as the second
yeah I misread the answer
Oof
Yeah so I guess it works fine
So, type checkers just don't do that I guess
it might be an intersection of the dynamic dataclass support and match narrowing
Which is major levels of bullying
does the same fail typechecking if you've manually written __init__?
The equivalent manual isinstance testing also doesnβt work, so I donβt think so
Can one mutate a mutable object inside a tuple ?
yes
so where is the tuple being inmutable line drawn
you can't add/remove/reassign elements of the tuple itself
but you could reasign an element in a list thats nested inside a tuple ?
sure
Don't think of tuples and lists as containers of objects, but of references to objects.
you can think of it as, the tuple only cares that the references it holds do not change
the objects being referred can change however they want
wouldn't that change the tuple ? thus being a mutated tuple not the same tuple as before?
from the tuple's perspective, it is still referring to the same objects at any point. but you're right. a deepcopy of the tuple at one point in time may not compare equal to a deepcopy at a different point in time.
so it just holds an identity check guard for it's immutability definition ?
When you have an object, and you change something about its internal state, it's still the same object in memory. The tuple only cares that it's the same object
There's no identity check, you just can't assign to elements after creating the tuple
well, imagine if you have a kid, and your kid just change their clothes, is your kid a new person?
not really. more like, it is immutable (in the tuple sense) by construction. what I mean by that is, it simply does not allow reassignment, and does not have any methods to append or delete or insert elements.
hah good one
ye, imagine tuple as something like that
i.e. tuple.__setitem__ and tuple.__delitem__ always throw an error, and there is no such method as tuple.append, etc.
It's the same tuple of references as before. That's the sense in which it's immutable.
so, there are no simply no allowed means for you to modify the tuple in the senses it cares about
!e
a = "Hello"
b = (a,)
b[0] = a
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m3[0m, in [35m<module>[0m
003 | [31mb[0m[1;31m[0][0m = a
004 | [31m~[0m[1;31m^^^[0m
005 | [1;35mTypeError[0m: [35m'tuple' object does not support item assignment[0m
Doesn't work, doesn't matter what you're assigning
right so as long as it hold the references to the same objects its still my child
This is the simplest guessing game ever
import random
while True:
number = int (input("Enter your guess:"))
dice = random.randint(1,10)
if number == dice:
print ("Congrats")
break
else:
print (" sorry")
the objects may mutate there states but the references stay the same thus mutable elements in a tuple can be mutated
yup, love your child
there's no need fot the else, but yeah. pretty good one
If you think about it, there's no way for the tuple to know a mutable object inside has changed, and the mutable object has no way to know it's inside some tuple
tuples could have disallowed mutable members in the same way that sets/dicts do, but idk if that would have been a good idea
probably not?
imagine someone doing 1 2 3 4 5 6 7 8 9 10 and they never win because its changing each time
sigh I upgraded to windows 11 and now the 8 versions of Python I installed in the past 6 years no longer work
Lol
Quick sanity question. Will continue allow the program to progress to write_06H_register() or go back to the top of the try block?
def input_06H_register():
while True:
try:
register = int(input("Register (decimal or 0x hex): "), 0)
value = int(input("Value (decimal or 0x hex): "), 0)
controller_id = int(input("Controller ID (1-32): "), 0)
if not (1 <= controller_id <= 32):
print("Invalid controller ID! Must be 1-32.")
continue
write_06H_register(
register,
value,
controller_id)
Is there a way to make tuples mutable
yes, turn them into a list
continue goes to the loop header
yes, but it's involving some ctypes dark magic
oh interesting so some data types have some level of awareness?
continue goes back to while condition to check if condition is True and if True it starts from top of while loop, if condition is False, it exits while loop
seems like windows is the problem tbh hah
Ah alright. I guess that's kind of weird when it's named 'continue'. But it functions as I want it to then
continue as in "abandon the current iteration and continue to the next one"
You'd need to implement a very specific mechanism for very specific classes to allow them to communicate like that. It's technically feasible, but not something you'll have unless you go out of your way to make it happen
That makes more sense
the magic in question: ctypes.cast(id(tup)+().__sizeof__(), ctypes.POINTER(ctypes.py_object))[idx] = value
oh very cool, is there a specific real world use case where this would be great or just some fun?
a magician never tells it's secrets (you just did)
