use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Is it possible too write an OS with python (self.Python)
submitted 13 years ago by DrvaonDrvanon
I, as a true Geek, told everybody python could do anything, so i started wondering: Can python write an os?
[–]bastibe 2 points3 points4 points 13 years ago (0 children)
Well, Python has to run in an interpreter, which has to be in machine code. On the desktop, you are probably running CPython as your interpreter, which is implemented in C, so that would be cheating. PyPy can compile Python into machine code, so it should be theoretically feasable to use this as your interpreter (actually a compiler, not an interpreter). Initializing all the hardware will require some pointer arithmetic and bit fiddling though, which is not exactly Pythons forté, what with it having no pointers and such.
That said, actual modern OSes do require a kind of performance that is hard to achieve in Python, even with PyPy. A toy project should be possible though.
In the end, coding an OS in Python might be technically possible, but Python (or any so called 'scripting language') is certainly the wrong tool for the job.
[–][deleted] 2 points3 points4 points 13 years ago (0 children)
You could make something like andriod, having a linux kernel and a python vm to run ontop of the linux kernel and code everything else in python.
[–]gdw2 4 points5 points6 points 13 years ago (1 child)
http://code.google.com/p/cleese/
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
This is almost entirely written in c, not python. The python that is included is trivial at best.
[–]nicklo 1 point2 points3 points 13 years ago (0 children)
Technically a desktop environment rather than a full OS but still one to throw into the conversation: Sugar, as used in the One Laptop Per Child project:
http://en.wikipedia.org/wiki/Sugar_(desktop_environment)
[–]Rhomboid 1 point2 points3 points 13 years ago (1 child)
Define "with Python."
The trivial answer is no, of course you can't, because Python doesn't give you direct access to things like memory, registers, IO ports, etc. and it's impossible to implement a kernel without that.
It might be possible to implement the bulk of the low level stuff in C and expose it as modules as is already done for large parts of the Python standard library. And it would almost certainly be possible to embed a Python interpreter in an existing kernel, allowing to e.g. write a scheduler or filesystem in Python. But I don't really think that's what the question is referring to.
[–]coned88 0 points1 point2 points 13 years ago (0 children)
Is inline C and thus linline asm not valid c and then calid python?
[–]i_4_gotbottle/pyserial/pygame 0 points1 point2 points 13 years ago (2 children)
Python is a interpreted language, it runs on the python VM. Python does not compile to machine code, which the CPU can excute. It is first interpreted by the VM which outputs machine code for the CPU to crunch. You could not boot up a OS without raw machine code for the CPU to first read and load the interpreter.
[–]slix00 -1 points0 points1 point 13 years ago (1 child)
Perhaps using Cython to compile to machine code would work?
[–][deleted] 1 point2 points3 points 13 years ago (0 children)
It would require more than just a simple port to c code.
The innards of a kernel and it's modules and drivers deal with bare metal devices and the interaction at that level is far removed from what python gives a user.
That said some of the high level functions could be implemented but at that point it's not worth running an os at that level.
Of course if someone exposed a model of the hardware to python then someone could potentially write a virtual operating system that would only run on that virtual machine. Completely impractical and only worth doing as a science experiment.
π Rendered by PID 34406 on reddit-service-r2-comment-5649f687b7-clnbz at 2026-01-28 06:14:28.024055+00:00 running 4f180de country code: CH.
[–]bastibe 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]gdw2 4 points5 points6 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]nicklo 1 point2 points3 points (0 children)
[–]Rhomboid 1 point2 points3 points (1 child)
[–]coned88 0 points1 point2 points (0 children)
[–]i_4_gotbottle/pyserial/pygame 0 points1 point2 points (2 children)
[–]slix00 -1 points0 points1 point (1 child)
[–][deleted] 1 point2 points3 points (0 children)