text
stringlengths
200
200k
source
stringclasses
2 values
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# How to generate dynamic (parametrized) unit tests in python? ## Question I have some kind of test data and want to create an unit test for each item. My first idea was to do it like this: import unittest l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]] class TestSequence(unittest.TestCase): def ...
stackoverflow-qa
# ssh hangs when command invoked directly, but exits cleanly when run interactive ## Question I need to launch a server on the remote machine and retrieve the port number that the server process is lsitening on. When invoked, the server will listen on a random port and output the port number on stderr. I want to aut...
stackoverflow-qa
# Extending base classes in Python ## Question I'm trying to extend some "base" classes in Python: class xlist (list): def len(self): return len(self) def add(self, *args): self.extend(args) return None class xint (int): def add(self, value): self += value return...
stackoverflow-qa
# Extending base classes in Python ## Question I'm trying to extend some "base" classes in Python: class xlist (list): def len(self): return len(self) def add(self, *args): self.extend(args) return None class xint (int): def add(self, value): self += value return...
stackoverflow-qa
# Extending base classes in Python ## Question I'm trying to extend some "base" classes in Python: class xlist (list): def len(self): return len(self) def add(self, *args): self.extend(args) return None class xint (int): def add(self, value): self += value return...
stackoverflow-qa
# Find out how much memory is being used by an object in Python ## Question How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want. ## Answer...
stackoverflow-qa
# Find out how much memory is being used by an object in Python ## Question How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want. ## Answer...
stackoverflow-qa
# Find out how much memory is being used by an object in Python ## Question How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want. ## Answer...
stackoverflow-qa
# Find out how much memory is being used by an object in Python ## Question How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want. ## Answer...
stackoverflow-qa
# Find out how much memory is being used by an object in Python ## Question How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want. ## Answer...
stackoverflow-qa
# Are Python threads buggy? ## Question A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor? ## Answer As far as I know there are no real bugs, but the performance when threading in cPython is reall...
stackoverflow-qa
# Are Python threads buggy? ## Question A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor? ## Answer Python threads are good for concurrent I/O programming. Threads are swapped out of the CPU as s...
stackoverflow-qa
# Are Python threads buggy? ## Question A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor? ## Answer The GIL (Global Interpreter Lock) might be a problem, but the API is quite OK. Try out the exce...
stackoverflow-qa
# Are Python threads buggy? ## Question A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor? ## Answer The standard implementation of Python (generally known as CPython as it is written in C) uses O...
stackoverflow-qa
# Are Python threads buggy? ## Question A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy - enough to avoid using altogether. What can said about this rumor? ## Answer If you want to code in python and get great threading support, you might want to check out Iron...
stackoverflow-qa
# How to specify an authenticated proxy for a python http connection? ## Question What's the best way to specify a proxy with username and password for an http connection in python? ## Answer This works for me: import urllib2 proxy = urllib2.ProxyHandler({'http': 'http:// username:password@proxyurl:proxyport'}) a...
stackoverflow-qa
# How to specify an authenticated proxy for a python http connection? ## Question What's the best way to specify a proxy with username and password for an http connection in python? ## Answer The best way of going through a proxy that requires authentication is using urllib2 to build a custom url opener, then using t...
stackoverflow-qa
# How to specify an authenticated proxy for a python http connection? ## Question What's the best way to specify a proxy with username and password for an http connection in python? ## Answer Or if you want to install it, so that it is always used with urllib2.urlopen (so you don't need to keep a reference to the ope...
stackoverflow-qa
# How to specify an authenticated proxy for a python http connection? ## Question What's the best way to specify a proxy with username and password for an http connection in python? ## Answer Setting an environment var named http_proxy like this: http://username:password@proxy_url:port Tags: python, http, proxy
stackoverflow-qa
# Django ImageField core=False in newforms admin ## Question In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields. I get the following error: TypeError: __init__() got an unexpected keyword argument 'core' [Edit] However, by just removing the core argument I...
stackoverflow-qa
# Django ImageField core=False in newforms admin ## Question In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields. I get the following error: TypeError: __init__() got an unexpected keyword argument 'core' [Edit] However, by just removing the core argument I...
stackoverflow-qa
# Django ImageField core=False in newforms admin ## Question In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields. I get the following error: TypeError: __init__() got an unexpected keyword argument 'core' [Edit] However, by just removing the core argument I...
stackoverflow-qa
# Python descriptor protocol analog in other languages? ## Question Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any...
stackoverflow-qa
# How do I make Windows aware of a service I have written in Python? ## Question In another question I posted yesterday, I got very good advice on how a Python script could be run as a service in Windows. What I'm left wondering is: How is Windows aware of the services that can be managed in the native tools ("service...
stackoverflow-qa
# How do I make Windows aware of a service I have written in Python? ## Question In another question I posted yesterday, I got very good advice on how a Python script could be run as a service in Windows. What I'm left wondering is: How is Windows aware of the services that can be managed in the native tools ("service...
stackoverflow-qa
# How do I make Windows aware of a service I have written in Python? ## Question In another question I posted yesterday, I got very good advice on how a Python script could be run as a service in Windows. What I'm left wondering is: How is Windows aware of the services that can be managed in the native tools ("service...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Finding what methods an object has ## Question Given a Python object of any kind, is there an easy way to get a list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is...
stackoverflow-qa
# Scaffolding in pylons ## Question Is there anything similar to rails' scaffolding fo pylons? I've been poking around google, but fofund only this thing caled dbsprockets, which is fine, although probably way to much for my needs. What i really need is a basic CRUD thas is based on the SQLAlchemy model. ## Answer I ...
stackoverflow-qa
# Scaffolding in pylons ## Question Is there anything similar to rails' scaffolding fo pylons? I've been poking around google, but fofund only this thing caled dbsprockets, which is fine, although probably way to much for my needs. What i really need is a basic CRUD thas is based on the SQLAlchemy model. ## Answer Th...
stackoverflow-qa
# Validate (X)HTML in Python ## Question What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. ## Answer XHTML is easy, use lxml. HTML ...
stackoverflow-qa
# Validate (X)HTML in Python ## Question What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. ## Answer I think that HTML tidy will do ...
stackoverflow-qa
# Validate (X)HTML in Python ## Question What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. ## Answer Try tidylib. You can get some r...
stackoverflow-qa
# Validate (X)HTML in Python ## Question What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. ## Answer Starting with html5, you can tr...
stackoverflow-qa
# Validate (X)HTML in Python ## Question What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. ## Answer http://countergram.com/software...
stackoverflow-qa
# Validate (X)HTML in Python ## Question What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. ## Answer I think the most elegant way it...
stackoverflow-qa
# Why does Python's iter() on a mapping return iterkeys() instead of iteritems()? ## Question It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this? ## Answer Check out this thread...
stackoverflow-qa
# Ruby "is" equivalent ## Question Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location). ## Answer Use a.equal? b http://www.ruby-doc.org/core/classes/Object.html Unlike ==, the equal? method should never be overridden by subclasses: it is ...
stackoverflow-qa
# Ruby "is" equivalent ## Question Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location). ## Answer You could also use __id__. This gives you the objects internal ID number, which is always unique. To check if to objects are the same, try a._...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Is Python good for big software projects (not web based)? ## Question Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved t...
stackoverflow-qa
# Why is my instance variable not in __dict__? ## Question If I create a class A as follows: class A: def __init__(self): self.name = 'A' Inspecting the __dict__ member looks like {'name': 'A'} If however I create a class B: class B: name = 'B' __dict__ is empty. What is the difference between ...
stackoverflow-qa
# Why is my instance variable not in __dict__? ## Question If I create a class A as follows: class A: def __init__(self): self.name = 'A' Inspecting the __dict__ member looks like {'name': 'A'} If however I create a class B: class B: name = 'B' __dict__ is empty. What is the difference between ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# How to escape os.system() calls in Python? ## Question When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing ...
stackoverflow-qa
# Django templates and variable attributes ## Question I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: <table> <tr align="cent...
stackoverflow-qa
# Django templates and variable attributes ## Question I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: <table> <tr align="cent...
stackoverflow-qa
# Django templates and variable attributes ## Question I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: <table> <tr align="cent...
stackoverflow-qa
# Django templates and variable attributes ## Question I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: <table> <tr align="cent...
stackoverflow-qa
# Django templates and variable attributes ## Question I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: <table> <tr align="cent...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer How about a...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer You can use...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer Use a named...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer dF: that's ...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer You can als...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer Perhaps you...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer Whenever I ...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer You access ...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer This might ...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer You can sub...
stackoverflow-qa
# C-like structures in Python ## Question Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like: class MyStruct(): def __init__(self, field1, field2, field3): self.field1 = field1 self.field2 = field2 self.field3 = field3 ## Answer I wrote a d...
stackoverflow-qa
# How do I sort a list of strings in Python? ## Question What is the best way of creating an alphabetically sorted list in Python? ## Answer list.sort() It really is that simple :) Tags: python, string, sorting
stackoverflow-qa
# How do I sort a list of strings in Python? ## Question What is the best way of creating an alphabetically sorted list in Python? ## Answer Basic answer: mylist = ["b", "C", "A"] mylist.sort() This modifies your original list (i.e. sorts in-place). To get a sorted copy of the list, without changing the original, ...
stackoverflow-qa
# How do I sort a list of strings in Python? ## Question What is the best way of creating an alphabetically sorted list in Python? ## Answer But how does this handle language specific sorting rules? Does it take locale into account? No, list.sort() is a generic sorting function. If you want to sort according to the...
stackoverflow-qa
# How do I sort a list of strings in Python? ## Question What is the best way of creating an alphabetically sorted list in Python? ## Answer It is also worth noting the sorted() function: for x in sorted(list): print x This returns a new, sorted version of a list without changing the original list. Tags: pyth...
stackoverflow-qa
# How do I sort a list of strings in Python? ## Question What is the best way of creating an alphabetically sorted list in Python? ## Answer The proper way to sort strings is: import locale locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') # vary depending on your lang/locale assert sorted((u'Ab', u'ad', u'aa'), cmp=lo...
stackoverflow-qa
# "The system cannot find the file specified" when invoking subprocess.Popen in python ## Question I'm trying to use svnmerge.py to merge some files. Under the hood it uses python, and when I use it I get an error - "The system cannot find the file specified". Colleagues at work are running the same version of svnme...
stackoverflow-qa
# Setup django with WSGI and apache ## Question I have been sold on mod_wsgi and apache rather than mod_python. I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying. I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3 My application is called tred. Here are the...
stackoverflow-qa
# Setup django with WSGI and apache ## Question I have been sold on mod_wsgi and apache rather than mod_python. I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying. I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3 My application is called tred. Here are the...
stackoverflow-qa
# Setup django with WSGI and apache ## Question I have been sold on mod_wsgi and apache rather than mod_python. I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying. I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3 My application is called tred. Here are the...
stackoverflow-qa