0
votes
2answers
41 views

How to copy all python instances to a new class?

I would like to make a deep-copy all the instances of a class, but without copying the definitions and rules of given class. The intended use is, given I have the class "OriginalClass", its instances ...
0
votes
1answer
15 views

Filtering calls to parent method

I am extending a Parent class using composition instead of inheritance. I pass method calls from my "Child" to the Parent as shown in the code: class Child(object): def __init__(self, obj): ...
0
votes
3answers
29 views

understanding classes in python 2 [learn python the hard way exercise 43]

Complete novice programmer here. I've been going through Zed's Learn Python the Hard Way book for the past few weeks to cover the basics of programming, and I've found myself at a standstill. I've ...
1
vote
1answer
21 views

How to deal with global parameters in a scientific Python script

I am writing a piece of scientific software in Python which comprises both a Poisson equation solver (using the Newton method) on a rectangular mesh, and a particle-in-cell code. I've written the ...
0
votes
2answers
29 views

how to create nicer variable interface in python class

I want a variable to do more than just be set when I set it. and the interface to be as clean as possible. short: what I'd want: # have class with a variable that I can access: print myInstance.var ...
1
vote
1answer
57 views

Pythonic way of extending base class

I am trying to create a pandas Dataframe like class with some added constructors: class ExtendedDataFrame(DataFrame): def __init__(self): super(ExtendedDataFrame, self).__init__() # ...
0
votes
2answers
45 views

Summing Attribute in a list of Python Objects

Similar to "What's the most concise way in Python to group and sum a list of objects by the same property", I have a script in which I need to sum the attributes of list of objects. However, my issue ...
2
votes
3answers
32 views

Calling a method from a parent class in Python

Can anyone help me with the correct syntax to call my method __get_except_lines(...) from the parent class? I have a class with a method as shown below. This particular method has the 2 underscores ...
1
vote
1answer
76 views

“subtracting” strings, classes in python

Learning about classes in python. I want the difference between two strings, a sort of subtraction. eg: a = "abcdef" b ="abcde" c = a - b This would give the output f. I was looking at this class ...
1
vote
1answer
33 views

Confused about self in derived class and relation to base class member variables

In the code sample below I am using self.number in the derived class, b, and number is defined in a (the base class). If a data member is defined in this way in a base class, is it always accessible ...
0
votes
2answers
16 views

unittest testcase setup new object

I'm using pydev in Classic Eclipse 4.2.2 with Python2.7. Please consider the code and result below as you read. Suppose I create an object with a variable of a predefined value. Now, suppose I ...
0
votes
1answer
20 views

Get list of elements currently in heap using heapq in Python ?

This structure i have built for easier understanding and usability class PriorityQueue: """ Implements a priority queue data structure. """ def __init__(self): self.heap = [] ...
0
votes
1answer
26 views

Scope of classes inside of functions and classes inside of a class in python

I am writing some code and had a general question about python If I have something like this: class A(): def __init__(self): self.name ... def doSomething(self): ...
-1
votes
1answer
31 views

python flask class definition syntax

In python classes are defined like this class ClassName:, but can anyone explain to me what this means class flask.Flask() in the flask documentation and what is a flask object. Thanks
0
votes
2answers
37 views

Method that applies to instance of a class in python // Apply a method to an instance of a class in python

Im starting to create classes in python and I am very confused about the terms, so I cant find the answers to my questions since I dont know how to ask those,hence the double title of this post. I ...

1 2 3 4 5 128
15 30 50 per page