Hello! I am attempting to script a short code to figure out the number of days it takes to reach a given principal in the bank due to daily interest. Using my code below does not yield any errors when run in IDLE, but the counter returns 0. Any ideas what I missed? from math import * d...
I'd like a way to download the content of every page in the history of a popular article on Wikipedia. In other words I want to get the full contents of every edit for a single article. How would I go about doing this. Is there a simple way to do this using the Wikipedia API. I looked and ...
I have a CSV file the first row of which contains the variables names and the rest of the rows contains the data. What's a good way to break it up into files each containing just one variable in Python? Is this solution going to be robust? E.g. what if the input file is 100G in size? I am tryi...
I have a big file transfer (say 4gb or so) and rather than using shutil, I'm just opening and writing it the normal file way so I can include a progress percentage as it moves along. It then occurred to me to try to attempt to resume the file write, if for some reason it borked out du...
Hi All, I generated a SQL script from a C# application on Windows 7. The name entries have utf8 characters. It works find on Windows machine where I use a python script to populate the db. Now the same script fails on Linux platform complaining about those special characters. S...
Hi, I am using python's multiprocessing module to spawn new process as follows : import multiprocessing import os d = multiprocessing.Process(target=os.system,args=('iostat 2 > a.txt',)) d.start() I want to obtain pid of iostat command or the command executed using multiprocess...
I'm writing a threading.Thread subclass that implements 'callable' methods. Normally with an arbitrary method on a thread, the method runs in whatever thread calls it. These methods run in the thread that they are called on and either block further execution in the calling...
I am playing around with vim and I heard that python.vim has some nifty settings for python. Link to python.vim vim.org/scripts/script.php?script_id=790 Q1: How do I integrate python.vi...
Hi Stack Overflow - I am developing a pure-Python module as a drop-in replacement for a C extension module. This C extension module is GPL'd and has unit tests written in Python. If I am developing open-source software under the MIT, am I able to re-use these test cases in my project?
Hi i need to parse xml file which is more then 1 mb in size, i know GAE can handle request and response up to 10 MB but as we need to use SAX parser API and API GAE has limit of 1 MB so is there way we can parse file more then 1 mb any ways.
I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I want...
I have a class: class A: s = 'some string' b = <SOME OTHER INSTANCE> now I want this class to have the functionality of a string whenever it can. That is: a = A() print a.b will print b's value. But ...
I constantly get this error using mako: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 6: ordinal not in range(128) I've told mako I'm using unicode in any possible way: mylookup = TemplateLookup( direc...
Hello, I am trying to run my GTK app on Windows XP and I am having troubles with an import. I have installed the following as needed and recommended: python-2.6.msi gtk2-runtime.2-16.6.exe pycairo-1.8.6.exe pygobject-2.20.0 pygtk-2.16.0.exe pyserial-2.5.exe However, I a...
I have a file that in C++ I load into array using below code: int SomeTable[10000]; int LoadTable() { memset(SomeTable, 0, sizeof(SomeTable)); FILE * fin = fopen("SomeFile.dar", "rb"); size_t bytesread = fread(SomeTable, sizeof(SomeTable), 1, fin); fclose(fin)...
I use python ftplib to connect to a ftp server which is running on active mode; That means the server will connect my client machine on a random port when data is sent between us. Considering security issue, Can I specify the client's data port (or port range) and let the server connec...
I wish to return only the number of google search results for a particular keyword in the fastest manner possible, avoiding (keeping to minimum) the use of third party libraries. I have already considered xgoogle.
Hi Developers, I want to integrate ns2 with a web server to show some kind of simulation results. Could anyone plz suggest if there's any middleware for this purpose? Google failed to return me any suitable result for this :( Also, if I plan to develop a middleware from scratch...
Hi folks, I'm using long polling for a chat with gevent. I'm using Event.wait() when waiting for new messages to be posted on the chat. I would like to handle the occasion a client disconnects with some functionality: e.g. Return ...
Hi, I am trying to use urllib2 to open url and to send specific cookie text to the server. E.g. I want to open site Solve chess problems, with a specific cookie, e.g. search=1. How do I do it? I am trying to do the follow...
Hii! I want to get the time execution of my function ( test(G) ). when I use Timer I need to write the type of my object : "test(% ?? )" %G which is DiGraph here. How can I do that? from networkx import nx def test(G): for e in G.edges_iter(): print(e) if __name__...
Here's my problem: import urllib2 response=urllib.urlopen('http://proxy-heaven.blogspot.com/') html=response.read() print html It's just this site, and I don't know why the result is all garbled characters. Anyone can help?
I'm looking for a tool that'd let me embed json-formatted information inside a PNG -file. This far it's been quite quiet. Do I have to write it myself? I'd be especially interested of doing it with javascript. Into an image I extract from a canvas with toDataURL -m...
I'm currently trying to write a multiple-file Python (2.6.5) game using PyGame. The problem is that one of the files, "pyconsole.py", needs to be able to call methods on instances of other objects imported by the primary file, "main.py". The problem is that despite the fact that I have a lis...
JavaScript has object literals, e.g. var p = { name: "John Smith", age: 23 } and .NET has anonymous types, e.g. var p = new { Name = "John Smith", Age = 23}; // C# Something similar can be emulated in Python by (ab)using ...
The question says everything. How can I check if my MySQL connection is closed in Python? I'm using MySQLdb, see http://mysql-python.sourceforge.net/
Is while True an accepted method for looping over a block of code until an accepted case is reached as below? Is there a more elegant way to do this? while True: value = input() if value == condition: break else: pass # Continue code her...
I'm kind of new to Django and am having some trouble pulling from existing tables. I'm trying to pull data from columns on multiple joined tables. I did find a solution, but it feels a bit like cheating and am wondering if my method below is considered proper or not. class Si...
i have implemented a function: def postback(i,user,tval): """functie ce posteaza raspunsul bazei de date;stringul din mesaj tb sa fie mai mic de 140 de caractere""" result = { 1:api.PostDirectMessage(user,'Trebuie sa-mi spui si marca pe care o cauti'), 2:post...
I'm working on a web app that will allow the user to do a lookup by date, so that, for example: results = Something.objects.filter(end = date) I'm planning on passing in the date information via the URL, like this: example.com/invoicer?2/9/198...
I’m currently using the @property decorator to achieve “getters and setters” in a couple of my classes. I wish to be able to inherit these @property methods in a child class. I have some Python code (specifically, I’m working in py3k) which looks vaguely like ...
Hello there, Started to learn programming 2 months ago, in one of my little projects i encountered the need to generate permutations of list of objects. I knew that i'll find how to do this if i'll just searched for it, but i wanted to make one of my own, so i worked up and made my own...
Hi, Hi would like to set the "Return-Path" header for a MIME message I send with Python. Basically, I tried something like this : message = MIMEMultipart() message.add_header("Return-Path", "something@something.com") #... smtplib.SMTP().sendmail(from, to, message.as_s...
I have two variables that are the result of regex searches. a = re.search('some regex', str) b = re.search('different regex', str) This should return a re object. If they are not None, I want to use the group() method to get the string that it matched. This i...
I've been tyring to figure out how to load JSON objects in Python. I'm able to send a JSON string to the server, but there it fails. This is what I'm sending through a websocket with JavaScript: ws.send('{"test":"test"}'); The server receives i...
How do I use setdefault in python for nested dictionary structures. eg.. self.table[field] = 0 self.table[date] = [] self.table[value] = {} I would like to setdefault for these.
I have the same code on localhost and on server (thanks to mercurial), but it works a little bit different. I want to render category and its subcategories in template using this code: views.py: def category(request, category_slug): try: category = Category....
I'm having a problem with building a form from a request. I'm using WTForms with the sqlalchemy field extensions (in particular the QuerySelectField), and so users pick a Practice from a dropdown, and then when they submit the form it actually submits the UUID which goes with that practice. ...
I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose. I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows. My goals: 1. to make GUI using as less custom c...
For languages that allow nested functions, how does nesting affect performance? I expect this depends a lot on the optimizations done by particular compilers. But with the extreme difference between the deep nesting of Lispers and the "flat is better than nested" of the Pythonistas, I'd like t...
I am interested in hearing the differences between Go and Python and reading an overview of the similarities. I know that Google has heavy usage of Python and Go looks to be a bit related. I was searching around a bit for a comparison and...
I wanna setup a global hotkey in python 2.6 that listens to the keyboard shortcut ctrl + D or ctrl + alt + D on windows, please help me
Hi all. From my understanding, os.popen() opens a pipe within Python and initiates a new sub process. I have a problem when I run a for loop in conjunction with os.popen(). I can't seem to CTRL+C out of the loop. Here is my code: for FILE in os.popen("ls $MY_DIR/"): .......
i've written a tool in python where you enter a title, content, then tags, and the entry is then saved in a pickle file. it was mainly designed for copy-paste functionality (you spot a piece of code you like on the net, copy it, and paste it into the program), not really for handwritten conten...
I want to scrape this web page using Mechanize. The form element looks like this: <form name="ctl00" method="post" action="PSearchResults.aspx?state=ME&rp=" id="ctl00"> ...
I know that it's possible to share a global variable across modules in Python. However, I would like to know the extent to which this is possible and why. For example, global_mod.py x = None mid_access_mod.py from global_mod import * ...
I'm trying to decrypt some data from gpg files that I've downloaded. Downloading the files to a directory is no problem, but I'm having trouble actually decrypting them. Here's what I'm doing right now: def extractGPGs(gpglist,path,gpgPath="\"C:\\Program Files\\GNU\\GnuPG\\gpg....
I've searched several threads and bug reports, but couldn't find a solution. I changed the locale of my Django project to pt-br but it made no difference. I excepted all input fields and outputs to localize dates and numbers, specially DECIMAL_SEPARATOR and
I am in the process of applying to a Computer Science program which requires students to have at least an intro-level exposure to either Java, C or C++. I have some experience with Python and I would prefer to continue working in Python before starting another language; however, the professor...
i have an excel spreadsheet of about 3 million cells. i asked the following question and i liked the answer about saving the spreadsheet as CSV and then processing it with python:
I'm trying to do a lengthy operation but pexpect with the timeout argument doesn't seem to change the length of time before the timeout exception gets fired. Here is my code: child = pexpect.spawn('scp file user@:/temp', timeout=300) whichMatched = child.expect(['(?i)Password'...
I'm wanting to use some newer software that requires Python 2.6, and we currently have both 2.4 and 2.6 installed on our dedicated CentOS server, which looks like this: $ which python /usr/local/bin/python $ which python2.6 /usr/bin/python...
i am opening a csv file like this: import csv reader = csv.reader(open("book1.csv", "rb")) for row in reader: print row how can i replace the value in column 3 with its log and then save the result into a new csv?
« first day (11 days earlier) ← previous day next day → last day (23 days later) »