python

how to change [1,2,3,4] to '1234' using python ..

i want get a string from a list thanks ...

What does this python line mean?

abc = [0, ] * datalen; "datalen" is an Integer. Then I see referencing like this: abc[-1] Any ideas? ...

How to retrieve the process start time (or uptime) in python

How to retrieve the process start time (or uptime) in python in Linux? I only know, I can call "ps -p my_process_id -f" and then parse the output. But it is not cool. ...

why egrep's stdout did not go through pipe?

Hi, i got a weird problem regarding egrep and pipe I tried to filter a stream containing some lines who start with a topic name, such as "TICK:this is a tick message\n" When I try to use egrep to filter it : ./stream_generator | egrep 'TICK' | ./topic_processor It seems that the topic_processor never receives any messages However, wh...

Pass logger instance to class

Hi Guys, I'm using a open-source Python library in my project. This library logs a lot of information using the logging class. ...but I can't see the output or log it to file. I know that i would have to create a logger instance and add a file-handler or a console-handler to it but how can i pass this logger instance to the class? Here'...

how to get firefox address bar url for python (pywin32)

hi; i need grab to firefox address bar. how to get address bar url for python ? (i need second part other browsers chrome and safari grabbing address bar but firefox is urgently). Thanks. ...

How to Implement a Binary Tree in Python

Which is the best data structure that can be used to implement Binary Tree in Python? ...

Python + GPG (edit-key change password)

Hi to all I'm looking for a gpg Python library that let me change password for my key. I saw python-gnupg but there aren't that function :( Anyone can help me please? If is possibile i wish have also some examples from docs ...

Python SOAP web-service client access through authenticated proxy, How?

Hi, I've been trying to write a Python client to access a SOAP webservice through our companys authenticated proxy server using the SUDS lib. The proxy uses basic username:password authentication not NTLM and I have been able to get basic downloads working through it using URLLIB2 like this: passmanager = urllib2.HTTPPasswordMgrWithDef...

Numpy: Creating a complex array from 2 real ones?

I swear this should be so easy... Why is it not? :( In fact, I want to combine 2 parts of the same array to make a complex array: Data[:,:,:,0] , Data[:,:,:,1] These don't work: x = np.complex(Data[:,:,:,0], Data[:,:,:,1]) x = complex(Data[:,:,:,0], Data[:,:,:,1]) Am I missing something? Does numpy not like performing array functi...

Python / SQLite - database locked despite large timeouts

I'm sure I'm missing something pretty obvious, but I can't for the life of me stop my pysqlite scripts crashing out with a database is locked error. I have two scripts, one to load data into the database, and one to read data out, but both will frequently, and instantly, crash depending on what the other is doing with the database at any...

Python recursion with list returns None

def foo(a): a.append(1) if len(a) > 10: print a return a else: foo(a) Why this recursive function returns None (see transcript below)? I can't quite understand what I am doing wrong. In [263]: x = [] In [264]: y = foo(x) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] In [265]: print y None ...

Django templates check condition

If there are are no values in the table how can should the code be to indicate no name found else show the drop down box in the below code {% for name in dict.names %} <option value="{{name.id}}" {% for selected_id in selected_name %}{% ifequal name.id selected_id %} {{ selected }} {% endifequal %} {% endfor %}>{{name.firstname}}</o...

Does python have one way of doing things?

I have always seen in python articles/books that python is simple and it has only one way of doing things. I would like someone to explain to me this concept keeping in mind the example below, if I wanted to get the min and max values of sequence I would do the following; seq=[1,2,3,4,5,6] min(seq) #1 max(seq) #6 but I can also do t...

Parsing <geo:lat>, <geo:long> tags value using feedparser in python!

Hello, I am using feedparser for parsing from XML file.But I couldn't parse <geo:lat>, <geo:long> tags using feedparser from that file! Do you people have any idea how I can parse those tags using feedparser in python? Thanks in advance! ...

appcfg.py upload_data entity kind problem

Hi, I am developing application on app-engine-path and I would like to upload some data to datastore. For example I have a model models/places.py: class Place(db.Model): name = db.StringProperty() longitude = db.FloatProperty() latitude = db.FloatProperty() If I save this in view, kind() of this entity is "models_place"...

MacPorts for Python on Leopard

I haven't found any concrete language on the terminal commands for installing python 3.1 on Leopard using MacPorts. I already have 2.5.1 on Leopard by way of Apple. I don't want to mess with this version & I think having the newer version of Python running from my opt/local file would be better. Also SQL3 comes packed with the standard P...

How to calculate the occurrences of a list item in Python?

Given an item, how to count its occurrences in a list in Python? ...

Why would Django fcgi just die? How can I find out?

I'm running Django on Linux using fcgi and Lighttpd. Every now and again (about once a day) the server just dies. I'm using the latest stable release of Django, Python and Lighttpd. The only thing I can think of is that my program is opening a lot of files and executing a lot of external processes, but I'm fairly sure that side of thing...

Problem building a complete binary tree of height 'h' in Python

Here is my code. The complete binary tree has 2^k nodes at depth k. class Node: def __init__(self, data): # initializes the data members self.left = None self.right = None self.data = data root = Node(data_root) def create_complete_tree(): row = [root] for i in range(h): ...