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)

0
votes
2answers
28 views

For Python programming and being Pythonic, why “never is often better than *right* now”?

In the Zen of Python, I can understand most parts of it, except: Now is better than never. Although never is often better than *right* now So I think doing it now or getting results now is better ...
1
vote
1answer
36 views

Is it a common pattern in Python to have instance variables assigned in a constructor start with an underscore?

I recently started using UtilSnips, a Vim plugin allowing for a certain level of automation while coding by using template-like code snippets for common code fragments (class and function definitions, ...
15
votes
6answers
3k views

For what types of applications is Python a bad choice?

I just started learning Python, and I'd like to get some more context on the language. I realize that, in many cases, Python is a slow language relative to C or C++. Thus, Python is probably not the ...
0
votes
2answers
71 views

Better way to check multiple variables equal a single value in Python

In Python I want to check the following: if x is None and y is None and z is None and ... I'd rather say something like: if x, y, z is None: But that's not valid syntax. Is there a better way to ...
-1
votes
1answer
75 views

Create arithmetic expression from number using +-/* that equals target [duplicate]

For example, you are given the source 1234 and the target 24. The task is to use the standard arithmetic operators +-/* placed within source, without changing the order of the digits of source to ...
10
votes
6answers
11k views

Is Python a good choice to develop UIs? If so, wxPython or Tkinter?

I'm looking forward to develop a desktop application using Python. I'm a beginner and I don't have sufficient expertise in Python. I'm also a Java programmer. Although I have some experience in ...
15
votes
3answers
6k views

Why isn't there a python compiler to native machine code?

As I understand, the cause of the speed difference between compiled languages and python is, that the first compiles code all way to the native machine's code, whereas python compiles to python ...
0
votes
0answers
20 views

How can I make a Python deserialization function useable from another module? [migrated]

I have some serialization and deserialization code which works well within one module (and within the universe of classes I care about). E.g. class A(...): ... class B(...): ... def ...
2
votes
1answer
563 views

Web application / Domain model integration using JSON capable DTOs

I'm a bit confused about architectural choices for the web-applications/java/python world. For c/c++ world the available (open source) choices to implement web applications is pretty limited to zero, ...
0
votes
0answers
50 views

Python Micro-services Architecture

I have a Python-Flask webapp that stores data in MongoDB using an ORM. I want to extend this app and add a Apache Storm based micro-service that will require read & write access to dbs of the ...
1
vote
1answer
66 views

Python file naming convention?

I've seen this part of PEP-8 https://www.python.org/dev/peps/pep-0008/#package-and-module-names I'm not clear on whether this refers to the file name of a module/class/package. If I had one example ...
5
votes
2answers
381 views

What is the relationship between scope and namespaces in Python?

In many resources I found "scope" and "namespaces" are used interchangeably, which seems a bit confusing since they mean different things. Scope defines the region of the code where a name is ...
1
vote
1answer
70 views

Does exception handling belong at the lowest level of the runtime?

I'm designing a fairly simplistic stack-based programming language, and implementing it in Python. (no link, because it's not fully implemented yet.) The language itself is essentially intended to be ...
1
vote
1answer
57 views

Question regarding the names of OrderedDict and defaultdict functions in Python

While reading Python Cookbook I came across these two lines: from collections import OrderedDict from collections import defaultdict Now see the naming conventions of the functions in ...
1
vote
4answers
177 views

Handling exceptions I don't know about

When I work with handling exceptions, I notice that I often have to deal with the ones I had no idea about. Especially it is noticeable when I program a method that grabs data from web. An error may ...
0
votes
0answers
22 views

How can word lists be used as supervised data in finding the score of the report?

We have got historical reports and we need to find the score (whether report is effective or useful or not) based on supervised learning. While doing the supervised learning process, we have to ...
1
vote
2answers
51 views

Should I include scripts inside a Python package?

In my Python application, I can distinguish between entry points (scripts) and what I think of as library code. My instinct is to put the library code inside a package, and the scripts elsewhere ...
0
votes
2answers
166 views

Why is Python 3.4 still developed after the release of 3.5? [closed]

The lastest version of Python is 3.5.1. However, the latest release is 3.4.4. Why is 3.4.x still developed? Are there breaking changes in 3.5 with respect to 3.4? https://www.python.org/downloads/
31
votes
9answers
6k views

Is the algorithm more important than the programming language?

During the current (2013) Google Code Jam contest, there was a problem that took C++ and Java people 200+ lines of code as compared to Python people that solved the same problem only using 40 lines of ...
51
votes
1answer
35k views

Module vs. Package?

Whenever I do from 'x' import 'y' I was wondering which one is considered the 'module' and which is the 'package', and why it isn't the other way around?
0
votes
2answers
109 views

How to approach hours forecasting

I have a django web app and I basically need to forecast budgeted hours for 2 departments to help them schedule staff as currently the best they can do is just wing it. When we receive a job proposal ...
0
votes
1answer
56 views

Developing an app using Django. Do I design front-end after app? Or develop Django to fit UI? [duplicate]

Edit: this differs from a similar question because I'm interested specifically in how Django works with the front-end. I.e. what is considered best practice when developing using the Django framework. ...
0
votes
2answers
66 views

What is the difference between proxy class and delegation in Python?

Wiki: A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, ...
1
vote
0answers
27 views

How do I minimize the number of database queries in a GeoJson API (of countries, and smaller areas) with custom data?

The general version of the question is above - a a little more detail, I am using Django Rest Framework, but am happy for answers to be dealing with the problem in abstract. So, I have data with ~200 ...
3
votes
1answer
523 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 ...
0
votes
2answers
203 views

Using a bytearray rather than a string to store password in memory

Using a bytearray datatype to store a password (in memory) has an advantage over using a string datatype for a password in that a bytearray is mutable and can be overwritten with 0x00 values when the ...
4
votes
1answer
88 views

Explicitly fill in requirements.txt for our Python projects?

As a user of pip install package and then pip freeze > requirements.txt, I was surprised to see a requirements.txt like this: # Flask # License: BSD # Upstream url: ...
2
votes
3answers
239 views

the perils of using eval() for dynamic object creation — is this a valid argument in a consenting-adults culture?

I've read on stackoverflow explicit warnings against using eval() to create objects. The reason that seems to be given is that malicious code could be injected and blindly created objects could ...
2
votes
1answer
57 views

Passing in objects to __init__ or passing a common param to and constructing objects inside __init__?

I have a class Foo that creates instances of other classes A, B, and C in its constructor. A, B, and C share the same constructor parameter and are used in other parts of the codebase, not just in ...
0
votes
1answer
76 views

How can you catch all index out of range errors in python?

Our program does these kinds of operations hundreds of times for many different variables and lists, then uses them throughout the program: variable = values[5] The list values are coming from the ...
4
votes
3answers
2k views

Lambda expressions with no parameters in Haskell and / or lambda calculus

In eager languages like Scheme and Python, you can use a lambda expression without parameters to delay evaluation, e.g. in Scheme (Chicken Scheme): #;1> (define (make-thunk x) (lambda () (+ x 1))) ...
5
votes
1answer
327 views

Draw a Call Graph

I'm maintaining an old code base written in python. In particular there is a complex piece of code that from a module calls other functions from other modules that call other functions and so on. It ...
2
votes
0answers
58 views

How to find related articles among a set of articles?

I'm utilising OpenCalais API to tag the articles from multiple news sources. I know which category each article belongs to (e.g. crime, politics etc). Also each article has three social tags ...
9
votes
4answers
638 views

Why do python generators and functions share the “def” keyword?

Consider the following: def some_function(): return 1 def some_generator(): yield 1 In the code above, some_function is a function, while some_generator is a generator. They look quite ...
0
votes
0answers
3 views

Subprocess writing stdin and reading stdout python 3.4 [migrated]

I am writing a script which would run a Linux command and write a string (up to EOL) to stdin and read a string (until EOL) from stdout. The easiest illustration would be cat - command: ...
0
votes
1answer
202 views

Making API calls with celery

I'm designing a system for a client where the requirements are: they upload a JSON file (one object/line) make a call to an API with the JSON object as the payload record the state (success/failure) ...
23
votes
1answer
2k views

Why does the documentation on some languages say “equivalent to” rather than “is”?

Why does the documentation on some languages say "equivalent to" rather than "is"? For example, the Python Docs say itertools.chain(*iterables) ... Equivalent to: def ...
-1
votes
2answers
74 views

Detecting Persons In Seats from Image [closed]

I am attempting to build an attendance program which could analyze if someone is sitting in a seat. The seats are fixed making knowing where each seat is easy, but I don't really know where to start ...
5
votes
1answer
111 views

How to organize my module

This is currently the way I'm organizing it. myProject/ README subproject1/ __init__.py classA.py classB.py driver.py basicTest.py Driver imports ...
4
votes
3answers
301 views

Is it ok to have multiple classes in the same file in Python?

I'm freshly coming to the Python world after years of Java and PHP. While the language itself is pretty much straightforward, I'm struggling with some 'minor' issues that I can't wrap my head around — ...
40
votes
3answers
5k views

Experience of Python's “PEP-302 New Import Hooks” [closed]

I'm one of the developers of Ruby (CRuby). We are working on Ruby 2.0 release (planned to release 2012/Feb). Python has "PEP302: New Import Hooks" (2003): This PEP proposes to add a new set of ...
2
votes
1answer
85 views

How do I manage quickly changing python modules

I write Python code for scientific computation. As it is research I face among other two problems: the demands are quickly changing results need to stay reproducable Imagine you have a package A ...
11
votes
2answers
1k views

Object oriented vs vector based programming

I am torn between object oriented and vector based design. I love the abilities, structure and safety that objects give to the whole architecture. But at the same time, speed is very important to me, ...
1
vote
2answers
112 views

python - differences between reusable code vs. code for solving specific tasks

Reusable code (ex. libraries and frameworks) and code written to solve a specific task and not meant to be reused as a general tool (for example, code being used only by my 6 person team in a private ...
-2
votes
1answer
534 views

Is pywebsocket a production tool? [closed]

Is it a good idea to use pywebsocket in a production environment, since it is so widely used, but their google developer page states "pywebsocket is intended for testing or experimental purposes". ...
4
votes
1answer
100 views

Using Python's Method Resolution Order for Dependency Injection - is this bad?

I watched Raymond Hettinger's Pycon talk "Super Considered Super" and learned a little bit about Python's MRO (Method Resolution Order) which linearises a classes "parent" classes in a deterministic ...
4
votes
1answer
83 views

Is Python's inheritance an “is-a” style of inheritance or a compositional style?

Given that Python allows for multiple inheritance, what does idiomatic inheritance in Python look like? In languages with single inheritance, like Java, inheritance would be used when you could say ...
6
votes
1answer
85 views

Python: Control subprocess from calling thread

I am working on a database interface to a MongoDB using Python Eve as an API. The database stores several documents containing parameters and values needed for some calculations. I wrote a Python ...
59
votes
8answers
13k views

Defensive Programming vs Exception Handling?

I'm working through the book "Head First Python" (it's my language to learn this year) and I got to a section where they argue about two code techniques: Defensive coding vs Exception handling. Here ...
4
votes
1answer
131 views

What is the most efficient way to implement a RESTful client app?

I am working on a web application for ranking some products based on some factors. The user send a search query to 5 restful webservices which by their turn send a response in a JSON format and ...