How do you end up running pypcap for python 2.6 on a mac? It seems that there hasn't been any new releases since 2.5 or am I just looking in the wrong places?
for example you run some client program, this program communicate with server to recieve data in realtime ... how can i listen to this network traffic and filter / store data in python?
I need to change some characters that are not ASCII to '_'.
For example,
Tannh‰user - Tann_huser
If I use regular expression with Python, how can I do this?
Is there better way to do this not using RE?
I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? From the looks of it (Sybase ASE) it needs some type of compilation before use. Is it possible for this type of work around?
Im using python to access a MySQL database and im getting a unknown column in field due to quotes not being around the variable.
code below:
cur = x.cnx.cursor()
cur.execute('insert into tempPDBcode (PDBcode) values (%s);' % (s))
rows = cur.fetchall()
How do i manually insert double or single quotes around the value of s?
I've trying using str() and manually concatenating quotes around s but it still doesn't work.
The sql statement works fine iv double and triple check my sql query.
I have an unknown number of functions in my python script (well, it is known, but not constant) that start with site_...
I was wondering if there's a way to go through all of these functions in some main function that calls for them.
something like:
foreach function_that_has_site_ as coolfunc
if coolfunc(blabla,yada) == true:
return coolfunc(blabla,yada)
so it would go through them all until it gets something that's true.
thanks!
I am iterating over an array in python:
for g in [ games[0:4] ]:
g.output()
Can I also initialise and increment an index in that for loop and pass it to g.output()?
such that g.output(2) results in:
Game 2 - name: Fruit Splat, text: "Splat fruits!", bitrate: 250000
In Python I can use the iterkeys() method to iterate over the keys of a dictionary. For example:
mydict = {'a': [3,5,6,43,3,6,3,],
'b': [87,65,3,45,7,8],
'c': [34,57,8,9,9,2],}
for k in mydict.iterkeys():
print k
gives me:
a
c
b
How can I do something similar in Javascript?
class A:
def __init__(self):
print "world"
class B(A):
def __init__(self):
print "hello"
B()
hello
In all other languages I've worked with the super constructor is invoked implicitly. How does one invoke it in Python? I would expect super(self) but this doesn't work
Does anybody know any module in Python that computes the best bipartite matching?
I have tried the following two:
munkres
hungarian
However, in my case, I have to deal with non-complete graph (i.e., there might not be an edge between two nodes), and therefore, there might not be a match if the node has no edge. The above two packages seem not to be able to deal with this.
Any advice?
I want to parse a html-page that unfortunately requires JavaScript to show any content. In order to do so I use a small python-script that pulls the html-code of the page, but after that I have to execute the JavaScript in a DOM-context which seems pretty hard.
To make it even harder I want to use it in a server environment that has no X11-server.
Note: I already read about http://code.google.com/p/pywebkitgtk/ but it seems to need a X-server.
I have a following string - "AACCGGTTT" (alphabet is ["A","G","C","T"]). I would like to generate all strings that differ from the original in any two positions i.e.
GAGCGGTTT
^ ^
TATCGGTTT
^ ^
How can I do it in Python?
I have only brute force solution (it is working):
generate all strings on a given alphabet with the same length
append strings that have 2 mismatches with a given string
However, could you suggest more efficient way to do so?
Hi folks,
I'm serving a Django app behind IIS 6. I'm wondering if I can restart IIS 6 within Python/Django and what one of the best ways to do would be.
Help would be great!
I have a Python app that contains an object structure that the user can manipulate. What I want to do is allow the user to create a file declaring how the object structure should be created.
For example, I would like the user to be able to create the following file:
foo.bar.baz = true
x.y.z = 12
and for my app to then create that object tree automatically. What's the best way to do something like this?
I am trying to get python to make noise when certain things happen. Preferably, i would like to play music of some kind, however some kind of distinctive beeping would be sufficient, like an electronic timer going off. I have thus far only been able to make the system speaker chime using pywin32's Beep, however this simply does not have the volume for my application.
Any ideas on how I can do this?
I am writing a program in Python, and want to get it to make the OS open the current working directory, making for instance Windows open explorer.exe and navigating to the wanted directory. Any ideas on how to do this?
The directory is already given by os.getcwd.
Cross platform methods preferred :)
I'm curious if their is some python magic I may not know to accomplish a bit of frivolity
given the line:
csvData.append(','.join([line.split(":").strip() for x in L]))
I'm attempting to split a line on :, trim whitespace around it, and join on ,
problem is, since the array is returned from line.split(":"), the
for x in L #<== L doesn't exist!
causes issues since I have no name for the array returned by line.split(":")
So I'm curious if there is a sexy piece of syntax I could use to accomplish this in one shot?
Cheers!
Hi I have a MySQL server that I need access through a VPN.
I use MySQLdb package to access MySQL server in Python.
When I can access the server without VPN, it works fine, but when I'm at certain locations, I need to connect through VPN.
My computer is connected to the VPN and I can access the database through PHPMyAdmin, but MySQLdb gives me an error message:
OperationalError: (2003, "Can't connect to MySQL server on 'MY_IP' (10061)")
Any ideas on why it's not working?
Thanks
Well i'm learning Python cuz' i think is an awesome and powerful language like C++, perl or C# but is really really easy at same time. I'm using JetBrains' Pycharm and when i define a function it ask me to add a "Documentation String Stub" when i click yes it adds somethin like this:
"""
"""
so the full code of the function is something like this:
def otherFunction(h, w):
"""
"""
hello = h
world = w
full_word = h + ' ' + w
return full_word
I would like to know what these (""" """) symbols means, Thanks.
Ps.Data: Sorry for my bad english :D
What sort of mime type should I be using to email a .avi file from an automated python script? There are specific ones for audio/images, but not video afaik.
I need to be able to block the urls that are stored in a text file on the hard disk using Python. If the url the user tries to visit is in the file, it redirects them to another page instead. How is this done?
I'm trying to use python to determine if one (small) image is within another (large) image.
Any suggestions before I take myself completely down the wrong path?
I am looking to setup a automated screen scraper that will run on Google app engine using python. I want it to scrape the site and put the specified results into a Entity in app engine. I am looking for some directions on what to use. I have seen beautifulsoup but wonder if people could recommend anything else that could run on Google App engine.
Hi, I have an application that starts several threads using
gobject.timeout_add(delay, function)
Now in my function I want to test and set on some variable, e.g.
def function(self):
if flag == True:
flag = False
doSomething()
Now to make this threadsafe, I would have to lock the function using some mutex lock.
Is this possible with Gtk? Or can I use the Python Lock objects from threading?