text
stringlengths
200
200k
source
stringclasses
2 values
# How can I read the RGB value of a given pixel in Python? ## Question If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel? Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? It would b...
stackoverflow-qa
# How can I read the RGB value of a given pixel in Python? ## Question If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel? Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? It would b...
stackoverflow-qa
# How can I read the RGB value of a given pixel in Python? ## Question If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel? Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? It would b...
stackoverflow-qa
# How can I read the RGB value of a given pixel in Python? ## Question If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel? Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? It would b...
stackoverflow-qa
# How can I read the RGB value of a given pixel in Python? ## Question If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel? Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? It would b...
stackoverflow-qa
# How can I read the RGB value of a given pixel in Python? ## Question If I open an image with open("image.jpg"), how can I get the RGB values of a pixel, if I have the coordinates of the pixel? Then how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? It would b...
stackoverflow-qa
# Dynamic radio button creation ## Question In wxPython, if I create a list of radio buttons and place the list initially, is it possible to change the contents in that list later? For example, I have a panel that uses a boxSizer to place the widgets initially. One of those widgets is a list of radio buttons (I have ...
stackoverflow-qa
# Pure Python XSLT library ## Question Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ## Answer Have you looked at 4suite? Tags: pytho...
stackoverflow-qa
# Pure Python XSLT library ## Question Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ## Answer If you only need basic support, and you...
stackoverflow-qa
# Pure Python XSLT library ## Question Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ## Answer Unfortunately there are no pure-python ...
stackoverflow-qa
# Pure Python XSLT library ## Question Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ## Answer I don't think you can do it in cpython:...
stackoverflow-qa
# Pure Python XSLT library ## Question Is there an XSLT library that is pure Python? Installing libxml2+libxslt or any similar C libraries is a problem on some of the platforms I need to support. I really only need basic XSLT support, and speed is not a major issue. ## Answer There's also http://lxml.de/ "lxml...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Is it feasible to compile Python to machine code? ## Question How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would ne...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Can Regex be used for this particular string manipulation? ## Question I need to replace character (say) x with character (say) P in a string, but only if it is contained in a quoted substring. An example makes it clearer: axbx'cxdxe'fxgh'ixj'k -> axbx'cPdPe'fxgh'iPj'k Let's assume, for the sake of simplicity, t...
stackoverflow-qa
# Vim extension (via Python)? ## Question is it possible to extend vim functionality via custom extension (preferably, written in Python)? What I need ideally is custom command when in command mode. E.g. ESC :do_this :do_that ## Answer vim supports scripting in python (and in perl as well, I think). You just hav...
stackoverflow-qa
# Vim extension (via Python)? ## Question is it possible to extend vim functionality via custom extension (preferably, written in Python)? What I need ideally is custom command when in command mode. E.g. ESC :do_this :do_that ## Answer Yes it is. There are several extensions on http://www.vim.org/scripts/index.ph...
stackoverflow-qa
# Vim extension (via Python)? ## Question is it possible to extend vim functionality via custom extension (preferably, written in Python)? What I need ideally is custom command when in command mode. E.g. ESC :do_this :do_that ## Answer Had a problems to compile Vim with Python. "...checking if compile and link ...
stackoverflow-qa
# How do I test a django database schema? ## Question I want to write tests that can show whether or not the database is in sync with my models.py file. Actually I have already written them, only to find out that django creates a new database each time the tests are run based on the models.py file. Is there any way I...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# listing all functions in a python module ## Question I have a python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it. I want to call the doc function on each one. In ruby I can do something like ClassName.methods to get a list of all the methods ava...
stackoverflow-qa
# Adding Cookie to ZSI Posts ## Question I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it...
stackoverflow-qa
# Why results of map() and list comprehension are different? ## Question The following test fails: #!/usr/bin/env python def f(*args): """ >>> t = 1, -1 >>> f(*map(lambda i: lambda: i, t)) [1, -1] >>> f(*(lambda: i for i in t)) # -> [-1, -1] [1, -1] >>> f(*[lambda: i for i in t]) # -> [-1,...
stackoverflow-qa
# Why results of map() and list comprehension are different? ## Question The following test fails: #!/usr/bin/env python def f(*args): """ >>> t = 1, -1 >>> f(*map(lambda i: lambda: i, t)) [1, -1] >>> f(*(lambda: i for i in t)) # -> [-1, -1] [1, -1] >>> f(*[lambda: i for i in t]) # -> [-1,...
stackoverflow-qa
# Why results of map() and list comprehension are different? ## Question The following test fails: #!/usr/bin/env python def f(*args): """ >>> t = 1, -1 >>> f(*map(lambda i: lambda: i, t)) [1, -1] >>> f(*(lambda: i for i in t)) # -> [-1, -1] [1, -1] >>> f(*[lambda: i for i in t]) # -> [-1,...
stackoverflow-qa
# Writing a Domain Specific Language for selecting rows from a table ## Question I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a sma...
stackoverflow-qa
# Writing a Domain Specific Language for selecting rows from a table ## Question I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a sma...
stackoverflow-qa
# Writing a Domain Specific Language for selecting rows from a table ## Question I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a sma...
stackoverflow-qa
# Regular expressions but for writing in the match ## Question When using regular expressions we generally, if not always use them to extract some kind of information. What I need is to replace the match value with some other value... Right now I'm doing this... def getExpandedText(pattern, text, replaceValue): ...
stackoverflow-qa
# Regular expressions but for writing in the match ## Question When using regular expressions we generally, if not always use them to extract some kind of information. What I need is to replace the match value with some other value... Right now I'm doing this... def getExpandedText(pattern, text, replaceValue): ...
stackoverflow-qa
# Regular expressions but for writing in the match ## Question When using regular expressions we generally, if not always use them to extract some kind of information. What I need is to replace the match value with some other value... Right now I'm doing this... def getExpandedText(pattern, text, replaceValue): ...
stackoverflow-qa
# Using locale.setlocale in embedded Python without breaking file parsing in C thread ## Question We're using a third-party middleware product that allows us to write code in an embedded Python interpreter, and which exposes an API that we can call into. Some of these API calls allow us to load various kinds of file, ...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Authenticating against active directory using python + ldap ## Question How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears. I can't even bind to perform a simple query: import sys import ldap Server = "ldap://my-ldap-server" DN, Secr...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer Straight from Python's Refererence Library...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer Try "listdir()" in the os module (docs): ...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer Take a look at os.walk() and the examples ...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer Yes, there is. The Python way is even bett...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer Use os.path.walk if you want subdirectorie...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer I'd recommend against os.path.walk as it i...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer As a long-time Pythonista, I have to say t...
stackoverflow-qa
# Looking for File Traversal Functions in Python that are Like Java's ## Question In Java you can do File.listFiles() and receive all of the files in a directory. You can then easily recurse through directory trees. Is there an analogous way to do this in Python? ## Answer You can also check out Unipath, an object-...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How to list only top level directories in Python? ## Question I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-d...
stackoverflow-qa
# How do I find what is using memory in a Python process in a production system? ## Question My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a Python memory profiler (specifically, Heapy) with some success in the development environmen...
stackoverflow-qa
# How do I find what is using memory in a Python process in a production system? ## Question My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a Python memory profiler (specifically, Heapy) with some success in the development environmen...
stackoverflow-qa
# How do I find what is using memory in a Python process in a production system? ## Question My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a Python memory profiler (specifically, Heapy) with some success in the development environmen...
stackoverflow-qa
# How do I find what is using memory in a Python process in a production system? ## Question My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a Python memory profiler (specifically, Heapy) with some success in the development environmen...
stackoverflow-qa
# How do I find what is using memory in a Python process in a production system? ## Question My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a Python memory profiler (specifically, Heapy) with some success in the development environmen...
stackoverflow-qa
# How do I find what is using memory in a Python process in a production system? ## Question My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a Python memory profiler (specifically, Heapy) with some success in the development environmen...
stackoverflow-qa
# How can I create a status bar item with Cocoa and Python (PyObjC)? ## Question I have created a brand new project in XCode and have the following in my AppDelegate.py file: from Foundation import * from AppKit import * class MyApplicationAppDelegate(NSObject): def applicationDidFinishLaunching_(self, sender): ...
stackoverflow-qa
# How can I create a status bar item with Cocoa and Python (PyObjC)? ## Question I have created a brand new project in XCode and have the following in my AppDelegate.py file: from Foundation import * from AppKit import * class MyApplicationAppDelegate(NSObject): def applicationDidFinishLaunching_(self, sender): ...
stackoverflow-qa
# How do I wrap a string in a file in Python? ## Question How do I create a file-like object (same duck type as File) with the contents of a string? ## Answer Use the StringIO module. For example: >>> from cStringIO import StringIO >>> f = StringIO('foo') >>> f.read() 'foo' I use cStringIO (which is faster), but ...
stackoverflow-qa
# How do I wrap a string in a file in Python? ## Question How do I create a file-like object (same duck type as File) with the contents of a string? ## Answer In Python 3.0: import io with io.StringIO() as f: f.write('abcdef') print('gh', file=f) f.seek(0) print(f.read()) Tags: python, string, file...
stackoverflow-qa
# How do I wrap a string in a file in Python? ## Question How do I create a file-like object (same duck type as File) with the contents of a string? ## Answer Two good answers. I’d add a little trick — if you need a real file object (some methods expect one, not just an interface), here is a way to create an adap...
stackoverflow-qa
# Is there an easy way to populate SlugField from CharField? ## Question class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. ## Answer For p...
stackoverflow-qa
# Is there an easy way to populate SlugField from CharField? ## Question class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. ## Answer for A...
stackoverflow-qa
# Is there an easy way to populate SlugField from CharField? ## Question class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. ## Answer Outsi...
stackoverflow-qa
# Is there an easy way to populate SlugField from CharField? ## Question class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. ## Answer You c...
stackoverflow-qa
# overloading __init__ in python ## Question Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing this? Do you just check ...
stackoverflow-qa
# overloading __init__ in python ## Question Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing this? Do you just check ...
stackoverflow-qa
# overloading __init__ in python ## Question Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing this? Do you just check ...
stackoverflow-qa