#python-discussion

1 messages · Page 191 of 1

silver plover
#

This sounds like a db/er modelling question, not anything particularly unusual.

silver plover
#

entity/relation

pallid garden
#

kinda

#

the faculty could delete or add lessons too

grizzled wasp
#

just for reference I'm paying not even 4€ a month for a 2 core 4gb ram 40gb storage vps, only concern here should be usability and to a lesser degree maintainability, as there's no way that amount of records should be hitting any machine limits

shrewd pine
#

you just need some identifier, you could try to force them to keep the same identifier as a course evolves, or when modifying something one could note somewhere "X is the modified version of Y" or whatever

pallid garden
#

with my method:

#

try to differentiate each lessons by their class number

#

if that does not work

#

add the day

#

if that does not work

#

add the venue

#

so on and so forth

fathom vortex
#

that's exactly what i meant by having to do a lot of "guess work"

pallid garden
#

as you can imagine, this logic will be quite complex

shrewd pine
#

you can only do so much with garbage data

fathom vortex
pallid garden
silver plover
bronze dragon
#

would this mapping be easy to make for a human?

shrewd pine
#

pushing for making the data saner would be a good idea

pallid garden
#

the thing is, the method by which we get this data from the university is not stateful, it does not read the current database during ingress

#

the method (we call it scraper but it's more like API caller) runs without calling the API to access the previous set of data

#

i can see how you can map the old data to the new data and assign each unique a course number/id

#

i guess that's something to consider

shrewd pine
#

how should thing work between years?

#

is a course repeating annually the same course?

visual juniper
#

all of this will be so much easier to understand if we just got to see some examples of data lol

shrewd pine
#

is it completely independent? or is there a connection between the instances of the course?

silver plover
fathom vortex
visual juniper
#

and the problem we are trying to solve is ?

pallid garden
bronze dragon
#

covidZone in 2026?

pallid garden
fathom vortex
#

oh, so you're having trouble finding which specific lesson changed and in what way

#

there are no identifiers for lesson themselves

pallid garden
fathom vortex
#

yep, can add or remove lessons

pallid garden
#

anyway so each student can have any combinations of these lessons for every module

bronze dragon
#

can you explain why a mapping needs to be made from old to new to begin with? I assume there is some (user-specific?) info which is stored against each lesson which needs to be carried over, but I am not sure what it is

visual juniper
bronze dragon
#

nah, each JSON is for one subject I believe

pallid garden
pallid garden
bronze dragon
#

so... is it something like the course is offered simultaneously on (say) Tue/Wed and Mon/Thu tracks, and as a student I can choose to attend whichever?

pallid garden
fathom vortex
#

so if an update happens to one of the classes which the student had assigned themselves with, you've to figure out the diff and get the updated value for what the student was assigned to.

Are the updates one at a time, or multiple at a time

pallid garden
#

we also want this share link to work across data changes by the faculty

pallid garden
#

obviously the implementation is not hard

#

but is it maintainable?

fathom vortex
#

this problem really surrounds around the lack of identifiers, isn't the most logical solution to add some form of identifier?

pallid garden
fathom vortex
pallid garden
fathom vortex
#

you're pretty much guessing what changed

pallid garden
fathom vortex
#

yeah yea

bronze dragon
#

if you gave it to a human, would they be able to generate a correct mapping easily?
I'm thinking, since you have a large userbase, you could get the mapping crowdsourced

fathom vortex
#

what's the ownership of the initial json api, can you modify it or is it faculty provided

pallid garden
pallid garden
bronze dragon
#

also, 3 hour lecture from 1200 to 1500 is diabolical

pallid garden
#

the API is maintained by us

pallid garden
#

i can see how you can generate an identifier from comparing the old dataset from calling the API and comparing with the new list

pallid garden
fathom vortex
#

you'd have to maintain a db of states then

silver plover
fathom vortex
#

w each lesson getting an ident in the beginning and modifications happening over the db like you defined

silver plover
#

But more importantly, the goal is to fit the data into a data model... so the focus should be: what end state (data model) do we want to end up in?

fathom vortex
#

or better yet, if you can write a script to port the faculty lists to have identifiers in them

pallid garden
pallid garden
fathom vortex
#

there are no stable items within the size of unit of data to have a stable representation from initial to final unless you're tracking it all and providing them fixed uuids from the start

pallid garden
#

yes

#

and therein lies the question: "what is a good id/uuid"

#

it cant be too long

fathom vortex
#

randomly generated works ig

pallid garden
#

it wont work across data modifications would it

fathom vortex
#

or autoincrement on the db if you're using that to track it

fathom vortex
pallid garden
#

hmmm

#

ok, let me think about that again

bronze dragon
#

right now you're not storing the history of changes anywhere, right? you just have the present moment's schedule data

pallid garden
#

though, while generating a new set of data, technically you could write some code to call the API to get the current set of data

bronze dragon
#

it doesn't seem like it would be a huge increase in storage burden to store a history of changes

pallid garden
#

i dont know

#

no one knows how much modifications the faculty are making

silver plover
fathom vortex
#

if not history of changes, you could have a db that poulates random uuid for a lesson at initial and then you update the db everytime you detect a change

#

only storing the uuid and the lesson

bronze dragon
#

even if they were issuing new schedules every week, that's not a lot of data from a storage POV

pallid garden
kindred pier
#

Hello

pallid garden
safe folio
#

if I had a dynamic database and I am interested in getting the top 10 (positive and negative) values from a column, what data structure would be suggested? I was looking into heapq, but not sure if it loads all the data into memory

pallid garden
#

we run the "scraper" every hour (iirc)

fathom vortex
#

man, this problem is hard to solve

#

maybe the constraints so far don't allow for better solutions

pallid garden
#

if i represent the data as a "minimally-differentiable-identifier" i was thinking it can be stable enough

fathom vortex
pallid garden
#

actually

silver plover
pallid garden
#

i suddenly had a revelation

#

for all normal students, we can just store the class numbers

safe folio
fathom vortex
silver plover
pallid garden
#

for the teaching assistants, we store the class numbers and some other bit of information, but if that changes beyond recognition, we just inform the user that the matching could not find the lesson that matches

safe folio
fathom vortex
#

mm

pallid garden
#

even with the extra bit of info, like venue or day

fathom vortex
#

yea

#

why not hash the identifier to make it smaller

pallid garden
#

the class number is like 2 chars

fathom vortex
#

oh lol

pallid garden
#

it's fine

#

that was the old representation too

fathom vortex
#

. 👍

safe folio
pallid garden
#

as yous might have been able to tell, im quite averse to touching the API, because quite a few other apps have actually popped up that piggybacks on this API to work

silver plover
# safe folio pgsql
create table myvals as SELECT * FROM generate_series(1, 100) t(x);

with q1 as (select *, row_number() over (order by x) rn from myvals)
select * from q1 where x < 10 or x > 90
fathom vortex
#

oof

pallid garden
safe folio
golden mortar
pallid garden
#

i also have to talk to the other peeps

#

about this change

#

since some of them also use this string representation

#

but at least the next release period is in 7 months

#

so we should have quite some time

limpid phoenix
#

^

limpid phoenix
pallid garden
pallid garden
# limpid phoenix Why so?

the pedagogy leaves much to be desired because they only show the code and does not prompt you to actually think for yourself

pallid garden
#

quite a few people actually came to the server from the video

#

and they encountered an issue that they could not solve

#

because they copied the code wrongly from the video

#

ideally we want to help everyone develop the critical thinking skills to read and understand errors

#

and solve it themselves

tight rampart
#

Hiiii I just started to learn python can someone help me a lil bit? Ty❤️

cerulean ravine
brisk gazelle
tight rampart
brisk gazelle
#

!resources

edgy krakenBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

golden mortar
# tight rampart Where do I start from, started to learn python 2 days ago and idk where to start

Automate the Boring Stuff is a really good book for complete beginners and it's free to read online: https://automatetheboringstuff.com/#toc
If you prefer to watch video tutorials Corey Schafer's playlist is also really good: https://www.youtube.com/playlist?list=PL-osiE80TeTskrapNbzXhwoFUiLCjGgY7
I also recommend Harvard’s free online course, CS50P: Introduction to Programming with Python: https://pll.harvard.edu/course/cs50s-introduction-programming-python
This is an alternative online course with lots of integrated practice problems you can do directly in the browser: https://programming-25.mooc.fi/

pallid garden
#

this is way too long

clear fable
#

then vsc just gave out an error and the file got marked red and lost 😭

#

not even in the recycle bin

#

i dont remember anything i wrote in it

pallid garden
#

how did you delete it?

clear fable
#

i switched to zed there after

clear fable
pallid garden
#

what?

#

how is that possible

clear fable
#

For some reason, the file got strikethroughed

clear fable
#

I was so confused, I started typing print(bye world) without the quotations

cold bronze
#

hello everyone! I wasnted to ask a quick question, how do i check if something is an int or a float or a bool, I'm using a list

name_list = [
("name", "name desctription", int(1)),
("name 2", "name 2 desctription", float(0.0)),
]

for name, name_desctription, name_type in name_list:
  #idk what to do after this point

clear fable
#

like if thisvariable==bollean

#

i've no idea im new

opal gull
#

use isinstance

harsh anchor
cerulean ravine
cold bronze
cerulean ravine
clear fable
#

i think i should work on my game now instead of playing cs 1.6

#

😭 🙏

cold bronze
pallid garden
#

try using vscodium

clear fable
#

im using zed

pallid garden
clear fable
#

rn im on zed

pallid garden
#

who recommended zed to you?

cold bronze
pallid garden
#

zed is quite new, and it's not exactly widely recommended to beginners

clear fable
golden mortar
cold bronze
edgy krakenBOT
#

isinstance(object, classinfo, /)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) exception is raised. [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) may not be raised for an invalid type if an earlier check succeeds.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
pallid garden
reef lily
#

