text stringlengths 200 200k | source stringclasses 2
values |
|---|---|
# extracting text from MS word files in python
## Question
for working with MS word files in python, there is python win32 extensions, which can be used in windows. How do I do the same in linux?
Is there any library?
## Answer
Just an option for reading 'doc' files without using COM: miette. Should work on any platf... | stackoverflow-qa |
# extracting text from MS word files in python
## Question
for working with MS word files in python, there is python win32 extensions, which can be used in windows. How do I do the same in linux?
Is there any library?
## Answer
If you have LibreOffice installed, you can simply call it from the command line to convert... | stackoverflow-qa |
# extracting text from MS word files in python
## Question
for working with MS word files in python, there is python win32 extensions, which can be used in windows. How do I do the same in linux?
Is there any library?
## Answer
Is this an old question?
I believe that such thing does not exist.
There are only answered... | stackoverflow-qa |
# How do I modify a text file in Python?
## Question
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
## Answer
Depends on what you want to do. To append you can open it with "a":
with open("foo.txt", "a") as f:
f.write("new line\n")... | stackoverflow-qa |
# How do I modify a text file in Python?
## Question
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
## Answer
Unfortunately there is no way to insert into the middle of a file without re-writing it. As previous posters have indicated, you ... | stackoverflow-qa |
# How do I modify a text file in Python?
## Question
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
## Answer
Rewriting a file in place is often done by saving the old copy with a modified name. Unix folks add a ~ to mark the old one. Wi... | stackoverflow-qa |
# How do I modify a text file in Python?
## Question
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
## Answer
Python's mmap module will allow you to insert into a file. The following sample shows how it can be done in Unix (Windows mmap ma... | stackoverflow-qa |
# How do I modify a text file in Python?
## Question
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
## Answer
The fileinput module of the Python standard library will rewrite a file inplace if you use the inplace=1 parameter:
import sys
i... | stackoverflow-qa |
# How do I modify a text file in Python?
## Question
I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?
## Answer
As mentioned by Adam you have to take your system limitations into consideration before you can decide on approach whether you ha... | stackoverflow-qa |
# Python library for rendering HTML and javascript
## Question
Is there any python module for rendering a HTML page with javascript and get back a DOM object?
I want to parse a page which generates almost all of its content using javascript.
## Answer
Only way I know to accomplish this would be to drive real browser... | stackoverflow-qa |
# Python library for rendering HTML and javascript
## Question
Is there any python module for rendering a HTML page with javascript and get back a DOM object?
I want to parse a page which generates almost all of its content using javascript.
## Answer
The big complication here is emulating the full browser environme... | stackoverflow-qa |
# Python library for rendering HTML and javascript
## Question
Is there any python module for rendering a HTML page with javascript and get back a DOM object?
I want to parse a page which generates almost all of its content using javascript.
## Answer
QtWebKit is contained in PyQt4, but I don't know if you can use i... | stackoverflow-qa |
# Python library for rendering HTML and javascript
## Question
Is there any python module for rendering a HTML page with javascript and get back a DOM object?
I want to parse a page which generates almost all of its content using javascript.
## Answer
You can probably use python-webkit for it. Requires a running gl... | stackoverflow-qa |
# Example Facebook Application using TurboGears -- pyFacebook
## Question
I have a TurboGears application I'd like to run through Facebook, and am looking for an example TurboGears project using pyFacebook or minifb.py. pyFacebook is Django-centric, and I can probably figure it out, but this is, after all, the lazy w... | stackoverflow-qa |
# Example Facebook Application using TurboGears -- pyFacebook
## Question
I have a TurboGears application I'd like to run through Facebook, and am looking for an example TurboGears project using pyFacebook or minifb.py. pyFacebook is Django-centric, and I can probably figure it out, but this is, after all, the lazy w... | stackoverflow-qa |
# Iterate a list with indexes in Python
## Question
I could swear I've seen the function (or method) that takes a list, like this [3, 7, 19] and makes it into iterable list of tuples, like so: [(0,3), (1,7), (2,19)] to use it instead of:
for i in range(len(name_of_list)):
name_of_list[i] = something
but I can't... | stackoverflow-qa |
# Iterate a list with indexes in Python
## Question
I could swear I've seen the function (or method) that takes a list, like this [3, 7, 19] and makes it into iterable list of tuples, like so: [(0,3), (1,7), (2,19)] to use it instead of:
for i in range(len(name_of_list)):
name_of_list[i] = something
but I can't... | stackoverflow-qa |
# Iterate a list with indexes in Python
## Question
I could swear I've seen the function (or method) that takes a list, like this [3, 7, 19] and makes it into iterable list of tuples, like so: [(0,3), (1,7), (2,19)] to use it instead of:
for i in range(len(name_of_list)):
name_of_list[i] = something
but I can't... | stackoverflow-qa |
# Iterate a list with indexes in Python
## Question
I could swear I've seen the function (or method) that takes a list, like this [3, 7, 19] and makes it into iterable list of tuples, like so: [(0,3), (1,7), (2,19)] to use it instead of:
for i in range(len(name_of_list)):
name_of_list[i] = something
but I can't... | stackoverflow-qa |
# Iterate a list with indexes in Python
## Question
I could swear I've seen the function (or method) that takes a list, like this [3, 7, 19] and makes it into iterable list of tuples, like so: [(0,3), (1,7), (2,19)] to use it instead of:
for i in range(len(name_of_list)):
name_of_list[i] = something
but I can't... | stackoverflow-qa |
# Checking for code changes in all imported python modules
## Question
Almost every Python web framework has a simple server that runs a wsgi application and automatically reloads the imported modules every time the source gets changed. I know I can look at the code and see how it's done, but that may take some time a... | stackoverflow-qa |
# Checking for code changes in all imported python modules
## Question
Almost every Python web framework has a simple server that runs a wsgi application and automatically reloads the imported modules every time the source gets changed. I know I can look at the code and see how it's done, but that may take some time a... | stackoverflow-qa |
# Find out number of capture groups in Python regular expressions
## Question
Is there a way to determine how many capture groups there are in a given regular expression?
I would like to be able to do the follwing:
def groups(regexp, s):
""" Returns the first result of re.findall, or an empty default
>>> gr... | stackoverflow-qa |
# Find out number of capture groups in Python regular expressions
## Question
Is there a way to determine how many capture groups there are in a given regular expression?
I would like to be able to do the follwing:
def groups(regexp, s):
""" Returns the first result of re.findall, or an empty default
>>> gr... | stackoverflow-qa |
# Find out number of capture groups in Python regular expressions
## Question
Is there a way to determine how many capture groups there are in a given regular expression?
I would like to be able to do the follwing:
def groups(regexp, s):
""" Returns the first result of re.findall, or an empty default
>>> gr... | stackoverflow-qa |
# Find out number of capture groups in Python regular expressions
## Question
Is there a way to determine how many capture groups there are in a given regular expression?
I would like to be able to do the follwing:
def groups(regexp, s):
""" Returns the first result of re.findall, or an empty default
>>> gr... | stackoverflow-qa |
# Contributing to Python
## Question
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
## Answer
I guess one way would be to help with documentation (tr... | stackoverflow-qa |
# Contributing to Python
## Question
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
## Answer
If you aren't up to actually working on the Python core... | stackoverflow-qa |
# Contributing to Python
## Question
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
## Answer
Get involved with the community: http://www.python.org... | stackoverflow-qa |
# Contributing to Python
## Question
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
## Answer
Add to the docs. it is downright crappy
Help out other ... | stackoverflow-qa |
# Contributing to Python
## Question
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
## Answer
Build something cool in Python and share it with others... | stackoverflow-qa |
# Contributing to Python
## Question
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand oop), but Python is so awesome that I would like to help the community. What's the best way for a beginner to contribute?
## Answer
I see two ways of going about it: working on Python dir... | stackoverflow-qa |
# Editing XML as a dictionary in python?
## Question
I'm trying to generate customized xml files from a template xml file in python.
Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:
con... | stackoverflow-qa |
# Editing XML as a dictionary in python?
## Question
I'm trying to generate customized xml files from a template xml file in python.
Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:
con... | stackoverflow-qa |
# Editing XML as a dictionary in python?
## Question
I'm trying to generate customized xml files from a template xml file in python.
Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:
con... | stackoverflow-qa |
# Editing XML as a dictionary in python?
## Question
I'm trying to generate customized xml files from a template xml file in python.
Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:
con... | stackoverflow-qa |
# Editing XML as a dictionary in python?
## Question
I'm trying to generate customized xml files from a template xml file in python.
Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:
con... | stackoverflow-qa |
# How to implement a Decorator with non-local equality?
## Question
Greetings, currently I am refactoring one of my programs, and I found an interesting problem.
I have Transitions in an automata. Transitions always have a start-state and an end-state. Some Transitions have a label, which encodes a certain Action tha... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
What is the exact error yo... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
import re,datetime
s="2008... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
Try the iso8601 module; it... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
Note in Python 2.6+ and Py... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
For something that works w... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
I've coded up a parser for... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
The python-dateutil packag... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
The python-dateutil will t... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
If you don't want to use d... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
Nobody has mentioned it ye... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
This works for stdlib on P... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
Several answers here sugge... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
If you are working with Dj... | stackoverflow-qa |
# How to parse an ISO 8601-formatted date in Python?
## Question
I need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.
I have found strptime in the Python standard library, but it is not very convenient.
What is the best way to do this?
## Answer
Django's parse_datetime() ... | stackoverflow-qa |
# What is the best way to store set data in Python?
## Question
I have a list of data in the following form:
[(id\__1_, description, id\_type), (id\__2_, description, id\_type), ... , (id\__n_, description, id\_type))
The data are loaded from files that belong to the same group. In each group there could be multiple... | stackoverflow-qa |
# What is the best way to store set data in Python?
## Question
I have a list of data in the following form:
[(id\__1_, description, id\_type), (id\__2_, description, id\_type), ... , (id\__n_, description, id\_type))
The data are loaded from files that belong to the same group. In each group there could be multiple... | stackoverflow-qa |
# What is the best way to store set data in Python?
## Question
I have a list of data in the following form:
[(id\__1_, description, id\_type), (id\__2_, description, id\_type), ... , (id\__n_, description, id\_type))
The data are loaded from files that belong to the same group. In each group there could be multiple... | stackoverflow-qa |
# What's the best way to upgrade from Django 0.96 to 1.0?
## Question
Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?
## Answer
Upgrade. For me it was very simple: change __str__() to __unicode__(), write basic admin.py, and done. Ju... | stackoverflow-qa |
# What's the best way to upgrade from Django 0.96 to 1.0?
## Question
Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?
## Answer
Although this depends on what you're doing, most applications should be able to just upgrade and then fix... | stackoverflow-qa |
# What's the best way to upgrade from Django 0.96 to 1.0?
## Question
Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?
## Answer
Just upgrade your app. The switch from 0.96 to 1.0 was huge, but in terms of Backwards Incompatible chang... | stackoverflow-qa |
# What's the best way to upgrade from Django 0.96 to 1.0?
## Question
Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?
## Answer
Only simplest sites are easy to upgrade.
Expect real pain if your site happen to be for non-ASCII part o... | stackoverflow-qa |
# What's the best way to upgrade from Django 0.96 to 1.0?
## Question
Should I try to actually upgrade my existing app, or just rewrite it mostly from scratch, saving what pieces (templates, etc) I can?
## Answer
We upgraded in a multi step process and I'm quite happy with that. The application in Question was about ... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Should Python import statements always be at the top of a module?
## Question
PEP 08 states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
However if the class/method/function that I am importing is only used in rare cases... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Using property() on classmethods
## Question
I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in... | stackoverflow-qa |
# Doing CRUD in Turbogears
## Question
Are there any good packages or methods for doing extensive CRUD (create-retrieve-update-delete) interfaces in the Turbogears framework. The FastDataGrid widget is too much of a black box to be useful and CRUDTemplate looks like more trouble than rolling my own. Ideas? Suggestions... | stackoverflow-qa |
# Doing CRUD in Turbogears
## Question
Are there any good packages or methods for doing extensive CRUD (create-retrieve-update-delete) interfaces in the Turbogears framework. The FastDataGrid widget is too much of a black box to be useful and CRUDTemplate looks like more trouble than rolling my own. Ideas? Suggestions... | stackoverflow-qa |
# Does Django support multi-value cookies?
## Question
I'd like to set a cookie via Django with that has several different values to it, similar to .NET's HttpCookie.Values property. Looking at the documentation, I can't tell if this is possible. It looks like it just takes a string, so is there another way?
I've tri... | stackoverflow-qa |
# Does Django support multi-value cookies?
## Question
I'd like to set a cookie via Django with that has several different values to it, similar to .NET's HttpCookie.Values property. Looking at the documentation, I can't tell if this is possible. It looks like it just takes a string, so is there another way?
I've tri... | stackoverflow-qa |
# Does Django support multi-value cookies?
## Question
I'd like to set a cookie via Django with that has several different values to it, similar to .NET's HttpCookie.Values property. Looking at the documentation, I can't tell if this is possible. It looks like it just takes a string, so is there another way?
I've tri... | stackoverflow-qa |
# Perl or Python script to remove user from group
## Question
I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from ... | stackoverflow-qa |
# Perl or Python script to remove user from group
## Question
I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from ... | stackoverflow-qa |
# Perl or Python script to remove user from group
## Question
I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from ... | stackoverflow-qa |
# Perl or Python script to remove user from group
## Question
I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from ... | stackoverflow-qa |
# Generic Exception Handling in Python the "Right Way"
## Question
Sometimes I find myself in the situation where I want to execute several sequential commands like such:
try:
foo(a, b)
except Exception, e:
baz(e)
try:
bar(c, d)
except Exception, e:
baz(e)
...
This same pattern occurs when exception... | stackoverflow-qa |
# Generic Exception Handling in Python the "Right Way"
## Question
Sometimes I find myself in the situation where I want to execute several sequential commands like such:
try:
foo(a, b)
except Exception, e:
baz(e)
try:
bar(c, d)
except Exception, e:
baz(e)
...
This same pattern occurs when exception... | stackoverflow-qa |
# Generic Exception Handling in Python the "Right Way"
## Question
Sometimes I find myself in the situation where I want to execute several sequential commands like such:
try:
foo(a, b)
except Exception, e:
baz(e)
try:
bar(c, d)
except Exception, e:
baz(e)
...
This same pattern occurs when exception... | stackoverflow-qa |
# Generic Exception Handling in Python the "Right Way"
## Question
Sometimes I find myself in the situation where I want to execute several sequential commands like such:
try:
foo(a, b)
except Exception, e:
baz(e)
try:
bar(c, d)
except Exception, e:
baz(e)
...
This same pattern occurs when exception... | stackoverflow-qa |
# Generic Exception Handling in Python the "Right Way"
## Question
Sometimes I find myself in the situation where I want to execute several sequential commands like such:
try:
foo(a, b)
except Exception, e:
baz(e)
try:
bar(c, d)
except Exception, e:
baz(e)
...
This same pattern occurs when exception... | stackoverflow-qa |
# How do you test that a Python function throws an exception?
## Question
How does one write a unittest that fails only if a function doesn't throw an expected exception?
## Answer
Have a look at the assertRaises method of the unittest module.
Tags: python, unit-testing, exception, exception-handling | stackoverflow-qa |
# How do you test that a Python function throws an exception?
## Question
How does one write a unittest that fails only if a function doesn't throw an expected exception?
## Answer
Use TestCase.assertRaises (or TestCase.failUnlessRaises) from the unittest module, for example:
import mymod
class MyTestCase(unittest.... | stackoverflow-qa |
# How do you test that a Python function throws an exception?
## Question
How does one write a unittest that fails only if a function doesn't throw an expected exception?
## Answer
Your code should follow this pattern (this is a unittest module style test):
def test_afunction_throws_exception(self):
try:
... | stackoverflow-qa |
# How do you test that a Python function throws an exception?
## Question
How does one write a unittest that fails only if a function doesn't throw an expected exception?
## Answer
The code in my previous answer can be simplified to:
def test_afunction_throws_exception(self):
self.assertRaises(ExpectedException,... | stackoverflow-qa |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.