text
stringlengths
200
200k
source
stringclasses
2 values
# How does one do the equivalent of "import * from module" with Python's __import__ function? ## Question Given a string with a module name, how do you import everything in the module as if you had called: from module import * i.e. given string S="module", how does one get the equivalent of the following: __import...
stackoverflow-qa
# How does one do the equivalent of "import * from module" with Python's __import__ function? ## Question Given a string with a module name, how do you import everything in the module as if you had called: from module import * i.e. given string S="module", how does one get the equivalent of the following: __import...
stackoverflow-qa
# Django VMware appliance ## Question Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware appliance? A "vanilla" Django 1.0 appliance where postgresql can be installed manually would also do. ## Answer Configure and build your appliance at Elastic Server On-Demand. Tags: python, django, vmware
stackoverflow-qa
# Django VMware appliance ## Question Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware appliance? A "vanilla" Django 1.0 appliance where postgresql can be installed manually would also do. ## Answer Another option I've had moderate success with TurnKey Linux Django Appliance Tags: python, ...
stackoverflow-qa
# Django VMware appliance ## Question Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware appliance? A "vanilla" Django 1.0 appliance where postgresql can be installed manually would also do. ## Answer In addition to the other appliances suggested, you may want to take a look at our BitNami Dja...
stackoverflow-qa
# Debug Pylons application through Eclipse ## Question I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ## Answer Create a new launch c...
stackoverflow-qa
# Debug Pylons application through Eclipse ## Question I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ## Answer yanjost has it right,...
stackoverflow-qa
# Debug Pylons application through Eclipse ## Question I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ## Answer On linux that will pr...
stackoverflow-qa
# Debug Pylons application through Eclipse ## Question I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ## Answer I was able to get --r...
stackoverflow-qa
# Debug Pylons application through Eclipse ## Question I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ## Answer I also got this worki...
stackoverflow-qa
# Debug Pylons application through Eclipse ## Question I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ## Answer If you'd rather not i...
stackoverflow-qa
# How do I manipulate bits in Python? ## Question In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ## Answer value = 0xdeadbeef value &= ~(1<<10) Tags: python
stackoverflow-qa
# How do I manipulate bits in Python? ## Question In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ## Answer Have you tried copying and pasting your code into the Python REPL to see what will happen? >...
stackoverflow-qa
# How do I manipulate bits in Python? ## Question In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ## Answer Omit the 'unsigned long', and the semi-colons are not needed either: value = 0xDEADBEEF valu...
stackoverflow-qa
# How do I manipulate bits in Python? ## Question In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ## Answer Python has C style bit manipulation operators, so your example is literally the same in Pytho...
stackoverflow-qa
# How do I manipulate bits in Python? ## Question In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ## Answer Bitwise operations on Python ints work much like in C. The &, | and ^ operators in Python wor...
stackoverflow-qa
# How do I manipulate bits in Python? ## Question In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ## Answer You should also check out BitArray, which is a nice interface for dealing with sequences of b...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# Character reading from file in Python ## Question In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do th...
stackoverflow-qa
# In Django is there a way to display choices as checkboxes? ## Question In the admin interface and newforms there is the brilliant helper of being able to define choices. You can use code like this: APPROVAL_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ('cancelled', 'Cancelled'), ) client_approved = models...
stackoverflow-qa
# Preserving signatures of decorated functions ## Question Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): arg...
stackoverflow-qa
# Preserving signatures of decorated functions ## Question Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): arg...
stackoverflow-qa
# Preserving signatures of decorated functions ## Question Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): arg...
stackoverflow-qa
# Preserving signatures of decorated functions ## Question Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): arg...
stackoverflow-qa
# Preserving signatures of decorated functions ## Question Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): arg...
stackoverflow-qa
# Using OR comparisons with IF statements ## Question When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept m...
stackoverflow-qa
# Using OR comparisons with IF statements ## Question When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept m...
stackoverflow-qa
# Using OR comparisons with IF statements ## Question When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept m...
stackoverflow-qa
# Using OR comparisons with IF statements ## Question When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept m...
stackoverflow-qa
# Using OR comparisons with IF statements ## Question When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept m...
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer This ActiveState Python recipe might be helpful: http://code.activestate.com/recipes/491261/ Tags: python, caching, urllib2
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer If you don't mind working at a slightly lower level, httplib2 (http://code.google.com/p/httplib2/) is an excellent HTTP library that includes caching functionality. ...
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer You could use a decorator function such as: class cache(object): def __init__(self, fun): self.fun = fun self.cache = {} def __call__(self,...
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer I was looking for something similar, and came across "Recipe 491261: Caching and throttling for urllib2" which danivo posted. The problem is I really dislike the cac...
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer This article on Yahoo Developer Network - http://developer.yahoo.com/python/python-caching.html - describes how to cache http calls made through urllib to either mem...
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer I've always been torn between using httplib2, which does a solid job of handling HTTP caching and authentication, and urllib2, which is in the stdlib, has an extensi...
stackoverflow-qa
# Caching in urllib2? ## Question Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ## Answer @dbr: you may need to add also https responses caching with : def https_response(self, request, response): return self.http_response(request,response) Tags: py...
stackoverflow-qa
# Keeping GUIs responsive during long-running tasks ## Question Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. Here's a good discussion of how to do this in wxPython. To summarize, there are 3 ways: Use threads Use wxYield Chunk...
stackoverflow-qa
# Keeping GUIs responsive during long-running tasks ## Question Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. Here's a good discussion of how to do this in wxPython. To summarize, there are 3 ways: Use threads Use wxYield Chunk...
stackoverflow-qa
# Keeping GUIs responsive during long-running tasks ## Question Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. Here's a good discussion of how to do this in wxPython. To summarize, there are 3 ways: Use threads Use wxYield Chunk...
stackoverflow-qa
# Keeping GUIs responsive during long-running tasks ## Question Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. Here's a good discussion of how to do this in wxPython. To summarize, there are 3 ways: Use threads Use wxYield Chunk...
stackoverflow-qa
# Keeping GUIs responsive during long-running tasks ## Question Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. Here's a good discussion of how to do this in wxPython. To summarize, there are 3 ways: Use threads Use wxYield Chunk...
stackoverflow-qa
# Is there a way to define which fields in the model are editable in the admin app? ## Question Assume the following: models.py class Entry(models.Model): title = models.CharField(max_length=50) slug = models.CharField(max_length=50, unique=True) body = models.CharField(max_length=200) admin.py class ...
stackoverflow-qa
# Background tasks on appengine ## Question How to run background tasks on appengine ? ## Answer GAE is very useful tool to build scalable web applications. Few of the limitations pointed out by many are no support for background tasks, lack of periodic tasks and strict limit on how much time each HTTP request takes,...
stackoverflow-qa
# Background tasks on appengine ## Question How to run background tasks on appengine ? ## Answer Up and coming version of runtime will have some kind of periodic execution engine a'la cron. See this message on AppEngine group. So, all the SDK pieces appear to work, but my testing indicates this isn't running on t...
stackoverflow-qa
# Background tasks on appengine ## Question How to run background tasks on appengine ? ## Answer Using the Deferred Python Library is the easiest way of doing background task on Appengine using Python which is built on top of TaskQueue API. from google.appengine.ext import deferred def do_something_expensive(a, b, ...
stackoverflow-qa
# Python desktop widgets ## Question I'm interested in making desktop widgets, similar to Apple's Dashboard or what Vista has. I'd like to make them cross-platform, if possible. Opera's widgets are cross-platform but require the user to have Opera installed, so that's a big limitation. I know most widgets are made wi...
stackoverflow-qa
# Python desktop widgets ## Question I'm interested in making desktop widgets, similar to Apple's Dashboard or what Vista has. I'd like to make them cross-platform, if possible. Opera's widgets are cross-platform but require the user to have Opera installed, so that's a big limitation. I know most widgets are made wi...
stackoverflow-qa
# BeautifulSoup's Python 3 compatibility ## Question Does BeautifulSoup work with Python 3? If not, how soon will there be a port? Will there be a port at all? Google doesn't turn up anything to me (Maybe it's 'coz I'm looking for the wrong thing?) ## Answer I'm guessing the answer is "No". According to Python.or...
stackoverflow-qa
# BeautifulSoup's Python 3 compatibility ## Question Does BeautifulSoup work with Python 3? If not, how soon will there be a port? Will there be a port at all? Google doesn't turn up anything to me (Maybe it's 'coz I'm looking for the wrong thing?) ## Answer There's a release candidate for Python 3.0 available, so...
stackoverflow-qa
# BeautifulSoup's Python 3 compatibility ## Question Does BeautifulSoup work with Python 3? If not, how soon will there be a port? Will there be a port at all? Google doesn't turn up anything to me (Maybe it's 'coz I'm looking for the wrong thing?) ## Answer About two months after I asked this question, a port has...
stackoverflow-qa
# BeautifulSoup's Python 3 compatibility ## Question Does BeautifulSoup work with Python 3? If not, how soon will there be a port? Will there be a port at all? Google doesn't turn up anything to me (Maybe it's 'coz I'm looking for the wrong thing?) ## Answer http://www.crummy.com/software/BeautifulSoup/ says: ...
stackoverflow-qa
# BeautifulSoup's Python 3 compatibility ## Question Does BeautifulSoup work with Python 3? If not, how soon will there be a port? Will there be a port at all? Google doesn't turn up anything to me (Maybe it's 'coz I'm looking for the wrong thing?) ## Answer Beautiful Soup 4.x officially supports Python 3. pip in...
stackoverflow-qa
# What is the difference between __reduce__ and __reduce_ex__? ## Question I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both? ## Answer The docs say that If provided, at pickling time ...
stackoverflow-qa
# What is the difference between __reduce__ and __reduce_ex__? ## Question I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both? ## Answer __reduce_ex__ is what __reduce__ should have been but ...
stackoverflow-qa
# How do you break into the debugger from Python source code? ## Question What do you insert into Python source code to have it break into pdb (when execution gets to that spot)? ## Answer import pdb; pdb.set_trace() See Python: Coding in the Debugger for Beginners for this and more helpful hints. Tags: python, de...
stackoverflow-qa
# Send file using POST from a Python script ## Question This is an almost-duplicate of http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to find...
stackoverflow-qa
# Send file using POST from a Python script ## Question This is an almost-duplicate of http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to find...
stackoverflow-qa
# Send file using POST from a Python script ## Question This is an almost-duplicate of http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to find...
stackoverflow-qa
# How Does One Read Bytes from File in Python ## Question Similar to this question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python. I first read all ten bytes into a string. I then want to parse out the individual pieces of information. I can grab...
stackoverflow-qa
# How Does One Read Bytes from File in Python ## Question Similar to this question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python. I first read all ten bytes into a string. I then want to parse out the individual pieces of information. I can grab...
stackoverflow-qa
# How Does One Read Bytes from File in Python ## Question Similar to this question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python. I first read all ten bytes into a string. I then want to parse out the individual pieces of information. I can grab...
stackoverflow-qa
# How Does One Read Bytes from File in Python ## Question Similar to this question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python. I first read all ten bytes into a string. I then want to parse out the individual pieces of information. I can grab...
stackoverflow-qa
# Is there any Visual Library alternative to wxPython that supports CSS/Style Sheets? ## Question I've developed a program that extensively uses wxPython - the wxWindow port for python. Even though it is as mature library it is still very primitive and very programming oriented. Which is time consuming and not flexi...
stackoverflow-qa
# Is there any Visual Library alternative to wxPython that supports CSS/Style Sheets? ## Question I've developed a program that extensively uses wxPython - the wxWindow port for python. Even though it is as mature library it is still very primitive and very programming oriented. Which is time consuming and not flexi...
stackoverflow-qa
# How do I calculate number of days betwen two dates using Python? ## Question If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days? ## Answer If you have two date objects, you can just subtract them. from datetime import date d0 = date(2008, 8, 18) d1 = ...
stackoverflow-qa
# How do I calculate number of days betwen two dates using Python? ## Question If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days? ## Answer Using the power of datetime: from datetime import datetime date_format = "%m/%d/%Y" a = datetime.strptime('8/18/2...
stackoverflow-qa
# How do I calculate number of days betwen two dates using Python? ## Question If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days? ## Answer Days until Christmas: >>> import datetime >>> today = datetime.date.today() >>> someday = datetime.date(2008, 12,...
stackoverflow-qa
# How do I calculate number of days betwen two dates using Python? ## Question If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days? ## Answer You want the datetime module. >>> from datetime import datetime >>> datetime(2008,08,18) - datetime(2008,09,26)...
stackoverflow-qa
# How do I calculate number of days betwen two dates using Python? ## Question If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days? ## Answer from datetime import datetime start_date = datetime.strptime('8/18/2008', "%m/%d/%Y") end_date = datetime.strptime...
stackoverflow-qa
# How do I calculate number of days betwen two dates using Python? ## Question If I have two dates (ex. '8/18/2008' and '9/26/2008') what is the best way to get the difference measured in days? ## Answer from datetime import date def d(s): [month, day, year] = map(int, s.split('/')) return date(year, month, day) ...
stackoverflow-qa
# Get other running processes window sizes in Python ## Question This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processe...
stackoverflow-qa
# Get other running processes window sizes in Python ## Question This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processe...
stackoverflow-qa
# Get other running processes window sizes in Python ## Question This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processe...
stackoverflow-qa
# Errors with Python's mechanize module ## Question I'm using the mechanize module to execute some web queries from Python. I want my program to be error-resilient and handle all kinds of errors (wrong URLs, 403/404 responsese) gracefully. However, I can't find in mechanize's documentation the errors / exceptions it t...
stackoverflow-qa
# Errors with Python's mechanize module ## Question I'm using the mechanize module to execute some web queries from Python. I want my program to be error-resilient and handle all kinds of errors (wrong URLs, 403/404 responsese) gracefully. However, I can't find in mechanize's documentation the errors / exceptions it t...
stackoverflow-qa
# Errors with Python's mechanize module ## Question I'm using the mechanize module to execute some web queries from Python. I want my program to be error-resilient and handle all kinds of errors (wrong URLs, 403/404 responsese) gracefully. However, I can't find in mechanize's documentation the errors / exceptions it t...
stackoverflow-qa
# Is it OK to inspect properties beginning with underscore? ## Question I've been working on a very simple crud generator for pylons. I came up with something that inspects SomeClass._sa_class_manager.mapper.c Is it ok to inspect this (or to call methods begining with underscore)? I always kind of assumed this is ...
stackoverflow-qa
# Is it OK to inspect properties beginning with underscore? ## Question I've been working on a very simple crud generator for pylons. I came up with something that inspects SomeClass._sa_class_manager.mapper.c Is it ok to inspect this (or to call methods begining with underscore)? I always kind of assumed this is ...
stackoverflow-qa
# Looking for a regular expression including aplhanumeric + "&" and ";" ## Question Here's the problem: split=re.compile('\W*') works fine when dealing with regular words, but there are occasions where I need the expression to include words like k&auml;ytt&auml;j&aml;auml;. What should I add to the regex to include...
stackoverflow-qa
# Looking for a regular expression including aplhanumeric + "&" and ";" ## Question Here's the problem: split=re.compile('\W*') works fine when dealing with regular words, but there are occasions where I need the expression to include words like k&auml;ytt&auml;j&aml;auml;. What should I add to the regex to include...
stackoverflow-qa
# Looking for a regular expression including aplhanumeric + "&" and ";" ## Question Here's the problem: split=re.compile('\W*') works fine when dealing with regular words, but there are occasions where I need the expression to include words like k&auml;ytt&auml;j&aml;auml;. What should I add to the regex to include...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer isinstance(o, str) Link Tags: py...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer isinstance(o, str) will return true...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer To check if the type of o is exactl...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer I think the cool thing about using ...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer The most Pythonic way to check the ...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer To Hugo: You probably mean list ra...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer Here is an example why duck typing ...
stackoverflow-qa
# What's the canonical way to check for type in python? ## Question What is the best way to check whether a given object is of a given type? How about checking whether the object inherits from a given type? Let's say I have an object o. How do I check whether it's a str? ## Answer Since the question was asked and an...
stackoverflow-qa
# Runnning a Python web server as a service in Windows ## Question I have a small web server application I've written in Python that goes and gets some data from a database system and returns it to the user as XML. That part works fine - I can run the Python web server application from the command line and I can have ...
stackoverflow-qa
# Extension functions and 'help' ## Question When I call help(Mod.Cls.f) (Mod is a C extension module), I get the output Help on method_descriptor: f(...) doc_string What do I need to do so that the help output is of the form Help on method f in module Mod: f(x, y, z) doc_string like it is for random....
stackoverflow-qa
# Extension functions and 'help' ## Question When I call help(Mod.Cls.f) (Mod is a C extension module), I get the output Help on method_descriptor: f(...) doc_string What do I need to do so that the help output is of the form Help on method f in module Mod: f(x, y, z) doc_string like it is for random....
stackoverflow-qa
# How to iterate over a timespan after days, hours, weeks and months in Python? ## Question How do I iterate over a timespan after days, hours, weeks or months? Something like: for date in foo(from_date, to_date, delta=HOURS): print date Where foo is a function, returning an iterator. I've been looking at the ...
stackoverflow-qa
# How to iterate over a timespan after days, hours, weeks and months in Python? ## Question How do I iterate over a timespan after days, hours, weeks or months? Something like: for date in foo(from_date, to_date, delta=HOURS): print date Where foo is a function, returning an iterator. I've been looking at the ...
stackoverflow-qa