What's new in Django community blogs?

Ship It Day Q1 2017

Jan 18 2017 [Archived Version] □ Published at Caktus Blog

Last Friday, Caktus set aside client projects for our regular quarterly ShipIt Day. From gerrymandered districts to RPython and meetup planning, the team started off 2017 with another great ShipIt. Books for the Caktus Library Liza uses Delicious Library to track books in the Caktus Library. However, the tracking of books isn't visible to the...


How I Deploy Django Day-to-Day

Jan 18 2017 [Archived Version] □ Published at GoDjango Screencasts and Tutorials

There are a lot of ways to deploy Django so I think it is one of those topics people are really curious about how other people do it. Generally, in all deploys you need to get the latest code, run migrations, collect your static files and restart web server processes. How yo do those steps, that is the interesting part.

In todays video I go over How I deploy Django day to day, followed by some other ways I have done it. This is definitely a topic you can make as easy or complicated as you want.

Here is the link again: https://www.youtube.com/watch?v=43lIXCPMw_8?vq=hd720


Django 1.11 alpha 1 released

Jan 18 2017 [Archived Version] □ Published at The Django weblog

Django 1.11 alpha 1 is now available. It represents the first stage in the 1.11 release cycle and is an opportunity for you to try out the changes coming in Django 1.11.

Django 1.11 has a medley of new features which you can read about in the in-development 1.11 release notes.

This alpha milestone marks a complete feature freeze. The current release schedule calls for a beta release in about a month and a release candidate about a month from then. We'll only be able to keep this schedule if we get early and often testing from the community. Updates on the release schedule schedule are available on the django-developers mailing list.

As with all alpha and beta packages, this is not for production use. But if you'd like to take some of the new features for a spin, or to help find and fix bugs (which should be reported to the issue tracker), you can grab a copy of the alpha package from our downloads page or on PyPI.

The PGP key ID used for this release is Tim Graham: 1E8ABDC773EDE252.


Mathematical Modules in Python: Decimal and Fractions

Jan 16 2017 [Archived Version] □ Published at tuts+

Even the most basic mathematical operations can sometimes give an erroneous result. This happens due to limitations in storing the exact value of some numbers. You can overcome these limitations by using the decimal module in Python. Similarly, neither the math nor the cmath module that we learned about in our last tutorial can help us in doing fraction-based arithmetic. However, the fractions module in Python does exactly that.

In this tutorial, you will learn about both these modules and the different functions they make available. 

Why Do We Need a Decimal Module?

You are probably wondering why we need a module to do basic arithmetic with decimal numbers when we can already do the same using floats.

Before I answer this question, I want you to take a guess about the output value if you type 0.1 + 0.2 in the Python console. If you guessed that the output should be 0.3, you will be surprised when you check out the actual result, which is 0.30000000000000004. You can try some other calculation like 0.05 + 0.1 and you will get 0.15000000000000002. 

To understand what's going on here, try to represent 1/3 in decimal form, and you will notice that the number is actually non-terminating in base 10. Similarly, some numbers like 0.1 or 1/10 are non-terminating in base 2. Since these numbers still need to be represented somehow, a few approximations are made while storing them, which results in those errors.

The number 0.30000000000000004 is actually very close to 0.3, so we can get away with this approximation most of the time. Unfortunately, this approximation is not going to cut it when you are simulating a satellite launch or dealing with money. Another problem with these approximations is that the errors keep piling up. 

To get precise results like the ones we are used to dealing with when doing calculations by hand, we need something that supports fast, correctly rounded, decimal floating point arithmetic, and the decimal module does exactly that.

Using the Decimal Module

Before using the module, you need to import it first. After that, you can create decimals from integers, strings, floats, or tuples. When the decimal is constructed from an integer or a float, there is an exact conversion of the value of that number. Take a look at the examples below to see what I mean:

As you can see, the value of Decimal(0.05) is slightly different from Decimal('0.05'). This means that when you add 0.05 and 0.1, you should use decimal.Decimal('0.05') and decimal.Decimal('0.1') to construct the decimals.

Now that you can perform various operations on decimals, you might want to control the precision or rounding for those operations. This can be done by using the getcontext() function. This function allows you to get as well as set the value of the precision and rounding options, among other things. 

