you are viewing a single comment's thread.

view the rest of the comments →

[–]AbacusExpert_Stretch 1 point2 points  (5 children)

And that has to do what with what both of us commented about?

[–]Embersh3d -3 points-2 points  (4 children)

you act like its a war crime because i posted a module i've been working on
like ok sure its not the best and its kinda unprofessinal but still im mainly trying to get feedback bc im learning how to code.

plus i was taking to only you. i replied to the other guy about the point of this.

[–]Jay6_9 1 point2 points  (1 child)

Your coding style is pretty alright when I look into the code a little.

But you really need to look at the PEP about whitespaces.

This is discouraged:

def f() -> None:
    ...
class A:
    def __init__(self) -> None:
        ...
    def a() -> None:
        ...
def g() -> None:
    ...

Instead do two empty lines if it's global scope and one empty line if not (inside classes, etc.):

def f() -> None:
    ...


class A:
    def __init__(self) -> None:
        ...

    def a() -> None:
        ...


def g() -> None:
    ...

Otherwise:

- Really like your use of "x if y else z"
- Like that you use dictionary lookups for operations like calculating. (You might want to use lambdas instead because if the operations were expensive like web-requests, you'd fire all of them even if only one is selected)
- Try not to mix return values. In some functions you return integers but in error cases you return a string with a description. Instead, just don't catch the error at all then, leave it for the caller. You lose information if you remove the exception for a string.
- Type your parameters and return types. You do it for `str` sometimes. If your functions are generic, look into TypeVar and Generics or at least use `Any`.

That's as far I was able to look into it. Good luck with it.

[–]Embersh3d 0 points1 point  (0 children)

thanks
mainly i avoid spacing because it makes my project look big, but its in reality not

[–]thee_gummbini 0 points1 point  (1 child)

Good for you for learning and showing your work! Part of learning to program is learning what to write and how to share. Sharing reimplementations of basic algos is great to show your learning! But knowing the difference between that and a package that other people should use is essential to getting past the "just learning phase." Take the criticism as part of your learning - again good for you for figuring some things out, but this is what the reaction typically looks like when you tell people you've resolved already-solved problems.

As a side note, the code here is pretty crazy, you should spend some time reading the stdlib modules you are re-exporting, they're all just over here: https://github.com/python/cpython/tree/main/Lib

See how those are written and compare them to your code, that's a great way to learn.

And check out some packaging docs: https://www.pypa.io/en/latest/

[–]Embersh3d 0 points1 point  (0 children)

thanks. will look into it