home.social

#stdlib — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #stdlib, aggregated by home.social.

  1. Now this is an interesting #Python problem. I don't know if it's a #bug, but it's a change in behaviour that I don't see documented.

    I upgraded from #Debian 12/Bookworm to 13/Trixie, so the default Python3 changed from 3.11 to 3.13. A script of mine broke, because `pathlib.Path.is_mount()` changed behaviour when the path is a symlink (at least to a directory).

    i.e. I'm testing a path that is a symlink. The symlink points to a directory. That directory *is* a mountpoint. The `.is_mount()` test in 3.11 returned True, while in 3.13 it returns False.

    This seems wrong to me. Most path-manipulation functions transparently treat symlinks as if they were the pointed-to object unless you pass an option/flag specifically to say you want the symlink itself.

    Gonna have to dig to see what else I can find.

    #pathlib #path #is_mount #stdlib #behaviour #symlink #filesystem #mountpoint #mount

  2. Now this is an interesting #Python problem. I don't know if it's a #bug, but it's a change in behaviour that I don't see documented.

    I upgraded from #Debian 12/Bookworm to 13/Trixie, so the default Python3 changed from 3.11 to 3.13. A script of mine broke, because `pathlib.Path.is_mount()` changed behaviour when the path is a symlink (at least to a directory).

    i.e. I'm testing a path that is a symlink. The symlink points to a directory. That directory *is* a mountpoint. The `.is_mount()` test in 3.11 returned True, while in 3.13 it returns False.

    This seems wrong to me. Most path-manipulation functions transparently treat symlinks as if they were the pointed-to object unless you pass an option/flag specifically to say you want the symlink itself.

    Gonna have to dig to see what else I can find.

    #pathlib #path #is_mount #stdlib #behaviour #symlink #filesystem #mountpoint #mount

  3. Now this is an interesting #Python problem. I don't know if it's a #bug, but it's a change in behaviour that I don't see documented.

    I upgraded from #Debian 12/Bookworm to 13/Trixie, so the default Python3 changed from 3.11 to 3.13. A script of mine broke, because `pathlib.Path.is_mount()` changed behaviour when the path is a symlink (at least to a directory).

    i.e. I'm testing a path that is a symlink. The symlink points to a directory. That directory *is* a mountpoint. The `.is_mount()` test in 3.11 returned True, while in 3.13 it returns False.

    This seems wrong to me. Most path-manipulation functions transparently treat symlinks as if they were the pointed-to object unless you pass an option/flag specifically to say you want the symlink itself.

    Gonna have to dig to see what else I can find.

    #pathlib #path #is_mount #stdlib #behaviour #symlink #filesystem #mountpoint #mount

  4. Now this is an interesting #Python problem. I don't know if it's a #bug, but it's a change in behaviour that I don't see documented.

    I upgraded from #Debian 12/Bookworm to 13/Trixie, so the default Python3 changed from 3.11 to 3.13. A script of mine broke, because `pathlib.Path.is_mount()` changed behaviour when the path is a symlink (at least to a directory).

    i.e. I'm testing a path that is a symlink. The symlink points to a directory. That directory *is* a mountpoint. The `.is_mount()` test in 3.11 returned True, while in 3.13 it returns False.

    This seems wrong to me. Most path-manipulation functions transparently treat symlinks as if they were the pointed-to object unless you pass an option/flag specifically to say you want the symlink itself.

    Gonna have to dig to see what else I can find.

    #pathlib #path #is_mount #stdlib #behaviour #symlink #filesystem #mountpoint #mount

  5. Now this is an interesting #Python problem. I don't know if it's a #bug, but it's a change in behaviour that I don't see documented.

    I upgraded from #Debian 12/Bookworm to 13/Trixie, so the default Python3 changed from 3.11 to 3.13. A script of mine broke, because `pathlib.Path.is_mount()` changed behaviour when the path is a symlink (at least to a directory).

    i.e. I'm testing a path that is a symlink. The symlink points to a directory. That directory *is* a mountpoint. The `.is_mount()` test in 3.11 returned True, while in 3.13 it returns False.

    This seems wrong to me. Most path-manipulation functions transparently treat symlinks as if they were the pointed-to object unless you pass an option/flag specifically to say you want the symlink itself.

    Gonna have to dig to see what else I can find.

    #pathlib #path #is_mount #stdlib #behaviour #symlink #filesystem #mountpoint #mount

  6. Brand new PEP by @emmatyping to add Zstandard to the standard library:
    peps.python.org/pep-0784/

    Will it make it in to 3.14 before the feature freeze on 2025-05-06? It'll be close but it's possible!

    The PEP also suggests namespacing the other compression libraries lzma, bz2 and zlib, with a 10-year deprecation for the old names.

    Join the discussion to give your support, suggestions or feedback:

    discuss.python.org/t/pep-784-a

    #PEP #PEP784 #zstd #zstandard #stdlib #Python #compression

  7. Brand new PEP by @emmatyping to add Zstandard to the standard library:
    peps.python.org/pep-0784/

    Will it make it in to 3.14 before the feature freeze on 2025-05-06? It'll be close but it's possible!

    The PEP also suggests namespacing the other compression libraries lzma, bz2 and zlib, with a 10-year deprecation for the old names.

    Join the discussion to give your support, suggestions or feedback:

    discuss.python.org/t/pep-784-a

    #PEP #PEP784 #zstd #zstandard #stdlib #Python #compression

  8. Brand new PEP by @emmatyping to add Zstandard to the standard library:
    peps.python.org/pep-0784/

    Will it make it in to 3.14 before the feature freeze on 2025-05-06? It'll be close but it's possible!

    The PEP also suggests namespacing the other compression libraries lzma, bz2 and zlib, with a 10-year deprecation for the old names.

    Join the discussion to give your support, suggestions or feedback:

    discuss.python.org/t/pep-784-a

    #PEP #PEP784 #zstd #zstandard #stdlib #Python #compression

  9. Brand new PEP by @emmatyping to add Zstandard to the standard library:
    peps.python.org/pep-0784/

    Will it make it in to 3.14 before the feature freeze on 2025-05-06? It'll be close but it's possible!

    The PEP also suggests namespacing the other compression libraries lzma, bz2 and zlib, with a 10-year deprecation for the old names.

    Join the discussion to give your support, suggestions or feedback:

    discuss.python.org/t/pep-784-a

    #PEP #PEP784 #zstd #zstandard #stdlib #Python #compression

  10. Brand new PEP by @emmatyping to add Zstandard to the standard library:
    peps.python.org/pep-0784/

    Will it make it in to 3.14 before the feature freeze on 2025-05-06? It'll be close but it's possible!

    The PEP also suggests namespacing the other compression libraries lzma, bz2 and zlib, with a 10-year deprecation for the old names.

    Join the discussion to give your support, suggestions or feedback:

    discuss.python.org/t/pep-784-a

    #PEP #PEP784 #zstd #zstandard #stdlib #Python #compression

  11. ePub derived from a specialized Anki deck with integrated Python REPL, focusing on the Python Standard Library. pin.it/6vMDXKvoj via @pinterest
    #epub #ebook #python #anki #stdlib

  12. ePub derived from a specialized Anki deck with integrated Python REPL, focusing on the Python Standard Library. pin.it/6vMDXKvoj via @pinterest

  13. ePub derived from a specialized Anki deck with integrated Python REPL, focusing on the Python Standard Library. pin.it/6vMDXKvoj via @pinterest
    #epub #ebook #python #anki #stdlib

  14. ePub derived from a specialized Anki deck with integrated Python REPL, focusing on the Python Standard Library. pin.it/6vMDXKvoj via @pinterest
    #epub #ebook #python #anki #stdlib

  15. ePub derived from a specialized Anki deck with integrated Python REPL, focusing on the Python Standard Library. pin.it/6vMDXKvoj via @pinterest
    #epub #ebook #python #anki #stdlib

  16. Unix buffering: The clearest explanation I've ever seen about line buffering, block buffering, and tty output vs simple file / pipe
    jvns.ca/blog/2024/11/29/why-pi
    #buffering #stdlib #linux #shell #unix #cli #+

  17. Unix buffering: The clearest explanation I've ever seen about line buffering, block buffering, and tty output vs simple file / pipe
    jvns.ca/blog/2024/11/29/why-pi
    #buffering #stdlib #linux #shell #unix #cli #+

  18. Unix buffering: The clearest explanation I've ever seen about line buffering, block buffering, and tty output vs simple file / pipe
    jvns.ca/blog/2024/11/29/why-pi
    #buffering #stdlib #linux #shell #unix #cli #+

  19. Unix buffering: The clearest explanation I've ever seen about line buffering, block buffering, and tty output vs simple file / pipe
    jvns.ca/blog/2024/11/29/why-pi
    #buffering #stdlib #linux #shell #unix #cli #+

  20. Unix buffering: The clearest explanation I've ever seen about line buffering, block buffering, and tty output vs simple file / pipe
    jvns.ca/blog/2024/11/29/why-pi
    #buffering #stdlib #linux #shell #unix #cli #+

  21. @astraluma

    It depends on what, exactly, you want. time.localtime() will give you a value in the system's configured #timezone. time.gmtime() will give you #UTC. The difference between those will tell you the current local time's offset from UTC.

    If you want the name of the configured timezone, on many Unix-type systems, you can read /etc/timezone to get it.

    If you want more specific info about a timezone, you can add an external dependency which includes (or provides access to a system-provided) database of timezone info. This stuff changes often, and is decided politically rather than technically, so it's a moving target and the #Python #stdlib doesn't try to include it. `pytz` is one such package with a fairly complete database.

    And you can easily override any of these in a test framework. Using unittest.mock.MagicMock(), for example, lets you override any of the above with whatever value you want those functions to return.

    #pytz #test #mock #MagicMock

  22. @astraluma

    It depends on what, exactly, you want. time.localtime() will give you a value in the system's configured #timezone. time.gmtime() will give you #UTC. The difference between those will tell you the current local time's offset from UTC.

    If you want the name of the configured timezone, on many Unix-type systems, you can read /etc/timezone to get it.

    If you want more specific info about a timezone, you can add an external dependency which includes (or provides access to a system-provided) database of timezone info. This stuff changes often, and is decided politically rather than technically, so it's a moving target and the #Python #stdlib doesn't try to include it. `pytz` is one such package with a fairly complete database.

    And you can easily override any of these in a test framework. Using unittest.mock.MagicMock(), for example, lets you override any of the above with whatever value you want those functions to return.

    #pytz #test #mock #MagicMock

  23. @astraluma

    It depends on what, exactly, you want. time.localtime() will give you a value in the system's configured #timezone. time.gmtime() will give you #UTC. The difference between those will tell you the current local time's offset from UTC.

    If you want the name of the configured timezone, on many Unix-type systems, you can read /etc/timezone to get it.

    If you want more specific info about a timezone, you can add an external dependency which includes (or provides access to a system-provided) database of timezone info. This stuff changes often, and is decided politically rather than technically, so it's a moving target and the #Python #stdlib doesn't try to include it. `pytz` is one such package with a fairly complete database.

    And you can easily override any of these in a test framework. Using unittest.mock.MagicMock(), for example, lets you override any of the above with whatever value you want those functions to return.

    #pytz #test #mock #MagicMock

  24. @astraluma

    It depends on what, exactly, you want. time.localtime() will give you a value in the system's configured #timezone. time.gmtime() will give you #UTC. The difference between those will tell you the current local time's offset from UTC.

    If you want the name of the configured timezone, on many Unix-type systems, you can read /etc/timezone to get it.

    If you want more specific info about a timezone, you can add an external dependency which includes (or provides access to a system-provided) database of timezone info. This stuff changes often, and is decided politically rather than technically, so it's a moving target and the #Python #stdlib doesn't try to include it. `pytz` is one such package with a fairly complete database.

    And you can easily override any of these in a test framework. Using unittest.mock.MagicMock(), for example, lets you override any of the above with whatever value you want those functions to return.

    #pytz #test #mock #MagicMock

  25. @astraluma

    It depends on what, exactly, you want. time.localtime() will give you a value in the system's configured #timezone. time.gmtime() will give you #UTC. The difference between those will tell you the current local time's offset from UTC.

    If you want the name of the configured timezone, on many Unix-type systems, you can read /etc/timezone to get it.

    If you want more specific info about a timezone, you can add an external dependency which includes (or provides access to a system-provided) database of timezone info. This stuff changes often, and is decided politically rather than technically, so it's a moving target and the #Python #stdlib doesn't try to include it. `pytz` is one such package with a fairly complete database.

    And you can easily override any of these in a test framework. Using unittest.mock.MagicMock(), for example, lets you override any of the above with whatever value you want those functions to return.

    #pytz #test #mock #MagicMock

  26. 2) Python Standard Library: #Python #stdlib comes with batteries included, that means even though there are several ways to do something, in specific cases using a certain stdlib function like `chain()` will be the fastest. Or not, like when cloning a 2d list it's faster to `copy()` manually in a loop than to pickle-unpickle

  27. 2) Python Standard Library: comes with batteries included, that means even though there are several ways to do something, in specific cases using a certain stdlib function like `chain()` will be the fastest. Or not, like when cloning a 2d list it's faster to `copy()` manually in a loop than to pickle-unpickle

  28. 2) Python Standard Library: #Python #stdlib comes with batteries included, that means even though there are several ways to do something, in specific cases using a certain stdlib function like `chain()` will be the fastest. Or not, like when cloning a 2d list it's faster to `copy()` manually in a loop than to pickle-unpickle

  29. 2) Python Standard Library: #Python #stdlib comes with batteries included, that means even though there are several ways to do something, in specific cases using a certain stdlib function like `chain()` will be the fastest. Or not, like when cloning a 2d list it's faster to `copy()` manually in a loop than to pickle-unpickle

  30. 2) Python Standard Library: #Python #stdlib comes with batteries included, that means even though there are several ways to do something, in specific cases using a certain stdlib function like `chain()` will be the fastest. Or not, like when cloning a 2d list it's faster to `copy()` manually in a loop than to pickle-unpickle

  31. @doctorwhom

    Well done, but ...

    >>> import fractions
    >>> fractions.Fraction(0.125)
    Fraction(1, 8)
    >>> fractions.Fraction(0.3333)
    Fraction(6004199023210345, 18014398509481984)
    >>> fractions.Fraction(0.3333).limit_denominator(1000)
    Fraction(1, 3)

    A lesser-known part of the #stdlib

    😂

  32. @doctorwhom

    Well done, but ...

    >>> import fractions
    >>> fractions.Fraction(0.125)
    Fraction(1, 8)
    >>> fractions.Fraction(0.3333)
    Fraction(6004199023210345, 18014398509481984)
    >>> fractions.Fraction(0.3333).limit_denominator(1000)
    Fraction(1, 3)

    A lesser-known part of the #stdlib

    😂

  33. @doctorwhom

    Well done, but ...

    >>> import fractions
    >>> fractions.Fraction(0.125)
    Fraction(1, 8)
    >>> fractions.Fraction(0.3333)
    Fraction(6004199023210345, 18014398509481984)
    >>> fractions.Fraction(0.3333).limit_denominator(1000)
    Fraction(1, 3)

    A lesser-known part of the #stdlib

    😂

  34. @doctorwhom

    Well done, but ...

    >>> import fractions
    >>> fractions.Fraction(0.125)
    Fraction(1, 8)
    >>> fractions.Fraction(0.3333)
    Fraction(6004199023210345, 18014398509481984)
    >>> fractions.Fraction(0.3333).limit_denominator(1000)
    Fraction(1, 3)

    A lesser-known part of the #stdlib

    😂

  35. @doctorwhom

    Well done, but ...

    >>> import fractions
    >>> fractions.Fraction(0.125)
    Fraction(1, 8)
    >>> fractions.Fraction(0.3333)
    Fraction(6004199023210345, 18014398509481984)
    >>> fractions.Fraction(0.3333).limit_denominator(1000)
    Fraction(1, 3)

    A lesser-known part of the #stdlib

    😂

  36. I need a dummy #RubyLang #IMAP server that can support #STARTTLS but otherwise treats most commands as no-ops. I couldn't find anything well-maintained via GitHub or Ruby Toolbox other than the gem from Ruby's #stdlib at:

    ruby-doc.org/3.2.2/gems/net-im

    Rather than gutting Net::IMAP, is there already a gem out there that can be used to support fetch-before-send clients like Apple's Mail that won't send email before completing POP3 or IMAP4 authentication?

  37. Python libs you're using (stdlib and not) that have better alternatives.

    - `dataclasses` -> `attrs`
    - `json` -> `orjson`
    - `requests` -> `httpx`
    - `pyoidc` -> `authlib`
    - `pytest-freezegun` -> `time-machine`
    - `aioredis` -> `redis`

    Have I missed anything?

    #python #programming #learn #stdlib #libraries #pypi

  38. Python libs you're using (stdlib and not) that have better alternatives.

    - `dataclasses` -> `attrs`
    - `json` -> `orjson`
    - `requests` -> `httpx`
    - `pyoidc` -> `authlib`
    - `pytest-freezegun` -> `time-machine`
    - `aioredis` -> `redis`

    Have I missed anything?

  39. Python libs you're using (stdlib and not) that have better alternatives.

    - `dataclasses` -> `attrs`
    - `json` -> `orjson`
    - `requests` -> `httpx`
    - `pyoidc` -> `authlib`
    - `pytest-freezegun` -> `time-machine`
    - `aioredis` -> `redis`

    Have I missed anything?

    #python #programming #learn #stdlib #libraries #pypi

  40. Python libs you're using (stdlib and not) that have better alternatives.

    - `dataclasses` -> `attrs`
    - `json` -> `orjson`
    - `requests` -> `httpx`
    - `pyoidc` -> `authlib`
    - `pytest-freezegun` -> `time-machine`
    - `aioredis` -> `redis`

    Have I missed anything?

    #python #programming #learn #stdlib #libraries #pypi