Please keep in mind that both rounding and precision come into play only during arithmetic operations and not while you are creating the decimals themselves.

You can also use some of the mathematical functions like sqrt(), exp(), and log() with decimals. Here are a few examples:

Using the Fractions Module

Sometimes, you might face situations where you need to perform various operations on fractions or the final result needs to be a fraction. The fractions module can be of great help in these cases. It allows you to create a Fraction instance from numbers, floats, decimals, and even strings. Just like the decimal module, there are a few issues with this module as well when it comes to creating fractions from floats. Here are a few examples:

You can also perform simple mathematical operations like addition and subtraction on fractions just like regular numbers.

The module also has a few important methods like limit_denominator(max_denominator) which will find and return a fraction closest in value to the given fraction whose denominator is at most max_denominator. You can also return the numerator of a given fraction in the lowest term by using the numerator property and the denominator by using the denominator property.

You can also use this module with various functions in the math module to perform fraction-based calculations.

Final Thoughts

These two modules should be sufficient to help you perform common operations on both decimals and fractions. As shown in the last section, you can use these modules along with the math module to calculate the value of all kinds of mathematical functions in the format you desire.

In the next tutorial of the series, you will learn about the random module in Python.


Python Meeting Düsseldorf - 2017-01-18

Jan 16 2017 [Archived Version] □ Published at eGenix.com News & Events

The following text is in German, since we're announcing a regional user group meeting in Düsseldorf, Germany.

Ankündigung

Das nächste Python Meeting Düsseldorf findet an folgendem Termin statt:

18.01.2017, 18:00 Uhr
Raum 1, 2.OG im Bürgerhaus Stadtteilzentrum Bilk
Düsseldorfer Arcaden, Bachstr. 145, 40217 Düsseldorf


Neuigkeiten

Bereits angemeldete Vorträge

Charlie Clark
        "Kurze Einführung in openpyxl und Pandas"

Jochen Wersdörfer
        "CookieCutter"

Marc-Andre Lemburg
        "Optimierung in Python mit PuLP"

Weitere Vorträge können gerne noch angemeldet werden. Bei Interesse, bitte unter [email protected] melden.

Startzeit und Ort

Wir treffen uns um 18:00 Uhr im Bürgerhaus in den Düsseldorfer Arcaden.

Das Bürgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der Düsseldorfer Arcaden.

Über dem Eingang steht ein großes "Schwimm’ in Bilk" Logo. Hinter der Tür direkt links zu den zwei Aufzügen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt.

>>> Eingang in Google Street View

Einleitung

Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in Düsseldorf, die sich an Python Begeisterte aus der Region wendet.

Einen guten Überblick über die Vorträge bietet unser PyDDF YouTube-Kanal, auf dem wir Videos der Vorträge nach den Meetings veröffentlichen.

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf:

Programm

Das Python Meeting Düsseldorf nutzt eine Mischung aus (Lightning) Talks und offener Diskussion.

Vorträge können vorher angemeldet werden, oder auch spontan während des Treffens eingebracht werden. Ein Beamer mit XGA Auflösung steht zur Verfügung.

(Lightning) Talk Anmeldung bitte formlos per EMail an [email protected]

Kostenbeteiligung

Das Python Meeting Düsseldorf wird von Python Nutzern für Python Nutzer veranstaltet.

Da Tagungsraum, Beamer, Internet und Getränke Kosten produzieren, bitten wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00 inkl. 19% Mwst. Schüler und Studenten zahlen EUR 5,00 inkl. 19% Mwst.

Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.

Anmeldung

Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung eingegangen. Es erleichtert uns allerdings die Planung.

Meeting Anmeldung bitte formlos per EMail an [email protected]

Weitere Informationen

Weitere Informationen finden Sie auf der Webseite des Meetings:

              http://pyddf.de/

Viel Spaß !

Marc-Andre Lemburg, eGenix.com


Static Websites with Flask

Jan 13 2017 [Archived Version] □ Published at Dougal Matthews under tags  flask frozen python static

I was investigating static site generators last week, I have used a couple of them before; this website is generated by Pelican, I am one of the maintainers of MkDocs, I use Sphinx regularly and I have written my own before1.

However, this time I wanted something a little …


New Code eBooks Available for Subscribers

