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

Literals versus instantiating by name lists and dicts in Python?

In Python, what is the difference in these declarations… my_list = [] my_list = list() …and in these? my_dict = {} my_dict = dict() Are they interpreted the same, and why would you use one over ...
0
votes
0answers
23 views

Algorithm for Multiple Choice Test Prep App

I'm working on app that helps students prepare for a specific exam. I have a database of 1000 questions, question categories, multiple choice options, hints and correct answers. Today, the app simply ...
0
votes
0answers
23 views

Place of a threading module in a MVP design pattern in Python

I am working on a GUI that displays images, 1 image or many (a video). Some processing is needed before displaying an image. Hence, I would like to do some threading in order to keep the GUI ...
0
votes
0answers
80 views

Am I right that anyone can use PyQt free of charge for commercial and closed source applications? [on hold]

This is a question about licensing mechanics of PyQt, GPL and optional Riverbank GPL Exception. The whole point of the question: Am I right that anyone can use PyQt free of charge for commercial and ...
-1
votes
0answers
46 views

Is it legal to distribute a Python commercial and closed source application together with QtPy or PyQtGraph linked to PySide? [on hold]

This question is a twin brother of the following question: Am I rigth that anyone can use PyQt free of charge for commercial and closed source applications?. But it still differs in important details. ...
-4
votes
0answers
31 views

Picking a random word in Python [on hold]

I have a tuple which contains three lists in python and I want the interpreter to pick a random word from each list to make a sentence. How do I do this? An example of what I'm saying is this: Tuple ...
0
votes
0answers
16 views

Difference between RAISE and RETURN HTTPResponse in bottle framwork

I am using Bottle framework to implement API's. There is code return before I started, and they use from bottle import HTTPResponse @api.get('/some/api/url') def some_method(...): ... ... ...
2
votes
2answers
67 views

How to retrieve policy after Dynamic Programming?

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, ...
0
votes
2answers
269 views

How to approach hours forecasting

I 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 I'll have the person submitting the ...
-3
votes
0answers
30 views

Use variable to slice string in Python [on hold]

I have what seems like a fairly simple question, but I have had no luck finding an answer to date. In Python 2.7, I generate a unique id and then want to slice the first x characters based on the ...
6
votes
2answers
224 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 ...
11
votes
1answer
15k views

Why use classes when programming a tkinter gui in python

I program primarily in python and have programmed a couple of GUI's with Tkinter, every tutorial I have ever seen has recommended defining and using a class for the GUI, but my GUI runs flawlessly ...
2
votes
2answers
44 views

Accomodating a LGPL Python module into a BSD project

I have a program written in Python that I would like to make available to the public under a three-clause BSD license. My program has an import blah statement, where blah is a Python module that is ...
0
votes
2answers
45 views

Modelling a REST Object Question (Python)

I have a REST API that I want to model in a class so I can access the properties using the dot notation (JS list notation). I explicately defined the properties on my class using the @property tags ...
3
votes
1answer
629 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 ...
-5
votes
0answers
33 views

PYTHON SyntaxError: Non-ASCII character '\xc3' [closed]

I have the following code, but when trying to compile I get Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main mod_name, _Error) File ...
5
votes
1answer
195 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: ...
1
vote
2answers
171 views

Python build system

Currently our Python application is deployed like this: Development team work on issues, commit code and create a Pull request Pull request is integrated to Development branch QA and Operations team ...
3
votes
1answer
42 views

Importing large data sets into a database over the web

I need to import 100,000 products from one database to another using the results from a RESTful API. But I can only do this overnight. So if I can't get the job done in one day, I need to spread it ...
0
votes
1answer
12 views

Shortest route between wikipedia articles in python

I have a python program which collects links from wikipedia, and stores the article names in one file, and the links between them in another. For the first file, every article name is stored, and ...
0
votes
1answer
42 views

Most Pythonic way to remove first match of potential leading strings?

This is a bit difficult to describe, but I'll do my best. In Python, I can use string.startswith(tuple) to test for multiple matches. But startswith only returns a boolean answer, whether or not it ...
5
votes
1answer
39 views

How do I scale up a bot/service?

I have this bot that I've created for Twitter. It's written in Python. It lives on my Raspberry Pi and I've set up a cronjob to run it every 60 seconds. Part 2 of the project is to build a web app ...
1
vote
1answer
73 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
vote
1answer
100 views

Is using __import__('module_name') an antipattern in Python?

I'm currently refactoring a Python 2 project which includes the ability to add or remove plugins, which are Python modules implementing a given API. The main app accesses add/remove/update hooks in ...
0
votes
2answers
484 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, ...
0
votes
0answers
39 views

Modeling a cookbook recipe with django

I'm trying to model recipes in a cookbook. Here's what I have so far: class Recipe(models.Model): title = models.CharField(max_length=255) class Ingredient(models.Model): class Meta: ...
-1
votes
0answers
17 views

Why are my tuple values changing (Python)? [migrated]

