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)

1
vote
1answer
220 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 ...
-1
votes
0answers
15 views

Error finding primes with simple python program [on hold]

The below code is to output an array containing all the primes up to a limit. My code above does not do so, I cannot determine where the error is. #generate prime numbers up to a given value pa=[2] ...
-4
votes
0answers
47 views

How to run this Python program [on hold]

How does on run this Python script to produce an SVG from LaTeX? https://github.com/levskaya/OW/blob/master/scripts/latex2svg.py I tried the simple stuff so far, like "python prog.py" but cannot ...
1
vote
1answer
86 views

Does dynamically generating classes in python affect readability/performance?

I have a set of classes that represent different objects (tables in a database): class ObjA: # some class specific attributes and methods def refresh(self): # implementation ...
0
votes
0answers
26 views

Python - Flask controller structure

This is my first python application (I have some experience in Java/groovy-grails), and therefore I am not confident of the application structure I should be following. My application has two ...
-2
votes
0answers
44 views

Python Gmail app password [on hold]

I offer this as a "hey look what I found" and not a question. I had my Gmail username and password in plaintext in a python script that sends me notifications. Fearing it could become compromised, i ...
-5
votes
0answers
35 views

iterate list in python like for loop in python [on hold]

How to loop a list in python. What I have tried is, l=[1,2,4,5] for i in l print i I know how to in C. for(i=0;i<=10;i++){ do something.. } How can I achieve this in python ?
-2
votes
0answers
44 views

Multi process programming

I'm developing an xml server in python which serves as an api emulator for an existing server. I'm using process libraries in order to handle multiple processes in the server for each client request. ...
-4
votes
0answers
30 views

Phone to PC voice commands [on hold]

I am currently programming a small program in python that takes voice commands and executes commands depending on what was said. I need a way to input voice commands phone and send the translated text ...
3
votes
3answers
293 views

How to use multiple programming languages together in the same program? [on hold]

Such a simple question, but I have not found a reasonable answer to this. I currently program in Python, an interpreted language. I always hear of people using multiple languages in the same program? ...
-1
votes
0answers
20 views

Different values for linux crc32 vs python binascii [migrated]

I'm trying to calculate the CRC-32 for various files in Python. I used the binascii module to do so. But when I compare the value output with the output of the crc32 command, I get different values. ...
1
vote
1answer
201 views

From which point does it become dangerous to keep going as the sole developer on a project? [duplicate]

I'm working at a company where the management wants to capitalise on consulting experience to offer quality software to their (already existing) customers, and expand from that to become one day ...
3
votes
1answer
86 views

How should I represent composeable, associative computations to be repeatedly applied to units of data?

Spoiler My question is the following: Are there any design patterns for representing chainable functions that are for the problem described below? High-Level Decription of the Process I'm ...
-4
votes
1answer
59 views

Explanation of the code to read a file (File IO) [on hold]

In the code: in_file = open("test.txt", "r") text = in_file.read() in_file.close() What is the role of the text in the 2nd line ?
0
votes
2answers
80 views

How early does a hashable type need to become immutable?

Suppose I have a class that looks vaguely like this: class Foo(object): _value = None # XXX: see below def __init__(self, value): self._value = value @property def ...
-2
votes
0answers
57 views

Django vs Rails for SaaS Startup [closed]

Several friends and I have a SaaS idea we want to flush out and build a prototype. We have already decided on AngularJS for the front-end, so we need to find a framework that plays well with ...
28
votes
6answers
3k views

Why aren't there other programming languages that compile to Python bytecode?

In Java, there are multiple languages that compile to Java bytecode and can run on the JVM -- Clojure, Groovy, and Scala being the main ones I can remember off the top of my head. However, Python ...
2
votes
3answers
60 views

How do I deal with imported modules in GPL?

I wish to release a non-commercial python application under GPL3 in both source and (PyInstaller) executable form. I'm struggling to find a consistent answer to the problem of imported modules. Can I ...
0
votes
0answers
5 views

Python large list error [migrated]

I did the following program to generate a list of consecutive numbers. However, the computations seem to fail for more than 70.000 elements in the list. I tried using Pycharm IDE and also the python ...
0
votes
0answers
11 views

Networkx: draw edges certain attributes [migrated]

Using Networkx, I am considering a graph that is in reality the union of several subgraphs. I am trying to figure out the best way to deal with this. Currently, I have been using the following ...
0
votes
1answer
116 views

Running Python script in background on Mac

I have a Python script that counts the number of file in a folder, and if the number of files exceeds 10 then it creates a popup window to ask the user to clean up the folder (I use tkMessageBox). ...
0
votes
2answers
82 views

Is it ok to access private members while doing same class comparison?

I am writing a class which basically is a wrapper around a dictionary with some extra functionality. This dictionary is stored as protected member _store. Now I am writing a __eq__ method to compare ...
42
votes
8answers
8k 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 ...
2
votes
2answers
81 views

Django CBVs vs FBVs

For creating a large Django project with many apps, my first initial thought was to used Class Based Views (as the Django tutorials seem to emphasize). However, I noticed that due to a lot of the ...
1
vote
0answers
19 views

Keeping Track of Calculation Dependencies [migrated]

Suppose I have a set of calculations: x = x() y = y(x()) z = z(y(), x()) I would like to create a Python class to implement these calculations, being mindful of the dependencies and caching results ...
0
votes
1answer
48 views

