content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Best way to store and use a large text-file in python
I'm creating a networked server for a boggle-clone I wrote in python, which accepts users, solves the boards, and scores the player input. The dictionary file I'm using is 1.8MB (the ENABLE2K dictionary), and I need it to be available to several game solver cl... | Best way to store and use a large text-file in python | I'm creating a networked server for a boggle-clone I wrote in python, which accepts users, solves the boards, and scores the player input. The dictionary file I'm using is 1.8MB (the ENABLE2K dictionary), and I need it to be available to several game solver classes. Right now, I have it so that each class iterates th... | [
"If you create a dictionary.py module, containing code which reads the file and builds a dictionary, this code will only be executed the first time it is imported. Further imports will return a reference to the existing module instance. As such, your classes can:\nimport dictionary\n\ndictionary.words[whatever]\n\n... | [
11,
1,
1,
0
] | [] | [] | [
"boggle",
"python"
] | stackoverflow_0000158546_boggle_python.txt |
Q:
How many bytes per element are there in a Python list (tuple)?
For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
A:
"It depends." Python allocates space for lists in such a way as to achieve amortized constan... | How many bytes per element are there in a Python list (tuple)? | For example, how much memory is required to store a list of one million (32-bit) integers?
alist = range(1000000) # or list(range(1000000)) in Python 3.0
| [
"\"It depends.\" Python allocates space for lists in such a way as to achieve amortized constant time for appending elements to the list.\nIn practice, what this means with the current implementation is... the list always has space allocated for a power-of-two number of elements. So range(1000000) will actually a... | [
26,
15,
6,
4,
2
] | [] | [] | [
"memory_management",
"python"
] | stackoverflow_0000135664_memory_management_python.txt |
Q:
Date change notification in a Tkinter app (win32)
Does anyone know if it is possible (and if yes, how) to bind an event (Python + Tkinter on MS Windows) to a system date change?
I know I can have .after events checking once in a while; I'm asking if I can somehow have an event fired whenever the system date/time c... | Date change notification in a Tkinter app (win32) | Does anyone know if it is possible (and if yes, how) to bind an event (Python + Tkinter on MS Windows) to a system date change?
I know I can have .after events checking once in a while; I'm asking if I can somehow have an event fired whenever the system date/time changes, either automatically (e.g. for daylight saving ... | [
"\nI know, because if I have an .after timer waiting and I set the date/time after the timer's expiration, the timer event fires instantly.\n\nThat could just mean that Tkinter (or Tk) is polling the system clock as part of the event loop to figure out when to run timers.\nIf you're using Windows, Mark Hammond's bo... | [
1
] | [] | [] | [
"events",
"python",
"tkinter",
"windows"
] | stackoverflow_0000157116_events_python_tkinter_windows.txt |
Q:
What is "lambda binding" in Python?
I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.
A:
First, a general definition:
When a... | What is "lambda binding" in Python? | I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.
| [
"First, a general definition:\n\nWhen a program or function statement\n is executed, the current values of\n formal parameters are saved (on the\n stack) and within the scope of the\n statement, they are bound to the\n values of the actual arguments made in\n the call. When the statement is\n exited, the ori... | [
14,
8,
1
] | [] | [] | [
"binding",
"lambda",
"python"
] | stackoverflow_0000160859_binding_lambda_python.txt |
Q:
Library for converting a traceback to its exception?
Just a curiosity: is there an already-coded way to convert a printed traceback back to the exception that generated it? :) Or to a sys.exc_info-like structure?
A:
Converting a traceback to the exception object wouldn't be too hard, given common exception class... | Library for converting a traceback to its exception? | Just a curiosity: is there an already-coded way to convert a printed traceback back to the exception that generated it? :) Or to a sys.exc_info-like structure?
| [
"Converting a traceback to the exception object wouldn't be too hard, given common exception classes (parse the last line for the exception class and the arguments given to it at instantiation.) The traceback object (the third argument returned by sys.exc_info()) is an entirely different matter, though. The traceba... | [
2
] | [] | [] | [
"python"
] | stackoverflow_0000161367_python.txt |
Q:
Interface to versioned dictionary
I have an versioned document store which I want to access through an dict like interface.
Common usage is to access the latest revision (get, set, del), but one should be able to access specific revisions too (keys are always str/unicode or int).
from UserDict import DictMixin
cla... | Interface to versioned dictionary | I have an versioned document store which I want to access through an dict like interface.
Common usage is to access the latest revision (get, set, del), but one should be able to access specific revisions too (keys are always str/unicode or int).
from UserDict import DictMixin
class VDict(DictMixin):
def __getit... | [
"Yes, provide a different API for getting different versions. Either a single methodcall for doing a retrieval of a particular item of a particular revision, or a methodcall for getting a 'view' of a particular revision, which you could then access like a normal dict, depending on whether such a 'view' would see mu... | [
4
] | [] | [] | [
"python"
] | stackoverflow_0000162656_python.txt |
Q:
Django admin site not displaying ManyToManyField relationship
I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.
Here's my models.py:
class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.... | Django admin site not displaying ManyToManyField relationship | I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.
Here's my models.py:
class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max_length = 50)
techs = m... | [
"\nI've tried adding the TechInline class to the inlines list, but that causes a\n'TechInLine' not defined\n\nIs that a straight copy-paste? It looks like you just made a typo -- try TechInline instead of TechInLine.\nIf your syncdb didn't create the proper table, you can do it manually. Execute this command:\npyth... | [
3,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000160905_django_python.txt |
Q:
Most pythonic way of counting matching elements in something iterable
I have an iterable of entries on which I would like to gather some simple statistics, say the count of all numbers divisible by two and the count of all numbers divisible by three.
My first alternative, While only iterating through the list once... | Most pythonic way of counting matching elements in something iterable | I have an iterable of entries on which I would like to gather some simple statistics, say the count of all numbers divisible by two and the count of all numbers divisible by three.
My first alternative, While only iterating through the list once and avoiding the list expansion (and keeping the split loop refactoring in... | [
"Having to iterate over the list multiple times isn't elegant IMHO.\nI'd probably create a function that allows doing:\ntwos, threes = countmatching(xrange(1,10),\n lambda a: a % 2 == 0,\n lambda a: a % 3 == 0)\n\nA starting point would be something like this:... | [
20,
7,
4,
3,
1,
1,
0,
0,
0,
0,
0,
0
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0000157039_list_comprehension_python.txt |
Q:
WPF Alternative for python
Is there any alternative for WPF (windows presentation foundation) in python?
http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF
A:
Here is a list of Python GUI Toolkits.
Also, you can use IronPython to work with WPF directly.
A:
You might want to look at p... | WPF Alternative for python | Is there any alternative for WPF (windows presentation foundation) in python?
http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF
| [
"Here is a list of Python GUI Toolkits.\nAlso, you can use IronPython to work with WPF directly. \n",
"You might want to look at pygtk and glade. Here is a tutorial.\nThere is a long list of alternatives on the Python Wiki.\n",
"Try PyQt which binds python to QT graphics library. There are some other links at t... | [
7,
3,
2,
1
] | [] | [] | [
"python",
"user_interface"
] | stackoverflow_0000163881_python_user_interface.txt |
Q:
Subclassing a class with private members
One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:
self.__value = 1
def value():
return self.__value
Is there a simple way of providing access to the private members of a class that I... | Subclassing a class with private members | One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:
self.__value = 1
def value():
return self.__value
Is there a simple way of providing access to the private members of a class that I wish to subclass? Often I wish to simply work... | [
"Not conveniently, without further breaking encapsulation. The double-underscore attribute is name-mangled by prepending '_ClassName' for the class it is being accessed in. So, if you have a 'ContainerThing' class that has a '__value' attribute, the attribute is actually being stored as '_ContainerThing__value'. Ch... | [
5,
3,
1
] | [] | [] | [
"encapsulation",
"oop",
"python"
] | stackoverflow_0000162798_encapsulation_oop_python.txt |
Q:
Apache sockets not closing?
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content.
This all works just ... | Apache sockets not closing? | I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content.
This all works just fine for small workloads. Howeve... | [
"SetEnv proxy-nokeepalive 1 would probably tell you right away if the problem is keepalive between Apache and CP. See the mod_proxy docs for more info.\n",
"You might run the netstat command and see if you have a bunch of sockets in the TIME_WAIT state. Depending on your MaxUserPort setting you might be severly l... | [
6,
5
] | [] | [] | [
"apache",
"cherrypy",
"mod_proxy",
"python",
"urllib2"
] | stackoverflow_0000163603_apache_cherrypy_mod_proxy_python_urllib2.txt |
Q:
How do I get the key value of a db.ReferenceProperty without a database hit?
Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an _, but I hav... | How do I get the key value of a db.ReferenceProperty without a database hit? | Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an _, but I have been unable to get any code working. Examples would be much appreciated. Thank... | [
"Actually, the way that you are advocating accessing the key for a ReferenceProperty might well not exist in the future. Attributes that begin with '_' in python are generally accepted to be \"protected\" in that things that are closely bound and intimate with its implementation can use them, but things that are u... | [
13,
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0000141973_google_app_engine_python.txt |
Q:
What is the difference between Ruby and Python versions of"self"?
I've done some Python but have just now starting to use Ruby
I could use a good explanation of the difference between "self" in these two languages.
Obvious on first glance:
Self is not a keyword in Python, but there is a "self-like" value no matt... | What is the difference between Ruby and Python versions of"self"? | I've done some Python but have just now starting to use Ruby
I could use a good explanation of the difference between "self" in these two languages.
Obvious on first glance:
Self is not a keyword in Python, but there is a "self-like" value no matter what you call it.
Python methods receive self as an explicit argumen... | [
"Python is designed to support more than just object-oriented programming. Preserving the same interface between methods and functions lets the two styles interoperate more cleanly.\nRuby was built from the ground up to be object-oriented. Even the literals are objects (evaluate 1.class and you get Fixnum). The lan... | [
8,
6,
5,
5
] | [] | [] | [
"language_features",
"python",
"ruby"
] | stackoverflow_0000159990_language_features_python_ruby.txt |
Q:
What is the best way to sample/profile a PyObjC application?
Sampling with Activity Monitor/Instruments/Shark will show stack traces full of C functions for the Python interpreter. I would be helpful to see the corresponding Python symbol names. Is there some DTrace magic that can do that? Python's cProfile module... | What is the best way to sample/profile a PyObjC application? | Sampling with Activity Monitor/Instruments/Shark will show stack traces full of C functions for the Python interpreter. I would be helpful to see the corresponding Python symbol names. Is there some DTrace magic that can do that? Python's cProfile module can be useful for profiling individual subtrees of Python calls, ... | [
"The answer is \"dtrace\", but it won't work on sufficiently old macs.\nhttp://tech.marshallfamily.com.au/archives/python-dtrace-on-os-x-leopard-part-1/\nhttp://tech.marshallfamily.com.au/archives/python-dtrace-on-os-x-leopard-part-2/\n"
] | [
3
] | [] | [] | [
"cocoa",
"macos",
"pyobjc",
"python"
] | stackoverflow_0000157662_cocoa_macos_pyobjc_python.txt |
Q:
Python object attributes - methodology for access
Suppose I have a class with some attributes. How is it best (in the Pythonic-OOP) sense to access these attributes ? Just like obj.attr ? Or perhaps write get accessors ?
What are the accepted naming styles for such things ?
Edit:
Can you elaborate on the best-pra... | Python object attributes - methodology for access | Suppose I have a class with some attributes. How is it best (in the Pythonic-OOP) sense to access these attributes ? Just like obj.attr ? Or perhaps write get accessors ?
What are the accepted naming styles for such things ?
Edit:
Can you elaborate on the best-practices of naming attributes with a single or double lea... | [
"With regards to the single and double-leading underscores: both indicate the same concept of 'privateness'. That is to say, people will know the attribute (be it a method or a 'normal' data attribute or anything else) is not part of the public API of the object. People will know that to touch it directly is to inv... | [
58,
23,
8,
3,
1,
0
] | [
"Some people use getters and setters. Depending on which coding style you use you can name them getSpam and seteggs. But you can also make you attributes readonly or assign only. That's a bit awkward to do. One way is overriding the \n> __getattr__\n\nand \n> __setattr__\n\nmethods.\nEdit:\nWhile my answer is stil... | [
-2
] | [
"attributes",
"object",
"oop",
"python"
] | stackoverflow_0000165883_attributes_object_oop_python.txt |
Q:
Removing a subset of a dict from within a list
This is really only easy to explain with an example, so to remove the intersection of a list from within a dict I usually do something like this:
a = {1:'', 2:'', 3:'', 4:''}
exclusion = [3, 4, 5]
# have to build up a new list or the iteration breaks
toRemove = []
fo... | Removing a subset of a dict from within a list | This is really only easy to explain with an example, so to remove the intersection of a list from within a dict I usually do something like this:
a = {1:'', 2:'', 3:'', 4:''}
exclusion = [3, 4, 5]
# have to build up a new list or the iteration breaks
toRemove = []
for var in a.iterkeys():
if var in exclusion:
... | [
"Consider dict.pop:\nfor key in exclusion:\n a.pop(key, None)\n\nThe None keeps pop from raising an exception when key isn't a key.\n",
"a = dict((key,value) for (key,value) in a.iteritems() if key not in exclusion)\n\n",
"Why not just use the keys method, instead of iterkeys? That way you can do it in one ... | [
14,
3,
2,
2
] | [] | [] | [
"containers",
"list",
"python"
] | stackoverflow_0000167120_containers_list_python.txt |
Q:
How do I enter a pound sterling character (£) into the Python interactive shell on Mac OS X?
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here: Python/editline on OS X: £ sign seems to be bound to ed-prev-word
On Mac OS X I can’t enter a pound sterling sign (£) in... | How do I enter a pound sterling character (£) into the Python interactive shell on Mac OS X? | Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here: Python/editline on OS X: £ sign seems to be bound to ed-prev-word
On Mac OS X I can’t enter a pound sterling sign (£) into the Python interactive shell.
Mac OS X 10.5.5
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)... | [
"Not the best solution, but you could type:\n pound = u'\\u00A3'\n\nThen you have it in a variable you can use in the rest of your session.\n",
"In unicode it is 00A003. With the Unicode escape it would be u'\\u00a003'. \nEdit:\n@ Patrick McElhaney said you might need to use 00A3.\n",
"u'\\N{pound sign}'\nIf yo... | [
5,
2,
2,
1,
0
] | [] | [] | [
"bash",
"macos",
"python",
"shell",
"terminal"
] | stackoverflow_0000167439_bash_macos_python_shell_terminal.txt |
Q:
Naming conventions in a Python library
I'm implementing a search algorithm (let's call it MyAlg) in a python package. Since the algorithm is super-duper complicated, the package has to contain an auxiliary class for algorithm options. Currently I'm developing the entire package by myself (and I'm not a programmer)... | Naming conventions in a Python library | I'm implementing a search algorithm (let's call it MyAlg) in a python package. Since the algorithm is super-duper complicated, the package has to contain an auxiliary class for algorithm options. Currently I'm developing the entire package by myself (and I'm not a programmer), however I expect 1-2 programmers to join t... | [
"I suggest you read PEP8 (styleguide for Python code).\n",
"Just naming it Options should be fine. The Python standard library generally takes the philosophy that namespaces make it easy and manageable for different packages to have identically named things. For example, open is both a builtin and a function in... | [
9,
2,
2
] | [] | [] | [
"naming_conventions",
"python"
] | stackoverflow_0000168022_naming_conventions_python.txt |
Q:
Django: How do I create a generic url routing to views?
I have a pretty standard django app, and am wondering how to set the url routing so that I don't have to explicitly map each url to a view.
For example, let's say that I have the following views: Project, Links, Profile, Contact. I'd rather not have my urlpa... | Django: How do I create a generic url routing to views? | I have a pretty standard django app, and am wondering how to set the url routing so that I don't have to explicitly map each url to a view.
For example, let's say that I have the following views: Project, Links, Profile, Contact. I'd rather not have my urlpatterns look like this:
(r'^Project/$', 'mysite.app.views.proj... | [
"mods = ('Project','Links','Profile','Contact')\n\nurlpatterns = patterns('',\n *(('^%s/$'%n, 'mysite.app.views.%s'%n.lower()) for n in mods)\n)\n\n",
"Unless you have a really huge number of views, writing them down explicitly is not too bad, from a style perspective.\nYou can shorten your example, though, by ... | [
5,
5,
5
] | [] | [] | [
"django",
"pylons",
"python"
] | stackoverflow_0000168113_django_pylons_python.txt |
Q:
How can I compress a folder and email the compressed file in Python?
I would like to compress a folder and all its sub-folders/files, and email the zip file as an attachment. What would be the best way to achieve this with Python?
A:
You can use the zipfile module to compress the file using the zip standard, th... | How can I compress a folder and email the compressed file in Python? | I would like to compress a folder and all its sub-folders/files, and email the zip file as an attachment. What would be the best way to achieve this with Python?
| [
"You can use the zipfile module to compress the file using the zip standard, the email module to create the email with the attachment, and the smtplib module to send it - all using only the standard library.\nPython - Batteries Included\nIf you don't feel like programming and would rather ask a question on stackove... | [
19,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0000169362_python.txt |
Q:
Initializing cherrypy.session early
I love CherryPy's API for sessions, except for one detail. Instead of saying cherrypy.session["spam"] I'd like to be able to just say session["spam"].
Unfortunately, I can't simply have a global from cherrypy import session in one of my modules, because the cherrypy.session obj... | Initializing cherrypy.session early | I love CherryPy's API for sessions, except for one detail. Instead of saying cherrypy.session["spam"] I'd like to be able to just say session["spam"].
Unfortunately, I can't simply have a global from cherrypy import session in one of my modules, because the cherrypy.session object isn't created until the first time a ... | [
"For CherryPy 3.1, you would need to find the right subclass of Session, run its 'setup' classmethod, and then set cherrypy.session to a ThreadLocalProxy. That all happens in cherrypy.lib.sessions.init, in the following chunks:\n# Find the storage class and call setup (first time only).\nstorage_class = storage_typ... | [
5
] | [] | [] | [
"cherrypy",
"python"
] | stackoverflow_0000168167_cherrypy_python.txt |
Q:
Google App Engine: how can I programmatically access the properties of my Model class?
I have a model class:
class Person(db.Model):
first_name = db.StringProperty(required=True)
last_name = db.StringProperty(required=True)
I have an instance of this class in p, and string s contains the value 'first_name'. I... | Google App Engine: how can I programmatically access the properties of my Model class? | I have a model class:
class Person(db.Model):
first_name = db.StringProperty(required=True)
last_name = db.StringProperty(required=True)
I have an instance of this class in p, and string s contains the value 'first_name'. I would like to do something like:
print p[s]
and
p[s] = new_value
Both of which result in... | [
"If the model class is sufficiently intelligent, it should recognize the standard Python ways of doing this.\nTry:\ngetattr(p, s)\nsetattr(p, s, new_value)\n\nThere is also hasattr available.\n",
"With much thanks to Jim, the exact solution I was looking for is:\np.properties()[s].get_value_for_datastore(p)\n\nTo... | [
7,
3,
1,
1
] | [
"p.first_name = \"New first name\"\np.put()\nor p = Person(first_name = \"Firsty\",\n last_name = \"Lasty\" )\np.put()\n"
] | [
-1
] | [
"google_app_engine",
"python",
"string"
] | stackoverflow_0000091821_google_app_engine_python_string.txt |
Q:
Issue With Python Sockets: How To Get Reliably POSTed data whatever the browser?
I wrote small Python+Ajax programs (listed at the end) with socket module to study the COMET concept of asynchronous communications.
The idea is to allow browsers to send messages real time each others via my python program.
The trick... | Issue With Python Sockets: How To Get Reliably POSTed data whatever the browser? | I wrote small Python+Ajax programs (listed at the end) with socket module to study the COMET concept of asynchronous communications.
The idea is to allow browsers to send messages real time each others via my python program.
The trick is to let the "GET messages/..." connection opened waiting for a message to answer ba... | [
"The problem you have is that\n\nyour tcp socket handling isn't reading as much as it should\nyour http handling is not complete\n\nI recommend the following lectures:\n\nrfc2616\nThe sockets Networking API by Stevens\n\nSee the example below for a working http server that can process posts\nindex = '''\n<html>\n ... | [
2,
0,
0
] | [] | [] | [
"comet",
"javascript",
"python",
"sockets"
] | stackoverflow_0000167426_comet_javascript_python_sockets.txt |
Q:
USB Driver Development on a Mac using Python
I would like to write a driver to talk to my Suunto t3 watch in Python on a Mac. My day job is doing basic web work in C# so my familiarity with Python and developing on a Mac is limited.
Can you suggest how one would start doing driver development in general and then m... | USB Driver Development on a Mac using Python | I would like to write a driver to talk to my Suunto t3 watch in Python on a Mac. My day job is doing basic web work in C# so my familiarity with Python and developing on a Mac is limited.
Can you suggest how one would start doing driver development in general and then more specifically on a Mac. I.e. how to easily see ... | [
"The Mac already has the underlying infrastructure to support USB, so you'll need a Python library that can take advantage of it. For any Python project that needs serial support, whether it's USB, RS-232 or GPIB, I'd recommend the PyVisa library at SourceForge. See http://pyvisa.sourceforge.net/.\nIf your device... | [
4,
3
] | [] | [] | [
"drivers",
"macos",
"python",
"usb"
] | stackoverflow_0000170278_drivers_macos_python_usb.txt |
Q:
How would I implement a bit map?
I wish to implement a 2d bit map class in Python. The class would have the following requirements:
Allow the creating of arbitrarily sized 2d bitmaps. i.e. to create an 8 x 8 bitmap (8 bytes), something like:
bitmap = Bitmap(8,8)
provide an API to access the bits in this 2d map a... | How would I implement a bit map? | I wish to implement a 2d bit map class in Python. The class would have the following requirements:
Allow the creating of arbitrarily sized 2d bitmaps. i.e. to create an 8 x 8 bitmap (8 bytes), something like:
bitmap = Bitmap(8,8)
provide an API to access the bits in this 2d map as boolean or even integer values, i.e.... | [
"Bit-Packing numpy ( SciPY ) arrays does what you are looking for.\nThe example shows 4x3 bit (Boolean) array packed into 4 8-bit bytes. unpackbits unpacks uint8 arrays into a Boolean output array that you can use in computations.\n>>> a = np.array([[[1,0,1],\n... [0,1,0]],\n... [[1,1,0... | [
7,
4
] | [] | [] | [
"class",
"python"
] | stackoverflow_0000171512_class_python.txt |
Q:
Emulation of lex like functionality in Perl or Python
Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?
One example:
I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize ... | Emulation of lex like functionality in Perl or Python | Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?
One example:
I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matching every expressi... | [
"Look at documentation for following modules on CPAN\nHTML::TreeBuilder\nHTML::TableExtract\nand\nParse::RecDescent\nI've used these modules to process quite large and complex web-pages.\n",
"If you're specifically after parsing links out of web-pages, then Perl's WWW::Mechanize module will figure things out for ... | [
8,
7,
5,
3,
2,
2,
1,
0
] | [] | [] | [
"lex",
"parsing",
"perl",
"python"
] | stackoverflow_0000160889_lex_parsing_perl_python.txt |
Q:
Is it possible to pass arguments into event bindings?
I haven't found an answer elsewhere and this doesn't appear to have been asked yet on SO.
When creating an event binding in wxPython, is it possible to pass additional arguments to the event? For example, this is the normal way:
b = wx.Button(self, 10, "Default... | Is it possible to pass arguments into event bindings? | I haven't found an answer elsewhere and this doesn't appear to have been asked yet on SO.
When creating an event binding in wxPython, is it possible to pass additional arguments to the event? For example, this is the normal way:
b = wx.Button(self, 10, "Default Button", (20, 20))
self.Bind(wx.EVT_BUTTON, self.O... | [
"You can always use a lambda or another function to wrap up your method and pass another argument, not WX specific.\nb = wx.Button(self, 10, \"Default Button\", (20, 20))\n self.Bind(wx.EVT_BUTTON, lambda event: self.OnClick(event, 'somevalue'), b)\ndef OnClick(self, event, somearg):\n self.log.write(... | [
49,
14
] | [] | [] | [
"events",
"python",
"wxpython"
] | stackoverflow_0000173687_events_python_wxpython.txt |
Q:
How do I blink/control Macbook keyboard LEDs programmatically?
Do you know how I can switch on/off (blink) Macbook keyboard led (caps lock,numlock) under Mac OS X (preferably Tiger)?
I've googled for this, but have got no results, so I am asking for help.
I would like to add this feature as notifications (eg. new ... | How do I blink/control Macbook keyboard LEDs programmatically? | Do you know how I can switch on/off (blink) Macbook keyboard led (caps lock,numlock) under Mac OS X (preferably Tiger)?
I've googled for this, but have got no results, so I am asking for help.
I would like to add this feature as notifications (eg. new message received on Adium, new mail received).
I would prefer apples... | [
"http://googlemac.blogspot.com/2008/04/manipulating-keyboard-leds-through.html\n"
] | [
4
] | [] | [] | [
"blink",
"keyboard",
"macos",
"python"
] | stackoverflow_0000173905_blink_keyboard_macos_python.txt |
Q:
How do you develop against OpenID locally
I'm developing a website (in Django) that uses OpenID to authenticate users. As I'm currently only running on my local machine I can't authenticate using one of the OpenID providers on the web. So I figure I need to run a local OpenID server that simply lets me type in a u... | How do you develop against OpenID locally | I'm developing a website (in Django) that uses OpenID to authenticate users. As I'm currently only running on my local machine I can't authenticate using one of the OpenID providers on the web. So I figure I need to run a local OpenID server that simply lets me type in a username and then passes that back to my main ap... | [
"The libraries at OpenID Enabled ship with examples that are sufficient to run a local test provider. Look in the examples/djopenid/ directory of the python-openid source distribution. Running that will give you an instance of this test provider.\n",
"I have no problems testing with myopenid.com. I thought ther... | [
15,
9,
3,
3,
3,
1,
1
] | [] | [] | [
"django",
"openid",
"python"
] | stackoverflow_0000172040_django_openid_python.txt |
Q:
SQLAlchemy and kinterbasdb in separate apps under mod_wsgi
I'm trying to develop an app using turbogears and sqlalchemy.
There is already an existing app using kinterbasdb directly under mod_wsgi on the same server.
When both apps are used, neither seems to recognize that kinterbasdb is already initialized
Is ther... | SQLAlchemy and kinterbasdb in separate apps under mod_wsgi | I'm trying to develop an app using turbogears and sqlalchemy.
There is already an existing app using kinterbasdb directly under mod_wsgi on the same server.
When both apps are used, neither seems to recognize that kinterbasdb is already initialized
Is there something non-obvious I am missing about using sqlalchemy and ... | [
"I thought I posted my solution already...\nModifying both apps to run under WSGIApplicationGroup ${GLOBAL} in their httpd conf file\nand patching sqlalchemy.databases.firebird.py to check if self.dbapi.initialized is True\nbefore calling self.dbapi.init(... was the only way I could manage to get this scenario up a... | [
2
] | [] | [] | [
"kinterbasdb",
"python",
"sqlalchemy"
] | stackoverflow_0000155029_kinterbasdb_python_sqlalchemy.txt |
Q:
SQL Absolute value across columns
I have a table that looks something like this:
word big expensive smart fast
dog 9 -10 -20 4
professor 2 4 40 -7
ferrari 7 50 0 48
alaska 10 0 1 0
gnat -3 0 ... | SQL Absolute value across columns | I have a table that looks something like this:
word big expensive smart fast
dog 9 -10 -20 4
professor 2 4 40 -7
ferrari 7 50 0 48
alaska 10 0 1 0
gnat -3 0 0 0
The + and - values are as... | [
"Words listed by absolute value of big:\nselect word, big from myTable order by abs(big)\n\ntotals for each category:\nselect sum(abs(big)) as sumbig, \n sum(abs(expensive)) as sumexpensive, \n sum(abs(smart)) as sumsmart,\n sum(abs(fast)) as sumfast\n from MyTable;\n\n",
"abs value fartheres... | [
3,
3,
1,
0,
0
] | [] | [] | [
"mysql",
"oracle",
"postgresql",
"python",
"sql"
] | stackoverflow_0000177284_mysql_oracle_postgresql_python_sql.txt |
Q:
Accessing python egg's own metadata
I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:
import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)
but this would probably work incorrectly if I had multiple v... | Accessing python egg's own metadata | I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:
import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)
but this would probably work incorrectly if I had multiple versions of the same egg installed. And if... | [
"I am somewhat new to Python as well, but from what I understand: \nAlthough you can install multiple versions of the \"same\" egg (having the same name), only one of them will be available to any particular piece of code at runtime (based on your discovery method). So if your egg is the one calling this code, it ... | [
4,
0
] | [] | [] | [
"pkg_resources",
"python",
"setuptools"
] | stackoverflow_0000177910_pkg_resources_python_setuptools.txt |
Q:
Django/Python - Grouping objects by common set from a many-to-many relationships
This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.
In Python, it's worth mentioning that the problem is somewhat relate... | Django/Python - Grouping objects by common set from a many-to-many relationships | This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.
In Python, it's worth mentioning that the problem is somewhat related to how-do-i-use-pythons-itertoolsgroupby.
Suppose you're given two Django Model-deri... | [
"Have you tried sorting the list first? The algorithm you proposed should work, albeit with lots of database hits.\nimport itertools\n\ncars = [\n {'car': 'X2', 'mods': [1,2]},\n {'car': 'Y2', 'mods': [2]},\n {'car': 'W2', 'mods': [1]},\n {'car': 'X1', 'mods': [1,2]},\n {'car': 'W1', 'mods': [1]},\n ... | [
4,
2,
1,
1,
0
] | [] | [] | [
"algorithm",
"django",
"puzzle",
"python"
] | stackoverflow_0000160298_algorithm_django_puzzle_python.txt |
Q:
What symmetric cypher to use for encrypting messages?
I haven't a clue about encryption at all. But I need it. How?
Say you have a system of nodes communicating with each other on a network via asynchronous messages. The nodes do not maintain session information about other nodes (this is a design restriction).
Sa... | What symmetric cypher to use for encrypting messages? | I haven't a clue about encryption at all. But I need it. How?
Say you have a system of nodes communicating with each other on a network via asynchronous messages. The nodes do not maintain session information about other nodes (this is a design restriction).
Say you want to make sure only your nodes can read the messag... | [
"Your first thought should be channel security - either SSL/TLS, or IPSec.\nAdmittedly, these both have a certain amount of setup overhead, IPSec more than SSL/TLS, especially when it comes to PKI etc. - but it more than pays for itself in simplicity of development, reliability, security, and more. Just make sure y... | [
7,
7,
4,
3,
1,
1,
1
] | [] | [] | [
"encryption",
"python",
"security"
] | stackoverflow_0000172392_encryption_python_security.txt |
Q:
Python, unit-testing and mocking imports
I am in a project where we are starting refactoring some massive code base. One problem that immediately sprang up is that each file imports a lot of other files. How do I in an elegant way mock this in my unit test without having to alter the actual code so I can start to ... | Python, unit-testing and mocking imports | I am in a project where we are starting refactoring some massive code base. One problem that immediately sprang up is that each file imports a lot of other files. How do I in an elegant way mock this in my unit test without having to alter the actual code so I can start to write unit-tests?
As an example: The file with... | [
"If you want to import a module while at the same time ensuring that it doesn't import anything, you can replace the __import__ builtin function.\nFor example, use this class:\nclass ImportWrapper(object):\n def __init__(self, real_import):\n self.real_import = real_import\n\n def wrapper(self, wantedM... | [
8,
1,
1,
0,
0
] | [] | [] | [
"python",
"python_import",
"refactoring",
"unit_testing"
] | stackoverflow_0000178458_python_python_import_refactoring_unit_testing.txt |
Q:
Python class factory ... or?
We have a database library in C# that we can use like this:
DatabaseConnection conn = DatabaseConnection.FromConnectionString("...");
This library hides many of the differences between different database engines, like SQL function names, parameter names and specifications, etc.
Intern... | Python class factory ... or? | We have a database library in C# that we can use like this:
DatabaseConnection conn = DatabaseConnection.FromConnectionString("...");
This library hides many of the differences between different database engines, like SQL function names, parameter names and specifications, etc.
Internally, the DatabaseConnection class... | [
"This is possible in Python, but is probably not the best way to do it. The class factory pattern is essentially a workaround for languages that don't have first class classes. Since Python does have first class classes, you can store a class in a variable, and use that class directly to create instances. To cha... | [
5,
3,
1
] | [] | [] | [
"c#",
"python"
] | stackoverflow_0000179985_c#_python.txt |
Q:
What is the best way to change text contained in an XML file using Python?
Let's say I have an existing trivial XML file named 'MyData.xml' that contains the following:
<?xml version="1.0" encoding="utf-8" ?>
<myElement>foo</myElement>
I want to change the text value of 'foo' to 'bar' resulting in the following:
... | What is the best way to change text contained in an XML file using Python? | Let's say I have an existing trivial XML file named 'MyData.xml' that contains the following:
<?xml version="1.0" encoding="utf-8" ?>
<myElement>foo</myElement>
I want to change the text value of 'foo' to 'bar' resulting in the following:
<?xml version="1.0" encoding="utf-8" ?>
<myElement>bar</myElement>
Once I am do... | [
"Use Python's minidom\nBasically you will take the following steps:\n\nRead XML data into DOM object\nUse DOM methods to modify the document\nSave new DOM object to new XML document\n\nThe python spec should hold your hand rather nicely though this process. \n",
"For quick, non-critical XML manipulations, i reall... | [
4,
3,
3,
1
] | [] | [] | [
"python",
"text",
"xml"
] | stackoverflow_0000179287_python_text_xml.txt |
Q:
Django UserProfile... without a password
I'd like to create a subset of Users that don't have a login... basically as a way to add a photographer field to photos without having a full blown account associated with that person (since in many cases, they'll never actually log in to the site). A caveat is that I'd al... | Django UserProfile... without a password | I'd like to create a subset of Users that don't have a login... basically as a way to add a photographer field to photos without having a full blown account associated with that person (since in many cases, they'll never actually log in to the site). A caveat is that I'd also like to be able to enable an account for th... | [
"A user profile (as returned by django.contrib.auth.models.User.get_profile) doesn't extend the User table - the model you specify as the profile model with the AUTH_PROFILE_MODULE setting is just a model which has a ForeignKey to User. get_profile and the setting are really just a convenience API for accessing an ... | [
8,
3,
3,
0,
0,
0,
0
] | [] | [] | [
"database",
"django",
"django_authentication",
"django_users",
"python"
] | stackoverflow_0000172066_database_django_django_authentication_django_users_python.txt |
Q:
WSGI Middleware recommendations
I have heard that there is lots of interesting and useful WSGI middleware around. However, I am not sure which ones (apart from the ones that are part of pylons) are useful and stable. What is your favourite WSGI middleware?
A:
WSGI.org has a fairly comprehensive list of WSGI Mid... | WSGI Middleware recommendations | I have heard that there is lots of interesting and useful WSGI middleware around. However, I am not sure which ones (apart from the ones that are part of pylons) are useful and stable. What is your favourite WSGI middleware?
| [
"WSGI.org has a fairly comprehensive list of WSGI Middleware & Utilities.\n"
] | [
2
] | [] | [] | [
"pylons",
"python",
"wsgi"
] | stackoverflow_0000178001_pylons_python_wsgi.txt |
Q:
Python, beyond the basics
I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it wil... | Python, beyond the basics | I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.
| [
"Well, there are great ressources for advanced Python programming :\n\nDive Into Python (read it for free)\nOnline python cookbooks (e.g. here and there)\nO'Reilly's Python Cookbook (see amazon)\nA funny riddle game : Python Challenge \n\nHere is a list of subjects you must master if you want to write \"Python\" on... | [
16,
5,
3,
2,
2,
2,
1,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0000092230_python.txt |
Q:
wxPython: displaying multiple widgets in same frame
I would like to be able to display Notebook and a TxtCtrl wx widgets in a single frame. Below is an example adapted from the wxpython wiki; is it possible to change their layout (maybe with something like wx.SplitterWindow) to display the text box below the Note... | wxPython: displaying multiple widgets in same frame | I would like to be able to display Notebook and a TxtCtrl wx widgets in a single frame. Below is an example adapted from the wxpython wiki; is it possible to change their layout (maybe with something like wx.SplitterWindow) to display the text box below the Notebook in the same frame?
import wx
import wx.lib.sheet as ... | [
"Making two widgets appear on the same frame is easy, actually. You should use sizers to accomplish this.\nIn your example, you can change your Notebook class implementation to something like this:\nclass Notebook(wx.Frame):\n def __init__(self, parent, id, title):\n wx.Frame.__init__(self, parent, id, ti... | [
9,
1
] | [] | [] | [
"layout",
"python",
"user_interface",
"wxpython",
"wxwidgets"
] | stackoverflow_0000181573_layout_python_user_interface_wxpython_wxwidgets.txt |
Q:
Os.path : can you explain this behavior?
I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me.
I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubuntu linux, w... | Os.path : can you explain this behavior? | I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me.
I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubuntu linux, while dealing with string that represent window... | [
"If you want to manipulate Windows paths on linux you should use the ntpath module (this is the module that is imported as os.path on windows - posixpath is imported as os.path on linux)\n>>> import ntpath\n>>> filepath = r\"c:\\ttemp\\FILEPA~1.EXE\"\n>>> print ntpath.basename(filepath)\nFILEPA~1.EXE\n>>> print ntp... | [
26,
4,
1
] | [] | [] | [
"path",
"python"
] | stackoverflow_0000182253_path_python.txt |
Q:
Setup Python environment on Windows
How do I setup a Python environment on windows computer so I can start writing and running Python scripts, is there an install bundle? Also which database should i use?
I should of mentioned that I am using this for web based applications. Does it require apache? or does it us... | Setup Python environment on Windows | How do I setup a Python environment on windows computer so I can start writing and running Python scripts, is there an install bundle? Also which database should i use?
I should of mentioned that I am using this for web based applications. Does it require apache? or does it use another http server? What is the standa... | [
"Download the Python 2.6 Windows installer from python.org (direct link). If you're just learning, use the included SQLite library so you don't have to fiddle with database servers.\n\nMost web development frameworks (Django, Turbogears, etc) come with a built-in webserver command that runs on the local computer wi... | [
7,
4,
2,
1,
1,
0
] | [] | [] | [
"database",
"development_environment",
"installation",
"python",
"windows"
] | stackoverflow_0000182053_database_development_environment_installation_python_windows.txt |
Q:
Code to verify updates from the Google Safe Browsing API
In order to verify the data coming from the Google Safe Browsing API, you can calculate a Message Authentication Code (MAC) for each update. The instructions to do this (from Google) are:
The MAC is computed from an MD5 Digest
over the following informat... | Code to verify updates from the Google Safe Browsing API | In order to verify the data coming from the Google Safe Browsing API, you can calculate a Message Authentication Code (MAC) for each update. The instructions to do this (from Google) are:
The MAC is computed from an MD5 Digest
over the following information:
client_key|separator|table
data|separator|client_key.... | [
"Anders' answer gives the necessary information, but isn't that clear: the client key needs to be decoded before it is combined. (The example above is also missing a newline at the end of the final table data).\nSo the working code is:\n>>> s = \"+8070465bdf3b9c6ad6a89c32e8162ef1\\t\\n+86fa593a025714f89d6bc8c9c5a1... | [
2,
1
] | [] | [] | [
"api",
"python",
"safe_browsing",
"verification"
] | stackoverflow_0000181994_api_python_safe_browsing_verification.txt |
Q:
MVC model structure in Python
I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have:
Model/__init__p.y
should hold all Model class names so
I can do a "from Model import User"
e.g. from a ... | MVC model structure in Python | I'm having problems structuring classes in the Model part of an MVC pattern in my Python app. No matter how I turn things, I keep running into circular imports. Here's what I have:
Model/__init__p.y
should hold all Model class names so
I can do a "from Model import User"
e.g. from a Controller or a unit
test case
Mod... | [
"There is an inconsistency in your specification. You say Database.py needs to import all Model classes to do ORM but then you say the User class need access to the Database to do queries.\nThink of these as layers of an API. The Database class provides an API (maybe object-oriented) to some physical persistence la... | [
7,
3,
1
] | [] | [] | [
"model",
"model_view_controller",
"python",
"structure"
] | stackoverflow_0000185389_model_model_view_controller_python_structure.txt |
Q:
Regular expression to match start of filename and filename extension
What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'?
The regular expression should match any of the following:
RunFoo.py
RunBar.py
Run42.py
It should not match:
... | Regular expression to match start of filename and filename extension | What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'?
The regular expression should match any of the following:
RunFoo.py
RunBar.py
Run42.py
It should not match:
myRunFoo.py
RunBar.py1
Run42.txt
The SQL equivalent of what I am looking ... | [
"For a regular expression, you would use:\nre.match(r'Run.*\\.py$')\n\nA quick explanation:\n\n. means match any character.\n* means match any repetition of the previous character (hence .* means any sequence of chars)\n\\ is an escape to escape the explicit dot\n$ indicates \"end of the string\", so we don't match... | [
56,
16,
15,
10,
6,
4,
0,
0
] | [] | [] | [
"python",
"regex",
"sql",
"sql_like"
] | stackoverflow_0000185378_python_regex_sql_sql_like.txt |
Q:
Extracting unique items from a list of mappings
He're an interesting problem that looks for the most Pythonic solution. Suppose I have a list of mappings {'id': id, 'url': url}. Some ids in the list are duplicate, and I want to create a new list, with all the duplicates removed. I came up with the following functi... | Extracting unique items from a list of mappings | He're an interesting problem that looks for the most Pythonic solution. Suppose I have a list of mappings {'id': id, 'url': url}. Some ids in the list are duplicate, and I want to create a new list, with all the duplicates removed. I came up with the following function:
def unique_mapping(map):
d = {}
for res i... | [
"Your example can be rewritten slightly to construct the first dictionary using a generator expression and to remove necessity of construction of another mappings. Just reuse the old ones:\ndef unique_mapping(mappings):\n return dict((m['id'], m) for m in mappings).values()\n\nAlthough this came out as a one-lin... | [
4,
2,
1
] | [] | [] | [
"duplicate_data",
"python",
"unique"
] | stackoverflow_0000186131_duplicate_data_python_unique.txt |
Q:
How to make parts of a website under SSL and the rest not?
I need to create a cherrypy main page that has a login area. I want the login area to be secure, but not the rest of the page. How can I do this in CherryPy?
Ideally, any suggestions will be compatible with http://web.archive.org/web/20170210040849/http:... | How to make parts of a website under SSL and the rest not? | I need to create a cherrypy main page that has a login area. I want the login area to be secure, but not the rest of the page. How can I do this in CherryPy?
Ideally, any suggestions will be compatible with http://web.archive.org/web/20170210040849/http://tools.cherrypy.org:80/wiki/AuthenticationAndAccessRestrictions... | [
"This is commonly considered a bad idea. The primary reason is that it confuses most people due to the website identity markers appearing in just about every current browsers url area.\n",
"Assuming you only want parts of the actual page to be secure, you should create an iframe pointing to a HTTPS source. Howev... | [
1,
1
] | [] | [] | [
"cherrypy",
"python",
"ssl"
] | stackoverflow_0000187434_cherrypy_python_ssl.txt |
Q:
Configuration file with list of key-value pairs in python
I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would match "file... | Configuration file with list of key-value pairs in python | I have a python script that analyzes a set of error messages and checks for each message if it matches a certain pattern (regular expression) in order to group these messages. For example "file x does not exist" and "file y does not exist" would match "file .* does not exist" and be accounted as two occurrences of "fil... | [
"I sometimes just write a python module (i.e. file) called config.py or something with following contents:\nconfig = {\n 'name': 'hello',\n 'see?': 'world'\n}\n\nthis can then be 'read' like so:\nfrom config import config\nconfig['name']\nconfig['see?']\n\neasy.\n",
"You have two decent options:\n\nPython s... | [
38,
36,
8,
4,
4,
3
] | [] | [] | [
"configuration",
"python",
"serialization"
] | stackoverflow_0000186916_configuration_python_serialization.txt |
Q:
Django admin interface inlines placement
I want to be able to place an inline inbetween two different fields in a fieldset. You can already do this with foreignkeys, I figured that inlining the class I wanted and defining it to get extra forms would do the trick, but apparently I get a:
"class x" has no Foreig... | Django admin interface inlines placement | I want to be able to place an inline inbetween two different fields in a fieldset. You can already do this with foreignkeys, I figured that inlining the class I wanted and defining it to get extra forms would do the trick, but apparently I get a:
"class x" has no ForeignKey to "class y"
error. Is this not something... | [
"It seems to be impossible in Django admin site itself (you should not include inlined fields in \"fields\" at all) but you can use JS to move inlined fields wherever you want.\n"
] | [
3
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0000188451_django_django_admin_python.txt |
Q:
OCSP libraries for python / java / c?
Going back to my previous question on OCSP, does anybody know of "reliable" OCSP libraries for Python, Java and C?
I need "client" OCSP functionality, as I'll be checking the status of Certs against an OCSP responder, so responder functionality is not that important.
Thanks
... | OCSP libraries for python / java / c? | Going back to my previous question on OCSP, does anybody know of "reliable" OCSP libraries for Python, Java and C?
I need "client" OCSP functionality, as I'll be checking the status of Certs against an OCSP responder, so responder functionality is not that important.
Thanks
| [
"Java 5 has support of revocation checking via OCSP built in. If you want to build an OCSP responder, or have finer control over revocation checking, check out Bouncy Castle. You can use this to implement your own CertPathChecker that, for example, uses non-blocking I/O in its status checks.\n",
"Have you check p... | [
3,
1,
1
] | [] | [] | [
"c",
"java",
"ocsp",
"python"
] | stackoverflow_0000143515_c_java_ocsp_python.txt |
Q:
Resources for Python Programmer
I have written a lot of code in Python, and I am very used to the syntax, object structure, and so forth of Python because of it.
What is the best online guide or resource site to provide me with the basics, as well as a comparison or lookup guide with equivalent functions/features ... | Resources for Python Programmer | I have written a lot of code in Python, and I am very used to the syntax, object structure, and so forth of Python because of it.
What is the best online guide or resource site to provide me with the basics, as well as a comparison or lookup guide with equivalent functions/features in VBA versus Python.
For example, I ... | [
"VBA is quite different from Python, so you should read at least the \"Microsoft Visual Basic Help\" as provided by the application you are going to use (Excel, Access…).\nGenerally speaking, VBA has the equivalent of Python modules; they're called \"Libraries\", and they are not as easy to create as Python modules... | [
25,
2,
2,
2,
2,
1,
0,
0
] | [] | [] | [
"porting",
"python",
"vba"
] | stackoverflow_0000076882_porting_python_vba.txt |
Q:
Python - How to use Conch to create a Virtual SSH server
I'm looking at creating a server in python that I can run, and will work as an SSH server. This will then let different users login, and act as if they'd logged in normally, but only had access to one command.
I want to do this so that I can have a system wh... | Python - How to use Conch to create a Virtual SSH server | I'm looking at creating a server in python that I can run, and will work as an SSH server. This will then let different users login, and act as if they'd logged in normally, but only had access to one command.
I want to do this so that I can have a system where I can add users to without having to create a system wide ... | [
"When you write a Conch server, you can control what happens when the client makes a shell request by implementing ISession.openShell. The Conch server will request IConchUser from your realm and then adapt the resulting avatar to ISession to call openShell on it if necessary.\nISession.openShell's job is to take ... | [
7
] | [
"While Python really is my favorite language, I think you need not create you own server for this. When you look at the OpenSSH Manualpage for sshd you'll find the \"command\" options for the authorized keys file that lets you define a specific command to run on login.\nUsing keys, you can use one system account to... | [
-2
] | [
"python",
"twisted"
] | stackoverflow_0000186316_python_twisted.txt |
Q:
Base-2 (Binary) Representation Using Python
Building on How Do You Express Binary Literals in Python, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with, but I'd like to replace it with a better algorithm, or at ... | Base-2 (Binary) Representation Using Python | Building on How Do You Express Binary Literals in Python, I was thinking about sensible, intuitive ways to do that Programming 101 chestnut of displaying integers in base-2 form. This is the best I came up with, but I'd like to replace it with a better algorithm, or at least one that should have screaming-fast perform... | [
"For best efficiency, you generally want to process more than a single bit at a time.\nYou can use a simple method to get a fixed width binary representation. eg.\ndef _bin(x, width):\n return ''.join(str((x>>i)&1) for i in xrange(width-1,-1,-1))\n\n_bin(x, 8) will now give a zero padded representation of x's lo... | [
14,
3
] | [] | [] | [
"python"
] | stackoverflow_0000187273_python.txt |
Q:
What property returns the regular expression when re.compile is called?
def foo ():
x = re.compile('^abc')
foo2(x)
def foo2(x):
How do I get x to return '^abc'? within the following code
logging.info('x is ' + x.???)
A:
pattern
| What property returns the regular expression when re.compile is called? | def foo ():
x = re.compile('^abc')
foo2(x)
def foo2(x):
How do I get x to return '^abc'? within the following code
logging.info('x is ' + x.???)
| [
"pattern\n"
] | [
3
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000189861_python_regex.txt |
Q:
Getting the pattern back from a compiled re?
Assume I have created a compiled re:
x = re.compile('^\d+$')
Is there a way to extract the pattern string (^\d+$) back from the x?
A:
You can get it back with
x.pattern
from the Python documentation on Regular Expression Objects
| Getting the pattern back from a compiled re? | Assume I have created a compiled re:
x = re.compile('^\d+$')
Is there a way to extract the pattern string (^\d+$) back from the x?
| [
"You can get it back with\nx.pattern\n\nfrom the Python documentation on Regular Expression Objects\n"
] | [
31
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000190967_python_regex.txt |
Q:
How to make Ruby or Python web sites to use multiple cores?
Even though Python and Ruby have one kernel thread per interpreter thread, they have a global interpreter lock (GIL) that is used to protect potentially shared data structures, so this inhibits multi-processor execution. Even though the portions in those ... | How to make Ruby or Python web sites to use multiple cores? | Even though Python and Ruby have one kernel thread per interpreter thread, they have a global interpreter lock (GIL) that is used to protect potentially shared data structures, so this inhibits multi-processor execution. Even though the portions in those languajes that are written in C or C++ can be free-threaded, that... | [
"I'm not totally sure which problem you want so solve, but if you deploy your python/django application via an apache prefork MPM using mod_python apache will start several worker processes for handling different requests.\nIf one request needs so much resources, that you want to use multiple cores have a look at p... | [
4,
4,
1,
1,
0
] | [] | [] | [
"multicore",
"multithreading",
"python",
"ruby"
] | stackoverflow_0000037142_multicore_multithreading_python_ruby.txt |
Q:
Configuring python
I am new to python and struggling to find how to control the amount of memory a python process can take? I am running python on a Cento OS machine with more than 2 GB of main memory size. Python is taking up only 128mb of this and I want to allocate it more. I tried to search all over the intern... | Configuring python | I am new to python and struggling to find how to control the amount of memory a python process can take? I am running python on a Cento OS machine with more than 2 GB of main memory size. Python is taking up only 128mb of this and I want to allocate it more. I tried to search all over the internet on this for last half... | [
"Forget all that, python just allocates more memory as needed, there is not a myriad of comandline arguments for the VM as in java, just let it run. For all comandline switches you can just run python -h or read man python.\n",
"Are you sure that the machine does not have a 128M process limit? If you are running ... | [
11,
2
] | [] | [] | [
"memory",
"python"
] | stackoverflow_0000191700_memory_python.txt |
Q:
How do I turn an RSS feed back into RSS?
According to the feedparser documentation, I can turn an RSS feed into a parsed object like this:
import feedparser
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
but I can't find anything showing how to go the other way; I'd like to be able do mani... | How do I turn an RSS feed back into RSS? | According to the feedparser documentation, I can turn an RSS feed into a parsed object like this:
import feedparser
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
but I can't find anything showing how to go the other way; I'd like to be able do manipulate 'd' and then output the result as XML:
... | [
"Appended is a not hugely-elegant, but working solution - it uses feedparser to parse the feed, you can then modify the entries, and it passes the data to PyRSS2Gen. It preserves most of the feed info (the important bits anyway, there are somethings that will need extra conversion, the parsed_feed['feed']['image'] ... | [
7,
1,
0,
0
] | [] | [] | [
"python",
"rss"
] | stackoverflow_0000181818_python_rss.txt |
Q:
In Django how do I notify a parent when a child is saved in a foreign key relationship?
I have the following two models:
class Activity(models.Model):
name = models.CharField(max_length=50, help_text='Some help.')
entity = models.ForeignKey(CancellationEntity)
...
class Cancellation(models.Model):
... | In Django how do I notify a parent when a child is saved in a foreign key relationship? | I have the following two models:
class Activity(models.Model):
name = models.CharField(max_length=50, help_text='Some help.')
entity = models.ForeignKey(CancellationEntity)
...
class Cancellation(models.Model):
activity = models.ForeignKey(Activity)
date = models.DateField(default=datetime.now().d... | [
"What you want to look into is Django's signals (check out this page too), specifically the model signals--more specifically, the post_save signal. Signals are Django's version of a plugin/hook system. The post_save signal gets sent every time a model is saved, whether it's updated or created (and it'll let you kno... | [
17,
5
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0000192367_django_django_models_python.txt |
Q:
Read colors of image with Python (GAE)
How can I read the colors of an image with python using google app engine?
Example: I like to build a function to determine the most striking colors of an image to set a harmonic background color for it.
A:
The Images API does not (currently) contain pixel-level functions. ... | Read colors of image with Python (GAE) | How can I read the colors of an image with python using google app engine?
Example: I like to build a function to determine the most striking colors of an image to set a harmonic background color for it.
| [
"The Images API does not (currently) contain pixel-level functions. To quote the overview document:\n\nNote: In order to use the Images API in your local environment you must first download and install PIL, the Python Imaging Library. PIL is not available on App Engine; it is only used as a stub for the Images API ... | [
2,
2,
0
] | [] | [] | [
"analysis",
"google_app_engine",
"image",
"python"
] | stackoverflow_0000190675_analysis_google_app_engine_image_python.txt |
Q:
How can I, in python, iterate over multiple 2d lists at once, cleanly?
If I'm making a simple grid based game, for example, I might have a few 2d lists. One might be for terrain, another might be for objects, etc. Unfortunately, when I need to iterate over the lists and have the contents of a square in one list af... | How can I, in python, iterate over multiple 2d lists at once, cleanly? | If I'm making a simple grid based game, for example, I might have a few 2d lists. One might be for terrain, another might be for objects, etc. Unfortunately, when I need to iterate over the lists and have the contents of a square in one list affect part of another list, I have to do something like this.
for i in range(... | [
"If anyone is interested in performance of the above solutions, here they are for 4000x4000 grids, from fastest to slowest:\n\nBrian: 1.08s (modified, with izip instead of zip)\nJohn: 2.33s\nDzinX: 2.36s\nΤΖΩΤΖΙΟΥ: 2.41s (but object initialization took 62s)\nEugene: 3.17s\nRobert: 4.56s\nBrian: 27.24s (original, wi... | [
33,
15,
10,
4,
3,
3,
2,
1,
0
] | [
"for d1 in alist\n for d2 in d1\n if d2 = \"whatever\"\n do_my_thing()\n\n"
] | [
-4
] | [
"python"
] | stackoverflow_0000189087_python.txt |
Q:
Problem opening berkeley db in python
I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work.
The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 w... | Problem opening berkeley db in python | I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work.
The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 while libdb is version 4.6. I get the follow... | [
"I think answers should go in the \"answer\" section rather than as an addendum to the question since that marks the question as having an answer on the various question-list pages. I'll do that for you but, if you also get around to doing it, leave a comment on my answer so I can delete it.\nQuoting \"answer in q... | [
3,
0
] | [] | [] | [
"berkeley_db",
"database",
"python"
] | stackoverflow_0000181648_berkeley_db_database_python.txt |
Q:
How can I find the full path to a font from its display name on a Mac?
I am using the Photoshop's javascript API to find the fonts in a given PSD.
Given a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.
This is all happening in a python program... | How can I find the full path to a font from its display name on a Mac? | I am using the Photoshop's javascript API to find the fonts in a given PSD.
Given a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.
This is all happening in a python program running on OSX so I guess I'm looking for one of:
Some Photoshop javascrip... | [
"Unfortunately the only API that isn't deprecated is located in the ApplicationServices framework, which doesn't have a bridge support file, and thus isn't available in the bridge. If you're wanting to use ctypes, you can use ATSFontGetFileReference after looking up the ATSFontRef.\nCocoa doesn't have any native su... | [
22,
7,
6,
5
] | [] | [] | [
"fonts",
"macos",
"photoshop",
"python"
] | stackoverflow_0000000469_fonts_macos_photoshop_python.txt |
Q:
How do you design data models for Bigtable/Datastore (GAE)?
Since the Google App Engine Datastore is based on Bigtable and we know that's not a relational database, how do you design a database schema/data model for applications that use this type of database system?
A:
Designing a bigtable schema is an open pro... | How do you design data models for Bigtable/Datastore (GAE)? | Since the Google App Engine Datastore is based on Bigtable and we know that's not a relational database, how do you design a database schema/data model for applications that use this type of database system?
| [
"Designing a bigtable schema is an open process, and basically requires you to think about:\n\nThe access patterns you will be using and how often each will be used\nThe relationships between your types\nWhat indices you are going to need\nThe write patterns you will be using (in order to effectively spread load)\n... | [
19,
1
] | [
"As GAE builds on how data is managed in Django there is a lot of info on how to address similar questions in the Django documentation (for example see here, scroll down to 'Your first model').\nIn short you design you db model as a regular object model and let GAE sort out all of the object-relational mappings. \n... | [
-2
] | [
"bigtable",
"database",
"google_app_engine",
"python"
] | stackoverflow_0000079850_bigtable_database_google_app_engine_python.txt |
Q:
How can I search through Stack Overflow questions from a script?
Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of tuples (title... | How can I search through Stack Overflow questions from a script? | Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of tuples (title, URL).
How can I accomplish this? Would you consider querying Google ... | [
">>> from urllib import urlencode\n>>> params = urlencode({'q': 'python best practices', 'sort': 'relevance'})\n>>> params\n'q=python+best+practices&sort=relevance'\n>>> from urllib2 import urlopen\n>>> html = urlopen(\"http://stackoverflow.com/search?%s\" % params).read()\n>>> import re\n>>> links = re.findall(r'<... | [
6,
5,
2,
1,
0
] | [] | [] | [
"python",
"scripting",
"search",
"stackexchange_api"
] | stackoverflow_0000196755_python_scripting_search_stackexchange_api.txt |
Q:
MySQLdb execute timeout
Sometimes in our production environment occurs situation when connection between service (which is python program that uses MySQLdb) and mysql server is flacky, some packages are lost, some black magic happens and .execute() of MySQLdb.Cursor object never ends (or take great amount of time ... | MySQLdb execute timeout | Sometimes in our production environment occurs situation when connection between service (which is python program that uses MySQLdb) and mysql server is flacky, some packages are lost, some black magic happens and .execute() of MySQLdb.Cursor object never ends (or take great amount of time to end).
This is very bad be... | [
"if the communication is such a problem, consider writing a 'proxy' that receives your SQL commands over the flaky connection and relays them to the MySQL server on a reliable channel (maybe running on the same box as the MySQL server). This way you have total control over failure detection and retrying.\n",
"Yo... | [
2,
1
] | [] | [] | [
"mysql",
"python",
"timeout"
] | stackoverflow_0000196217_mysql_python_timeout.txt |
Q:
what is the best/easiest to use encryption library in python
I want to encrypt few files using python what is the best way
I can use gpg/pgp using any standard/famous python libraries?
A:
PyCrypto seems to be the best one around.
A:
Try KeyCzar
Very easy to implement.
A:
I use GPGme The main strength of GP... | what is the best/easiest to use encryption library in python | I want to encrypt few files using python what is the best way
I can use gpg/pgp using any standard/famous python libraries?
| [
"PyCrypto seems to be the best one around.\n",
"Try KeyCzar \nVery easy to implement. \n",
"I use GPGme The main strength of GPGme is that it read and writes files at the OpenPGP standard (RFC 4880) which can be important if you want to interoperate with other PGP programs. \nIt has a Python interface. Warning:... | [
12,
7,
6,
5,
4,
0
] | [] | [] | [
"encryption",
"gnupg",
"pgp",
"python"
] | stackoverflow_0000090413_encryption_gnupg_pgp_python.txt |
Q:
Which AES library to use in Ruby/Python?
I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the ruby-aes gem/library. The library is very easy to use but we've been having trouble passing data between it and the pyCrypto AES library... | Which AES library to use in Ruby/Python? | I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the ruby-aes gem/library. The library is very easy to use but we've been having trouble passing data between it and the pyCrypto AES library for Python. These libraries seem to be fine w... | [
"\n(e.g., the lengths differ by one or there is extra garbage characters on the end of the decrypted string)\n\nI missed that bit. There's nothing wrong with your encryption/decryption. It sounds like a padding problem. AES always encodes data in blocks of 128 bits. If the length of your data isn't a multiple of 12... | [
5,
3,
2,
1,
1
] | [] | [] | [
"aes",
"encryption",
"python",
"ruby"
] | stackoverflow_0000196776_aes_encryption_python_ruby.txt |
Q:
What are the advantages of packaging your python library/application as an .egg file?
I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer?
A:
From the Python Enterprise Application Kit community:
"Eggs are to Pythons as... | What are the advantages of packaging your python library/application as an .egg file? | I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer?
| [
"From the Python Enterprise Application Kit community:\n\n\"Eggs are to Pythons as Jars are to Java...\"\nPython eggs are a way of bundling\n additional information with a Python\n project, that allows the project's\n dependencies to be checked and\n satisfied at runtime, as well as\n allowing projects to prov... | [
32,
5,
4,
3,
1,
1
] | [] | [] | [
"egg",
"packaging",
"python",
"software_distribution",
"zip"
] | stackoverflow_0000047953_egg_packaging_python_software_distribution_zip.txt |
Q:
Dealing with a string containing multiple character encodings
I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me.
I'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-i... | Dealing with a string containing multiple character encodings | I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me.
I'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-in struct module. My problem is with the strings, as they include mu... | [
"Here's a relatively simple example of how do it...\n# -*- coding: utf-8 -*-\nimport re\n\n# Test Data\nENCODING_RAW_DATA = (\n ('latin_1', 'L', u'Hello'), # Latin 1\n ('iso8859_2', 'E', u'dobrý večer'), # Central Europe\n ('iso8859_9', 'T', u'İyi akşamlar'), # Turkish\n ('iso8859_13', 'B',... | [
7,
4,
3,
2,
1
] | [] | [] | [
"encoding",
"python",
"string",
"unicode"
] | stackoverflow_0000197759_encoding_python_string_unicode.txt |
Q:
A python web application framework for tight DB/GUI coupling?
I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum wi... | A python web application framework for tight DB/GUI coupling? | I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum with of 20 characters, there GUIs should automatically constrain the ... | [
"web2py does most of what you ask:\nBased on a field type and its validators it will render the field with the appropriate widget. You can override with\ndb.table.field.widget=...\n\nand use a third party widget.\nweb2py has js to blocks the user from entering a non-integer in a integer field or a non-double in a d... | [
5,
3,
1,
1,
1
] | [] | [] | [
"coupling",
"data_driven",
"metadata",
"python",
"sql"
] | stackoverflow_0000043368_coupling_data_driven_metadata_python_sql.txt |
Q:
Python Regex vs PHP Regex
Not a competition, it is instead me trying to find why a certain regex works in one but not the other.
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
That's my Regex and I'm tr... | Python Regex vs PHP Regex | Not a competition, it is instead me trying to find why a certain regex works in one but not the other.
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
That's my Regex and I'm trying to run it on
127.255.0.0
... | [
"It works for me. You must be doing something wrong.\n>>> re.match(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)', '127.255.0.0').groups()\n('127', '255', '0', '0')\n\nDon't forget to escape the reg... | [
7,
4,
3,
2,
1,
1
] | [] | [] | [
"php",
"python",
"regex"
] | stackoverflow_0000118143_php_python_regex.txt |
Q:
Docstrings for data?
Is there a way to describe the module's data in a similar way that a docstring describes a module or a funcion?
class MyClass(object):
def my_function():
"""This docstring works!"""
return True
my_list = []
"""This docstring does not work!"""
A:
To my knowledge, i... | Docstrings for data? | Is there a way to describe the module's data in a similar way that a docstring describes a module or a funcion?
class MyClass(object):
def my_function():
"""This docstring works!"""
return True
my_list = []
"""This docstring does not work!"""
| [
"To my knowledge, it is not possible to assign docstrings to module data members.\nPEP 224 suggests this feature, but the PEP was rejected.\nI suggest you document the data members of a module in the module's docstring:\n# module.py:\n\"\"\"About the module.\n\nmodule.data: contains the word \"spam\"\n\n\"\"\"\n\nd... | [
15,
11,
10
] | [] | [] | [
"docstring",
"python"
] | stackoverflow_0000197387_docstring_python.txt |
Q:
How to find out whether subversion working directory is locked by svn?
A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir.
Before running 'svn co ...' command in a sub-process ( v... | How to find out whether subversion working directory is locked by svn? | A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir.
Before running 'svn co ...' command in a sub-process ( via python subprocess module ) the parent python code checks if the working c... | [
"Within the directory, there should be a directory called '.svn'. Within this, a file named 'locked' indicates that the directory is locked.\n",
"This sounds like a potential race condition, in that something like the following can happen:\n\nProcess A checks to see if the directory exists (it doesn't yet).\nProc... | [
4,
2
] | [] | [] | [
"python",
"svn"
] | stackoverflow_0000197009_python_svn.txt |
Q:
How do I remove a cookie that I've set on someone's computer?
I've got a web system where users log in, and it stores a cookie of their session. When they log in as someone else or log out I want to remove that original cookie that I stored. What's the best way to do that?
I'm using Python and Apache, though I sup... | How do I remove a cookie that I've set on someone's computer? | I've got a web system where users log in, and it stores a cookie of their session. When they log in as someone else or log out I want to remove that original cookie that I stored. What's the best way to do that?
I'm using Python and Apache, though I suppose the answer will remain the same for most languages.
| [
"Set the cookie again, as if you hadn't set it the first time, but specify an expiration date that is in the past.\n",
"I guess the best way is to set the expiration to a date of the cookie to some date in the past.\n",
"Return the header\n\nSet-Cookie: token=opaque; Domain=.your.domain; Expires=Thu, 01-Jan-197... | [
7,
4,
1
] | [] | [] | [
"apache",
"cookies",
"http",
"python"
] | stackoverflow_0000200250_apache_cookies_http_python.txt |
Q:
fast filter method in python
I want to filter two list with any fastest method in python script. I have used the built-in filter() method for this purpose. but it is quite slow and taking too much time because I have very big list, I think more than 5 million item in each list or may be more.
I do not know how I ... | fast filter method in python | I want to filter two list with any fastest method in python script. I have used the built-in filter() method for this purpose. but it is quite slow and taking too much time because I have very big list, I think more than 5 million item in each list or may be more.
I do not know how I will make it. Please if anybody ha... | [
"Maybe your lists are too large and do not fit in memory, and you experience thrashing.\nIf the sources are in files, you do not need the whole list in memory all at once. Try using itertools, e.g.:\nfrom itertools import ifilter\n\ndef is_important(s):\n return len(s)>10\n\nfiltered_list = ifilter(is_important, ... | [
15,
5,
2,
2,
2,
2
] | [] | [] | [
"filter",
"list",
"python"
] | stackoverflow_0000200373_filter_list_python.txt |
Q:
How can I unpack binary hex formatted data in Python?
Using the PHP pack() function, I have converted a string into a binary hex representation:
$string = md5(time); // 32 character length
$packed = pack('H*', $string);
The H* formatting means "Hex string, high nibble first".
To unpack this in PHP, I would simply... | How can I unpack binary hex formatted data in Python? | Using the PHP pack() function, I have converted a string into a binary hex representation:
$string = md5(time); // 32 character length
$packed = pack('H*', $string);
The H* formatting means "Hex string, high nibble first".
To unpack this in PHP, I would simply use the unpack() function with the H* format flag.
How wou... | [
"There's an easy way to do this with the binascii module:\n>>> import binascii\n>>> print binascii.hexlify(\"ABCZ\")\n'4142435a'\n>>> print binascii.unhexlify(\"4142435a\")\n'ABCZ'\n\nUnless I'm misunderstanding something about the nibble ordering (high-nibble first is the default… anything different is insane), th... | [
13,
11,
8
] | [] | [] | [
"binary",
"hex",
"python"
] | stackoverflow_0000200738_binary_hex_python.txt |
Q:
urllib.urlopen works but urllib2.urlopen doesn't
I have a simple website I'm testing. It's running on localhost and I can access it in my web browser. The index page is simply the word "running". urllib.urlopen will successfully read the page but urllib2.urlopen will not. Here's a script which demonstrates the... | urllib.urlopen works but urllib2.urlopen doesn't | I have a simple website I'm testing. It's running on localhost and I can access it in my web browser. The index page is simply the word "running". urllib.urlopen will successfully read the page but urllib2.urlopen will not. Here's a script which demonstrates the problem (this is the actual script and not a simplifi... | [
"Sounds like you have proxy settings defined that urllib2 is picking up on. When it tries to proxy \"127.0.0.01/\", the proxy gives up and returns a 504 error.\nFrom Obscure python urllib2 proxy gotcha:\nproxy_support = urllib2.ProxyHandler({})\nopener = urllib2.build_opener(proxy_support)\nprint opener.open(\"http... | [
16,
1,
1,
1
] | [] | [] | [
"python",
"urllib",
"urllib2"
] | stackoverflow_0000201515_python_urllib_urllib2.txt |
Q:
python name a file same as a lib
i have the following script
import getopt, sys
opts, args = getopt.getopt(sys.argv[1:], "h:s")
for key,value in opts:
print key, "=>", value
if i name this getopt.py and run it doesn't work as it tries to import itself
is there a way around this, so i can keep this filename bu... | python name a file same as a lib | i have the following script
import getopt, sys
opts, args = getopt.getopt(sys.argv[1:], "h:s")
for key,value in opts:
print key, "=>", value
if i name this getopt.py and run it doesn't work as it tries to import itself
is there a way around this, so i can keep this filename but specify on import that i want the st... | [
"You shouldn't name your scripts like existing modules. Especially if standard. \nThat said, you can touch sys.path to modify the library loading order\n~# cat getopt.py\nprint \"HI\"\n~# python\nPython 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)\n[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2\nType \"help\", \"copyri... | [
7,
4,
0,
0
] | [
"import getopt as bettername\n\nThis should allow you to call getopt as bettername.\n"
] | [
-1
] | [
"python"
] | stackoverflow_0000201846_python.txt |
Q:
Store simple user settings in Python
I am programming a website in which users will have a number of settings, such as their choice of colour scheme, etc. I'm happy to store these as plain text files, and security is not an issue.
The way I currently see it is: there is a dictionary, where all the keys are users a... | Store simple user settings in Python | I am programming a website in which users will have a number of settings, such as their choice of colour scheme, etc. I'm happy to store these as plain text files, and security is not an issue.
The way I currently see it is: there is a dictionary, where all the keys are users and the values are dictionaries with the us... | [
"I would use the ConfigParser module, which produces some pretty readable and user-editable output for your example:\n[bob]\ncolour_scheme: blue\nbritish: yes\n[joe]\ncolor_scheme: that's 'color', silly!\nbritish: no\nThe following code would produce the config file above, and then print it out:\nimport sys\nfrom C... | [
10,
7,
6,
5,
3,
2,
2,
1,
0,
0,
0,
0
] | [] | [] | [
"database",
"python",
"settings",
"web"
] | stackoverflow_0000200599_database_python_settings_web.txt |
Q:
Creating self-contained python applications
I'm trying to create a self-contained version of pisa (html to pdf converter, latest version), but I can't succeed due to several errors. I've tried py2exe, bb-freeze and cxfreeze.
This has to be in windows, which makes my life a bit harder. I remember that a couple of m... | Creating self-contained python applications | I'm trying to create a self-contained version of pisa (html to pdf converter, latest version), but I can't succeed due to several errors. I've tried py2exe, bb-freeze and cxfreeze.
This has to be in windows, which makes my life a bit harder. I remember that a couple of months ago the author had a zip file containing th... | [
"Check out pyinstaller, it makes standalone executables (as in one .EXE file, and that's it).\n"
] | [
28
] | [] | [] | [
"executable",
"python",
"self_contained",
"windows"
] | stackoverflow_0000203487_executable_python_self_contained_windows.txt |
Q:
Alert Popups from service in Python
I have been using win32api.MessageBox to do alerts, and this works for apps running from the interactive prompt and normally executed code, however when I built a Python service when a MessageBox is triggered I can hear the 'beep' but the box does not display. Is it possible to... | Alert Popups from service in Python | I have been using win32api.MessageBox to do alerts, and this works for apps running from the interactive prompt and normally executed code, however when I built a Python service when a MessageBox is triggered I can hear the 'beep' but the box does not display. Is it possible to display alerts from services?
| [
"No, Windows services run on a completely separate hidden desktop and have no access to the logged-on user's desktop. There is no way around this from a service developer's perspective.\nIn previous versions of Windows, it was possible for a service to be marked as \"allowed to interact with the user desktop\", but... | [
5
] | [] | [] | [
"alerts",
"python",
"service",
"winapi"
] | stackoverflow_0000204062_alerts_python_service_winapi.txt |
Q:
Can I implement a web user authentication system in python without POST?
My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?
If it's not, how would you do it wi... | Can I implement a web user authentication system in python without POST? | My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?
If it's not, how would you do it with POST? Just out of curiosity.
Cheers!
| [
"You can actually do it all with GET methods. However, you'll want to use a full challenge response protocol for the logins. (You can hash on the client side using javascript. You just need to send out a unique challenge each time.) You'll also want to use SSL to ensure that no one can see the strings as they g... | [
5,
1,
0,
0,
0
] | [
"Logging in securely is very subjective. Full 'security' is not easy to achieve (if at all possible...debatable). However, you can come close. \nIf POST is not an option, maybe you can use a directory security method such as .htaccess or windows authentication depending on what system you're on.\nBoth of the abov... | [
-1
] | [
"authentication",
"cgi",
"python"
] | stackoverflow_0000069979_authentication_cgi_python.txt |
Q:
Failed to get separate instances of a class under mod_python
I'm trying to run some python code under Apache 2.2 / mod_python 3.2.8. Eventually the code does os.fork() and spawns 2 separate long-run processes. Each of those processes has to create a separate instance of a class in order to avoid any possible colli... | Failed to get separate instances of a class under mod_python | I'm trying to run some python code under Apache 2.2 / mod_python 3.2.8. Eventually the code does os.fork() and spawns 2 separate long-run processes. Each of those processes has to create a separate instance of a class in order to avoid any possible collision in the parallel flow.
class Foo(object):
pass
kidprocs =... | [
"The memory location given by the repr() function is an address in virtual memory, not an address in the system's global memory. Each of your processes returned by fork() has its own virtual memory space which is completely distinct from other processes. They do not share memory.\nEdit: Per brian's comments below... | [
3
] | [] | [] | [
"apache",
"mod_python",
"python"
] | stackoverflow_0000204427_apache_mod_python_python.txt |
Q:
Checking for member existence in Python
I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use hasattr like this:
class Foo(object):
@classmethod
def singleton(self):
if not hasattr(self, 'instance'):
... | Checking for member existence in Python | I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use hasattr like this:
class Foo(object):
@classmethod
def singleton(self):
if not hasattr(self, 'instance'):
self.instance = Foo()
return se... | [
"These are two different methodologies: №1 is LBYL (look before you leap) and №2 is EAFP (easier to ask forgiveness than permission).\nPythonistas typically suggest that EAFP is better, with arguments in style of \"what if a process creates the file between the time you test for it and the time you try to create it... | [
22,
10,
5,
1,
0
] | [] | [] | [
"exception",
"hasattr",
"introspection",
"python"
] | stackoverflow_0000204308_exception_hasattr_introspection_python.txt |
Q:
Capture the contents of a regex and delete them, efficiently
Situation:
text: a string
R: a regex that matches part of the string. This might be expensive to calculate.
I want to both delete the R-matches from the text, and see what they actually contain. Currently, I do this like:
import re
ab_re = re.com... | Capture the contents of a regex and delete them, efficiently | Situation:
text: a string
R: a regex that matches part of the string. This might be expensive to calculate.
I want to both delete the R-matches from the text, and see what they actually contain. Currently, I do this like:
import re
ab_re = re.compile("[ab]")
text="abcdedfe falijbijie bbbb laifsjelifjl"
ab_re.fi... | [
"import re\n\nr = re.compile(\"[ab]\")\ntext = \"abcdedfe falijbijie bbbb laifsjelifjl\"\n\nmatches = []\nreplaced = []\npos = 0\nfor m in r.finditer(text):\n matches.append(m.group(0))\n replaced.append(text[pos:m.start()])\n pos = m.end()\nreplaced.append(text[pos:])\n\nprint matches\nprint ''.join(repla... | [
4,
4,
3,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000204829_python_regex.txt |
Q:
Sometimes can't delete an Oracle database row using Django
I have a unit test which contains the following line of code
Site.objects.get(name="UnitTest").delete()
and this has worked just fine until now. However, that statement is currently hanging. It'll sit there forever trying to execute the delete. If I ju... | Sometimes can't delete an Oracle database row using Django | I have a unit test which contains the following line of code
Site.objects.get(name="UnitTest").delete()
and this has worked just fine until now. However, that statement is currently hanging. It'll sit there forever trying to execute the delete. If I just say
print Site.objects.get(name="UnitTest")
then it works, s... | [
"From a separate session, can you query the DBA_BLOCKERS and DBA_WAITERS data dictionary tables and post the results? That will tell you if your session is getting blocked by a lock held by some other session, as well as what other session is holding the lock.\n"
] | [
1
] | [] | [] | [
"django",
"oracle",
"python"
] | stackoverflow_0000205136_django_oracle_python.txt |
Q:
Any good team-chat websites?
Are there any good team-chat websites, preferably in Python, ideally with CherryPy or Trac?
This is similar to https://stackoverflow.com/questions/46612/whats-a-good-freeware-collaborative-ie-multiuser-instant-messenger#46660, but a few primary differences:
1) I very much want to host ... | Any good team-chat websites? | Are there any good team-chat websites, preferably in Python, ideally with CherryPy or Trac?
This is similar to https://stackoverflow.com/questions/46612/whats-a-good-freeware-collaborative-ie-multiuser-instant-messenger#46660, but a few primary differences:
1) I very much want to host the server.
2) I don't care if Smi... | [
"Campfire from 37 signals - the rails guys.\nEdit: It doesn't meet your requirements but it has some great features...\n"
] | [
2
] | [] | [] | [
"collaboration",
"instant_messaging",
"python"
] | stackoverflow_0000206040_collaboration_instant_messaging_python.txt |
Q:
Why do attribute references act like this with Python inheritance?
The following seems strange.. Basically, the somedata attribute seems shared between all the classes that inherited from the_base_class.
class the_base_class:
somedata = {}
somedata['was_false_in_base'] = False
class subclassthing(the_base... | Why do attribute references act like this with Python inheritance? | The following seems strange.. Basically, the somedata attribute seems shared between all the classes that inherited from the_base_class.
class the_base_class:
somedata = {}
somedata['was_false_in_base'] = False
class subclassthing(the_base_class):
def __init__(self):
print self.somedata
firs... | [
"You are right, somedata is shared between all instances of the class and it's subclasses, because it is created at class definition time. The lines \nsomedata = {}\nsomedata['was_false_in_base'] = False\n\nare executed when the class is defined, i.e. when the interpreter encounters the class statement - not when t... | [
24,
12,
3
] | [] | [] | [
"class",
"inheritance",
"python"
] | stackoverflow_0000206734_class_inheritance_python.txt |
Q:
Receive socket size limits good?
I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why?
More info:
So certain chat programs limit the amount of text one can send per send (i.e. per time user presses sen... | Receive socket size limits good? | I am writing a program in Python that will act as a server and accept data from a client, is it a good idea to impose a hard limit as to the amount of data, if so why?
More info:
So certain chat programs limit the amount of text one can send per send (i.e. per time user presses send) so the question comes down to is th... | [
"Most likely you've seen code which protects against \"extra\" incoming data. This is often due to the possibility of buffer overruns, where the extra data being copied into memory overruns the pre-allocated array and overwrites executable code with attacker code. Code written in languages like C typically has a lo... | [
2,
1,
0
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0000203758_python_sockets.txt |
Q:
How to update a Tix.ComboBox's text?
I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?
Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. ... | How to update a Tix.ComboBox's text? | I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?
Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text field current... | [
"woo!\nsolved it on my own.\nUse \nself.combo['selection']\n\ninstead of\nself.combo['value']\n\n",
"NOTE: copy of Moe's answer that can be selected as chosen answer\nwoo!\nsolved it on my own.\nUse \nself.combo['selection']\n\ninstead of\nself.combo['value']\n\n"
] | [
5,
1
] | [] | [] | [
"combobox",
"python",
"tix",
"tkinter"
] | stackoverflow_0000117211_combobox_python_tix_tkinter.txt |
Q:
variables as parameters in field options
I want to create a model, that will set editable=False on creation, and editable=True on editing item. I thought it should be something like this:
home = models.ForeignKey(Team, editable=lambda self: True if self.id else False)
But it doesn't work. Maybe something with o... | variables as parameters in field options | I want to create a model, that will set editable=False on creation, and editable=True on editing item. I thought it should be something like this:
home = models.ForeignKey(Team, editable=lambda self: True if self.id else False)
But it doesn't work. Maybe something with overriding the init can help me, but i don't su... | [
"Add the following (a small extension of this code) to your admin.py:\nfrom django import forms\n\nclass ReadOnlyWidget(forms.Widget):\n def __init__(self, original_value, display_value):\n self.original_value = original_value\n self.display_value = display_value\n\n super(ReadOnlyWidget, se... | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000206245_django_python.txt |
Q:
Howto do python command-line autocompletion but NOT only at the beginning of a string
Python, through it's readline bindings allows for great command-line autocompletion (as described in here).
But, the completion only seems to work at the beginning of strings. If you want to match the middle or end of a string r... | Howto do python command-line autocompletion but NOT only at the beginning of a string | Python, through it's readline bindings allows for great command-line autocompletion (as described in here).
But, the completion only seems to work at the beginning of strings. If you want to match the middle or end of a string readline doesn't work.
I would like to autocomplete strings, in a command-line python progra... | [
"I'm not sure I understand the problem. You could use readline.clear_history and readline.add_history to set up the completable strings you want, then control-r to search backword in the history (just as if you were at a shell prompt). For example:\n#!/usr/bin/env python\n\nimport readline\n\nreadline.clear_histo... | [
10
] | [] | [] | [
"autocomplete",
"command_line",
"linux",
"python",
"unix"
] | stackoverflow_0000209484_autocomplete_command_line_linux_python_unix.txt |
Q:
Advanced Python FTP - can I control how ftplib talks to a server?
I need to send a very specific (non-standard) string to an FTP server:
dir "SYS:\IC.ICAMA."
The case is critical, as are the style of quotes and their content.
Unfortunately, ftplib.dir() seems to use the 'LIST' command rather than 'dir' (and it us... | Advanced Python FTP - can I control how ftplib talks to a server? | I need to send a very specific (non-standard) string to an FTP server:
dir "SYS:\IC.ICAMA."
The case is critical, as are the style of quotes and their content.
Unfortunately, ftplib.dir() seems to use the 'LIST' command rather than 'dir' (and it uses the wrong case for this application).
The FTP server is actually a t... | [
"Try the following. It is a modification of the original FTP.dir command which uses \"dir\" instead of \"LIST\". It gives a \"DIR not understood\" error with the ftp server I tested it on, but it does send the command you're after. (You will want to remove the print command I used to check that.)\nimport ftplib\... | [
4
] | [] | [] | [
"ftp",
"python"
] | stackoverflow_0000210067_ftp_python.txt |
Q:
py3k RC-1: "LookupError: unknown encoding: uft-8"
I just installed the first release candidate of Python 3.0 and got this error after typing:
>>> help('modules foo')
[...]
LookupError: unknown encoding: uft-8
Notice that it says uft-8 and not utf-8
Is this a py3k specific bug or a misconfiguration on my part? I d... | py3k RC-1: "LookupError: unknown encoding: uft-8" | I just installed the first release candidate of Python 3.0 and got this error after typing:
>>> help('modules foo')
[...]
LookupError: unknown encoding: uft-8
Notice that it says uft-8 and not utf-8
Is this a py3k specific bug or a misconfiguration on my part? I do not have any other versions of Python installed on th... | [
"It's not a typo, it's a deliberate error in a test module.\nmet% pwd\n/home/coventry/src/Python-3.0rc1\nmet% rgrep uft-8 .\n./Lib/test/bad_coding.py:# -*- coding: uft-8 -*-\n./py3k/Lib/test/bad_coding.py:# -*- coding: uft-8 -*-\n\nRemoving this module causes the help command to fall over in a different way.\nIt is... | [
5,
0
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0000210344_python_python_3.x.txt |
Q:
How to base64 encode a PDF file in Python
How should I base64 encode a PDF file for transport over XML-RPC in Python?
A:
If you don't want to use the xmlrpclib's Binary class, you can just use the .encode() method of strings:
a = open("pdf_reference.pdf", "rb").read().encode("base64")
A:
Actually, after some m... | How to base64 encode a PDF file in Python | How should I base64 encode a PDF file for transport over XML-RPC in Python?
| [
"If you don't want to use the xmlrpclib's Binary class, you can just use the .encode() method of strings:\na = open(\"pdf_reference.pdf\", \"rb\").read().encode(\"base64\")\n\n",
"Actually, after some more digging, it looks like the xmlrpclib module may have the piece I need with it's Binary helper class:\n\nbina... | [
25,
5,
2,
0
] | [] | [] | [
"base64",
"encoding",
"python",
"xml_rpc"
] | stackoverflow_0000208894_base64_encoding_python_xml_rpc.txt |
Q:
Extracting a parenthesized Python expression from a string
I've been wondering about how hard it would be to write some Python code to search a string for the index of a substring of the form ${expr}, for example, where expr is meant to be a Python expression or something resembling one. Given such a thing, one c... | Extracting a parenthesized Python expression from a string | I've been wondering about how hard it would be to write some Python code to search a string for the index of a substring of the form ${expr}, for example, where expr is meant to be a Python expression or something resembling one. Given such a thing, one could easily imagine going on to check the expression's syntax wi... | [
"I think what you're asking about is being able to insert Python code into text files to be evaluated. There are several modules that already exist to provide this kind of functionality. You can check the Python.org Templating wiki page for a comprehensive list.\nSome google searching also turned up a few other mod... | [
2,
1,
1,
0
] | [] | [] | [
"parsing",
"python"
] | stackoverflow_0000207290_parsing_python.txt |
Q:
Is it possible to compile Python natively (beyond pyc byte code)?
I wonder if it is possible to create an executable module from a Python script. I need to have the most performance and the flexibility of Python script, without needing to run in the Python environment. I would use this code to load on demand user ... | Is it possible to compile Python natively (beyond pyc byte code)? | I wonder if it is possible to create an executable module from a Python script. I need to have the most performance and the flexibility of Python script, without needing to run in the Python environment. I would use this code to load on demand user modules to customize my application.
| [
"\nThere's pyrex that compiles python like source to python extension modules \nrpython which allows you to compile python with some restrictions to various backends like C, LLVM, .Net etc. \nThere's also shed-skin which translates python to C++, but I can't say if it's any good. \nPyPy implements a JIT compiler wh... | [
14,
7,
2,
1
] | [] | [] | [
"compilation",
"module",
"python"
] | stackoverflow_0000205062_compilation_module_python.txt |
Q:
arguments to cryptographic functions
I'm a bit confused that the argument to crypto functions is a string. Should I simply wrap non-string arguments with str() e.g.
hashlib.sha256(str(user_id)+str(expiry_time))
hmac.new(str(random.randbits(256)))
(ignore for the moment that random.randbits() might not be cryptogr... | arguments to cryptographic functions | I'm a bit confused that the argument to crypto functions is a string. Should I simply wrap non-string arguments with str() e.g.
hashlib.sha256(str(user_id)+str(expiry_time))
hmac.new(str(random.randbits(256)))
(ignore for the moment that random.randbits() might not be cryptographically good).
edit: I realise that the ... | [
"Well, usually hash-functions (and cryptographic functions generally) work on bytes. The Python strings are basically byte-strings. If you want to compute the hash of some object you have to convert it to a string representation. Just make sure to apply the same operation later if you want to check if the hash is c... | [
6,
1
] | [
"Oh and Sha256 isn't really an industrial strength cryptographic function (although unfortunately it's used quite commonly on many sites). It's not a real way to protect passwords or other critical data, but more than good enough for generating temporal tokens\nEdit: As mentioned Sha256 needs at least some salt. Wi... | [
-1
] | [
"cryptography",
"python"
] | stackoverflow_0000211483_cryptography_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.