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)

-3
votes
1answer
34 views

Convert Python script to .exe?

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 ...
-8
votes
0answers
33 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.
-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 ...
-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 ...
-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 ...
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 ...
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
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
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 ...
3
votes
2answers
199 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 ...
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 ...
-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: ...
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 ...
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 ...
-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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
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 ...
-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 ...
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 ...
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
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 ...
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
50 views

Writing a container that treats nearly-identical images as the same

I want to create a mapping in Python that will use images as keys, but treat similar (but not identical) images as the same key. I have an approach for deciding which images are similar enough: I ...
1
vote
1answer
33 views

How to represent alternative and sequential tasks?

I am experimenting with hierarchical task planning (in python) and I would like to have functions which return lists of tasks. I need to differentiate between alternative paths and sequential tasks. ...
2
votes
1answer
202 views

Is there a better algorithm to distribute integer to X integers minimizing their difference?

Is there a better algorithm to distribute values from one source to X destinations minimizing their difference? I have some source integer. I need to know how much of that value I need to distribute ...
3
votes
1answer
107 views

Structuring a Python Project: Need some guidance

I currently am working on a project that involves several discrete components that have some common functionality, and I am in need of some advice. Right now I have a central component responsible ...
0
votes
1answer
40 views

Optional text qualifier in CSV file as input to SSIS package

I receive several CSV files each quarter to process through an SSIS package, and the formatting is inconsistent. This quarter, I encountered what I term optional text qualifiers--text qualifer of ...
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 ...
1
vote
2answers
103 views

Is there a better pattern than multiple inheritance here?

I'm working on a server implementation for a large game with many gametypes. There are several kinds of interactable entities: players, monsters, objects, vehicles. All entities share the same base ...
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 ...
2
votes
2answers
109 views

Final steps of wrapping up a Python script into a program

I finished building a Python script containing eight functions which download files, extracts them, manipulate and analyze their data and then produce graphs and export them into PNG files. The ...
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 = ...
-2
votes
1answer
32 views

Move file into apropriate directory based upon first letter of second word, followed by the first two letters of the second word with Python [closed]

EDIT: Apparently the below question is too specific. Let me rephrase: I'm looking for a way to fit a letter into a list of specified ranges such that, if given the letter S and the ranges A-F, G-M, ...
1
vote
1answer
73 views

When should I use a generator and when a list in Python? [duplicate]

I often find it cleaner to write a generator than to return a list. For example, I prefer def my_func_gen(foo): for i in foo: # Do some stuff that's too complicated for a list or ...
-1
votes
2answers
79 views

Will statically typed, compiled programming languages be affected by Microservices Architecture? [closed]

Judging based on my experience, as systems grow bigger, statically typed languages like Java or C# tend to be more reliable and easier to manage. But do we need all the advantages of such languages ...
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 ...
2
votes
1answer
43 views

Module level logger function

I've recently been assigned to a new project because I'm one of the only developers at my company who has used Python extensively in the past. My first task was to clean up the code base and make it ...
2
votes
2answers
94 views

Is the function using python list comprehension, stateless?

Below is the function count_leaf, that appends mutable list branch_counts, which is not stateless. def count_leaf(tree): if is_leaf(tree): return 1 branch_counts = list() for b in ...
1
vote
1answer
45 views

Is async keyword an ultimate replacement for asyncio module?

Recently, there was a rise of interest toward asynchronous programming in Python community. First prominent expression of this interest was the appearance of Asyncio —codenamed Tulip— framework [PEP ...