Tagged Questions

Python is a dynamically and strongly typed programming language, used for developing a wide range of applications. The philosophy of Python is succinctly formulated in The Zen of Python, which can be revealed by issuing this command at the interactive interpreter: >>> import this The ...

learn more… | top users | synonyms

1
vote
3answers
70 views

I think I'm not using Try Except properly in this Python code

Please offer some advice for this code. It all works, but I know that its messy and I don't think the Exception catching is doing what I want it to. Thanks in advance for any and all advice... def ...
3
votes
3answers
73 views

Blackjack card game

It's been a long while since I've done any Python programming so I thought I'd start with a simple blackjack game. Any comments on how I can make this more readable? Use more methods perhaps? from ...
2
votes
1answer
64 views

Parse a text file in python

I would like to refactor a large python method I wrote to have better practices. I wrote a method that parses a design file from the FSL neuroimaging library. Design files are text files with settings ...
2
votes
3answers
37 views

Building and getting a form of objects that have multiple properties

I'm building a form dynamically in a web app where I'm using product_id to keep track which product I'm reading and then product_<id>_property to grab the value of it. Then in my view I end up ...
8
votes
2answers
116 views

Replacing Python Classes with Modules

I try to avoid using classes in Python as much as possible; if I don't plan on building on it, I don't build it in the first place. It helps me avoid Java-like classes like FileDownloader(), when I ...
2
votes
1answer
46 views

How to improve this SmartDownloader?

This is a class that downloads files in a smart way: it tries to download from different sessions. This do speed up things. How can I Improve it? import os import urllib2 import time import ...
1
vote
0answers
64 views

Markov Encryption API in Python 2.5

The module in question provides classes used to execute Markov encryption and decryption on arrays of bytes. ME was inspired by a combination of Markov chains with the puzzle of Sudoku. This version ...
3
votes
2answers
123 views

How to avoid repetition

The program is supposed perform discrete mathematics operations on a number of conjunctive statements (see lines 34 - 50). Currently I just have it so they print out the tables in 0's and 1's, but ...
1
vote
2answers
128 views

How to Improve This Program, Add Comments, etc.?

Do you have any suggestions to improve or extend this script? Any ideas for removing or adding comments/docstrings? import dbm import subprocess import time subprocess.call("clear") try: # Tries ...
1
vote
1answer
52 views

JPEG metadata processor

I am looking to make the below code a bit more efficient / OOP based. As can be seen by the X, Y & Z variables, there is a bit of duplication here. Any suggestions on how to make this code more ...
1
vote
2answers
46 views

Doubts about db_index, primary_key and unique parameters

I'm trying to improve my code. I've some doubts about db_index, primary_key and unique parameters. # -*- coding: UTF-8 -*- from django.db import models from django.contrib.auth.models ...
1
vote
1answer
27 views

LPTHW - ex48 - Handling exceptions and unit testing

This is my solution to the exercise 48 of Learn Python the hard way by Zed Shaw. Please visit the link for testing suite and requirements. I'm worried about my the word banks I have created (COMPASS, ...
1
vote
2answers
87 views

How to (and should I) avoid repetition while assigning values from different sources?

In a Mako template partial I accept an argument (step) that can be an instance of Step class, a dict or None. Can I in some way avoid repetition or do the check in other more 'pythonic' way? Or how ...
1
vote
2answers
47 views

Accounts Payable Buckets (Current,30,44,48,60) / Kludgy

The following method is designed to display what we owe to a vendor based on 5 buckets. So basically an aged trial balance (totals only). It also needs to be able to display the data based on any ...
1
vote
2answers
60 views

Performing a chain of mutually dependent actions, and reversing in case of failure

Description I'm writing a program that makes changes to a few Python source files--creating some, and appending content to others. Since some changes depend on others, I check frequently to make sure ...

1 2 3 4 5 25
15 30 50 per page