2
votes
1answer
33 views

Add methods to a third party library class in Python

I'm using a third party library (PySphere) for a project I'm working on. PySphere provides a simple API to interact with VMware. This is a general problem though, not specific to this library. A ...
0
votes
2answers
31 views

Python 2.7: How to extend a class from an imported base class

New to python, apologies if this is nub stuff: Writing a small module (maybe a package, eventually?). It's gotten too big for single file, so I'm moving my larger classes to individual files. All of ...
2
votes
2answers
60 views

Python abc and factory function

I'm trying to implement a factory function that creates subclasses of a given base class (comparing to a string of its name for now). I have this class Base(object): ... And in another file I ...
1
vote
0answers
39 views

Modelling a subgraph to graph relationship using OOP

I have been teaching myself Python and OOP. I have been working on a way of representing graphs. My implementation has graphs, edges and vertices as objects. A natural thing to want is to find a ...
0
votes
1answer
27 views

creating instance methods outside of the constructor in python

I am able to get my code to work, but I am wondering if it is correct to set an instance method on a class outside of the constructor. When I wrote this, it just didn't feel right but I couldn't ...
0
votes
2answers
41 views

How to access variables and functions from within a class?

I am quite new to OOP, but I can see its benefits. I have written a class (structured on an example from zetcode) that makes a window and puts an entry box and a button in it. Also, I have a function ...
2
votes
4answers
72 views

Python class members confusion

First of all, i come from a java and php background and am now learning python. This may therefore seem like a silly question but it has me a little confused. As an example in php: class MyClass { ...
-1
votes
0answers
58 views

What are classes and OOP in Python [closed]

I have been learning Python 3.3 and I dont understand what are OOP/classes and how they work. I would like an explanation of their systax and their structure.
-2
votes
2answers
78 views

Can someone help me with this class [closed]

class database(object): def __init__(self): self.l = [] def insert(self, e): for i in range[len(self.l)]: if i == e: return self.l.append(e) Why is ...
0
votes
2answers
76 views

Required positional argument: self

I'm new to Python, and I need some help. I was writing a blackjack program as homework, and I think I may have it working, but whenever I run it, it complains that I have not provided anything for ...
1
vote
1answer
37 views

python metaclasses of classes created by type

Code is better than words here: class MetaA(type): def __new__(cls, name, bases, attrs): print "MetaA" return super(MetaA, cls).__new__(cls, name, bases, attrs) class A(object): ...
0
votes
2answers
117 views

How to understand python classes?

Hello I'm learning python, it is also my first language. I'm trying to figure out how classes work. I have this small code and I can't get it to work after a week of searching. Thank you for helping ...
0
votes
2answers
52 views

eval() function in object-oriented programming

Here's the thing: My program is a GUI-based calculator written in python/GTK. In the first version I didn't used classes, so here is a piece of the old code: def show(result): textbox3.set_text( ...
0
votes
1answer
42 views

Object instances as list elements

I've written the below on a whim after being reading about the "METHINKS IT IS LIKE A WEASEL" algorithm. What I expect to happen in pop_gen() is for ten instances of Gib to be created - each with a ...
-2
votes
2answers
45 views

how to change attribute of parent class

I have two classes. In the object oriented methodology, I can change parent attribute from low level class. In python, how can I change variable of the parents from other class ? What I have class ...

1 2 3 4 5 59
15 30 50 per page