@orsinium@fosstodon.org
@orsinium@fosstodon.org avatar

orsinium

@orsinium@fosstodon.org

:python: #python :golang: #golang :elixir: #elixir :rust: #rust #security #foss

No politics.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

mariatta, to random
@mariatta@fosstodon.org avatar

Tried to use the search engine to ask about "how to pronounce #"
but the search engine treated "#" as a comment and it tried to be "smart" and is telling me how to pronounce the word "to" instead.

I also tried "how to pronounce the # symbol", "the # sign", but it just tells me how to pronounce "symbol" or "sign"

🤕

orsinium,
@orsinium@fosstodon.org avatar

@mariatta @diazona @pganssle

I call it "sharp" like in "C#" programming language.

orsinium,
@orsinium@fosstodon.org avatar

@cpontvieux @mariatta @diazona @pganssle

Yes, for semi-tones. And that's why the programming language has this name. I'm not much of a musician myself but I know about C# from the early days of my career. And since I'm also not a native speaker, that's the first English name for the symbol I had heard.

orsinium,
@orsinium@fosstodon.org avatar

@timorl @mariatta @cpontvieux @pganssle @diazona

You can call C# "D minor" to make it more confusing.

itsfoss, to random
@itsfoss@mastodon.social avatar

LanguageTool is a good open-source alternative to Grammarly.

Learn why:

https://news.itsfoss.com/languagetool-grammarly-experience/

orsinium,
@orsinium@fosstodon.org avatar

@itsfoss

All links from the article to the tool are tracked through a marketing service. Someone gets money from this post.

malte, to golang
@malte@hachyderm.io avatar

are there best practices regarding in ? I have something like an in-memory database that gets accessed by multiple clients in parallel. The RWMutexes drive me crazy.

orsinium,
@orsinium@fosstodon.org avatar

@malte

The short answer is "use channels and goroutines instead of synchronization primitives". It's usually also called "don't communicate by sharing, share by communicating":

https://stackoverflow.com/questions/36391421/explain-dont-communicate-by-sharing-memory-share-memory-by-communicating#36391868

For the long answer, there are lots of books, talks, and tutorials. In particular, I found the book "Concurrency in Go" quite useful, even if a bit dated in some parts:

https://www.oreilly.com/library/view/concurrency-in-go/9781491941294/

orsinium,
@orsinium@fosstodon.org avatar

@imclaren @ainmosni @malte

You mean, internally? Performance. The answer is performance. Low-level synchronization primitives are generally faster, and for the stdlib every nanosecond matters. In your own code, you mostly have different priorities.

jamwil, to python
@jamwil@fosstodon.org avatar

You guys remember when every library in the ecosystem was branded “X for Humans”? That was annoying.

orsinium,
@orsinium@fosstodon.org avatar

@jamwil You forgot "™️" at the end.

krz, to python German
@krz@mastodon.social avatar

Here‘s another interesting , , comparison: „count the number of vowels in a string“. uses an anonymous function as an argument to count(), iterates over the string using list comprehension, does the same but in a vectorized way

orsinium,
@orsinium@fosstodon.org avatar

@krz

Since in bool is essentially an int, you can also do it a bit shorter:

sum(i in 'aeiou' for i in input_str)

orsinium, to foss
@orsinium@fosstodon.org avatar

Is there a software license which is as permissive as MIT License but explicitly forbids using the code to train any AI?

freakinbox, to random
@freakinbox@fosstodon.org avatar

What's everyone using for free email that isn't Gmail, Outlook, or Yahoo?

orsinium,
@orsinium@fosstodon.org avatar

@Nouvanity @freakinbox

I use ProtonMail for 4 years now. I pay for it but I think I could just as well stay on a free version. I just checked and I've used only 249 Mb of storage. And that's considering that I never removed any messages. So, I think 500 Mb should last for a few years if not forever, depending on your usage.

yakkoj, to random
@yakkoj@fosstodon.org avatar

