Such clear thinking and elucidation around concurrency!
Thank you Mo Lun for creating a brand new Chinese translation of the latest version of A Byte of Python book!
In Mo Lun’s words:
I am a common journalism student from CYU, Beijing. And actually, I am an absolute newbie in Python programming when I start to translate this book. Initially, it was just a whim, but when I done this work, I realized that a decision triggered by interest had prompted me to go so far. With the help of my predecessors’ translations and the vast amount of information provided by the developed Internet, and with the help of my friends, I prudently presented this translation edition. I just hope my translation work will help other newcomers in learning Python. At the same time, I am always waiting for my translation of the comments and suggestions, and ready to change or improve this superficial work.
Note that the full translations list is at https://python.swaroopch.com/translations.html and you can read how to create a new translation at https://python.swaroopch.com/translation_howto.html.
I have converted the book to AsciiDoc format and also converted the book back to Python 2 (I got tired of readers emails who were confused between using Python 2 and reading the Python 3 version of the book and vice-versa).
- The updated online version is at https://www.swaroopch.com/notes/python/
- The AsciiDoc sources are at https://github.com/swaroopch/byte_of_python
- PDF is at http://files.swaroopch.com/python/byte_of_python.pdf
- EPUB is at http://files.swaroopch.com/python/byte_of_python.epub
- Mobi (new) is at http://files.swaroopch.com/python/byte_of_python.mobi (for Kindle)
Please let me know any feedback regarding the same.
Advantages would be:
- The sharing of database ORM models across multiple programming languages will be seamless.
- Making the API available via Thrift (like the Evernote API) implies native API wrapper libraries can be automatically generated for almost any programming language.
- Using Thrift also means the storage of logs, etc. in JSON / Thrift format will be straightforward and migration to a Lambda Architecture in future would be far more plausible as well.
- Performance enhancements such as converting long keys to actually short keys in backend (for MongoDB, HBase) and using good hash keys (for DynamoDB) can be handled in this layer without every language-specific wrapper having to implement it.
- Switching some data from Postgres to MongoDB or sharding in MongoDB, etc. could be hidden as internals of this layer.
- Rate-limiting, monitoring and scaling would have been easy – and Django memory leaks, etc. would not affect other parts of the system…
- This would have easily enabled having a lot of small apps instead of a big monolithic Django app, etc.
Did we just sort-of reinvent Datomic?
Of course, this is not a new idea at all, take restSQL as an example – my question is why is this not talked about more often?
Do most frameworks support this? If not, why not? If so, why don’t most frameworks don’t talk about such a use case in their documentation? If I use Django, I’ll start writing the models and use South to create migrations, and that’s that. If I have to reuse those model, from say, Java, then you’re on your own. The point is that, by default, Django (or Rails) doesn’t encourage you to do such a thing. If you go for a lighter framework such as Flask, then this becomes easier because the ORM is anyway not part of the framework.
Is this concept felt needed only in a polyglot case (multiple database systems, multiple programming languages)?
P.S. Also read Stevey’s Google Platforms rant.
Update on [2013-04-28 Sun]: Also see the very useful tech talk Designing a Beautiful REST+JSON API.
I was reading about the EDN format over the weekend. EDN (pronounced like in “eden garden”) is a data format in the same league as JSON but is supposed to have some nifty features such as sets, keywords, date-time type, custom types, and also being a proper subset of Clojure.
Having a date-time type as well as custom types seems useful to me, so I was taking a look at the current Python implementations of the EDN format and I didn’t find them satisfactory, for example, one of the listed ones had all custom parsing code which was difficult to read, one was not even a real implementation, just boilerplate code, etc.
So I thought why not create a better implementation and I did – it is up on GitHub at https://github.com/swaroopch/edn_format.
It has been a long time since I did lex and yacc, so it was a fun weekend project :)
Some people, when confronted with a problem, think “I know, I’ll use a wiki” Now they have no idea how many problems are there.
The above quote summarizes my experience in the past years in having converted A Byte of Python book into a wiki. I was hoping to make it much easier for readers to make corrections and contributions to the book. The only thing it enabled is tons of spam.
The second issue was that lots of readers kept emailing me to ask about ebook and kindle versions of the book which I could not do because it was stuck in a wiki format.
The solution was obvious – Pandoc, but it just seemed too daunting a task to do and hence I delayed it for years. It has been done now, thanks to my wife who did the conversion from the earlier Mediawiki syntax.
I also wrote a small Fabric file to update the websites in a single command invocation – so now I can edit the book and by running one command, it will update the book chapters pages on the WordPress site as well as generate and update the PDF and EPUB files stored in AWS S3.
I have also made a few quick changes to the text:
- Overhauled installation and first steps chapters for Python 3 and explaining how to find and open a terminal application in detail
- Recommending newbies to start with ActiveState Komodo Edit editor and instructions on how to use it to create and run a source file
- Removed unnecessary sections such as
- Moved escape sequences in strings to the ‘More’ chapter in the end, it was an unrequired hurdle
I haven’t done an exhaustive review of the text yet, because frankly, that is draining, but I hope this is the start of me responding to readers’ suggestions on how to improve the book.
But still, it’s difficult to top this:
I’m a 16-year-old boy from Guangxi,China.
Thanks for the book named A Byte of Python of yours.I learnt lots of things from it.
I have never been able to program before but with your byte of python I actually managed to not only write the small programs but even understand. For me this is good because I am 57 years old and I always gave up any programming I attempted to learn before no matter how desirable a goal it seemed. The real problem I run into is what the words mean. I consider myself fairly literate but when I run into a special word I do not know the meaning of, it frustrates me, especially when I cannot find a definition, and there goes the understanding. Also, there are gradients of knowledge that are skipped. One minute you’re riding along nicely and the next minute you’re behind the 8 ball. Along the way, one quits. You, on the other hand, seem to have undercut this better than anyone I have encountered before. Your explanations are clear and concise and you define words well so I understood more of python than I have of any other language including Basic which I tried and gave up on years ago and the understanding flows very well. And you’re giving hope to an older person who really wants to learn to program!
Thanks so much
Indian companies just don’t take Python seriously, not as much as Perl. Why is that?
Most companies opting for Ruby as their programming language of choice instead of Python
The future of the Perl programming language?
Phew, that is quite a lot of people asking about programming language adoption!
The TLDR version of my thoughts on this topic is: Companies are choosing the right tool and the right community for the right job. Which programming language is used in your company depends on the kind of work they are doing.
Ruby and Rails ecosystems are built by and built for web programmers. That is why you will see web programmers switching from PHP and Python to Rails. For web programming, I do believe that Rails has an edge, not just because of the framework itself, but because of the community rallying around it. The amount of amazingly useful stuff that they churn out outpaces any other community w.r.t. web-dev, and they even have quick effective screencasts to make it digestable, hence their edge!
Data analysis is the hot thing these days and as per O’Reilly, Python is the choice of language for data analysis even though Ruby gets more buzz in the tech news. It is the same reason why scientists are switching away from Ruby to Python.
So I have a question back for the 134 people who asked the above 3 questions – Is the programming language chosen by your company match the kind of community we have described here?
What would you say to these 134 people?
“Coding Homework” is a small website that I have built to list small problems that one can work on, to learn how to use a new programming language. For example, small problems requiring to read from a file, or to use regular expressions, how to find duplicate files in a folder, and so on.
Note that the problems listed on the site is not for testing your algorithm skills, there are many sites for that already.
This list was inspired by repeated requests and suggestions from readers of A Byte of Python for homework problems at the end of each chapter to exercise the skills they have just learned. So I thought why not make it applicable to any language and multiple programming skill levels. And it’s a good topic that can be collaboratively worked on with the programming community, à la Stack Overflow.
All the content will be licensed under Creative Commons Attribution-Share Alike 2.5 India License so that anybody can reuse this content, especially in classroom situations.
I also had my own specific goals when implementing this side project:
- Solve the lack of “homework problems” for people to exercise their programming skills, especially in the context of learning a new programming language.
- Learn how to do website layouts, specifically how to use YUI Grids CSS.
- Learn how to pick colors for website design; ColorCombos turned out to be useful.
- Learn to use Google App Engine.
It has been a fun side-project, spending a few hours here and there. It is very far from polished, but the basic functionality works. There is still more to do — adding a search functionality, conforming to standard UI design patterns, caching for the rendered HTML (from Markdown), optimizing the housekeeping code, and so on.
This site itself is a good example on the kind of problems that beginners can work on, but they would not know what kind of problems they can solve and what level of expertise (beginner / intermediate / advanced) would be needed. That is where this list of problems can help.
I request you to spend 5 minutes of your creativity to add a few problems so that beginners and intermediate level folks will have interesting problems to test their learning of a new programming language. Thanks!
Roorky is a new startup that has created a new file format and software for interactive books. As part of the default installation of the software, they are bundling A Byte of Python free with the software.
What is interesting is that this may help complete beginners who stumble in getting started with IDLE, etc. The most common email that I get asked is when people run
python abc.py on the IDLE interpreter prompt and wonder why it is not working – both the concepts of two command lines as well as the concept of running a program is not grokked well by beginners who are getting started, especially people who are self-taught. From that perspective, this is an interesting approach to the problem.
I am still not convinced about this approach because people cannot bypass the learning of how to edit, compile and run the code in the native environment, because that will be needed when writing new programs. It will be interesting how the two opposing needs will be balanced.
But I hope beginners will try it out and see if it helps them get started.
Note: Be warned that it is a beta software.