Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 PYTHON


  Python internals: adding a new statement to Python

This article is an attempt to better understand how the front-end of Python works. Just reading documentation and source code may be a bit boring, so I’m taking a hands-on approach here: I’m going to add an until statement to Python.All the coding for this article was done against the cutting-edge Py3k branch in the Python Mercurial repository mirror.The until statementSome languages, like Ruby, have an until statement, which is the complement to while (until num == 0 is equivalent to while num != 0). In Ruby, I can write:num = 3until num == 0 do puts num num -= 1endAnd it will...

2,308 0       PYTHON NEW STATEMENT RESEARCH ADDITION


  Python Performance Tips, Part 1

To read the Zen of Python, type import this in your Python interpreter. A sharp reader new to Python will notice the word “interpreter”, and realize that Python is another scripting language. “It must be slow!”No question about it: Python program does not run as fast or efficiently as compiled languages. Even Python advocates will tell you performance is the area that Python is not good for. However, YouTube has proven Python is capable of serving 40 million videos per hour. All you have to do is writing efficient code and seek external (C/C++) implementation for speed ...

3,122 1       TIPS PERFORMANCE PYTHON EFFICIENCY


  Why so many Python web frameworks?

When asked about the plethora of web frameworks for Python the answer is often that it is way too easy to put together one in Python. That certainly seems plausible since there are so many libraries that implement the components of a web framework and if it's easy to plug those pieces together then maybe that lowers the bar of entry for new frameworks. So let's give it a shot, we'll pick some components and spend a couple hours seeing how far we can get building a web framework, which we'll call Robaccia. Executive Summary: Robaccia was built in three hours and a total of 60 lines of Pytho...

2,627 0       WEB DESIGN PYTHON WEB FRAMEWORK DYNAMIC SCRIPTING LANGUAGE


  Python: calculate lighter/darker RGB colors

Many times color palettes have lighter and darker variations of the same color. This may be used to convey relative importance, or for something as simple as a gradient. Usually the designer will specify both colors. However, if you have a site that needs to allow user configurable styling, you may not want to ask the user for two variations of the same color.Here is some Python code to take a single color in RGB, and output an artitrarily lighter or darker variation of the same color. You could wrap this in a filter and use it right in your Django templates.view plainprint?def color_vari...

7,759 0       PYTHON RGC COLOR CALUCALTION LIGHTER/DARKER


  Why Python is important for you

I believe that Python is important for software development. Whilethere are more powerful languages (e.g. Lisp), faster languages(e.g. C), more used languages (e.g. Java), and weirder languages(e.g. Haskell), Python gets a lot of different things right, andright in a combination that no other language I know of has done sofar.It recognises that you’ll spend a lot more time reading code thanwriting it, and focuses on guiding developers to write readablecode. It’s possible to write obfuscated code in Python, but theeasiest way to write the code (assuming you know Python) is almosta...

5,385 0       PYTHON IMPORTANCE PARADIGM


  Create successful Python projects

The ecosystem for open source Python projects is both rich and diverse. This enables you to stand on the shoulders of giants in the production of your next open source project. In addition, it means that there's a set of community norms and best practices. By adhering to these conventions and applying the practices in your project, you may gain wider adoption for your software. This article covers practices that have worked well for building large and small projects that have gained wide user c...

1,903 0       PYTHON PROJECT OPEN SOURCE TEAM MANAGEMENT


  Before Python

This morning I had a chat with the students at Google's CAPE program. Since I wrote up what I wanted to say I figured I might as well blog it here. Warning: this is pretty unedited (or else it would never be published :-). I'm posting it in my "personal" blog instead of the "Python history" blog because it mostly touches on my career before Python. Here goes.Have you ever written a computer program? Using which language?HTMLJavascriptJavaPythonC++COther - which?[It turned out the students had used a mixture of Scratch, App Inventor, and Processing. A few students had also used Python or Java.]...

2,500 0       PROGRAMMING LANGUAGE PYTHON HISTORY B


   Python – parallelizing CPU-bound tasks with multiprocessing

In a previous post on Python threads, I briefly mentioned that threads are unsuitable for CPU-bound tasks, and multiprocessing should be used instead. Here I want to demonstrate this with benchmark numbers, also showing that creating multiple processes in Python is just as simple as creating multiple threads.First, let’s pick a simple computation to use for the benchmarking. I don’t want it to be completely artificial, so I’ll use a dumbed-down version of factorization – breaking a number to its prime factors. Here is a very naive and un-optimized function that take...

3,773 0       PYTHON MULTITASKING MULTIPROCESSING CPU BOUND