Jan 12 2017 [Archived Version] □ Published at tuts+

Do you want to learn more about developing iOS apps with Swift? How about building web applications with Go, or functional programming in JavaScript? Our latest batch of eBooks will teach you all you need to know about these topics and more.

our new selection of code eBooks

What You’ll Learn

In the past couple of months we’ve made 16 new eBooks available for Envato Tuts+ subscribers to download. Here’s a selection of those eBooks and a summary of what you can learn from them.

1. TypeScript Design Patterns

TypeScript Design Patterns
TypeScript Design Patterns

In programming, there are several problems that occur frequently. To solve these problems, there are various repeatable solutions that are known as design patterns. Design patterns are a great way to improve the efficiency of your programs and improve your productivity.

This book is a collection of the most important patterns you need to improve your applications’ performance and your productivity. The journey starts by explaining the current challenges when designing and developing an application and how you can solve these challenges by applying the correct design pattern and best practices.

2. Swift: Developing iOS Applications

Swift Developing iOS Applications
Swift: Developing iOS Applications

The Swift: Developing iOS Applications eBook will take you on a journey to become an efficient iOS and macOS developer, with the latest trending topic in town. Right from the basics to the advanced level topics, this eBook will cover everything in detail. 

The learning path consists of four modules. Each of these modules is a mini-book in its own right, and as you complete each one, you’ll gain key skills and be ready for the material in the next module.

3. Python: Journey From Novice to Expert

Python Journey from Novice to Expert
Python: Journey from Novice to Expert

Python is a dynamic and powerful programming language, having its application in a wide range of domains. It has an easy-to-use, simple syntax, and a powerful library, which includes hundreds of modules to provide routines for a wide range of applications, thus making it a popular language among programming enthusiasts.

This eBook will take you on a journey from basic programming practices to high-end tools and techniques that will give you an edge over your peers.

4. Learning GraphQL and Relay

Learning GraphQL and Relay
Learning GraphQL and Relay

There’s a new choice for implementing APIs: the open-source and Facebook-created GraphQL specification. Designed to solve many of the issues of working with REST, GraphQL comes alongside RelayJS, a React library for querying a server that implements the GraphQL specification. This book takes you quickly and simply through the skills you need to be able to build production-ready applications with both GraphQL and RelayJS.

5. JavaScript: Functional Programming for JavaScript Developers

JavaScript  Functional Programming for JavaScript Developers
JavaScript : Functional Programming for JavaScript Developers

Functional programming is a way of writing cleaner code through clever ways of mutating, combining, and using functions. And JavaScript provides an excellent medium for this approach. By learning how to expose JavaScript's true identity as a functional language, we can implement web apps that are more powerful, easier to maintain and more reliable.

This book will take you on a journey to show you how functional programming when combined with other techniques makes JavaScript programming more efficient.

6. Ionic 2 Blueprints

Ionic 2 Blueprints
Ionic 2 Blueprints

Ionic 2, the latest version of Ionic Mobile SDK, is built on the top of latest technologies such as Angular 2, TypeScript, SASS, and lot more. The idea behind Ionic 2 is to make the entire app development process even more fun.

This book makes it possible to build fun and engaging apps using Ionic 2. You will learn how to use various Ionic components, integrate external services, derive capabilities, and most importantly how to make professional apps with Ionic 2. 

By the end of this book, you will be able to proudly call yourself a pro Ionic developer who can create a host of different apps with Ionic, and you’ll have a deeper practical understanding of Ionic.

7. Go: Building Web Applications

Go Building Web Applications
Go: Building Web Applications

Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. It is a statically typed language with syntax loosely derived from that of C, adding garbage collection, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library.

This eBook starts with a walkthrough of the topics most critical to anyone building a new web application. Whether it’s keeping your application secure, connecting to your database, enabling token-based authentication, or utilizing logic-less templates, this book has you covered.

8. Django: Web Development With Python

Django Web Development with Python
Django: Web Development With Python

Data science is hot right now, and the need for multitalented developers is greater than ever before. A basic grounding in building apps with a framework as minimalistic, powerful, and easy-to-learn as Django will be a useful skill to launch your career as an entrepreneur or web developer. 

