python

Telnet behaviour on Windows and Linux

I'm working on writing a MUD-like game (in Python, if that matters). I've noticed that the Windows telnet client and Ubuntu's telnet client behave slightly differently when connecting to the server. In Ubuntu, I type something, but the server doesn't recieve anything until I press enter. With Windows, every keystroke is sent to the se...

Change Node Display Size in Networkx

I am not using GraphViz because I am having problems with making it play nice with Networkx. I know this is weird, but I've tried many suggestions to fix this problem, but I just seem to have some of the worst luck in the world. Therefore the problem that I have must be solved withing Networkx without using GraphViz. My program reads a ...

pyqt QTreeWidget setItemWidget dissapears after drag/drop

I'm trying to keep a widget put into a QTreeWidgetItem after a reparent (drag and drop) using QTreeWidget.setItemWidget() But the result, if you compile the following code - is that the widget inside the QTreeWidgetItem disappears. Any idea why? What code would fix this (repopulate the QTreeWidgetItem with the widget I guess?) from Py...

%windir% in Python?

How can I do something like if sys.argv[0] != '%windir%\\blabla.exe' I'm having no success at all ...

How to I make the result of this a variable?

right now its set up to write to a file, but I want it to output the value to a variable. not sure how. from BeautifulSoup import BeautifulSoup import sys, re, urllib2 import codecs woof1 = urllib2.urlopen('someurl').read() woof_1 = BeautifulSoup(woof1) woof2 = urllib2.urlopen('someurl').read() woof_2 = BeautifulSoup(woof2) GE_DB = o...

Using Numpy to find the average distance in a set of points

I have an array of points in unknown dimensional space, such as: data=numpy.array( [[ 115, 241, 314], [ 153, 413, 144], [ 535, 2986, 41445]]) and I would like to find the average euclidean distance between all points. Please note that I have over 20,000 points, so I would like to do this as efficiently as possible. Thanks. ...

Regex: Using lookahead assertion to check if character exist at most a certain number of times

How do I use lookahead assertion to determine if a certain character exist at most a certain number of times in a string. For example, let's say I want to check a string that has at least one character to make sure that it contains "@" at most 2 times. Thanks in advance. Using python if that matters. ...

How can I make an error verifiy with os.makedirs in Python?

How can I make a verify error for this command? if blablablabla: os.makedirs('C:\\test\\') If the folder already exists, he return me an error... how can I make it ignore this error? and move on ? ...

_winreg.CreateKey problem in Python

I'm trying to create a key like this _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\') and the key is beeing created here HKLM\Software\Wow6432Node\Microsoft\Shared Tools\MSCONFIG\startupreg\test\ why? Yes, Windows 7 64x here ...

Why aren't there any dates in the Netflix.com NewWatchInstantlyRSS feed entries (when parsed with feedparser)?

The output from the following: import feedparser d = feedparser.parse('http://www.netflix.com/NewWatchInstantlyRSS') d.entries[177].keys() is: ['summary_detail', 'links', 'title', 'summary', 'guidislink', 'title_detail', 'link', 'id'] According to http://feedparser.org/docs/common-rss-elements.html, there should be a "date" element...

python: _winreg problem

the windows registry may contain keys whose names with embedded nulls when i call _winreg.OpenKey(key, subkey_string_with_embbeded_null) i get the following error: TypeError: OpenKey() argument 2 must be string without null bytes or None, not str Q1: is the meaning of the error that python _winreg module has a limitation that it cann...

Why is ''>0 True in Python?

In Python 2.6.4: >> ''>0 True Why is that? ...

Connect to a samba share with python in a platform independent manner?

Is there an abstraction that will allow me to connect to a samba share in python regardless of my platform? More information I do not want to mount a share. I simply want to upload files to a share, such as smbclient's put. Thanks, Pete ...

Crontab job does not start... ideas?

Hey folks, thanks for helping me setting my cron jobs, crontab has really been a gold mine for me. Unfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain This is my crontabs job list: */10 * * * * python /webapps/foo/manage.py fe...

Better way to script USB device mount in Linux

Hi. I'm writing a python module for a device that interacts with a user supplied USB memory stick. The user can insert a USB memory stick in the device USB slot, and the device will dump data onto the memory stick without user intervention. If the device is running when the user inserts the USB stick, I have hooked into D-Bus and have an...

py2app Not Finding BeautifulSoup

I have a script that uses BeautifulSoup that I want to make into a standalone app using py2app. When I run the app made by py2app I get an error saying that the module BeautifulSoup could not be found. My sys.path has '/Library/Python/2.6/site-packages/BeautifulSoup-3.1.0.1-py2.6.egg' so it seems like it should be there, any advice? ...

List of evented / asynchronous languages

I'm working on a system than has to be pretty scalable from the beginning. I've started looking at / playing around with asynchronous/evented approaches to writing serverside code. I've played around with both ruby's EventMachine and node.js. EventMachine is cool, but doesn't have asynchronous file I/O, which I need. The interface is ki...

Python in SU cron gives different output than manually execution

Ubuntu Server 9.10, Here is my file, test.py import commands blkid = commands.getoutput('blkid') print blkid When I manually run (as SU) this: python test.py I get the output of the blkid as expected: /dev/sda1: UUID="3f0ac5bb-f0da-4574-81f5-77844530b561" TYPE="ext4" /dev/sda5: UUID="67df0e7c-74fb-47dd-8520-ad720fbed67d" TYPE="swa...

rounded rectangle in pygtk

what is the best way to draw a rounded rectangle in a pygtk application ...

wx.ProgressDialog too small

My program uses wx.ProgressDialog to give feedback on a process that is in multiple stages. At the beginning of each stage, I use the second argument of Update to change the message in the dialog. The problem is that the width of the dialog is determined from the message in the constructor, and the dialog is not resized if a later call...