python

How to get download progress info from I.D.Manager to python?

hi fellows, im working a project lately to get download progress info remotely when im away. i googled a bit but i couldnt find any useful info. on this issue im using Internet Download Manager. please help :/ i appreciate any suggestions im thinking about making software with python but Also C is Ok. if there is a solution ...

What situation is PHP, Python, Java, C++, Erlang better in ?

In my life I have learned many program languages: C, C++, python, java, assembly, javascript, php, etc but some times I don't know what languages is better for some projects. So I want to know, in your opinion: what situation is python better in ? and Why ? what situation is c++ better in ? and Why ? what situation is php better in ?...

Python: OverflowError: math range error

I get a Overflow error when i try this calculation, but i cant figure out why. 1-math.exp(-4*1000000*-0.0641515994108) ...

How come a document in MongoDB sometimes gets inserted , but most often don't?

con = pymongo.Connection('localhost',27017) db = con.MouseDB post = { ...some stuff } datasets = db.datasets datasets.insert(post) So far, there are only 3 records, and it's supposed to have about 100... ...

Django Apps extendability - How to make your django apps easily extendable?

What are your best practises for making your django application easily extendable for other developers? What are your approaches for enabling other to overwrite your views forms templates models classes In a way that enables a healthy environment for extensions to work well together? ...

Split Python list into several lists based on index

So I've got a string of bytes which represents cubes in three dimensions. The coordinates are ordered like this: [x0y0z0, x0y1z0, x0y2z0, ..., x0y127z0, x0y0z1, x0y1z1, ..., x15y127z15] I'd like to split this into 128 lists, one for each Y coordinate. This code already does that, but I think inefficiently. Is there some way to split t...

How to profile combined python and c code

I have an application that consists of multiple python scripts. Some of these scripts are calling C code. The application is now running much slower than it was, so I would like to profile it to see where the problem lies. Is there a tool, software package or just a way to profile such an application? A tool that will follow the python c...

Handle a blocking function call in Python

Hi! I'm working with the Gnuradio framework. I handle flowgraphs I generate to send/receive signals. These flowgraphs initialize and start, but they don't return the control flow to my application: I imported time while time.time() < endtime: # invoke GRC flowgraph for 1st sequence if not seq1_sent: tb = se...

print lists in a file in a special format in python

Hi, I have a large list of lists like: X = [['a','b','c','d','e','f'],['c','f','r'],['r','h','l','m'],['v'],['g','j']] each inner list is a sentence and the members of these lists are actually the word of this sentences.I want to write this list in a file such that each sentence(inner list) is in a separate line in the file, and each ...

Phylo BioPython building trees

Hello! I trying to build a tree with BioPython, Phylo module. What I've done so far is this image: each name has a four digit number followed by - and a number: this number refer to the number of times that sequence is represented. That means 1578 - 22, that node should represent 22sequences. the file with the sequences aligned: file...

What is the canonical way of handling different types in Python?

I have a function where I need to generate different output strings for another program I invoke, depending on which type it wants. Basically, the called program needs a command line argument telling it which type it was called with. Happily I found this answer on SO on how to check a variable for type. But I noticed how people also ra...

help.....serial port programming

I want to communicate with my serial port in python. I installed pyserial, and uspp for linux. Still, when I run the following code: import serial ser = serial.Serial('/dev/pts/1', 19200, timeout=1) print ser.portstr #check which port was really used ser.write("hello") #write a string ser.close() # it gives the following error: ...

Django creating object from POST

Hello, I have a question regarding Djanog views here is a sample code def example register ( request ) : if request.method == ’POST ’ : username = request.POST.get ( ’ username ’ ) password = request.POST.get ( ’ password ’ ) email = request.POST.get (’email’) user = User.objects .create_user ( username , email , password ) user . sa...

Auto-Completion In wxPython wxComboBox

I've been trying to make a ComboBox which would suggest options as you type, much like an IDE's code suggestions/code-sense, or googles suggestions when you type in a search. The suggestions would be the items from the ComboBox dropdown, which contained the substring typed in the text box of the ComboBox. I've tried to make a ComboBox ...

tvrage-python search episode by air date

I'm playing with tvrage-python package to learn a bit Python, while still creating some kind of 'real' project. Currently I'm trying to figure out the best way to search for an episode by its original air date. There is not a direct support for this kind of search, so I thought it could worth a shot by listing all episodes go through the...

Pull data from one couchdb doc via ids in another (Python)

I have two databases in CouchDB - DB1's documents are user data - name, email address, username, password but within one field that I store a list of the ID's saved in DB2 where user projects are saved (containing a username field and some Textfields. Example DB1 Document (Users) { "_id": "bobsmith1000", "_rev": "83-1...

Interpret 0x string as hex in Python

I'm appending some hex bytes into a packet = [] and I want to return these hex bytes in the form of 0x__ as hex data. packet.append("2a") packet.append("19") packet.append("00") packet.append("00") packHex = [] for i in packet: packHex.append("0x"+i) #this is wrong return packHex How do I go about converting ('2a', '19', '00', ...

py2exe error when compiling

Hello. i was made some python script and i want to make this script to exe file. but when compiling this script to exe, some error encounter i was try to resolve this problem but no luck. following is script source if anyone can help me really much appreciate! # -*- coding: utf-8 -*- import lxml,cookielib,urllib,configobj,sys,get...

Open file in universal-newline mode when using pkg_resources?

Hi - I am processing a CSV file and have the following working code: reader = csv.reader(open(filename, 'rU'), dialect='excel') header = reader.next() However, to be compatible with elsewhere in the codebase, I need to use a file object using pkg_resources.resource_stream, as follows: fileobj = pkg_resources.resource_stream('foo', 't...

I need to return a link generated after the completion of ModelForm

part of forms.py class FormPublicar(forms.ModelForm): class Meta: model = Publicacao exclude = ('usuario', 'aprovado', 'cadastrado_em', 'slug') def enviar(self): titulo = 'mensagem enviada pelo site' destino = self.cleaned_data['emailp'] mensagem = u""" Message that will be sent after completing the form. H...