Django is a web framework that was designed to strike a balance between rapid web development and high performance. This book will take you on a journey to become an efficient web developer thoroughly understanding the key concepts of Django framework. By the end of the four modules, you will be able to leverage the Django framework to develop a fully functional web application with minimal effort.

Start Learning With a Yearly Subscription

Subscribe to Envato Tuts+ for access to our library of hundreds of eBooks. With a Yearly subscription, you can download up to five eBooks per month, while the Yearly Pro subscription gives you unlimited access.


Internet Pause Button with DD-WRT

Jan 12 2017 [Archived Version] □ Published at Nerdy Dork under tags  programming & internet

I love the idea of Disney Circle, Torch, and Luma where you can get on your phone and pause the internet for certain devices at home. But Circle being the cheapest, I didn’t really want to shell out $99 for yet another device when I just paid $155 for a new Nighthawk R7000 router and […]

The post Internet Pause Button with DD-WRT appeared first on Dustin Davis.


Remote Front End Django Developer

Jan 12 2017 [Archived Version] □ Published at Djangojobs.Net latest jobs

Required Skills

Demonstrable skills in:

  • Django templating using HTML5, CSS3, Bootstrap for modern browsers
  • version control using git (flow)
  • Good responsive design knowledge and accessibility skills (WCAG/WAI exposure)
  • Javascript (DOM manipulation without sole relienced upon jQuery)
  • node.js / bower / gulp knowledge
  • LESS (or SASS) experience
  • I18n L10n, G11n exposure
  • comfortable using a Linux/Mac OS CLI

Bonus Skills

  • Agile development experience
  • Jira
  • Slack
  • CI/CD

Conditions

  • US or naturalized citizen - no H-1B * Must be able to work comfortably and reliably from home, preferrably US Eastern, but +/- 2 hours timezone difference OK
  • comfortable in start-up mentality
  • entrepreneurial mindset

About Open Therapeutics™ LLC

Open Therapeutics™ is a seven-year-old company that curates and develops open medical, biopharma, and synthetic biology-based biotechnologies. Among the technologies being freely opened to the global community are essential proteins for developing antibiotic and anticancer therapeutics, immunotherapy and oncolytics, and biomarker inducers. The Company is headquartered in Cincinnati, Ohio with laboratory operations in Covington, Kentucky, USA, and Madrid, Spain via its strategic partner, Bacmine SL.


New year, new Python: Python 3.6

Jan 11 2017 [Archived Version] □ Published at Caktus Blog

Python 3.6 was released in the tail end of 2016. Read on for a few highlights from this release. New module: secrets Python 3.6 introduces a new module in the standard library called secrets. While the random module has long existed to provide us with pseudo-random numbers suitable for applications like modeling and simulation, these...


Static Websites with Flask

Jan 11 2017 [Archived Version] □ Published at Dougal Matthews under tags  flask frozen python static

Test


Talented Python Django Developer Edinburgh UK

Jan 10 2017 [Archived Version] □ Published at Djangojobs.Net latest jobs

Are you looking for a new challenge?

Agency life getting you down? Fed up of office politics and out of touch managers? Tired of being married to your desk?

Mercurytide is different!

We have a genuinely friendly and experienced team who will support you when you struggle and champion you when you nail it. Our directors don’t sit in glass offices making unrealistic demands, they sit at the desk next to us as our co-workers and argue over who shot first…cough cough Han!

Our company has and will continue to grow via the input and decisions of the entire team, based both on formal team meetings as well as impromptu chats at the kettle. Our office is fairly chilled and you will have 3 options; listen to the office radio with optional cross office chat, put your headphones in and listen to your own beats, or start an epic elastic band battle with the testers.

Oh yeah, we have testers! They are like our office siblings; we are best of friends but they do insist on breaking everything we own. It’s cool though, we don’t have a blame culture...we don’t find it to be very productive!

What you’ll be getting up to:

  • Designing and building neat software for the web
  • Chatting…ahem we mean planning...with other members of the team
  • Solving dev world problems in the office...and real world problems in the pub!
  • Working on a verity of solutions from e-commerce, bespoke applications, new products and for multiple industry sectors!

