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?
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?
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
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?
I've been using Python for 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?
I want to start using Python for 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?
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?
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.
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?
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?
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?
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??
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?
I'm writing a script to parse some text files, and insert the data that they contain into a mysql database. I don't have root access on the server that this script will run on. I've been looking at mysql-python, but it requires a bunch of dependencies that I don't have available. Is there a simpler way to do this?
in python , suppose i have file data.txt . which has 6 lines of data . I want to calculate the no of lines which i am planning to do by going through each character and finding out the number of '\n' in the file . How to take one character input from the file ? Readline taken the whole line .
I have a list of elements, and each element consists of four seperate values that are seperated by tabs:
['A\tB\tC\tD', 'Q\tW\tE\tR', etc.]
What I want is to create a larger list without the tabs, so that each value is a seperate element:
['A', 'B', 'C', 'D', 'Q', 'W', 'E', 'R', etc.]
How can I do that in Python? I need it for my coursework, due tonight (midnight GMT) and I'm completely stumped.
In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).
My guess is they are using a common library they have written then just have to use different hooks for the different platforms.
What method of development is this? It clearly isn't IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me.
Its not urgent but I was just wondering how one would go about authenticating against a single db using python and openfire? Is there a simple module that will do this?
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?
I'm currently trying to build a scalable infrastructure for my Python webservers.
Actually, I'm trying to find the most elegant way to build a scalable cluster to host all my Python WebServices.
For now, I'm using three servers like this:
1 x PuppetMaster to deploy my servers.
2 x Apache Reverse Proxy Front-end servers.
1 x Apache HTTPd Server which host the Python WSGI Applications and binded to using mod_wsgi.
4 x MongoDB Clustered server.
Everything is OK concerning the Reverse proxy and the DB Backend, I'm able to easily add a new Reverse Proxy and a new DB Node, but my problem is about the Python WebServer.
I thinked to just provision a new node with exactly the same configuration and a rsync replication between the two nodes, but It's not really usefull in term of deployement for my developpers etc.
So if you have a solution which is as efficient and elegant that the Tomcat Cluster I'll be really happy to ear it ;-)
I am trying to add some security to my computer at home and would like to have a copy of all Yahoo! IMs sent to me. I am using Python 2.6 on Windows.
I would also like to have every URL in Internet Explorer sent to me.
Python offers an optional else clause in loop statements, which is executed if and only if the loop is not terminated by a break. For an interesting discussion about this neglected commodity, see this question. Here, I just wanted to know:
if the very concept of this loop-else construct originates from another language (either theoretical or actually implemented),
conversely, if it was taken up in any newer language.
May be I should ask the former to Guido, but he surely is a too busy guy for such a futile inquiry. ;-)
All the Python built-ins are subclasses of object and I come across many user-defined classes which are too. Why? What is the purpose of the class object? It's just an empty class, right?