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)

-4
votes
0answers
16 views

Travis CI + GIT HUB + BEHAVE + PYTHON - What is the command to run behave scripts in .travis.yaml file. Please give me few examples [on hold]

I am using Behave automation tool with python and GitHUB and Travis. Could anyone please let me know how to run the behave scripts in .travis.yaml file? I tried many options for this specific setup ...
0
votes
0answers
20 views

How can I make a Python deserialization function useable from another module? [migrated]

I have some serialization and deserialization code which works well within one module (and within the universe of classes I care about). E.g. class A(...): ... class B(...): ... def ...
0
votes
0answers
49 views

Python Micro-services Architecture

I have a Python-Flask webapp that stores data in MongoDB using an ORM. I want to extend this app and add a Apache Storm based micro-service that will require read & write access to dbs of the ...
1
vote
1answer
59 views

Python file naming convention?

I've seen this part of PEP-8 https://www.python.org/dev/peps/pep-0008/#package-and-module-names I'm not clear on whether this refers to the file name of a module/class/package. If I had one example ...
0
votes
0answers
37 views

Trying to understand architecture of my project [closed]

I'm embarking on a project and I'd like to get some feedback on how I plan to implement it. I have a number of IP addresses with vulnerabilities attached to them (CVE IDs). This is in the form of a ...
2
votes
1answer
65 views

Does exception handling belong at the lowest level of the runtime?

I'm designing a fairly simplistic stack-based programming language, and implementing it in Python. (no link, because it's not fully implemented yet.) The language itself is essentially intended to be ...
0
votes
0answers
20 views

How can word lists be used as supervised data in finding the score of the report?

We have got historical reports and we need to find the score (whether report is effective or useful or not) based on supervised learning. While doing the supervised learning process, we have to ...
1
vote
2answers
50 views

Should I include scripts inside a Python package?

In my Python application, I can distinguish between entry points (scripts) and what I think of as library code. My instinct is to put the library code inside a package, and the scripts elsewhere ...
1
vote
4answers
172 views

Handling exceptions I don't know about

When I work with handling exceptions, I notice that I often have to deal with the ones I had no idea about. Especially it is noticeable when I program a method that grabs data from web. An error may ...
0
votes
2answers
159 views

Why is Python 3.4 still developed after the release of 3.5? [closed]

The lastest version of Python is 3.5.1. However, the latest release is 3.4.4. Why is 3.4.x still developed? Are there breaking changes in 3.5 with respect to 3.4? https://www.python.org/downloads/
0
votes
2answers
105 views

How to approach hours forecasting

I have a django web app and I basically 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 ...
0
votes
1answer
54 views

Developing an app using Django. Do I design front-end after app? Or develop Django to fit UI? [duplicate]

Edit: this differs from a similar question because I'm interested specifically in how Django works with the front-end. I.e. what is considered best practice when developing using the Django framework. ...
1
vote
0answers
26 views

How do I minimize the number of database queries in a GeoJson API (of countries, and smaller areas) with custom data?

The general version of the question is above - a a little more detail, I am using Django Rest Framework, but am happy for answers to be dealing with the problem in abstract. So, I have data with ~200 ...
2
votes
1answer
57 views

Passing in objects to __init__ or passing a common param to and constructing objects inside __init__?

I have a class Foo that creates instances of other classes A, B, and C in its constructor. A, B, and C share the same constructor parameter and are used in other parts of the codebase, not just in ...
0
votes
1answer
73 views

How can you catch all index out of range errors in python?

Our program does these kinds of operations hundreds of times for many different variables and lists, then uses them throughout the program: variable = values[5] The list values are coming from the ...
2
votes
0answers
57 views

How to find related articles among a set of articles?

I'm utilising OpenCalais API to tag the articles from multiple news sources. I know which category each article belongs to (e.g. crime, politics etc). Also each article has three social tags ...
0
votes
0answers
3 views

Subprocess writing stdin and reading stdout python 3.4 [migrated]

I am writing a script which would run a Linux command and write a string (up to EOL) to stdin and read a string (until EOL) from stdout. The easiest illustration would be cat - command: ...
22
votes
1answer
2k views

Why does the documentation on some languages say “equivalent to” rather than “is”?

Why does the documentation on some languages say "equivalent to" rather than "is"? For example, the Python Docs say itertools.chain(*iterables) ... Equivalent to: def ...
0
votes
0answers
5 views

Why trunc(4.9999999999999999) ==5, but trunc(4.999999999999999) ==4? [migrated]

Why trunc(4.9999999999999999) ==5, but trunc(4.999999999999999) ==4?
-1
votes
2answers
74 views

Detecting Persons In Seats from Image [closed]

I am attempting to build an attendance program which could analyze if someone is sitting in a seat. The seats are fixed making knowing where each seat is easy, but I don't really know where to start ...
3
votes
1answer
84 views

How do I manage quickly changing python modules

I write Python code for scientific computation. As it is research I face among other two problems: the demands are quickly changing results need to stay reproducable Imagine you have a package A ...
0
votes
1answer
72 views