What you’ll get in return:

  • When we say flexible hours we mean flexible hours!
  • Private health insurance including dental and optical
  • An extra day's holiday for each year of loyal service...long live The Empire!
  • An invite to “The Real Coffee Club”, as well as their arch nemesis “The Biscuit Club”
  • Free fruit to mellow out that caffeine and sugar come down
  • Devs Assemble! Support from your fellow devs when the call comes
  • Stability: Mercurytide is pushing 20 with a low staff turn around
  • Pizza...tonnes of Pizza! Successful project? Pizza! New streamlined process? Pizza! matching socks? PIZZA!
  • What you’ll need:

Ideally you’ll have experience with Python...and possibly Django Or several years experience with another object orientated language. There will be a small coding test which you can do at home...we want to get to know you and we believe you don’t truly know someone until you have read their code.

If that all sounds good then get in touch and we can have a proper chat.


5 Reasons I don't think you shold use the django admin

Jan 09 2017 [Archived Version] □ Published at GoDjango Screencasts and Tutorials

Have you ever needed to quickly modify data or look it up. But while the task is simple the entire process of changing one value frustrates you?

Well, this is very common to me, bad UX is annoying. I quite often have to either lookup, or edit, two disparate, yet related pieces of data, and sometimes it is an exercise in frustration.

An all to common occurrence is I just needed to check the edit history of a "Company" our database. This is a simple process, go to the admin find the Company model, do a search and you have your answer.

Except, it isn't that easy in reality. Lets run through what really happened.

I went to "http://superawesomesite.com/admin/" and logged in.

I then looked at how my model options extended well below the fold of my browser so I had to scroll. No problem I'll just hit "ctrl+f" and search for it. WTF!!! where is my company model?

I then proceed to scroll down and finally find it only to remember it was pluralized. If I had searched for "Companies" I would have been good to go, grrrrr.

I click into and see the list of companies available to me. I see that there is a search feature at the top so I do a search for the relevant information. Unfortunately, I don't know the company name that is what I am trying to find out.

Except, we aren't filtering our search in the admin based on that field. So no results show up.

No problem I can do a list filter on the side. So I set the correct filters and still no luck because someone didn't set all the metadata that was supposed to be set for the company. Again grrrrr.

Finally, I abandoned the admin and opened up the django/python shell and did a query with the model, and in about 30 seconds had the record I needed. Took the id and plugged that into the django admin and I was good to go.

This was an exercise in frustration because the 30 seconds that was taken during development to decide which fields should be filtered didn't let that person imagine the field I needed. Also the fact that whomever added the company didn't add all the correct information, made it almost impossible to find the data. In the end I had to go outside this system that is hailed as one of the greatest tools for django to get the information I needed.

I propose we as a community reduce our reliance on the django admin, especially in production.

I also created a Video on the 5 reasons we shouldn't use the django admin.


Mathematical Modules in Python: Math and Cmath

Jan 09 2017 [Archived Version] □ Published at tuts+

When writing programs in our day-to-day life, we usually come across situations where we need to use a little maths to get the task done. Like other programming languages, Python provides various operators to perform basic calculations like * for multiplication, % for modulus, and // for floor division.

If you are writing a program to perform specific tasks like studying periodic motion or simulating electric circuits, you will need to work with trigonometric functions as well as complex numbers. While you can't use these functions directly, you can access them by including two mathematical modules first. These modules are math and cmath

The first one gives you access to hyperbolic, trigonometric, and logarithmic functions for real numbers, while the latter allows you to work with complex numbers. In this tutorial, I will go over all the important functions offered by these modules. Unless explicitly mentioned, all the values returned are floats.

Arithmetic Functions

These functions perform various arithmetic operations like calculating the floor, ceiling, or absolute value of a number using the floor(x), ceil(x), and fabs(x) functions respectively. The function ceil(x) will return the smallest integer that is greater than or equal to x. Similarly, floor(x) returns the largest integer less than or equal to x. The fabs(x) function returns the absolute value of x.

You can also perform non-trivial operations like calculating the factorial of a number using factorial(x). A factorial is the product of an integer and all the positive integers smaller than it. It is used extensively when dealing with combinations and permutations. It can also be used to calculate the value of sine and cosine functions. 

Another useful function in the math module is gcd(x,y), which gives you the greatest common divisor (GCD) of two numbers x and y. When x and y are both not zero, this function returns the largest positive integer that divides both x and y. You can use it indirectly to calculate the lowest common multiple of two numbers using the following formula:

