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
29 views

Roadmap to create a scientific computing website

I am a theoretical physicist starting my Ph.D. shortly. As a side project, I would like to create a scientific computing website in the field of General Relativity. It should be an interactive ...
-2
votes
0answers
22 views

Is there a way using Python to create multiple volatile table in teradata

I am using python to create multiple volatile statements in teradata but I am not able to execute more than a table. I am using End Transactions after every create statement. Please help I am getting ...
-2
votes
0answers
31 views

Cython /Numba for competitive coding [on hold]

Is there any competitive programming site that accepts submissions in cython. I know that in competitions like Google code jam or fb hacker cup, you can use cython. Here, I am asking about coding ...
-4
votes
1answer
33 views

Load files with Python in JavaScript [on hold]

I have some data in files (10mb x 10 files) that need to be loaded with Python. I would like to pass a file name from JavaScript to a Python server to load and then get a json/array back in a ...
1
vote
1answer
41 views

Guidelines for returning None vs. raising Error for Python string-validating functions

Let's say we have a function that checks if a given pattern occurs in a string. The default behaviour is that if the pattern matches, then it returns the pattern. So far so good but what is the ...
1
vote
0answers
11 views

Refactoring Code into a MVC Pattern under the Constraint of a Library God Object [duplicate]

I have 1000 LOC that I plan to refactor into different files and functions. The goal is to be able to test the business logic independently from the visual display. Hence, I am considering an MVC ...
1
vote
1answer
176 views

Why Variables in Python Are Different from Other Programming Languages?

According to my understanding, a variable in Python is: A name that refers to a value stored in the computer memory, and it's like a label on a box. but in other programming languages it is: ...
-2
votes
0answers
22 views

How to find the algorithmic complexity of this program? [duplicate]

I have the following program which finds out all the prime factors of a given number. Algorithm: Divide by 2 until the number is odd, for each successful division add 2 to list of prime factors. ...
1
vote
0answers
66 views

If LYBL is faster than EAFP, why should I use try/except over hasattr?

I was once told that hasattr is simply getattr with exception handling. This is not the case, because hasattr is implemented in C like the rest of Python's builtins. I was curious one day, so I ...
2
votes
1answer
61 views

When should I worry about freeing objects from memory in Python?

I've been reading a few different guides and tutorials, as I am interested in learning some best practices of programming. I was reading the How to be a Programmer guide, and there is a section about ...
-2
votes
0answers
15 views

Can no Longer open Spyder IDE for Python Programming [migrated]

I installed Python 3.4 on my Windows 7 laptop several months ago as part of Anaconda (https://www.continuum.io/downloads). My installation included the Spyder IDE, and I have successfully been using ...
-3
votes
0answers
40 views

How can I write a web application using Python to write down things I want? [closed]

I've just finished reading tutorials on Python's homepage. And now I want to create one web application to get deeper understanding about Python. The aim is to note (write down) information and save ...
-1
votes
0answers
18 views

Control music playback from python or terminal

As part of a larger project, I have been working on a program that will take a string, search a directory and sub directories for a song file that matches, and play it. I need the program to continue ...
1
vote
2answers
74 views

Is it good design to log something related to an object from the callee?

I am designing a class whose object is instaniated with a user idn which creates a pdf with that user specific details. It should log something depending on success or failure which can be determined ...
2
votes
0answers
43 views

Are there any generic algorithims or Python functions to help find the longest item in a JSON document?

I am trying to log a JSON error message to Google's Cloud Logging platform. Unfortunately, the maximum size message you can log is 8000 bytes and some of the JSON documents I want to log are larger ...
5
votes
2answers
347 views

You don't call the Framework, it calls you

I need some clear explanation and maybe an example of how frameworks like JavaFX, Tkinter etc. work. Lets take Python's Tkinter. When I bind a button's action I just do def callback(): print ...
-2
votes
0answers
42 views

API Wrappers: Should I return Objects or arrays? Or maybe there is no difference?

I have some 3rd party API that I'm building a wrapper around it. The API is "...a RESTful web API, to which you POST data to, the API response is an XML or JSON output." I wonder, should I return ...
3
votes
1answer
100 views

Is it pythonic to use properties to limit the mutability of class attributes (variables and methods)?

Some Explanation I'm somewhat new to python and to programming (I've been at it for a little over a year). I just recently discovered python properties, and I've been using them to limit the ...
2
votes
1answer
70 views

