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
3answers
214 views

What's special about “non-blocking” node.js?

In the short chapter, What is Node by McLaughlin, he writes: "Node has no blocks, no threads competing for the same resource (Node is happy to just let things happen however they happen), ...
7
votes
3answers
25k views

How to develop front end (UI) for my Django website

I am learning Django and new to web development. Please excuse me if you find this question too dumb. So, I am creating a Facebook application using Django which I would like to host in Google App ...
0
votes
1answer
114 views

using one database connection across multiple functions in python

whats the best way to go about this in python? I have a number of like so def test1() .... code ..... def test2() .... code ..... def test3() .... code ..... how could I create one ...
4
votes
2answers
82 views

Should serialization and deserialization be the responsibility of the class being serialized?

I'm currently in the (re)design phase of several model classes of a C# .NET application. (Model as in M of MVC). The model classes already have plenty of well-designed data, behaviors, and ...
0
votes
1answer
37 views

Normalizing a numpy array

I checked a while back for questions relevant to my own about normalizing numpy arrays but couldn't find any. So I'll pose my question following this line of code: for i in ...
2
votes
1answer
76 views

How do I distinguish derived code from original code?

I'm working on a Python project which extends the functionality of some other python modules. Some are part of the standard Python library and mostly use the PSF License agreement while some are ...
2
votes
1answer
87 views

Python Classes and Design Questions

What is the best way to design a class to see if an update occurs on a property? I have a whole bunch of classes, and current am going through a re-design of the python package I created. ...
1
vote
1answer
51 views

Should I automatically install needed modules?

I'm writing a program for my grandpa. Occasionally an update will require a new module that's not installed on his computer. I don't want to have to manually install new modules every time, but he's ...
-2
votes
0answers
11 views

Using SAML with Python (client application) [on hold]

I am writing a script that need to authenticate against a site that uses SAML to verify the user's identity. Can anyone provide a sample or point me to a simple working example of doing this with the ...
-7
votes
3answers
123 views

Why different languages have different syntax? [duplicate]

Different programming language always/most of the time use different syntax. For example take PHP, Java and Python. In Php & Java semicolons are compulsory at the end of the line, yet Python ...
-5
votes
0answers
13 views

Why does next(some_generator_func()) yield a different result from next(a_var), where a_var = some_generator_fun()? [migrated]

Let some_generator_func() be the function: def some_generator_fun(): yield 1 yield 2 Why is it that >>>>next(some_generator_func()) 1 ...
0
votes
0answers
52 views

Will this data mining approach work? Is it a good idea?

I need to extract fields like the document number, date, and invoice amount from a bunch of .csv files, which I believe are referred to as "unstructured text." I have some labeled input files and will ...
2
votes
1answer
46 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. ...
-5
votes
0answers
28 views

trouble in printing row from two text files [closed]

i have two txt files of three columns each,but unequal rows. from the two files i have to perform an operation using 2nd and 3rd column of both files simultaneously. do an operation and then if ...
-3
votes
0answers
26 views

Programming design on heavy web I/O Django based scrapping application [on hold]

I've started a project few month ago for closest to real time database operations next to HTTP requests. I choose Django + Celery as a first place, then tried with home made multiprocessing + ...
-1
votes
0answers
22 views

Create/run a script, which securely stores account info, searches, scrapes targets, and then displays targets in canvas, without installing Python [closed]

I made the title as brief and to the point as I could but I'll be more detailed here. I have a Python project in mind that I'd like to start working on now even though I'm still learning and should be ...
4
votes
2answers
895 views

Does this code follow duck typing?

The principle of duck typing says that you shouldn't care what type of object you have - just whether or not you can do the required action with your object. For this reason the isinstance keyword ...
23
votes
6answers
3k views

Can you implement “object-oriented” programming without the class keyword?

Say we want to provide an abstraction of an "account" in a bank. Here's one approach, using a function object in Python: def account(): """Return a dispatch dictionary representing a bank ...
-3
votes
0answers
39 views

set() is the value in a key:value pair?

I'm working on dictionary comprehension for a database so that I can save various database tables as nested dictionaries for easier data manipulation. SQLAlchemy Core has a good tutorial with an ...
2
votes
1answer
321 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 ...
0
votes
0answers
27 views

list is editing all values instead of just one [migrated]

snake = [] snake_size = 10 snake.append([display_width / 2, display_height / 2]) snake_dx = 10 snake_dy = 0 #I then declare some more lists in snake in an identical fashion for i in ...
2
votes
1answer
29 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() ...
0
votes
0answers
20 views

Ipython3 development cycle

I am new to python (python3) and am using Ipython3 while writing the code just in my preferred text editor. I am not yet sure what is a good development cycle as I keep getting problems with reloading ...
-4
votes
1answer
62 views

How do I use a list of int to set the index of another list [closed]