Here are a few of the arithmetic functions that Python offers:

Trigonometric Functions

These functions relate the angles of a triangle to its sides. They have a lot of applications, including the study of triangles and the modeling of periodic phenomena like sound and light waves. Keep in mind that the angle you provide is in radians.

You can calculate sin(x), cos(x), and tan(x) directly using this module. However, there is no direct formula to calculate cosec(x), sec(x), and cot(x), but their value is equal to the reciprocal of the value returned by sin(x), cos(x), and tan(x) respectively.

Instead of calculating the value of trigonometric functions at a certain angle, you can also do the inverse and calculate the angle at which they have a given value by using asin(x), acos(x), and atan(x)

Are you familiar with the Pythagorean theorem? It states that that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. The hypotenuse is also the largest side of a right-angled triangle. The math module provides the hypot(a, b) function to calculate the length of the hypotenuse.

Hyperbolic Functions

Hyperbolic functions are analogs of trigonometric functions that are based on a hyperbola instead of a circle. In trigonometry, the points (cos b, sin b) represent the points of a unit circle. In the case of hyperbolic functions, the points (cosh b, sinh b) represent the points that form the right half of an equilateral hyperbola. 

Just like the trigonometric functions, you can calculate the value of sinh(x), cosh(x), and tanh(x) directly. The rest of the values can be calculated using various relations among these three values. There are also other functions like asinh(x), acosh(x), and atanh(x), which can be used to calculate the inverse of the corresponding hyperbolic values.

Since math.pi is equal to about 3.141592653589793, when we used asinh() on the value returned by sinh(math.pi), we got our π back.

Power and Logarithmic Functions

You will probably be dealing with powers and logarithms more often than hyperbolic or trigonometric functions. Fortunately, the math module provides a lot of functions to help us calculate logarithms.

You can use log(x,[base]) to calculate the log of a given number x to the given base. If you leave out the optional base argument, the log of x is calculated to the base e. Here, e is a mathematical constant whose value is 2.71828182.... and it can be accessed using math.e. By the way, Python also allows you to access another constant π using math.pi.

If you want to calculate the base-2 or base-10 logarithm values, using log2(x) and log10(x) will return more accurate results than log(x, 2) and log(x, 10). Keep in mind that there is no log3(x) function, so you will have to keep using log(x, 3) for calculating base-3 logarithm values. The same goes for all other bases.

If the value whose logarithm you are calculating is very close to 1, you can use log1p(x). The 1p in log1p signifies 1 plus. Therefore, log1p(x) calculates log(1+x) where x is close to zero. However, the results are more accurate with log1p(x).

You can also calculate the value of a number x raised to the power y by using pow(x, y). Before computing the powers, this function converts both the arguments to type float. If you want the final result to be computed in exact integer powers, you should use the built-in pow() function or the ** operator.

You can also compute the square root of any given number x by using sqrt(x), but the same thing can also be accomplished by using pow(x, 0.5).

Complex Numbers

Complex numbers are stored internally using rectangular or Cartesian coordinates. A complex number z will be represented in Cartesian coordinates as z = x + iy, where x represents the real part and y represents the imaginary part. Another way to represent them is by using polar coordinates. 

In this case, the complex number z would be defined a combination of the modulus r and phase angle phi. The modulus r is the distance between the complex number z and the origin. The angle phi is the counterclockwise angle measured in radians from the positive x-axis to the line segment joining z and the origin.

While dealing with complex numbers, the cmath module can be of great help. The modulus of a complex number can be calculated using the built-in abs() function, and its phase can be calculated using the phase(z) function available in the cmath module. You can convert a complex number in rectangular form to polar form using polar(z), which will return a pair (r, phi), where r is abs(z) and phi is phase(z)

Similarly, you can convert a complex number in polar form to rectangular form using rect(r, phi). The complex number returned by this function is r * (math.cos(phi) + math.sin(phi)*1j).

The cmath module also allows us to use regular mathematical functions with complex numbers. For example, you can calculate the square root of a complex number using sqrt(z) or its cosine using cos(z)

Complex numbers have a lot of applications like modelling electric circuits, fluid dynamics, and signal analysis. If you need to work on any of those things, the cmath module won't disappoint you. 

