Tagged Questions

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)

0
votes
2answers
211 views

Python - only one return per method? [duplicate]

I'm trying to sort out whether this is just a personal preference thing or whether it's actually bad practice to do this one way or another. I did try to reference PEP8 first, and I did not see an ...
5
votes
2answers
323 views

Is there a name for the number of values a variable can take? [closed]

For example, a bit or a boolean can be either 0 or 1 so the number 2 is associated with it. Similarly, for a byte which is 8 bits, the maximum number of different assignments would be 2^8. Is there a ...
0
votes
3answers
265 views

Isolating unit tests in python

As a 30-year software developer, mostly in OO languages, but a newbie at python, I'm looking to find what is best practise for isolating unit tests in python. Let's say I have the following, ...
3
votes
2answers
202 views

Tablet development for a dedicated system

I need to make an architectural decision for developing (actually porting) my embedded solution on a tablet. The choice comes down to Ubuntu or Android, so I have some specific questions to help me ...
2
votes
1answer
120 views

why is len not a reserved keyword in python

why is functions like len and max not a reserved keyword in python. Following are the only reserved words http://docs.python.org/2/reference/lexical_analysis.html#keywords
2
votes
3answers
154 views

When to use python function nesting?

I am writing a program that creates backup of directories. Which of the following approach is better for code organization? Create separate class for Backup and Zip logic - class BackupUtil: ...
0
votes
1answer
162 views

How to Think like a computer Scientist. Chapter 3, Question 2 [closed]

http://interactivepython.org/runestone/static/thinkcspy/PythonTurtle/helloturtle.html I'm stuck on question 3. Give three attributes of your cellphone object. Give three methods of your cellphone. ...
0
votes
1answer
95 views

Making a sldprt to PDB file converter?

I wanted to create a parser that can read a solidworks file and turn it into a protein data bank file. This has already been done in a program called DiamondCAD. ...
0
votes
3answers
146 views

Is it possible to have setup and tear down methods run only for specific unittests?

I currently have a test class with a setUp method for creating a temp file and a tearDown method for deleting a temp file. However, only some of the the test_ methods in that class require this ...
0
votes
1answer
295 views

How to develop an algorithm for brute-forcing / backtracking?

As a beginner programmer, I don't know how to conceptually think about brute-forcing. My mind can't really fathom how to write code that will try every possibility. I have a problem that I want to ...
2
votes
3answers
399 views

Global request context - anti-pattern?

I was talking today to a colleague of mine about Python web frameworks and our impressions about them. I told him I think Flask having a global request smells badly and is an anti-pattern. The docs ...
0
votes
0answers
73 views

Check some value between each function call

Can you recommend a nice way of checking a particular value between calls to a set of functions? E.g. something like this in Python (might not be terribly 'Pythonic'): self.error_code = 0 # this ...
3
votes
1answer
168 views

Advantages of contracts over assert statements

Today I stumbled upon the python package called PyContracts. However, python has the assert statement which seems to allow you to do exactly those things. What advantages do contracts have over assert ...
10
votes
2answers
3k views

Is it conventional to raise a NotImplementedError for methods whose implementation is pending, but not planned to be abstract?

I like to raise a NotImplementedError for any method that I want to implement, but where I haven't gotten around to doing it yet. I might already have a partial implementation, but prepend it with ...
1
vote
3answers
194 views

Python methods vs builtin functions

Python widely uses built-ins (or module function) and not class methods. So len([]) instead of [].length() filter(f, []) instead of [].filter(f) str(2) instead of 2.to_str same for map, foreach etc ...
0
votes
3answers
55 views

If an object should be flagged, should it be built with the flag attribute?

Let us assume I have a basic object with a handful of self-relevant points of data. class A(object): def __init__(self, x, y, width, length): self.x = x self.y = x ...
-2
votes
2answers
118 views

RESTful API development : is it web developer's work or software developer's work? [closed]

First of all, I am sorry that the issue I'm going to say is not about a technical thing. I'm just confused. I am trying applying to several companies as a software engineer. The latest work that I ...
0
votes
0answers
45 views

Choosing a database for a framework with both asynchronous and synchronous calls

I'm building a framework to work as an all-purpose astronomy pipeline and before I get too far into development I was hoping to run my needs by you all to see if there are any optimizations or ...
1
vote
1answer
357 views

Logging in a distributed system

We have several application servers (and different applications) running on Amazon AWS and our main method of logging is a combination of statsd, carbon/graphite, and an alert system based off of the ...
1
vote
1answer
172 views

Pythonic version of Java interfaces

I fully acknowledge that Python and Java are different programming languages and should be used differently. That said, "Program to an interface, not to an implementation" is good language-agnostic ...
1
vote
2answers
226 views

Usage of __ while declaring any variables or class member in python

Is it good practice to use __ convention while declaring the member variable? This also imparts private kind of feature of that data member. There have been cases when I found that its good to have ...
0
votes
0answers
79 views

HTTP API that wraps any Python-Scrapy spider

I have to write an HTTP API that wraps any Scrapy spider, it should accept Requests, execute them in Scrapy, and return data extracted by the spider and lets the user reuse the same code to extract ...
1
vote
2answers
87 views

Learning python functions and parameters

def printMax(a, b): if a > b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4) # directly give literal values x = 5 y = ...
10
votes
9answers
2k views

Is there any difference learning OOP on different programming languages? [closed]

I want to learn OOP. I know Python and I know very little things about OOP. But when I search for "learn OOP" in forums I saw a guy saying that "Python is so new that's why you can't learn OOP on ...
1
vote
1answer
114 views

Why chaining matters (Python & SQLite3)?

