0
votes
2answers
91 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 ...
-1
votes
1answer
101 views

Python Source Code for Learning Style [on hold]

I've been making an effort to gain a more advanced understanding of Python, and several people and sources have recommend that I go find open source Python projects and look at how they're written. ...
0
votes
2answers
52 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
17 views

ajax request not being called from javascript function in django [migrated]

This is a full flow which has to be taken care here. I am coding in Django/Python/Web Development. I have an html page which has got a dummy button which is triggering all the functions that I want ...
-1
votes
0answers
41 views

Hi, is posible to create a Python code for Face Recognition(OPENCV), using MySQL as database? [closed]

i want to create a Face Recognition code, using Python(OPENCV) and store their values on MYSQL database, then with other code, compare both. I don't want in my database, images, only values and ...
0
votes
0answers
24 views

What is a good language to do both CSV read/write and XMLHTTP requests? [closed]

I'm looking for a language to use that has good libraries for reading and writing a CSV and for performing XMLHTTP requests. Right now, I'm looking at Python and Perl as my top choices. I know PHP ...
0
votes
0answers
6 views

How to determine the newly closed file within a continuous audit log rotation? [migrated]

I am attempting to find the best way to determine when the second file (of a matching criteria) is created. The context is an audit log rotation. Given a directory where audit logs are created every ...
-2
votes
0answers
33 views

Develop own MVC for Python (User defined custom framework) [closed]

I have been creating many PHP applications and have also developed many applications based on the custom MVC that I have developed. When I started learning PHP MVC, I learned it from JREAM MVC for ...
0
votes
0answers
13 views

remove stop words from arabic corpora [duplicate]

how to remove stop words from corpus in Arabic language using python? i tried to write code for that but the problem appear they couldn't find matching with stop words which read from other text file. ...
0
votes
0answers
32 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
204 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 ...
-3
votes
0answers
25 views

python programming error - not printing out correctly [closed]

I have this code that is supposed to print out the least occurring vowel when a word is inputed, but it doesn't print out a vowel and the least value. here is my code: #Program to count the least ...
4
votes
2answers
194 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
0answers
20 views

How to extract the attributes of a function of an instance passed as a function? [migrated]

How can I extract the attributes of the "SimpleSubscriber object from the following method object? <bound method SimpleSubscriber.process of <__main__.SimpleSubscriber object at ...
0
votes
1answer
81 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 ...
-1
votes
0answers
33 views

removing stop words from unicode annotated arabic corpus in puthon [closed]

i want to remove stop words from Unicode annotated corpus in arabic language i have read the text from file but i couldnt find matching with stopwords? any one can help me please? Note: i'm using ...
0
votes
0answers
8 views

Python logging wont shutdown [migrated]

I have been learning the python logging module but have been having problems getting the logging to shutdown after it's done. Here is an example - import logging log = logging.getLogger() ...
3
votes
1answer
52 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
69 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 ...
-3
votes
2answers
185 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
19 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 ...
-1
votes
0answers
15 views

How to import mysql modules in Python? [migrated]

As you are aware, I am a complete noob on this. I am trying to use this reusable class to connect to mysql Python Connection with MySQL But whenever i try to run the python I am getting Traceback ...
0
votes
0answers
24 views

Abstracting away scrapy's parse() method - good idea or not?

We use Scrapy quite a bit at work, and recently it's been decided that the spiders we write with it are all too 'different' in the way they're written and could use a little bit of 'standardization' ...
2
votes
2answers
75 views

subclass reference to another subclass

Imagine I have the following code: class A: pass class B(A): pass class C(A): def __init__(self): self.b = B() Is the above code correct in terms of correct inheritance? I ...
0
votes
0answers
13 views

Defining property and find substitution for copy function of python in cython

I want to cythonize a code in python to speed up the code. In the following you can see my attempt to make my python class understandable for cython: import numpy as np cimport numpy as np ctypedef ...
2
votes
1answer
55 views

Python API: Extension Module or Pure Module

We have a C++ application, with C++ interfaces changing regularly during development. We also have a C API which is designed to be stable in spite of such changes; the C API is tighly focused on ...
1
vote
1answer
59 views

Adding new functionality to all of shelve.Shelf's subclasses in Python

In order to avoid the overhead associated with the shelve module's writeback option I'm interested in putting together a shelf class that only accepts hashable values, with hashability being a proxy ...
-2
votes
0answers
20 views

Syntax error in visual studio [migrated]

I started Udacity's Intro to Comp Sci course today, and generated this code at the end of the first lesson: page = '<a href="http://udacity.com">Hello world</a>' start_link = ...
1
vote
2answers
122 views

Can a version of Python's shelve module that knows when its entries have been modified be written in any programming language?

