Python
Reflection in Python: getattr
· β˜• 2 min read
1. Application Scenarios Control the program’s runtime flow through a configuration file. What a configuration file usually holds is a string, not an object. When debugging a program, inspect all the attribute values of an object. Dynamic module import. For the first scenario, reflection is the widely adopted approach. Many

Common Built-in Functions in Python
· β˜• 5 min read
Function Description abs(number) Returns the absolute value of a number apply(function[, args[, kwds]]) Calls the given function, optionally providing arguments all(iterable) Returns True if all elements of the iterable are true, otherwise False any(iterable) Returns True if any element of the iterable is true, otherwise False basestring() Abstract superclass of str and unicode, used for type checking bool(object) Returns True or False depending on the boolean value of object callable(object) Checks whether an object is callable chr(number) Returns the character whose ASCII code is the given number classmethod(func) Creates a class method from an instance method cmp(x, y) Compares x and y β€” returns a positive number if x>y; returns 0 if x==y complex(real[, imag]) Returns the complex number with the given real part (and optional imaginary part) delattr(object, name) Deletes the given attribute from the given object dict([mapping-or-sequence]) Constructs a dictionary, optionally from a mapping or a list of (key, value) pairs.

Drawing Fractals with Python: Koch Curves, Julia Sets, and Mandelbrot Sets
· β˜• 2 min read
1. Koch Curve The Swedish mathematician Helge von Koch proposed the Koch curve in his 1904 paper “On a continuous curve without tangents, constructible from elementary geometry.” It is described as follows: Specify the length of a line segment \(l\) (this can be thought of as iteration 0) Divide this

Permission Control in Django
· β˜• 2 min read
1. Django Built-in Permission Management 1.1 Permission Categories Permission Used to define User A’s permission on Task. User If User A has permission on Model B, then User A has the corresponding permission on all instances in Model B. The user_permission field of the User object is used to manage

Several Methods of Django Data Migration (with Code)
· β˜• 4 min read
1. Background In the course of Web development, migrating data between multiple environments (local, testing, and production) comes up often. This article mainly discusses the possible data migration paths involved in Django development, and seeks feasible methods for them. 2. Scenarios There are four data migration targets in total: the