Create arithmetic expression from number using +-/* that equals target [duplicate]

For example, you are given the source 1234 and the target 24. The task is to use the standard arithmetic operators +-/* placed within source, without changing the order of the digits of source to ...
5
votes
3answers
299 views

Is it ok to have multiple classes in the same file in Python?

I'm freshly coming to the Python world after years of Java and PHP. While the language itself is pretty much straightforward, I'm struggling with some 'minor' issues that I can't wrap my head around — ...
4
votes
1answer
83 views

Is Python's inheritance an “is-a” style of inheritance or a compositional style?

Given that Python allows for multiple inheritance, what does idiomatic inheritance in Python look like? In languages with single inheritance, like Java, inheritance would be used when you could say ...
4
votes
1answer
99 views

Using Python's Method Resolution Order for Dependency Injection - is this bad?

I watched Raymond Hettinger's Pycon talk "Super Considered Super" and learned a little bit about Python's MRO (Method Resolution Order) which linearises a classes "parent" classes in a deterministic ...
1
vote
1answer
57 views

Question regarding the names of OrderedDict and defaultdict functions in Python

While reading Python Cookbook I came across these two lines: from collections import OrderedDict from collections import defaultdict Now see the naming conventions of the functions in ...
1
vote
1answer
49 views

How to choose python module license as python itself

I would like to publish a python module and would like to publish it as the same license of python Below is a example of how Perl module does: This library is free software; you can redistribute ...
8
votes
3answers
748 views

What are “class methods” and “instance methods”, in Python?

There has been a discussion in chat relating to a question (the question itself being irrelevant to this one), that has revealed I may not know Python whatsoever. In my mind, although terminology ...
2
votes
2answers
112 views

python - differences between reusable code vs. code for solving specific tasks

Reusable code (ex. libraries and frameworks) and code written to solve a specific task and not meant to be reused as a general tool (for example, code being used only by my 6 person team in a private ...
9
votes
1answer
210 views

Python's join seems to focus not on the items to join, but on the symbol, as compared to Ruby or Smalltalk, for a design reason?

I thought one of the cornerstone of OOP is that, we have objects, which are the items we are interested in dealing with, and then we send messages to them. So it may seem natural that, I have a ...
4
votes
1answer
88 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: ...
4
votes
1answer
130 views

What is the most efficient way to implement a RESTful client app?

I am working on a web application for ranking some products based on some factors. The user send a search query to 5 restful webservices which by their turn send a response in a JSON format and ...
4
votes
1answer
49 views

Signature-changing decorator: properly documenting additional argument

Let's say I have a custom decorator, and I want it to properly handle docstring of decorated function. Problem is: my decorator adds an argument. from functools import wraps def ...
3
votes
1answer
92 views

How to move Python doctest examples into another unit test framework?

Years ago AFAIK the mathematitician and software developer Tim Peters discovered that very often the documentation of APIs tends to get out of date over time during the software live cycle, because ...
3
votes
0answers
99 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): ...
6
votes
1answer
85 views

Python: Control subprocess from calling thread

I am working on a database interface to a MongoDB using Python Eve as an API. The database stores several documents containing parameters and values needed for some calculations. I wrote a Python ...
5
votes
0answers
63 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' ...
-3
votes
2answers
101 views

Am i looking at HTML / Django the wrong way? [closed]

So I'm comfortable programming in Python, I love the minimalist nature of the language. However, I haven't been exposed to any Django yet. I do know html, css etc for web design but when making ...
1
vote
3answers
112 views

How To Extend Parent Methods in Children Classes?

There is a parent class with a method which many children use but many children extend the method, what is the best way to extend it without violating DRY? Here are my 2 current solutions: 1: The ...
0
votes
1answer
70 views

How to periodically serialise object's state and deserialise on initialisation in Python?

We're designing an application that is supposed to monitor a system for certain events, email interested parties to prompt them to take action when relevant and parse their replies. The application ...
1
vote
3answers
223 views

Function Overloading in Python

My book says that function overloading is not possible in python but it asks me questions like: WAP to find out the volume of a cube,cuboid and cylinder using function overloading. Do I have to ...
4
votes
4answers
891 views

Why is %s better than + for concatenation?

I understand that we should use %s to concatenate a string rather than + in Python. I could do any of: hello = "hello" world = "world" print hello + " " + world print "%s %s" % (hello, world) print ...
-1
votes
1answer
66 views

Can I use Qt open-source for my web-scraping website? [closed]

I apologize if I should be understanding this more readily but I'm a little new to this and dont understand the LGPL license. Here is the FAQ for it: http://www.qt.io/qt-licensing-terms/ I am making ...
0
votes
1answer
107 views

How to document **kwargs in python? [closed]

I have a function which has a large number of arguments. I want to have the names of the arguments available in the help() function, but I want the results as a dict. At the moment, I have the ...
3
votes
2answers
181 views

Where to put very specialised functions which heavily use one class?

I have a class which is centred around lower-level methods, to make this class much more useful it would be great to put some middle or higher level methods (i.e. methods which make a series of calls ...
0
votes
1answer
41 views

Architecture/technology for implementing Management console [closed]

I'm having a distributed environment which include several machines under the same network , which are being controlled by another computer in another network which is also running a UI for doing the ...
0
votes
1answer
101 views

Docstring convention for Python __str__, __unicode__, and __repr__ class methods

What is the docstring convention in Python for the following "magic" class methods: __str__ __unicode__ __repr__ Should I add docstrings for these? If yes, what should they say (for each)?
3
votes
1answer
113 views

A condition on an argument used in multiple calls of a method: enforced by caller or by the method?

Let's assume I have an object a of a class A. It has a method that needs an argument in form of another object of a particular type - but the argument should also be in particular state, because the ...
1
vote
0answers
101 views

Is the logic behind `Asyncio.wait()` and async/await, the same, just the code is written differently (syntax)?

I'm learning Python, more specially parallel programming using Python Parallel Programming Cookbook by Giancarlo Zaccone. At the time the book was published async/await was still in the beta version ...
5
votes
3answers
452 views

Why do you need “self.” in Python to refer to instance variables?

I have been programming into a number of languages like Java, Ruby, Haskell and Python. I have to switch between many languages per day due to different projects I work on. Now, the issue is I often ...