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)

-3
votes
1answer
50 views

Python or PHP for website development [on hold]

Can I build a website that contains functionality like login, admin pages (with restricted access) file upload etc etc, using python (Obviously html and css as well) or should I really invest the time ...
0
votes
0answers
20 views

Python IZIP list comprehension returns empty list [migrated]

I have a list of strings that I am sorting. There are 12 different key strings within the list that I am using to sort by. So instead of writing 12 separate list comprehensions I would like to use a ...
-3
votes
0answers
42 views

Most Efficient Way to design a Dynamic Web application [on hold]

I've come up with the idea to develop a side project. I want to dive into Django development after doing the Django tutorial. Basically what i want the project to provide is different resources to ...
-4
votes
0answers
62 views

How to control multiple monitors from one CPU? [on hold]

Is there a way to control multiple monitors from one CPU using Python? For example, opening a browser on each screen?
9
votes
5answers
914 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 = ...
0
votes
2answers
84 views

Is creating and writing to one large file faster than creating and writing to many smaller files in Python on Linux?

If using Python on a Linux machine, which of the following would be faster? Why? Creating a file at the very beginning of the program, writing very large amounts of data (text), closing it, then ...
-2
votes
1answer
70 views

Where does the name “psycopg” come from? [on hold]

Apologies if here is not the place to ask, but so far google, the documentation and the faq page are not giving me an answer.
28
votes
2answers
4k views

How do I move away from the “for-loop” school of thought?

This is a rather conceptual question, but I was hoping I could get some good advice on this. A lot of the programming I do is with (NumPy) arrays; I often have to match items in two or more arrays ...
0
votes
0answers
3 views

How can I set “no subprocess” for Python IDLE other than shortcut [migrated]

I have been able to get my favorite Python tool, Python iDLE, to work by starting it with a windows shortcut to IDLE.BAT with a -n (no subprocess) at the end of the TARGET string. Is there a ...
3
votes
2answers
183 views

Which programming idiom to choose for this open source library?

I have an interesting question about which programming idiom is easier to use for beginner developers writing concrete file parsing classes. I'm developing an open source library, which one of the ...
-4
votes
0answers
31 views

scrapy cannot find div on this website [on hold]

I am very new at this and have been trying to get my head around my first selector can somebody help? i am trying to extract data from page ...
1
vote
0answers
12 views

Is this a good place to ask a question i have about programing? [migrated]

I have asked the same question twice about a program on python and it keeps getting put on hold and i thought this was a good place to ask programming questions and I just wanted to make sure.
2
votes
2answers
131 views

Why doesn't Python have a “flatten” function for lists?

Erlang and Ruby both come with functions for flattening arrays. It seems like such a simple and useful tool to add to a language. One could do this: >>> mess = [[1, [2]], 3, [[[4, 5]], 6]] ...
4
votes
4answers
553 views

How does Python compile some its code in C?

I read that some constructs of Python are more efficient because they are compiled in C. https://wiki.python.org/moin/PythonSpeed/PerformanceTips Some of the examples used were map() and filter(). I ...
-1
votes
0answers
39 views

Bit by bit comparison of using Java or Python for unit testing frameworks and Selenium [closed]

Currently we are in the process of finalizing which language out of Java, Python should be used for Automation using selenium webdriver and a suitable unit testing frameworks. I have made use of ...
1
vote
0answers
85 views

What is the right way to process inconsistent data files?

I'm working at a company that uses Excel files to store product data, specifically, test results from products before they are shipped out. There are a few thousand spreadsheets with anywhere from ...
0
votes
1answer
93 views

One boilerplate class or many similar classes?

Lets say I'm trying to model a variety of objects that are virtually identical, the only difference being their class variables. Am I better off creating one boilerplate class and just calling the ...
3
votes
2answers
85 views

Should I use nested matrices or dictionaries?

