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
1answer
38 views

Convert Python script to .exe? [on hold]

I've done some researching, but all I know is that I have Python 3.4, Windows, and the desire to run python programs on computers without python installed. In my searches, I found out about pip, but I ...
3
votes
2answers
202 views

Why does Python's math.ceil return a float?

While I understand that the difference between integral and long values is blurred in Python, the difference between floats and integral values is not. Therefore, I'm having a difficult time ...
-8
votes
0answers
34 views

can i write a software (windows application) and make it work on another windows application [on hold]

can i write a software (windows application) and make it work on another windows application. i mean i have a system (windows application) it has a shell command line. and i want to write ...
-2
votes
0answers
19 views

Stripping one set of arrays and replacing quotes [on hold]

How could I take: s = [[0,0,0,0],[0,0,0,1]] and change it to: s = ["0,0,0,0","0,0,0,1"] Don't really mind how elegant it is.
0
votes
1answer
281 views

What is the convention regarding class names that may already exist in the ORM? [on hold]

This is a generic question about class names and ORMs, but for context; I'm working on a Flask web app in Python using SQLalchemy. I'm struggling with naming a new class that will contain the ...
-2
votes
0answers
10 views

Python MySQLdb Install [on hold]

I'm using MySQL Workbench 6.3 and trying to write some code to import many csv files into my table. I'm trying to follow the coding around using MySQLdb and I keep getting an error about the module ...
3
votes
1answer
79 views

Best practices for a daemon that forks and becomes user

I want to write a small daemon in python under Linux that accepts connections and authenticates the user (details for this don't matter) and then forks a child for the connection and becomes the user. ...
-1
votes
0answers
24 views

Best practice to lock write to resource [on hold]

I'm writing a little Python script that do some writes on files. I want to exclude the possibilities that the execution of two instances of the same script will write on the same resource. So I'm ...
0
votes
1answer
77 views

Should I put the parameters in constructor or in method? (Python 3)

I have the following code: def __init__(self, vocable_file_path, xsd_file_path, word_list_file_path): self.vocable_file_path = vocable_file_path self.xsd_file_path = xsd_file_path ...
2
votes
1answer
384 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
0answers
17 views

Using regular expressions in Python to parse LaTeX code [migrated]

I am trying to write a Python script to tidy up my LaTeX code. I would like to find instances in which an environment is started, but there are non-whitespace characters after the declaration before ...
6
votes
1answer
145 views

Is **kwargs an antipattern?

We have a lot of code in our internal codebase that calls our libraries internally - these libraries often have a lot of arguments (think matplotlib) and our code is often doing only a specific task ...
0
votes
2answers
150 views

Ensuring program output is always the same [on hold]

I am working on a +10k LOC program, and I need to ensure its output is always the same for given input. The program consists of dozens of modules and classes, inherited by a MainClass. Initially I ...
-2
votes
0answers
98 views

How are these symbols `` named? I want to know what's their meaning in Python [closed]

After years of programming in Python, I've just accidentally found that these symbols (I don't even know how to name them) can be used to evaluate an expression and convert it to str. For example: ...
0
votes
0answers
15 views

Reusing models and classes with blueprints with flask

Designing a content management system using Python/Flask. I have a blueprint module called pages [app/pages/..]. Pages contains the title, description and content. It can be queried using ...
0
votes
0answers
13 views

How much additional specialised functionality should I bundle with my main flask application?

I am building a custom content management system (i.e. html, some js) for a project using Flask/Python. As things have progressed, I have seen that I need to add: Some AJAX for interactivity. ...
1
vote
1answer
65 views

Multiple different versions of similar apps in one project

I need some help to improve the architecture of a site I've built. What I want to achieve within a single Django project is the following: I want a site that comes in several versions (one per ...
1
vote
2answers
103 views

Is it considered good practice to use mutables this way? [closed]

Lately I came across a way of using mutables which I had not thought of before. Let's say you have a list comprehension which calls a method, and you put the result in a list like the following ...
0
votes
0answers
22 views

Why does this code take up so much memory? [migrated]

I created a solution to this problem on leetcode: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes ...
15
votes
7answers
6k views

Would Python be too slow for client-side use in Browsers?

I've heard the statement that Python would be too slow to be of any use in browsers. I reckon Javascript is only superior in this aspect because of companies like Google who need it fast (and made it ...
6
votes
1answer
136 views

UI Design patterns for non-screen based project

I'm working on a small project coded in Python that uses a single button for input and a RGB LED as feedback, which responds to button presses and asynchronous events from the network. As the ...
0
votes
1answer
86 views

Programming to multiple backends

My current project is a high-level abstraction package for GPIO programming on those nifty little SoC-Computers (Raspberry Pi, Cubieboard, Beaglebone Black, Pandaboard etc.). One of my goals is to ...
3
votes
0answers
105 views

Why 'x += y' is not always the same as 'x = x + y' in Python (2.7)? [migrated]

I always assumed that x += y was just a shortcut for x = x + y But it seems that's not the case for lists: x = [] x2 = x print x is x2 True x += [2] print x is x2 True x = x + [2] print ...
0
votes
1answer
87 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) ...
1
vote
1answer
81 views

Is Python's calendar.month_name implementation of an empty string in the first index good practice or poor design?

The documentation states: An array that represents the months of the year in the current locale. This follows normal convention of January being month number 1, so it has a length of 13 and ...
4
votes
2answers
119 views

