I'm using Suds to access a SOAP web service from python. If I have multiple threading.Thread threads of execution, can each of them safely access the same suds.client.Client instance concurrently, or must I create separate Client objects for each thread?
I need to get a path to the GIT on Max OS X 10.6 using Python 2.6.1 into script variables. I use this code for that:
r = subprocess.Popen(shlex.split("which git"), stdout=subprocess.PIPE)
print r.stdout.read()
but the problem is that output is empty (I tried stderr too). It works fine with another commands such as pwd or ls.
Can anyone help me with that?
I have a file that I need to "protect" so that it cannot be copied! I am using Python on Windows XP.
I think it may just be changing file permissions??
I am having a heck of a time taking the information in a tweet including hashtags, and pulling each hashtag into an array using Python. I am embarrassed to even put what I have been trying thus far.
For example, "I love #stackoverflow because #people are very #helpful!"
This should pull the 3 hashtags into an array.
this is my code:
print '??'.decode('gb2312').encode('utf-8')
and it print :
SyntaxError: Non-ASCII character '\xe5' in file D:\zjm_code\a.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
how to print '??'
thanks
There is a certain page on my website where I want to prevent the same user from visiting it twice in a row. To prevent this, I plan to create a Lock object (from Python's threading library). However, I would need to store that across sessions. Is there anything I should watch out for when trying to store a Lock object in a session (specifically a Beaker session)?
How do you determine which file is imported in Python with an "import" statement?
I am want to determine that I am loading the correct version of a locally modified .py file. Basically the equivalent of "which" in a POSIX environment.
I am trying to add the ability to send mails using the default mail client from my python app.
It can be done with the webbrowser module by opening a 'mailto:' URI. But, is there a better and direct way to do this like java's Desktop.mail(URI).
Thanks in advance.
Python: How to get the caller's method name in the called method?
Assume I have 2 methods:
def method1(self):
...
a = A.method2()
def method2(self):
...
If I don't want to do any change for method1, how to get the name of the caller (in this example, the name is method1) in method2?
want to ask user to input something but not want to wait forever. There is a solution for Linux, http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python, but I am in windows environment. anybody can help me?
Hello,
I'm trying to open a write-protected ms excel 2007 file using win32com in python -- I know the password. I can open it with user input of the password into the excel dialog box. I want to be able to open the file without any user interaction. I've tried the following, but it still pops up the dialog box.
app.Workbooks.Open("filename.xls", WriteResPassword="secret")
Any ideas what I'm doing wrong please?
Thanks,
Dave.
I've been using Pythonfor quite a while now, and I'm still unsure as to why you would subclass from object. What is the difference between this:
class MyClass():
pass
And this:
class MyClass(object):
pass
As far as I understand, object is the base class for all classes and the subclassing is implied. Do you get anything from explicitly subclassing from it? What is the most "Pythonic" thing to do?
Where can i find good practice python problems with solutions?
I'm looking for detailed practice problems that are designed with a coding purpose in mind.
I maintain a few Python packages. I have a very similar setup.py file for each of them. However, when doing setup.py install, one of my packages gets installed as an egg, while the others get installed as "egg folders", i.e. folders with an extension of "egg".
I couldn't figure out what is the difference between them that causes this different behavior. What can it be?
Hi,
We have discussion in my job place about question (We use 1 of the php frameworks):
Why program with php frameworks big web application if it can be done better with rubi on rails, python or java?
Please say our opinion
thanks
I want to start using Pythonfor small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?
I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?
For the following Python dictionary:
dict = {
'stackoverflow': True,
'superuser': False,
'serverfault': False,
'meta': True,
}
I want to aggregate the boolean values above into the following boolean expression:
dict['stackoverflow'] and dict['superuser'] and dict['serverfault'] and dict['meta']
The above should return me False. I'm using keys with known names above but I want it to work so that there can be an infinite number of unknown key names.
i have users from all timezones, and i want to send out alerts at around 8AM in each users respective timezone.
i need a python script that runs every hour [in a cron job] and i need to find out at which timezone it is 8AM right now, and i can use that info to select the users that have to receive the alerts.
how do i go about doing this? there seems to be gmt+14 to gmt-12 that is 27 timezones, and there are only 24 hours in a day!
I've got a piece of software which consists of several python sources and a couple of c++ libraries. I'd like to pack them in a executable single file, just like java does with .jar files. Is there a way to do that?
A project that involves image processing, i.e. to calculate the angular shift of the same image when shifted by a medium of certain Refractive Index. We have to build an app that correlates the 2 images (phase/2D correlation?) and then plot using Chaco and Mayavi (2 libraries in Python).
Is there any other existing template software (FOSS) that we can base our app on, or use it as a reference?
I'm parsing some code and want to match the doxygen comments before a function. However, because I want to match for a specific function name, getting only the immediately previous comment is giving me problems.
Is there a way to search backward through a string using the Python Regex library?
Is there a better (easier) approach that I'm missing?
Hello,
How would I pass a Python variable to the Bash shell? It should work like this:
foo="./RetVar.py 42"
Replace the double-quotes with `s
I have tried printing and sys.exiting the result, but to no avail. How would I accomplish my goal?
Hi boys, im newest... I've got a simple question... wich is better? Python or C++? I wanna study computational science, and i like algorithms and TAD analyses... what do you prefer?
In Perl, I would write:
$x = "abbbc";
$x =~ s/(b+)/z/;
print "Replaced $1 and ended up with $x\n";
# "Replaced bbb and ended up with azc"
How do I do this in Python -- do a regular-expression string replacement and record what it was that got replaced?