python

How to translate between programming languages

I am setting out to do a side project that has the goal of translating code from one programming language to another. The languages I am starting with are PHP and Python (Python to PHP should be easier to start with), but ideally I would be able to add other languages with (relative) ease. The plan is: This is geared towards web develo...

How do I duplicate certificate authentication (Mumble (c/c++)) in Python?

Alright so, before I really get into this post, I am going to have to warn you that this might not be an easy fix. Whoever reads and is able to reply to this post must know a lot of c/c++, and at least some python to be able to answer the question I have above. Basically, I have a connection method from Mumble (a VOIP client), that con...

Calling code in a string without exec/eval, python

I have this code that executes when a player attempts to eat something: def eat(target='object'): global current_room global locations global inventory if target in inventory: items[target]['on_eat'] #This is showing no results. else: print 'You have no ' + target + ' to eat.' and this code for item...

gpgpu programming in python

i want to start gpgpu programming in python. should i start with pyopencl or clyther? whats the difference? ...

Python 3.X or Python 2.X

What's the ideal Python version for a beginner to start learning Python? I need to recommend some newbies a programming language to learn and I chose Python. I'm still not sure which version. ...

Why does my remote MongoDB connection require authentication on every query?

After fighting with different things here and there, I was finally able to get BottlePY running on Apache and run a MongoDB powered site. I am used to running Django apps, so I will be relating to that a bit in my question. The Problem Every time a page is loaded via BottlePY, the connection to the MongoDB database located on MongoHQ.c...

Can selenium open a search result page?

Hi everyone, I'm new to selenium. I want to ask about if there's a easy way to open a search result page of some urls, not just the homepages. for examples, I search stack overflow in google. The url is here, but the return page is google homepage.Is it possible to get the result page directly? I want to scratch some result pages. If I...

Python: object as an argument of another object

I have a module including definitions for two different classes in Python. How do I use objects of one class as an argument of the other? Say, I have class definitions for Driver and Car, and tuen want to have a Driver object as an argument for a Car object. ...

python analyse 2 logfiles

I have 2 large logfiles. I want to see if a device is in a but not b and vice versa (exclude lines where the device is common) the files look like this example. 04/09/2010,13:11:52,Authen OK,user1,Default Group,00-24-2B-A1-08-88,29,10.1.1.1,(Default),,,,,,13,EAP-TLS,,device1, 04/19/2010,15:35:24,Authen OK,user2,Default Group,00-24-2B-...

Python subprocess.Popen communicate through a pipeline

I want to be able to use Popen.communicate and have the stdout logged to a file (in addition to being returned from communicate(). This does what I want - but is it really a good idea? cat_task = subprocess.Popen(["cat"], stdout=subprocess.PIPE, stdin=subprocess.PIPE) tee_task = subprocess.Popen(["tee", "-a", "/tmp/logcmd"], stdin=cat...

How to save a webpage by seleniumRC

Hi everyone, I use seleniumRC to open a url, then how to save this web page? How to realize it like urllib.urlretrieve do it? But urllib can't operate javascript in the page. One more question: Will it save the whole page with what I see as seleniumRC open it? ...

Python importing modules that all import another module that is the same

What i want to is, I have foo.py it imports classes from bar1, bar2, and they both need bar3, e.g. foo.py from src import * ... src/ __ init__.py from bar1 import specialSandwichMaker from bar2 import specialMuffinMaker src/bar1.py import bar3 class specialSandwichMaker(bar3.sandwichMaker) ... src/bar2.py import bar3 class spe...

Difference between simple Python function call and wrapping it in cProfile.run()

I have a rather simple Python script that contains a function call like f(var, other_var) i.e. a function that gets several parameters. All those parameters can be accessed within f and have values. When I instead call cProfile.run('f(var, other_var)') it fails with the error message: NameError: "name 'var' is not defined" Python ...

Make an installer for python project

I downloaded an open source project http://gmapcatcher.googlecode.com/files/GMapCatcher-0.7.2.0.tar.gz and I am trying to modify a few things in the code but don't know how to test the code! I tried to make an installer for the project but nothing worked till now maybe I didn't follow the right steps or I am missing somthing. my questi...

Can't read file in__init__

Hello all. I am a newbe to Python. I have tried to create a class, named ic0File. Here is what I get when I use it (Python 3.1) >>> import sys >>> sys.path.append('/remote/us01home15/ldagan/python/') >>> import ic0File >>> a=ic0File.ic0File('as_client/nohpp.ic0') Traceback (most recent call last): File "<stdin>", line 1, in <module> ...

Comparing dates and times in different formats using Python

I have lines of the following format in a file. Summary;meeting;Description;None;DateStart;20100629T110000;DateEnd;20100629T120000;Time;20100805T084547Z I need to create a function that has two inputs: time and date in the following formats Time: HH:MM and date as mmddyyyy. (These are strings). Now the function needs to read this line...

Elegant way to create a dictionary of pairs, from a list of tuples?

I have defined a tuple thus: (slot, gameid, bitrate) and created a list of them called myListOfTuples. In this list might be tuples containing the same gameid. E.g. the list can look like: [ (1, "Solitaire", 1000 ), (2, "Diner Dash", 22322 ), (3, "Solitaire", 0 ), (4, "Super Mario Kart", 854564 ), ... and so on. ] ...

Django: Accessing method on child different child classes through common name

I have an abstract base class for defining common attributes shared by different user profiles. class Profile(models.Model): ... def has_permissions(self, project): ... class Meta: abstract = True class Standard(Profile): ... class Premium(Profile): ... Now I would like to check the permission of a certa...

When while loop placed in wxPython events

I'm trying to write a GUI program grabbing specific contents from a webpage. The idea is when I hit the start button, the program should start extracting information from that page. And I want to add some code to check if connected to the Internet. If not, continue trying until connected. So I just added the following code in the event...

Concurrency Testing For A Web Service Using Python

I have a web service that is required to handle significant concurrent utilization and volume and I need to test it. Since the service is fairly specialized, it does not lend itself well to a typical testing framework. The test would need to simulate multiple clients concurrently posting to a URL, parsing the resulting Http response, che...