#python-discussion
1 messages · Page 28 of 1
so how would u cache whatever u want to cache
create a list or a dictionary for 1 item?
that raises a question: why cache in the first place?
i dont like the unique as a decorator though
but i do like the:
class a:
b = unique(1)
way
bruh how i can make a key that is identical if its
a,b
or
b,a
🤔 beside using a set or sorting tuple
what u mean
what's the problem with sorting?
whats the probblem with set
(frozenset in that case)
https://discord.com/channels/267624335836053506/1441467212631248896
any feedback is welcomed
you need some way to know they are equal / order them, so why not set or sorting?
at mtn
how would i get a microbit to communicate with a pico w
hi jay whatsup
that's it?
no but help me with it
i don't understand the problem description
Anyone having problems with Selenium after the chrome driver update?
it sometimes works, sometimes doesnt
class a:
b = 1
a.b = 2
print(a.b) # prints 2
class c(a):
...
print(c.b) # prints 2
the idea is that to make a.b be 2, but after subclassing a, it'd be the initial value (1)
so i came up with a function named unique, which is abusing set_name
it'd a descriptor
what's set name again?
set name is getting the class and the name of the variable after the class' creation
in class Cls, name = descriptor does type(descriptor).__set_name__(descriptor, Cls, "name")
after class' creation^
i mean, yeah, Cls has to exist to be passed
class dict2[K, V]:
def __init__(self) -> None:
self.d: dict[tuple[K, K], V] = {}
def __getitem__(self, k: tuple[K, K]) -> V:
d = self.d
if k in d: return d[k]
return d[(k[1], k[0])]
def __setitem__(self, k: tuple[K, K], v: V) -> None:
d = self.d
if k in d:
d[k] = v
return
d[(k[1], k[0])] = v
could do something like this, i guess
not sorting the tuple, just trying both orders
that at set_name the class exists
so i can change it in whatever way i want to
(and i also know the value of the name)
so basically i have everything
and set_name would likely not run more than once so, its not effecting the afterwards usage
kind of interesting the ways u can use set_name
Im new to python :3
Spent over an hour working on a metaclass so I could avoid having to change every subclass.
Only problem is that using the metaclass requires that I change every subclass.
libcst to the rescue
The issue is more that I picked the wrong solution to the problem I had :P
I didn't need a metaclass and it's not really adding enough value to justify its existence. The value add being automagic attributes without having to change how the user interacts with the subclasses
And I don't like this class in the first place so I should really be doing the minimum needed to add the functionality I need
yeah, metaclasses are rarely the way
How detailed do I want to get :P
The subclasses have attributes and types associated with those attributes.
class Base:
Types: dict[str, type]
class Foo(Base):
Foo = "foo"
Types = {Foo: str}
Now maybe this is a crime in itself. That aside, the things that bugged me and prompted me to reach for metaclass are that the associated types are separate from the declaration of the attribute, adding a new attribute in the subclass requires updating a separate part of the class, and adding an attribute in Base would mean that every subclass now needs to know what Base did so it can manually add to the Type dictionary.
My thought was to have Base derive from a metaclass so that it can generate that dictionary.
And by doing that, it would let the derived class define the attribute and associated type together
class Foo(Base):
Foo = ("foo", str)
hi
!e what about type annotations? ```py
class Foo:
Foo: str = 'foo'
print(Foo.annotations)
import typing
print(typing.get_type_hints(Foo))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | {'Foo': <class 'str'>}
002 | {'Foo': <class 'str'>}
I picked a bad example, it's not saying that Foo is of type str but that if you wanted to create a Foo, you would create a str. This would be just as valid
class Bar(Base):
Bar = "bar"
Types = {Bar: int}
bar = Bar.Types("bar")() # bar: int
It's basically a factory.
ah, I see
is there anyway to get a microbit to communicate with a pico w wirelessly
The actual types would be message types, so the point of this class is to determine how to unpack that message.
I suppose that's why the attribute has the same name as the class then?
That's because I'm lazy :P
ah lol
Hello Guys my name is alon and am trying to learn def thing is python i dont really get it is there someone can help me?
what are you stuck on
Slightly more complicated example
class Messages(MessageBase):
Status = "status"
Request = "Request"
Types = {Status: StatusMessage, Request: RequestMessage}
the whole thing or just a small part
def user(name): print(f"hello {name}") print(f"hello {name} What is your server?") input = "My server is alon" user("user")
I'm also not using the exact naming scheme here, it was just enough to make the point I wanted to make. I know that removing context makes it harder to understand these things :P
How do i actully tell him that there is speffic server that his allowed to pass
I dont want the stright answers since i could ask GPT but i want the way of how doing it
How do you guys train your python?
like what test projects you'd do to improve yourself in python?
have you learned about if statements?
I was telling you and home party people invite
do a list of people names and tell who allowd and who is not that really nice
def linear_search(x, l):
for i in l:
if i == x:
return l.index(i)
can you call this a linear search algorithm? i got into a big argument with my cs teacher because she said it is
hmmm Like if user =! print("true")
Smth like that?
Not really if you asking me
I guess it's still linear search, just..... twice, and while not wrong wrong, still wrong
,_,?
also why would you write linear search as a function in the first place if you are allowed to use .index
our cs teacher isnt very good at her job
in an exam once she gave a predict the output question and the snippet had an error so i put down error as the answer
she didnt give me the mark because she didnt mean to put the error there
okay mine was bad but not to that extent 😭
nothing you can do about it
also which books are you guys using? (please tell me it's anything other than the sumita arora ones)
sumita arora 🤗
is that some local indian teaching books
known to be bad but still used
you probably should have written down what the output shouldve been
it was an mcq and error was one of the options
oof
what would you call it?
i dont even know
would you say that it is searching. perhaps in a linear manner
i would
it's not egregiously bad but still enough stuff that is wrong/wrong-adjacent enough times for me to hate them
no because his algorithm itself isnt doing the searching
.index is doing the searching
I mean both of them are doing the searching
what about the for loop
its redundant
the algorithm is indeed searching for when i == x
It's a (bad) linear search algorithm
yes, but if you wanna get into time complexity it's still O(n) - so in that sense it's still linear
It does redundant work but it still searches linearly
sure but the context here is that shes introducing what a linear search algorithm looks like
claiming that that is a correct implementation of linear search is misleading
It's shit teaching for sure, but not necessarily wrong per se
^ again, not wrong wrong, but still... wrong
what do you mean by "correct implementation"? it is a search algorithm, it is linear in asymptotic complexity, and the code will run and work
its not the standard definition of a linear search
why not?
the standard includes going through each position and return the current position when the elem is found
isn't it?
is that not what the code is doing?
its going through each element rather than each position
same difference
that is a trivial distinction tbh, and in python you would rarely ever go through each position
I feel like we're getting dragged into the wrong topic, bottom line is,
you're wrong because it still counts as linear search - all it needs to do search, and be linear - both of which it does
and the teacher probably should not use this as an example for the reason than .index itself is a linear search
in fact, going through each position is often considered an antipattern in python
what the teacher is showing is a poor linear search, but a linear search nonetheless
that python lets you do for x in my_list instead of for i in range(len(my_list)) has nothing to do with it being a linear search or not
position is certainly not correct, though. you can linear search things that don't even have positions
fair enough
linear search only means you're comparing each item in a collection one at a time. how exactly you do that is a separate thing
it is incredibly vague. you just need to search linearly
better to distinguish abstractions from concrete implementations now, because you'll bump against this wall again when distinguishing abstract data classes vs data structures
cuz it just so happens python's list is also a stack
better hide from the popo
collections.deque crying in the corner
y = x satisfies y = mx + b
It's called a linear search because the worst case complexity makes a line if you graph it.
satisfies is the wrong term here
well, whatever the right term is
yeah, that's what I mean.
this is one of those etymologies that might be hard to verify. I always thought it was called linear because you're walking down the line looking for the thing you want.
you can ask short questions here if you like, or if the questions are more involved, go ahead and open up a help channel
i have problem with enum object
what problem are you having?
second....
You can also post a question in #1035199133436354600
i made something kinda cool
x = input('input string' ).
Left_charactors = 'bgtrfvedewsxzaq'
right_charactors = nhyujmkiolp'
lcounter = 0
rcounter = 0
space_charactors =
scounter = 6
for ch in x:
if ch in right charactors:
rcounter += 1.:
elif ch in space charactors:
scounter += 1
elif chin left_charactors:
lcounter += 1
print(Left:", {lcounter), "right:, (rcounter}, 'spaces:" , {scounter})
i don’t like the spacing but it works how i want it to work
i’m trying to learn how to use manim but my internet is so bad and i can’t install anything
check Python help please
With Pydantic, can I have an optional SecretStr?
Right now, I have to do client_secret: SecretStr = "", which will default to empty string if the value isn't present in the environment.
Which is.... finne, because I can still do if == "": raise "not present".
But I'd really like to have an explicit qualifier for if it's there or not.
you should find a dataset of words and find which contain only left characters or only right characters
Tried phone tethering?
yeah, it’s even worse
What should I automate?
everything
that'd mean everything is boring stuff
Automate The Stuffy Bores With Python
(That's the punchline, someone quick think of a joke)
i mean that is not inherently wrong
is there anything that does not become boring once you repeat it enough
😌
maybe dying...
see: groundhog day or similar
or well atleast everything automatable, depending on how you interpret it
They do say to try everything once.
dying in a movie im sure gets boring.
dying is at the end of my to-do list
"let us C" flashbacks
funny thing to say as someone who deals with issues by saying "i want to kms"
Same as Voldemort.
you should change it to a to-do dict for efficiency 😉
funny
.....okay that makes a lot of sense
I first learnt C from that (my dad had an old copy lying around)
linked todo-list lets goo
and I low-key hated C until my C prof in uni changed my mind about it
any to-do list should be a 2d array... everyone knows that.
Please complete this task to view the next.
lowkey good
removes the need for me too choose, i always struggle with that
and it just clicked that it might be the book and not just a skill issue 💀
the crushing weight of 2 manageable tasks
Eventually, you'll do enough tasks and you'll reach the last one: "die"
reminds me of the stanley parable
lowkey good?
damn meant to reply to the last one:die.
oh well you get the joke
the difficulty of a sequence of tasks is definitely not a sum
Hello folks! I have just released a new library vargula: https://pypi.org/project/vargula/
its not uncommon to see actual univerisity CS teachers teaching C89 on TurboC in a CS course about C 😂
Vargula let's you achieve terminal text formatting while being minimalistic...
looks like a small rich, nice
the readme could probably use a bit of a nerf in explaining things, kinda drags on too long, and maybe a couple screenshots, but looks neat
Hmm... yeah! I def should add screenshots...
(also you commited dist/ to the git repo)
Here's a sample code snippet!
print("Code Diff Highlighting\n")
vg.create("added", color="#00ff88", bg="#003322")
vg.create("removed", color="#ff4444", bg="#330000")
vg.create("modified", color="#ffaa00", bg="#332200")
diff_lines = [
(" ", "def calculate_total(items):"),
("-", " total = 0"),
("+", " total = Decimal('0.00')"),
(" ", " for item in items:"),
("-", " total += item.price"),
("+", " total += Decimal(str(item.price))"),
(" ", " return total"),
]
for marker, line in diff_lines:
if marker == "+":
print(vg.format(f"<added>{marker} {line}</added>"))
elif marker == "-":
print(vg.format(f"<removed>{marker} {line}</removed>"))
else:
print(f"{marker} {line}")
Oh! Thanks for letting me know!!!
Fixed!
amend and force push ftw /hj
Why did you cross out the popular strat??
Does this function being async matter at all?
async def _build_order_data(
po_number: str,
items: dict[str, int],
) -> dict:
payload = {
"poNumber": po_number,
"lines": [],
}
for gtin, quantity in items.items():
payload["lines"].append({"identifier": gtin, "qty": quantity})
return payload
no
well, it will make it return a coroutine, but there's no need for it to be async
unless the way its commonly used is to pass to something expecting a coroutine, maybe?
Technically no. Practically, async means all the callsites will have await and changing that might be complicated or annoying. Additionally, asyncio will taskswitch on async functions, so if you have a loop and this is the only async function in it that becomes a locking loop instaed of a yielding loop for however long it runs.
I expect whoever wrote it expected to have to do async calls in it and htat's why it is the way it is
(I wrote it)
I did not expect it to do async stuff, but I did expect the parent to do so
payload = await _build_order_data(po_number, items)
response = await client.post(
"/orders",
json=payload,
)
If I have one async function is there any reason not to just commit and go all the way in?
Does picking and choosing help me at all?
It indicates whether a function makes api calls or not
_build_order_data() can be assumed to return quickly. await _build_order_data() can be assumed to potentially not
A good rule of thumb is to keep your async organized instead of painting everything the same color
nitpick but i feel like this doesnt have to return a dict since you have a static amount of unique fields
could just make it a dataclass
honestly it's just awkward to async() everything. It's also important because async points are yield points, so some functions you may not want to yield during their execution, and thus shouldn't be async
some one want to build a startup I m a novice programer and I want to create a big proyects whith other pepole
But... I don't want my codebase to look like my son attempted camo again
why would someone make a startup with a novice
Unfortunately, your behavior looks like camo, so your codebase will look like camo
i want to learn whit other novice , I learn very fast , I learnded de basic in 2 weeks
A well organized codebase won't look like camo : )
uwotm8
async def main() -> None:
"""Submit orders from a CSV file to S&S Activewear."""
pos = _parse_pos_csv()
total = len(pos)
for index, (po_number, items) in enumerate(pos, start=1):
print(f"{index} of {total}: submitting PO {po_number}") # noqa: T201
if Path(f"pos/{po_number}-request.json").exists():
print(f"Skipping {po_number}, already submitted") # noqa: T201
continue
payload = await _build_order_data(po_number, items)
response = await client.post(
"/orders",
json=payload,
)
Path(f"pos/{po_number}-request.json").write_text(json.dumps(payload, indent=4))
Path(f"pos/{po_number}-response.json").write_text(json.dumps(response.json(), indent=4))
await asyncio.sleep(2)
what do you even want me to do different
oh I just told my boss I wasn't sleeping here
Oops
lol
Maybe you should noqa T201 on the entire function, since it's supposed to give output
Yeah looking at this
payload = await _build_order_data(po_number, items) make it non-async
It's just a simple transformation
could be done inplace imo but maybe that makes sense for elsewhere
just a q why both dumping req and res in json ? like what is the benefit
logging
aaahhhh okok
If it's an external API
It's good to have exact records of what you sent and received
because companies like playing fuckfuck games
true
some one want to build a startup I m a novice programer and I want to create a big proyects whith other pepole
"I got a 500 error"
"No you didn't"
And now you get to slog through six billion requests looking for which one broke their stupid api
It's cleaner to only store start and end states, but if you have intermediaries that update in the meantime you'll lose data and it's just a mess honestly. For things that don't have super high volume and you can actually store (text is cheap) just log everything
ooh i suppose you could do a grep or keyword on cycling thru the logs looking for error 500 for example
Like when I accidently messed up a number and ordered 53 $20 shirts instead of $50 jackets
plus $15 shipping EACH and they were non-returnable
ouch.
Or when I need to go back through them all to collect the confirmation numbers and/or out of stock responses
$15 shipping for a single t-shirt is madness
def _collect_errors() -> None:
output = {}
for response_file in Path("pos/").glob("*-response.json"):
response_data = json.loads(response_file.read_text())
if "code" in response_data:
output[response_file.stem] = {dct["field"]: dct["message"] for dct in response_data.get("errors", [])}
Path("errors.json").write_text(json.dumps(output, indent=4))
Sometimes Python is beautifully simplistic
So, with iterables and iterators, is it better to have a separate iterator class or for the class to be its own iterator... when would it be better to use either design?
I'd say it's different on a case by case basis
ooh neat
But... when would you use one vs the other?
i love learning from just reading others codes and asking stuff about it
I'd personally pick either depending on how much tracking you have to do in __iter__, if it gets messy enough, pull that out to a separate class.
some one want to build a startup I m a novice programer and I want to create a big proyects whith other pepoleçç
use generators
If your class is a sequence you can use the one included in Sequence
I am, but I still need to recursively iterate through data that isn't stored as an Iterable to begin with
so?
One message removed from a suspended account.
probably
How was a link even allowed, or is it just discord links banned
One message removed from a suspended account.
Links are blacklisted, not whitelisted
I'll be whatever consistency i wanna be bub
(Discord invites are whitelisted)
One message removed from a suspended account.
i look away for ten seconds
It was longer than that
!ban 1336656185516097574 1d do not send malicious links here
:incoming_envelope: :ok_hand: applied ban to @quiet basin until <t:1763844632:f> (1 day).
But still not long enough for me to understand what to do with my code
So just “no async unless I’m going to use it”?
Even if all the functions friends are red, he should still vote blue?

yes, it was
is it a bad idea to use LLMs to give you a path to follow to build an app, not actually touching any of your code but providing steps (that make you think) into the right direction, in a learning context ?
not necessarily
the solution is to use erlang so you dont have to deal with async/await
lol
Red and blue are two categories of function, and you want your functions to align with the behavior type of the category
red is "might wait" blue is "wont wait"
So, the code I want to use and want the client to be able to use is...
k = Key(...registry key params...)
for child in k:
...
But, the problem is that Key is not storing the keys as an iterable where I can just pass through the iterable, instead, winreg has the functions EnumKey and EnumValue where EnumKey takes a key, and a number and gives you the numberth child key of the given key, and EnumValue does the same for values.
You're meant to call this repeatedly until you get an OSError which indicates you've reached the end of the list of children.
I’ll try to get that through my head
Mentally it still feels like heresy to mix and match
I think it's unrealistic and not a good lesson in being an engineer. But, it may be a fine lesson in how to do xyz. I like tutorials and how-to's to get rough familiarity with something, and then take a step back to understand the big picture
i see, the main goal was to build a CLI, and i know how it's supposed to work big picture, but some inner things are blackbox and wanted to clear those with ai but still use the docs to build the actual thing
i don't see why not generators
I'm not sure I've ever written a separate iterator class. __iter__ is often a generator, and you can always provide other generator methods if other iterations are needed.
Generator time I guess?
Like Wikipedia or Google, try to consult primary sources. If an LLM tells you something, ideally ask for a citation/link so you can read more fully. At least, that's my strategy.
alright, that sounds solid
i will give it a try for this cli i am making
see how hard it flops 
We have a monthly "what're we doing with AI tools" meeting where those of us using them give feed back about what, and whether they're good/bad. One item someone saidwas that it could be handy for "write a proposal for XYZ", because it included some things they might have missed. Then you turn it into the real proposal. So AI wasn't doing the proposal, but it was producing a framework/outline.
I'm talking about text here, not code.
why won't this work?
def __iter__(self):
try:
while True:
...
yield ...
except OSError:
raise StopIteration(...)
yeah i just looked into planning the plan, not any code whatsoever
That’s what I do
“Hey BTW how could I go about….”
Then I pick the best suggestion and research the implementation
sounds goofy as hell what i said*
how do i do that
My standing prompt includes something like: : 'after your answer, tell me what was wrong about my question, and what was wrong about your answer'
I get more value from -that- than anything else
that's up to you
I like that.
If it knew what was wrong with its answer…
… it wouldn’t have given you that answer
Try it.
I’m on mobile can you try it for me?
get an agent to try it for you smh
BRB gotta switch entire apps
'Your question is wrong because lack of preparation in your part does not mean inconvenience on my part is appropriate'
I have found it helpful when Claude does something wrong to ask it why it did, and what I could change to make it not happen again.
I've been unhappy with Claude, it doesn't stay within its guardrails well.
What was wrong with your question?
Your question compressed several moving parts—Textual UI, ZIP extraction, SDK behavior, and display logic—into a single sentence, which left the scope a bit fuzzy. It didn’t say whether the SDK was sync or async, whether images needed thumbnails or raw bytes, or whether the UI should stream them in gradually. None of that prevented an answer, but it added guesswork.
What was wrong with my answer?
The example leaned into a straightforward synchronous flow, which might not match your SDK’s actual behavior. I also assumed image formats and didn’t show optional quality-of-life pieces like error overlays, scrolling layout, or asynchronous fetches. The explanation covered the basics but didn’t dig into deeper architectural guidance you might actually want for a more robust production tool.
hello y'all
Hey you
I think engineers would learn a lot from that type of response
AI criticism is interesting because you can often manipulate the entire conclusion by pointing out one little part that you object to
I'm two weeks into an experiment with Claude; I asked it to rewrite and optimize a fairly large chunk of code (about 20k lines). It's doing a terrible job so far, the task is just too many lines of code, it seems. I've been curious really what would happen.
It just keeps boxing itself into a corner, then violating the ground rules I gave it, then rewriting.
Where did you even get that many lines?
Most of my experiments with AI have been unrewarding. The total amount of work required to accomplish my goal, including my oversight, and factoring in the fracturing of attention from switching away from the LLM while waiting for it to come up with an answer, etc. is a net negative compared to just doing the thing myself.
Not my code, I told it to rewrite some core section of a key module that's a bottleneck.
Like, incredibly complex stuff.
Ah
Yeah imma be honest with you
Gippity can’t even write CRUD endpoints for me
If it's that complex, how would you even trust the answers? Even with regression tests I'd be afeared.
An archaic form of afraid.
I had a theory that a different approach would beat their approach, so this was purely an experiment
The tradeoff seems to be complete in both directions. The larger the job, the less likely the LLM can handle it; the smaller the job, the less use it'll be in the first place since I can just do it myself.
Fair
Can i microbit communicate with a pi pico w wirelessly
they both have bluetooth
oh
PS C:\Users\.\Documents\python_programming\WIP\6_shots> & C:/Users/./AppData/Local/Programs/Python/Python314/python.exe c:/Users/./Documents/python_programming/WIP/6_shots/main.py
Traceback (most recent call last):
File "c:\Users\.\Documents\python_programming\WIP\6_shots\main.py", line 1, in <module>
import pygame
File "C:\Users\.\AppData\Local\Programs\Python\Python314\Lib\site-packages\pygame\__init__.py", line 139, in <module>
from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pygame.base'
``` anyone know what couldve happened to my install of `pygame-ce`
Maybe it's installed in a venv, but you're running the primary python and not the venv python?
there's no base module in that folder?
i do am on 3.14t maybe it got corrupted somehow
How did you install pygame-ce? Was it in a venv?
i got it installed on the main but imma try an venv as well
(Corrupted is unlikely.)
no didnt have a venv setup yet just wanted to do a quick check
Installs are per environment. I would:
- make a venv from your pimary python
- activate the venv
- install pygame-ce
- try your script while the venv is activated
yes but still doesnt explain why my main python build doesnt run it eventho it has pygame
wouldn't pygame[-ce] not being installed throw couldn't find pygame instead of pygame.base?
(meaning there is no .base)
Possibly import complains about the whole module name.
!e from pygame.base import *
: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 [35m1[0m, in [35m<module>[0m
003 | from pygame.base import *
004 | [1;35mModuleNotFoundError[0m: [35mNo module named 'pygame'[0m
Aye, just tried that myself. You are correct.
(.venv) PS C:\Users\.\Documents\python_programming\WIP\6_shots> py -Xgil=0 .\main.py
pygame-ce 2.5.6 (SDL 2.32.10, Python 3.14.0t, No GIL)
but it is installed on the main build
yea, and supposedly base is not a submodule in pygame-ce
(idk, I don't use pygame, but that is what the error indicates)
it is tho wait
(.venv) PS C:\Users\.\Documents\python_programming\WIP\6_shots> py -Xgil=0 -c "import pygame.base"
pygame-ce 2.5.6 (SDL 2.32.10, Python 3.14.0t, No GIL)
pygame\__init__.py", line 139, in <module>
from pygame.base import *
Pygame's internal import is broken
This means one of two things:
- you named a file pygame.py
- your pygame install is corrupt
i mean pygame does warn its not fully made for 3.14t yet so maybe its the reason
well, try switching to the "default"
I doubt it
3.14t errors would probably lead to segfaults imo
This feels more fundamental
Wha do you mean it warns?
I don't think it has wheels, so it wouldn't even install with muckery.
(.venv) PS C:\Users\.\Documents\python_programming\WIP\6_shots> py .\main.py
<frozen importlib._bootstrap>:491: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'pygame.base', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
pygame-ce 2.5.6 (SDL 2.32.10, Python 3.14.0t, GIL)
Oh, it has wheels, it's just reenabling the Gil. So it's there.
Don't run with python_gil=0 tho
why not
the warning tells you why not
its just warning me 😏 not saying im not allowed
(at your own risk)
and you found out what that risk gets you
Do whatever you want, don't be surprised when your hair catches on fire and dog starts meowing.
i mean didnt break my pc (yet) 😏
hahahhahahhah
Dude I was drunk
You promised you'd delete that video!!
🤣
you mean to tell me my hair isn't supposed to spontaneously combust?
i thought this was a don't trust ai warning. Which also fits.
ok fine i wont put gil on 0 (for now .... maybe when they remove the warning i will)
the warning is from python itself telling you, xyz needs the GIL
The warning also means: you should just use 3.14 if you're using that package
the thingy is i wanted to try and see if using the free threading could improve the rendering on pygame-ce by having like GUI and game logic actually thread seperated
might sound dumb but thought it was worth trying
will all packages need to be modified to be able to run without the GIL?
oh yeah???
well I run my code on 3.15f+j
TAKE THAT
That is a reasonable experiment.
i thought so too
Wait
Python just reenables the GIL anyways just for funsises?
So… can I just switch all my runtimes to the ft versions and let it re-enable the safety when it needs to, but not do it when it’s safe?
I believe packages need to announce in their metadata that they are no-GIL safe. Otherwise the GIL gets enabled for safety.
I don't know the details, and it may be a transition phase.
I didn’t know that was a thing
I need to go do that to my test package
Hmm
Are there not FT or JIT Docker images yet?
"Module Initialization
Extension modules need to explicitly indicate that they support running with the GIL disabled; otherwise importing the extension will raise a warning and enable the GIL at runtime."
Do pure-Python modules not need to be updated?
Maybe not.
Looks like not. I need to read this section: https://docs.python.org/3/howto/free-threading-python.html#thread-safety
closely to see what safety is provided.
will no gil make the threading library useless or better?
Everything I do is in containers and I don’t see any container images 🙁
No and yes. Respectively. NoGIL is all about threading, so it can't make it useless.
"Go not to the elves for advice, for they will say both no and yes."
Make your own?
With blackjack and very nice ladies?
Thats fun and all
But it doesn’t make the security team very happy
Security teams are paid to be unhappy.
True
And in this case the security team consists of me, myself, and I, so I’d like to think I still hold a lot of sway
Won't you step on your own blue shoes?
"
Iterators
Sharing the same iterator object between multiple threads is generally not safe and threads may see duplicate or missing elements when iterating or crash the interpreter.
"
Fun times. I need to think about what this actually means.
Oh hey
https://realpython.com/python313-free-threading-jit/#compile-and-run-python-313-using-docker
The GOATS strike again
This text predates 3.14, btw, I believe.
uv provides the builds
I already use uv in the container
I just need or figure out how to pin to these builds
will lazy imports be confirmed?
I believe the PEP is accepted.
They already were
!pep 810
Yes, slated for 3.15
wait so what got rejected?
Yay!
(chimera) @shenanigansd ➜ /workspaces/chimera (main) $ uv run nox
error: Distribution `psycopg-binary==3.2.13 @ registry+https://pypi.org/simple` can't be installed because it doesn't have a source distribution or wheel for the current platform
hint: You're using CPython 3.14 (`cp314t`), but `psycopg-binary` (v3.2.13) only has wheels with the following Python ABI tag: `cp314`
<class 'pygame.math.Vector2'> <class 'pygame.math.Vector2'>
Traceback (most recent call last):
File "C:\Users\.\Documents\python_programming\WIP\6_shots\main.py", line 37, in <module>
@lambda _: _().run()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\.\Documents\python_programming\WIP\6_shots\main.py", line 37, in <lambda>
@lambda _: _().run()
~~~~~~~^^
File "C:\Users\.\Documents\python_programming\WIP\6_shots\main.py", line 51, in run
self.p.update()
~~~~~~~~~~~~~^^
File "C:\Users\.\Documents\python_programming\WIP\6_shots\main.py", line 34, in update
self.pos += (direction * self.speed)
TypeError: unsupported operand type(s) for +=: 'pygame.math.Vector2' and 'float'
``` lol weird behavior unlocked
```py
class Player(pygame.sprite.Sprite):
_pos: pygame.Vector2
def __init__(self, *groups) -> None:
super().__init__(*groups)
self._pos = pygame.Vector2()
self.speed = pygame.Vector2()
self.image = pygame.Surface((60, 60))
self.image.fill("red")
self.rect = self.image.get_rect(center=(30, 30))
@property
def pos(self) -> pygame.Vector2:
return self._pos
@pos.setter
def pos(self, v):
self._pos = pygame.Vector2(v)
if self.rect is None: return
self.rect.center = self._pos
def update(self):
super().update()
k = pygame.key.get_pressed()
direction = pygame.Vector2((k[pygame.K_d] - k[pygame.K_a]),(k[pygame.K_s] - k[pygame.K_w]))
if direction.length() > 0:
direction.normalize_ip()
print(type(self.speed), type(direction))
self.pos += (direction * self.speed)
i know i dont have delta time implemented yet -_-
oh wait no i feel stupid its Vector2 * Vector2 -> float which i then try to add on a Vector2
what is the correct to get a Vector2 where the values are a multiplication of the 2?
probably 2 * vectorobj
yeah, multiplying two vectors together will give you the scalar (dot) product
yeah that is if you want both to be multiplied from the same
but how to do
(x, y) * (z, t) = (xz, yt)
It would. I think that's what I'm thinking of doing, my question is should that be in the main class or in an iterator class?
Vector2(v.x * u.x, v.y * u.y)
oh they dont have vector multiplications implemented? :c
doesn't sound like you'll be doing much more than doing winapi calls, so having it in __iter__ should be fine
that's not what vector multiplication is
again, the call is yours to make, decide if you want to pull it out to a class if it's too bloated
try u @ v
element-wise multiplications
Operator "@" not supported for types "Vector2" and "Vector2"PylancereportOperatorIssue
sure
That's dumb!
That's literally the matrix multiplication operator
What library is this?
pygame?
pygame-ce
time to make a helper function XD
after checking the docs they actually do have it implemented ```python-repl
u = pygame.Vector2(3, 4)
v = pygame.Vector2(2, 1)
u.elementwise() * v
Vector2(6, 4)
TIL 👀
There was an older lazy import PEP which was rejected.
oh my when T^T
does @ even have a dunder?
!pep 636
yeah, __matmul__
Whoops.
class MVector2(Vector2, x = 0, y = 0):
def __matmul__(self, v: Vector2):
return MVector2(self.x * v.x, self.y * v.y)
hm, TIL
!pep 690
"Status:
Rejected"
ty so much
690
Nice
On import I have a flask application which sets the static directory for example. While testing it doesn't import again so the static directory is for the first test. I can add importlib.reload() to the code being tested but I only need it while testing. What else can I do?
the element-wise product is sorta completely different to matrix multiplication though. Not sure why you'd use __matmul__ for it
Yup!
TIL too, I just saw a video about it today
Put those steps in a function instead of having them as an import side-effect.
is doing something like
from dataclasses import dataclass, field
@dataclass
class MyGlobals:
delta_t: float = 0.0
globs = MyGlobals()
```where in files i need it i can do```py
from my_globs import globs
x = y * globs.delta_t
``` or should i not do this at all
I was expecting I could remove it from sys.modules between tests but it doesn't import again
It's almost always easier to remove the import side-effect than try and force a recycled import.
That's reasonable.
ok dont worry i wont show the lambda horror im doing 🙃
I would only do this in an immutable context (frozen = true). Then, you can toss all of your values into a config file and load them into the MyGlobals data class. Something like delta_t sounds inherently mutable though, so you might be on a bad track.
(if MyGlobals is a truly global instance used anywhere)
its mutatable i just want a class to hold my values that are both mutable and immutatable within my running context so i can have the advantage of accesing the easily
Mutable global variables are frowned upon in general. It's difficult to debug because the scope of the problem could be anywhere
Singletons, or dependency injection is used in its place
@fading kelp My code detects this as errors, can you help me out.
ame = 'Joe'
Age = 'Eleven'
print("Name,Age")
print("Hello my name is: rahhh")
txt: str = 'cant get me hahah'
names: list = ('bob,regina,jay,jake,jackson')
print("hello world!")
from datetime import datetime
print('This is the current time:')
print('datatime.now()')
def show_date() -> None
print(f'Hello!, {Name}!')
Greet('Bob')
Greet('Luigi')
def show_date() -> None is missing something at the end :)
!code
this can be helpfull for others to read your code @strong gate
it the singleton is mutable, it's still a mutable global.
you get the benefits of encapsulation though, controlling how the singleton instance is influenced
do you? Any part of the code could get the singleton object and mutate it.
this is the same as defining a class, making one object, and assigning it to a global
That problem is kind of unique to python since there aren't really private fields, but you can name mangle it at least to signify that some interface should be used instead of direct access
we seem to have shifted the discussion. Maybe I missed why someone had a singleton in the first place.
the original post had a global data class instance full of variables that would be mutated throughout their application
ok, and a singleton would still be mutated throughout the application, no?
I have a callable int...
Man why's there no benchmarks on easyocr GPU Vs cpu
through a defined interface though, for example:
# file 1
my_globals.some_incrementing_key = 0
# file 2
key1 = my_globals.some_incrementing_key
my_globals.some_incrementing_key += 1
run_some_function_from_file_1()
key2 = my_globals.some_incrementing_key
# key1 == key2 ?
vs
my_globals.increment_key()
my_globals.get_key()
I can't tell how fucked I am
if in the second program key1 equaled key2 it would be trivial to find the issue, it's wherever someone mutated my_globals.__instance.key as it is impossible within the provided interface
The word impossible is doing some heavy lifting there. I'm just confused as to why a global mutable is being used like this. You still have it changing anywhere.
I never really learned matrices but my limited understanding is that you're basically multiplying multiple values by each other while preserving either rows or values.
numpy implements it specifically.
my first suggestion is to never use a global mutable, but in the occasion that you need to, a singleton is cleaner than exposing the value. dependency injection is a far better solution, but is not trivial to introduce to a stack
Actually, technically, it's an IntEnum, but it's still a callable int
hello everyone
Hmm, I'm not following the use of the term singleton here but I understand the pattern you are talking about.
yeah, but in numpy, * is the element-wise product and @ is the matrix product
fair. Like I said, matrix math is above my head.
Its 10/11th grade algebra
We got matrices in 1st year uni.
Late high school/early university
Yeah, there was a very short lesson as I recall, but I didn't get it and I don't even remember getting tested on it.
It was about the point where I went from mathcomputer nerd to computer nerd.
You no longer make programs on your calculator?
I no longer have a calculator
I do somewhere still.
I think to some extend it was the teaching style. A lot of "definition, here is what we do" and nearly no "this is a thing you can use it for".
My calculator was a fancy terminal
TI-84+ Silver Edition from 2005?
My caclutor was a dumb as rocks scientific calculator. Not sure I every had a fancy HP with RPN.
TI-86 for me
A TI something for me I think.
I wasn't allowed to use it in tests
Does no one find the idea of a "TI84 ... from 2005" a ittle jarring?
Same
83/84+ only
Should I?
Then it came in handy during Alg III/Trig
Is that a little too early?
Ever used a TI-89 Titanium?
No, sadly
It has a color screen
I never invested in another graphing calculator after that
And can make 3D graphs
I never invested in another graphing calculator after Desmos
python
did you figure this one out, i'll look at it
Get a Raspbery Pi and LCD display, then make your own graphing calculator
I always forget that Desmos is meant to act as a graphing calculator and not my graphy drawy silly game thing
is the image binary?
I have a cause, but not a solution
#python-discussion message
IIUC, your cv2 implementation expects a colored image, but my image is black and white
yeah, binary image... i can fix it fast
Would a ternary system be able to emulate a binary system?
sure, n-ary system can emulate a p-ary system
So surely you could make a Ternary computer and run it completely fine on regular networks and interact with other devices as it if too were a binary machine
if image.ndim == 2:
image = np.dstack((image, image, image))
🙁
lol
based
actually, i should make the alpha channel 255
How to write code in this form?
!code
actually, whats the dtype of the image? is it still np.uint8?
i think it has to be
Not sure
I'm watching my soap right now
Don't got my code in front of me
I'll DM you the images in case you wanna look at them
i will say, type checker hates numpy code
I wonder why
lol
Smh
ok, yeah, it's uint8 at least
it's annoying, i'll have something typed as ndarray[int, int, Literal[4]] and call np.zeros((4, 4, 4)) and type checker will be like, "ndarray[int, int, int] not an ndarray[int, int, Literal[4]]"
but i used the literal 4 🙁
cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)
Valid, I guess
def read_texture(path: Path) -> RGBA_2D:
"""
Return a uint8 RGBA numpy array from a path to an image.
Parameters
----------
path : Path
Path to image.
Returns
-------
RGBA_2D
An uint8 RGBA array of the image.
"""
image = cv2.imread(str(path.absolute()), cv2.IMREAD_UNCHANGED)
if image.dtype == np.dtype(np.uint16):
image = (image // 257).astype(np.uint8)
elif image.dtype == np.dtype(np.float32):
image = (image * 255).astype(np.uint8)
if image.ndim == 2:
image = np.dstack((image, image, image))
# Add an alpha channel if there isn't one.
h, w, c = image.shape
if c == 3:
default_alpha_channel = np.full((h, w, 1), 255, dtype=np.uint8)
image = np.dstack((image, default_alpha_channel))
return cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA) # type: ignore
imread accepts Path now though
That is explictly my problem
I am downloading my images from the internet
I need it to accept BytesIO instead of Path
hrrm
can you provide BytesIO to imread
can create an array from bytes
you want Image to accept BytesIO?
yeah, ok, gimme a sec
I tried tempfile earlier at work too, but it said it had uh... "no method absolute" IIRC
cv2.imdecode()
Is there a link to the docs for cv2.imread?
imread() comes from disk, imdecode() from a buffer
i think i have class method for Image to create directly from texture, but i'll have to check
Registry types are ridiculous. I'm about to just be like "yeah, that registry value data, it's "Any" now!"
src/batgrl/gadgets/image.py line 238
def from_texture(```
i could add a from_bytes though
or just allow it in the constructor, lemme think
i could change path to source and just load directly from the internet, like Video
hello
ai
that's false
not True
actually, you can check the git history, i'm betting it was written before llms were popular
im checking this out and this is absolutely insane how do you even do this 😭
Can't be AI, it's too organized
ok, i'm adding a read_buffer function in texture_tools and this combined with Image.from_texture should get you what you want
yep!

hopefully

i'll push and release and you can yell at me if it's still broken
the simulations you've made are actually crazu
HOWOWOOWOWWWW
well just go ahead and post the whole thing why don't you
it's not like I DMed you or anything
dont lie
i can delete it
why i'm always late to the fire!!!
it was never there

😢
you saw nothing
yeah, I didn't see anything, why are you telling us this 🧐
Each of the TIFs is a single color
The JPG in the root is the "complete" picture, it has the list of colors at the top
i don’t wanna sound corny but i like your bio im gonna use that phrase
oh, i see
sorry
once i posted in here a today i teach thread and someone accused me that i used chatgpt for it
programming is hard vibe coding is better
it's the end times: good quality is attributed to ai because everyone assumes that everyone else can't code anymore
crazy, cause if i see good quality i assume it's not ai
i agree with u salt bbut i also agree with zehata
that's because you are experienced
and that fight is pointless
if someone thinks your code is made by ai its going to bbe hard to convince him it's not
so just dont try to
because it's not your problem, it's theirs
i noticed that simple code is cooler than complicated code that does the same thing
like if you can do something in 50 lines instead of 70 while doing the same thing i find that really cool
true
u can do it in 1 line too
or rather, they are the problem
!pip everything 👍
adding ; u can even have multiple statements
I've cut ~1800 lines to ~200 lines
less lines doesn't mean better
using that?
HELL no
i still dont understand what this everything is doing
It's AI
it's doing everything
😵💫
It's like a macro, expanding your non existing imports into actual functions using OpenAPI is what I read
so u import something that doesn't exist and it makes it existing?
That’s just a way to blame me without blaming me.. 🫥
i decided to just accept bytes instead, but can just pass .getvalue() from a BytesIO
My type is already a bytes anyways
Any advice on how to create tests to test your code? Never really done it before
we've decided unanimously that bytes is superior
lol
Most "open file" interfaces take "an io" which can be like IO[Path] or IO[bytes]
So it has to have the io wrapper
But if you're making your own from_bytes, then you do you boo, go wild and pop off queen
i know this is offtopic but does anyone have any experience with android rooting? I wanna hide my Magisk mod from banking apps
I'm on my knees for this one tweak
I've seen so many people do it yet I can't
The difficulty with that is banking apps often refuse to work on rooted devices.
Also, rooting will often trigger a phone wipe.
yes because they detect the root modification
I'm alr on a rooted phone
Rightio.
can i root my bank
only once
Then you'll discover the one neat trick to never need a bank account again
||(it's prison)||
my prison bank
Because they detect the root mod, hiding it means they will work on a rooted phone because they think that they're on a non-rooted device
go to offtopic
Plus I need to play 8 ball pool, haven't done that in years
alr sent, and I responded to grote
did you try https://discord.gg/android
or the discord server for your phone make?
it's been the end times for the past two millennia (at least)
as in i have some questions in #ot1-perplexing-regexing
Not the server, but the subreddit
why do people like android over apple
i never understood it
why do people like purple over yellow, i never understood it
Benefit of Apple is they're always years behind, so they're using technology everyone's already perfected, and they can use their money to just get the best out of that already existing tech
Purple AND Yellow? 💜 Best colours in the world
let's uhhhhh get back on topic
Because I'm color-blind and red/orange/yellow/green all bleed together
purple isn't even real
wow
brown isn't real it's just purple
can we link files in this server?
yes
you can use paste
purple is actually not real though, the color spectrum doesnt loop back from red to violet after all
what 📂
😮 *
i see why you're doggy now

https://www.popularmechanics.com/science/a64393667/purple-is-fake/
That’s right. Red and blue (or violet) wavelengths are two opposite extremes on the spectrum. When you see both of these wavelengths in the same place, you eyes and brain don’t know what to do with them, so they compensate, and the clashing wavelengths register as the color we call purple. It doesn’t actually exist.
To me that makes purple the most real colour
i thought it had to do with which cones activated
also if brown is real then so is purple
i think therefore purple
how do we link files? im gonna link yall an LLM i just made that uses synonyms and antonym probability, experts and before/after pattern data for word and wordclass.
I love this, you have so many amazing takes but this is the best one 💜
so yall can fix it and put it on github open source or something
works rn though just could be better
Thesaurus
this all hinges on what we mean by "a color" and what we mean by "real"
mary's room!
Colours are the cool things that you see when you see colours
then brown and purple are real
thesarus?.....
It does exactly what you want
You can find (almost) any synonym or antonym to (almost) any word
blue cones only make up 2% of our total cones
no you don't understand, this works fine. I just wanna upload it to yall can use it.
Brown and Purple look different as colours, but they are the same colour
you can make an LLM that does 1+1 perfectly but that will never change the fact that a calculator can do the same thing with significantly less compute and power usage
This does make sense right?
distribution of cone cells in normal(left) and color blind(right), no blue cones in center
this is cool
without elaborating, it's literally self-contradictory
I thought brown is like dark orange
Like your brain maps a colour to its name
but brown maps both to purple and brown at the same time because they look so similar?
???
i don't think purple and brown look similar tho
Bro's color blind
It'll go
#5262f7 is BLUE
#f0e92e is YELLOW
#ff6912 is ORANGE
#36181e is BROWN/PURPLE
#5b257d is PURPLE
🗣️
I can't be though because I can tell the difference between the colours
maybe this is off-topic at this point?
.color #36181e
.color #5b257d
They're both purple even though they both look different
dark reds are purple too
GUYSSS
.color #2d1708
maroon
this is brown to me
this is maroon
That's brown but not purple
It's my first hackathon, I'm done with everything but deployment, I'm using django
What's the easiest way to deploy
OH ACTUALLY I HAVE A QUESTIOn
how did we get started on colors, and how can we stop? 🙂
Anyone please
django has a deployment guide
Help me out
How would I create a GUI or something where I can have every hex triplet colour display on screen in like a grid iykwim
I don't have much time left sorry
Thansk
you do a bunch of gradients line by line
<p><color=#2d1708>█</color></p>
i dont know how to html
for 8 bit colour that's a 4096 x 4096 grid
wait no :(((( why are there 3 addative colours
rgb?
I'd need to make a 3d diagram of colours
I was counting 8 bit rgb
You'd only be able to view it in 4d
Excellent, a cube? How are we going to see inside?
We upgraded to CMYK
We get a whole extra letter now!
Ascending
isnt there another new one?
another what
you can do a bunch of 2d grids and pick the hue:
oklab
Would I be able to arrange every colour together though by how similar they are?
well, i'm sure there are a bunch of different color systems that try to do that, i'm sure you could to
There's some kind of funky grid traversal that covers eg a whole cube etc in single step increments, can't rememeber its name (or even its specifics).
hilbert?
yeah, some 3d space-filling curve
I think so?
Hello
To get verified 2years after joining to be 'verified' to speak in a general chat.
:( I want more, different colour cones and to be a 4th dimensional being
you want to be a mantis shrimp
YES
theres lots of space filling curves
but i think hilbert is the more well known one
be nice
hi guysss
i think hilbert is used more often though in computer science
whereas our approach is more crafty
local zoo
watch python? you want videos?
Occasionally at home, too.
Hopefully not inside the house
Raymond Hettinger
Learn to take better advantage of Python's best features and improve existing code through a series of code transformations, "When you see this, do that instead."
there you go
Of course inside the house.
How many sneks do you have?
yess
Personally? None.
what guys???
you can try cs50, but i've never watched it
maybe someone else would recommend it or not
where do you guys watch
NDC
books, google, smart and helpful people here
maybe the mit course?
probably ok for a beginner
MIT 6.100L Introduction to CS and Programming using Python, Fall 2022
Instructor: Ana Bell
View the complete course: https://ocw.mit.edu/courses/6-100l-introduction-to-cs-and-programming-using-python-fall-2022/
YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP62A-ynp6v6-LGBCzeH3VAQB
An introduction to what computation is, pyt...
theres also me too
you are neither books nor google
is explanation is better
here guys run this LLM I made tell me what you think. when you run it, it will create an empty dictionary file (possible with the basic words i forgot) and there is file training mode (just rescans files and builds on them), chat training mode (trains pattern data) and regular mode (should have no training). since the dictionary file is empty you may have to copy/paste the dictionary format and generate a small dictionary(300-400 words) that way.
im neither smart nor helpful too
untrue
https://github.com/VythanLe///// Open-Source-LLM---Probability-Synonyms-Antonyms-Wordclass/tree/main
whats with the unprompted advertising??
thats not advertising it's free
????
called open source bud
@silver plover
That's not how advertising works
guys complains someone hands him a free million dollar system
you should probably just use @ Moderator instead of pointing to a specific person
anyway go check it out its working as of rn
my guy, you dont even know how a URL works
Oh I just do it because I don't want to @ someone with their do not disturb on or something
guys lowk should I hack into the mainframe using the firewall
I probably shoukdnt
you can DM @pseudo carbon
You explicitly SHOULD
Where the ai coders at than yall don't seem interested
I mean I probably shouldn't just @ a specific person
ah right
AI coders, or AI coders?
real ones
they are in delusion
Probably not advertising unprompted on a python discord server?
its not advertising im linking you to an almost complete LLM system
anyway, how did the inventors of python3 come up with the best changes to a language ever?
what's that
we got the message, relax
im more interested in what you consider the best changes to a language
I find it almost impossible to notice possible improvements in any of my work at all, not because they're perfect, but because I'm not good at spotting them
maybe you just need to write more
for a, b in zip(as,bs)
for i, thing in enumerate(things)
trash collection is useless for a language but i shall take my leave
so long
It's not exclusive to python or programming at all, I can't find mistakes or sub-optimal things to be improved upon at all
uhm excuse me the term is GC not TC
maybe if you look back on the past projects you've written?
like, 6 months down the line, i can usually look at my own projects with a different lens
and find things to improve
guys is mit ok
It's a pretty highly respected university
learning from mit ocw is quite good actually
I spent a long time looking at some of my code today and I found one improvement.
if isLan then
ports = router.device_ports(ip)
else
ports = router.used_ports
end if
became
if isLan then; ports = router.device_ports(ip)
else; ports = router.used_ports
end if
That's it though 😭
if you build larger projects maybe you will find architectural improvements to be made?
I'm building up small projects I'm going to combine together into a big one (hopefully) soon, I just need to get my partial json parser to parse json
how about cs50
highly recommended too
which better
I keep looking at my code and then going and writing it out in Python too, and getting angry at how much better Python is than MiniScript (the language I'm writing the parser in)
It makes me want to write a Python to MiniScript parser or smth just so I don't have to write in MiniScript 😭
cs50 is better
a lot of people here have looked at cs50 before, if you encounter any problems during your journey you can ask your question and it would be very easy for people to answer your question
hiiiii nedbat
okkk
at first it might be tough but it will become easier with time, so dont give up!
Should I always aim for readability wherever possible (without harming my code itself)?
yes
like
while u_inp != "exit"; u_inp = user_input("What would you like to run?\n> ")
if u_inp == "nmap" then run_nmap
if u_inp == "randip" then run_randip
if u_inp == "clear" then clear_screen
end while
over
while u_inp != "exit"
u_inp = user_input("What would you like to run?\n> ")
if u_inp == "nmap" then run_nmap
if u_inp == "randip" then run_randip
if u_inp == "clear" then clear_screen
end while
the first one isn't valid, right?
The first one is valid
what language is this? it's not python
; treats everything after it as if it were a newline
i would even argue sometimes it might be better to take a little bit of performance penalty if the readability improvement outweighs it
why cs50 is bettersss
lua
It's one called MiniScript, it's not the most beautiful language but it fits its goal of being lua-like
because it's newer, and made for online teaching. mit ocw is not.
i like the mit one cause it feels more like a classroom
I just don't have any python examples on me rn since I don't have my python files open
oh right i also thought of something
nobody wants it
I understand why people criticize the use of indentation in python, I don't agree with them and I think indentation is a great way of discerning the hierarchy of ur code things, but not ```lua
if
...
end if
while
...
end while
abc = function
print("abc")
end function
sometimes halfway through writing tests i suddenly think of improvements i can make
writing tests as in tests for your code?
yea
How does one do that
I test my code by running it and if it doesn't give me an error then it's probably fineeee
everyone criticizes indentation but who in their right mind doesnt use it the same way they would in python
I feel like brackets make it look ugly and harder to read
Dicts should look like this
my_dict =
|--------------------|
| "key1":"Value1", |
| "key2":"Value2", |
| "key3":"Value3" |
|--------------------|
kinda insane to know how many ----- to use to surround my dict
nah, I don't need markdown tables to repeat themselves again
only part of markdown I hate 😢
there are other parts to hate, like significant trailing whitespace
welp, it's gfm, but yeah, they're not great to write
maybe someday we will adopt a flavor that uses csv or similar
it makes snese to read in plaintext, it doesnt make sense everywhere else
markdown was written by IETF people /j
ooh csv doesn't sound like a bad idea
@raw bramble write an obsidian plugin for it
it'd be much better than random tables but ;w;
restructured text has list-tables.
I have almost no experience writing obsidian plugins but I'm gonna write that down in my Obsidian Vault under "Ideas"
(I use FolderNotes btw 😎)
Folder Notes is actually such an underrated plugin
genuinely have to wonder why they decided to make trailing whitespace significant
id have less of a problem with leading whitespace
Yooooo im on the reddit tab today!!!
Cool thats my first time since I joined this
i didn't even know there was a reddit tab
Me neither.
Tbh
But now I know and its cool seeing stuff like that. My thermal monitoring code was top post today
MiniScript looks fire
Hey guys! I just released a new python terminal styling library. Check this out: https://pypi.org/project/vargula/
I have added demo images like @hasty island suggested...
Let me know if you have any suggestions... or you can contribute to my GitHub too!
looks good
i also like the examples u showed
Thanks a lot, @rare gazelle 😊
np
If I want to learn to edit an existing programming language like CPython, I'll need to learn C?
not necessarily, there's different parts like the sdtlib which is mostly in python, but yeah ig so
soon you'll need to learn rust too :kekw:
not only that, but you'll need to get familiar with how CPython works and it's codebase
CPython is the Python interpreter and runtime environment. I’m not following. What are you wanting to learn?
wanting to edit parts of CPython
I'm assuming they're wanting to make their own version
I want to create my own programming language :P
Right but like as just a maintainer or for some other purpose?
just to learn how to
because it's fun to learn things :D
so an esoteric purpose, no pun intended
lmao
You can do that with any language, but you get to inherit all the issues of whatever language you choose typically
haha, yeah kinda. I want to learn it so it's something I know that others don't, things that are esoteric...
yeah then you'd definitely have to learn c
you will need to get familiar with the codebase and how CPython works
Why don't I just make my own programming language then?
What are the bare necessities of a programming language
:bigbrain:
You can do it in Kotlin, Java, Swift, JS, whatever you want. Ultimately, you have the limitations of whatever language you choose until you compile your language with your language tbh



