Python is a dynamically typed, high-level interpreted programming 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 and exceptions, and has an extensive standard module library. ...

learn more… | top users | synonyms (1)

-4
votes
0answers
24 views

pycharm is warning me that it cant read an abstractpropery [on hold]

I have the following Python 2 script, which runs as expected, but gives two warnings in the PyCharm IDE. May I ignore them? #!/usr/bin/env python2 # coding=UTF-8 import random,logging from abc import ...
0
votes
0answers
20 views

Is there a cross-platform way to execute a Python3 script fullscreen?

I'm currently developing a small CLI game in Python for practice. While I can set the shell width and height quite easily, there are lots of different screen sizes in use right now, and I would like ...
-1
votes
0answers
27 views

Do I have to learn some actual Python to use Tkinter

I am learning Python to build some Desktop Applications. I am wondering if I have to learn most of Python before using Tkinter with Python for GUI based applications.
0
votes
3answers
201 views

When NOT to use a class / member variable?

I am trying to learn WHEN NOT to use: classes member variables HERE IS THE CODE access_point_detection_classes.py from scapy.all import * class Handler : def __init__(self) : ...
0
votes
2answers
47 views

Object Oriented Python methods and their parameters

Let's say I have a class MyClass ... which has a data member x class MyClass1 : def __init__(self) : self.x = 1 Also a method which does something with x Should I pass self.x as a ...
-4
votes
0answers
25 views

Objects and Classes in Python [on hold]

Can anyone: 1. Define what an object is in programming and python. 2. What is class in programming 3. Give an example of an object in python 4. Give an example of class in python I can't seem to ...
-2
votes
1answer
56 views

Do .pyc files in Python contain mnemonics

I'm interested for some time in CPython implementation of Python. I understand that .pyc files contain serialized bytecode, including opcodes. However do these files contain mnemonics? I think that ...
2
votes
2answers
82 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, ...
-2
votes
0answers
20 views

Minimum value of a node in a binary search tree

I am making a program that returns the minimum value of a binary search tree recursively and I don't know how to implement it. I am stucked here, please help def bst_min(t): if t.is_leaf == True: ...
6
votes
2answers
10k views

How to deal with database connections in a Python library module

I have created a library in Python that contains functions for accessing a database. This is a wrapper library around a third party application database, written due to the fact that the third party ...
1
vote
3answers
332 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 ...
-1
votes
0answers
40 views

Big web application on python [on hold]

I am experienced PHP developer. I am pretty familiar with tools in this language. I know, that for big complex application I'd use symfony or zend framework. On the other hand, for some kind of REST-...
0
votes
0answers
36 views

Inaccurate fractional exponentiation / accurate fractional exponentiation in Python? [duplicate]

In Python, 9 ** 3 obviously is 729; why is 729 ** (1 / 3) 8.999999999999998? 9 == 8.999999999999998 gives False. Is this problem solvable?
0
votes
1answer
49 views

Is there a way to control a looping Python script with Heroku?

I have a Python script that continuously makes GET and POST requests to a third-party API at about 1 request per second. It uses a while loop, so the requests all come from the same process. Currently,...
1
vote
1answer
104 views

Should I use this very short Python Quicksort implementation?

