Python for Experienced Java Developers Quotes

Rate this book
Clear rating
Python for Experienced Java Developers Python for Experienced Java Developers by Jörg Richter
1 rating, 5.00 average rating, 1 review
Open Preview
Python for Experienced Java Developers Quotes Showing 91-120 of 144
“an unbound method is a standalone function that is not associated with any particular instance, similar to a static function in Java.”
Jörg Richter, Python for Experienced Java Developers
“A bound method is a method that is associated with a specific instance of a class. Since the instance (self) is passed as the first argument to the method,”
Jörg Richter, Python for Experienced Java Developers
“you can also add a method to an instance of a class instead to the class itself.”
Jörg Richter, Python for Experienced Java Developers
“It is also possible to dynamically add a method to a statically defined class.”
Jörg Richter, Python for Experienced Java Developers
“You can also use the type() function to dynamically create class objects”
Jörg Richter, Python for Experienced Java Developers
“To obtain the class object of an object, you can use the built-in type() function.”
Jörg Richter, Python for Experienced Java Developers
“These decorators provide precise control over attribute access while preserving the illusion of direct attribute access.”
Jörg Richter, Python for Experienced Java Developers
“Attributes and methods surrounded by double underscores, such as __name__ and __init__(), are not subject to name mangling. These are typically part of Python’s standardized data model and serve specific, predefined roles within the language.”
Jörg Richter, Python for Experienced Java Developers
“When a member of a class is prefixed with double underscores (__), Python internally renames the member by adding the class name as a prefix to the original member name.”
Jörg Richter, Python for Experienced Java Developers
“multiple inheritance is used frequently, even within Python’s built-in libraries, to implement what is called a mixin in object-oriented programming:”
Jörg Richter, Python for Experienced Java Developers
“Multiple inheritance is a feature supported by Python, but its popularity varies among developers and is often a topic of debate.”
Jörg Richter, Python for Experienced Java Developers
“isinstance()”
Jörg Richter, Python for Experienced Java Developers
“super() function can be used to call the overridden method in the superclass.”
Jörg Richter, Python for Experienced Java Developers
“super().__init__(). But this step is not mandatory, and failing to do so will not result in a compile error.”
Jörg Richter, Python for Experienced Java Developers
“Python does not automatically invoke the constructor of the superclass from a subclass constructor.”
Jörg Richter, Python for Experienced Java Developers
“Python does not enforce access restrictions on inherited members, meaning that the parent class cannot prevent them from being used by a subclass.”
Jörg Richter, Python for Experienced Java Developers
“In the example above, the statement obj1.x = "Good Morning" is possible but would create an instance variable obj1.x, so obj1.print_x() would still print the old value of x and not "Good Morning".”
Jörg Richter, Python for Experienced Java Developers
“del MyClass.x is possible as well, it removes the class attribute.”
Jörg Richter, Python for Experienced Java Developers
“Defined within the class definition but outside of any class methods, class variables are shared by all instances of the class.”
Jörg Richter, Python for Experienced Java Developers
“the del statement can be used to remove an instance variable:”
Jörg Richter, Python for Experienced Java Developers
“In Python the == operator invokes the __eq__() method, which by default compares values like the is operator.”
Jörg Richter, Python for Experienced Java Developers
“dunder methods (double underscore methods).”
Jörg Richter, Python for Experienced Java Developers
“Null reference: Python’s None reference is equivalent to null in Java.”
Jörg Richter, Python for Experienced Java Developers
“Instead, the constructor and every method within a class need to have at least one parameter, conventionally named self. Python automatically passes the object instance as the first argument when you call a method on an object.”
Jörg Richter, Python for Experienced Java Developers
“Python does not support method overloading based on different parameter types. Instead, you can utilize default parameter values and conditional logic within the method to achieve similar functionality.”
Jörg Richter, Python for Experienced Java Developers
“Python does not provide explicit access modifiers like Java (public, private, protected), it does offer conventions such as single (_) and double (__) underscore prefixes to indicate visibility.”
Jörg Richter, Python for Experienced Java Developers
“To achieve functionality similar to having multiple constructors in Java, you can use default parameter values and variable-length argument lists.”
Jörg Richter, Python for Experienced Java Developers
“In Python, the / symbol is used in function definitions to indicate that parameters preceding it are positional-only. This means they can only be specified by position and cannot be passed as keyword arguments. Parameters following the / are either positional-only or positional-or-keyword. def func(a, b, c, /, d, e):
    print(a, b, c, d, e)


func(1, 2, 3, 4, 5)  # 1 2 3 4 5
func(6, 7, 8, 9, e=10)  # 6 7 8 9 10

# This does not work
# func(6, 7, c=8, d=9, e=10)”
Jörg Richter, Python for Experienced Java Developers
“def func(a=[]):
a.append(1)
return a

print(func()) # Output: [1]
print(func()) # Output: [1, 1]”
Jörg Richter, Python for Experienced Java Developers
“Please note that default parameter values are evaluated only once when the function is defined, not every time the function is called.”
Jörg Richter, Python for Experienced Java Developers