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
0answers
169 views

Embed Python into Lua?

I've found a lot of things about embedding Lua into Python, but I was wondering is is possible to embed Python into Lua? I've searched for a while, and couldn't find anything on it, so maybe some of ...
2
votes
1answer
358 views

Python multithreading and utilizing modern processors - what is the downside?

CPython implementation detail: In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome ...
1
vote
2answers
118 views

Listener, logger, plotter - what threading arcitecture to choose for this?

I am constructing a program that does several things. Listens to a port. Every second a string is received When new data is received, it has to be logged. No errors or skipped entries are allowed ...
0
votes
2answers
520 views

Languages implemented in Python?

AFAIK, Scala and Clojure are implemented in Java and Java is implemented in C. I suppose that many or most languages are implemented in C, for instance Perl, Python and SQL. I don't know much about ...
3
votes
4answers
452 views

How to elegantly work with a lot of print functions?

I'm working on a Python project that is executed on a terminal (or console) for which I am planning to implement a GUI. I did not major in CS so I really have no idea how to effectively design a ...
2
votes
1answer
164 views

In Python, what is the proper testing structure for packages containing packages? [closed]

Which is the preferred test package structure for packages containing subpackages: Tests in Subpackages? a/ __init__.py b.py c/ __init__.py cc.py test/ __init__.py ...
4
votes
4answers
228 views

Design: multiple algorithms on the same large data sets

I have several algorithms that I would like to test against the same data sets to compare their results. I don't know how to design it so there is maximum readability and maximum efficiency. I have ...
0
votes
1answer
129 views

What is the preferred object to store this type of data structure

I was in a conversation with someone who codes for me. He was frustrated with my approach to a particular problem. I am entirely self taught and very pragmatic - I am not a professional developer ...
5
votes
4answers
464 views

How can I stop myself overwriting member variables with 'new' ones?