Difference between Python classes and Haskell typeclasses

I'm an intermediate Python dev and just starting out with Haskell. It seems like Python's classes can be used in a way that is similar to how Haskell's typeclasses are used. It seems like typeclasses ...
-1
votes
0answers
19 views

Backup directory with tar through tarfile module but with exclusion of some folder

I would ask if is possible in Python create an archive from a directory that I want backup excluding some sub-dirs. For example I would like create a tar backup of home dir without include the Music ...
5
votes
1answer
88 views

Is there such a thing as a workflow pattern? or how to do a workflow properly?

(and alternatives to a workflow engine) Problem: I have various inputs with various attributes. For example {name: john, country: US} and {name: Jose, country: MX} And I have the following workflows ...
-5
votes
1answer
77 views

Struggling with classes in python

I'm trying to understand how to use classes so that a user can interact with it. So in this example I want a player to type in their player name and have that saved as player_name. prompt = '> ' ...
0
votes
1answer
30 views

How to retrieve policy after DP?

I'm working on a simple resource allocation problem, that I'm solving using backward DP. The full code is at: http://codereview.stackexchange.com/questions/123641/allocating-a-resource It works fine, ...
1
vote
2answers
97 views

How to generate C++ code? (probably WITH (not FROM) Python) [closed]

For a scientific simulation I need to write some computations in C++. Since this became extremely tedious, I built myself a small code generator: In a scripting language (Python) you put together a ...
1
vote
0answers
46 views

Calculating the multiplicative inverse of a number in a Galois field

I was told to come here from Stack Overflow because I was "looking for an algorithm". I'm trying to implement it in Python, but there is nowhere on the net that gives a straightforward way for ...
-1
votes
0answers
17 views

Python: subprocess check_output giving large variable delays ranging from 7s-2min

#!/usr/bin/env python import subprocess import time end = time.time()+1 while (time.time() < end): y = subprocess.check_output(['sudo', 'cat', '/dev/ttyUSB0']) fh = ...
-5
votes
1answer
41 views

OPENPYXL tutorial / help with AVERAGE DICTIONARY

For my thesis I am trying to extract some data from Excel. I want to create a list with the name as in excel and then append the values to said list so I can work with it. EDIT I realize I ...
1
vote
2answers
87 views

How does the Python Runtime actually work?

I have some problems understanding the concept of a runtime library, especially the Python one. So I have written some a hello world python program and intend to execute it, so I write python ...
0
votes
1answer
38 views

python snippet optimization explanation

I'm attempting optimize and figure out why for input n a function I wrote f(n) appears to never finish executing when n > 26. TL;DR I need to figure out how to find the complexity of various python ...
1
vote
0answers
55 views

How to combine N non-comparable arrays up to an output limit in a fair way?

Given N non-comparable arrays of different sizes, what is the best method to combine them into one output array? Since the input arrays are non-comparable, a metric is needed to represent how ...
-1
votes
0answers
10 views

PyQt: How to dynamically call objectNames in a loop? [migrated]

I created 9 QPushButtons which objectName's are E1, E2, E3, ..., E9. Now, I want to update their text field with strings I get from a database, so I want to do something like this: ...
1
vote
2answers
53 views

Is python list comprehension using multi-threading or parallelized in any way by default?

When I write... l2 = [my_computation(x) for x in l] ..., I wonder if python is applying my_computation to every x using all cores of my CPU. If not, why ? Is there a simple way to make python ...
-2
votes
0answers
5 views

Making window size the same as canvas size in Python [migrated]

