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)

5
votes
4answers
512 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 ...
2
votes
0answers
41 views

idea mapping with global state [closed]

I need to map ideas to ideas to ideas to ideas (four in total, semantically, and a fifth one-to-one): the state is global it can change over time I'm writing the module from scratch Here's my ...
0
votes
2answers
128 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, ...
1
vote
4answers
367 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 ...
0
votes
1answer
144 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 ...
2
votes
1answer
157 views

Merge two different API calls into One

I have two different apps in my django project. One is "comment" and an other one is "files". A comment might save some file attached to it. The current way of creating a comment with attachments is ...
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 ...
7
votes
3answers
457 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 ...
1
vote
2answers
81 views

Suggestions designing an XML polling deamon in python

I'm about to take on a new project for a client designing a server-side python program that will poll a number of XML streams at regular intervals and populate a Postgresql database with results. The ...
-2
votes
1answer
202 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 ...
0
votes
2answers
153 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, ...
2
votes
2answers
123 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
1answer
811 views

XMPP— openfire, PHP and python web service

I am planning to integrate real time notifications into a web application that I am currently working on. I have decided to go with XMPP for this and selected openfire server which I thought to be ...
1
vote
2answers
146 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
165 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 ...
1
vote
2answers
188 views

Using a web framework as python GUI

If I built some useful piece of python code to e.g. scrape a website or to calculate something big, at some point I might want to add a GUI to my project. For this I could use Tk, Qt, Pygame or any ...
115
votes
9answers
23k views

Why do people hesitate to use Python 3?

Python 3 was released in December 2008. A lot of time has passed since then but still today many developers hesitate to use Python 3. Even popular frameworks like Django are not compatible with Python ...
0
votes
5answers
303 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 ...
1
vote
1answer
82 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
172 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 ...
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 ...
4
votes
3answers
320 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 ...
6
votes
2answers
734 views

How to remove the boundary effects arising due to zero padding in scipy/numpy fft?

I have made a python code to smoothen a given signal using the Weierstrass transform, which is basically the convolution of a normalised gaussian with a signal. The code is as follows: #Importing ...
11
votes
2answers
3k views

What are hooks? [closed]

I keep coming across this term hooks in various programming articles. However I don't understand what they are, and how can they be used. So I just wanted to know what is the concept of hooks; if ...
2
votes
1answer
1k views

Python multiple inheritance or decorators for composable behaviours

I recently discovered (or rather realised how to use) Python's multiple inheritance, and am afraid I'm now using it in cases where it's not a good fit. I want to have some starting data source ...
3
votes
2answers
166 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 ...
3
votes
2answers
166 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
685 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 ...
0
votes
3answers
271 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 ...
0
votes
2answers
141 views

Factory for arrays of objects in python

Ok, the title might be a little misleading. I have a Window class that draws widgets inside itself in the constructor. The widgets are all of the same type. So I pass a list of dictionaries, which ...
1
vote
2answers
151 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 ...
38
votes
7answers
22k views

Why use try … finally without a catch clause?

The classical way to program is with try / catch but when is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do ...
1
vote
1answer
117 views

How do we pass data between two Amazon instances?

I'm trying to create a website where the user enters a few numbers, these numbers are fed into some equations, and the output of these equations is emailed to the user. I'm using Python 2.7 for ...
0
votes
2answers
83 views

How to make the leap from classification to clustering

I have a clustering problem which I can't seem to solve, although if I treat it as a labeled classification problem, I can solve it with satisfactory precision. Is there an elegant way to make the ...
1
vote
1answer
140 views

Is using os.environ to store the value of command line switches pythonic?

I write CLI-executable Python 3 scripts regularly to do data compilation and some maintenance tasks, and try to adhere to PEP 8 and the Google Python Style Guide when doing so. Google's guide says to ...
6
votes
6answers
4k views

What language to use for prototyping and creating quick scripts? [closed]

Right now, I use Python for my quick scripts and prototypes (e.g. algorithms, my pseudocode is very Python-like as well). The oher languages that I am familiar with include Java, C, x86 Assembly and ...
0
votes
1answer
199 views

processing Postfix log with python

I need to process all log messages from Postfix (/var/log/mail/mail.log), and print a summary/statistics (how many emails were sent/received and from/to which email addresses) The situation is made ...
7
votes
4answers
2k views

Google App Engine, what are the advantages and limitations?

First, does anyone know a specific advantage of Google App Engine for Python Apps? Is there some advantage over Heruko or Appfog? And about the database API? Now, what about the limitations? Are ...
0
votes
3answers
175 views

Tips for developing a mobile app with a team [duplicate]

I am currently a high school student, I've been assigned to manage a group in my school to develop a mobile app and the problem is that all of us have no experience in making a project in a team and ...
2
votes
3answers
277 views

is it really necessary for python to differentiate between tuples, lists, dicts, ordered dicts and sets?

i have been learning python over the past month or so. i like many of the things about the language, but i find the differentiation between tuples, lists, dicts, ordered dicts, and sets to be ...
2
votes
1answer
213 views

Python garbage collection giving me a hard time

Context: I am developing a web application using webapp2 web-framework with python to be hosted on GAE. The web application (web-app from now on), is a chess variant. Being a first timer, I have ...
3
votes
4answers
451 views

How to elegantly work with a lot of print functions?

I'm working on a Python project that is executed on a terminal (or console) for which I am planning to implement a GUI. I did not major in CS so I really have no idea how to effectively design a ...
3
votes
2answers
331 views

What was the need of introducing Python 3 when we already had Python 2 [duplicate]

I am still learning python and I started with Python 3. This question not Python 2 vs 3 or difference between them like print() is a function and not language construct and 3/2 = 1.5 My question is ...
8
votes
3answers
389 views

When and how should I use exceptions (in Python)?

The Setting I often have trouble determining when and how to use exceptions. Let's consider a simple example: suppose I am scraping a webpage, say "http://www.abevigoda.com/", to determine if Abe ...
4
votes
2answers
282 views

Is using static-typing the solution to domain-driven design and decreasing the number of errors?

We are using PHP (a dynamically-typed language) in our project. However, I have found my colleagues asking questions such as ...
4
votes
1answer
336 views

Will loop constructs become obsolete? [closed]

By loop constructs I mean for… and while… constructs with nested statements. Currently I am coding a tool in Python and decided out of curiosity not to use the regular loops - and rely on ...
9
votes
4answers
632 views

Python decorators and Lisp macros

When looking Python decorators someone made the statement, that they are as powerful as Lisp macros (particularly Clojure). Looking at the examples given in PEP 318 it looks to me as if they are just ...
2
votes
4answers
3k views

Pros of start learning programming with Python if what I really want is Javascript? [closed]

A friend of mine seeks to learn Javascript programming but he never programmed before. I've found Python as a quite nice language that takes most unneeded "strangeness" out of learning programming ...