I want to use a list called index with only ints to use it to set the index of another list. index = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26] dictionary = ["a", "b", ...
2
votes
3answers
252 views

How much should I break up my unit tests?

I recently learned about unit tests and TDD and have started going back to add unit tests to my code (and thank god, it's proven that some things I've written are much more broken than I thought). ...
3
votes
3answers
76 views

How to structure project where a library and application using the library are concurrently developed?

I am planning to develop a new application that will heavily use a library that will be developed from scratch specifically for the application, but made general enough for it to be used for other ...
0
votes
1answer
50 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. ...
2
votes
4answers
614 views

outsourcing code review/refactoring [closed]

I have a small project (3000 lines in Python) that I wrote myself; it has no known bugs and has some decent parts, but is largely a mess because of my lack of time. Unfortunately, I have to be the one ...
-2
votes
0answers
24 views

Use Bisection Search to guess number [migrated]

I'm writing a program that is supposed to guess the user's secret number using bisection search. I feel like I understand the concept of bisection search quite well but my IDE (Canopy) won't let me ...
0
votes
5answers
412 views

How to create a Python method prototype

If I'm giving an interview coding question in Java, I can specify the most of the question just by giving a method signature. (Made-up example follows.) public class Table { public String ...
0
votes
1answer
59 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) ...
-6
votes
1answer
107 views

I wrote a Python Switch statement [closed]

I wrote a python switch statement. I have seen a number of of examples that were outlandish and I was wondering if my switch statement is worth having and as it is written, what is a better way to ...
3
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 ...
0
votes
1answer
80 views

Django urls.py runs only once. Why? How does it call views on next request?

While testing django cashing on our development server, one of our senior asked if is it possible to change the value of caching timeout on urls.py without restarting the http service. On first note, ...
-5
votes
1answer
63 views

Linux on USB for Python (or other) Programming on the go? [closed]

This is my first question and I didn't see a similar question asked. Sorry if I didn't search hard enough. To the point. I'm learning the Python programming language and I've read Linux plays very ...
2
votes
1answer
206 views

how to test a generator with unittest?

I have programmed a small iterator in Python: class anything(): def __init__(self): self.i=1 def __iter__(self): return self def next(self): if self.i>100: ...
2
votes
1answer
126 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 ...
-1
votes
0answers
17 views

Unique path for file upload [duplicate]

What is a best practice to follow for the following problem? Say you have a web service in which an authenticated user needs to upload a file and from this file (say a cv in pdf) other info might be ...
-1
votes
0answers
34 views

Taking screenshot of website with python results in blank page [migrated]

So I'm trying to take a screenshot of a website using a python script: #! /usr/bin/python import sys import time from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * ...
0
votes
0answers
41 views

Best practices for creating a project utilities module? [migrated]

Does anyone know of any best practices around creating a utilities module or class specific to your project? I have a project I've been working on that has three different moving pieces, but we keep ...
-1
votes
2answers
57 views

python code style for long lists [closed]

when coding a very long list in python, is it better to fit several items on each line or should I limit it to 1 per line? 99% of the time I would go with style2 below but I have 5 lists each about ...
0
votes
0answers
6 views

Compilation difference in Spyder IDE and Python intrepeter [migrated]

This problem may seem a little strange, but a while (about 1-2 weeks) ago I wrote a little Python script which I tested and everything worked just fine. Today when I was taking lines from this latter ...
0
votes
1answer
49 views

Python replace function for classes? Like namedtuple _replace?

Does the Python standard library offer anything similar to the custom replace function below? I can put this in my own *utils module, but I'd rather use a standard library implementation. Also, this ...
0
votes
1answer
170 views

Best strategy for converting change in longitude and latitude to north, south, east, west in degrees

This is not a class assignment but a conceptual question I'm struggling with for a personal project. I need to convert a large paired group of long and lat coordinate values that show a ...
20
votes
9answers
5k views

Why there is no power operator in Java / C++?

While there is such operator - ** in Python, I was wondering why Java and C++ don't have one too. It is easy to make one for classes you define in C++ with operator overloading (and I believe such ...
0
votes
0answers
33 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 ...
0
votes
1answer
85 views

Setting up folders and importing modules in Python

I'm building an app to automate some processes that are annoying to do by hand (looking in a file, taking certain information out of a file, building another file with that information). My project ...
4
votes
2answers
2k views

Loop Invariants in Python

I have a bit of experience with loop invariants but I'm not really clear on them. I'm trying to learn them through an example in Python. Can someone point one out or help me understand? I've ...
0
votes
0answers
25 views

Python 2.7, Binary & ASCII [migrated]

I'm new to Python and I've just completed my first book, so my knowledge is somewhat average of known terms etc, but as practice I've been accessing an API, Information on it is located here; ...
13
votes
2answers
7k 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 ...