#mypie
Explore tagged Tumblr posts
Text
I mean it's not really (float, float) → float, is it?
It's something like...
forall a. (HasLAdd a, HasRAdd a, HasMul a, HasPow a, HasSub a) => a -> a -> a
#I think were it float and were mypy running it would object!#oh also that's still a fake signature#iirc + * ** etc are not required to take or return the same type#so something close to real would look like an unsolved type inference problem with half a dozen type variables#abusing computers for fun and profit#⊤#<- is I think my type theory tag#.....I wonder if there _is_ a way to write down this signature in mypy. methods can be somewhat-assumed to be known at typechecking time...
501 notes
·
View notes
Text
my pie... #mypie
43 notes
·
View notes
Text
i think python is *okay* from a language semantics perspective, though the lack of static typing (and mypy isn't nearly as widely adopted as typescript is) hurts, having "len" and "input" be globals was a mistake, and my understanding is that the async stuff in the stdlib is bad
but the packaging system is an unfixable nightmare
15 notes
·
View notes
Text
mypy can force you to be pretty strict about typing, which is great !!! i think pipy should only accept content that was checked by mypy to avoid those kind of FUCKERS !
(Nearly) Never use auto in C++!!!
So I used to be amongst the people who thought "Yeah ok, auto hides the type. But if the type is not really important to understand the code, and was really long and confusing then it is worth it"
Like this: std::vector<std::pair<std::string, Employee>> MyFunction(); To turn it into: auto MyFunction();
And I was wrong. Do NOT use auto to hide that monstrosity. You FIX it. auto hides that awful thing and dumps the problem on the next poor fucker who will use it. ( People writing and using metaprogramming libraries are especially prone to doing this, since their typenames can fill entire screens ).
YOU just looked at YOUR code. Found it confusing... And decided... to HIDE it??? What it is the next person who did NOT write this code going to do when they read this going to do???
No. I beg of you. Use typedef.
You can create aliases of anything and make your code easy to read. And this only "hides" the code as much as auto and you can get the types the alias points to by musing over it. So it is auto... but way better. Because it is a UNIQUE name. Which can DESCRIBE things.
Like, with the horror in the previous example. Let us have a typedef in the .hpp file where "MyFunction" is declared. Now it reads MUCH better:
std::vector<std::pair< Employee_ID, Employee>> MyFunction();
I actually understand what the pair is now! Key value pairs! And screw it. Let us typedef the pair too now that we understand it!
std::vector<Employee_KeyValuePair> MyFunction();
And fuck it. Once more! Typedef the vector too!
Employee_Roster MyFunction();
I will bet most of you reading this only realized what the hell that moster was when you got near the end. BECAUSE THE FIRST THING IS FREAKING UNREADABLE! Fix it. Make your code readable. If you feel the urge to use an auto to hide a typename, it is time to typedef that motherfucker!
227 notes
·
View notes
Text

my pie #mypie
#the stardew valley cookbook does not pull any punches. this is fantastic#tart enough that I need ice cream with it though
3 notes
·
View notes
Note
HAPPYBIRTHMONTH. YOUREGETTING APPLY PIE
YAYAYAYAYAYAYAY I LOVE MY PIE #MyPie ❤️❣️❤️❣️🍎🥧
2 notes
·
View notes
Text
Static Typing in Dynamic Languages: A Modern Safety Net
Content: Traditionally, dynamic languages like Python and JavaScript traded compile-time type safety for speed and flexibility. But today, optional static typing—via tools like TypeScript for JavaScript or Python’s typing module—brings the best of both worlds.
Static types improve code readability, tooling (like autocompletion), and catch potential errors early. They also make refactoring safer and large-scale collaboration easier.
TypeScript’s popularity showcases how adding types to JavaScript empowers developers to manage growing codebases with greater confidence. Similarly, using Python’s type hints with tools like mypy can improve code robustness without sacrificing Python’s simplicity.
For teams prioritizing long-term maintainability, adopting static typing early pays dividends. Organizations, including Software Development, advocate for using typing disciplines to future-proof projects without overcomplicating development.
Static typing is not about perfection; it’s about increasing predictability and easing future changes.
Start by adding types to critical parts of your codebase—public APIs, core data models, and utility libraries—before expanding to the entire project.
3 notes
·
View notes
Text
In 2025, Python best practices emphasize type hints, modular code, async programming, and test automation. Use virtual environments, follow PEP 8, and leverage tools like Black, Ruff, and MyPy. Adopt secure coding practices, optimize performance with built-ins, and document code clearly using docstrings and Markdown-friendly formats.
0 notes
Text
Barcodes and Signal Recovery
▌▌▖▌▖▘▌▖▖▖▌▖▘▖▖▖▌▘▘▖▖▖▌▖▖▖▘▖▖▌▖▖▘▌▌▌
Last week I ran across an interesting project that caught my attention called dollcode by a GitHub user by the name of v01dlabs.
Of it's own, it's an exceptionally straightforward project: encode numbers and strings using a ternary code based on some simple Unicode characters ▌▖▘. I've long had a fascination with the way barcodes are read and the signal processing that goes with it, so I dug in to the working logistics.
Unfortunately, as I fiddled with it and tried to understand how one might decode it, it became increasingly clear that there were some limitations to the coding being used. For example, the encoding for "x" is "▌▌▌▌" and the encoding for the number 120 is also "▌▌▌▌". Similarly, the encoding p is "▘▘▘▘", which, if you don't know how tall the barcode is, looks exactly the same as the encoding for "(" which is "▖▖▖▖".
So given the seed and some knowledge about signal recovery, I decided to set out to make my own variation of the dollcode signaling method.
In my design, which I ended up calling signalbar, I added several features to constrain the coding, and improve its recovery with flexible optical media (printed paper) as the primary consideration.
Rather than encode data directly, a 4-to-3 encoding would be used; 4 bits of information using 3 trits.
The minimum unit of transfer would be a nibble. This is convenient in the 4-to-3 encoding, but also means that sending data smaller than 4 bits would require the cooperation of a higher level protocol.
Each symbol would actually come from one of three symbol tables based on the last bit of the previous symbol. This would allow for error detection and make use of the unused codes.
Two ▌ trits in a row would never appear outside of control symbols. This would make detecting control signals very easy.
Framing symbols would be added that could be used to detect the beginning and end of transmission. These symbols would be the same in all three encoding tables to simplify implementation. The start symbol would begin with a ▌▌ and the stop symbol would end with ▌▌, ensuring that the edges of the frame would always be max height and even if read backwards would immediately trigger the ▌▌ control sequence detection.
Symbols would be chosen such that no arrangement of the symbols could possibly create an infinitely long run, and symbols would be chosen in a way to minimize the maximum run length. This would aid in both clock recovery and detecting the code height on paper that wasn't flat since you could guarantee that you would see symbols of different sizes in a known and short window.
There are several things I think might be useful, such as frame length encoding and check codes, but those logistics are being left to higher level protocols. This implementation is mostly about the encoder/decoder hardware; so anything beyond what that is beyond the scope of this project for now.
With that said, the signalbar repo itself ended up being a powerful opportunity to do some work with GitHub Actions (I had been using Gitlab CI/CD up till now, and Jenkins before that) so that was interesting, and with some more time, I may add some explicit tests to verify the function of the module. But even without tests, it was a great way to bring pylint and mypy to bear, and made refining the code very nice.
However, this was largely just an amusement since I hadn't done a lot of personal programming over the last few years thanks to work. I don't know if I'll go far enough with this project to truly finish it up. dollcode, and now signalbar, are interesting, but I wouldn't particularly regard either as especially useful; just a neat way of exercising the ol' braincells. Nevertheless, I recommend you go check it out; there are some useful ways to think about signaling that are trapped up in the specific implementation that this toy example should make fairly clear (such as how 8b10b encoding solves the self-clocking issue.)
With that said, I have stuff in the pipeline that is more useful, but that writeup will have to wait for a different day.
#programming#barcodes#barcode scanner#barcode#python#python3#dollcode#signalbar#silly things I do to keep myself sharp and entertained
0 notes
Text
Python Code Quality Automation: Enhancing Network Automation, Pandas Training, and Pytest for Networking
Python has become one of the most widely used programming languages across various domains, from web development to data science, automation, and even network management. In the realm of network automation, Python plays a pivotal role, offering robust tools and libraries that streamline tasks, enhance workflows, and improve overall efficiency. This article will delve into several key areas where Python enhances network automation, including Python Code Quality Automation, Python Network Automation Courses, Python Pandas Training for Networks, and Python for network engineers.

Python Code Quality Automation: Ensuring Clean, Efficient Code
In any development environment, code quality is paramount. Poorly written code can lead to bugs, inefficiencies, and security vulnerabilities. In network automation, where the complexity of tasks is high, ensuring that code is well-written, maintainable, and efficient is critical. Python code quality automation tools are indispensable in this process.
Python offers several tools that help automate the process of checking and enforcing code quality:
Linters: Tools like Pylint and Flake8 are designed to analyze Python code for potential errors, style violations, and complexity issues. These tools can automatically flag problems such as unused variables, improper indentation, and potential logic errors. By automating this process, developers save time and ensure their code adheres to best practices, especially in network automation projects where reliability is key.
Formatters: Python's Black formatter can automatically format code to adhere to a consistent style. This is particularly useful in network automation projects that involve collaboration among multiple developers. Consistent formatting helps improve readability, making it easier for teams to collaborate and troubleshoot issues.
Static Analysis: Tools like Pyflakes and Mypy help detect errors in code without executing it, which is especially useful in network automation scripts that may interface with critical network infrastructure. These tools can catch issues like type mismatches and undeclared variables, preventing bugs before they even occur.
By automating code quality checks, developers can ensure that their network automation scripts are not only functional but also robust and maintainable.
Python Network Automation Courses: Learning the Essentials
As network infrastructures become more complex, traditional manual configuration and troubleshooting methods are no longer sustainable. Python network automation courses are essential for network engineers and developers who want to streamline their workflow and enhance their capabilities.
A typical Python network automation course will cover several core areas:
Network Programming with Python: Students will learn how to interact with network devices (routers, switches, firewall) using Python. This involves using libraries like Netmiko and NAPALM to automate common tasks such as configuring devices, fetching device statuses, and running diagnostics. By automating these tasks, network engineers can reduce human error and increase efficiency.
APIs and Network Automation: Modern network devices often provide RESTful APIs that allow Python scripts to interact directly with network equipment. Learning to work with these APIs is a key aspect of network automation training. Students will gain hands-on experience in sending API requests to network devices, retrieving information, and performing configuration changes.
Ansible and Python: Ansible is a popular automation tool that can work seamlessly with Python. Many courses incorporate learning how to use Python in conjunction with Ansible to automate more complex network tasks, such as managing configurations across multiple devices or orchestrating network changes in response to certain triggers.
Error Handling and Debugging: Effective network automation also involves being able to handle errors gracefully. Training often covers best practices in error handling, troubleshooting, and debugging automated scripts to ensure network automation tasks run smoothly.
By investing time in a Python quality assurance training, professionals can learn how to automate tasks such as device configuration, performance monitoring, and fault detection, transforming the way they manage network infrastructure.
Python Pandas Training for Networks: Leveraging Data in Network Automation
Network management and troubleshooting often generate large amounts of data, from performance metrics to logs, traffic analysis, and more. This is where Python Pandas comes into play. Pandas is a powerful library for data manipulation and analysis, making it ideal for processing the complex data generated by network systems.
Network engineers can benefit from Python Pandas training in the following ways:
Log Analysis: Network devices typically generate vast amounts of log data, which can be overwhelming to manually sift through. Pandas allows engineers to load log files into dataframes, where they can filter, clean, and analyze the data with ease. This makes it much easier to pinpoint issues such as security breaches, network slowdowns, or device malfunctions.
Traffic Analysis: Pandas can be used to analyze network traffic data, such as bandwidth usage, latency, and packet loss. By importing raw data into Pandas, engineers can create visualizations, perform trend analysis, and gain insights into network performance, helping them make informed decisions about optimization.
Automation Reporting: For network automation tasks, Python Pandas can be used to automate the generation of reports based on real-time network data. This is especially useful for network monitoring and creating dashboards that track performance metrics or incidents over time.
By gaining Python Pandas training, network professionals can not only automate network management tasks but also gain deeper insights into their network’s behavior, helping them make data-driven decisions and improve performance.
Python Pytest for Networking: Automated Testing in Network Automation
One of the most critical aspects of network automation is ensuring that scripts and configurations are working as intended. This is where Python Pytest for networking becomes invaluable. Pytest is a popular testing framework in Python that allows developers to write simple yet powerful tests for their code.
In network automation, Pytest can be used for:
Unit Testing Network Scripts: Before deploying a network automation script, it’s essential to ensure that the code works as expected. Pytest allows engineers to write unit tests that simulate different network scenarios, such as testing device configurations or verifying the output of a network diagnostic command.
Integration Testing with Real Devices: Pytest can also be used for integration testing. Network automation scripts often interact with multiple devices and services, and Pytest allows developers to test the entire system by simulating interactions with real network devices. This helps identify issues before they affect production networks.
Regression Testing: After making changes to network automation scripts, it’s important to ensure that the new changes don’t break existing functionality. Pytest can be used to run regression tests, ensuring that previously functioning parts of the system continue to work as expected.
By incorporating Pytest for networking into their workflow, network engineers can ensure that their automation solutions are reliable and resilient.
Conclusion
Python is a game-changer in the world of network automation. With tools for ensuring code quality, resources for learning network automation, data manipulation with Pandas, and testing capabilities with Pytest, Python enables network engineers to automate complex tasks, enhance efficiency, and improve the quality of their network management processes. Whether you're an aspiring network automation professional or an experienced engineer looking to expand your skill set, diving into Python’s capabilities in network automation is a step toward transforming your approach to network management.
For More Info:-
automate configs with Jinja2
automate data transformation
automate network configs with Scrapli
0 notes
Text
Enhance Flask Code Quality with Type Hinting and MyPy
Introduction Using type hinting and MyPy to improve Flask code quality is a crucial aspect of modern software development. As codebases grow in complexity, static type checking and code analysis become essential tools for maintaining code quality, detectin issues early, and preventing bugs. In this tutorial, we will explore the world of type hinting and MyPy, a static type checker for Python.…
0 notes
Text
Type annotation
파이썬의 타입 주석(Type Annotation)은 변수나 함수의 매개변수, 반환값 등에 대한 타입 정보를 명시적으로 지정하는 문법입니다. 이것은 코드의 가독성을 높이고, 개발자들이 코드를 이해하고 유지보수하는 데 도움이 됩니다. 하지만 파이썬은 동적 타이핑 언어이므로, 이러한 타입 주석은 실행 시간에는 무시되고, 주로 정적 분석 도구 등에서 활용됩니다.
변수에 대한 타입 주석:
pythonCopy code
age: int = 25 name: str = "John"
위의 예제에서 age 변수는 정수(int) 타입이고, name 변수는 문자열(str) 타입임을 명시적으로 표현하고 있습니다.
함수 매개변수와 반환 값에 대한 타입 주석:
pythonCopy code
def add(x: int, y: int) -> int: return x + y
위의 예제에서 add 함수는 두 개의 정수 매개변수를 받아 정수를 반환하는 것으로 타입을 명시하고 있습니다.
List, Tuple, Dictionary 등에 대한 타입 주석:
pythonCopy code
from typing import List, Tuple, Dict def process_list(data: List[int]) -> Tuple[int, List[int]]: # 함수 내용 result: Dict[str, int] = {'count': len(data)} return len(data), data
위의 예제에서는 리스트, 튜플, 딕셔너리 등에 대한 타입 주석을 사용하는 방법을 보여줍니다. List, Tuple, Dict 등은 typing 모듈을 통해 제공됩니다.
타입 주석은 주석이므로 실제로 실행 시에는 무시되지만, 정적 타입 검사 도구를 사용하여 코드를 분석하거나, 통합 개발 환경에서 코드 작성 중에 도움을 받을 수 있습니다. MyPy, Pyright, Pyre 등은 파이썬 코드를 정적으로 분석하여 타입 오류를 찾아주는 도구 중 일부입니다.
0 notes