Extract name of return variable from Python function

I have a python function x that returns some module x(): return y I would like to parse the file x is located in and learn that "x returns this thing called 'y'". I have no idea how. I'm not trying ...
4
votes
3answers
1k 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. As you know, Django app contains two main directories for front-end: /static - for ...
-3
votes
0answers
13 views

How do I iterate through cell values of an .xlsx using xlrd in python? [migrated]

I am trying to iterate through individual cells from an xlsx document in python using xlrd. I am running Python 2.7.6. My script so far contains the following: import xlrd book = ...
2
votes
1answer
41 views

Should I be taking these as arguments or define them in a sub class?

So I am making a mario clone in pygame and I have a base class Character and two sub classes, Mario and Luigi. The methods that the Character class defines require a significant amount of attributes ...
3
votes
0answers
197 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 ...
1
vote
0answers
20 views

How can I improve my websocket server's structure/flow?

I'm building a websocket server in python and I've hit a block regarding my program's flow and structure. Here's what I'm doing at the moment. The program creates a instance of 'server' and listens ...
2
votes
1answer
83 views

Patterns for sharing context variables between functions

I am looking for ways of passing around a set of contextual variables that are required by functions. As a Python programmer, right now I can see three ways of solving the problem: passing them ...
7
votes
2answers
3k views

Why does Python use hash table to implement dict, but not Red-Black Tree? [closed]

Why does Python use hash table to implement dict, but not Red-Black Tree? What is the key? Performance?
0
votes
1answer
33 views

Ways of embedding static data with python application

I have several projects on Python I am currently versioning with Git. I also have the input-output data that is gradually changing over the course of the project. I need to be able to re-run my ...
1
vote
2answers
77 views

Factored out loop control in Python

I have a for loop in python like this: for item in items: onwards = make_flow_decision(item) if onwards == 'break': break elif onwards == 'continue': continue elif ...
0
votes
1answer
75 views

Can I listen on a port without interrupting traffic?

I have developed the bare bones on a socket server in Python. I'm trying to capture the HTTP packets going to a web server without blocking them. try: self.socket = ...
1
vote
0answers
47 views

Logical Structure of PyQt or PySide application that conforms to reusability

I am making a PyQt application that has a QDialog UI as main widget that contains QTabWidget. This QTabWidget has two tabs, each tabs sits in a source folder under _widget. My goal is to build a ...
0
votes
1answer
224 views

Best strategy for converting change in longitude and latitude to north, south, east, west in degrees

This is not a class assignment but a conceptual question I'm struggling with for a personal project. I need to convert a large paired group of long and lat coordinate values that show a ...
0
votes
1answer
61 views

How to properly handle indefinite generators in Python

Let's say we have a generator that is indefinite, where new elements can arrive at any moment with significant (up to indefinite) delay. An example of such generator is tail -F command. In python ...
0
votes
2answers
115 views

How should I structure these Python classes?

Base Class I have a class called Remote. This class represents a remote machine and has properties such as ip, hostname, username, and password, as well as methods for transferring files to/from the ...
5
votes
2answers
129 views

Is the benefit of the IO monad pattern for handling side effects purely academic?

Sorry for yet another FP + side effects question, but I couldn't find an existing one which quite answered this for me. My (limited) understanding of functional programming is that state/side effects ...
3
votes
2answers
187 views

Python classes with only one instance: When to create a (single) class instance and when to work with the class instead?

Given a Python class which will be instantiated only once, i.e. there will be only one object of the class. I was wondering in which cases it makes sense to create a single class instance instead of ...
0
votes
0answers
43 views

Is there an algorithm to avoid getting in hundreds of datapoints from API to represent a bar graph?

I am showing a graph on HTML5 canvas using the flot charting library for a between a start date and an end date. It's fine as long as the period is less than a year or so but if the user selects a big ...
0
votes
1answer
153 views

Setting up folders and importing modules in Python

I'm building an app to automate some processes that are annoying to do by hand (looking in a file, taking certain information out of a file, building another file with that information). My project ...
-3
votes
0answers
16 views

Script Execution Proccess not doing what it should be doing in theory? [migrated]

Forgive me for the beginner question, but here I have a Python 2.7.10 Script that I wrote which does not execute as I expected it to: frReq=int(raw_input("Friends?")) friends=[] for i in ...
3
votes
3answers
478 views

Is this OOP class hierarchy too deep?

So I am making a Super Mario Bros NES clone in pygame and for all enemies that are drawn to the window, I have a class hierarchy that is 5 classes deep. Going in the order of: Object (A base class ...
0
votes
0answers
19 views

Writing a Python class that provides default instance succinctly [migrated]

I have a Python class for which I'm often going to want an instance with the default arguments, but I want the class to allow creation of instances. For brevity I'd prefer that the default instance be ...
2
votes
2answers
252 views

Which programming idiom to choose for this open source library? [closed]

Which programming idiom is easier to use for beginner developers writing concrete file parsing classes? I'm developing an open source library, which one of the main functionality is to parse plain ...
1
vote
2answers
161 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
178 views

Could there be a use case for C# style auto-properties in Python

I've been doing a lot of work in C# recently (my primary language is Python) and I love that I can do something like public string MyProperty{ get; set; } Going back to Python I miss that sort of ...