shelve is a Python module that makes it easy to persist a Python dictionary to disk (under the right conditions). The documentation for shelve gives this example to demonstrate one of the pitfalls of ...
10
votes
2answers
167 views

Early attempt to remove Python GIL resulted in bad performance: Why?

This post from Python creator, Guido Van Rossum, mentions an early attempt to remove the GIL from Python: This has been tried before, with disappointing results, which is why I'm reluctant to ...
-1
votes
0answers
100 views

Python service oriented application vs. non-service one

I'm looking forward starting a new web application with Python and I have some doubts before starting. My idea is building a web application and later maybe an Android/iOS mobile app. I am considering ...
1
vote
1answer
66 views

Using class like an object in Python

I am learning from Learn Python the hard way where I have come across a study drill where they want to know that whether a class can be used like an object. As I have experimented: class A(object): ...
0
votes
1answer
58 views

Measuring performance of a network simulator?

I have written a python program to test a new network routing algorithm, that uses a Content Centric Network Approach for handling requests (CCN), where the CCN router keeps 3 data structures: A ...
0
votes
0answers
28 views

API providing function to be run in a thread vs. thread that runs this function

I'm writing a Python library which exposes a certain event listener interface. The user can register callbacks to handle different types of events. There is also a function which handles the actual ...
3
votes
2answers
74 views

Object identification in Python

In learning Python, I found that when two "names" (or "variables") are assigned to the same value, both of them point to the same memory address. For example >>> a = 10 >>> b = 10 ...
0
votes
1answer
102 views

How to avoid Memory Error

I am working with quite large files (pytables) and I am having problems with the Memory Error when I try to load the data for processing. I would like some tips about how to avoid this in my python ...
2
votes
1answer
66 views

Random forest ML algorithm suitable for use on cluster based HPC?

I need help in identifying a better algorithm. I have developed a script using pythons scipy package to analyse a rather large model that I wish to solve. The model contains over 12GB of data ...
-2
votes
2answers
55 views

Is the tool pywebsocket suited for production? [closed]

Is it a good idea to use pywebsocket in a production environment, since it is so widely used, but their google developer page states "pywebsocket is intended for testing or experimental purposes". ...
2
votes
0answers
68 views

The inheritance argument of zope.interface (providedby vs isinstance)

What limitations does inheritance of an interface through an abstract base class present that are addressed by zope.interface? In the following talk given in 2010 by Jeff Rush about interfaces, at ...
-1
votes
2answers
45 views

Minima of a convex list using binary search [closed]

A list is strictly convex if its elements first decrease then increase. How can I write a function in python that accepts a convex list and returns its minima in time complexity O(log(n)), n being the ...
1
vote
2answers
79 views

How would I change the precision of a variable in Python?

I'm working on a 2D-physics engine, and I need a certain variable to be precise only to the hundredths. Are there any methods for basically shaving off all of that unneeded precision? I have tried ...
1
vote
1answer
91 views

Is it possible to have a mutable type that is not garbage collected?

I'm wondering if such a thing can exist. Can there be an object that is mutable but not flagged as garbage collected ( specifically, tp_flags & Py_TPFLAGS_HAVE_GC ) I have a C++ struct-like ...
-3
votes
1answer
156 views

Is it recommended to use more than one language at a startup? [closed]

I work for a mobile startup where, for historical reasons, our chosen language was C#. I was recently assigned to a small project to build a tool that would be used by us internally. When I explained ...
0
votes
1answer
280 views

Why isn't there a python compiler to native machine code?

As I understand, the cause of the speed difference between compiled languages and python is, that the first compiles code all way to the native machine's code, whereas python compiles to python ...
2
votes
1answer
69 views

Single python file distribution: module or package?

Suppose I have a useful python function or class (or whatever) called useful_thing which exists in a single file. There are essentialy two ways to organize the source tree. The first way uses a single ...
0
votes
0answers
55 views

Converting large files in python

I have a few files that are ~64GB in size that I think I would like to convert to hdf5 format. I was wondering what the best approach for doing so would be? Reading line-by-line seems to take more ...
0
votes
1answer
64 views

Storing primary keys of objects in Redis and then querying them in Postgres through Django

This is probably my second time posting in programmers. I'm usually on stackoverflow but this question is more fit for the community here. All suggestions, advice and insight on this matter is ...
7
votes
5answers
310 views

Algorithm for flattening overlapping ranges

I am looking for a nice way of flattening (splitting) a list of potentially-overlapping numeric ranges. The problem is very similar to that of this question: Fastest way to split overlapping date ...
8
votes
1answer
394 views

Refactoring a 1500 LOC method that only builds the graphical UI [closed]

I'm currently scratching my head over how to refactor a method that basically only builds the UI. The method is more than 1500 lines of code (LOC) long - and counting. It has grown, there was no plan ...