python

Tired of ASP.NET, which of the following should I learn and why?

Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why Clojure/Compojure+Ring/Moustache+Ring Groovy/Grails Python/Django Ruby/Rails Turbogear Cappuccino or Sproutcore Javascript/jQuery ...

Where can i get free GSM libraries/components for delphi or python?

Guys, Where can i get good free GSM libraries for Delphi or Python? Libraries i can use to send and receive sms's on my application? Gath ...

Python: Prevent fileinput from adding newline characters

I am using a Python script to find and replace certain strings in text files of a given directory. I am using the fileinput module to ease the find-and-replace operation, i.e., the file is read, text replaced and written back to the same file. The code looks as follows: import fileinput def fixFile(fileName): # Open file for in-pla...

How to access Yahoo Enterprise Web Services using Python SOAPpy?

Hi everyone. I have a PHP script which works and i need to write the same in Python but SOAPpy generates a slightly different request and i'm not sure how to fix it so the server likes it. The request generated by php script looks like this: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlso...

Python : is it ok returning both boolean and string ?

Original Question I have made a function which is waiting for a particular string to appear on a serial port, and returns all character read until the string was found, or false if not. This is quite convenient, but I was wondering if it is considered bad practice or not ? Clarification : The primary goal is to wait for a particular s...

How do I find the modules that are available for import from within a package?

Is there a way of knowing which modules are available to import from inside a package? ...

How would you implement a basic event-loop?

If you have worked with gui toolkits, you know that there is a event-loop/main-loop that should be executed after everything is done, and that will keep the application alive and responsive to different events. For example, for Qt, you would do this in main(): int main() { QApplication app(argc, argv); // init code return a...

How can I find which file contains a specific function in python?

Is there any way of finding which file contains a specific function? I'm using many modules in an application and I would like to see what file contains them. How could I do this? ...

How do I suppress scientific notation in Python?

Here's my code: x = 1.0 y = 100000.0 print x/y My quotient displays as 1.00000e-05 Is there any way to suppress scientific notation and make it display as 0.00001? Thanks in advance. This feels somewhat ridiculous to ask but I haven't figured out a way to do it yet. I'm going to use the result as a string. ...

Linking to Python import library in Visual Studio 2005

I have a C++ application that has embedded Python. I'm building with Visual Studio 2005. When I try to link to python26.lib, I get a number of unresolved symbols, all of which begin with "__imp": error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main python26.lib is an import library (installed by t...

pinging mysql using mysql alchemy and python

how do i ping mysql using mysql alchemy and python? ...

Python equivalent to "php -s"

As you may or may not know, you can generate a color syntax-higlighted HTML file from a PHP source file using php -s. I know about the syntaxhighlighter that Stackoverflow uses and that's not really what I'm looking for. I'm looking for something will generate HTML output without Javascript. Does anyone know of something equivalent to...

Accessing Microsoft Automation Objects from Python

I have a set of macros that I have turned into an add-in in excel. The macros allow me to interact with another program that has what are called Microsoft Automation Objects that provide some control over what the other program does. For example, I have a filter tool in the add-in that filters the list provided by the other program to ...

Python sequence naming convention

Since there is no explicit typing in python, I want to be able to make the difference between sequences and non-sequences using a naming convention. I have been programming with python for a little while now, and I still haven't found any logical/practical way to name sequences. Of course, I went through the famous PEP8, and made some re...

What's the correct way to add extra find-links to easy_install when called as a function?

I need to call easy_install as a function to install some Python eggs from a bunch of servers. Precisely what I install and where I get it from is determined at run-time: For example which servers I use depends on the geographic location of the computer. Since I cannot guarantee that any single server will always be available, it has be...

Python: How to add RSA padding?

I've been looking at most python crypto libraries, I've decided to use either PyCrypto or M2Crypto. I've discarded ezPyCrypto because it only supports MD5 for signing and Keyczar because it's not mature enough. So I've read that RSA is vulnerable to several attacks if the to-be-encrypted text (or signature hash) is not properly padded. ...

Reversing Django URLs With Extra Options

Suppose I have a URLconf like below, and 'foo' and 'bar' are valid values for page_slug. urlpatterns = patterns('', (r'^page/(?P<page_slug>.*)/', 'myapp.views.someview'), ) Then, I could reconstruct the URLs using the below, right? >>> from django.core.urlresolvers import reverse >>> reverse('myapp.views.someview', kwargs={'page_...

Checking file attributes in python

Hi, I'd like to check the archive bit for each file in a directory using python. So far i've got the following but i can't get it to work properly. The idea of the script is to be able to see all the files that have the archive bit on. Thanks # -*- coding: latin-1 -*- import os , win32file, win32con from time import * start = clock() ...

Python multiprocessing: sharing a large read-only object between processes?

Do child processes spawned via multiprocessing share objects created earlier in the program? I have the following setup: do_some_processing(filename): for line in file(filename): if line.split(',')[0] in big_lookup_object: # something here if __name__ == '__main__': big_lookup_object = marshal.load('file.bi...

.NET Framework equivalent of Python's imghdr.what function

Does .NET Framework have a function similar to Python's imghdr.what function to determine what type of image a file (or stream) is? I can't find anything. ...