Python with Braces
Bython is a Python preprocessor on GitHub, enabling curly brace usage instead of whitespace for indentation. It ensures compatibility with modules like NumPy and Matplotlib. Installation options include pip or GitHub cloning.
Read original articleBython is a Python preprocessor tool available on GitHub that allows writing Python code using curly braces instead of relying on whitespace for indentation. It helps avoid indentation issues and is compatible with Python modules like NumPy and Matplotlib. Bython files with a .by extension are translated into Python files for execution. Installation can be done via pip from PyPI or by cloning the GitHub repository. The repository structure includes directories for the parser, utilities, manual pages, scripts, and test cases. A code example demonstrates the usage of curly braces in Bython. Additionally, a quick intro explains how to run Bython programs and translate Python files to Bython using `py2by`. For more information, visit the Bython GitHub repository.
Related
As you learn Forth, it learns from you (1981)
The Forth programming language is highlighted for its unique features like extensibility, speed, and efficiency. Contrasted with Basic, Forth's threaded code system and data handling methods make it versatile.
What scripting languages come out of the box on Debian 12?
The article discusses pre-installed scripting languages in Debian 12: bash, Python 3, awk, sed, and Perl. Emphasizes convenience for offline work, ease of script transfer, and benefits of learning Python.
Igneous Linearizer: semi-structured source code
The Igneous Linearizer project enhances source code in Obsidian Markdown format, enabling features like links and transclusion. It sacrifices AST correctness for compatibility with text editors and Git, benefiting literate programming. Users must follow specific input file formats for optimal use.
Show HN: Adding Mistral Codestral and GPT-4o to Jupyter Notebooks
Pretzel is an open-source tool enhancing Jupyter with AI code generation, inline tab completion, sidebar chat, and error fixing. Seamless transition from Jupyter is possible, maintaining compatibility. Installation via 'pip install pretzelai'.
Python Modern Practices
Python development best practices involve using tools like mise or pyenv for multiple versions, latest Python version, pipx for app running. Project tips include src layout, pyproject.toml, virtual environments, Black, flake8, pytest, wheel, type hinting, f-strings, datetime, enum, Named Tuples, data classes, breakpoint(), logging, TOML config for efficiency and maintainability.
To some, significant indentation is better.
Others — too used to braces — miss them dearly in Python.
Next ones, vie for the non-text source code, something to get us past these discussions altogether (editors working on .pyc files directly?).
For programs to be maintained, they need to be read, understood and improved. One—often undervalued—skill in programming is to write beautiful code, because that is more art than craft. And unfortunately, tools like Black prohibit the true artists from expressing themselves clearly with code formatting too. And to those, white-space or braces matters on a different level, and everything else is attempting to make up excuses for why one is better than other.
And while conceptual operations we do on the code seem simple on the surface, devising an editing tool that would do semantic operations on the AST is fricking hard and likely to be very non-ergonomic. Look at all the attempts to make code refactoring tooling: it's crazily complex and confusing that it's simpler to just go and grep for a string and fix anything you find.
As long as it's faster to use regular editing operations to shuffle code around, indent or unindent it (or wrap it with braces), tweak one thing here or there, simple text editors will mostly rule the world of programming.
if foo == 1: # {
print "one foo"
# }
It also supports PASCAL style begin/end: if foo == 1: # begin
print "one foo"
# end
And it's fully internationalized, even supporting mixing multiple languages: if foo == 1: # beginnen
print "one foo"
# 終了
In fact, you can even mix styles: if foo == 1: # begin
print "one foo"
# }
Or optionally leave one of them out, or spell them any way you like, if you feel like it: if foo == 2:
print "one foo"
# fi
Even verbose COBOL style: if foo == 1: # perform conditional foo value check
print("one foo")
# end perform conditional
Make python a lisp - indentation is just the number of brackets.
Hy - http://hylang.org
Antoine de Saint-Exupéry
Unfortunately, we still live in an era where humans have to adapt to technology rather than the other way around. From my perspective, this is particularly true for programming.
For me, Python is a good (though not ideal) mix of simple syntax and power. The language is characterized by low redundancy, meaning it uses fewer unnecessary characters like semicolons or curly braces to mark the end of a line. If a human can recognize the end of a line without special characters, then the compiler should be able to as well.
As someone with ADHD, I find it particularly difficult not to get distracted by these and other superfluous details. These small distractions add up and can become very burdensome. Interestingly, I found it easier to program in Assembler and Modula than in languages like C++ (MSVC), PHP, or JavaScript – at least as long as the projects were small.
Even a brief look at Rust’s syntax causes me almost physical discomfort, no matter how great, powerful, and useful the language may be.
For this reason, I almost exclusively use the terminal for emails, calendar, and programming, even though complex GUIs can simplify some tasks.
Although Python is not perfect in terms of syntax, it offers a good balance. Perhaps one day, before the perfect programming language exists, we will be able to use AI and ML to explain to the computer what a program should do with simple language (better than ChatGPT right now), just like Captain Picard. In fantasy, a few letters, punctuation marks, and some grammar is all that is needed. This may lead to inaccuracies in human-to-human communication, but that does not mean the same problems must occur in communication with an intelligent compiler.
Making syntax as “human-readable” as possible should always be the highest priority. We could unlock so much potential this way.
This transpiles into Python. Okay. So for this to work in a collaborative environment, EVERYONE working on the code has to use it. Given how popular python is, and the natural inertia of programming languages, I simply don't see that happening.
The reasons for this are legion: From programmers simply being used to how python looks, over IDEs and linters that would have to be remade, all the way to automated tooling.
And even if all that were not a problem: This introduces one more step and one more element into the build chain. Which is something I can't see DevOps doing, for a, at the end of the day, purely cosmetic change.
[0] https://github.com/yairchu/awesome-structure-editors/blob/ma...
[1] https://news.ycombinator.com/item?id=9495493
[2] https://web.archive.org/web/20151023070244/http://joelburget...
IMHO, some level of linting should be required. I would often have to reject lengthy and excellent pull requests (PRs), just because autoformat was not pressed and three instead of four whitespaces are in kotlin code. That annoys everyone. Python does that right, code won't compile with the three version whitespace, which is easily spotted before the PR.
Text editors are easy, but are waaaaay in the past. There could be much much better 3D like editors out there, but everyone is lazy to make one that would make your life much easier.
Now Ruby as his own defects of course. Static type can be integrated through Sorbet, but that still something out of the core for now. On that side, PHP had during the last years shown a far more remarkable pace in integrating many advanced feature for OOP (and functional stuffs are also progressing well). That said, the foundation of Ruby still win my preference in term of elegance and feeling of coherence.
I didn’t touch that much Python over the last few years. The only (significant) reason I would see it as opportune is its heavy use in ML and the like domains, and I didn’t have an opportunity to dig this domain much.
Also TS has slightly more consistent syntax for return types than Python. ``` // TS
function fn(a: Type, b: Type) : Type {
}
// Python def fn(a: Type, b:Type) -> Type {
} ```
But I want python to have to close braces on as few lines as possible. Yes I'm a Black user and wonder how.
They could fix the latter, but the REPL is Python tooling so it is required to be awful.
Pythons use their sharp, backward-curving teeth, four rows in the upper jaw, two in the lower, to grasp prey which is then killed by constriction; after an animal has been grasped to restrain it, the python quickly wraps a number of coils around it. Death occurs primarily by cardiac arrest.
IMO lack of support for them (because of the lack of a good syntax) is the main downside of Python’s significant indentation.
Despite node feeling more verbose, I've found that I understand node easier than Python. It's definitely strange to me, because there can't be that much difference between the 2, but parentheses seem to make it easier to follow structure?
This seems contradictory. But I see the benefits. Perhaps braces and an official linter would be a more ergonomic approach.
PR #1: Makes Bython self-hosting
self.onandonandon is a real pain along with copy.deepcopy
Troll. 100%. A good one at that.
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
>>>
This is how Python got big: Discuss cute issues endlessly, pretend to be a funny, benevolent community. But real issues like performance, correctness or security are never addressed, and people who dare to mention them are punished severely.
Related
As you learn Forth, it learns from you (1981)
The Forth programming language is highlighted for its unique features like extensibility, speed, and efficiency. Contrasted with Basic, Forth's threaded code system and data handling methods make it versatile.
What scripting languages come out of the box on Debian 12?
The article discusses pre-installed scripting languages in Debian 12: bash, Python 3, awk, sed, and Perl. Emphasizes convenience for offline work, ease of script transfer, and benefits of learning Python.
Igneous Linearizer: semi-structured source code
The Igneous Linearizer project enhances source code in Obsidian Markdown format, enabling features like links and transclusion. It sacrifices AST correctness for compatibility with text editors and Git, benefiting literate programming. Users must follow specific input file formats for optimal use.
Show HN: Adding Mistral Codestral and GPT-4o to Jupyter Notebooks
Pretzel is an open-source tool enhancing Jupyter with AI code generation, inline tab completion, sidebar chat, and error fixing. Seamless transition from Jupyter is possible, maintaining compatibility. Installation via 'pip install pretzelai'.
Python Modern Practices
Python development best practices involve using tools like mise or pyenv for multiple versions, latest Python version, pipx for app running. Project tips include src layout, pyproject.toml, virtual environments, Black, flake8, pytest, wheel, type hinting, f-strings, datetime, enum, Named Tuples, data classes, breakpoint(), logging, TOML config for efficiency and maintainability.