After ten years,The world's seventh star wars movie "The Force Awakens" will be released in China on January 9, 2016.It will rekindle those mysterious years of space and the time of the universe with force.But what does Star Wars have to do with the Python programming language?

Python and the industrial light magic behind Star Wars

Speaking of the python language, many people will think of system operation and maintenance, web development and other work.Few people will know that Python can also be used for the production of film visual effects,This includes the production of some special effects for Star Wars movies.

The father of Star Wars, George Lucas, founded Industrial Light and Magic (full name:industrial light and magic) in 1975, and has been involved in the production of special effects since the first Star Wars.According to the official website of python,Industrial Light and Magic has been using Python since 1996, replacing the previous unix shell scripts. Why Industrial Light and Magic made this decision,It is because python is difficult to learn,Fast development.At the time, Python was only version 1.4.

The film special effects industry is highly competitive.Production companies are constantly looking for better programming languages,Improve work efficiency.ILM has also been evaluating the use of the python language,But for almost 20 years, no better alternative has been found.

Tommy Burnette, senior technical director of Industrial Light and Magic, once commented:

Python plays a vital role in our production process.Without it,Big projects like the second part of Star Wars are difficult to complete.From collective rendering to batch processing to movie compositing,Python tightly glues all the steps together.

This shows that python is powerful.

star wars api

You know how many races appeared in the Star Wars series,How many kinds of spaceships?These answers can all be found in the star wars api.

According to the developer,The star wars api is the world's first quantifiable and programmable star wars dataset.After a long collection and collation of developers,The detailed data of the characters, races, planets, and spaceships in the Star Wars series are compiled.At present, this API has included new data from "The Force Awakens".The author of api also developed a helper library with python.

Let's see what you can do with this library.

Sort all planets by size:

import swapi
for planet in swapi.get_all ("planets"). order_by ("diameter"):
  print (planet.name)

See who has sailed more than 1 spacecraft:

import swapi
for people in swapi.get_all ("people"). iter ():
  if len (people.starships)>1:
    print (people.name)

Retrieve whether jar jar binks appear in the movie:

import swapi
pm=swapi.get_film (4)
jj=swapi.get_person (36)
for c in pm.get_characters (). iter ():
  if c.name == jj.name:
    print ("why george, why.")

star wars game written in python

Finally, I will share with you a Star Wars game developed by a foreign developer using python.Hope you like it.

This game is similar to current parkour,Control by up, down, left and right direction keys.

Isn't it cool! thumbs up! Am looking forward to!

  • Previous PHP combines Jquery and ajax to achieve waterfall effects
  • Next Basic configuration example of dynamic and static separation of Nginx with Apache or Tomcat