As per Should I ask my question about which data structure to use here? I'm asking this here. Hopefully this isn't too implementation specific. I'm currently developing a program that will represent ...
0
votes
1answer
55 views

Where to save something between invocations?

The 2nd time I run this program I'd like it to start in the same HDD location as the previous instance. How should I save, or remember, where I was so the program starts in the same place? I'd like ...
1
vote
3answers
146 views

How do I test my code in Python other than by doing it by hand?

I am used to user testing in Java, and I also manually test each section of code I write, but now, I want to automate it. There is no GUI for this project, so user testing is not required and I can ...
-4
votes
0answers
37 views

Crowd movements with Python [migrated]

I've done a program in order to calculate the time required to evacuate a room. The program takes in arguments the number of people (N), the dimensions of the room (L,l), and the location of the exit ...
0
votes
1answer
129 views

Best Practices For Temporary Scripts (Python)

I am running two separate programs which are similar enough that they share a lot of code. I run these programs often and after I evaluate the output. This is a very fluid process and everytime is ...
0
votes
1answer
80 views

Python case statement? [duplicate]

I made a simple Python script that takes user input in order to generate a series of mathematical responses. In one part I did this: while True: And iterated through the loop until I used an if ...
0
votes
2answers
91 views

How to route messages between clients using a central server in Python

I've got three Raspberry Pis sitting around. I want 2 of them to be able to chat while the 3rd routes the messages (acts as a server between them). The general flow of events should be something like ...
2
votes
1answer
181 views

How do you make decorators as powerful as macros?

Quick background: I am designing a Pythonic language that I want to be as powerful as Lisp while remaining easy to use. And by "powerful", I mean "flexible and expressive". I've just been introduced ...
-2
votes
0answers
27 views

studying parallel programming python [migrated]

import multiprocessing from multiprocessing import Pool from source.RUN import* def func(r,grid,pos,h): return r,grid,pos,h p = multiprocessing.Pool() # Creates a pool with as many workers ...
0
votes
3answers
86 views

How to convert this recursive problem to iterative? Line Simplification algorithm fails to run due to Maximum Recursion Depth being hit

I am implementing the Douglas, Peucker's Line Simplification algorithm in Python. I started with this implementation. However, it fails to run in Python due to Maximum Recursion Depth being hit. How ...
0
votes
0answers
5 views

alternate method of iterating than os.walk [migrated]

recently, I became tired of how slowly os.walk seems to run (really, it should be called os.crawl), and made something recursive which moves much faster. I was using it to take directories i wanted ...
0
votes
0answers
25 views

Intermediate table with generic foreign key [migrated]

I'm trying to replace a field in an intermediate table with a generic field. Using Django 1.6, MariaDB/MySQL. I have a class (PermissionGroup) that links a resource to a group. Works fine. However I ...
0
votes
1answer
63 views

Running Python script in background on Mac

I have a Python script that counts the number of file in a folder, and if the number of files exceeds 10 then it creates a popup window to ask the user to clean up the folder (I use tkMessageBox). ...
0
votes
1answer
131 views

Is Lambda Still Supported In Python?

Only one or two years ago, I remember reading Python constructs that would be removed from Python -- reduce was one of them -- and other constructs that would be emphasized like comprehensions and ...
0
votes
0answers
4 views

How to write and run more than one code in Python IDLE? [migrated]

How do you get that code, see below, run in IDLE? I am stuck in my course right now and I could not find an explanation. I know how to run in IDLE just one "def" or code, pressing F5, write e.g. ...
-1
votes
0answers
17 views

Buildozer fails to create apk with standard settings [migrated]

I downloaded the VM provided by Kivy for packaging android apps. This VM includes Android NDK, SDK, Py4A and other dependencies. I used it successfully to build some test apps. Then, in the same VM I ...
-2
votes
0answers
28 views

How to merge my code with other existing code? [duplicate]