AMZN are deploying this "Vega" OS and apparently its party trick is to let people write apps in React ("tell me you hate programmers without telling me you hate programmers")

We really missed an opportunity to curse the web with procedural languages like C.

orsinium,
@orsinium@fosstodon.org avatar

@yakkoj

> We really missed an opportunity to curse the web with procedural languages like C.

Thanks to WebAssembly, we're slowly catching up.

orsinium, to python
@orsinium@fosstodon.org avatar

New blog post: Diving into PyPI package name squatting:

https://blog.orsinium.dev/posts/py/pypi-squatting/

I always wanted to find time to dive into the subject, and today's news about yet another malware campaign on PyPI motivated me to do so.

Special thanks to @sethmlarson for providing the dataset.

dabeaz, to random
@dabeaz@mastodon.social avatar

I wonder if there's a correlation between attitudes about programming safety and the distance you were allowed to travel on your own from your house as a kid.

For example, we used to ride our bikes for hours at a time--usually to go play on the train tracks. And well, maybe I should just leave it at that...

orsinium,
@orsinium@fosstodon.org avatar

@dabeaz

Wearing a bike helmet, using extra strong condoms, looking both sides when crossing the road, pressing "eject" in Windows before ejecting a USB device, putting on the wrist strap when playing VR, saving every minute in PC games, saving every minute when editing a text file, wearing protective glasses when sawing, turning off all home electricity before a long trip, washing hands after eating bananas, and locking the front door.

orsinium, to linux
@orsinium@fosstodon.org avatar

Today I got some time to find out why my takes a noticeably long time to start. The offender was . As I removed it, the time got down from 450ms to 60ms.

To time startup of zsh vs bash:

$ for i in $(seq 1 10); do /usr/bin/time bash -i -c exit; done

$ for i in $(seq 1 10); do /usr/bin/time zsh -i -c exit; done

To find how long each plugin takes at startup, add zmodload zsh/zprof at the top of ~/.zshrc and zprof at the bottom.

RhetTbull, to python
@RhetTbull@fosstodon.org avatar

friends: I would like to examples in my README.md -- doctest is great for this. But examples modify resources so some setup/teardown is needed and would prefer not to show that for each example. Anyway to have "hidden" setup/teardown that isn't shown in README but gets run by pytest? @brianokken

orsinium,
@orsinium@fosstodon.org avatar

@RhetTbull @brianokken

You can use doctest not only as CLI tool but also as a library form your pytest tests. Then you can change any of its steps, including what gets run before and after. For example:
https://github.com/life4/deal/blob/master/tests/test_doctest.py

Another option is to have one one readme that you test and then the other cleaned up that you generate from the first one.

Or you can write a Jupyter Notebook, run it to test the code, hide some cells, and then export as Markdown. A world of possibilities!

publicvoit, to python
@publicvoit@graz.social avatar

I'm coding on an amateur level for more than a decade but it was not until now that I learned that

print(f"The value of variable foo is {foo}.")

is a thing. 😯

orsinium,
@orsinium@fosstodon.org avatar

@meliache @publicvoit

print(locals())

:smart:

rwp0, to random
@rwp0@fosstodon.org avatar

With Twitter and Mastodon, I feel like what accounts I follow never seem to be in Home (timeline) while what I don't want to see is deemed interesting for me.

orsinium,
@orsinium@fosstodon.org avatar

@rwp0 On Mastodon, there is no The Algorithm. Your timeline is what you follow. If it sucks, it's on you 👀

orsinium,
@orsinium@fosstodon.org avatar