def quicksort(N): if len(N) < 2: return N else: less = quicksort([number for number in N[1:] if number < N[0]]) more = quicksort([number for number in N[1:] if ...
-2
votes
0answers
19 views

Need some help with making Selenium to click on a button [Python] [closed]

<input class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." ...
0
votes
0answers
16 views

Developing Python Scripting API using Petrel Ocean SDK (C#/.NET)

I use a commercial software called Petrel. Petrel has a software development kit (SDK) that allows the user to develop plugins in C#/.NET via the Ocean core API. At our offices, we have installed a ...
-2
votes
2answers
36 views

Using Python to start up multiple programs simultaneously

I am attempting to write a python script that with remove some of the tedium of my everyday actions. Specifically, I always need to run Eclipse, Java VisualVM, and a docker container. I had planned ...
2
votes
2answers
60 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
69 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
672 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 ...
-2
votes
0answers
36 views

Requesting feedback on my python code: [closed]

I'm a teacher in a school which is offering computer science next year. I'm relatively new to the subject myself and currently in the process of up skilling . I have written a program in pythons which ...
-3
votes
0answers
48 views

Develop a python project from 2 different operating systems on the same machine? [closed]

Can I work on a python project from 2 different operating systems on the same machine? I have a python 2.7 project I am developing with a virtualenv that lives on my HDD (with win7) that I have as a ...
5
votes
1answer
255 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: http://github.com/mitsuhiko/...
0
votes
0answers
30 views

Store as much code as possible in single folder to allow easier upgrading

I have a rather large Python code with a structure that looks like this: my_code.py +-- packages/ |-- __init__.py +-- pack1/ |-- modu_11.py |-- modu_12.py +-- ...
5
votes
3answers
124 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 ...
2
votes
5answers
71 views

How do I systematically evaluate the performance of my Python script?

How do I know if my code is running fast enough? Is there a measurable way to test the speed & performance of my code? For example, I have script that is reading CSV files and writing new CSV ...
4
votes
1answer
47 views

How to redistribute modified code under PSF license

I spent a few hours cleaning up a really old Python library, ProxyTypes. Two days from now will mark 10 years since it was updated. Today, I updated it to support the newer Python 3, and to be ...
0
votes
2answers
76 views

Building a personal C/Python library to replace Matlab [closed]

I am considering to switch from Matlab to Python/C++ for research work. The objective is to create an environment similar to Matlab for rapid prototyping. Python is slow even with numpy and schipy. ...
7
votes
2answers
797 views

What is the relationship between scope and namespaces in Python?

In many resources I found "scope" and "namespaces" are used interchangeably, which seems a bit confusing since they mean different things. Scope defines the region of the code where a name is ...
1
vote
1answer
82 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
13 views

Application made in python and compiled with py2exe didn't work [migrated]

I made a python 2.7 program in PyCharm called Intelligent Timer. It is working and showing the stopwatch Changing time in both PyCharm and python IDLE. But when I converted it to .exe file using ...
-4
votes
0answers
60 views

Extensible python project layout

I am developing a bot for a game I'm playing and i am having quite a debate as how should i structure my code. I designed my bot to be extensible, everyone can develop a module to farm something the ...
1
vote
1answer
90 views

Making a member function treat two objects differently in Python

I have in my program a class with a member function that should treat certain objects slightly differently than others. In order to do this, it needs to know which object was passed to it, because ...
-4
votes
1answer
33 views

How do I get python to recognize my DLL file as import(able)

I ran into an error stating: "ImportError: No module named 'pywintypes'", and after some reading around, I have discovered that the DLL for pywintypes is in C:\Python35-32\Lib\site-packages\...
2
votes
1answer
31 views

Variables (scalars and matrices) assignment in Python

Here are the two cases under consideration. (a)Scalars and (b) Numpy matrices. My query is about initialization and assignment. 1 Perfect y = x = 0; x = 7 print(x,y) y = 8 print(x,y) x=10 ...
4
votes
1answer
51 views

Reraising exception explicitly or passing it on?

This question is about coding style. Say I have a function, f. f depends on a condition C. It calls another function g as a subroutine. g also depends on condition C. If it finds condition C is not ...
2
votes
2answers
188 views

`var is None` vs `var == None`

I often see var is None in Python code, using is to test equality only works for a very few objects like None. I used to think that it's better practice to use == to compare equality even if is is ...
1
vote
1answer
326 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) ...
0
votes
1answer
52 views

Should I always use prefix private methods with an underscore in Python?

Prefixing methods and members with an underscore indicates internal use. For simple classes, I sometimes find the easier reading and typing of self.foo outweighing the indent of self._foo. Especially ...
1
vote
0answers
38 views

Optimal Simplification of Transposition Products

I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil ...
23
votes
2answers
672 views

What semantic features of Python (and other dynamic languages) contribute to its slowness?

I don't know very well Python. I'm trying to understand more precisely what exact features of dynamic languages (à la Python, Lua, Scheme, Perl, Ruby, ....) are forcing their implementations to be ...
0
votes
1answer
72 views

Designing a RESTful API for a file manager

I am building a file manager web UI (front end ReactJS, back end Flask). RESTful API seems to be very suitable in this situation at first sight, but I get into trouble. I need API contain: List ...
-4
votes
3answers
412 views

Why different languages have different syntax? [duplicate]

Different programming language always/most of the time use different syntax. For example take PHP, Java and Python. In Php & Java semicolons are compulsory at the end of the line, yet Python ...
1
vote
1answer
63 views

How can I integrate Python into an OSX program?

I'm very comfortable with Swift, Obj-C, and Javascript but for a new project I need to use a library that is only available in Python. How do I integrate python or python scripts into an OSX project? ...
0
votes
3answers
91 views

Can I easily paralellize this script?

I have a script that compares in some way each line from file1 and file2, and outputs the lines if there is a difference. I want to make it faster - right now it's in Python. I could use threads, but ...
0
votes
1answer
50 views

How to distinguish the two types of Python “packages”

In the Python ecosystem, there are two related but distinct concepts called "package": A "dotted module name", represented in its source as a directory with an __init__ module (i.e. an __init__.py ...
0
votes
0answers
38 views

Abstracting remote API efficiently in Python

I have to replace SQLAlchemy "table" (declarative) class with mostly functionally equivalent wrapper, which will use API of another microservice. All the usages can be edited, so there is no need to ...
1
vote
1answer
22 views

Python Base class for instantiating API query module

So I am writing a datamodel in python that interacts with an python module that queries the api. class QueryAPI(): def __init__(self, clientid, clientsecret): self.clientid = clientid ...
2
votes
1answer
160 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 ...