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)

2
votes
1answer
113 views

Where to implement thread-safety logic for my queue data structure?

I will immediately confess that I do very little multithreading, so questions of style and organization in this domain a little fresh to me. I've written a data structure (in Python, if that matters) ...
0
votes
1answer
74 views

How to write a good mock for testing

I code in Python and I'm starting to use the Mock library. Although I've read through all of the documentation, something that I'm finding hard to understand is 'What makes a good mock'. For ...
0
votes
0answers
36 views

Search substring using suffix array (and LCP)

I'm searching for a best way to improve suffix array run time using LCP. My text (about 2 500 000 chars) seems like: 0ricco0eric0america0polo0.... My thoughs: SA=suffixArray char=firstChar(input) s ...
4
votes
1answer
2k views

Which low-level programming language is most similar to Python? [closed]

I'm trying to discover a low-level language that is similar in how code is written in Python. I am not familiar with all technical terms relating to programming languages, but if you can think of it ...
0
votes
1answer
75 views

“Saving method name in a variable: Python”, How does this code works? [closed]

I am trying to make sense of the following code snipet: factor = misc.kkt_chol2(G, dims, A) .... .... factor(W, P) How the parameter in factor binding with the parameters inside kkt_chol2? Thank ...
0
votes
1answer
38 views

Python shelve class rename

The main reason I use Shelve is to be able to quickly develop code without worrying about db table structure. Unfortunately changing a class name from, say, 'class1' to 'class2' gives "AttributeError: ...
-3
votes
1answer
106 views

Sqlite3 slow on standard queries, is it expected? [closed]

Using Python and sqlite3. This simple print loop takes a few seconds to execute. I don't know much about databases, so I'm guessing I'm not using these queries correctly. Surely sqlite should be ...
3
votes
3answers
152 views

Unit Testing: How much more code? [duplicate]

I'm fairly new to unit testing. In school it's always been, "hey it works, onward!" But I've started to write professionally, and even at work that's been basically the mantra. However, I've started ...
4
votes
2answers
232 views

Should duck typing affect naming conventions?

I'm a C++/C# developer and recently I've started to learn Python. I think I understand the concept of duck typing right now except for one thing. When I'm coding in C++ or C# I sometimes create ...
28
votes
1answer
958 views

How to deal with a misnamed function in production code?

I've recently come across a Python library on GitHub. The library is great, but contains one glaring typo in a function name. Let's call it dummy_fuction() while it should be dummy_function(). This ...
-4
votes
1answer
43 views

cx_Freeze'd application license [closed]

I have a python program packed to .exe using cx_Freeze. I am trying to understand licensing implications: do I have to reproduce cx_Freeze license agreement? do I have to reproduce python license ...
0
votes
1answer
131 views

Is the following example a strategy pattern?

In my problem I had lots of objects with slightly different behaviour, but identical attributes and methodes with identical interfaces. The objects variants were quite big in number, and I didn't want ...
2
votes
0answers
241 views

Why are so many Python files really big (5k+ lines)? [closed]

Is there any specific reason driving Python files to often be so large? Python files may contain several classes within one file, and some files go up over 10k lines in length. This seems to go ...
4
votes
2answers
210 views

Using a closure to avoid code duplication in Python

Sometimes I find myself wanting to run the same code from a few different spots in the same function. Say I have some function func1, and I want to do the same thing from a few different spots in ...
0
votes
0answers
58 views

Gevent - Make blocking calls non-blocking

I have the blocking code shown below. Is calling monkey.patch_all() enough/optimal to make it non-blocking? Does Gevent handle iterations like these? # front page def front_page(): database = ...
-1
votes
3answers
201 views

Finding the name of a video game with a picture of its cover (Python/Java) [closed]

For the past few days, I've been trying to figure out how to take an image of a video game cover (like this one) and get the name of the game from it. Initially I attempted to use Google's Search by ...
-3
votes
1answer
153 views

Is there a purely technical term for 'monkey patching' [closed]

EDIT The original title of the question was Is there a non-derogatory term for 'monkey patching'. As I have learned that the term is actually not derogatory, or is at least not meant to be, I changed ...
1
vote
1answer
81 views

Is it possible to get probabilities from a support vector machine?

From what I understand, SVM's take a discrete number of x and y values from which to learn from, then when given new x values map it to one y value (category). Is it possible to use SVM's or something ...
14
votes
2answers
539 views

Creating nested functions for purely aesthetic reasons?

I've always wondered what other programmers think about the idea of creating pure aesthetic functions. Say I have a function that processes a chunk of data: Function ProcessBigData. Say I need ...
0
votes
0answers
50 views

streaming data in memory aggregation

We have a stream of data we're aggregating stats over and putting into a python dictionary (sent from kafka). Every X time interval, We update our database with these aggregated metrics. This ...
0
votes
2answers
237 views

DDD - Domain Driven Design, which development order should be applied?

1 - Design my entities, ie (in python): class Account: def __init__(name, author): self.name = name self.email = email 2 - Design my repositories: (as interface) class ...
1
vote
2answers
409 views

Why does Python use hash table to implement dict, but not Red-Black Tree? [closed]

Why does Python use hash table to implement dict, but not Red-Black Tree? What is the key? Performance?
2
votes
2answers
497 views

Why do concurrent languages tend to have more complicated syntax?

This is a question that's been on my mind for a while. Recently I've been checking out concurrent languages like Haskell or Go or Erlang. From my point of view, they have huge benefit in performance ...
1
vote
1answer
188 views

Python - Is this a bad strategy pattern?

I've got a Python project wherein a basic object is created and various different attributes are modified/given to it via what I thought was a good example of a strategy pattern. In this silly game ...
0
votes
0answers
55 views

subclass QAbstractTableModel - reuse as much code as possible

in my PyQt application I am heavily using the model/view approach. For every model I create, I do the following: class myModel(QtCore.QAbstractTableModel): def __init__(self, parent = None): ...
1
vote
1answer
75 views

Best way to search through directory structure

I'm working on a python program which organizes a music library. The program will basically help me detect misspelled file or directory names, wrong FLAC tags or unknown/superfluous files. It will ...
-1
votes
2answers
251 views

Utterly Confused with OOP - How do I overcome a beginner's hurdle? [closed]

I have been reading and working through the exercises of Steve Lott's book Building Skills in Python. However, on the very first exercise dealing with OOP I have gotten completely stuck. The problem ...
0
votes
1answer
71 views

scipy.stats.percentileofscore() wrong?

i'm a data scientist and python noob, but I seem to have found a bug with scipy.stats.percentileofscore. it may be "by design" but please bear with me. if you have an array, you will get an upper ...
0
votes
2answers
177 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
317 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
151 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
185 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
108 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
139 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
139 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. ...
1
vote
1answer
175 views

Why are Python's package names not creative? [closed]

First, I LOVE Python, and Python is my first programming language. I'm just wondering why Python's packages got kinda ugly unmemorable and sometimes very long names? I find other languages (e.g. ...
0
votes
1answer
69 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
118 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
175 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 ...
1
vote
3answers
268 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
58 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
145 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 ...
7
votes
2answers
1k 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
184 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
53 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
105 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
34 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
180 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
159 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
140 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 ...