@rwp0 I don't know! Maybe, you've subscribed to a hashtag? Or maybe you are looking not at the home timeline? There are a few separate timelines:

  1. People and hashtags you follow
  2. All posts on the same instance (that's how I found your post)
  3. Popular posts of the day over all instances.
  4. Lists. You can create separate tumelines and add there specific people.
orsinium,
@orsinium@fosstodon.org avatar

@rwp0 Also, if someone you follow boosts too much, you can mute busts from them.

orsinium,
@orsinium@fosstodon.org avatar

@rwp0 Las advise: follow @feditips ,it helps newbies to get to know this place. You can also ask them a question.

treyhunner, to python
@treyhunner@mastodon.social avatar

"Due to their single expression limitation, lambda expressions have no need for return statements (and don't allow them)." https://trey.io/uuFX1k

orsinium,
@orsinium@fosstodon.org avatar

@treyhunner Fun ("but slightly irrelevant) fact: you can use yield in list comprehensions. not quite lambda and not quite return but still cursed.

fribbledom, to random
@fribbledom@mastodon.social avatar

"If Tetris has taught me anything, it's that errors pile up and accomplishments disappear."

orsinium,
@orsinium@fosstodon.org avatar

@fribbledom

Tech debt is like tetris. You can't win, you can only delay when you lose. And you'd better to constantly work on it.

zekjur, (edited ) to golang
@zekjur@mas.to avatar

For some reason, Fedora disables the Go module proxy by default in its Go package: https://src.fedoraproject.org/rpms/golang/blob/f39/f/0001-Modify-go.env.patch

This makes module fetching unnecessarily slow, in particular when large repositories are involved, which need to be cloned via git when using GOPROXY=direct :-/

To fix:

go env -w GOPROXY=https://proxy.golang.org,direct
go env -w GOSUMDB=sum.golang.org

orsinium,
@orsinium@fosstodon.org avatar

@filippo The legend himself! I just wanted to thank you for all the work you've done for Go and making the world a bit more secure. I like the stuff you do, even if I don't understand half of it :)

treyhunner, to python
@treyhunner@mastodon.social avatar

What feature or best practice do you wish everyone knew?

orsinium,
@orsinium@fosstodon.org avatar

@treyhunner

How lazy evaluation with functools.cached_property can make the code faster and cleaner.

dabeaz, to random
@dabeaz@mastodon.social avatar

As someone who recently attempted to write a small coherent book on Python, it was neat to meet Doug Crockford ("JavaScript: The Good Parts") at yesterday's RacketCon. We then had a conversation about async/await...

orsinium,
@orsinium@fosstodon.org avatar

@dabeaz

If you start an async conversation, it's important to await before you leave.

orsinium,
@orsinium@fosstodon.org avatar

@robpike @dabeaz @chrisjrn

Most languages opt for async/await because it can be added into an existing language without affecting the regular runtime and all the existing code. If Python suddenly started to run everything, including the main thread, in a scheduler, like you do in Go, I assume that would cause lots of stuff to break.

Rust has a different reason. It uses async/await because then you can build smaller and faster binaries if you don't need scheduler and async runtime.

GlenDownton, to python
@GlenDownton@mastodon.au avatar

Stoopid 3.9 to 3.10 incompatibility ...

orsinium,
@orsinium@fosstodon.org avatar

@GlenDownton @SebastianM6L

How much code do you have that needs rewriting? I think you can write a rewrite rule on semgrep. Or you can install Python 3.10 on raspberry, it's not that hard.

SwiftOnSecurity, to random
@SwiftOnSecurity@infosec.exchange avatar

Magnets are fucking bullshit and nobody says this enough

orsinium,
@orsinium@fosstodon.org avatar

@SwiftOnSecurity

More people find rocks powerful than attractive.

thelinuxcast, to random
@thelinuxcast@fosstodon.org avatar

If your story has one of your characters "falling out of their chair laughing" and you're being literal about it, I will stop reading.

orsinium,
@orsinium@fosstodon.org avatar

@thelinuxcast Some books are written by aliens that learned about humans from other books.

jamescooke, to python
@jamescooke@fosstodon.org avatar

Dear users and friends, could one of you lovely people have a read of this issue I've opened today in pipx https://github.com/pypa/pipx/issues/1091 - and please tell me "it's no big thing". 🙏

TL;DR if a file exists in your current directory that has the same name as a package that pipx, or the installed package you're trying to run depends on, that file will be:

  1. executed
  2. will probably crash.

Is this a vulnerability?

orsinium,
@orsinium@fosstodon.org avatar

@jamescooke

By default, adds into the import paths (sys.path) the current directory you're in. That means, your modules in the current directory will have precedence over third-party modules, which is generally good. Since Python 3.11, you can change this behavior by setting PYTHONSAFEPATH=yes environment variable.

https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSAFEPATH

orsinium,
@orsinium@fosstodon.org avatar

@jamescooke @pawamoy

As described in the link in my previous message, the -P flag and PYTHONSAFEPATH are two ways to do the same thing. Choose the one that works for you the best. I find the env var more descriptive.

benjaoming, to python
@benjaoming@social.data.coop avatar

Okay I remember there was some talk about this earlier but can't recall the answers....

In packages, what was it again about these classifiers for supported Python releases? Should we maintain them or can we just remove them in favor of python_requires?

✅ pip uses only python_requires for resolving packages.
✅ PyPi displays the information of python_requires

😖 PyPi also displays the classifies (tropes) so in this case maintaining/not maintaining meta data creates work/noise.

orsinium,
@orsinium@fosstodon.org avatar

@benjaoming

Trove classifier categories that you specify for a package were never used by pypi, pip, or any other tool I know for anything. Poetry automatically adds some categories for you (python versions, license) but again, doesn't use them.

The only purpose of the classifier is to categorize projects on pypi. However, considering how many projects there are now, I doubt anyone searches projects this way. I personally use github topics to find projects on a subject.

orsinium,
@orsinium@fosstodon.org avatar

@benjaoming That's exactly what I mean! These are classifiers, they classify projects on pypi so that you, in theory, can use pypi as a catalog of Python projects.

treyhunner, to python
@treyhunner@mastodon.social avatar

What's your favorite one-liner?

orsinium,
@orsinium@fosstodon.org avatar

@cazabon @treyhunner

You can do the same with just python3 -m json.tool

https://docs.python.org/3/library/json.html#module-json.tool

orsinium,
@orsinium@fosstodon.org avatar

@treyhunner

from future import annotations

The one-liner that my every Python file has. Makes type annotations lazy so that I can use forward-references, latest annotations syntax, and other cool things without affecting the runtime.

orsinium, to random
@orsinium@fosstodon.org avatar

The rating of "This Is Spinal Tap" on IMDB goes to eleven.

https://imdb.com/title/tt0088258/

https://youtu.be/uMSV4OteqBE

blong, to python
@blong@fosstodon.org avatar

In addition to using , can anyone share any guidance, tooling, or blogs that may help steer a application towards the "TypeState" pattern? I'm also curious if there are references comparing the "State" pattern to the "TypeState" pattern (Rust).

I suppose I'm looking specifically for Python comparisons with , e.g. if there were a part 2 for the article here:

https://kobzol.github.io/rust/python/2023/05/20/writing-python-like-its-rust.html

Forgive my ignorance, I'm trying to learn 😬

cc/ @adamchainz @davidfstr

orsinium,
@orsinium@fosstodon.org avatar

@blong @adamchainz @davidfstr

Here is a video about the pattern:
https://youtu.be/PSh7JUfDstE

The examples are on Scala but I don't think there is anything special to know about Python, it's easy to translate.

orsinium, to privacy
@orsinium@fosstodon.org avatar

Is there a privacy-friendly alternative to TripAdvisor, Yelp, Google Maps, and alike? Specifically, for restaurant reviews.

I want to go on my next trip ungoogled. And while @organicmaps fully covers my needs for how to get to where I want to go, it's not enough for picking where to eat.

isagalaev, to python
@isagalaev@mastodon.social avatar

Yesterday I learned refuses to compare naive and aware datetimes:

>>> from datetime import datetime, timezone
>>> datetime.now() < datetime.now(timezone.utc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't compare offset-naive and offset-aware datetimes

Finally! Does anyone know when it was fixed?

orsinium,
@orsinium@fosstodon.org avatar

@isagalaev A long time ago, actually. I'm pretty sure it was like this in Python 3.4. I don't remember about 2.7, though.

orsinium,
@orsinium@fosstodon.org avatar

@isagalaev That ages you ;)

chipx86, (edited ) to python
@chipx86@mastodon.online avatar

ReStructuredText writers, where do you like to put your

.. _RefName: <target>

definitions?

While we're at it, what are your personal ReST best practices? Share in the comments!

orsinium,
@orsinium@fosstodon.org avatar

@chipx86 The best ReST practice I learned over the years is to use Markdown instead 👀

orsinium,
@orsinium@fosstodon.org avatar

@chipx86

There is hardly anything in ReST nowadays that myst-parser doesn't support. And even if it doesn't, there is a way to embed ReST in it.

https://myst-parser.readthedocs.io/en/latest/index.html

yakkoj, to random
@yakkoj@fosstodon.org avatar

that I'd rather learn C properly than try to pick up any of these "modern" languages that can't even Hello World without ninja or an internet connection says... something, I'm sure

orsinium,
@orsinium@fosstodon.org avatar

@yakkoj

I haven't seen yet a language that would require internet connection for anything but package manager. I often program in Rust, Go, Python, and Elixir from the train. If you install packages in advance, all of them work fine offline.

And I haven't seen ninjas. Only Jinja, if that counts.

orsinium, to random
@orsinium@fosstodon.org avatar

Evolution of programming:

  1. Engineers write code that they understand.

  2. Engineers use libraries (made by others) that they understand.

  3. Engineers use libraries (made by others) that they don't understand (because there are too many of them to audit how each one works).

  4. Engineers copy-paste SO code (made by others) they don't understand.

  5. Engineers use AI-generated code (made by no human being) that nobody understands.

brianokken, to random
@brianokken@fosstodon.org avatar

deleted_by_author

  • Loading...
  • orsinium,
    @orsinium@fosstodon.org avatar

    @brianokken

    Whoa, VR.

    gregorni, (edited ) to random
    @gregorni@fosstodon.org avatar

    remove vs. uninstall – What do you say?

    orsinium,
    @orsinium@fosstodon.org avatar

    @gregorni I think I like that when I run "pip install something", try that something, and see that it sucks, I can get the same command, add "un" before "install" and undo my mistakes. In other words, install+uninstall saves me a bit of typing compared to install+remove.

    joel, to random
    @joel@fosstodon.org avatar

    I made a mistake upgrading this old laptop of mine. It has 2128 updates and its Fedora with dnf :blobcatsadlife:

    I wanna go sleep :blobfoxcry2:

    orsinium,
    @orsinium@fosstodon.org avatar

    @joel You can go to sleep now, updates will wait.

    orsinium, to random
    @orsinium@fosstodon.org avatar

    I just migrated pythonetc.orsinium.dev from to pages.

    Cloudflare pros: Python 3.11 (Netlify is still on 3.8 and no plans to ever upgrade), amazing analytics, unlimited free bandwidth.

    Netlify pros: more configuration options, has a config file, friendlier UI.

    Both provide PR previews and are easy to use and fast to set up.

    orsinium,
    @orsinium@fosstodon.org avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • relationshipadvice
  • Egalitarianism
  • GTA5RPClips
  • Youngstown
  • osvaldo12
  • NeutralPolitics
  • slotface
  • Durango
  • OmnivoreApp
  • oldschoolgamer
  • DreamBathrooms
  • rhentai
  • ethstaker
  • InstantRegret
  • morbius
  • Kemonomimi
  • cisconetworking
  • tacticalgear
  • TeamSpeak
  • tester
  • normalnudes
  • smallboobs
  • cubers
  • lostlight
  • modclub
  • kopitiam
  • Leos
  • HellsKitchen
  • All magazines