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
159 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 ...
-2
votes
2answers
120 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, ...
-1
votes
1answer
78 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 "substr0"\...
-2
votes
1answer
82 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
52 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
134 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 ...
0
votes
0answers
46 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
97 views

python: detecting if my method is called with 0 or 1 args

I want to write a suite of methods that act as getters when passed zero arguments and as setters when passed a single argument. I have two two reasonable implementations, shown below. Is one better ...
4
votes
1answer
65 views

Common imports between many scripts in Python project

I'm writing an automated installation script for a bunch of software, in Python. The purpose is for the script to fetch compressed files from a directory and install/configure each utility or ...
2
votes
2answers
50 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 ...
1
vote
0answers
30 views

How would I identify a gap in a set of curve data, and get its value?

I have a set of 2-D data (x,y) and it produces a set of curves, and sometimes the set of curves do not overlap, and there is a distinct separation between the groups of curves, how would I identify ...
0
votes
1answer
110 views

Is there any simpler way to check the strong level of password?

So i found out this following code used to check the strong level of password. I was kind of confused about the part: score = len([x for x in password_strength.values() if x]) I know that it was used ...
1
vote
1answer
40 views

Pyinstaller EXEs license

I'd like to know about licenses in Python program distributions. This is the scenario: let's say one would distribute a Python program for Windows, created with PyInstaller as a single executable file,...
-3
votes
1answer
121 views

Returning a variable or a return code from a function

Let assume that we have a main() function in which we call a createDirectory() function. In Python for instance, the code would be: def main(): # Do some stuff createDirectory(myPath) # ...
-3
votes
1answer
79 views

When I am doing a GET request to any website, how do I prevent that website from seeing my IP address? [closed]

I'm new with programming. I was wondering if, when I am doing a GET request to any website from my python application, they will see my IP in their logs. And if so, will enabling a VPN be able to ...
0
votes
2answers
55 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 ...
6
votes
4answers
244 views

Is using nested function calls a bad thing?

In a recent homework assignment I ended up calling my functions in an ugly way uglyReceipt(cashParser(cashInput())) the program itself worked perfectly but I still felt like I was doing something ...
4
votes
3answers
115 views

Microservices and shared libraries

We are designing a system based on independent microservices (connected via a RabbitMq bus). The code will (for the first components at least) be written in python (both python2 and python3). We have ...
0
votes
1answer
16 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 ...
1
vote
1answer
83 views

Cross-platform unicode support for Python command line tool

I am working on a large command line tool, written for Python 2.6+ and supported for Windows, OS X and Linux. The target users are developers but it is also being auto-invoked by CI-systems etc. In ...
0
votes
2answers
78 views

Why is the _replace method of Python namedtuple classes protected?

In the section Method Names and Instance Variables, the Python Style Guide (aka PEP 0008) says, "Use one leading underscore only for non-public methods and instance variables." Why then, does the ...
-2
votes
2answers
80 views

When using an if statement with or in Python, is there a way to identify which variable exactly triggered the statement?

If I have something like this: var1 = input("Enter a number lower than or equal to 100") var2 = input("Enter a number greater than or equal to 1.") if var1 > 100 or var2 < 1: print("Wrong.")...
2
votes
1answer
92 views

Roadmap to create a scientific computing website [closed]

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 ...
1
vote
1answer
64 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
12 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
216 views

Why Variables in Python Are Different from Other Programming Languages? [closed]

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
1answer
83 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 ...
1
vote
2answers
78 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
51 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 ...
6
votes
2answers
389 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 "...
3
votes
1answer
140 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
95 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 ...
6
votes
2answers
154 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
90 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 = '> ' ...
2
votes
2answers
74 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, ...
1
vote
2answers
146 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
53 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 ...
-5
votes
1answer
115 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
121 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
42 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
1answer
78 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
2answers
97 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
94 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 ...
0
votes
0answers
96 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
48 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
115 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() self....
1
vote
1answer
76 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
82 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
128 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 ...