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
0answers
14 views

Connection Refused Error while trying to open Python Console in PyCharm

I am new to PyCharm/Python. Installed successfully PyCharm (Communities edition) on MAC ensured Python is installed and available (Version 2.7.11). Issue I am facing is when I am trying to open ...
-4
votes
0answers
37 views

python convert utf-8 characters to LaTeX ASCII

In order to solve my problem http://tex.stackexchange.com/q/316802/108917 I implemented after http://stackoverflow.com/a/13089420/5195446 my code below #!`#!/usr/bin/pythonw # -*- coding: utf-8 -*- ...
0
votes
1answer
33 views

Web app with a Node.js front end interefacing with a python script with sockets

Right now I have a webpage with various buttons and options that I'd like to use to send commands to a python script running on the webserver. The python script is being used to interface with devices ...
-6
votes
0answers
47 views

What programs are there to use with Python? [on hold]

I know codeblocks and codelite are for C and C++ programming but what is out there for Python users? I would prefer something free at the moment since I am a newcomer to Python.
1
vote
1answer
137 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 ...
0
votes
1answer
25 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,...
0
votes
2answers
79 views

Why python doesn't provide optional types?

I've recently used typescript, and I think the ability to mention or not types is great. It greatly reduces the debugging time while also giving you the advantages of an untyped language. I could ...
0
votes
0answers
40 views

Download latest Excel files from a website regularly

First, I'll try and describe my problem, then I'll explain how I am trying to get around it. Problem: I regularly download excel files from the internet, this occurs every three months. There's a ...
2
votes
2answers
75 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
299 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
12 views

Syntax error at second definition in Python [migrated]

def specificChecker(someThing, checker): if checker == None: return someThing elif checker == True: return not someThing else: return None def ...
-2
votes
0answers
42 views

multiprocessing in Python does not work the way I thought

The project is about comparing strings from a large text file, I wrote a for loop to do the comparison, this part was done without any problem. In order to increase efficiency, our professor asks us ...
57
votes
7answers
57k views

'import module' vs. 'from module import function'

I have always been using this method: from sys import argv and use argv with just argv. But there is a convention of using this: import sys and using the argv by sys.argv The second method ...
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 ...
-2
votes
0answers
59 views

Python web crawler [closed]

I wrote a python web crawler #!/usr/bin/python import threading import urllib import Queue from bs4 import BeautifulSoup import sys import time import signal visited_urls = [] crawl_lock = ...
0
votes
2answers
56 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
647 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 ...
1
vote
1answer
45 views

How do I organize my project to accomodate GIT pull requests for source installed via PIP?

I want to structure my Python project in a manner such that others can use a package manager (PIP) to easily clone the environment for team development, and GIT to contribute to the project, plus a ...
5
votes
1answer
223 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/...
5
votes
3answers
82 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
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 ...
5
votes
2answers
6k views

How to hide the python code from users?

I am developing a paid application in python. I do not want the users to see the source code or decompile it. How can I accomplish this task to hiding the source code from the user but running the ...
-1
votes
0answers
22 views

problem re-associating .py from Python26 to 27 on Windows 7

I needed to re-associate python .py file from Python26 to Python27 on Windows7. New association now works but at first when I ran test python script it failed. I had to re-run same script 3 or 4 times ...
1
vote
1answer
52 views

When to have a generic method for multiple tasks when some differ?

I process a lot of tweets in real time using python and for each tweet I need to assign it in to a specific bucket. I have about 50 buckets, each with their own rules. The majority of them are simple ...
0
votes
1answer
98 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 ...
-3
votes
0answers
23 views

logging another device using exscript PYTHON from already logged into device

I am using Python's Exscript module to log onto network device (Juniper/Cisco), once in I fetch vrf details and use same to log onto another device which is basically a SWITCH. I am stuck how to I ...
0
votes
0answers
34 views

Why do I get a memory error using .next()? [migrated]

I'm trying to parse a text file in python 2.7. The file has has around 10^11 lines so I can't load it into memory. This works just fine: with open('file_name.txt') as f: for row in f: ...
11
votes
1answer
16k 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 ...
1
vote
1answer
304 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
0answers
86 views

How random are these numbers?

I am making a script for creating true random numbers. I use APIs from RANDOM.ORG and ANU QRNG. The method I have is I get a number from one of the sites and use it as a seed in the Mersenne Twister ...
4
votes
3answers
405 views

What is the preferred way of communicating between applications on the same system?

I'm designing a system that is built on several small applications written in python, some of these will be services and others will be programs that only run during special situations. What I need to ...
3
votes
2answers
218 views

What makes a scientific programming language, scientific?

Why are some programming languages such as Python or Julia considered to be "scientific" programming languages? I guess my real question what is the criteria that makes a programming language ...
0
votes
1answer
42 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? ...
-1
votes
0answers
27 views

Python public package development environments

I have a package on my computer I use for personal, general use code. I build it with python setup.py develop --user which works very well for making changes to the code and it taking effect without ...
1
vote
4answers
479 views

Why use a higher level language? [closed]

A question that gets asked a lot is "Why use low level languages if you can code in high level languages more easily (and often tersely)?". I think the answers are fairly straight forward here, being ...
19
votes
5answers
9k views

Best practices for execution of untrusted code

I have a project where I need to allow users to run arbitrary, untrusted python code (a bit like this) against my server. I'm fairly new to python and I'd like to avoid making any mistakes that ...
1
vote
0answers
47 views

Facebook Login vs Python Social Auth (or django-allauth, etc.)

Background: I'm creating a mobile app using an API built with Django using Django REST Framework and hosted on Heroku. In the past, I've used Python Social Auth with this setup to authenticate users ...
3
votes
3answers
131 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 ...
-2
votes
0answers
44 views

What are Python .pyc files and how can one use them in django project and is there any way to open them? [closed]

.pyc contain Python bytecode for .py file(Please make a correction if i am wrong here). I have gone through this link.. < http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html>
1
vote
1answer
42 views

Editing Python libraries

I have been using python for a fairly long time and now I want to modify a python library to fit my needs. There are two ways to do this as far as I know. One is to modify the source code itself. ...
2
votes
2answers
528 views

What was the need of introducing Python 3 when we already had Python 2 [duplicate]

I am still learning python and I started with Python 3. This question not Python 2 vs 3 or difference between them like print() is a function and not language construct and 3/2 = 1.5 My question is ...
9
votes
1answer
165 views

Unit testing for data munging pipelines made up of one-line functions

Reading Mary Rose Cook's Practical Introduction to Functional Programming, she give as an example of an anti-pattern def format_bands(bands): for band in bands: band['country'] = 'Canada' ...
-1
votes
0answers
25 views

How to set the limits on a color bar - python Mayavi?

I am using Mayavi to create 3D visualizations of data I am producing with another code. Eventually, I would like to be able to string together all the images created with Mayavi to produce a movie. I ...
4
votes
1answer
182 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
607 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, ...
0
votes
0answers
31 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 ...