Why does cursor = connection.cursor() cursor.execute("... return cursor.fetchall() return the expected non-empty result whereas connection.cursor().execute("... return ...
0
votes
1answer
113 views

does anyone know how to use the PyQt 'uic' module method 'compileUiDir'?

I don't find the docstring to be very clear: def compileUiDir(dir, recurse=False, map=None, **compileUi_args): """compileUiDir(dir, recurse=False, map=None, **compileUi_args) Creates Python ...
1
vote
2answers
425 views

Python sorted iterable set, modifiable during iteration

I am looking for a datastructure to handle cycling through a large number of ordered subroutines, some of which are active, most of which are not. I am thinking I need an implementation of a python ...
0
votes
1answer
72 views

Pythonic design for controlling multiple devices through an I2C bus

I'm writing a piece of software in python that will communicate with a bunch of devices via an I2C bus. Each of these devices are going to need some sort of a module or class to handle the ...
1
vote
1answer
135 views

Dynamic method creation in python

I have a class that will have a number of external methods that will all call the same smaller set of internal methods. So something like: obj.method_one(a, c) and obj.method_two(a, c) where ...
0
votes
1answer
148 views

In python, do we have class encapsulation at the level of the object?

I was bitten by using the is operator when i should have been using ==. Am aware that the former tests for equality of the objects' identities and that the latter tests for equality of the objects' ...
0
votes
1answer
346 views

Using module level declared global “singletons” in python

Ok, I know that using singletons is generally a bad practice, but if I do it (for db connection, logging et al.) am I allowed to go (in respect of clean design) with a module defined variable that is ...
0
votes
2answers
1k views

How to write an optimal LAN messenger software?

I am asking this question as an extension to the following question: https://superuser.com/questions/713409/how-to-message-any-user-on-your-lan I don't think I have a real answer. I found it quite ...
0
votes
0answers
44 views

Implementing FUSE for deduplication

I am new to FUSE and using python-fuse for writing a file system for data deduplication. Let's say, I have a directory named "metadata" and in that directory, there is a file foo and a directory ...
4
votes
1answer
346 views

What is the historical reason why Python uses the double underscore for Class Private members

In python a module private function or variable is named _foo. If it is private to a class it is names __foo, The mechanics behind how these work are different, however that is of little relevance to ...
2
votes
3answers
374 views

Is Python suitable for a statistical modeling application looking over thousands of past events?

I'm currently working on a project with a partner where we analyze large datasets of past sporting events. There are approximately 30,000 events per year and we have historical data for five years. ...
4
votes
4answers
404 views

Communicate to a junior developer about bad style

I have a friend who's managed to pick up comma first (best case might be made here: http://ajaxian.com/archives/is-there-something-to-the-crazy-comma-first-style) but it's 100% against our org's style ...
1
vote
1answer
964 views

Using python to parse log files? [closed]

My first useful projects as a programmer has been python scripts that parse out relevant information from log files and do some analysis. I've bumped around and found my way to some functional ...
1
vote
1answer
80 views

How to comment on a PEP?

Proposals for new Python features are collected in documents called PEPs (Python Enhancement Proposals). There's a master list at http://www.python.org/dev/peps/ which links to (for example): ...
1
vote
1answer
320 views

Python for a desktop app

I currently have a .NET app that I want to convert to being cross platform, as a growing number of my users want a Mac version. Since this forum doesn't seem to like questions that are "what ...
2
votes
2answers
545 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 (oh my...). As you know, Django app contains two main directories for front-end: ...
0
votes
0answers
288 views

Django web app with websockets

I want to make a web service using Django, but that also has websocket functionality. Having done a bit of reading, this is the tech stack that I'm looking at: --------------------------------- ...
0
votes
2answers
275 views

How can I convince my client that the task was complex and the time I took is fair?

I am the single programmer working on a website handling both frontend and backend. Recently in my task list I have to provide a social news feed (activities among friends) which should summarize ...
0
votes
1answer
111 views

return Trivial booleans?

I am writing a simple piece of code. Its a function that allowed the user to withdraw some money. There are some restrictions to this though. The user can't withdraw more than the given withdraw ...
0
votes
0answers
76 views

Distributing Contestant Entries Between Multiple Bins, Is this Knapsack?

I am an algorithm novice and am faced with a rather difficult problem. I am working with contests. There are contestant - individual player entry - contestants can have multiple entries into a ...
1
vote
2answers
1k views

Python - assert vs if & return

I am writing a script that does something to a text file (what it does is irrelevant for my question though). So before I do something to the file I want to check if the file exists. I can do this no ...
0
votes
1answer
157 views

Why can python webapps keep sessions between restart and not java?

I've used both webapp2 + GAE for python and a number of Java/JEE webapp frameworks. The python WSGI framework could keep users logged in while I redeploy the app while none of the Java web framework ...
0
votes
2answers
142 views

What are and how do (data-) types work?

What is a "variable"/data type? How does a compiler / interpreter handle types? My specific concern has to do with the different types in lower and higher level languages. For instance in Python, ...
0
votes
1answer
53 views

Verify 0 or 2+ sub sections in a section

There is a rule in writing: When you break a section into subsections, typically it should have more than one subsection. This goes back to the old high school composition rules: if you have an A. ...
16
votes
8answers
1k views

What are good unit tests to cover the use case of rolling a die?

I'm trying to get to grips with unit testing. Say we have a die which can has a default number of sides equal to 6 (but can be 4, 5 sided etc.): import random class Die(): def __init__(self, ...
0
votes
0answers
87 views

Approach to statically analyze a Python code base

What approach should I use to statically analyze a Python code base? In particular, I am looking for ways to: extract and display the class hierarchy, extract and display class relationships, ...