Python is a dynamic, high-level language. Its design focuses on clear syntax, an intuitive approach to object-oriented programming, and making the right way to do things obvious. Python supports modules, exceptions, had an extensive standard module library. Python can also be embedded in other ...

learn more… | top users | synonyms (1)

10
votes
9answers
2k views

Is there any difference learning OOP on different programming languages? [closed]

I want to learn OOP. I know Python and I know very little things about OOP. But when I search for "learn OOP" in forums I saw a guy saying that "Python is so new that's why you can't learn OOP on ...
1
vote
1answer
94 views

Why chaining matters (Python & SQLite3)?

Why does cursor = connection.cursor() cursor.execute("... return cursor.fetchall() return the expected non-empty result whereas connection.cursor().execute("... return ...
0
votes
1answer
76 views

does anyone know how to use the PyQt 'uic' module method 'compileUiDir'?

I don't find the docstring to be very clear: def compileUiDir(dir, recurse=False, map=None, **compileUi_args): """compileUiDir(dir, recurse=False, map=None, **compileUi_args) Creates Python ...
1
vote
2answers
212 views

Python sorted iterable set, modifiable during iteration

I am looking for a datastructure to handle cycling through a large number of ordered subroutines, some of which are active, most of which are not. I am thinking I need an implementation of a python ...
0
votes
1answer
68 views

Pythonic design for controlling multiple devices through an I2C bus

I'm writing a piece of software in python that will communicate with a bunch of devices via an I2C bus. Each of these devices are going to need some sort of a module or class to handle the ...
1
vote
1answer
117 views

Dynamic method creation in python

I have a class that will have a number of external methods that will all call the same smaller set of internal methods. So something like: obj.method_one(a, c) and obj.method_two(a, c) where ...
0
votes
1answer
107 views

In python, do we have class encapsulation at the level of the object?

I was bitten by using the is operator when i should have been using ==. Am aware that the former tests for equality of the objects' identities and that the latter tests for equality of the objects' ...
0
votes
1answer
131 views

Using module level declared global “singletons” in python

Ok, I know that using singletons is generally a bad practice, but if I do it (for db connection, logging et al.) am I allowed to go (in respect of clean design) with a module defined variable that is ...
0
votes
2answers
746 views

How to write an optimal LAN messenger software?

I am asking this question as an extension to the following question: https://superuser.com/questions/713409/how-to-message-any-user-on-your-lan I don't think I have a real answer. I found it quite ...
0
votes
0answers
37 views

Implementing FUSE for deduplication

I am new to FUSE and using python-fuse for writing a file system for data deduplication. Let's say, I have a directory named "metadata" and in that directory, there is a file foo and a directory ...
4
votes
1answer
226 views

What is the historical reason why Python uses the double underscore for Class Private members

In python a module private function or variable is named _foo. If it is private to a class it is names __foo, The mechanics behind how these work are different, however that is of little relevance to ...
3
votes
3answers
331 views

Is Python suitable for a statistical modeling application looking over thousands of past events?

I'm currently working on a project with a partner where we analyze large datasets of past sporting events. There are approximately 30,000 events per year and we have historical data for five years. ...
5
votes
4answers
378 views

Communicate to a junior developer about bad style

I have a friend who's managed to pick up comma first (best case might be made here: http://ajaxian.com/archives/is-there-something-to-the-crazy-comma-first-style) but it's 100% against our org's style ...
2
votes
1answer
851 views

Using python to parse log files? [closed]

My first useful projects as a programmer has been python scripts that parse out relevant information from log files and do some analysis. I've bumped around and found my way to some functional ...
1
vote
1answer
78 views

How to comment on a PEP?

Proposals for new Python features are collected in documents called PEPs (Python Enhancement Proposals). There's a master list at http://www.python.org/dev/peps/ which links to (for example): ...
1
vote
1answer
286 views

Python for a desktop app

I currently have a .NET app that I want to convert to being cross platform, as a growing number of my users want a Mac version. Since this forum doesn't seem to like questions that are "what ...
0
votes
1answer
306 views

Front-end structure of large scale Django project

Few days ago, I started to work in new company. Before me, all front-end and backend code was written by one man (oh my...). As you know, Django app contains two main directories for front-end: ...
0
votes
0answers
236 views

Django web app with websockets

I want to make a web service using Django, but that also has websocket functionality. Having done a bit of reading, this is the tech stack that I'm looking at: --------------------------------- ...
0
votes
2answers
269 views

How can I convince my client that the task was complex and the time I took is fair?

I am the single programmer working on a website handling both frontend and backend. Recently in my task list I have to provide a social news feed (activities among friends) which should summarize ...
0
votes
1answer
107 views

return Trivial booleans?

I am writing a simple piece of code. Its a function that allowed the user to withdraw some money. There are some restrictions to this though. The user can't withdraw more than the given withdraw ...
0
votes
0answers
49 views

Distributing Contestant Entries Between Multiple Bins, Is this Knapsack?

I am an algorithm novice and am faced with a rather difficult problem. I working with contest's. There are contestant - individual player entry - contestants can have multiple entries into a ...
1
vote
2answers
617 views

Python - assert vs if & return

I am writing a script that does something to a text file (what it does is irrelevant for my question though). So before I do something to the file I want to check if the file exists. I can do this no ...
0
votes
1answer
145 views

Why can python webapps keep sessions between restart and not java?

I've used both webapp2 + GAE for python and a number of Java/JEE webapp frameworks. The python WSGI framework could keep users logged in while I redeploy the app while none of the Java web framework ...
0
votes
2answers
130 views

What are and how do (data-) types work?

What is a "variable"/data type? How does a compiler / interpreter handle types? My specific concern has to do with the different types in lower and higher level languages. For instance in Python, ...
0
votes
1answer
53 views

Verify 0 or 2+ sub sections in a section

There is a rule in writing: When you break a section into subsections, typically it should have more than one subsection. This goes back to the old high school composition rules: if you have an A. ...
15
votes
8answers
797 views

What are good unit tests to cover the use case of rolling a die?

I'm trying to get to grips with unit testing. Say we have a die which can has a default number of sides equal to 6 (but can be 4, 5 sided etc.): import random class Die(): def __init__(self, ...
0
votes
0answers
86 views

Approach to statically analyze a Python code base

What approach should I use to statically analyze a Python code base? In particular, I am looking for ways to: extract and display the class hierarchy, extract and display class relationships, ...
3
votes
2answers
121 views

Inform caller or just let them deal with exception?

I'm not sure how to proceed in the following situation. say we have a function as so: def runsATask(codes): myDicts = [helperFunc(code) for code in codes] for item in myDicts: # some ...
5
votes
4answers
534 views

Why doesn't Haskell have a 'format' function for string interpolation?

I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about Text.Printf — it's not what I'm looking for. The ...
7
votes
3answers
504 views

Python - 'if foo in dict' vs 'try: dict[foo]'

This is less a question about the nature of duck typing and more about staying pythonic, I suppose. First of all - when dealing with dicts, in particular when the structure of the dict is fairly ...
-2
votes
1answer
204 views

Extracting data from log files

I will be extracting certain bits from log files using regular expressions to filter out bit of data. Initially I was going to do this with Python. I later started to think about the fastest way I can ...
2
votes
2answers
126 views

Automated testing of programs with graphical output

I am a lecturer for a post-graduate module where I expect my students to write Python code that replicates examples from the textbook. The project has been running for a couple of years and this year ...
18
votes
3answers
1k views

Why do so many languages treat numbers starting with 0 as octal?

I've read Where are octals useful? and it seems like octals are something that were once upon a time useful. Many languages treat numbers preceding with a 0 as octal, so the literal 010 is actually ...
2
votes
2answers
106 views

Is there a way to efficiently allow a user to upload multiple content at once for e-commerce type sites?

Sellers on large sites like Amazon and Newegg need to provide names, descriptions, and images for their products to be displayed on the e-commerce sites. These sellers could have 10000+ products to ...
1
vote
2answers
148 views

Documenting/defining data structures in Python

What is the preferred way to document the contents of and logic behind dynamically generated data structures in Python? E.g. a dict which contains the mapping of a string to a list of lists of ...
3
votes
2answers
168 views

What are the advantages of dynamically binding a method to class instance?

I came across Instagram's API client written in Python. In their class InstagramAPI, they bind the methods to a function in bind.py. When called, the function returns an instance of the class ...
0
votes
5answers
306 views

How to create a Python interview question to write a method

If I'm giving an interview coding question in Java, I can specify the most of the question just by giving a method signature. (Made-up example follows.) public class Table { public String ...
0
votes
0answers
138 views

Extending user registration in Django site that uses both site admin tables and my own module?

I'm writing a Django site that registers a particular type of user and this is done by the resources that come with the framework, the site administration. The issue: I'd like to create a new model ...
3
votes
3answers
163 views

conditional expressions, correct usage

I've recently become quite taken with conditional expressions in Python. Apparently some people consider it unpythonic and whether or not conditional/ternary expressions are even A Good Thing seems to ...
1
vote
1answer
83 views

Additional actions in setup.py for install

Background So, I'm developing a project, and I'm writing setup.py script for it, using distutils. I'm using CPython3.3. I use some libraries that have invalid distributions in PyPI, so they have to ...
4
votes
3answers
328 views

Which is better API: table.add_row() or table.rows.add()?

I'm writing a library to create and manipulate Word .docx files in Python. In general, I take a lot of influence from the Microsoft VBA/C# API for Word in designing the API, figuring they've given it ...
4
votes
3answers
185 views

Python: How to decide which class' methods should provide behavior (functionality) affecting multiple classes

I have a question about object oriented design that is not specific to Python but since my code is in Python, I tagged it as such. How do I decide which of my classes should be responsible for ...
0
votes
2answers
160 views

Google App Engine overview

I have gone through many Google App Engine tutorials, and I became quite familiar with how to do basic stuff like implementing a webapp2.RequestHandler, and using ndb.Models to manage your data. Now, ...
1
vote
4answers
383 views

How should you cleanly restrict object property types and values in Python?

I have been learning python from no long time ago. But nearly at the beginning I stumbled on simple question: how to set a restriction (limitation) on object value or object's properties without ...
3
votes
2answers
173 views

Writing a unit test for a platform dependent unit

I have a method to be tested which depends on the OS, what's the best approach for testing the method depending on the OS? Is it to test on every OS that I have I require? Is there a better approach ...
-3
votes
1answer
59 views

Pausing Python Tkinter Program [closed]

I have made a card matching game using python, and I need it so that when two cards are selected, they are shown for a few seconds and then the code executes to get rid of them or return them. I have ...
0
votes
2answers
715 views

Model-View-Controller — Where does a factory class go?

I'm working (slowly) on a small Flask project. One of my models is a class called Post, which is a lightweight namedtuple. Post objects are created by a PostFactory, because creating a Post involves ...
3
votes
2answers
169 views

Python - defining exit method before importing

This breaks nothing (in my experience), but lots of things "don't break anything" and are still wrong. #! /usr/bin/env python """Short description of this module.""" def ...
0
votes
3answers
272 views

What is the difference between 'code readability' and 'language conventions' used within a community? [closed]

When I'm looking at questions asked on sites like stackoverflow on how to make a particular piece of code "more pythonic" there are usually suggestions offered to use complex list comprehensions or ...
1
vote
2answers
154 views

How can I automate the process of code review

I have a team that works on multiple technologies. I want to know how can I automate the process of code review for .Net, .Net MVC, Python, PHP, Drupal and HTML5/CSS with JavaScript. I have read ...