i make some improvements to my friend´s code, now i need to add my code to someone else´s code that hasn´t any documentation nor test functions. How to merge my code with my team´s code without ...
0
votes
0answers
6 views

Vlookup in python [migrated]

I am new to python and leaning as fast as possible. I know how to do my problem in bash and trying to work on python. I have a data file (data_array.csv in the example) and index file, index.csv, at ...
1
vote
1answer
125 views

Should I separate a web api from the webserver?

Lets say I'm building a site similar to this or Quora (or some arbitrary blog-like site). I need a real-time component that will be using web-sockets/long-polling to notify the user of new posts, ...
8
votes
5answers
899 views

Are there technical limitations or language features that prevent my Python script from being as fast as an equivalent C++ program?

I'm a long-time Python user. A few years ago, I started learning C++ to see what it could offer in terms of speed. During this time, I would continue to use Python as a tool for prototyping. This, it ...
1
vote
2answers
44 views

Django CBVs vs FBVs

For creating a large Django project with many apps, my first initial thought was to used Class Based Views (as the Django tutorials seem to emphasize). However, I noticed that due to a lot of the ...
3
votes
1answer
255 views

Good practice for returns in Python

I was recently working on some prototype code in Python. The code worked great, then I realized that I needed a little more feedback from one of my functions so I changed the return statement from ...
0
votes
2answers
102 views

the perils of using eval() for dynamic object creation — is this a valid argument in a consenting-adults culture?

I've read on stackoverflow explicit warnings against using eval() to create objects. The reason that seems to be given is that malicious code could be injected and blindly created objects could ...
0
votes
2answers
91 views

Need help understanding a recursion example in Python

Python is my first programming language, and I'm learning it from "How to Think Like a Computer Scientist". In Chapter 5 the author gives the following example on recursion: def factorial(n): if n ...
-2
votes
0answers
33 views

subprocess.Popen.communicate not effient with large data sets? [migrated]

I understand communicate() will wait for the process to finish, store data in memory buffer and return. I was thinking the below code will not be efficient as I want to query all interesting rpms and ...
0
votes
0answers
42 views

Checking that a function is only run from __main__ in Python

I often end up with code files that can either be imported or run as __main__. It's easy to handle this by checking if __name__ == '__main__'. But sometimes if my main function gets too big I split ...
4
votes
1answer
233 views

Why don't Python and Ruby make a distinction between declaring and assigning a value to variables?

Two of the most popular dynamically typed scripting languages, Python and Ruby, do not make a distinction in syntax between the declaration of a variable and assignation of a value to it. That is in ...
4
votes
2answers
230 views

What are the key differences between Java's and Python's OOP support? [closed]

The only language I've ever used is Java. I like it a lot but decided it's time to learn another language :) . I'm interested in learning Python. It seems like a good choice because it's partly ...
0
votes
1answer
117 views

Javascript function should call python logic in django web development without additional triiger

I have been trying to solve this problem for sometime now. This is regarding django web development. I have an HTML page which has a Javascript function to upload an image file from the users local ...
3
votes
1answer
58 views

optimize human-readable database with index

i need to store a large amount of data - about 10 million entries of the format unique hash (64 chars), value 1 (5 chars), value 2 (9 chars) i will be reading and deleting (but not updating) this ...
2
votes
2answers
101 views

where exactly should python business logic be placed in django

I have just begun to learn Django/Python/Web Development. This problem has been troubling me for a while now. I am creating an application with multiple templates in Django. I have a views.py which ...
-4
votes
2answers
198 views

A newbie in python trying to learn [closed]

Am trying to learn how to program before i go to uni and i stumbled upon a question which i have been unable to do. In the function write code to input two integers m and n and calculate and display ...
0
votes
0answers
23 views

How to deal with multiple output modes of multiple types?

Note: The business domain being a bit complicated to explain, I replaced the names of actual classes by more illustrative examples. I'm writing an application in which the business layer returns a ...