I'm drawing the Syrian flag with python's turtle thingy. Forget that I left out the two green stars for now, as they require an external dependency (oh wow, how's that for an accidental political pun? ...
0
votes
0answers
4 views

How to extract reviewer's ratings from Yelp. [migrated]

I am learning web scraping on my own and I am trying to scrap reviewer's ratings on Yelp as a practice. Typically, I can use CSS selector or XPath methods to select the contents I am interested in. ...
2
votes
0answers
91 views

How should I represent to-be binary data?

I'm writing some serialization code, and I'm wondering how to deal with binary data. As I'm doing it in Python, my goal is to make it very simple, not require a lot of programmer overhead, etc. Three ...
-2
votes
0answers
24 views

How to calculate the run time of my algorithm? [duplicate]

I'm trying to calculate the running time of my algorithm without the running time of the input and output of a file I tried timeit but it calculates the running time of inputting the file import ...
-2
votes
0answers
23 views

How can I combine masks on a masked array in Numpy? [migrated]

I want to create a mask for a numpy array by combining two masks using the masked_where methods. import numpy as np a = np.arange(10) #=> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) a = ...
0
votes
0answers
70 views

How do I replicate my object-ish style from Python into Golang?

I've been going around in circles on this for a while Googling and reading, time to ask experts. When coding my common approach is to create a type of thing and add it to some sort of list with ...
0
votes
0answers
41 views

Deciding on a Portable Platform (given a set of requirements)

Background Before asking this question, I researched this site and found the following 3 most similar questions have already been asked: When would using a scripting language within a larger program ...
3
votes
1answer
103 views

Avoiding tightly coupled class definitions in Python for has-a relationships

I have the following code: class Car(object): def __init__(self, my_id): self.my_id = my_id self.color = color self.brand = brand self.get_color() ...
1
vote
1answer
51 views

Python's __get/set/delattr__, ordinary assignment versus __setattr__, __dict__ vs dir()

I have a few more related OOP Python questions: What does these attributes do exactly: __get/set/delattr__? Why not use just Myclass.NewAttr = value instead of __setattr__? Why does Python use ...
1
vote
0answers
72 views

Why my greedy algorithm not working for merge stone problem

Merge Stone Problem: You have n piles of stones in a line. For example, [4, 1, 2] means 3 piles of stone, the first pile has 4 stones, the second pile has 1 stone, and so on. You task is to merge ...
1
vote
1answer
116 views

Questions on Python Attributes and dir()

I have two inter-related questions about attributes and dir(): What are attributes? Is it an object inside of another object? Or is it a method, property, etc? When you do dir(), what's the ...
9
votes
3answers
2k views

Ensure unsafe code is not used accidentally

Note: I do know eval() is dangerous and can usually be replaced by something safe. My goal is to learn rather than find a solution to an existing problem (Besides, I will be replacing completely the ...
1
vote
1answer
98 views

Is this the right way to use classes on this project?

Before any down voting or blaming, please bear in mind that this is my first "serious" Python project. Before this I have only coded a program that uses several Google API's to do stuff, and not much ...
0
votes
1answer
112 views

How to structure huge conditional statement?

I'm creating some kind of a "personal assistant" application which is basically a web service that receives a message and then does something according to it. For example I send "what time is it?" ...
4
votes
2answers
103 views

If I create a desktop application using Tkinter, PyGTK or PyGame does my app have to be open source?

I intent to start learning desktop gui programming, so I've been looking to Python and it's Tkinter, PyGTK and PyGame. But I want to make proprietary software, so I'm concerned because of the licences ...
0
votes
0answers
73 views

Class design of keyboard interpreter to execute commands

I'm designing a keyboard interpreter that will map typed characters to a (or many) command(s) via a hierarchical menu-style structure, taking into consideration testability (ideally TDD). However I'm ...
1
vote
0answers
67 views

Does PyPy or Jython run untrusted Python 3 code more secure while still being fast?

I know that one can not securely restrict normal CPython's capabilities to properly run foreign code without allowing it to access some builtins like open() or allowing other kinds of I/O. So I ...
3
votes
1answer
176 views

Etiquette: How to respond to a Open source release Mail? [closed]

So I was lucky to be able to contribute to DateUtil in python(just a small documentation). I recently received a mail regarding the release 2.5.0 . So I was all exited because it was the first time I ...