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
24 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. ...
1
vote
1answer
95 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 ...
4
votes
2answers
161 views

What are some examples of Python lambdas from real world applications? [on hold]

Most tutorials on Python lambdas show examples like the one below. >>> sentence = 'It is raining cats and dogs' >>> words = sentence.split() >>> print words ['It', 'is', ...
-1
votes
0answers
15 views

Kodi addon with LXML is not parsing properly [on hold]

I'm writing a scraper for Kodi, that scrapes a video page, and I'm doing it with LXML, but sometimes(sometimes it works ok), when I call tree.xpath(xpath) it says 'NoneType' object is not callable. ...
3
votes
1answer
63 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 ...
2
votes
1answer
124 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 ...
2
votes
1answer
64 views

Best practices for a daemon that forks and becomes user

I want to write a small daemon in python under Linux that accepts connections and authenticates the user (details for this don't matter) and then forks a child for the connection and becomes the user. ...
0
votes
1answer
23 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
51 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
91 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
votes
0answers
18 views

Rpy2 - install and configure it [on hold]

I dowloaded the zip file rpy2. I'd like to use some function of R statistic in python. How can we install and configure it, in order to import it in a file or module of python please? Thank you for ...
5
votes
1answer
1k views

Good practices for packaging Python programs

I've been using Python for a while now, both in the context of personal and professional projects. One thing that occured to me recently is that I had never thought about a good way to deploy Python ...
-3
votes
0answers
19 views

Please recommend an IDL/RPC framework that works with Java and Python [on hold]

I'm looking for a framework that supports RPC from Java to Python, where the message format can be defined via a simple IDL. My requirements are: Must be high performance Must support streaming ...
2
votes
1answer
340 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
votes
0answers
59 views

Database design in Python? [on hold]

I need to design a teaching staff timetable database. The times for all subjects are fixed: my job is to assign staff to classes. There are plenty of database modules and staffing apps available, ...
2
votes
1answer
35 views

log method calls per object

How to log method calls on a per object basis for a particular class? I.e. after instanciating a = myClass() I somehow want to keep a log for what methods have been called on a like a.reverse() ...
-4
votes
1answer
21 views

Python: Find pattern of repeating number in an array [on hold]

so i've tried to make a program that finds a repeating digit in an array of numbers. So after a bit of trial and error i've realized i don't even really know where to start. ...
2
votes
2answers
92 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
0answers
46 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 = ...
-1
votes
0answers
9 views

Python seeming to incorrectly handle time zone conversions [migrated]

I am confused by the following behaviour in a python program I am writing to convert dates and times. I have data in raw `wall clock time' as New Zealand Standard time, and want to convert it so that ...
-3
votes
0answers
15 views

i'm getting this error in python<__main__.Node object at 0x03A5F990> linked list [migrated]

linked list implementation using python class Node: def __init__(self,data,next): self.data = data self.next = next class List: head=None ...
-6
votes
0answers
33 views

snackdown round 1A problem 1 [closed]

Please see the following problem : https://www.codechef.com/problems/CHEFVOTE My code is receiving WRONG ANSWER every time, although I checked my algorithm as well as my code in python many times. Can ...
-2
votes
1answer
30 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, ...
0
votes
1answer
47 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 ...
1
vote
2answers
83 views

Efficient way to handle foreign keys

I am building a script that checks a large network of sites for invalid links. The idea is to flag links that continuously show as not available so that they can be cleaned by the administration team. ...
0
votes
1answer
56 views

Programming to multiple backends

My current project is a high-level abstraction package for GPIO programming on those nifty little SoC-Computers (Raspberry Pi, Cubieboard, Beaglebone Black, Pandaboard etc.). One of my goals is to ...
1
vote
1answer
68 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
68 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 ...
0
votes
1answer
72 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) ...
2
votes
1answer
33 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 ...
4
votes
2answers
5k views

What is the way to go to extract data from websites? [closed]

I've been thinking about a side project that envolves web data scraping. Ok, I read the Getting data from a webpage in a stable and efficient way question and the discussion gave me some insights. ...
4
votes
3answers
1k views

Front-end structure of large scale Django project

Few days ago, I started to work in new company. Before me, all front-end and backend code was written by one man. As you know, Django app contains two main directories for front-end: /static - for ...
2
votes
2answers
90 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
33 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 ...
3
votes
1answer
165 views

Draw a Call Graph

I'm maintaining an old code base written in python. In particular there is a complex piece of code that from a module calls other functions from other modules that call other functions and so on. It ...
0
votes
1answer
100 views

Python object oriented programming problems while implementing binary search tree

I am shifting from procedural C programming to OOP Python programming and I faced some problems while implementing binary search trees. I cannot make my Tree_Node null in case of deleting it. In C I ...
0
votes
0answers
15 views

Making list of adjacent node pairs from Cube-formatted line file (using Python) [migrated]

My files are formatted like this: LINE NAME="FirstLine", MODE=15, ONEWAY=T, HEADWAY[1]=20, HEADWAY[2]=30, HEADWAY[3]=20, HEADWAY[4]=30, HEADWAY[5]=30, VEHICLETYPE=2, XYSPEED=20, N=-20609, ...
0
votes
2answers
124 views

Nested functions; allow or not? [closed]

Having programmed a whole lot in python, using nested functions is a good way to not clutter the namespace with small helper functions that are only used once. Now I'm programming in go, and upon ...
6
votes
3answers
1k views

What's the best way to create a static utility class in python? Is using metaclasses code smell?

Ok so I need to create a bunch of utility classes in python. Normally I would just use a simple module for this but I need to be able to inherit in order to share common code between them. The common ...
19
votes
5answers
9k views

Is it a good practice to declare instance variables as None in a class in Python?

Consider the following class: class Person: def __init__(self, name, age): self.name = name self.age = age My coworkers tend to define it like this: class Person: name = ...
3
votes
3answers
253 views

Why does Python need both a compiler and an interpreter?

I can understand the fact that Java needs both a compiler and an interpreter. It compiles source code to bytecode and then a virtual machine (on Windows, on Linux, on Android, etc.) translates that ...
1
vote
2answers
37 views

Compiling vs pre-built binaries on production machine?

I referred Compiling vs using pre-built binaries performance?. The post talks about performance and opportunities for optimization. My question is about reliability. I built both python and ...
1
vote
0answers
7 views

Python, Service dies but PID remains.. Log file updates every minute [migrated]

I have service that as the topic says dies and leave a stale PID behind. This particular service logs every minute. So basically I want to create a python script to check the logfile based on modified ...
3
votes
1answer
61 views

What is more pythonic - subclassing dict or creating external functions to manipulate them?

Say I have a dictionary that contains complex classes that need to be loaded and unloaded in a special way. (Not especially special, just outside the bounds of this question.) Should I gracefully ...
3
votes
3answers
229 views

Can you do iterative development in c#? [closed]

I'm primarily a Python/R developer. In those languages, the way I develop is to sketch out a data and class structure, write the methods and their tests in interactive mode, then refactor them up into ...
8
votes
3answers
414 views

How can I start shipping code?

I have just started learning how to program using LPTHW, and as my skill level develops I would like to start shipping code whether or not it's ready to be shipped, just to get into the habit of ...
1
vote
0answers
15 views

save custom ui in pyside (Qt bindings for python) [closed]

I've build a PySide app in which the user can create as many tabs as he wants, each tab can be divided in as many panels as the user wants using spliters, and each subpanel can have a custom widget ...
1
vote
1answer
51 views

Function name in parentheses after fuction call in Python

I ran into these lines of code in the QPYTHON Android app. They are part of a sample that uses the Bottle module to create a simple Web server that seems to work fine. app = Bottle() app.route('/', ...
2
votes
1answer
255 views

What design patterns could be used here?

I'm trying to come up with a nice design (preferably pythonic) for the following use case. Say there's three services - A, B, C in multiple locations L1, L2, L3, etc. Each service provides ...
1
vote
0answers
73 views

Structuring a multi-language project?

I'm working on a project which involves writing code for multiple devices, each in its own language (in particular, Arduino and Python). I want to contain the entire project in a single directory, but ...