that's what i got banned for last time

cerulean ravine
cerulean ravine
pallid garden
reef lily
cold bronze
cerulean ravine
#

certainly, but this seems like an odd thing to ask.

cerulean ravine
#

let's drop it

golden mortar
reef lily
cerulean ravine
cerulean ravine
golden mortar
pallid garden
#

How about something like this?

  • CS50 is a widely recommended course here for fundamentals of programming with python
  • Automate the Boring Stuff is a good, free book for beginners, goes into using python in many real life scenarios
  • If you prefer Youtube, this playlist by Corey Schafer is good
  • Regardless, you have to write code to actually learn, try this course with practice problems and an editor for you to write and run code in
strong star
#

does anyone like to use kivy?

cerulean ravine
#

it's interesting to see us each develop our own custom "embeds"

robust ledge
#

I do hope at least one of them makes it into @edgy kraken

pallid garden
#

maybe we could make embeds like these version controlled

#

@edgy kraken would be a good home

robust ledge
#

I was under the impression that the existing tag embeds were in version control. As opposed to being in the database.

strong star
#

not one kivy py lib user?

robust ledge
#

What would you ask someone who claimed to be?

golden mortar
#

How's that?

pallid garden
midnight orbit
#

My b wrong place

strong star
pallid garden
#

because quite a lot of people recommend CS50

golden mortar
pallid garden
#

ah ok

golden mortar
#

I don't want to speak for other people

pallid garden
#

well, you can speak for me too

#

or you could just make it passive voice

cerulean ravine
golden mortar
#
  • @pallid gardenand I also recommend Harvard’s free online course CS50P: Introduction to Programming with Python
pallid garden
#

hahahaha

#

that caught me off-guard

clear fable
#

Hi, from where do I take the CS50 course. EDX or cs50.edx.org. I'm looking for free options

golden mortar
# cerulean ravine nice! You have a stray colon at the end of the first bullet. (I would also use ...

Just for you:

bronze dragon
#

comma after "tutorials" in the second bullet
comma after "course" in the third bullet
/pedantry

pallid garden
#

of course, we dont want to have to open a PR that is just 2 commas

cold sapphire
#

i have built a offline facebook clone (no ui just backend) what should i add next i have how to add friends and name and follow others with see your following etc and with bio and with login and sign up and friend request and chat(its random for now) what should i add next in python

golden mortar
pallid garden
#

welp, send it to production

#

git commit -m "it's friday night and i have plans"

cold sapphire
#

