python

Can distutils use a custom .def to expose extra symbols when it compiles a Windows .dll?

I'm abusing distutils to compile an extension module for Python, but rather than using the Python C API I'm using ctypes to talk to the resulting shared library. This works fine in Linux because it automatically exports all symbols in a shared library, but in Windows distutils provides a .def to export only the Python module init functi...

XML differences between WCF and Python SUDS for inheritance?

Hello StackOverflow! This is my first post, so apologies if I don't include all the right information! I have a question regarding the different ways inheritance are represented between WCF and SUDS (Python). I have a C++/CLI WCF server (.NET 3.5 SP1) and I'm trying to communicate with it. I've used a C# (WCF also) client and it work...

PyQt4: Adding QtMessageBox.information functionality to custom window

Hi everyone, what I need is something very alike QtMessageBox.information method, but I need it form my custom window. I need a one window with few labels, one QtTreeViewWidget, one QButtonGroup … This window will be called from main window. If we call class that implements called window as SelectionWindow, than what I need is: class ...

What is the scope of a defaulted parameter in Python?

When you define a function in Python with an array parameter, what is the scope of that parameter? This example is taken from the Python tutorial: def f(a, L=[]): L.append(a) return L print f(1) print f(2) print f(3) Prints: [1] [1, 2] [1, 2, 3] I'm not quite sure if I understand what's happening here. Does this mean that...

model.__unicode__() returning russian string cause TemplateSyntaxError

code: class Gallery(models.Model): title = models.CharField(max_length=100) description = models.TextField(blank=True) created = models.DateField(auto_now_add=True) class Meta: verbose_name = 'галерея' verbose_name_plural = 'галереи' def __unicode__(self): return 'Галерея %s' % self.title ...

Post processing attendance data with Django

I have a web app which tries to determine when people are attending events. class Attendee(models.Model): location = models.ForeignKey(Location) user = models.ForeignKey(User) checked_in = models.DateTimeField() checked_out = models.DateTimeField() last_active = models.DateTimeField() An Attendee is checked in when...

Send Email in Django without SMTP server. Like php mail() function does

Hello! As far as I read, Django only supports sending mails using SMTP. I would like to send Emails from my script in Django, but do not want to setup SMTP server (it's too complex for me, I'm a linux newbie). Is it possible, to send mails in Django in the same way like I do it in PHP, without providing SMTP login, password and etc? ...

Parse timezone abbreviation to UTC

How can I convert a date time string of the form Feb 25 2010, 16:19:20 CET to the unix epoch? Currently my best approach is to use time.strptime() is this: def to_unixepoch(s): # ignore the time zone in strptime a = s.split() b = time.strptime(" ".join(a[:-1]) + " UTC", "%b %d %Y, %H:%M:%S %Z") # this puts the time_tupl...

Python and NGREP

I want to be able to start and stop an NGREP process from inside my python code. I really dont have experience with python on a system level. Normally I run NGREP from the command line, but I would like to be able to run it from a script every hour and capture the trace and then process the results. Can anyone point me in the direction...

Can I use wxPython wx.ItemContainer in a derived class?

I'm trying to make a new wx.Choice-like control (actually a replacement for wx.Choice) which uses the wx.ItemContainer to manage the list of items. Here is a minimal example showing the error: import wx class c(wx.ItemContainer): def __init__(my): pass x = c() x.Clear() This fails with: Traceback (most recent call last): File...

[Python] How can I get the window focused on Windows and re-size it?

I want to get the focused window so I can resize it... how can I do it? ...

Is fortran-like print in python possible?

Hi, is it possible some way to "print" in python in a fortran like way like this? 1 4.5656 2 24.0900 3 698.2300 4 -3.5000 So the decimal points is always in the same column, and we get always 3 or n decimal numbers? Thanks ...

Is there a Python equivalent for the Perl module Term::VT102?

In Perl there is a very handy module, Term::VT102, which allows you to create a screen in memory. This is very handy for scraping purposes since you can keep track of all the changes to portions of the screen and then export the screen as plain-text for processing. Is there an equivalent module in Python? Followup Question: There are mo...

How do I make a command line program that takes arguments?

How can I make a command line, so I can execute my program on Windows with some parameters... For example: C:/Program/App.exe -safemode ...

Convert dbus.String to normal string

I am using dbus to get the current playing song from Songbird Media Player & Metadata is also taken from dbus object. The line where error comes is:- audio_file = MP3(current_playing_track['location'], ID3=ID3) The error is:- Traceback (most recent call last): File "./last.py", line 42, in <module> audio_file = MP3(current_pl...

Baby steps to a solution with django and mod-wsgi on os x

I'm running apache / os x and serving up localhost pages to test django on my laptop. I've already verified all the following • python is working fine and up to date (2.5.1) • django available to python and up to date (1,1,0, 'final', 0) • mod_wsgi module is loaded among apache modules in my apache config - Check! • path to django ...

Output of python scripts displayed only at termination when using SSH?

Hi, I'm running a script to manage processes on a remote (SSH) machine. Let's call it five.py #!/usr/bin/python import time, subprocess subprocess.call('echo 0',shell=True) for i in range(1,5): time.sleep(1) print(i) If i now run ssh user@host five.py I would like to see the output 0 1 2 3 4 appear on my standard out se...

Is it possible to read Fortran formatted data in Python?

I get output files from very old Fortran programs, which look like: 0.81667E+00 -0.12650E+01 -0.69389E-03 0.94381E+00 -0.11985E+01 -0.11502E+00 0.96064E+00 -0.11333E+01 -0.17616E+00 0.10202E+01 -0.12435E+01 -0.93917E-01 0.10026E+01 -0.10904E+01 -0.15108E+00 0.90516E+00 -0.11030E+01 -0.19139E+00 0.98624E+00 -0.11598E+...

Using eval securely to execute functions

def myFunc(arg1, arg2): print "This is a test with " + arg1 + " and " + arg2 while (input != "quit"): input = raw_input("> ") if input != "quit": eval(input) This code gives me a prompt, allowing me to invoke myFunc with parameters I want. I know that eval can be dangerous if a dictionary is not supplied, so I add...

What's the best module to access SimpleDB in python?

I'm writing a python script to select, insert, update, and delete data in SimpleDB. I've been using the simpledb module written by sixapart so far, and it's working pretty well. I've found one potential bug/feature that is problematic for me when running select queries with "limit", and I'm thinking of trying it with the boto module to...