python

Python networking library for a simple card game

I'm trying to implement a fairly simple card game in Python so that two players can play together other the Internet. I have no problem with doing the GUI, but I don't know the first thing about how to do the networking part. A couple libraries I've found so far: PyRO: seems nice and seems to fit the problem nicely by having shared Car...

trac-past-commit-hook on remote repository

Trying to set up the svn commit with trac using this script. It is being called without issue, but the problem is this line here: 144 repos = self.env.get_repository() Because I am calling this remotely self.env_get_repository() looks for the repository using the server drive and not the local drive mapping. That is, it is looking fo...

Name this python/ruby language construct (using array values to satisfy function parameters)

What is this language construct called? In Python I can say: def a(b,c): return b+c a(*[4,5]) and get 9. Likewise in Ruby: def a(b,c) b+c end a(*[4,5]) What is this called, when one passes a single array to a function which otherwise requires multiple arguments? What is the name of the * operator? What other languages support th...

Using and Installing Django Custom Field Models

I found a custom field model (JSONField) that I would like to integrate into my Django project. Where do I actually put the JSONField.py file? -- Would it reside in my Django project or would I put it in something like: /django/db/models/fields/ Since I assume it can be done multiple ways, would it then impact how JSONField (or any cu...

encryption with python

If I want to use: recip = M2Crypto.RSA.load_pub_key(open('recipient_public_key.pem','rb').read()) Then how will it retrieve the key? What will recip will print? I need to get the public key of the recipient from the server(open key server) and for that first I need to store the key on server. ...

How to hide a bulletpoint in blog

how to hide a bullet points? example like this website http://www.grainge.org/pages/various_rh_projects/alt_dropdowns/showhide_3/showhide3.htm you can see the example first Hotspot second hotspot if we click 'first' it appears but if not it's not appear. how to do that ...

MySQL db problem in Python...

Hi, For me mysql db has been successfully instaled in my system.I verified through the following code that it is successfully installed without any errors. C:\Python26>python Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >...

defining functions in decorator

Why does this not work? How can I make it work? That is, how can I make gu accessible inside my decorated function? def decorate(f): def new_f(): def gu(): pass f() return new_f @decorate def fu(): gu() fu() Do I need to add gu to a dictionary of defined functions somehow? Or can I add gu t...

How to modify the local namespace in python

How can I modify the local namespace of a function in python? I know that locals() returns the local namespace of the function when called inside it, but I want to do something like this (I have a reason why I want to do this where g is not accessible to f, but it's quicker to give a trivial, stupid example to illustrate the problem): ...

Problem executing with Python+MySQL

Hi, I am not getting the reason why my python script is not working though I hv put all the things correctly as my knowledge.The below test I did and it worked fine.But when I import the MySQLdb in my script it gives error as no module name MySQLdb. **C:\Python26>python Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 3...

Python @property versus method performance - which one to use?

I have written some code that uses attributes of an object: class Foo: def __init__(self): self.bar = "baz" myFoo = Foo() print (myFoo.bar) Now I want to do some fancy calculation to return bar. I could use @property to make methods act as the attribute bar, or I could refactor my code to use myFoo.bar(). Should I go back...

supported MySQL for Python2.6.1

Can any one tell me which MySQL version is suitable for Python2.6.1 to connect MySQLdb, I am using MySQL4.0.23 and MySQLdb of MySQL-python-1.2.3c1.win32-py2.6 after successfully installation also its showing No module named MySQLdb and I sent the Environment Variables also properly for Python2.6, using Windows XP, tested import MySQLdb...

Convert Html to Django Fixture (JSON)

We've got a couple of Django flatpages in our project, that are based on actual HTML files. These files undergo some changes once in a while and hence have to updated in the database. So i came up with the idea of simply copying the plain HTML text into a json fixture and do an manage.py loaddata . However the problem is, that there are ...

AttributeError: 'unicode' object has no attribute '_meta'

I am getting this error on "python manage.py migrate contacts". The error info does not pinpoint problem location. Here is the error description: http://dpaste.com/68162/ Hers is a sample model definition: http://dpaste.com/68173/ Can someone point me to right direction??? I got this: http://blog.e-shell.org/66 but can not figur...

python + Spreadsheet

Hi, Can anybody please tell me is there any possible way to connect to spreadsheet from python? I want to store some data from a form and submit it to google spreadsheet. Please help on this issue. What steps do I have to follow? Thanks in advance... ...

Merge list items in a Python List

Say I have a list like this: [a, b, c, d, e, f, g] How do modify that list so that it looks like this? [a, b, c, def, g] I would much prefer that it modified the existing list directly, not created a new list. ...

PyQt: Overriding QGraphicsView.drawItems

I need to customize the drawing process of a QGraphicsView, and so I override the drawItems method like this: self.graphicsview.drawItems=self.drawer.drawItems where self.graphicsview is a QGraphicsView, and self.drawer is a custom class with a method drawItems. In this method I check a few flags to decide how to draw each item, and t...

Create NTFS junction point in Python

Is there a way to create an NTFS junction point in Python? I know I can call the junction utility, but it would be better not to rely on external tools. ...

Removing duplicates from list of lists in Python

Can anyone suggest a good solution to remove duplicates from nested lists if wanting to evaluate duplicates based on first element of each nested list? The main list looks like this: L = [['14', '65', 76], ['2', '5', 6], ['7', '12', 33], ['14', '22', 46]] If there is another list with the same element at first position [k][0] that ha...

Python sorting list of dictionaries by multiple keys

I have a list of dicts: b = [{u'TOT_PTS_Misc': u'Utley, Alex', u'Total_Points': 96.0}, {u'TOT_PTS_Misc': u'Russo, Brandon', u'Total_Points': 96.0}, {u'TOT_PTS_Misc': u'Chappell, Justin', u'Total_Points': 96.0}, {u'TOT_PTS_Misc': u'Foster, Toney', u'Total_Points': 80.0}, {u'TOT_PTS_Misc': u'Lawson, Roman', u'Total_Points': 80.0}, {u...