0
votes
1answer
46 views

Class Inheritence (Python) Output Problems

I'm going through 'Learning Python The Hard Way', and I got to the class lesson. I understood it (or I at least think I did!) and tried to create a simple variation, using my own names, functions, ...
0
votes
2answers
16 views

How do I make a class a sub-group of another class?

from django.db import models class products(models.Model): #Table name, has to wrap models.Model to get the functionality of Django. name = models.CharField(max_length=200, unique=True) ...
-1
votes
1answer
24 views

Python Tklinter Button calling a function from another class

I have defined a Button with Tklinter class ventanapp(Tk): def initialize(self): self.grid() self.entry = Entry(self) msg = Message(text=' SSH - Ingresar IP ->') ...
0
votes
2answers
29 views

Quick Method for Sorting User Defined Classes

I have a class in python where one of the instance variables is an integer. Now when I have a few of those in a list if I call the sort method on that list I want them to sort by that integer instance ...
0
votes
1answer
24 views

isinstance without importing candidates

We have a function which takes a variety of different types of input: a function, a string, a compiled regular expression, a Hamcrest Matcher, and filters a list appropriately based on the type of the ...
3
votes
2answers
30 views

Python: Logging all of a class' methods without decorating each one

I want to log every method call in some classes. I could have done class Class1(object): @log def method1(self, *args): ... @log def method2(self, *args): ... But I ...
1
vote
1answer
46 views

What does the __init__ method serve for? [duplicate]

I started learning python (with no prior knowledge of it, not programming) few weeks ago and am stuck at Classes. Currently the "init" class method confuses me. What does it do, in fact? Here is an ...
0
votes
1answer
43 views

Looking for OOP Pythonic approach for putting objects in a 'list object' as opposed to just using [list] [closed]

For some reason I cannot conceptualize how to use Checkbook.class object instead of "ledger [list]" Trying to keep my approach OOP. What is a best practices approach to the objectives of this code? ...
0
votes
2answers
99 views

How do I use a method outside a class?

I'm taking python classes. I've asked for hints about this in our forums but with no luck. I think my implementation is very bad. I'm very new at this, so bear with me, even with the way I ask the ...
2
votes
2answers
61 views

Python class member or global variable [closed]

When defining a Python class, class members are like global variables for the class. Then, I do not understand why global variables do exist ? Shouldn t we always use class members instead ?
5
votes
1answer
119 views

Access .mat file containing matlab classes in python

I have a .mat file generated from matlab 2012b. It contains a variable with a user-defined matlab class. When loading the file using scipy.io.loadmat in python 3.3, I get the following: ...
16
votes
2answers
274 views

Decorators and class method

I am having trouble understanding why the following happens. I am having a decorator which does nothing except it checks whether a function is a method. I thought I have understood what method in ...
6
votes
6answers
2k views

Why do we use __init__ in python classes?

Sorry if this question is a bit general but its been bugging me because I don't fully understand it. I'm a python newbie and all my programming so far has been functions and I'm starting to look at ...
7
votes
7answers
5k views

Explaining the python 'self' variable to a beginner

I'm pretty much ignorant of OOP jargon and concepts. I know conceptually what an object is, and that objects have methods. I even understand that in python, classes are objects! That's cool, I just ...
7
votes
2answers
2k views

organising classes and modules in python

I'm getting a bit of a headache trying to figure out how to organise modules and classes together. Coming from C++, I'm used to classes encapsulating all the data and methods required to process that ...

1 2 3 4 5 122
15 30 50 per page