The bulk of my programming experience has been with C++ and (shudder) FORTRAN (I'm a scientist not a programmer as such, but I do my best). I've recently started using python extensively and find it ...
12
votes
2answers
966 views

Design decision - why generate <p> without </p>?

tl;dr Some widely used programs, which generate html, will only generate opening paragraph tags, and not closing ones, assuming that the browser will properly close paragraphs. On the face of it, it ...
2
votes
2answers
475 views

Python dynamic attributes creation, a blessing or a curse?

Consider this code: >>> class Foo(): pass ... >>> foo = Foo() >>> foo.a = 'test' >>> foo.a 'test' One can just override __setattr__ to make attributes ...
0
votes
2answers
142 views

Factory for arrays of objects in python

Ok, the title might be a little misleading. I have a Window class that draws widgets inside itself in the constructor. The widgets are all of the same type. So I pass a list of dictionaries, which ...
10
votes
5answers
2k views

Is it considered Pythonic to have multiple classes defined in the same file?

In working with python for the first time, I've found that I end up writing multiple classes in the same file, which is opposed to other languages like Java, which uses one file per class. Usually, ...
0
votes
0answers
46 views

Is it possible to write plugins for cPanel in Python?

I'd like to know if it is indeed possible to to write plugins for cPanel in Python. While checking cPanel's site, it mentions both PHP and Perl. Also this question on their forums says it's possible ...
3
votes
1answer
364 views

Is Python Cookbook for python 2.4 applicable to python 2.7.5?

My college has a course on Introduction to programming using python and we are using Python 2.7.5. I would like to know if it will be helpful to read Python Cookbook which is for python 2.4? There ...
0
votes
1answer
80 views

Code execution within delimiters

Is there any way I can execute a block of code in a loop, like so: [ some code goes here ] Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.: [the user can create ...
4
votes
4answers
885 views

Can a method that must be overridden be considered private?

Suppose I have a class C with a method f() which is meant to be used only within C's implementation, but which should be overridden by C's subclasses. Is it reasonable, or "pythonic", to consider it ...
0
votes
1answer
493 views

Python datetime timedelta attributes

In the python datetime module, timedelta objects take weeks, days, hours, minutes, seconds, and microseconds as arguments upon instantiation. However, after the timedelta is created, the only two ...
3
votes
5answers
788 views

When should use of database be preferred over parsing data from a text file?

I was making a Python program to measure the growth of codereview.SE. My approach was to get the "Site stats" shown on the front page and store them on my hard drive. I plan to do this once every day. ...
14
votes
5answers
1k views

Is a well written documentation a good enough reason for learning a programming language?

I am learning Python currently which wasn't part of my college curriculum. I was asked in an interview why I chose Python and I replied that it is easy to learn and the documentation is very well ...
3
votes
1answer
447 views

Web app outgrowing current framework

I have quite a bit of experience with using Django for websites and so when I started a new project I naturally chose to use Django for it. Everything went well for a time but now the application is ...
1
vote
2answers
219 views

How fast should a Python factoring script be?

Just how efficient is "good enough" for all intents and purposes? I wrote a script to simply list off all numbers that divide into an input, x, as pairs (i, n//i) and was just curious how efficient I ...
1
vote
5answers
872 views

Is SQLite a sensible option for data logging?

I am trying to setup a small data-logging application under linux. The data arrives via serial port, and from there it should be pumped to logging and to graphical display. The logging functionality ...
2
votes
3answers
4k views

1h coding test for recruitement interview, is it a common practice [closed]

I received an email for a web company position I applied to. They are asking me to provide a 1h time slot, so that they can make me pass a coding test. They'll send the test, start the time, and 1h ...
1
vote
3answers
320 views

Maintaining log stream after file name change

I'm trying to log to a file and move it about every 30 seconds. I'm using the os.rename function (which I do from a supervisord process) in python to move the current log to a timestamped log (which ...
3
votes
1answer
960 views

Is modifying an object's __dict__ to set its properties considered Pythonic?

I have a class that inflates objects from rows found in a database (or another source, e.g. MongoDB, a CSV file, etc.). To set the object's properties, it does something like ...
2
votes
2answers
6k views

What should I learn to be backend web developer? [closed]

I want to be a web developer and because I don't want to get into designing (and stuff like that) so I thought I should become a backend developer (also more suited because of my course i.e. b.tech in ...
0
votes
1answer
222 views

Code design: is this specific case of monkeypatching in python acceptable?

I'm using python to do some research tasks. I have a class hierarchy for "tools", where each object is an instance of a particular tool. They all share some functionality and have many similarities in ...
11
votes
3answers
570 views

Do I need to understand the Internals of a programming language?

I am beginner to Python and I really like it so far. One question that comes to my mind very often is if I need to understand and therefore learn the Internals of a programming language (as in my case ...
1
vote
1answer
1k views

Encoding a bash script for use in Python

I am writing some code in Python which checks for the validity of a license key after polling a server. If it is valid then the Python program in turn runs some bash scripts. How to create a ...
0
votes
0answers
64 views

How to implement a 'before' hook for RequestHandler in the webapp2 with conditional response?

Need to do some authentication checks before deciding what content to display. Ideally, I'd like to have a restrictive base handler, that would implement the "before" hook that could show an ...
4
votes
1answer
160 views

Class instance clustering in object reference graph for multi-entries serialization

My question is on the best way to cluster a graph of class instances around specifically marked objects (objects are the graph nodes and the references to each other are the directed edges of the ...
1
vote
1answer
495 views

Why are methods considered the class attributes in Python?

I read in a book that both methods and fields are considered the attributes of a class in Python. However, recently I was told by a friend of mine that methods may not be considered the attributes of ...
0
votes
0answers
133 views

Why does pkg_resources not find bloom in my virtualenv?

I'm trying to hack on the ROS bloom build system (https://github.com/ros-infrastructure/bloom). After I've made some edits, I build it and install it to a virtualenv to test using python setup.py ...
2
votes
2answers
220 views

Start by Teaching Classes [closed]

In every class, and every book I have seen regarding programming, classes are held off. They are thought to be confusing and strange. I certainly had issues with them. But in object orient ...
1
vote
5answers
514 views

Decoupling Components - Design

I have created a a number of non-trivial scripts in Python that do some long running reporting. At first these reports started off as scripts with a config file. Then I added in the a database ...
1
vote
1answer
182 views

Finding possible positions for rectangle in a 2-d array

Well, the title is not very appropriate, please read on (I couldn't get a better one). Note: Using Python 2.7, but an algorithm will help too. I'm making a side scroller game, in which I am ...
2
votes
2answers
269 views

How to structure a class in python

I have come to python from C++ (I also know a little Java). I am writing code to exercise a server so I basically use http methods to send a load of requests to the server. As part of my code I ...
1
vote
2answers
171 views

Specifying options “hard coded”, in an interpreted language

In a language like Python or JavaScript (NodeJS), is there anything wrong with defining "the configuration file" as a file which essentially hard-codes the configuration settings? For example: ...
0
votes
1answer
232 views

How to format this line according to PEP 8? [closed]

I'm trying to adhere to PEP 8, with a 78 character limit on the length of my lines. I have the following statement: startTime = time.strptime(request.GET.get('st', (dt.datetime.now() - ...
2
votes
1answer
245 views

Python - Importing modules and visibility

Consider the following code: a.py import os def print_rand(): print os.urandom() And another module: b.py from a import * In this code, I end up with an os variable getting imported from ...
1
vote
2answers
438 views

How can I work on multiple programming languages at same time [duplicate]

It always happen to me that if I leave the stuff for 1-2 months I forget the stuff. 5 months back I had symfony project and I did that. At that time I was very much confident that I can do any ...
3
votes
1answer
196 views

What is the advantage of determining scopes statically and using them dynamically in case of Python?

Firstly let me clarify that I know C and am learning Python. So my OOPS is kind of bad. I was reading the official tutorial and found this Although scopes are determined statically, they are ...
2
votes
1answer
110 views

Ported Functions Licensing

I have found several functions in python 2.7.2 to be very useful and I recreated them in C++ for my own uses. How do I properly give python credit for them? Do I even have to? I never actually looked ...
-1
votes
2answers
221 views

Starting Development with Python [closed]

I'm currently a beginning developer (3 years). I have been mainly doing Web Development for as long as I have been developing. This is my comfort zone when it comes to programming. I like both ...
0
votes
1answer
475 views

Restart button in Python

I am having trouble with python. I am making a text-based adventure game, and I am trying to make a restart function when you die. I am trying to count deaths by doing deaths = deaths + 1 whenever you ...
2
votes
0answers
110 views

How to restructure Python frameworks [duplicate]

I just joined a group of five developers (non-professionals) working on a medium sized Python framework (> 50 modules, > 10.000 lines of code). The project has no documentation whatsoever and there ...
0
votes
1answer
176 views

Can You Use 2 Python Modules Issued Under LGPL and BSD License in a Program?

I'm making a drawing program as my first open-source program merely to get a taste of the open-source community. To make said program, I am using Python 2.7. I'm using the following modules: EasyGUI ...
1
vote
3answers
226 views

What is the best way to store configurations of shell/script code to execute later?

I am working on a tool (Python, may or may not be important) that will allow a user to maintain a configuration file containing arbitrary shell and/or language code to be executed on particular events ...
4
votes
1answer
653 views

How to design a composite pattern in Python?

The concept I'm programming an interface over pygame as a personal project, to make the creation of games easier for me. So far I managed to design an architecture that behaves like this : Objects ...