Skip to content Skip to sidebar Skip to footer
Showing posts with the label Oop

Python: Isinstance() Undefined Global Name

I'm new with Python and I'm trying to use classes to program using objects as I do with C++… Read more Python: Isinstance() Undefined Global Name

Python Change Self To Inherited Class

I have this kind of structure: class Foo: def __init__(self, val1): self.val1 = val1 … Read more Python Change Self To Inherited Class

Python Class Constructor (static)

Does Python have a mechanism for class constructors, i.e. a function that is called whenever the cl… Read more Python Class Constructor (static)

How To Make A Class Attribute Exclusive To The Super Class

I have a master class for a planet: class Planet: def __init__(self,name): self.name =… Read more How To Make A Class Attribute Exclusive To The Super Class

How To Assign Properties To Symbols In Sympy And Have Them In The Same Domain?

I want to extend the Symbols class in SymPy so that I can add a Boolean attribute. I’m able to acc… Read more How To Assign Properties To Symbols In Sympy And Have Them In The Same Domain?

Convert String Elements To Class Attributes (py 2.7)

i have a string, and i want to use the elements to convert them into attrs of a class. @staticmetho… Read more Convert String Elements To Class Attributes (py 2.7)

How Do I Make Private Variables Inaccessable In Python?

class Car(object): def __init__(self, color, engine, oil): self.color = color s… Read more How Do I Make Private Variables Inaccessable In Python?

Python3 And Recursive Class

I want to define own tree-like class. I've written code like this: class forest: class … Read more Python3 And Recursive Class

Override Used Classes In Parent Class

Suppose there is a class NiceClass using some other class LesserClass in a place I can't edit #… Read more Override Used Classes In Parent Class

Do I Need To Learn About Objects, Or Can I Save Time And Just Learn Dictionaries?

OK to be short =) I'm noob yes. -.- but I'm convinced i don't need to learn everything.… Read more Do I Need To Learn About Objects, Or Can I Save Time And Just Learn Dictionaries?

Trouble Understanding Passing Values And References In Python

Having issues with when objects are changed and when they aren't in Python. Here is my poorly c… Read more Trouble Understanding Passing Values And References In Python

Creating Attributes Of Attributes - Possible?

I am dealing with monthly data for a number of different data sets (e.g. air temperature, ocean tem… Read more Creating Attributes Of Attributes - Possible?

Object Orientated Tkinter Functions - How Would I Put This In?

I am coding a program which will need functions to change labels and enter text into text boxes how… Read more Object Orientated Tkinter Functions - How Would I Put This In?

Program To Restrict Object Creation In Python

class object_restrict(object): _count = 0 def __new__(cls): if cls._count > 5: … Read more Program To Restrict Object Creation In Python

Properties Defined With Property() And @property

I am now trying to properly learn Python, and I am really puzzled by existence of two ways to creat… Read more Properties Defined With Property() And @property

Bad Practice To Run Code In Constructor Thats Likely To Fail?

my question is rather a design question. In Python, if code in your 'constructor' fails, th… Read more Bad Practice To Run Code In Constructor Thats Likely To Fail?

What Is The Purpose Of Checking Self.__class__?

What is the purpose of checking self.__class__ ? I've found some code that creates an abstract … Read more What Is The Purpose Of Checking Self.__class__?

Why Can Instance Methods Be Called As Class Methods In Python 3?

Consider the following class: class Foo(object): def bar(self): print(self) In Python … Read more Why Can Instance Methods Be Called As Class Methods In Python 3?

Should I Use A Class? (python)

I'm trying to write a small Python module which contain some mathematical functions. For exampl… Read more Should I Use A Class? (python)

Python Shell Shows No Error But Program Doesn't Run

I wrote this program to learn the basics of OOP. When I run this program from IDLE in the Python Sh… Read more Python Shell Shows No Error But Program Doesn't Run