Why do objects created with no assignment not generate a syntax error in Python?

While working on a Python project, I realized that during my editing I had left a string floating around in the middle of my code and it didn't generate an error. For example, these few lines execute ...
2
votes
1answer
108 views

Python Open Source Development

I am looking to contribute to some Python projects on Github, and I am looking for a bit of clarification on the mechanics of doing this effectively. As I understand it, the typical workflow is as ...
16
votes
4answers
2k views

How large should a Python module be? [closed]

I was browsing a github project and found this module which has more than 10 thousand lines. Is it good practice to have that much code in a single module? Shouldn't this be split over multiple ...
-1
votes
1answer
54 views

Python recipe question: Use of **kwds instead of specific named argument in itertools recipe [closed]

The function definition below comes from the itertools recipes page (https://docs.python.org/2/library/itertools.html#recipes). def random_product(*args, **kwds): "Random selection from ...
0
votes
1answer
125 views

Should an object query its owner?

I have a World class World: def __init__(self): self.size = 10 self.n_busStops = 10 self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0) self.buses ...
-1
votes
0answers
15 views

Is it possible to use Python to detect the address of a (parallel) port? [migrated]

I have an EEG experiment programmed in Python (PsychoPy, to be exact), and we send event markers to the EEG recording computer through one of these adapters. This requires giving Python the address of ...
0
votes
1answer
43 views

using one database connection across multiple functions in python

whats the best way to go about this in python? I have a number of like so def test1() .... code ..... def test2() .... code ..... def test3() .... code ..... how could I create one ...
1
vote
1answer
51 views

Is there a cleaner way to test extras_require

I have code reviewed a piece of Python code, but to me it looks really ugly, hacky and complex for something that can be achieved very easily. The code looks something similar to the following: ...
0
votes
0answers
5 views

Opencv two camera source [migrated]

I am working with opencv and have two video source. I am using the following code. The code works sometimes and sometimes it does not work. Is there a problem with my code. How can I make the ...
0
votes
1answer
43 views

How can I determine which version of Python introduced a particular module to the std lib? [closed]

Is there a single timeline-style resource available showing the history of the modules available in different versions of Python? I'd like to, for instance, easily determine which version of Python ...
4
votes
2answers
95 views

Changing method signature while keeping backwards compatibility

I've inherited an API to maintain. Users can pass a callback function to the class which gets called on some event. The callback function is currently passed in a single argument. I need to change ...
4
votes
4answers
986 views

What makes Python more used as an implementation language than the others?

Perl and Python are often compared to each other (let's not forget Ruby), and almost always those discussions will come to the conclusion pretty much anything you can do in one or the other. Without ...
0
votes
0answers
4 views

Trouble installing mechanize in virtualenv [migrated]

If use pip to install mechanize on my computer, I can import it perfectly fine. However, if I set up a virtualenv (following the instructions here), run ` pip install mechanize and then try ...
0
votes
3answers
329 views

What can C++ do that Python cannot? [closed]

I was reading this post: http://www.quora.com/What-are-the-advantages-of-Python-over-C++ And I am wondering the converse of this question: what can C++ do that Python cannot? For example, in the ...
-1
votes
1answer
83 views

Intership Interview Tips? [closed]

I am currently a freshman in college studying CS. I recently submitted my resume to a small subset of HP in my hometown and got a response back saying they will contact me for a phone interview. I ...
-1
votes
0answers
11 views

In IPython console (Spyder), can I access a variable from main() after running my program? [migrated]

I am running my code using an IPython Console. I have a main() function that is executed as follows: if __name__ == "__main__": main() Then main() calls a bunch of other functions and I don't ...
3
votes
4answers
147 views

What argument passing mechanism does python use, and where is this officially documented?

As far as I am aware, python is generally referred to as 'call-by-sharing', but does it implement this with call-by-value (like Java) or call-by-reference? or something else? I would appreciate if ...
2
votes
2answers
168 views

Building a string parser for user command and control?

My goal is to build a command parser that has basic syntax and multiple possible branches at each point. These commands come from users of the system and are text input (no GUI). The basic syntax is ...
0
votes
1answer
114 views

Should I use a class as a wrapper?

Lets say I have a class representing a chemical compound class Compound(networkx.Graph): def __init__(self): super(Compound, self).__init__() And lets say that I want to add some ...
17
votes
3answers
3k views

How to solve the problem of nested comments

It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes ...
49
votes
7answers
31k 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 ...
2
votes
6answers
528 views

Why is python treated as a interpreted language when it has a compiling stage? [closed]

Why is that python is treated as only an interpreted language when there is in fact a compiling stage where the code we write gets converted into byte code(.pyc), which is later interpreted by the ...
2
votes
2answers
609 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: ...
6
votes
0answers
114 views

Which languages have the best support for stackful coroutines? [closed]

Various languages support (some flavor of) coroutines. One way to discriminate coroutines is whether they are stackful or not (terminology based on Ana Lucia de Moura; Roberto Ierusalimschy (2004). ...
0
votes
1answer
37 views

Django Project Logic Solution

I'm starting to develop my first webapp, and I'm using django. Before anything I'm working on the software logic, how it should work, the links and objects it needs. The problem is: I need the app ...