[-] UlrikHD@programming.dev 4 points 4 months ago

Please follow our Code of Conduct when interacting with our instance. Hate speech violates section 3.5 and in this instance is severe enough to lead directly to a temporary ban instead of the usual warning. Repeated offences may lead to a permanent ban.

[-] UlrikHD@programming.dev 5 points 11 months ago

Looking at your instance handle, I hope/assume that your comment is supposed to be in lighthearted jest. However that would only be an assumption on my part and in general it's not ok to say someone's job/work tool is for [remarks directed at sex, gender, ethnicity, orientation, disabilities, etc...] per CoC 3.5.

Please take into consideration that members on this instance may be of different backgrounds than what you're used to and interpets what you say differently. Further breaches of our Code of Conduct may lead to temporary or permament ban.

[-] UlrikHD@programming.dev 5 points 1 year ago

Please refrain from harassing our users, keep whatever argument you have contained to the thread it started. Following and harassing users across communities/instances is not tolerated.

You will only be given a temporary ban of one week from our instance, but if it continues after that it will changed to a permanent ban.

[-] UlrikHD@programming.dev 4 points 1 year ago

programming.dev will migrate over to (lemmy compatible) Sublinks once it's ready, which will feature a different set of mod features. For that reason we will need new moderators to have an active programming.dev account. If you're willing keep an active user account on our instance let me know. We would prefer people we know will actively use their mod account to make sure reports are handled in a timely manner.

[-] UlrikHD@programming.dev 4 points 2 years ago* (last edited 2 years ago)

Personally I would recommend to use regex instead for parsing, which would also allow you to more easily test your expressions. You could then get the list as

import re
result = re.findall(r'[\w_]+|\S',  yourstring)  # This will preserve ULLONG_MAX as a single word if that's what you want

As for what's wrong with your expressions:

First expression: Once you hit (, OneOrMore(Char(printables)) will take over and continue matching every printable char. Instead you should use OR (|) with the alphanumerical first for priority OneOrMore(word | Char(printables))

Second expression. You're running into the same issue with your use of +. Once string.punctuation takes over, it will continue matching until it encounters a char that is not a punctuation and then stop the matching. Instead you can write:

parser = OneOrMore(Word(alphanums) | Word(string.punctuation))
result = parser.parseString(yourstring)

Do note that underscore is considered a punctutation so ULLONG_MAX will be split, not sure if that's what you want or not.

[-] UlrikHD@programming.dev 4 points 2 years ago

Stickied post would work just fine yeah, can't really expect the developer to set up a public repo for just tracking features. Hopefully Ruben takes notice.

[-] UlrikHD@programming.dev 4 points 2 years ago

Those doesn't break backwards compatibility though. Naturally you can't use match with a python 3.7 interpreter, but what scripts written for python 3.7 wouldn't work with a 3.11 interpreter?

I haven't encountered that issue before, so I'm curious what those problems OP have encountered looks like.

[-] UlrikHD@programming.dev 4 points 2 years ago

I assume you meant that both Rust and C compiles into machine code? Python compiles into bytecode that is then run in a VM, Rust and C usually doesn't do that as far as I know.

I was mostly curious if it was as easy as in C. Turun's reply answered that question though. Cheers.

[-] UlrikHD@programming.dev 4 points 2 years ago

Since it's variations of the combined ending, each permutation would count as unique. Meaning that 10 companions with 10 endings each would total 10.000.000.000 variations,

[-] UlrikHD@programming.dev 4 points 2 years ago

Whenever I click on the link it prompts me to register on kbin. Is it a closed off instance?

[-] UlrikHD@programming.dev 4 points 2 years ago

Got a Sony Xperia premium XZ from 2017 with the latest update being from 2019, android version 9

[-] UlrikHD@programming.dev 3 points 2 years ago* (last edited 2 years ago)

Obviously this is opinionated and I won't pretend it's the only correct way, but a few things that stood out to me was.

  • inconsistent use of type hinting. You type hint the "elem" arg for process_content and nothing else. Personally I use type hints religiously, but at the very least I would type hint every arg. The type may be obvious to you now, but it may not in 6 months, or for others who want to contribute.

  • while on the topics of type hints, you use "#" to comment the purpose of each function, but you really should use docstrings instead. Text editors supporting python will then use the docstrings to show users the description of each function without you having to jump to the declaration to read the description. It's particularly useful when you got multiple modules. For some IDEs like pycharm, the same format works on variables too.

  • You should wrap up your bottom infinite loop in if __name__ == '__main__': to avoid getting locked if you down the line want to reuse the class/module and import it into another file.

And the most opinionated point of them all:

  • I would recommend running a linter like pylint to warn about potential code smells. E.g. you're redefining the python built-in "id", no exception types are specified in your try blocks, too many branches and statements in process_content() which would probably benefit from being segmented into smaller functions, lines that are twice as long as the recommended length, wrong import order, etc... (these are purely pylint feedback)

I assume the setup is the same with GitHub's ci, but with GitLab you can automate pylint to check the the code with this:

  image: python:3.10
  script:
    - pip install pylint
    - pylint *folder*```
view more: ‹ prev next ›

UlrikHD

joined 2 years ago
MODERATOR OF