I just installed python 2.6 on my mac, mainly because I couldn't find freeze in my 2.5 distribution. I am wondering where freeze is. Is it even installed at all in the mac distribution?
I want to break a Python string into its characters.
sequenceOfAlphabets = list( string.uppercase )
works.
However, why does not
sequenceOfAlphabets = re.split( '.', string.uppercase )
work?
All I get are empty, albeit expected count of elements
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 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!
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?
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
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?
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
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 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 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?
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'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!
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 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 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?
Hi,
What is Python's equivalent of "public static void main(String[] args) { ... }"? I remember having used it in the past and then forgot.
What I'm basically trying to remember is a function which I think included some underscores (__)...
thx
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.
How can I log into my Launchpad account in a python script? Any sample code would be appreciated.
The login url is https://launchpad.net/+login and then redirect to something like https://login.launchpad.net/fJLVSRbxPfKTpVDr/+decide
Thanks in advance!
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?