＞「0.1+0.2≠0.3」を説明できないエンジニアがいるらしい #Python - Qiita https://qiita.com/higashi_nc/items/9a5ea00415a008f06843
# まぁ、正確には 0.1 == 1.0x10^-1 なので、計算前の単体の値であれば、たぶん浮動小数点型実数で正確に表せたりしてそうなんだけど、これを計算する際、仮数部を補正する際に循環化小数化してしまうとかいう話とかまで言い出すとややこしいからなぁ
Balbix is hiring Senior Software Engineer/Architect - Data Connector
Job details https://jobsfordevelopers.com/jobs/senior-software-engineer-architect-data-connector-at-balbix-com-aug-4-2020-012721?utm_source=mastodon.world&ref=mastodon.world
#jobalert #jobsearch #hiring
#TIL an interesting #Python "trick". Someone suggested that replacing `sys.stdin` with `open(0)` is shorter & eliminates need to `import sys`.
While that's great for code golf, obfuscated code, etc., it's impractical IRL. E.g.…
• Using `sys.stdin` is much more readable.
• If one isn't careful with `open(0)`, standard input could get closed & difficult (impossible?) to reopen in the same process. (Closing can be avoided by using `closefd=True` with `open()`.)
I'm a little confused as to why it's gotta be
choice = int(input (" > "))
choice = (input (" > "))
for the if statements to work later.
I'm guessing that input always stores user input as a string, even when it's a number, so in order for it to function as an integer, you have to specify that that variable is storing an integer by using int(input()). #python
I was searching for numbers in a string. My method was failing, so I finally decided to look into regular expressions. I couldn't for the life of me figure out why when setting the minimum matching digits to 2, it was also returning numbers of length 1.
Until I noticed I had forgotten to delete my broken code, so it was doing the regex and my thing. Sigh.
Gooey: Turn almost any Python command line program into a full GUI application
To fazendo alguns vídeos curtos sobre python para o canal do CodeShow~
Falando um pouco de strings
Quem tiver sugestão de assunto manda aqui: https://github.com/codeshow/one-minute
Obrigada, paz :heartemo:
I'm several decades familiar with many, many programming languages, but have about a half-dozen that I'd consider *daily driver* languages. #python is not one of them.
I'm writing a lil' thing in #py, and have to keep looking up what modules to include for basic things... and every single time, the answer is exactly what I would have intuited.
"What would I call my datetime module if I were me? I'd call it *datetime*." It's *datetime*.
"If I wanted today's date, I'd want 'date.today()'". Yup.
I guess that's why it's so widely recommended as a starter language. Not starter because it's lacks advanced features, but because it lacks unnecessary confusion!
Something that blew my mind today was realising that Python, while dynamically typed, _doesn't_ do automatic type coercion!
In the following situation, even though `a` is an int and `b` is a float, `+` doesn't coerce `a` to float, it just knows how to handle float + int (or int + float):
a, b, = 1, 1.5
c = a + b
This is subtle, but it really is a huge difference to R's approach. I actually like it...
Q: How do I learn Django?
A: Skip the books. Django is not something you learn by solving theoretical puzzles. It is a framework meant for solving real needs. The best way to learn it is to concentrate on a small business idea, and jump right into it. Understanding the business and product needs will drive the rest of the process. The more you intertwine Django’s concepts with real world needs, the better.
For accessibility, we don't rely on colour alone to convey information; as before, the info about whether examples are recommended is included in the text.
We can add similar borders to help illustrate other PEPs too.
uHTTP: Pythonic web development
C# Dapper has a `QueryMultiple` method, which allows to run multiple SQL statements in a single network round trip. #csharp
The same can be found with #JS, and from what I can tell, the performance is much better:
But for the life of me, I can not find the same functionality in #Python. I am looking all over asyncpg, or related libraries, and I feel like I am going crazy, because I can not even figure out what part of the Postgres protocol allows for this functionality.
When teaching #rust, I often see people have a "Wow 🤯!" experience when I show #rustdoc #doctest system: you write small pieces of Rust code in your documentation and they are then executed as part of your test suite.
What people often don't know is that this system is ancient! I first met in #python and there it was introduced in 1999: https://groups.google.com/g/comp.lang.python/c/DfzH5Nrt05E/m/Yyd3s7fPVxwJ. That's 24 years ago!
I don't know if this was the first implementation of this concept?
This year I've been really enjoying #AdventOfCode solution blogs by
Eric Burden : https://www.ericburden.work/categories/advent-of-code-2023/ : #Kotlin
Who else is writing great explanations of their solutions? Help me find new people.
I had a pretty epic run of bad rolls and my Pathfinder character was dead 20 minutes into last night's session. Since it isn't hard to role play a corpse, I grabbed my laptop and tinkered with some more of my #CreativeCoding sketches
Автоматические бэкапы БД PostgreSQL по расписанию
В этой статье я поделюсь скриптом для создания бэкапов БД PostgreSQL за определенный период (например: 1, 2, 3 дня, 1 неделя, 1 месяц, 6 месяцев, каждый год). Объясню как запустить скрипт с помощью расписания crontab, покажу как настроить синхронизацию папки с бэкапами с облаком Yandex Disk.
Enjoyed today's #AdventOfCode (Day 9). Pretty straightforward overall. Happy with the #python solve as it turned out pretty well. https://github.com/JamesTheBard/advent-of-code/blob/main/2023/09/solution.py
I started writing a blog post (for the @geniepy blog) on how to deploy Reflex.dev applications to Fly.io.
Luckily, I wrote another blog post a few weeks ago on how to run Reflex apps in production, so the one I'm writing right now builds on top of the previous one and saves me quite some work.
Hoping to hit the publish button this weekend! 🤞
(Code is in the image description.)
Возникла ситуация — из одной нейросетки надо выкачать сгенерированное, но зделоть это можно только по одному файлу, причем отдает она их с одинаковыми именами. Значит, надо следить за папкой и переименовывать с нумерацией.
Питонячий скрипт, написанный чат-ботом, заработал с первого раза, а после 1 небольшой правки — даже сделал то, что требуется.
Чесгря, немного удивлен. (Но Питон всё равно придется выучить, хотя бы на уровне чайника :coffeepot: )
Memray: Python memory profiler
The bundle All My Current Books by Michael Driscoll is on sale on Leanpub! Its suggested price is $149.94; get it for $86.39 with this coupon: https://leanpub.com/b/allmycurrentbooks/c/LeanpubWeeklySale2023Dec08 #Python #ComputerProgramming #Software
Zoox is hiring Senior/Staff Safety Research Engineer - Quantitative Risk Assessment
Job details https://jobsfordevelopers.com/jobs/senior-staff-safety-research-engineer-quantitative-risk-assessment-at-zoox-com-jan-24-2022-971e53?utm_source=mastodon.world&ref=mastodon.world
#jobalert #jobsearch #hiring
I'm slowly developing a #minimalistic style in Go. This minimal but type-safe style is possible in any language with first-class functions and #generics, though some languages like Python have standard libraries that accommodate this function compositional style out of the box. 🤔
Because it's AoC code error handling is entirely non-existent 😂 Therefore sadly this style will never pass for good production grade Go code. Ah well!
If you're a data scientist looking for an IDE to code in, try JetBrains. They have seriously leveled up their game by introducing AI into their IDE.
Today Puzzle was a bit easier compared to the previous days. I solved part1 and part2 with the same naive approach.
I also made a framework, that downloads the puzzle inputs and example inputs, and runs the code on them, so my code is less cluttered.
Stream du samedi lancé 📢
- 12H00 : Lunch code, la pause déj' programmable !
- 14H00 : Stream 3310
Aujourd'hui : on parle iA (entre autre !) puis on passe sur le mooc "Apprendre à coder avec Python"
Le tout de manière simple et ludique 😉
C'est maintenant sur https://www.twitch.tv/formamac 🍎
Python allows single underscores ("_") to visually separate digits in large numbers, making them easier to read. These underscores are not part of the actual number.
Today's post in my #Python and #Django "Advent calendar" series shows how you can use the HTTPX library to make and test HTTP requests without lots of layers of mock objects and patching (with a hat tip to @hynek for a nice concise explanation of why you shouldn't mock what you don't own):
📝 "7 things I learned about GitHub Actions"
👤 Lacey Henschel
Due to a stupid mistake I made very early in the project, I had to change a Class name, code file name and all corresponding references and test cases. Boy, what a chore.
Visual Studio Python extension offered to refactor with new Class name but only changed few references, making the task worse 🙁
If you want to get started doing Web scraping with Python, this tutorial is very well done.
By Cody Winchester for the NICAR @IRE_NICAR (National Institute for Computer Assisted Reporting - that is, data journalism) conference early this year
Yeah, from now on, I'll be helping him get the releases out as part of the regular CPython release process.
We had a great recording yesterday with @ericholscher, @charliermarsh, @foosel, @samuelcolvin, @tiangolo, and @willmcgugan on @talkpython. I’m looking forward to sharing the episode with you early next year.
During the stream, one of the listeners said it reminded them of an “Avengers” emergency meeting for #Python Open Source. What do you think:
Back in the late 90s I discovered #python and a few weeks later I had a job writing Python ("Can I use Python?" "Is the code readable?" "Yes"). I saw people post how they wished they could use it for their job.
Now I see people post that they wish they could write Rust professionally. I am over a year in. It did take me a few years of on and off learning as obtaining Rust proficiency can take a little while.
The Rust jobs are out there, but you may have to make them
Is it possible to improve the refactoring in #VSCode?
I was using #Eclipse nearly 20 years ago now and its Java refactoring was FAR superior to what VS Code has.
It might be a Python vs Java thing, but some of it is simple stuff like "extract variable" extracting _all_ instances in scope, or being able to rearrange function arguments.
Is the easiest way to find the location of the smallest nonzero element of a numpy floating point array/matrix really:
- Set all the 'small enough' entries to
(context: I am using
scipy.spatial.distance.cdist to generate a distance matrix of all the objects in a simulation, but I want to find the pair of closest different objects and remove that pair from the distance matrix, before iterating)
WOW! You helped us raised more than 2x what we raised last year with the PyCharm discount 🤩 We are so incredibly grateful for you and JetBrains! #python
The promo might be over, but you can still support the PSF in 2023: https://www.python.org/psf/donations/2023-q4-drive/
I just published a new coding project on github!
This is an early exploration of what I call an “epigenetic algorithm.” It’s inspired by an observation: in living cells, the process of evolution is actively managed by the cell, which itself is an evolved mechanism. Using evolution to optimize evolution seems like a powerful trick, so I’m trying to reproduce it in small-scale AI experiments. I hope to make evolutionary computing more open-ended, more successful in vast search spaces, and less biased by the programmer. In this case, I’m generating cool looking Game of Life simulations, but I hope to find many more practical applications in the future.
I hope folks find this interesting, and I’d love to hear your thoughts and feedback!
@bk1e @tiberiuichim And (I think) it's worth emphasizing that if that is the reason it's taking so long, it's not Poetry's fault, it's because PyPI does not make it easy to bulk-download package metadata to check dependencies. (The situation is probably a little better if it only has to consider newer package versions where there is a separate metadata file, or at least I would hope so)
Finding anything about f-strings docs in docs.python.org is hard (and I say this even as a core dev 🤨)
"F-strings" is like a "common name" that everybody knows now, but...it wasn't its original name.
First, the PEP for it is (PEP 498) is called "Formatted String Interpolation"
Then, CPython officially documents this feature not under "f-strings" heading but as "Formatted String Literal"
Dois encontros online, sábado 9/12 e sábado 16/12, entre 10h e 12h da manhã, horário de São Paulo.
Quem sabe você conhece alguém que iria gostar de participar? Quem sabe você não quer oferecer essa atividade como um presente para alguém? Contribuição sugerida de R$100
My #python project uses Poetry for development, but I have a git precommit that generates requirements*.txt files for production and CI. Poetry is great for syncing all your dependencies but you probably don't want to install it on your deployment images.
Today's post in my #Python and #Django “Advent calendar" series: using "pip install" as safely and securely as possible (with a hat tip to @brettcannon for being the first person I eve saw explain this stuff concisely).
PEP 593 is a bit vague on how you’re supposed to actually consume arguments to `Annotated`; here is my proposal.
Brett Cannon (@brettcannon) from Microsoft has added a build script for building Python for WASI.
Joel Dice from Fermyon and Peter Huene (@peterhuene) from Fastly have updated Componentize-Py from Wasmtime 13 up to 15 and are planning to be ready for Wasmtime 16 on release.
At 20tab we've always been involved in Open Source and we're part of the Python and Django community 🐍
We're working with the Django Software Foundation to improve the UX of its website 🌐
Take a few minutes -- today or tomorrow -- to complete the Python Developers Survey 2023 and have a chance to win an amazing prize from JetBrains! 🎁 #python https://survey.alchemer.com/s3/7554174/python-developers-survey-2023
Spent some time with my #Ubuntu 22.04 developing server and its DNS settings. It‘s really weird that there is more than one service which manipulates DNS. I can recommend reading through the man pages of systemd-resolved to understand how it works.
I had to edit the /etc/systemd/resolved.conf and deactivate the DNS stub listener. After that the /etc/resolv.conf won't be overwritten anymore and the netplan configuration works also after a reboot.
I thought I might try and buy my many bandcamp purchases using https://github.com/easlice/bandcamp-downloader - but I can't get it to do the cookie thing - instructions don't seem too great - anyone got it working? Basically it should iterate through your purchases and download them in the format of your choice. #python #bandcamp
Over the years of learning and teaching programming, I've modeled card games, especially poker, so many times that day 7 of #AdventOfCode was straight-forward for me.
In terms of Python stuff, today's solution uses classes, inheritance and enums that I haven't yet used this year.
Today Juan Luis Cano Rodríguez from QuantumBlack, AI by McKinsey will give a workshop at PyData Global titled "Who needs ChatGPT? Rock solid AI pipelines with Hugging Face and Kedro" in which attendees will learn how to create a complex AI pipeline using Hugging Face transformers and turn it into a Kedro project that cleanly separates code from configuration and data.
Tune in at 16:00 UTC! https://global2023.pydata.org/cfp/talk/NFZDPN/
In my team we have openings for #developer focused on #offensive / #redteam development. You will help to make the research and education sector better (focused specially for #sweden) with your skills and write all #opensource tools.
Ask me any question about the position or team and culture.
Please boost for more reach
Latest episode is out!
#441: Python = Syntactic Sugar?
In this sample chapter from Learn Enough Python to Be Dangerous, you will obtain an introduction to testing in #Python, including a first look at test-driven development, or #TDD. https://www.informit.com/articles/article.aspx?p=3178912
Many (but not all) of the quick examples I write when helping people with #Textual go into my sandbox repo; I doubt most are useful past that conversation, some of them likely won't even run any more as they'll have tested bugs or things we've improved. Every so often I tidy the "root" of the repo, moving stuff into the "attic”.
It's getting kinda busy in the attic…
I've finished the last part of my python beginners series that shows how to upload to PyPI using twine. It was a long two weeks but I hope the overall series is useful for beginners looking to put together a fairly modern python project. #python
Source Markdown available as Creative Commons licensed:
I'm also currently open for work: