2
votes
0answers
18 views

Fixed point iteration and cobweb diagram plotting

I'm using Python to find fixed points of a given function and then plot a cobweb diagram to visualize it. Thanks to this, I have the core of the code written and can accomplish the task, but I have a ...
2
votes
1answer
72 views

How can I optimize my insert function for the cuckoo hash table?

I'm working on class for a hash table where collisions are corrected using cuckoo hashing, I had difficulty writing the insert function, the function is supposed to insert the key if the ...
3
votes
2answers
99 views

Bad usage of classes in Python

I was recently working on a project where I had the following setup: ...
1
vote
2answers
103 views

Classes for Facebook graph API and Twitter access

Given below is code which I wrote to provide an easy access to Facebook graph API. ...
4
votes
1answer
61 views

Loop cleanly through different classes

If I have a number of different classes which manage certain tests. At the moment I have to launch each test individually which results in a lot of if statements. ...
2
votes
3answers
74 views

Raising error if method not overridden by sub-class

Background I have a base (only 2 classes inherit from it, and only from it) abstract (meaning I don't want it to be used directly) class that implements some common functionality. Some of it depends ...
7
votes
2answers
81 views

Python script to test music sight reading

I decided to write a program to test music theory, and, while it would've been much easier for me to make it elegant and perfect in Java, I thought I'd take the opportunity to get more familiar with ...
6
votes
2answers
115 views

Proper use of class constants

This question specifically relates to the use of the class constants ABOVE and BELOW in the sample code below. I have a few different classes that look like this: ...
3
votes
1answer
58 views

Using classes vs. using functions

I am trying to learn how to tell if my code will be better off creating a class as opposed to using many functions. I am a new Python programmer trying to get the hang of when classes should be ...
5
votes
1answer
371 views

Does this tkinter-based web browser widget use a well implemented class?

I have fully functional code in class format, and as far as I am aware from my previous question, it conforms to PEP 8 and the code logic and implementation is suitably pythonic. My main concerns here ...
0
votes
1answer
77 views

Class-based signal generator [closed]

I'm creating a class-based signal generator that, given a buy threshold, sell threshold and a list of list of indicators, creates a 'buy' of 'sell' signal on a given day if the indicator from that day ...
9
votes
1answer
77 views

Shortcuts and imports for large RPG basic code

I decided to work on putting together an Arena-style (very basic) text-based RPG as a way to help myself learn Python. Unfortunately, after about 1,000 lines of pieced-together code, I realize that ...
7
votes
3answers
150 views

Directly accessing class attributes in Rock Paper Scissors

I am reading a beginning Python programming book and in it the author says that you want to avoid accessing a class' attributes directly, but instead to create methods that return attribute values. ...
8
votes
3answers
252 views

Model cars as classes

I am learning about object oriented programming in Python using classes. I have attached an image of what I had in mind when structuring my classes. This is supposed script model cars. I want to know ...
1
vote
1answer
64 views

Class initialisation of fields

I have a the beginnings of a class (in this case for a NeuralNet). I'm not very happy with how I am initializing self.ws, seems a bit off. What is the pythonic way to do this? ...
-2
votes
1answer
50 views

Classes in Python [closed]

I am trying to create a class about birds with a few different methods. This is just theoretical code. Is there anything that is inherently wrong with the code from a syntactical or semantics point of ...
0
votes
1answer
89 views

Creating a singleton container class for intrer-class messaging

My question is for validation of my code (any loop holes / bugs) and guidance the best methodology to implement for my requirement. I am developing a Python application that will have many classes. ...
1
vote
0answers
124 views

Do I need inheritance or no?

I'm using Pygame to create a small game with few rectangle shapes. However, I want to learn more about classes, and I'm trying to use them. I'm very new to classes and inheritance, but I want to ...
1
vote
2answers
134 views

What is a better way to organize this Python code in a class?

I wrote a script that will eventually go onto a Raspberry Pi. It takes a picture then uploads it to Twitter every 15 minutes from 5:30-9:00pm. It works fine as is, but I feel I need to organize ...
1
vote
2answers
86 views

In this script what can I turn into funtions and how can I go about doing it?

I have just made a simple script which spawns an alien that chases the player, but I want to move as much of the script into funtions so as to minimize the amount of code, to make it run better when ...
2
votes
1answer
100 views

Streamlining repetitive class definitions in python with a class_factory() function

I forked this repo to be more concise. The code is here. I'll paste it below since that seems to be the style. I removed the class definitions at the bottom that I didn't change -- the edit I'm ...
3
votes
2answers
98 views

I know I'm not doing these methods right

I'm having difficulty understanding the implementation of methods in classes. I'm pretty sure I'm not doing this the correct way. Can anyone show me the way it should be done. This code works by ...
3
votes
2answers
164 views

Trying to use classes in my python code. Not sure if being done correctly

The point of my code is to: Read in the observed data from the a catalog of stars (whitespace separated table). Do some unit conversions on the observed data (math stuff). Apply an interstellar ...
0
votes
2answers
110 views

Extending a simple Python console program with external code. Did I handle this correctly?

I'm a hobbyist Python programmer with not much experience. I wrote some code for a solution to a Tic Tac Toe AI problem on the internet. Then yesterday I wrote a simple console Tic Tac Toe game for ...
2
votes
1answer
253 views

Should I use a class as a class factory in Python?

As a bit of a learning project, I decided to take the concept of proxying objects a bit further and extend it to creating proxy classes which create proxy'd objects. I originally found the idea of ...
2
votes
2answers
276 views

Pong game in Python

I'm writing a pong game in Python and I created classes for the game objects. The top level class is Object, and Ball and ...
3
votes
2answers
103 views

improve the design of class “accuracy” in Python

I am learning about the class and methods in Python. The class Accuracy is a class of several (13 in total) statistic values between a reference polygon and one or more segmented polygons based on ...
2
votes
2answers
204 views

Wiki API getter

I know there are other Python wiki API classes out there. I'm writing this one because I don't need all the bells and whistles, no edits, no talks, etc. I just need to be able to search for titles and ...
1
vote
2answers
426 views

Python: keeping track of info across classes by storing a variable to self

I wrote the following code to test a score-keeping class. The idea was to keep score of a game such that the score was kept across multiple classes and methods. I'm looking for any input on being ...
1
vote
1answer
957 views

Reversi move class

I redid a Python Reversi move preview routine that is online. I could use comments about using Python better and/or better OOP design since the original did not use classes. There are three main ...
3
votes
2answers
131 views

Style comments please on my timer class, which I hope will be a pattern for other classes

I'm a relative noob to Python. On a range of 0 to 10, where 0 is a complete noob and 9 is Guido, I'd put myself as 1 aspiring to 2. So I wanted a timer, rather like the Visual Basic object, and I ...
2
votes
1answer
225 views

Implementation of a Vector3D class

I'm an amateur coder writing a geometry library in Python, and would like some feedback regarding my implementation of a class for 3D Vectors. My priority is to have a really friendly API for ...
4
votes
1answer
328 views

Wrapping bound methods

I've written this small class in Python that wraps bound methods but does not prevent the deletion of self. Do you have any thoughts on my code? Do you think I handle errors appropriately? Is it ...