1
vote
2answers
33 views

Property method without class [duplicate]

I have a next code global_variable = 1 @property def method(): # Some magic, for example # incrementing global variable global global_variable global_variable += 1 return ...
6
votes
3answers
593 views

Python importing class attributes into method local namespace

I have been wondering for a while if there is easier way to assign class attributes to method local namespace. For example, in dosomething method, I explicitly make references to self.a and self.b: ...
3
votes
1answer
61 views

Python car race winner [closed]

I need to create a Python program that will determine the winner of a race using the equation odometer_miles = odometer_miles + speed * time and with a class called Car that has "total odometer ...
3
votes
4answers
77 views

how to define a class variable referring to an object of same class in python [duplicate]

Below is java code. I need to know the equivalent code in python: class A { public static A obj = new A(); }
0
votes
2answers
48 views

Int() Conversions not working right in python

So I'm making a python Module to create and save data for an in-game character. the the class is Character and goes as follows: #!/usr/bin/python import os import re class Character: storage = ...
0
votes
1answer
50 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
20 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) ...
0
votes
2answers
27 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
31 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 ...
1
vote
1answer
28 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
42 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
51 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
44 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
1answer
76 views

Return True|False from a function in a class in python [closed]

I can't get the return value True|False from a function. What Am I doing wrong? The script looks roughly like that. class getLogs: IAM=getpass.getuser() SRC_LOG_DIR='/server/log/session/' ...
0
votes
2answers
34 views

How can I have multiple objects moving at once in PYGAME

I want to make a game where I have enemies coming from two sides of the screen. Right now I have it so that enemies scroll across the screen one at a time. I would like to have more then one come at a ...

1 2 3 4 5 122
15 30 50 per page