python

Bazaar VCS under IronPython?

Has anyone successfully executed the source control system Bazaar in IronPython? ...

Building app to Classify / Describe Products - Overwhelmed somewhere between planning & execution

Greetings! I recently started working for a company that carries a line of 20,000 Surgical Instruments. Our data on all items is currently spotty and chaotic at best. I intend to fix this. I have been tasked with redesigning the web site. As part of the project, I'm building an app to classify and describe all products. We don't do any...

How to clean up my Python Installation for a fresh start

I'm developing on Snow Leopard and going through the various "how tos" to get the MySQLdb package installed and working (uphill battle). Things are a mess and I'd like to regain confidence with a fresh, clean, as close to factory install of Python 2.6. What folders should I clean out? What should I run? What symbolic links should I...

How does one feed a list of files into an app with appscript and Python?

Get your newb-shields up, I'm about to sprinkle you with some. I'm trying to get Photoshop CS4 to open a folderful of JPEG images with AppScript+Python, which could be described like so in BASH: #!/bin/bash for F in `ls ~/Desktop/test`; do open -a "Adobe Photoshop CS4" $F # proceed to mutilate the image appearance done I'm f...

Is it possible to use functions before declaring their body in python?

Is there any way to make possible to use functions in your file before you actually declare their body? The following code doesn't seem to work: abc = myFunction def myFunction(): print "123" Thanks ...

Combine lxml XSLT pretty_print with strip-space

I'm cleaning up some gross XML, and so I've had pretty_print = True set in the call to etree.tostring() on my lxml output of the XSL transform. However, that left me with a few junk whitespace nodes from the original input, so I added <xsl:strip-space elements="*"/> ...but that completely collapses all whitespace, ignoring pretty prin...

C/Python Socket Performance?

Hi, my question simply relates to the difference in performance between a socket in C and in Python. Since my Python build is CPython, I assume it's similar, but I'm curious if someone actually has "real" benchmarks, or at least an opinion that's evidence based. My logics is as such: C socket much faster? then write a C extension. n...

What is python used for?

Okay, so i am fairly new at programming (knowing only html, css, and javascript) and i just started diving into python. But what i want to know is, what is it used for? how can i apply python to an object? ...

Python: List to integers

I have read a file in and converted each line into a list. A sample of the list looks like: ['15', '2', '0'], ['63', '3', '445', '456' '0'], ['23', '4', '0'] i want to retrieve the first number from each list and convert it to and integer so when i carry out the type function i.e. type(x) <type 'int'> is returned Also when i print ...

ISO public Django apps developed Agile / BDD style with Doctest, Unitests and Selenium

I've found several blog posts where TDD/BDD is explained, but the examples are usually really basic. Usually they are just for Models. I want to see how people are really using BDD in Real Life. I'd love be pointed towards some Django apps that were built test first style so I can learn from them. I know that Rails had many examples, s...

Using style sheets in tab widgets in PyQT

Can you please tell me the syntax for using style sheets? in sub-controls like QStyle.SE_TabWidgetTabBar by having QTabWidget as a reference element For setting stylesheets for tabs (sub-control) in tab bar (example here) I've searched everywhere for the solution, but have had no luck. ...

How do I add rows and columns to a NUMPY array?

Hello I have a 1000 data series with 1500 points in each. They form a (1000x1500) size Numpy array created using np.zeros((1500, 1000)) and then filled with the data. Now what if I want the array to grow to say 1600 x 1100? Do I have to add arrays using hstack and vstack or is there a better way? I would want the data already in the...

lisp-style style `let` syntax in Python list-comprehensions

Consider the following code: >>> colprint([ (name, versions[name][0].summary or '') for name in sorted(versions.keys()) ]) What this code does is to print the elements of the dictionary versions in ascending order of its keys, but since the value is another sorted list, only the summary of its first element (the 'm...

facebook app in python showing file list

i am making a facebook app in python with django. now i have successfully resolved the callback url to my localhost account. but the app is not displaying on facebook. when i navigate to apps.facebook.com/'myappname', it authenticates and then displays the file list on project folder? ...

Need to add httpd support to this wxPython code.

I need to add httpd support to this sample wxpython code. It parses the url and display different images. What's the easiest way to do this? import wx a = wx.PySimpleApp() wximg = wx.Image('w.png',wx.BITMAP_TYPE_PNG) wxbmp=wximg.ConvertToBitmap() f = wx.Frame(None, -1, "Show JPEG demo") f.SetSize( wxbmp.GetSize() ) wx.StaticBitmap(f,-...

Dynamically build and return a Python list in a C Python extension

I'm writing a Python extension in C, and I'm trying to figure out how to dynamically build and return a Python list using my extension. I know how to build a list of predetermined size using Py_BuildValue. Is there a way to create a list with Py_BuildValue then append items to that list? Is there a different, and better, alternative? ...

Unicode filenames on Windows with Python & subprocess.Popen()

Why does the following occur: >>> u'\u0308'.encode('mbcs') #UMLAUT '\xa8' >>> u'\u041A'.encode('mbcs') #CYRILLIC CAPITAL LETTER KA '?' >>> I have a Python application accepting filenames from the operating system. It works for some international users, but not others. For example, this unicode filename: u'\u041a\u0433\u044b\u044...

Django: Problems with serving static files with non ascii names

Hi, I've moved my django application from one server to another, and spotted strange bug with media after it: Traceback (most recent call last): File "/usr/lib/python2.5/site- packages/Django-1.1.1-py2.5.egg/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) Fi...

csv utf-8 writer - compability with python2.4

At the bottom of this manual http://docs.python.org/library/csv.html we have example of UnicodeWriter But how can i use this example in python 2.4 I got exception about codecs.getincrementalencoder(encoding)(). Property getincrementalencoder created only in version 2.5. Who can replace this property? Thanks! ...

More efficient way to count intersections?

I have a list of 300000 lists (fiber tracks), where each track is a list of (x,y,z) tuples/coordinates: tracks= [[(1,2,3),(3,2,4),...] [(4,2,1),(5,7,3),...] ... ] I also have a group of masks, where each mask is defined as a list of (x,y,z) tuples/coordinates: mask_coords_list= [[(1,2,3),(8,13,4),...] [(6,2,2),(5,7,3),...] ... ]...