Final Thoughts

All of these functions we discussed above have their specific applications. For example, you can use the factorial(x) function to solve permutation and combination problems. You can use the trigonometric functions to resolve a vector into Cartesian coordinates. You can also use trigonometric functions to simulate periodic functions like sound and light waves. 

Similarly, the curve of a rope hanging between two poles can be determined using a hyperbolic function. Since all these functions are directly available in the math module, it makes it very easy to create little programs that perform all these tasks.

I hope you enjoyed this tutorial. If you have any questions, let me know in the comments.


2017 DSF Board Election Results

Jan 07 2017 [Archived Version] □ Published at The Django weblog

We're happy to announce the winners of the DSF Board elections for 2017.

Frank Wiles, Daniele Procida, and James Bennett were re-elected for another term. Our new Board members are Kenneth Love, Ken W. Alger, and Rebecca Conley.

Rebecca, as you may be aware, served as Board Secretary during 2016 to fill a vacancy but will be returning again this year.

We wish to thank Christophe Pettus and Karen Tracey who did not run again this year for their service and the wisdom they brought to us.

The Board will be having our first meeting in the coming days to ratify the slate of officers at which time we'll update the website accordingly.

We look forward to another great year of helping further Django and the Django Community.


django-planet aggregates posts from Django-related blogs. It is not affiliated with or endorsed by the Django Project.

Social Sharing

Feeds

Tag cloud

admin administration adsense advanced ajax amazon angular angularjs apache api app appengine app engine apple application security aprendiendo python architecture articles asides audrey authentication automation backup bash basics best practices binary bitbucket blog blog action day blogging book books buildout business c++ cache capoeira celery celerycam celerycrawler challenges chat cheatsheet cherokee choices class-based-views cliff cloud cms code codeship codeship news coding command community computer computers computing configuration consumernotebook continuous deployment continuous integration couchdb coverage css custom d data database databases db debian debugging deploy deployment deployment academy design developers development devops digitalocean django django1.7 django cms djangocon django framework django-nose django-readonly-site django-rest-framework django-tagging django templates django-twisted-chat django web framework tutorials documentation dojango dojo dotcloud dreamhost dughh easy_install eclipse education elasticsearch email encoding english error europe eventbrite events expressjs extensions fabric facebook family fashiolista fedora field file filter fix flash flask form forms frameworks friends fun functional reactive programming gae gallery games geek general gentoo gis git github gmail gnome google google app engine guides gunicorn hack hackathon hacking hamburg haskell heroku holidays hosting howto how-to howtos how-tos html http i18n image imaging indifex install installation intermediate internet ios iphone java javascript jinja2 jobs journalism jquery json justmigrated kde la latex linear regression linkedin linode linux login mac machine learning mac os x markdown math memcached meme mercurial meta meteor migration mirror misc model models mod_wsgi mongodb months mozilla multi-language mvc mysql nelenschuurmans newforms news nginx nodejs nosql oauth ogólne openshift opensource open source open-source openstack operations orm osx os x ottawa paas packages packaging patterns pedantics pelican penetration test performance personal personal and misc philippines philosophy php pi pil pinax pip piston planet plone plugin pony postgis postgres postgresql ppoftw presentation private programmieren programming programming & internet project projects pycharm pycon pycon-2013-guide pydiversity pygrunn pyladies pypi pypy pyramid python python3 queryset quick tips quora rabbitmq rails rant ratnadeep debnath reactjs recipe redis refactor release request resolutions rest reusable app review rhel rtnpro ruby ruby on rails scala scaling science screencast script scripting security server setup shell simple smiley snaking software software collections software development south sphinx sprint sql ssh ssl static storage supervisor support svn sysadmin tag tag cloud talk nerdy to me tastypie tdd techblog technical technology template templates template tags test testing tests tip tips tools tornado transifex travel travel tips for geeks tumbles tutorial tutorials twisted twitter twoscoops typo3 ubuntu uncategorized unicode unittest unix use user authentication usergroup uwsgi uxebu virtualenv virtualenvwrapper web web 2.0 web application web applications web design & development webdev web development webfaction web framework websockets whoosh windows wordpress work workshop wsgi yada znc zope