I have a tuple. The first element is a float and the second is a list with more nested lists containing floats (don't worry about what these values mean). (0.2742965753780876, [[[33.119], [-8.326]], ...
-1
votes
2answers
97 views

How to write code for different versions of linux

So, I've written some fairly big code for cent OS 7.1. The code essentially makes use of different command line tools by parsing the text output and shoving it in a database... pretty straight ...
0
votes
0answers
41 views

How and where should I put a version number in my Django project?

I'm making a Django project consisting of several apps and I want to use a version number for the whole project, which would be useful for tracking the status of the project between each time it comes ...
1
vote
1answer
39 views

Best structuring for IRC message decoding (Python)

I am writing a simple IRC chatbot in Python and, in an effort to get more into OOP, made a basic "connection" class that manages all the backing-and-forthing involved. But IRC protocol is rather ...
-3
votes
0answers
87 views

PyPy vs. Cython pure python mode vs. CPython for Django

Cython has a pure Python mode and PyPy is an implementation of Python with a JIT compiler. How do Cython, PyPy, or CPython compare for a Django application's speed if I use type annotations in 90% of ...
-1
votes
0answers
9 views

Can't install the “Boost” prerequisite for Caffe [migrated]

I'm getting into machine learning, and I recently happened upon this: Wide-Area Image Geolocalization with Aerial Reference Imagery . It's a net that predicts the GPS location of an image, from ...
1
vote
1answer
281 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) ...
-3
votes
1answer
76 views

Which license should I choose so I can open source my Botnet and not get sued?

I have been working on a Botnet for a high school project in Python and would like to open source it and share it on GitHub without getting sued. I need help with choosing a license such that I am ...
0
votes
0answers
34 views

Dynamic programming vs branch-and-bound for the knapsack problem

I have to implement a program that solves the 0-1 knapsack problem, where the weights and values of all items are nonnegative integers. We went over two methods in class: dynamic algorithms ...
1
vote
1answer
135 views

Is calling the superclass constructor in a subclass really important?

The following piece of Python code uses a superclass solely as the repository of functions that one of more subclasses may draw from: class Class(object): ''' A trivial repository for functions to be ...
-1
votes
0answers
54 views

How to decompose strings into a list of its spelling in an efficent way?

I have the problem where I'm taking as input a string, for example "table python desk" and I wish to decompose the string in terms of its spelling. So I want to output "t ta tab tabl table p py pyt ...
-2
votes
0answers
23 views

Trying To Make Second Window on Tkinter (code included)

New to programming in general and this is my first program. I want to be ablke to click one of the buttons to show a new window on the screen as well as carry the variable for PriceGrabber which is ...
6
votes
2answers
153 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 ...
-1
votes
1answer
75 views

Parsing a string with multiple levels of key value pairs

I need to write a part of the program which will work with a string, find in it some substrings and copy they to dictionary. Example of the string: thestring ='\ #: somethings\nchars0 ...
-2
votes
2answers
116 views

Are there coding standards for whether procedural programs should have source code listed top-down or bottom-up? [closed]

Let's say I have a basic procedural program which is well structured into decomposed functions. For example, a main() function which calls functions a and b, which in turn each call functions c and d, ...
3
votes
3answers
2k views

What is the most optimal algorithm for counting lines of text in a file?

File > 5Gb, simply with lines like apache access.log. Need to get number of lines. Any constructions like file(filename).read().counter('\n') Would read all of files and it would be very long ...
2
votes
2answers
71 views

Pattern for requests with long response times?

We are currently maintaining a homegrown python "web server" where generating the response for some requests can take a very long time mostly due to heavy computations - these requests are basically ...
41
votes
6answers
6k 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
1answer
75 views

In what way does programming help towards cyber security [closed]

I've been studying the cyber security field with great interest. I understand how networking can help cyber security but I am not sure how advanced programming knowledge can help fight cyber crime or ...
1
vote
0answers
48 views

Choosing Between Ruby and Python for a FS Microservice Backend in Node App [closed]

I have been working on a application that up until now has been pure Node. However I am concerned about performance and overhead since the application performs a lot of file system operations (Copy ...
-2
votes
1answer
122 views

Is this unprofessional when “Wappalyzer” sees all my technology? [closed]

After I installed "Wappalyzer", extension wich display technology, wich site using. I checked many sites and in most of cool projects, like "Youtube", "Github","stackoverflow" etc, wappalyzer display ...
4
votes
1answer
166 views

Refactoring of a client API for avoid duplicated code and unclear passage of parameters

I need to develop an API, the functions of the API are requests that call the service exposed by a server. Initially the API worked like this: class Server: def firstRequest(self, arg1, arg2): ...
2
votes
1answer
597 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, ...
8
votes
3answers
2k views

@staticmethod vs module-level function

This is not about @staticmethod and @classmethod! I know how staticmethod works. What I want to know is the proper use cases for @staticmethod vs. a module-level function. I've googled this ...