Questions for python


Python numpy loadtxt fails with date time

I am trying to use numpy loadtxt to load a csv file into an array. But it seem i can't get the date time correctly loaded.

Python, releasing memory for real, possible? Could it be because I'm using named tuples?

The code I've inherited is too nested to try and paraphrase here. Basically I have a class method defined that makes a copy of a complex graph structure (e.g. graph=NetworkX_graph.copy()) and retur...

Python: Perform ations repeatedly over a time interval, as long as a condition is true

So I'm trying to do this (access a file on a website, read its contents and perform actions until the content says to exit. The precondition being it has to wait x seconds before accessing the webs...

C++ API as an Python Extension Module

Can APIs written in C or C++ always be made into a library, given source code, and consequently be called from Python, due to the intrinsic callable nature of an API?

How do I parse a text file in dictionary form and put it into a dictionary in python?

I want to take a text file that contains something of the form:

How to setup setuptools for python 2.6 on Windows?

Is there any way to install setuptools for python 2.6 in Windows without having an .exe installer?

Python install issue on Mac OS X

I have been using the standard python that comes with OS X Lion (2.7.2) but I wanted to build a UCS-4 version to handle 4-byte unicode characters better.

Convert a list of tuples(edges) into list of longest paths in Python

Please look at the fig. below. As a part of my project, I am in need to convert a list of edges of a forest into a list of unique longest paths. The longest paths are actually paths which connect any

How to get the “next” item in an OrderedDict?

I'm using an OrderedDict to random access a list, but now want the next item in the list from the one that I have:

Inexplicable NameError with command-line Python

I am working my way through the excellent 'Python The Hard Way' and copied the following code into a file called

How to make a random but partial shuffle in Python?

Instead of a complete shuffle, I am looking for a partial shuffle function in python.

Django FormWizard and Admin application

I have a series of forms that I need a user to complete in sequence, which is perfect for the formwizard app. However, I've some need of the admin application also and would like to set the whole t...

How to open two reports in a single click in OpenERP?

I have a wizard (memory object) which selects a partner and when I click on the submit button, I need to print two reports: one report prints the sale orders related to the partner and the other re...

how to use Content_type, video/mp2t in http response?

I am preparing response to a http request to send video and receiving error: Broken Pipe

How to merge notifications with a common title in pynotify?

How can I tell a pynotify.Notification object to merge with another that has the same title?

How do you create nested dict in Python?

I have 2 csv files. First one is data file and other one is mapping file. Mapping file has 4 columns Device_Name GDN Device_Type Device_OS

How to know if message was published to a queue using rabbitmq routing features

I've been working on a project which uses rabbitmq to communicate. Recently we discovered that it would be much scalable if we used rabbit routing feature. So basically we bind the queue to several

Model measurement and error in NumPy

I'd like to try the SciPy suite instead of Octave for doing the statistics in my lab experiments. Most of my questions were answered here, there is just another thing left:

How do I determine if an email is Base64 encoded?

I am having difficulty determining if the body of a text email message is base64 encoded.

Tkinter Integral Symbol

I want to be able to pack an integral symbol into a label like this:

In Python, how do I check if a variable exists?

If "x" exists, then print "x exists".

Trying to build a metronome in kivy - Event loop management

since I haven't found anything here, I try and put my Question.

CherryPy, Threads, and Member Variables; potential issues?

Let's say I have the following simple class:

Replace comma by newline using django

I am using django and python.

Python - changing the output when querying my CSV file

I have been tasked to create a program in Python which searches through a CSV file; a list of academic papers (Author, Year, Title, Journal - it's actually TSV).

Play a Sound with Python

What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems over...

Remove the newline character in a list read from a file

I have a simple program that takes an ID number and prints information for the person matching the ID. The information is stored in a .dat file, with one ID number per line.

Integer (representing a sequence of bits) reinterpretation as Character Array in Python

I've written some C code that I would like to port to python, as I feel python is a better 'concept' language.

Proper layout of python packages for a Graphical User Interface (GUI)

On the project I'm currently working on (a GUI for a testing system) I'm required to write base classes for all graphical objects and inherit these objects into the class which utilises the graphical

How to handle actions in Django/Tastypie?

I'm writing a web app which purpose is to act as an intermediate layer between an application and Amazon's API. I figured a REST style API would fit and chose Tastypie to ease the implementation.

Python import as global name not defined

I have an application that runs on Postgres & Mysql. Each program checks to determine the database and then imports either postgres_db as db_util or mysql_dt as db_util. All works well when c...

How do I subclass pyCLI's

The documentation is really vague about subclassing the CommandLineApp, only mentioning one example:

Find all nodes from an XML using cElementTree

Is there a way to find all nodes in a xml tree using cElementTree? The findall method works only for specified tags.

Scripting language choice for initial performance

I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution...

Converting a string of 1's and 0's to a byte array

I have a string with a length that is a multiple of 8 that contains only 0's and 1's. I want to convert the string into a byte array suitable for writing to a file. For instance, if I have the st...

How to get around “sys.exit()” in python nosetest?

It seems that python nosetest will quit when encountered "sys.exit()", and mocking of this built-in doesn't work. Thanks for suggestions.

Cannot parse the date in Python

I need to parse date and time. Here is what I've got:

Using Blobstore Python API over HTTPS generates 405 error when redirecting back

Don't know if it's I'm doing it wrong or if there's a bug (I would think so, seen others having the same problem) in the blobstore.create_upload_url method.

Power spectral density of a signal with gaps?

Does anyone know if it is possible to find a power spectral density of a signal with gaps in it. For example (in matlab syntax cause that is what I'm familiar with)

How to click a link in WebDriver using Python?

<tr><td class=wb><a href="javascript:void(fight())" style='text-decoration:none'><b>Click here!</a></td></tr>

How to read a whole file in Python? To work universally in command line

How to read a whole file in Python? I would like my script to work however it is called

Checking input is a number in python

I need help, my program is simulating the actions of a dice. I want to an error check to occur checking if the input string is a number and if it isn't I want to ask the question again again until he

Using default arguments before positional arguments

I am learning to use positional arguments in python and also trying to see how they work when mixed up with default arguments:-

How to use SQLAlchemy to seamlessly access multiple databases?

Lets say I created a product database system for different departments of my company. Each department has its own PostgreSQL-databse-instance for various reasons. The schemata of the databases are ...

Comparing output to a list/array

I consider myself a very beginner at python(and programming in general!), but I am working though "learn python the hard way" by Zed A Shaw and slowing picking things up.

Extracting text from HTML file using Python

I'd like to extract the text from an HTML file using Python. I want essentially the same output I would get if I copied the text from a browser and pasted it into notepad.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.