say what should i add next?

cold sapphire
#

yup

pallid garden
#

can your followers see your posts?

cold sapphire
#

the followers are just
all_users=[
{"id":1,"name":idk so they all are just data

#

to 100 users in all_users

pallid garden
#

well, try to make a system where you can logout of your current account and log into another account and see the posts from your first account

cold sapphire
#

ok i will be working into it in like 5 min thanks for your time

steel whale
#

i dont think ive ever used breakpoints

cobalt flax
#

To be clear i'm already using pycharm but im considering switching to another IDE if im gonna be learning more than just python.

#

pycharm literally only does python im pretty sure

reef lily
fathom vortex
reef lily
fathom vortex
#

no, that's a dumb thing to do unless you're debugging

fossil steeple
#

can i make a custom dict that lets me do dict[index]

slender urchin
#

You an make any class work with [index]

fossil steeple
#

welp imma try it then

slender urchin
#

using the __getitem__

oblique spindle
#

__getitem__

fossil steeple
#

that's what he said

fathom vortex
oblique spindle
fossil steeple
#

that's close but not exactly

fathom vortex
#

index?

fossil steeple
#

do i need an init

fathom vortex
#

you mean to have both the dictionary and the ability to run integer indexes on the keys?

fossil steeple
#

i believe so

fathom vortex
#

i suppose you would have to create a separate list to maintain order for indexing

#

but insertion and deletion would be expensive op, so prolly a b-tree for larger data

#

wait

#

b tree won't work, it'd be a rope

oblique spindle
fossil steeple
fathom vortex
#

so a dictionary + rope data structure

#

ugh, not evn rope

fossil steeple
#

huh

fathom vortex
#

but something similar to that, where each parent node knows the total lengh of the child nodes

fossil steeple
#
    def __getitem__(self, index: int):
        return self.keys[index]
    
obj = Custom_dict({12: 2})
print(obj[0])```
edgy krakenBOT
#

Hey @fossil steeple!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
fathom vortex
#

i am just blabbering to myself atp, ignore

slender urchin
fathom vortex
#

built in dictionary does maintain order since v3.7 iirc

visual juniper
#

doesnt it ?
afaik dicts are now ordered according to the insertion order

oblique spindle
#

😭

fossil steeple
#

YEAH IT WORKS

slender urchin
#
def __getitem__(self, index):
  if isinstance(index, int):
    return self[list(self.keys())[index]]
  return self[index]```
fathom vortex
#

wouldn't calling list() be expensive?

fossil steeple
fathom vortex
#

no i mean, calling list(self.keys()) would be expensive

fossil steeple
slender urchin
fossil steeple
#
    def __getitem__(self, index: int):
        return tuple(self.keys())[index]
    
obj = Custom_dict({12: 2})
print(obj[0])
fathom vortex
fossil steeple
#

i wonder what else i can do

fathom vortex
#

list() on a hot path function like getting items by integer indexes is really expensive, unless the use case is not meant for larger dictionaries or if the use case is very rare

fossil steeple
#

k

fathom vortex
#

even tuple() for that matter

oblique spindle
#

What exactly is the use of this though?

#

._.

fathom vortex
#

mm, i wonder too

oblique spindle
#

Why would I ever need to get a dict value by index?

fathom vortex
#

i've not ever had to use such a thing in the decade i've programmed

fossil steeple
#

lads what are context managers

fossil steeple
fathom vortex
#
with open("file") as fp:
    fp.write("HELLO")

you see the with block? the file object implements a context manager

#

similarly, there are other functions that can do this neat trick

#

not sure what they're exactly

fossil steeple
#

huh

half pewter
#

I tried to number my dictionaries before I learned about hashmaps and enumerate, it's just a conceptual misunderstanding

fossil steeple
oblique spindle
#

Basically Context managers help in cleaning up actions.

fathom vortex
#

enumerate numbers an iterable, providing you a counter of sorts

slender urchin
fathom vortex
#
for i, x in enumerate(['a', 'b', 'c']):
    print(i, x)
0 a
1 b
2 c
fossil steeple
#

ah okay

oblique spindle
#

Like If you open a file normally i don't remember the syntax ahh
f.open()
f.write("Hello")
f.close()
If write throws an exception, the file will never be closed and cleanup won't happen correctly , context mangers ensure that the file will be closed.
.
Same with SMTP requests, database connections etc.

cosmic scaffold
#

With python can I automate working with excel like same excel but different details ?

slender urchin
#

yes

cosmic scaffold
#

But then I have to input all the details which is not pretty automated

#

I wanted to automate it it's pretty boring stuff doing same thing everyday atleast 3 or 4 time

pallid garden
#

try vba

#

it might be better suited, depending on your use case

harsh anchor
half night
#
def print_pattern2_diff():
    n=int(input("Enter a number: "))
    for i in range(1,n+1):
        for j in range(1,n-i+1):
            print(" ", end="")
        for k in range(1,2*i):
            print("*", end="")
        print()

can anyone explain me the logic of this code. I just don't understand

pallid gorge
#

Anyone got experience with papertrail logging and than with https?

pallid garden
half night
#

how can this be output????

fathom vortex
#

!d str.center

edgy krakenBOT
#

str.center(width, fillchar=' ', /)```
Return centered in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`. For example...
pallid garden
half night
#

let me try

oblique spindle
pallid garden
#

how many times will the i loop run? what is the first i, what is the last i

bronze dragon
half night
#

this is way quicker method I found, which makes sense to me

def print_pattern2():
    n=int(input("Enter a number:"))
    for i in range(1,n+1):
        print(" "*(n-i)+"*"*(2*i-1))```
cosmic scaffold
# harsh anchor what specifically are you trying to automate

Basically I work in bike showroom so as per bike sold I have to make excel of it with many details ofcourse like name address chasis model blah blah and it's pretty boring like atleast I have made those 3000 time or more and in season I do this thing morning to night so I was thinking if python could help in this but I'm not experienced in python to judge that if it could

bronze dragon
#

so what you don't understand is the end= part?

half night
#

it means that how will the statement ends, by default it is /n

unreal vigil
oblique spindle
bronze dragon
oblique spindle
unreal vigil
#

isn't that like, what a dict is for?

half night
unreal vigil
#

I didn't come up with anything better so my game map is saved in a dict as x y coordinate tuples

half night
#

I got it, thanks @pallid garden

#

I was not completing the initial nested loop in my mind ( am so dumb 😭 )

pallid garden
#

i did nothing lol

half night
#

you did said do it on paper

#

and I did!

pallid garden
#

you kinda solved the problem yourself

#

thank yourself more

half night
#

thanks me

#

:p

bronze dragon
#

pov: you're a rubber ducky

pallid garden
#

haha yes

mossy sigil
#

How do goy code in py vs non-goy?

pastel sluice
inland karma
half night
#
def print_pattern2():
    l1=[]
    l2=[]
    n=int(input("Enter a number:"))
    for i in range(1,n+1):
        l1.append(" "*(n-i)+"*"*(2*i-1))
    l2=l1[::-1]
    for item in l2:
        print(item)

Dude I am a genius. I think

cosmic scaffold
inland karma
fathom vortex
cosmic scaffold
half night
inland karma
#

you have to input something yeah, but there are ways to get things done more efficiently

gray siren
#

@inland karma your profile picture is Scary

inland karma
#

i dont mean to be scary

inland karma
inland karma
cosmic scaffold
#

That's why I choose it

inland karma
#

!res

edgy krakenBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

inland karma
#

automate the boring stuff with python

fathom vortex
#

atp it wouldn't be a very bad idea to have a command for the book and cs50p

azure crane
#

my code is compiling for like 5mins lol

cosmic scaffold
craggy willow
gray siren
#

A simple way to learn python is watch some basic python, and start practicing more you practice more you learn!!

half night
craggy willow
#

really? which part

fathom vortex
cold bronze
#

Is it worth it adding detailed comments even though it adds a bunch of lines to the code?

#

like it costs nothing right

silver plover
inland karma
cold bronze
inland karma
#

wong ping

inland karma
half night
steep roost
#

Hii one quick ques!!

inland karma
steep roost
#

This one
How can i create something like this

silk sable
#

Having a program crash because you forgot the parentheses for sys.exit() is kinda ironic.
And it's a mistake I've made more than once for various functions.

craggy willow
#

sys.exit would just be sittin' there

inland karma
steep roost
oblique spindle
#

Are .GitHub.io links trustable?

steep roost
#

same md file and how it's turn into slides!!

#

slides is cool!! i want to built my prsentations etc like this!!

inland karma
#

thats just a github page

edgy krakenBOT
#

Simple Python interface for Graphviz

Released on <t:1749980105:D>.

hallow umbra
#

I am proud to announce that I became an applicant for entering into master's science degree at Kyiv Polytechnic Institute in Computer Engineering for 2026 (Faculty of Software Systems and Applied Mathematics).

steep roost
fathom vortex
slow rivet
#

As trustable as any random webpage is

inland karma
pastel sluice
inland karma
#

but this is using something called mermaid @steep roost

steep roost
#

Thanks!! evil!!

inland karma
#

the js framework is called reveal, and the graphs are made with mermaid

silver plover
steep roost
#

ok okay thanks!! u guys r helpful and cool!!

craggy willow
#

is there some python bindings to tikz

#

cause that'd be another option

thick crown
#

Yo

steady rain
#

!ban 1072804156257095691 "1 year" You've been given many chances to reflect on your behavior here and learn how to behave properly, and you're still being problematic. Take some time to mature before you get another chance to engage with this server.

edgy krakenBOT
#

:incoming_envelope: :ok_hand: applied ban to @reef lily until <t:1800113959:f> (1 year).

inland karma
#

!pypi tikzpy

edgy krakenBOT
#

TikZpy simplifies the art of drawing by code tikz figures

Released on <t:1732477183:D>.

thick crown
thick crown
#

MY friend hoodie is gone 😭

half pewter
#

heh hoodie has multiple accounts... he'll be around

steady rain
inland karma
#

!pypi tikz-python

edgy krakenBOT
thick crown
solemn tartan
thick crown
#

Lol

half pewter
#

If anything you should be happy that he had SOOO many chances to correct his behavior, the server tries to be welcoming.

thick crown
steady rain
#

@inland karma what were you saying about tikz?

inland karma
#

i linked the wrong repo

solemn tartan
inland karma
#

but if you dont want to use JS you can use a python wrapper

#

as salt commented on

craggy willow
inland karma
#

though, i dont think there are python bindings outside sphinx, for reveal

thick crown
#

Guys what are you makin these days

cosmic scaffold
#

Can anyone recommend me good python book that cover atleast most of the python?

inland karma
#

there is also crash course and a byte of python

cosmic scaffold
#

Finding good python book was more harder then finding a good book for assembly

half pewter
#

...

inland karma
soft field
# thick crown Guys what are you makin these days

heat as it is cold with our building under low power short so cannot write code until the apartment place fixes the problem. Issue is the Arctic temps are making things worse and all our blankets are not enough.
Not enough power to run:

  • any appliances including the stove top/oven.
  • any space heater
  • computer/TV
  • any refrigerator/deep freezer
    2374pepesob
half pewter
#

@steady rain How would you feel about pinning some day 1 starter projects if I formatted a list with instructions?

steel whale
#

I FUCKING HATE LOKI SPAMMERS

inland karma
#

please be kind when your talking here @steel whale

edgy krakenBOT
#
Kindling Projects

The Kindling projects page contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

steady rain
#

we already have this

cosmic scaffold
half pewter
# steady rain !kindling

I'm talking about literal day one projects, I don't recall seeing rock paper scissors or high/low there but I'll double check

cosmic scaffold
inland karma
inland karma
velvet hull
#

Hello.world

half pewter
velvet hull
#

I feel a byte of python is better than automate cuz its not beginner friendly

inland karma
cosmic scaffold
velvet hull
inland karma
cosmic scaffold
half pewter
#

could always go to a library

inland karma
#

oh i see... it is not easy to use a phone to write code, i know people try, but its not really something i would recommend

steady rain
#

if you're going to write code on your phone, at least use a bluetooth keyboard

#

it will still suck, though

cosmic scaffold
#

Atleast I have app for it

toxic meteor
#

hello :p

inland karma
#

you dont have to think about the compile step with python, the interpreter does that when you run the code

#

all you need is a python interpreter, and you can run it on a phone

#

or use an online editor

#

or use an app with it build in

#

but i would just not recommend it, even though you can

half pewter
#

colab might be easiest if you intend to work on something at home that you'll use in your workplace

#

there are tons of options but "google"

cosmic scaffold
#

Yeah I do that I doesn't have choice here I was thinking if I could use the pc in my workplace but that has its own story

half pewter
#

nice thing about my suggestion is you can access it from home, work or even a library! Consider it, none of us would be here if we were worried about nerd status.

toxic meteor
#

im new to python , can someone tell me how i can learn it?
used to be a Scratch user , but i wanna learn something new this year !

edgy krakenBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

toxic meteor
hybrid nebula
half pewter
#

lol the top pinned message in this channel is just "be staff"

#

unemployment shaming is rude!

toxic meteor
hybrid nebula
#

I should finally make 'blockly but it's x86 assembly'

raw chasm
toxic meteor
#

dont worry

#

trust me.

raw chasm
#

u dont have to download anything

raw chasm
toxic meteor
raw chasm
#

I mean i lowkey still might recommend hitting up library if ur tryna do bigger project 😭

#

phone will work fine it will just be a lot easier to type and see lol

toxic meteor
#

i have a big brian now.

thick crown
#

@idle nimbus

idle nimbus
thick crown
raw chasm
mossy sigil
#

Yo

toxic meteor
#

termux still on 20% download 😭
my wifi is kinda speedless.
please internet, i need this.

subtle coyote
#

Yo

idle nimbus
subtle coyote
idle nimbus
raw chasm
subtle coyote
raw chasm
#

bro obv doesnt have a pc 😂

subtle coyote
#

yeah otherwise they'd know

idle nimbus
cyan wolf
#

What is LFX

cyan wolf
raw chasm
#

for managing projects

mossy sigil
raw chasm
#

LFX is a suite of tools built by the Linux Foundation to facilitate every aspect of open source development. The toolkit operationalizes the organization’s proven methodology for transforming projects into category leaders, providing direct support to projects, and empowering open source developers to write better, more secure code and grow sustainable ecosystems.

#

too many buzz words 🤮

cyan wolf
#

Is it like gsoc

#

Btw anyone preparing or got chance for gsoc?

raw chasm
#

with other stuff

cyan wolf
#

No its kind of opensource promotion campaign

#

Where beginners get paid for open source

#

contributions

warm girder
#

lfx is an umbrella org for fostering/growing new projects/ open source initiatives

raw chasm
warm girder
#

linux kernel, cncf, risc-v etc

cyan wolf
#

Oh intersting

warm girder
#

also its very competitive to get in

raw chasm
warm girder
raw chasm
#

how do i get in rq

#

or r u signing up for free labor 😭

cyan wolf
warm girder
thick crown
#

Yo

raw chasm
#

oh is it "apply to be a contributor"

#

ig not open until march

raw chasm
warm girder
#

u submit a proposal to a problem statement

warm girder
cyan wolf
#

But it's very competitive as said...

raw chasm
#

idk pull requests ig

warm girder
#

lmao the proposals have shot up since llms

raw chasm
#

bc theres like sign up for orgs and contributors right

thick crown
idle nimbus
#

@thick crown come online 🙂

raw chasm
#

u can see here if ur curious

#

last yr ppl who submitted stuff

thick crown
idle nimbus
charred python
#

^ Joined today to tell people to touch grass, that termux sucks and to DM them. notsureif

harsh anchor
#

termux does suck

jade robin
#

nah it saved me plenty

cosmic scaffold
#

👀👀

thick crown
#

Termux sucks

steady rain
#

is that different from tmux? I love tmux.

bronze dragon
thick crown
#

You can use tmux too using muile

steady rain
#

side note: I wish it was easy to turn old android phones into raspberry pis

thick crown
warped sigil
#

anyone use / heard of jscpd

half pewter
cold bronze
#

Hello! does anyone know regex? :)

cosmic scaffold
#

Can termux even little bit replaced terminal? I just try downloading pandas in it and it doesn't works

thick crown
#

Tbh userland is better than termux

bronze dragon
charred python
#

my old phones are unlocked google ones and I can re-flash them. I never botherd to do it, though.

cosmic scaffold
charred python
#

at least, i think i can. i remember doing it back in the day but I forget which device.

fossil steeple
#

Here i really can't seem to figure out decorators

slender urchin
cosmic scaffold
slender urchin
#

Making one is pretty advanced material

fossil steeple
bronze dragon
slender urchin
#

O wait, I was thinking context manager for some reason 😅

#

What is your question about decorators

fossil steeple
#

ok so why r we returning wrapper

slender urchin
#

The wrapper is the function that the original function will be replaced by

cold bronze
#

I'm using regex to find whether a name has a prefix

import re

#any word with the prefix DEF or ORG, case insensitive
pattern = r'(?i)(DEF|ORG)(.+)'
names = ["DEF_test","org_test"]

match = re.fullmatch(pattern, names)
if match:
  prefix = match.group(1)
  if prefix == "DEF"

so at the very end i get a bit confused, because I'm trying to check if the prefix is either "DEF" or "def", but if i write

if prefix == "DEF"

it only gives me the names with "DEF" capitalized, I'm not sure how to "capture" the first alternative within the group, or how to call it

slender urchin
#
@decorator
def example():
  print("test")

Is syntactic sugar for

def example():
  print("test")

example = decorator(example)```
fossil steeple
slender urchin
jagged belfry
#

Typically with a decorator you replace the original function because you need to

#

There are some cases where you don't, at which point you don't actually need the wrapper

fossil steeple
#

yes but can we not just put the stuff in decorator instead of def a new function

slender urchin
real tendon
#

hello ppl

bronze dragon
jagged belfry
#

The decorator is a function that only runs when the function is being defined, not later when the function that you @'d is being run

fossil steeple
#

wait does the @ make it run

slender urchin
#

Doing @decorator calls the decorator with the function as an argument

obsidian hollow
#

Hello friends

fossil steeple
#

ok so first the decorator is called when you @ it

obsidian hollow
#

I see that most python books avoid writing about the match keyword.This is so strange.

fossil steeple
#

even b4 starting program okay

#

wrapper is called when you call bob

jagged belfry
#

It's called immediately after the def runs

#

!e ```py

def decorator(func):
print("Decorator called with", func)
def wrapper(*args):
print("Wrapper called with", args)
return func(*args)
return wrapper

@decorator
def example(name):
print("Hi my name is", name)

print(f"{example=}")

print("Starting program")
example("Bob")

edgy krakenBOT
real tendon
#

hello ppl. cn sme1 help me in learning this language

#

i know js the basics

fossil steeple
#

ah okay

jagged belfry
#

The decorator syntax is fairly identical to doing this instead:

def decorator(func):
  print("Decorator called with", func)
  def wrapper(*args):
    print("Wrapper called with", args)
    return func(*args)
  return wrapper


def example(name):
  print("Hi my name is", name)
example = decorator(example)

print(f"{example=}")

print("Starting program")
example("Bob")
real tendon
fossil steeple
real tendon
fossil steeple
#

wait so then i don't see when wrapper is called

real tendon
#

so is there someone to help me?

cold bronze
fossil steeple
#

OH WAIT IT'S CALLED WHEN YOU DO DECORATOR(EXAMPLE)

#

COS THAT RETURNS WRAPPER

obsidian hollow
#

@bronze dragon I know that match was introduced in 3.10 version and according to this infographic, this is the oldest version that someone should use:

https://devguide.python.org/versions/

fossil steeple
#

SO THEN WHEN YOU CALL EXAMPLE YOU'RE REALLY JUST CALLING WRAPPER

cerulean ravine
fossil steeple
#

!res

edgy krakenBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

obsidian hollow
#

@cerulean ravine Many

real tendon
fossil steeple
real tendon
#

ig u wont help me @fossil steeple

fossil steeple
#

um...

real tendon
fossil steeple
slender urchin
obsidian hollow
#

Suggest me a book that includes match usage please!

fossil steeple
obsidian hollow
#

👍

cerulean ravine
cerulean ravine
fossil steeple
cerulean ravine
obsidian hollow
#

@cerulean ravine What do you mean?

cold bronze
cerulean ravine
edgy krakenBOT
cerulean ravine
fossil steeple
cerulean ravine
#

it might be that i don't have the latest.

#

@obsidian hollow did you check Fluent Python?

slender urchin
#

It see some pattern matching on page 192

#

but that's just about classes

obsidian hollow
#

@cerulean ravine Yes I am now between Learning Python: Powerful Object-Oriented Programming (6th ed) and Fluent

fossil steeple
#

Here lads is logging worth learning at about an intermediate level?
It's the next chapter in the video and it sounds boring

harsh anchor
#

yes

obsidian hollow
#

@cerulean ravine So between the two books you are suggesting the second one?

cerulean ravine
fossil steeple
silver plover
cerulean ravine
silver plover
#

Is there a laugh+cry+^ emoji?

slender urchin
#

😂

jolly night
#

Hello, can some1 share thoughts on websites such as codewars and similar? are they worth for learning? If so which one is the best in yours opinion?

harsh anchor
bright mauve
toxic meteor
#

I.... Am steve...

flat moon
golden mortar
golden mortar
half pewter
fossil steeple
#

configuring i mean he said no one understands

harsh anchor
#

applications need pretty minimal setup to get pretty good gains, logging.basicConfig is nice

toxic meteor
#

print("CHICKEN JOCKEY")

robust ledge
fossil steeple
golden mortar
toxic meteor
#

does being in a python server mean saying C++ or Java is a crime?

harsh anchor
#

🤨

golden mortar
fossil steeple
#

the questions are crazy

toxic meteor
#

was python made by a guy who was bitten by a python?

fossil steeple
#

yes

slender urchin
robust ledge
silver plover
# fossil steeple do i need to understand

tbh, as a beginner, I don't think you need to learn "logging" explicitly. Just use print statements to emit useful messages, and worry about how to make it better later.

toxic meteor
slender urchin
fossil steeple
toxic meteor
fossil steeple
#

contrary to popular belief, you are not born knowing how to code

toxic meteor
#

honestly the only reason i wanna learn python is to make minecraft python edition 🥹✌️

half pewter
slender urchin
velvet hull
#

Hello world

flat moon
slender urchin
half pewter
#

kinda makes you appreciate the days when computers were still big

toxic meteor
#

its been an hour and termux is still at 90% download....

dry pike
half pewter
#

we just need a programming language that's written purely by swiping left or right

#

tindary

harsh anchor
#

it just iterates through all language features until it gets to the one you want

half pewter
#

🤣

dry pike
#

Better not miss it!

harsh anchor
slender urchin
#

reminds me of this language that's based around linked lists

dry pike
slender urchin
#

I could make some really slow algorithms by continually indexing the list

harsh anchor
dry pike
#

ok I'll just go fuck myself

steady rain
#

um, are we okay?

harsh anchor
mossy sigil
steady rain
#

it's still going, and it's great, but I want to make sure NoWayJay is alright.

sullen dust
#

what projects do employeers like looking for because i doubt theyll give a shit about a chess engine

cerulean ravine
robust ledge
sullen dust
harsh anchor
chilly whale
#

I know someone who landed an internship in part because he listed skydiving in the hobbies section of his resume, and the interviewer wanted to bring him in at least in part to ask some questions about skydiving, haha

robust ledge
tame crest
#

guys what color is urbuggati?

sullen dust
#

Do you ever get to know who your interviewer is before the interview?

rancid fractal
robust ledge
bright mauve
rancid fractal
sullen dust
robust ledge
sullen dust
#

I should probably do the same

robust ledge
# sullen dust I should probably do the same

At the very least, read the sports headlines for the morning and have that small talk on your mind. Sports is another one of those high chances that someone at the table is interested.

obsidian hollow
#

I searched udemy too, for courses that teach match (v3.10 and above) and decided to buy the Complete 2026 Python Bootcamp: Learn Python from Scratch (Haris Ali Khan)

velvet hull
#

It's better to not put topics on table which u aren't familiar with a lie spotted is worse

obsidian hollow
#

by the way 80% of the udemy courses do not even mention match

robust ledge
sullen dust
cerulean ravine
sullen dust
#

I mean if i can find something they like they'll just end up talking loads because everyone likes yapping abt a specific topic they like

robust ledge
obsidian hollow
#

@cerulean ravine Because I am a software developer with more than 15 years of experience with different programming languages and I consider match very helpful for the experienced software developer.

cerulean ravine
soft coral
#

Never used match at work tbh 😛

robust ledge
obsidian hollow
#

@cerulean ravine I use it all the time

cerulean ravine
velvet hull
#

Isn't match on docs too would be a rip off to learn it on a paid course

half pewter
#

I have gotten some value out of my Udemy sub but for every great course I find there are 2-3 that are mid or even just plain bad

mossy sigil
#

Hi

obsidian hollow
#

@cerulean ravine Java, C#, Javascript, Typescript

robust ledge
#

I think I've used match once since it was added in Python. Not often I need pattern matching over an if-statement.

cerulean ravine
tight rampart
#

hiiii what vs should i use? (im a beginner)

proud escarp
robust ledge
rancid fractal
unborn lagoon
harsh anchor
#

Java and c# have real pattern matching these days. idk about typescript

cerulean ravine
obsidian hollow
silver plover
#

@cerulean ravine Is this (still) a doc bug, or is it intentional since powersort is a derivative of it? "The Timsort algorithm used in Python does multiple sorts efficiently because it can take advantage of any ordering already present in a dataset." https://docs.python.org/3/howto/sorting.html. I think this came up before in this channel, but someone asked recently about it again.

cerulean ravine
harsh anchor
cerulean ravine
obsidian hollow
#

@cerulean ravine I have watched another udemy course on it and I have already used it

stray field
#

java calls it enhanced switch expression

#

like enhanced for loops

cerulean ravine
obsidian hollow
#

@cerulean ravine Also "so far" is not a strong opinion

harsh anchor
silver plover
stray field
#

It's basically rust's match

edgy krakenBOT
sullen dust
#

damn

stray field
#

with sealed classes, you can even determine pattern exhaustion at compile time

coarse salmon
dusky crag
#

This actually works, tysm!

stray field
coarse salmon
#

oh you were talking abt java lol

cerulean ravine
cerulean ravine
edgy krakenBOT
stray field
obsidian hollow
#

@cerulean ravine As chat gpt says this is an added feature that I have not learned so far, so I stay at the common with switch feature of value matching for the time being

cerulean ravine
cerulean ravine
silver plover
#

"We expect that, in the future, general classes will be able to declare deconstruction patterns to specify how they can be matched against. Such deconstruction patterns can be used with a pattern switch to yield very succinct code."

stray field
#

double checking

silver plover
#

Looks like destructuring is a future, at lesat from that JEP

stray field
#

Ah, it's under future work

#
case IntExpr(int i) -> i;
coarse salmon
#

i think python probably has the best native pattern matching support out of all the imperative languages

#

which is an impressive feat

obsidian hollow
stray field
#

How come when I press End inside a code block in discord, it goes to the end of the current word instead of the line?

half pewter
#

what does ctrl end do?

stray field
#

Same thing

tight rampart
#

Can anyone recommend a good YouTuber who teaches Python?

obsidian hollow
#

@cerulean ravine By the way I must state at this point that python is the most friendly language for the programmer that I have ever seen.Everything I learn feels so natural.

silver plover
half pewter
#

(╯°□°)╯︵ ┻━┻

stray field
#

I already have a key to go to the (next) end of the current word. It's Alt+Right

harsh anchor
stray field
fossil steeple
#

lads whywhen using decorators we define a func that returns wrapper? would we not just make the func wrapper instead

coarse salmon
tight rampart
#

Can anyone recommend a good YouTuber who teaches Python? plss

silver plover
cerulean ravine
harsh anchor
coarse salmon
stray field
#

When I want to destructure an object, I do not want to do this. ```py
match x:
case Y(z): pass
case _: raise TypeError()

print(z)

half pewter
#

I'd like to organize my code better and use match/case but that's like 14th item on my priority list

silver plover
coarse salmon
#

it's a bit annoying that constants cant be used in place of literals idk

slender urchin
#

php match statements are weird, idk why they are even called match
They are basically an if/elif chain that throws an error if there is no match

charred python
#

C# and rust have pattern matching as well.

coarse salmon
stray field
dusty stone
stray field
#

or do you have to repeat the condition for each case?

cerulean ravine
golden mortar
shrewd pine
stray field
#

match is made for enums

golden mortar
#

Pattern matching in Java was included as a preview feature in Java 17 apparently

obsidian hollow
#

By the way nested elif is not as ugly as in other programming languages because of the lack of the curly braces and the mandatory nature of the identation.Just my 2 cents

slender urchin
cerulean ravine
slender urchin
#

One thing people do is
match(true)
and then just do a bunch of conditional expressions

harsh anchor
#

that is odd

shrewd pine
#

🥴

slender urchin
#

I once had to debug code that relied on side effects in the condition expressions 😔

stray field
#

Do traditional switch blocks even support non-static cases?

shrewd pine
#

in C?

stray field
#

Sure.

coarse salmon
shrewd pine
#

values must even be convertible to integers in C

stray field
#

Let me test this actually.

coarse salmon
mossy sigil
#

What's up?

stray field
#

Ah, you just can't call type aliases like type MyStr = str; MyStr()

shrewd pine
slender urchin
#

while looking into this i found a new horror
someone is suggesting to use an iife to get around the single return expression

stray field
#

(gotta do MyStr.__value__())

coarse salmon
# coarse salmon nah they work fine, i use them all the time
type NodeMsg = Advertisement | Stable | NetworkConverged


def serialize_node_msg(msg: NodeMsg) -> bytes:
  s = stream.new()

  match msg:
    case Advertisement(id, sequence_number, links):
      stream.write_uint32(s, 0)
      stream.write_uint32(s, id)
      stream.write_uint32(s, sequence_number)

      stream.write_uint32(s, len(links))
      for neighbor in links:
        stream.write_uint32(s, neighbor.id)
        stream.write_uint32(s, neighbor.distance)
    case Stable():
      stream.write_uint32(s, 1)
    case NetworkConverged():
      stream.write_uint32(s, 2)

  return stream.to_bytes(s)
silver plover
steady rain
silver plover
#

Did Python ever consider an LTS cycle? Not sure I ever saw any discussion of it.

stray field
golden mortar
steady rain
stray field
#

Java Version 8 Update 471
Release date: October 21, 2025
Filesize: 38.48 MB

#

It's still supported

warped sigil
#

anyone run a code duplication checker tool

dull dune
#

that's basically Javas main appeal, very long support Windows and backwards compat

#

so if you're an enterprise, you can be fairly sure your code will still run with minimal faff for a decade

#

which is also great if you're maintaining a legacy system

silver plover
#
dull dune
#

you can often upgrade the jvm to get improvements without having to touch code, and it's not a pita to get your dev environment up

cerulean ravine
silver plover
#

I was primarily curious a. if it was discussed, and b. the arguments against. Definitely understand it is a decision, just curious the history of it.

bright mauve
#

what do y'all use to listen to keyboard presses? is pynput well-established, or are other modules preferred? i just need something simple that can raise an exception when a key is pressed while other stuff is happening

fossil steeple
#

ok so i get decorators but how tf does this work:

def repeat(numtime):
  def decor_repeat(func):
    def wrapper(*args):
      for _ in range(numtime):
        res = func(*args)
      return res
    return wrapper
  return decor_repeat```
silver plover
fossil steeple
silver plover
slender urchin
fossil steeple
#

and also how come we start by having numtimes as an arg and then it magically beocmes func

bright mauve
#

(for real though, thoughts on pynput vs keyboard vs other similar modules?)

slender urchin
#

You can call this decorator to return a new decorater
So repeat(3) will return a decorator that will repeat something 3 times
You can use it like
@repeat(3)

uneven laurel
#

Hello can anyone give me voice access please.

slender urchin
fossil steeple
slender urchin
#

So

@repeat(3)
def func(): ...

is doing

func = repeat(3)(func)```
uneven laurel
fossil steeple
slender urchin
slender urchin
fossil steeple
#

is it calling decor repeat with numtime

#

as in is it decorrepeat(func, numtime)

slender urchin
#

it calls it with the func
it remembers what the numtime is because of something called a closure
a function inside another function will remember the variables from the outside function

fossil steeple
#

ah okay

#

all that's left now is multiple decorators on one func but i'll do that tomorows

#

thanks

uneven laurel
#

What is difference between range function and enumerate funtion ?

stray field
#

Is this homework?

uneven laurel
dry yacht
jagged belfry
#

range() should be used when you need a sequence of numbers

#

enumerate() should be used when you need to count something

stray field
#

Usage: ```py
for i in range(0, 20, 2):
print(i) # prints 0-20 evens

for i, n in enumerate(range(0, 20, 2)):
print(i, n) # prints 0-20 evens, plus index starting at 0

#

(excluding 20)

jagged belfry
#

enumerate is cleaner, leads to less mistakes, and doesnt' require you to know how many items are there beforehand

stray field
#

!d range

edgy krakenBOT
#

class range(stop, /)``````py

class range(start, stop, step=1, /)```
The arguments to the range constructor must be integers (either built-in [`int`](https://docs.python.org/3/library/functions.html#int) or any object that implements the [`__index__()`](https://docs.python.org/3/reference/datamodel.html#object.__index__) special method). If the *step* argument is omitted, it defaults to `1`. If the *start* argument is omitted, it defaults to `0`. If *step* is zero, [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) is raised.

For a positive *step*, the contents of a range `r` are determined by the formula `r[i] = start + step*i` where `i >= 0` and `r[i] < stop`.

For a negative *step*, the contents of the range are still determined by the formula `r[i] = start + step*i`, but the constraints are `i >= 0` and `r[i] > stop`.
stray field
#

!d enumerate

edgy krakenBOT
#

enumerate(iterable, start=0)```
Return an enumerate object. *iterable* must be a sequence, an [iterator](https://docs.python.org/3/glossary.html#term-iterator), or some other object which supports iteration. The [`__next__()`](https://docs.python.org/3/library/stdtypes.html#iterator.__next__) method of the iterator returned by [`enumerate()`](https://docs.python.org/3/library/functions.html#enumerate) returns a tuple containing a count (from *start* which defaults to 0) and the values obtained from iterating over *iterable*...
turbid orbit
#

hello guys i don t know where i will start learn can u help me

golden mortar
jagged belfry
#

I wonder if adding step to enumerate would be accepted...

stray field
#

honestly the doc blurb the bot gives for range and enumerate aren't that helpful in understanding what they are. Click into the docs page to learn more.

#

The "Equivalent to:" section in enumerate may help understand what's happening

storm frost
#

Hi!

turbid orbit
stray field
#

!ytdl

edgy krakenBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
storm frost
#

Doh

uneven laurel
#

Is it in python ?

chilly jasper
#

⟦AES⟧ 5x> Δrƚħυя mØЯgΔη > 3x> yØʊ’Яε gØØd mΔn > 1x> ⧫

stray field
#

Is that your AES encryption key?

rose peak
#

!d for

edgy krakenBOT
#
for

8.3. The for statement

The for statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object:


for_stmt: "for" target_list "in" starred_expression_list ":" suite
          ["else" ":" suite]
```...
stoic nova
#

is it worth type hinting -> None if your type checker knows this anyways

robust ledge
stray field
#

I will say that providing return type helps the type checker. Without it, it has to do more work and read the body to determine the return type.

#

Sometimes it's trivial, but with more complex functions with complex types...

dusk adder
#

doing -> None feels like a chore, but it does make things more explicit and clear

spice hill
jagged belfry
jagged belfry
#

-> None "this doesn't return anything, and shouldnt"

jagged belfry
#

Adding a return accidentally

spice hill
#

You mean, if you intend to return None but are actually returning something now?

#

yeah, that's also a good reason

#

unless you have some tooling that warns you when you omit an annotation on a function that doesn't return None (you'd have to write such a tool yourself)

dusk adder
#

right, the type checker would infer the return from the body

spice hill
#

(if the type checker is not mypy)

jagged belfry
#

Function signatures are contracts: I take this, I give you this

#

Write them as needed, basically

dusk adder
#

it gets really annoying sometimes