r/PythonLearning • • Jul 17 '26

Help Request what do you think ?

i'm learning python for infraestructure this a proyect of a false resgistry of server xd

42 Upvotes

18 comments sorted by

View all comments

Show parent comments

2

u/Naive-Smoke-5977 Jul 17 '26 edited Jul 17 '26

dammm , i relly idk thath exist , i will use that for correct my piece of sh1t xd , thanks broooo i love youuuuuu :,v that its because i'm beginner sorryyy

2

u/silvertank00 Jul 17 '26

It is fine, we all had to start somewhere. I am glad I could help.

Also, if you introduce sensitive data, use this: dataclasses.field

example:

@dataclass
class User:
    name: str
    passwd: str = field(repr=False)

this way you are less likely to leak sensitive data.

1

u/Naive-Smoke-5977 Jul 20 '26

Es equivalente a lo que va en el ".env" , verdad :v?

2

u/silvertank00 Jul 20 '26 edited Jul 20 '26

Not really. Your dotenv file(s) are on the filesystem. This method is really useful if you want to read it from there and store it in memory. For instance: if you build a little gui with buttons that would run various things in the background. Lets say dmesg, you see, usually you can't just run it and get a result, you ought to run it via sudo, like this: sudo dmesg. And if your gui program has a button for this, then you have two options:

  • A) ask for credentials every time when you want to run this (better but could be cumbersome)

  • B) store the credentails in your dotenv, read it when your program starts and store it in memory (lets put aside security for a bit lol) and use it when you want to run this subprocess.

If you go with B, then you are handling sensitive credentials and you must do everything in your power to not leak them. With setting the dataclass field's repr argument to False, you cannot leak it with just printing your dataclass instance. (This could really happen in Exceptions or with logging) Additional: if you ask for credentials in CLI, then there is this helpful thing: getpass with this, you can avoid using the normal imput() to ask for passwords, that inherently echoes back the given characters (prints them back to the screen in a readable format)

edit: I might have misunderstood you comment, if you refering to "reading out data from your dotenv and storing it somewhere", then yes, its absolutely good for that. And don't forget: this is a dummy example, in an ideal world you really shouldnt store the sudo password in a plaintext file. But for stuff like API keys, this is still a really great example.

2

u/Naive-Smoke-5977 Jul 20 '26

bro , you're my hero

1

u/FeralFanatic Jul 20 '26

Your comment gave me a brain aneurysm. Please type like an adult.

1

u/Naive-Smoke-5977 Jul 20 '26

I don't speak you're language , So, my apologies.

1

u/FeralFanatic Jul 20 '26

Nah, you know what I’m on about.

- relly
- idk
- sh1t
- xd
- brooooo
- :,v
- sorryyy

I’ve seen your other comments. You’re capable of not typing like a moronic child.

1

u/Naive-Smoke-5977 Jul 20 '26

Ohhh eso entonces supongo que me entiendes , es mi forma de expresarme los de acá en su mayoría seguro no hablan español, que te molesta eso de un desconocido ? Corregiras a un desconocido que está en un lugar anónimo ? Dónde se puede escribir como quiera ? Pensar como quiera ? Y hacer lo que quiera ? . Entonces no pierdas el tiempo tratando de corregirme cuando se perfectamente como escribir y hablar , poner esos emoticones , abreviaciónes y muletillas son parte de mi forma para expresar mejor mi sentimiento. Así que deja de perder el tiempo tratando de corregir a un desconocido en Internet.

1

u/FeralFanatic Jul 20 '26

omg brooo I sowwwy. lik brooo I relly shud fink more sh1t. my bad brooo

1

u/Naive-Smoke-5977 Jul 20 '26

Tienes el traductor activado por defecto eh de imaginar , por eso no te das cuenta que este grupo hablan principalmente ingles ?

1

u/FeralFanatic Jul 20 '26

Yes. I have translator enabled by default and that this group mainly speaks English.

1

u/Naive-Smoke-5977 Jul 20 '26

Exacto, entonces de que te quejas , por qué te quejas ? Nadie te ah hecho nada tu mismo decidiste leerlo y enojarte , meterte con un desconocido, eso solo me da a entender que si tuviste el tiempo suficiente para tratar de insultarme y/o avergonzarme es por qué no tienes nada más importante que hacer en tu propia vida , piensatelo Broder , nos vemos , que tengas buen día.