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:
Must a secure cryptographic signature reside outside of the file it refers to?
I'm programming a pet project in Python, and it involves users A & B interacting over network, attempting to insure that each has a local copy of the same file from user C.
The idea is that C gives each a file that has been digitally si... | Must a secure cryptographic signature reside outside of the file it refers to? | I'm programming a pet project in Python, and it involves users A & B interacting over network, attempting to insure that each has a local copy of the same file from user C.
The idea is that C gives each a file that has been digitally signed. A & B trade the digital signatures they have, and check it out on their own co... | [
"The digital signature from C alone should be enough for both A and B to confirm that their file is not corrupted, without ever communicating with eachother. If A and B did not receive a signature from C, they could each create a cryptographic hash of the file and compare the hash, but that does not require any di... | [
5,
4
] | [] | [] | [
"cryptography",
"digital_signature",
"file",
"python"
] | stackoverflow_0001132766_cryptography_digital_signature_file_python.txt |
Q:
Interact with a Windows console application via Python
I am using python 2.5 on Windows. I wish to interact with a console process via Popen. I currently have this small snippet of code:
p = Popen( ["console_app.exe"], stdin=PIPE, stdout=PIPE )
# issue command 1...
p.stdin.write( 'command1\n' )
result1 = p.stdout.... | Interact with a Windows console application via Python | I am using python 2.5 on Windows. I wish to interact with a console process via Popen. I currently have this small snippet of code:
p = Popen( ["console_app.exe"], stdin=PIPE, stdout=PIPE )
# issue command 1...
p.stdin.write( 'command1\n' )
result1 = p.stdout.read() # <---- we never return here
# issue command 2...
p.s... | [
"Your problem here is that you are trying to control an interactive application.\nstdout.read() will continue reading until it has reached the end of the stream, file or pipe. Unfortunately, in case of an interactive program, the pipe is only closed then whe program exits; which is never, if the command you sent it... | [
8,
2,
0,
0,
0
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0001124884_python_windows.txt |
Q:
Weird Problem with Classes and Optional Arguments
Okay so this was driving me nuts all day.
Why does this happen:
class Foo:
def __init__(self, bla = {}):
self.task_defs = bla
def __str__(self):
return ''.join(str(self.task_defs))
a = Foo()
b = Foo()
a.task_defs['BAR'] = 1
print 'B is ==>... | Weird Problem with Classes and Optional Arguments | Okay so this was driving me nuts all day.
Why does this happen:
class Foo:
def __init__(self, bla = {}):
self.task_defs = bla
def __str__(self):
return ''.join(str(self.task_defs))
a = Foo()
b = Foo()
a.task_defs['BAR'] = 1
print 'B is ==> %s' % str(b)
print 'A is ==> %s' % str(a)
Gives me th... | [
"Since you have bla initially set to a mutable type (in this case a dict) in the arguments, it gets shared since bla doesn't get reinitialized to a new dict instance for each instance created for Foo. Here, try this instead:\nclass Foo:\n def __init__(self, bla=None):\n if bla is None:\n bla = ... | [
6
] | [] | [] | [
"python"
] | stackoverflow_0001133309_python.txt |
Q:
Do I test a class that does nothing?
In my application, I have two classes: a logger that actually logs to the database and a dummy logger that does nothing (used when logging is disabled). Here is the entire DummyLog class:
class DummyLog(object):
def insert_master_log(self, spec_name, file_name, data_sourc... | Do I test a class that does nothing? | In my application, I have two classes: a logger that actually logs to the database and a dummy logger that does nothing (used when logging is disabled). Here is the entire DummyLog class:
class DummyLog(object):
def insert_master_log(self, spec_name, file_name, data_source,
environment_n... | [
"If you don't test, how will you really know it does nothing?\n:)\nSorry - couldn't resist. Seriously - I would test because some day it might do more?\n",
"If it can't fail. There is nothing to test.\nTest case results need to contain at least one successful state, and at least one unsuccessful state. If any i... | [
12,
4,
4,
3,
2,
2,
2,
1,
1,
1,
1,
0,
0,
0,
0
] | [] | [] | [
"logging",
"polymorphism",
"python",
"testing",
"unit_testing"
] | stackoverflow_0001127626_logging_polymorphism_python_testing_unit_testing.txt |
Q:
Creating a decorator in a class with access to the (current) class itself
Currently, I'm doing it in this fashion:
class Spam(object):
decorated = None
@classmethod
def decorate(cls, funct):
if cls.decorated is None:
cls.decorated = []
cls.decorated.append(funct)
r... | Creating a decorator in a class with access to the (current) class itself | Currently, I'm doing it in this fashion:
class Spam(object):
decorated = None
@classmethod
def decorate(cls, funct):
if cls.decorated is None:
cls.decorated = []
cls.decorated.append(funct)
return funct
class Eggs(Spam):
pass
@Eggs.decorate
def foo():
print ... | [
"I figured it out through using metaclasses. Thanks for all who posted. Here is my solution if anybody comes across a similar problem:\nclass SpamMeta(type):\n\n def __new__(cls, name, bases, dct):\n SpamType = type.__new__(cls, name, bases, dct)\n SpamType.decorated = []\n return SpamType\n... | [
1,
0,
0
] | [] | [] | [
"class",
"decorator",
"inheritance",
"python"
] | stackoverflow_0001129821_class_decorator_inheritance_python.txt |
Q:
How can I retrieve last x elements in Django
I am trying to retrieve the latest 5 posts (by post time)
In the views.py, if I try blog_post_list = blogPosts.objects.all()[:5] It retreives the first 5 elements of the blogPosts objects, how can I reverse this to retreive the latest ones?
Cheers
A:
blog_post_list = ... | How can I retrieve last x elements in Django | I am trying to retrieve the latest 5 posts (by post time)
In the views.py, if I try blog_post_list = blogPosts.objects.all()[:5] It retreives the first 5 elements of the blogPosts objects, how can I reverse this to retreive the latest ones?
Cheers
| [
"blog_post_list = blogPosts.objects.all().reverse()[:5]\n# OR\nblog_post_list = blogPosts.objects.all().order_by('-DEFAULT_ORDER_KEY')[:5]\n\nI prefer the first.\n",
"Based on Nick Presta's answer and your comment, try:\nblog_post_list = blogPosts.objects.all().order_by('-pub_date')[:5]\n\n"
] | [
8,
4
] | [] | [] | [
"django",
"list",
"python"
] | stackoverflow_0001133715_django_list_python.txt |
Q:
Speeding up GTK tree view
I'm writing an application for the Maemo platform using pygtk and the rendering speed of the tree view seems to be a problem. Since the application is a media controller I'm using transition animations in the UI. These animations slide the controls into view when moving around the UI. The... | Speeding up GTK tree view | I'm writing an application for the Maemo platform using pygtk and the rendering speed of the tree view seems to be a problem. Since the application is a media controller I'm using transition animations in the UI. These animations slide the controls into view when moving around the UI. The issue with the tree control is... | [
"I never did this myself but you could try to implement the caching yourself. Instead of using the predefined cell renderers, implement your own cell renderer (possibly as a wrapper for the actual one), but cache the pixmaps.\nIn PyGTK, you can use gtk.GenericCellRenderer. In your decorator cell renderer, do the fo... | [
1
] | [] | [] | [
"drawing",
"gtk",
"optimization",
"pygtk",
"python"
] | stackoverflow_0001132512_drawing_gtk_optimization_pygtk_python.txt |
Q:
Simple tray icon application using pygtk
I'm writing a webmail checker in python and I want it to just sit on the tray icon and warn me when there is a new email. Could anyone point me in the right direction as far as the gtk code?
I already coded the bits necessary to check for new email but it's CLI right now.
... | Simple tray icon application using pygtk | I'm writing a webmail checker in python and I want it to just sit on the tray icon and warn me when there is a new email. Could anyone point me in the right direction as far as the gtk code?
I already coded the bits necessary to check for new email but it's CLI right now.
| [
"You'll want to use a gtk.StatusIcon to actually display the icon. Here are the docs. If you're just getting started with gui programming you might want to work though a bit of the pygtk tutorial.\n",
"This http://www.pygtk.org/docs/pygtk/class-gtkstatusicon.html should get you going.\n"
] | [
6,
3
] | [] | [] | [
"pygtk",
"python",
"tray",
"trayicon"
] | stackoverflow_0001134749_pygtk_python_tray_trayicon.txt |
Q:
Adding tuples to produce a tuple with a subtotal per 'column'
What is the most pythonic way of adding the values of two or more tuples to produce a total for each 'column'?
Eg:
>>> a = (10, 20)
>>> b = (40, 50)
>>> c = (1, 3)
>>> ???
(51, 73)
I've so far considered the following:
def sumtuples(*tuples):
retur... | Adding tuples to produce a tuple with a subtotal per 'column' | What is the most pythonic way of adding the values of two or more tuples to produce a total for each 'column'?
Eg:
>>> a = (10, 20)
>>> b = (40, 50)
>>> c = (1, 3)
>>> ???
(51, 73)
I've so far considered the following:
def sumtuples(*tuples):
return (sum(v1 for v1,_ in tuples), sum(v2 for _,v2 in tuples))
>>> pri... | [
"I guess you could use reduce, though it's debatable whether that's pythonic ..\nIn [13]: reduce(lambda s, t: (s[0]+t[0], s[1]+t[1]), [a, b, c], (0, 0))\nOut[13]: (51, 73)\n\nHere's another way using map and zip:\nIn [14]: map(sum, zip(a, b, c))\nOut[14]: [51, 73]\n\nor, if you're passing your collection of tuples ... | [
6,
2,
1,
0,
0
] | [] | [] | [
"python",
"tuples"
] | stackoverflow_0001133286_python_tuples.txt |
Q:
Python processes stops responding to SIGTERM / SIGINT after being restarted
I'm having a weird problem with some python processes running using a watchdog process.
The watchdog process is written in python and is the parent, and has a function called start_child(name) which uses subprocess.Popen to open the child ... | Python processes stops responding to SIGTERM / SIGINT after being restarted | I'm having a weird problem with some python processes running using a watchdog process.
The watchdog process is written in python and is the parent, and has a function called start_child(name) which uses subprocess.Popen to open the child process. The Popen object is recorded so that the watchdog can monitor the proces... | [
"As explained here: http://blogs.gentoo.org/agaffney/2005/03/18/python_sucks , when Python creates a new thread, it blocks all signals for that thread (and for any processes that thread spawns).\nI fixed this using sigprocmask, called through ctypes. This may or may not be the \"correct\" way to do it, but it does ... | [
5
] | [
"Wouldn't it be better to restore the default signal handlers within Python rather than via ctypes? In your child process, use the signal module:\nimport signal\nfor sig in range(1, signal.NSIG):\n try:\n signal.signal(sig, signal.SIG_DFL)\n except RuntimeError:\n pass\n\nRuntimeError is raised ... | [
-1
] | [
"freebsd",
"ipc",
"python"
] | stackoverflow_0001133693_freebsd_ipc_python.txt |
Q:
Encryption with Python
I'm making an encryption function in Python and I want to encrypt a random number using a public key.
I wish to know that if I use Crypto package (Crypto.publicKey.pubkey) than how can I use the method like...
def encrypt(self,plaintext,k)
Here the k is itself a random number, is this mean ... | Encryption with Python | I'm making an encryption function in Python and I want to encrypt a random number using a public key.
I wish to know that if I use Crypto package (Crypto.publicKey.pubkey) than how can I use the method like...
def encrypt(self,plaintext,k)
Here the k is itself a random number, is this mean the key. Can somebody help m... | [
"Are you trying to encrypt a session/message key for symmetric encryption using the public key of the recipient? It might be more straightforward to use, say, SSH or TLS in those cases.\nBack to your question:\nMe Too Crypto (M2Crypto) is a nice wrapper around openssl.\nFirst, you need to get the public key of the... | [
4,
3,
0
] | [] | [] | [
"cryptography",
"encryption",
"python"
] | stackoverflow_0001130687_cryptography_encryption_python.txt |
Q:
When should I use varargs in designing a Python API?
Is there a good rule of thumb as to when you should prefer varargs function signatures in your API over passing an iterable to a function? ("varargs" being short for "variadic" or "variable-number-of-arguments"; i.e. *args)
For example, os.path.join has a vararg... | When should I use varargs in designing a Python API? | Is there a good rule of thumb as to when you should prefer varargs function signatures in your API over passing an iterable to a function? ("varargs" being short for "variadic" or "variable-number-of-arguments"; i.e. *args)
For example, os.path.join has a vararg signature:
os.path.join(first_component, *rest) -> str
W... | [
"Consider using varargs when you expect your users to specify the list of arguments as code at the callsite or having a single value is the common case. When you expect your users to get the arguments from somewhere else, don't use varargs. When in doubt, err on the side of not using varargs.\nUsing your examples, ... | [
8,
4,
0,
0
] | [] | [] | [
"api",
"python",
"variadic_functions"
] | stackoverflow_0001136673_api_python_variadic_functions.txt |
Q:
Problem compiling MySQLdb for Python 2.6 on Win32
I'm using Django and Python 2.6, and I want to grow my application using a MySQL backend. Problem is that there isn't a win32 package for MySQLdb on Python 2.6.
Now I'm no hacker, but I thought I might compile it myself using MSVC++9 Express. But I run into a pro... | Problem compiling MySQLdb for Python 2.6 on Win32 | I'm using Django and Python 2.6, and I want to grow my application using a MySQL backend. Problem is that there isn't a win32 package for MySQLdb on Python 2.6.
Now I'm no hacker, but I thought I might compile it myself using MSVC++9 Express. But I run into a problem that the compiler quickly can't find config_win.h,... | [
"Thanks all! I found that I hadn't installed the developer components in MySQL. Once that was done the problem was solved and I easily compiled the MySQLdb for Python 2.6.\nI've made the package available at my site.\n",
"I think that the header files are shipped with MySQL, just make sure you check the appropr... | [
9,
3,
1,
1
] | [] | [] | [
"mysql",
"python",
"winapi"
] | stackoverflow_0000316484_mysql_python_winapi.txt |
Q:
Using python scripts in subversion hooks on windows
My main goal is to get this up and running.
My hook gets called when I do the commit with Tortoise SVN, but it always exits when I get to this line: Python "%~dp0trac-post-commit-hook.py" -p "%TRAC_ENV%" -r "%REV%" || EXIT 5
If I try and replace the call to the p... | Using python scripts in subversion hooks on windows | My main goal is to get this up and running.
My hook gets called when I do the commit with Tortoise SVN, but it always exits when I get to this line: Python "%~dp0trac-post-commit-hook.py" -p "%TRAC_ENV%" -r "%REV%" || EXIT 5
If I try and replace the call to the python script with any simple Python script it still doesn... | [
"Take the following things into account:\n\nnetwork drive mappings and subst\nmappings are user specific. Make sure\nthe drives exist for the user account\nunder which the svn server is\nrunning.\nsubversion hook scripts are run\nwithout any environment variables\nbeing set for security reasons, not even %path%. Ca... | [
3
] | [] | [] | [
"hook",
"python",
"svn",
"svn_hooks",
"windows"
] | stackoverflow_0001135499_hook_python_svn_svn_hooks_windows.txt |
Q:
Execution of script using Popen fails
I need to execute a script in the background through a service.
The service kicks off the script using Popen.
p = Popen('/path/to/script/script.py', shell=True)
Why doesn't the following script work when I include the file writes in the for loop?
#!/usr/bin/python
import os
... | Execution of script using Popen fails | I need to execute a script in the background through a service.
The service kicks off the script using Popen.
p = Popen('/path/to/script/script.py', shell=True)
Why doesn't the following script work when I include the file writes in the for loop?
#!/usr/bin/python
import os
import time
def run():
fd = open('/hom... | [
"Here's your bug:\nfor x in (1,2,3,4,5):\n fd.write(x + '\\n')\n\nYou cannot sum an int to a string. Use instead (e.g.)\nfor x in (1,2,3,4,5):\n fd.write('%s\\n' % x)\n\n",
"What error are you getting? It's hard to see the problem without the error. Is there anyway that the file is opened somewhere else?... | [
1,
0
] | [] | [] | [
"mod_python",
"popen",
"python"
] | stackoverflow_0001138111_mod_python_popen_python.txt |
Q:
Get first non-empty string from a list in python
In Python I have a list of strings, some of which may be the empty string. What's the best way to get the first non-empty string?
A:
next(s for s in list_of_string if s)
Edit: py3k proof version as advised by Stephan202 in comments, thanks.
A:
To remove all em... | Get first non-empty string from a list in python | In Python I have a list of strings, some of which may be the empty string. What's the best way to get the first non-empty string?
| [
"next(s for s in list_of_string if s)\n\nEdit: py3k proof version as advised by Stephan202 in comments, thanks. \n",
"To remove all empty strings,\n[s for s in list_of_strings if s]\nTo get the first non-empty string, simply create this list and get the first element, or use the lazy method as suggested by wuub.\... | [
28,
6,
4,
3,
1,
0
] | [] | [] | [
"list",
"python",
"string"
] | stackoverflow_0001138024_list_python_string.txt |
Q:
Tired of ASP.NET, which of the following should I learn and why?
Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why
Clojure/Compojure+Ring/Moustache+Ring
Groovy/Grails
Python/Django
Ruby/Rails
Turbogear
Cappuccino or Sproutco... | Tired of ASP.NET, which of the following should I learn and why? | Which of the following technology is easy to learn and fun for developing a website? If you could only pick one which would it be and why
Clojure/Compojure+Ring/Moustache+Ring
Groovy/Grails
Python/Django
Ruby/Rails
Turbogear
Cappuccino or Sproutcore
Javascript/jQuery
| [
"Have you considered turning off the computer and going outside instead?\nRemember to wear pants!\n",
"Have you tried ASP.NET MVC? It is actually very different to ASP.NET (vanilla), but retains your knowledge of the .NET framework. Most people wouldn't look back...\nWith the view based on your html (rather than ... | [
31,
30,
12,
10,
9,
8,
6,
5,
4,
4,
4,
3,
1,
1,
1,
1,
0,
0
] | [] | [] | [
"asp.net_mvc",
"clojure",
"groovy",
"python",
"ruby"
] | stackoverflow_0000656987_asp.net_mvc_clojure_groovy_python_ruby.txt |
Q:
Regex in python
I'm trying to use regular expression right now and I'm really confuse. I want to make some validation with this regular expression :
^[A-Za-z0-9_.][A-Za-z0-9_ ]*
I want to make it so there is a limit of character (32) and I want to "match" all the string.
ex:
string : ".hello hello"
-this should ... | Regex in python | I'm trying to use regular expression right now and I'm really confuse. I want to make some validation with this regular expression :
^[A-Za-z0-9_.][A-Za-z0-9_ ]*
I want to make it so there is a limit of character (32) and I want to "match" all the string.
ex:
string : ".hello hello"
-this should work
string : ".hello... | [
"this?\n^[A-Za-z0-9_.][A-Za-z0-9_ ]{0,31}$\n\n",
"From 0 to 32 chars: \n\n^[\\w\\d_.]{0,32}$ \n\n"
] | [
2,
0
] | [] | [] | [
"python",
"regex",
"validation"
] | stackoverflow_0001138747_python_regex_validation.txt |
Q:
psycopg2 on OSX: do I have to install PostgreSQL too?
I want to access a postgreSQL database that's running on a remote machine, from Python in OS/X. Do I have to install postgres on the mac as well? Or will psycopg2 work on its own.
Any hints for a good installation guide for psycopg2 for os/x?
A:
macports te... | psycopg2 on OSX: do I have to install PostgreSQL too? | I want to access a postgreSQL database that's running on a remote machine, from Python in OS/X. Do I have to install postgres on the mac as well? Or will psycopg2 work on its own.
Any hints for a good installation guide for psycopg2 for os/x?
| [
"macports tells me that the psycopg2 package has a dependency on the postgres client and libraries (but not the db server). If you successfully installed psycopg, then you should be good to go.\nIf you haven't installed yet, consider using macports or fink to deal with dependency resolution for you. In most cases, ... | [
3,
1,
1
] | [] | [] | [
"macos",
"postgresql",
"python"
] | stackoverflow_0001052957_macos_postgresql_python.txt |
Q:
How do I receive SNMP traps on OS X?
I need to receive and parse some SNMP traps (messages) and I would appreciate any advice on getting the code I have working on my OS X machine. I have been given some Java code that runs on Windows with net-snmp. I'd like to either get the Java code running on my development ma... | How do I receive SNMP traps on OS X? | I need to receive and parse some SNMP traps (messages) and I would appreciate any advice on getting the code I have working on my OS X machine. I have been given some Java code that runs on Windows with net-snmp. I'd like to either get the Java code running on my development machine or whip up some Python code to do th... | [
"The standard port number for SNMP traps is 162. \nIs there a reason you're specifying a different port number ? You can normally change the port number that traps are sent on/received on, but obviously both ends have to agree. So I'm wondering if this is your problem.\n",
"Ok, the solution to get my code working... | [
0,
0
] | [] | [] | [
"java",
"macos",
"python",
"snmp",
"sockets"
] | stackoverflow_0001135981_java_macos_python_snmp_sockets.txt |
Q:
Detecting Retweets using computationally inexpensive Python hashing algorithms
In order to be able to detect RT of a particular tweet, I plan to store hashes of each formatted tweet in the database.
What hashing algorithm should I use. Cryptic is of course not essential. Just a minimal way of storing a data as som... | Detecting Retweets using computationally inexpensive Python hashing algorithms | In order to be able to detect RT of a particular tweet, I plan to store hashes of each formatted tweet in the database.
What hashing algorithm should I use. Cryptic is of course not essential. Just a minimal way of storing a data as something which can then be compared if it is the same, in an efficient way.
My first a... | [
"Do you really need to hash at all? Twitter messages are short enough (and disk space cheap enough) that it may be better to just store the whole message, rather than eating up clock cycles to hash it.\n",
"I am not familiar with Python (sorry, Ruby guy typing here) however you could try a few things. \nAssumpti... | [
6,
4,
2,
2,
1,
0,
0
] | [] | [] | [
"hash",
"md5",
"python",
"twitter"
] | stackoverflow_0000815313_hash_md5_python_twitter.txt |
Q:
Python RSA Decryption Using OpenSSL Generated Keys
Does anyone know the simplest way to import an OpenSSL RSA private/public key (using a passphrase) with a Python library and use it to decrypt a message.
I've taken a look at ezPyCrypto, but can't seem to get it to recognise an OpenSSL RSA key, I've tried importi... | Python RSA Decryption Using OpenSSL Generated Keys | Does anyone know the simplest way to import an OpenSSL RSA private/public key (using a passphrase) with a Python library and use it to decrypt a message.
I've taken a look at ezPyCrypto, but can't seem to get it to recognise an OpenSSL RSA key, I've tried importing a key with importKey as follows:
key.importKey(myKey,... | [
"The first error is telling you that importKey needs to be called on an instance of key.\nk = key()\nk.importKey(myKey, passphrase='PASSPHRASE')\n\nHowever, the documentation seems to suggest that this is a better way of doing what you want:\nk = key(keyobj=myKey, passphrase='PASSPHRASE')\n\n",
"It is not clear w... | [
6,
5
] | [] | [] | [
"encryption",
"openssl",
"python",
"rsa"
] | stackoverflow_0001139622_encryption_openssl_python_rsa.txt |
Q:
Python inheritance and calling parent class constructor
This is what I'm trying to do in Python:
class BaseClass:
def __init__(self):
print 'The base class constructor ran!'
self.__test = 42
class ChildClass(BaseClass):
def __init__(self):
print 'The child class constructor ran!'... | Python inheritance and calling parent class constructor | This is what I'm trying to do in Python:
class BaseClass:
def __init__(self):
print 'The base class constructor ran!'
self.__test = 42
class ChildClass(BaseClass):
def __init__(self):
print 'The child class constructor ran!'
BaseClass.__init__(self)
def doSomething(self):... | [
"From python documentation:\n\nPrivate name mangling: When an identifier that textually occurs in a class definition begins with two or more underscore characters and does not end in two or more underscores, it is considered a private name of that class. Private names are transformed to a longer form before code is... | [
20,
5,
3
] | [] | [] | [
"oop",
"python"
] | stackoverflow_0001139828_oop_python.txt |
Q:
Python fails to execute firefox webbrowser from a root executed script with privileges drop
I can't run firefox from a sudoed python script that drops privileges to normal user. If i write
$ sudo python
>>> import os
>>> import pwd, grp
>>> uid = pwd.getpwnam('norby')[2]
>>> gid = grp.getgrnam('norby')[2]
>>> os.... | Python fails to execute firefox webbrowser from a root executed script with privileges drop | I can't run firefox from a sudoed python script that drops privileges to normal user. If i write
$ sudo python
>>> import os
>>> import pwd, grp
>>> uid = pwd.getpwnam('norby')[2]
>>> gid = grp.getgrnam('norby')[2]
>>> os.setegid(gid)
>>> os.seteuid(uid)
>>> import webbrowser
>>> webbrowser.get('firefox').open('www.go... | [
"This could be your environment. Changing the permissions will still leave environment variables like $HOME pointing at the root user's directory, which will be inaccessible. It may be worth trying altering these variables by changing os.environ before launching the browser. There may also be other variables wor... | [
1
] | [] | [] | [
"browser",
"debian",
"python",
"uid"
] | stackoverflow_0001139835_browser_debian_python_uid.txt |
Q:
Using Python to Automate Creation/Manipulation of Excel Spreadsheets
I have some data in CSV format that I want to pull into an Excel spreadsheet and then create some standard set of graphs for. Since the data is originally generated in a Python app, I was hoping to simply extend the app so that it could do all th... | Using Python to Automate Creation/Manipulation of Excel Spreadsheets | I have some data in CSV format that I want to pull into an Excel spreadsheet and then create some standard set of graphs for. Since the data is originally generated in a Python app, I was hoping to simply extend the app so that it could do all the post processing and I wouldn't have to do it by hand. Is there an easy i... | [
"xlutils (and the included packages xlrd and xlwt) should allow your Python program to handily do any creation, reading and manipulation of Excel files you might want!\n",
"On Windows you could use the pywin32 package to create an Excel COM Object and then manipulate it from a script. You need to have an installe... | [
7,
1
] | [] | [] | [
"excel",
"python"
] | stackoverflow_0001140311_excel_python.txt |
Q:
How to produce the i-th combination/permutation without iterating
Given any iterable, for example: "ABCDEF"
Treating it almost like a numeral system as such:
A
B
C
D
E
F
AA
AB
AC
AD
AE
AF
BA
BB
BC
....
FF
AAA
AAB
....
How would I go about finding the ith member in this list? Efficiently, not by counting up throug... | How to produce the i-th combination/permutation without iterating | Given any iterable, for example: "ABCDEF"
Treating it almost like a numeral system as such:
A
B
C
D
E
F
AA
AB
AC
AD
AE
AF
BA
BB
BC
....
FF
AAA
AAB
....
How would I go about finding the ith member in this list? Efficiently, not by counting up through all of them. I want to find the billionth (for example) member in th... | [
"Third time's the charm:\ndef perm(i, seq):\n seq = tuple(seq)\n n = len(seq)\n max = n # number of perms with 'digits' digits\n digits = 1\n last_max = 0\n while i >= max:\n last_max = max\n max = n * (max + 1)\n digits += 1\n result = ''\n i -= last_max\n while digits:\n digits -= 1\n resu... | [
5,
5,
3,
2,
2,
1,
1,
0
] | [] | [] | [
"combinatorics",
"python"
] | stackoverflow_0001129704_combinatorics_python.txt |
Q:
Jython or JRuby?
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know ... | Jython or JRuby? | It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was won... | [
"In both cases, most of the code should Just Work™. I don't know of a really compelling reason to choose Jython over JRuby or vice versa if you'll be learning either from scratch. Python places a heavy emphasis on readability and not using \"magic\", but Ruby tends to give you a little more rope to do fancy things,... | [
5,
2,
1,
1,
1
] | [] | [] | [
"jruby",
"jython",
"python",
"ruby"
] | stackoverflow_0001130697_jruby_jython_python_ruby.txt |
Q:
Add local variable to running generator
Lately, I tried to set local variables from outside of a running generator. The generator code also should access these variables.
One trouble was, that when accessing the variables, it seamed that the interpreter was thinking it must be a global since the variable was not s... | Add local variable to running generator | Lately, I tried to set local variables from outside of a running generator. The generator code also should access these variables.
One trouble was, that when accessing the variables, it seamed that the interpreter was thinking it must be a global since the variable was not set in the local scope. But I don't wanted to ... | [
"What you may be looking for, is the send method, which allows a value to be sent into a generator. The reference provides an example:\n>>> def echo(value=None):\n... print \"Execution starts when 'next()' is called for the first time.\"\n... try:\n... while True:\n... try:\n... ... | [
5,
1,
1
] | [] | [] | [
"generator",
"local",
"python",
"variables"
] | stackoverflow_0001140665_generator_local_python_variables.txt |
Q:
Why was the 'thread' module renamed to '_thread' in Python 3.x?
Python 3.x renamed the low-level module 'thread' to '_thread' -- I don't see why in the documentation. Does anyone know?
A:
It's been quite a long time since the low-level thread module was informally deprecated, with all users heartily encouraged t... | Why was the 'thread' module renamed to '_thread' in Python 3.x? | Python 3.x renamed the low-level module 'thread' to '_thread' -- I don't see why in the documentation. Does anyone know?
| [
"It's been quite a long time since the low-level thread module was informally deprecated, with all users heartily encouraged to use the higher-level threading module instead; now with the ability to introduce backwards incompatibilities in Python 3, we've made that deprecation rather more than just \"informal\", th... | [
10,
9,
7
] | [] | [] | [
"multithreading",
"python",
"python_3.x"
] | stackoverflow_0001141047_multithreading_python_python_3.x.txt |
Q:
Count lines of code in a Django Project
Is there an easy way to count the lines of code you have written for your django project?
Edit: The shell stuff is cool, but how about on Windows?
A:
Yep:
shell]$ find /my/source -name "*.py" -type f -exec cat {} + | wc -l
Job's a good 'un.
A:
You might want to look at... | Count lines of code in a Django Project | Is there an easy way to count the lines of code you have written for your django project?
Edit: The shell stuff is cool, but how about on Windows?
| [
"Yep:\nshell]$ find /my/source -name \"*.py\" -type f -exec cat {} + | wc -l\n\nJob's a good 'un.\n",
"You might want to look at CLOC -- it's not Django specific but it supports Python. It can show you lines counts for actual code, comments, blank lines, etc.\n",
"Starting with Aiden's answer, and with a bit o... | [
19,
8,
4,
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001133391_django_python.txt |
Q:
Traversing a Python object tree
I'm trying to implement dynamic reloading objects in Python, that reflect code changes live.
Modules reloading is working, but I have to recreate every instance of the modules' classes for changes to become effective.
The problem is that objects data (objects __dict__ content) is lo... | Traversing a Python object tree | I'm trying to implement dynamic reloading objects in Python, that reflect code changes live.
Modules reloading is working, but I have to recreate every instance of the modules' classes for changes to become effective.
The problem is that objects data (objects __dict__ content) is lost during the process.
So I tried ano... | [
"See this recipe in the Python Cookbook (or maybe even better its version in the \"printed\" one, which I believe you can actually read for free with google book search, or for sure on O'Reilly's \"Safari\" site using a free 1-week trial subscription -- I did a lot of editing on Hudson's original recipe to get the ... | [
1
] | [] | [] | [
"python",
"reload",
"traversal"
] | stackoverflow_0001141039_python_reload_traversal.txt |
Q:
How can I get the string result of a python method from the XML-RPC client in Java
I wrote:
Object result = (Object)client.execute("method",params);
in java client.
Actually, the result should be printed in string format. But I can only output the address of "Object result", how can I get the content?
And I have ... | How can I get the string result of a python method from the XML-RPC client in Java | I wrote:
Object result = (Object)client.execute("method",params);
in java client.
Actually, the result should be printed in string format. But I can only output the address of "Object result", how can I get the content?
And I have tried String result = (String)client.execute("method",params);
It says lang.until.Object... | [
"I'm hesitant to post this because it seems rather obvious - forgive me if you've tried this, but how about:\nString result = (String)client.execute(\"method\",params);\n\n",
"so maybe the object returned is not a string... are you sure that you're returning a string in your python application? I seriously doubt ... | [
0,
0
] | [] | [] | [
"java",
"python",
"xml_rpc"
] | stackoverflow_0001140752_java_python_xml_rpc.txt |
Q:
Google App engine template unicode decoding problem
When trying to render a Django template file in Google App Engine
from google.appengine.ext.webapp import template
templatepath = os.path.join(os.path.dirname(file), 'template.html')
self.response.out.write (template.render( templatepath , template_values))
I c... | Google App engine template unicode decoding problem | When trying to render a Django template file in Google App Engine
from google.appengine.ext.webapp import template
templatepath = os.path.join(os.path.dirname(file), 'template.html')
self.response.out.write (template.render( templatepath , template_values))
I come across the following error:
<type
'exceptions.Unico... | [
"Well, turns out the rendered results returned by the template needs to be decoded first:\n\nself.response.out.write (template.render( templatepath , template_values).decode('utf-8') )\n\nA silly mistake, but thanks for everyone's answers anyway. :)\n",
"Are you using Django 0.96 or Django 1.0? You can check by l... | [
6,
2,
1
] | [] | [] | [
"django",
"google_app_engine",
"python",
"unicode"
] | stackoverflow_0001139151_django_google_app_engine_python_unicode.txt |
Q:
Alternative XML parser for ElementTree to ease UTF-8 woes?
I am parsing some XML with the elementtree.parse() function. It works, except for some utf-8 characters(single byte character above 128). I see that the default parser is XMLTreeBuilder which is based on expat.
Is there an alternative parser that I can u... | Alternative XML parser for ElementTree to ease UTF-8 woes? | I am parsing some XML with the elementtree.parse() function. It works, except for some utf-8 characters(single byte character above 128). I see that the default parser is XMLTreeBuilder which is based on expat.
Is there an alternative parser that I can use that may be less strict and allow utf-8 characters?
This is t... | [
"I'll start from the question: \"Is there an alternative parser that I can use that may be less strict and allow utf-8 characters?\"\nAll XML parsers will accept data encoded in UTF-8. In fact, UTF-8 is the default encoding.\nAn XML document may start with a declaration like this:\n`<?xml version=\"1.0\" encoding=\... | [
15,
4,
1,
1
] | [] | [] | [
"elementtree",
"python",
"utf_8",
"xml"
] | stackoverflow_0001139090_elementtree_python_utf_8_xml.txt |
Q:
How to get repository for core-plot
I am not able to get the repository for core-plot. What I am doing is that I am typing this in the terminal:
hg clone https://core-plot.googlecode.com/hg/ core-plot
and this is what I get:
Traceback (most recent call last):
File "/usr/local/bin/hg", line 25, in
mercurial.uti... | How to get repository for core-plot | I am not able to get the repository for core-plot. What I am doing is that I am typing this in the terminal:
hg clone https://core-plot.googlecode.com/hg/ core-plot
and this is what I get:
Traceback (most recent call last):
File "/usr/local/bin/hg", line 25, in
mercurial.util.set_binary(fp)
File "/Library/Python/2... | [
"Have you installed Mercurial on your computer? If not, you can download an installer here: http://mercurial.berkwood.com/\n",
"It looks like you're having a problem with your locale. Are you using Leopard? If so, check your Terminal preferences. In the Terminal prefs, open up the Settings pane, and click the Ad... | [
1,
1,
0,
0,
0
] | [] | [] | [
"core_plot",
"macos",
"mercurial",
"python",
"terminal"
] | stackoverflow_0001097711_core_plot_macos_mercurial_python_terminal.txt |
Q:
encryption with python
If I want to use:
recip = M2Crypto.RSA.load_pub_key(open('recipient_public_key.pem','rb').read())
Then how will it retrieve the key? What will recip will print?
I need to get the public key of the recipient from the server(open key server) and for that first I need to store the key on serve... | encryption with python | If I want to use:
recip = M2Crypto.RSA.load_pub_key(open('recipient_public_key.pem','rb').read())
Then how will it retrieve the key? What will recip will print?
I need to get the public key of the recipient from the server(open key server) and for that first I need to store the key on server.
| [
"check what public_key.pem returns .clear this how you want to recognize your recipient .\n"
] | [
0
] | [] | [] | [
"cryptography",
"python",
"rsa"
] | stackoverflow_0001141542_cryptography_python_rsa.txt |
Q:
How to hide a bulletpoint in blog
how to hide a bullet points? example like this website
http://www.grainge.org/pages/various_rh_projects/alt_dropdowns/showhide_3/showhide3.htm
you can see the example
first Hotspot
second hotspot
if we click 'first' it appears but if not it's not appear. how to do that
A:
This... | How to hide a bulletpoint in blog | how to hide a bullet points? example like this website
http://www.grainge.org/pages/various_rh_projects/alt_dropdowns/showhide_3/showhide3.htm
you can see the example
first Hotspot
second hotspot
if we click 'first' it appears but if not it's not appear. how to do that
| [
"This is done in JavaScript, not python, I would wager.\nBasic strategy:\n\nStart by adding (in the HTML) class=\"hideme\" to the div's or p's or li's you want to affect. \nThen using something like the below hideClass(class) function (jQuery would be worth looking at too), select all parts of the page with class=\... | [
1,
1,
0
] | [] | [] | [
"css",
"html",
"javascript",
"jquery",
"python"
] | stackoverflow_0001141774_css_html_javascript_jquery_python.txt |
Q:
MySQL db problem in Python
For me mysql db has been successfully instaled in my system.I verified through the following code that it is successfully installed without any errors.
C:\Python26>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "cred... | MySQL db problem in Python | For me mysql db has been successfully instaled in my system.I verified through the following code that it is successfully installed without any errors.
C:\Python26>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more infor... | [
"1) Try using your package manager to download python-mysql which includes MySQLdb.\n2) Ensure /usr/lib/python2.4/site-packages/ is in your PYTHONPATH, e.g.:\n>>> import sys\n>>> from pprint import pprint\n>>> pprint(sys.path)\n['',\n '/usr/lib/python2.4',\n '/usr/lib/python2.4/plat-linux2',\n '/usr/lib/python2.4/l... | [
2,
0
] | [] | [] | [
"mysql",
"python"
] | stackoverflow_0001141790_mysql_python.txt |
Q:
Problem executing with Python+MySQL
I am not getting the reason why my python script is not working though I hv put all the things correctly as my knowledge.The below test I did and it worked fine.But when I import the MySQLdb in my script it gives error as no module name MySQLdb.
**C:\Python26>python
Python 2.6.1... | Problem executing with Python+MySQL | I am not getting the reason why my python script is not working though I hv put all the things correctly as my knowledge.The below test I did and it worked fine.But when I import the MySQLdb in my script it gives error as no module name MySQLdb.
**C:\Python26>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC... | [
"seems like the path is not set properly.\n"
] | [
0
] | [] | [] | [
"mysql",
"python"
] | stackoverflow_0001142098_mysql_python.txt |
Q:
Python networking library for a simple card game
I'm trying to implement a fairly simple card game in Python so that two players can play together other the Internet. I have no problem with doing the GUI, but I don't know the first thing about how to do the networking part. A couple libraries I've found so far:
P... | Python networking library for a simple card game | I'm trying to implement a fairly simple card game in Python so that two players can play together other the Internet. I have no problem with doing the GUI, but I don't know the first thing about how to do the networking part. A couple libraries I've found so far:
PyRO: seems nice and seems to fit the problem nicely by... | [
"Both of those libraries are very good and would work perfectly for your card game.\nPyro might be easier to learn and use, but Twisted will scale better if you ever want to move into a very large number of players.\nTwisted can be daunting at first but there are some books to help you get over the hump.\nThe are s... | [
8,
5,
3
] | [] | [] | [
"networking",
"python"
] | stackoverflow_0001141130_networking_python.txt |
Q:
Convert HTML to Django Fixture (JSON)
We've got a couple of Django flatpages in our project, that are based on actual HTML files. These files undergo some changes once in a while and hence have to updated in the database. So I came up with the idea of simply copying the plain HTML text into a JSON fixture and do a... | Convert HTML to Django Fixture (JSON) | We've got a couple of Django flatpages in our project, that are based on actual HTML files. These files undergo some changes once in a while and hence have to updated in the database. So I came up with the idea of simply copying the plain HTML text into a JSON fixture and do an manage.py loaddata.
However, the problem ... | [
"You could write your own manage.py command to read in the HTML file and adding them to the flatpages:\n# Assuming variable html contains the new HTML file,\n#+ and var id the ID of the flatpage.\nfrom django.contrib.flatpages.models import FlatPage\nfp = FlatPage.objects.get (id=id)\nfp.content = html\nfp.save()\... | [
1
] | [] | [] | [
"django",
"json",
"python"
] | stackoverflow_0001142702_django_json_python.txt |
Q:
AttributeError: 'unicode' object has no attribute '_meta'
I am getting this error on "python manage.py migrate contacts".
The error info does not pinpoint problem location.
Here is the error description:
http://dpaste.com/68162/
Hers is a sample model definition:
http://dpaste.com/68173/
Can someone point me to r... | AttributeError: 'unicode' object has no attribute '_meta' | I am getting this error on "python manage.py migrate contacts".
The error info does not pinpoint problem location.
Here is the error description:
http://dpaste.com/68162/
Hers is a sample model definition:
http://dpaste.com/68173/
Can someone point me to right direction???
I got this: http://blog.e-shell.org/66
but ca... | [
"Figured out the problem. There was this line:\nnote = GenericRelation('Comment', object_id_field='object_pk')\n\nin model Company and Person. But Comment class was undefined. I commented the line at both places. It works now.\nThanks for your time.\n"
] | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001142717_django_python.txt |
Q:
Using and Installing Django Custom Field Models
I found a custom field model (JSONField) that I would like to integrate into my Django project.
Where do I actually put the JSONField.py file? -- Would it reside in my Django project or would I put it in something like: /django/db/models/fields/
Since I assume it c... | Using and Installing Django Custom Field Models | I found a custom field model (JSONField) that I would like to integrate into my Django project.
Where do I actually put the JSONField.py file? -- Would it reside in my Django project or would I put it in something like: /django/db/models/fields/
Since I assume it can be done multiple ways, would it then impact how JS... | [
"It's worth remembering that Django is just Python, and so the same rules apply to Django customisations as they would for any other random Python library you might download. To use a bit of code, it has to be in a module somewhere on your Pythonpath, and then you can just to from foo import x. \nI sometimes have a... | [
2,
1,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0001141524_django_django_models_python.txt |
Q:
PyQt: Overriding QGraphicsView.drawItems
I need to customize the drawing process of a QGraphicsView, and so I override the drawItems method like this:
self.graphicsview.drawItems=self.drawer.drawItems
where self.graphicsview is a QGraphicsView, and self.drawer is a custom class with a method drawItems.
In this me... | PyQt: Overriding QGraphicsView.drawItems | I need to customize the drawing process of a QGraphicsView, and so I override the drawItems method like this:
self.graphicsview.drawItems=self.drawer.drawItems
where self.graphicsview is a QGraphicsView, and self.drawer is a custom class with a method drawItems.
In this method I check a few flags to decide how to draw... | [
"There is an exception that occurs when the items are painted, but it is not reported right away. On my system (PyQt 4.5.1, Python 2.6), no exception is reported when I monkey-patch the following method:\ndef drawItems(painter, items, options):\n print len(items)\n for idx, i in enumerate(items):\n pri... | [
3,
1
] | [] | [] | [
"pyqt",
"python"
] | stackoverflow_0001142970_pyqt_python.txt |
Q:
Alternatives to using pack_into() when manipulating a list of bytes?
I'm reading in a binary file into a list and parsing the binary data. I'm using unpack() to extract certain parts of the data as primitive data types, and I want to edit that data and insert it back into the original list of bytes. Using pack_int... | Alternatives to using pack_into() when manipulating a list of bytes? | I'm reading in a binary file into a list and parsing the binary data. I'm using unpack() to extract certain parts of the data as primitive data types, and I want to edit that data and insert it back into the original list of bytes. Using pack_into() would make it easy, except that I'm using Python 2.4, and pack_into() ... | [
"Have you looked at the bitstring module? It's designed to make the construction, parsing and modification of binary data easier than using the struct and array modules directly.\nIt's especially made for working at the bit level, but will work with bytes just as well. It will also work with Python 2.4.\nfrom bitst... | [
4,
1
] | [] | [] | [
"binary",
"python",
"struct"
] | stackoverflow_0001133044_binary_python_struct.txt |
Q:
defining functions in decorator
Why does this not work? How can I make it work? That is, how can I make gu accessible inside my decorated function?
def decorate(f):
def new_f():
def gu():
pass
f()
return new_f
@decorate
def fu():
gu()
fu()
Do I need to add gu to a dicti... | defining functions in decorator | Why does this not work? How can I make it work? That is, how can I make gu accessible inside my decorated function?
def decorate(f):
def new_f():
def gu():
pass
f()
return new_f
@decorate
def fu():
gu()
fu()
Do I need to add gu to a dictionary of defined functions somehow? ... | [
"If you need to pass gu to fu you need to do this explicitly by parameters:\ndef decorate(f):\n def new_f():\n def gu():\n pass\n f(gu)\n return new_f\n\n@decorate\ndef fu(gu):\n gu()\n\nfu()\n\n",
"gu is local to the new_f function, which is local to the decorate function.\n",
... | [
3,
1,
1,
0,
0
] | [] | [] | [
"aop",
"argument_passing",
"decorator",
"python"
] | stackoverflow_0001141902_aop_argument_passing_decorator_python.txt |
Q:
Python @property versus method performance - which one to use?
I have written some code that uses attributes of an object:
class Foo:
def __init__(self):
self.bar = "baz"
myFoo = Foo()
print (myFoo.bar)
Now I want to do some fancy calculation to return bar. I could use @property to make methods act as... | Python @property versus method performance - which one to use? | I have written some code that uses attributes of an object:
class Foo:
def __init__(self):
self.bar = "baz"
myFoo = Foo()
print (myFoo.bar)
Now I want to do some fancy calculation to return bar. I could use @property to make methods act as the attribute bar, or I could refactor my code to use myFoo.bar().
... | [
"If it's logically a property/attribute of the object, I'd say keep it as a property. If it's likely to become parametrised, by which I mean you may want to invoke myFoo.bar(someArgs) then bite the bullet now and make it a method.\nUnder most circumstances, performance is unlikely to be an issue.\n",
"Wondering a... | [
22,
21,
7,
3,
2,
1
] | [] | [] | [
"performance",
"properties",
"python"
] | stackoverflow_0001142133_performance_properties_python.txt |
Q:
How do I convert (or scale) axis values and redefine the tick frequency in matplotlib?
I am displaying a jpg image (I rotate this by 90 degrees, if this is relevant) and of course
the axes display the pixel coordinates. I would like to convert the axis so that instead of displaying the pixel number, it will displa... | How do I convert (or scale) axis values and redefine the tick frequency in matplotlib? | I am displaying a jpg image (I rotate this by 90 degrees, if this is relevant) and of course
the axes display the pixel coordinates. I would like to convert the axis so that instead of displaying the pixel number, it will display my unit of choice - be it radians, degrees, or in my case an astronomical coordinate. I kn... | [
"It looks like you're dealing with the matplotlib.pyplot interface, which means that you'll be able to bypass most of the dealing with artists, axes, and the like. You can control the values and labels of the tick marks by using the matplotlib.pyplot.xticks command, as follows:\ntick_locs = [list of locations wher... | [
38
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0001143848_matplotlib_python.txt |
Q:
How to add a button (Add-in) to Outlook using Python
I'm looking the way to build an AddIn for Outlook with Python that add a button to the toolbar that has a behavior (doesn't matter).
I've searched around and didn't found anything. The only things I've found are backend, no GUI.
thanks!
A:
You could study the... | How to add a button (Add-in) to Outlook using Python | I'm looking the way to build an AddIn for Outlook with Python that add a button to the toolbar that has a behavior (doesn't matter).
I've searched around and didn't found anything. The only things I've found are backend, no GUI.
thanks!
| [
"You could study the source for the SpamBayes outlook addin:\n\nhttp://spambayes.svn.sourceforge.net/viewvc/spambayes/trunk/spambayes/Outlook2000/addin.py?revision=3243&view=markup\n\nwhich used \"Spam\" and \"Not Spam\" buttons. (Search for _AddControl function.)\nGeneral info on the addin here:\n\nhttp://spambay... | [
1
] | [] | [] | [
"outlook",
"python",
"winapi"
] | stackoverflow_0001143798_outlook_python_winapi.txt |
Q:
Hacking JavaScript Array Into JSON With Python
I am fetching a .js file from a remote site that contains data I want to process as JSON using the simplejson library on my Google App Engine site. The .js file looks like this:
var txns = [
{ apples: '100', oranges: '20', type: 'SELL'},
{ apples: '200', ora... | Hacking JavaScript Array Into JSON With Python | I am fetching a .js file from a remote site that contains data I want to process as JSON using the simplejson library on my Google App Engine site. The .js file looks like this:
var txns = [
{ apples: '100', oranges: '20', type: 'SELL'},
{ apples: '200', oranges: '10', type: 'BUY'}]
I have no control over th... | [
"It's not too difficult to write your own little parsor for that using PyParsing.\nimport json\nfrom pyparsing import *\n\ndata = \"\"\"var txns = [\n { apples: '100', oranges: '20', type: 'SELL'}, \n { apples: '200', oranges: '10', type: 'BUY'}]\"\"\"\n\n\ndef js_grammar():\n key = Word(alphas).setResultsNa... | [
5,
4,
0,
0
] | [] | [] | [
"javascript",
"json",
"python"
] | stackoverflow_0001144400_javascript_json_python.txt |
Q:
How to ensure user submit only english text
I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve this? Python o... | How to ensure user submit only english text | I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve this? Python or Javascript way preferred.
| [
"If the content is long enough I would suggest some frequency analysis on the letters. \nBut for a few words I think your best bet is to compare them to an English dictionary and accept the input if half of them match.\n",
"Check the Language Recognition Chart \n",
"I think the most effective way would be to as... | [
7,
6,
5,
5,
3,
3,
1,
0,
0,
0
] | [] | [] | [
"javascript",
"nlp",
"python"
] | stackoverflow_0000196924_javascript_nlp_python.txt |
Q:
Python value unpacking error
I'm building a per-user file browsing/uploading application using Django and when I run this function
def walkdeep(request, path):
path, dirs, files = walktoo('/home/damon/walktemp/%s' % path)
return render_to_response('walk.html', {
'path' : path[0],
'dirs' : ... | Python value unpacking error | I'm building a per-user file browsing/uploading application using Django and when I run this function
def walkdeep(request, path):
path, dirs, files = walktoo('/home/damon/walktemp/%s' % path)
return render_to_response('walk.html', {
'path' : path[0],
'dirs' : path[1],
'files' : path[2]... | [
"path, dirs, files = walktoo('/home/damon/walktemp/%s' % path)\n\nIn this line, you're expecting walktoo to return a tuple of three values, which are then to be unpacked into path, dirs, and files. However, your walktoo function is a generator object: calling walktoo() yields a single value, the generator. You ha... | [
7,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001144953_django_python.txt |
Q:
Looking for values in nested tuple
Say I have:
t = (
('dog', 'Dog'),
('cat', 'Cat'),
('fish', 'Fish'),
)
And I need to check if a value is in the first bit of the nested tuple (ie. the lowercase bits). How can I do this? The capitalised values do not matter really, I want to search for a string in onl... | Looking for values in nested tuple | Say I have:
t = (
('dog', 'Dog'),
('cat', 'Cat'),
('fish', 'Fish'),
)
And I need to check if a value is in the first bit of the nested tuple (ie. the lowercase bits). How can I do this? The capitalised values do not matter really, I want to search for a string in only the lowercase values.
if 'fish' in t:
... | [
"The elements of a tuple can be extracted by specifying an index: ('a', 'b')[0] == 'a'. You can use a list comprehension to iterate over all elements of some iterable. A tuple is also iterable. Lastly, any() tells whether any element in a given iterable evaluates to True. Putting all this together:\n>>> t = (\n... ... | [
10,
5,
3,
2
] | [] | [] | [
"python"
] | stackoverflow_0001144178_python.txt |
Q:
Using URLS that accept slashes as part of the parameter in Django
Is there a way in Django to accept 'n' parameters which are delimited by a '/' (forward slash)?
I was thinking this may work, but it does not. Django still recognizes forward slashes as delimiters.
(r'^(?P<path>[-\w]+/)$', 'some.view', {}),
A:
Add... | Using URLS that accept slashes as part of the parameter in Django | Is there a way in Django to accept 'n' parameters which are delimited by a '/' (forward slash)?
I was thinking this may work, but it does not. Django still recognizes forward slashes as delimiters.
(r'^(?P<path>[-\w]+/)$', 'some.view', {}),
| [
"Add the right url to your urlpatterns:\n# ...\n(\"^foo/(.*)$\", \"foo\"), # or whatever\n# ...\n\nAnd process it in your view, like AlbertoPL said:\nfields = paramPassedInAccordingToThatUrl.split('/')\n\n",
"Certainly, Django can accept any URL which can be described by a regular expression - including one which... | [
3,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001145334_django_python.txt |
Q:
How to make easy_install expand a package into directories rather than a single egg file?
How exactly do I configure my setup.py file so that when someone runs easy_install the package gets expanded into \site-packages\ as a directory, rather than remaining inside an egg.
The issue I'm encountering is that one of ... | How to make easy_install expand a package into directories rather than a single egg file? | How exactly do I configure my setup.py file so that when someone runs easy_install the package gets expanded into \site-packages\ as a directory, rather than remaining inside an egg.
The issue I'm encountering is that one of the django apps I've created won't auto-detect if it resides inside an egg.
EDIT: For example, ... | [
"You add zip_safe = False as an option to setup().\nI don't think it has to do with directories. Setuptools will happily eggify packages with loads of directories in it.\nThen of course it's another problem that this part of Django doesn't find the package even though it's zipped. It should.\n"
] | [
5
] | [] | [] | [
"django",
"easy_install",
"egg",
"python",
"setuptools"
] | stackoverflow_0001145524_django_easy_install_egg_python_setuptools.txt |
Q:
py2exe: Compiled Python Windows Application won't run because of DLL
I will confess I'm very new to Python and I don't really know what I'm doing yet. Recently I created a very small Windows application using Python 2.6.2 and wxPython 2.8. And it works great; I'm quite pleased with how well it works normally. By n... | py2exe: Compiled Python Windows Application won't run because of DLL | I will confess I'm very new to Python and I don't really know what I'm doing yet. Recently I created a very small Windows application using Python 2.6.2 and wxPython 2.8. And it works great; I'm quite pleased with how well it works normally. By normally I mean when I invoke it directly through the Python interpreter, l... | [
"You can't just copy msvcr*.dll - they need to be set up using the rules for side-by-side assemblies. You can do this by installing the redistributable package as Sam points out, or you can put them alongside your executables as long as you obey the rules.\nSee the section \"Deploying Visual C++ library DLLs as pr... | [
8,
2
] | [] | [] | [
"py2exe",
"python",
"wxpython"
] | stackoverflow_0001145662_py2exe_python_wxpython.txt |
Q:
Difference between "inspect" and "interactive" command line flags in Python
What is the difference between "inspect" and "interactive" flags?
The sys.flags function prints both of them.
How can they both have "-i" flag according to the documentation of sys.flags?
How can I set them separately? If I use "python -i"... | Difference between "inspect" and "interactive" command line flags in Python | What is the difference between "inspect" and "interactive" flags?
The sys.flags function prints both of them.
How can they both have "-i" flag according to the documentation of sys.flags?
How can I set them separately? If I use "python -i", both of them will be set
to 1.
Related:
tell whether python is in -i mode
| [
"According to pythonrun.c corresponding Py_InspectFlag and Py_InteractiveFlag are used as follows:\nint Py_InspectFlag; /* Needed to determine whether to exit at SystemError */\n/* snip */\nstatic void\nhandle_system_exit(void)\n{\n PyObject *exception, *value, *tb;\n int exitcode = 0;\n\n if (Py_InspectFl... | [
9,
0
] | [] | [] | [
"command_line",
"interpreter",
"python"
] | stackoverflow_0001145428_command_line_interpreter_python.txt |
Q:
Name this python/ruby language construct (using array values to satisfy function parameters)
What is this language construct called?
In Python I can say:
def a(b,c): return b+c
a(*[4,5])
and get 9. Likewise in Ruby:
def a(b,c) b+c end
a(*[4,5])
What is this called, when one passes a single array to a function wh... | Name this python/ruby language construct (using array values to satisfy function parameters) | What is this language construct called?
In Python I can say:
def a(b,c): return b+c
a(*[4,5])
and get 9. Likewise in Ruby:
def a(b,c) b+c end
a(*[4,5])
What is this called, when one passes a single array to a function which otherwise requires multiple arguments?
What is the name of the * operator?
What other language... | [
"The Python docs call this Unpacking Argument Lists. It's a pretty handy feature. In Python, you can also use a double asterisk (**) to unpack a dictionary (hash) into keyword arguments. They also work in reverse. I can define a function like this:\ndef sum(*args):\n result = 0\n for a in args:\n resul... | [
29,
10,
5,
3,
2,
2,
1
] | [] | [] | [
"language_features",
"python",
"ruby",
"syntax"
] | stackoverflow_0001141504_language_features_python_ruby_syntax.txt |
Q:
XML parsing expat in python handling data
I am attempting to parse an XML file using python expat. I have the following line in my XML file:
<Action><fail/></Action>
expat identifies the start and end tags but converts the & lt; to the less than character and the same for the greater than character and thus... | XML parsing expat in python handling data | I am attempting to parse an XML file using python expat. I have the following line in my XML file:
<Action><fail/></Action>
expat identifies the start and end tags but converts the & lt; to the less than character and the same for the greater than character and thus parses it like this:
outcome:
START 'Action'
D... | [
"expat does not mess up, < is simply the XML encoding for the character <. Quite to the contrary, if expat would return the literal <, this would be a bug with respect to the XML spec. That being said, you can of course get the escaped version back by using xml.sax.saxutils.escape:\n>>> from xml.sax.saxutils ... | [
2,
1
] | [] | [] | [
"expat_parser",
"parsing",
"python",
"xml"
] | stackoverflow_0001145015_expat_parser_parsing_python_xml.txt |
Q:
Trying to import a module that imports another module, getting ImportError
In ajax.py, I have this import statement:
import components.db_init as db
In components/db_init.py, I have this import statement:
# import locals from ORM (Storm)
from storm.locals import *
And in components/storm/locals.py, it has this:
... | Trying to import a module that imports another module, getting ImportError | In ajax.py, I have this import statement:
import components.db_init as db
In components/db_init.py, I have this import statement:
# import locals from ORM (Storm)
from storm.locals import *
And in components/storm/locals.py, it has this:
from storm.properties import Bool, Int, Float, RawStr, Chars, Unicode, Pickle
fr... | [
"I would guess that storm.locals' idea of its package name is different from what you think it is (most likely it thinks it's in components.storm.locals). You can check this by printing __name__ at the top of storm.locals, I believe. If you use imports which aren't relative to the current package, the package names... | [
2,
1
] | [] | [] | [
"import",
"package",
"python",
"relative_path"
] | stackoverflow_0001145794_import_package_python_relative_path.txt |
Q:
IE8 automation and https
I'm trying to use IE8 through COM to access a secured site (namely, SourceForge), in Python. Here is the script:
from win32com.client import gencache
from win32com.client import Dispatch
import pythoncom
gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1)
class Sourc... | IE8 automation and https | I'm trying to use IE8 through COM to access a secured site (namely, SourceForge), in Python. Here is the script:
from win32com.client import gencache
from win32com.client import Dispatch
import pythoncom
gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}', 0, 1, 1)
class SourceForge(object):
def __ini... | [
"I can't open https://sourceforget.net/ -- not by hand, not by script.\nAre you sure this link is right?\n"
] | [
2
] | [] | [] | [
"python",
"winapi",
"windows"
] | stackoverflow_0001147193_python_winapi_windows.txt |
Q:
Does Jython have the GIL?
I was sure that it hasn't, but looking for a definite answer on the Interwebs left me in doubt. For example, I got a 2008 post which sort of looked like a joke at first glance but seemed to be serious at looking closer.
Edit:
... and turned out to be a joke after looking even closer. Sorr... | Does Jython have the GIL? | I was sure that it hasn't, but looking for a definite answer on the Interwebs left me in doubt. For example, I got a 2008 post which sort of looked like a joke at first glance but seemed to be serious at looking closer.
Edit:
... and turned out to be a joke after looking even closer. Sorry for the confusion. Actually t... | [
"The quote you found was indeed a joke, here is a demo of Jython's implementation of the GIL:\nJython 2.5.0 (trunk:6550M, Jul 20 2009, 08:40:15) \n[Java HotSpot(TM) Client VM (Apple Inc.)] on java1.5.0_19\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> from __future__ import GIL... | [
26,
23,
5
] | [
"Google is making a Python implementation that is an modified cpython with performance improvements called unladen swallow. This will take care of removing the GIL.\nSee: Unladen Swallow\n"
] | [
-1
] | [
"jython",
"multithreading",
"python"
] | stackoverflow_0001120354_jython_multithreading_python.txt |
Q:
Connection refused when trying to open, write and close a socket a few times (Python)
I have a program that listens on a port waiting for a small amount of data to tell it what to do. I run 5 instances of that program, one on each port from 5000 to 5004 inclusively.
I have a second program written in Python that c... | Connection refused when trying to open, write and close a socket a few times (Python) | I have a program that listens on a port waiting for a small amount of data to tell it what to do. I run 5 instances of that program, one on each port from 5000 to 5004 inclusively.
I have a second program written in Python that creates a socket "s", writes the data to port 5000, then closes. It then increments the port... | [
"This sounds a lot like the anti-portscan measure of your firewall kicking in.\n",
"I don't know that much about sockets, so this may be really bad style... use at own risk. This code:\n#!/usr/bin/python\nimport threading, time\nfrom socket import *\nportrange = range(10000,10005)\n\nclass Sock(threading.Thread):... | [
1,
1,
0
] | [] | [] | [
"limit",
"max",
"python",
"sockets"
] | stackoverflow_0001145540_limit_max_python_sockets.txt |
Q:
Create instance of a python class , declared in python, with C API
I want to create an instance of a Python class defined in the __main__ scope with the C API.
For example, the class is called MyClass and is defined as follows:
class MyClass:
def __init__(self):
pass
The class type lives under __main_... | Create instance of a python class , declared in python, with C API | I want to create an instance of a Python class defined in the __main__ scope with the C API.
For example, the class is called MyClass and is defined as follows:
class MyClass:
def __init__(self):
pass
The class type lives under __main__ scope.
Within the C application, I want to create an instance of this ... | [
"I believe the simplest approach is:\n/* get sys.modules dict */\nPyObject* sys_mod_dict = PyImport_GetModuleDict();\n/* get the __main__ module object */\nPyObject* main_mod = PyMapping_GetItemString(sys_mod_dict, \"__main__\");\n/* call the class inside the __main__ module */\nPyObject* instance = PyObject_CallMe... | [
20
] | [] | [] | [
"c",
"python",
"python_c_api"
] | stackoverflow_0001147452_c_python_python_c_api.txt |
Q:
Python Xlib catch/send mouseclick
At the moment I'm trying to use Python to detect when the left mouse button is being held and then start to rapidly send this event instead of only once. What I basically want to do is that when the left mouse button is held it clicks and clicks again until you let it go. But I'm ... | Python Xlib catch/send mouseclick | At the moment I'm trying to use Python to detect when the left mouse button is being held and then start to rapidly send this event instead of only once. What I basically want to do is that when the left mouse button is held it clicks and clicks again until you let it go. But I'm a bit puzzled with the whole Xlib, I th... | [
"Actually you want Xlib.X.ButtonPressMask | Xlib.X.ButtonReleaseMask, to get events for button presses and releases (different from key presses and releases). The events are ButtonPress and ButtonRelease, and the detail instance variable gives you the button number. From when you get the press event, to when you ... | [
5
] | [] | [] | [
"click",
"events",
"mouse",
"python",
"xlib"
] | stackoverflow_0001147653_click_events_mouse_python_xlib.txt |
Q:
What is the DRY way to configure different log file locations for different settings?
I am using python's logging module in a django project. I am performing the basic logging configuration in my settings.py file. Something like this:
import logging
import logging.handlers
logger = logging.getLogger('project_lo... | What is the DRY way to configure different log file locations for different settings? | I am using python's logging module in a django project. I am performing the basic logging configuration in my settings.py file. Something like this:
import logging
import logging.handlers
logger = logging.getLogger('project_logger')
logger.setLevel(logging.INFO)
LOG_FILENAME = '/path/to/log/file/in/development/envi... | [
"Why don't you put this statements at the end of settings.py and use the DEBUG flal es indicator for developement?\nSomething like this:\nimport logging \nimport logging.handlers\nlogger = logging.getLogger('project_logger')\nlogger.setLevel(logging.INFO)\n\n[snip]\nif DEBUG:\n LOG_FILENAME = '/path/to/log/fil... | [
1,
1
] | [] | [] | [
"django",
"logging",
"python"
] | stackoverflow_0001147812_django_logging_python.txt |
Q:
Can you suggest any extended examples on object-oriented software design?
I am looking for instructional materials on object-oriented software design that are framed as extended examples. In other words, over the course of several lessons or chapters, the author would develop a moderately large piece of software a... | Can you suggest any extended examples on object-oriented software design? | I am looking for instructional materials on object-oriented software design that are framed as extended examples. In other words, over the course of several lessons or chapters, the author would develop a moderately large piece of software and explain the design approach step by step. Ideally, the material would addres... | [
"Head First Object-Oriented Analysis and Design \n",
"This is indispensable for understanding large scale oo design. In though its implemented in c++ the concepts are completely general and can be used effectively on any platform:\nLarge Scale OO Design\nTruly a classic!!\n"
] | [
3,
2
] | [] | [] | [
"oop",
"perl",
"python",
"ruby"
] | stackoverflow_0001148196_oop_perl_python_ruby.txt |
Q:
Python socket accept blocks - prevents app from quitting
I've written a very simple python class which waits for connections on a socket. The intention is to stick this class into an existing app and asyncronously send data to connecting clients.
The problem is that when waiting on an socket.accept(), I cannot en... | Python socket accept blocks - prevents app from quitting | I've written a very simple python class which waits for connections on a socket. The intention is to stick this class into an existing app and asyncronously send data to connecting clients.
The problem is that when waiting on an socket.accept(), I cannot end my application by pressing ctrl-c. Neither can I detect when... | [
"Add self.setDaemon(True) to the __init__ before self.start().\n(In Python 2.6 and later, self.daemon = True is preferred).\nThe key idea is explained here:\n\nThe entire Python program exits when\n no alive non-daemon threads are left.\n\nSo, you need to make \"daemons\" of those threads who should not keep the w... | [
9,
4
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0001148062_python_sockets.txt |
Q:
How to install Python 3rd party libgmail-0.1.11.tar.tar into Python in Windows XP home?
I do not know Python, I have installed it only and downloaded the libgmail package. So, please give me verbatim steps in installing the libgmail library. My python directory is c:\python26, so please do not skip any steps in th... | How to install Python 3rd party libgmail-0.1.11.tar.tar into Python in Windows XP home? | I do not know Python, I have installed it only and downloaded the libgmail package. So, please give me verbatim steps in installing the libgmail library. My python directory is c:\python26, so please do not skip any steps in the answer.
Thanks!
| [
"The easiest way might be to install easy_install using the instructions at that page and then typing the following at the command line:\neasy_install libgmail\n\nIf it can't be found, then you can point it directly to the file that you downloaded:\neasy_install c:\\biglongpath\\libgmail.zip\n\n",
"Extract the ar... | [
3,
2,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0001147713_python.txt |
Q:
Python threads - crashing when they access postgreSQL
here is a simple threading program which works fine:
import psycopg2
import threading
import time
class testit(threading.Thread):
def __init__(self, currency):
threading.Thread.__init__(self)
self.currency = currency
def run(self):
... | Python threads - crashing when they access postgreSQL | here is a simple threading program which works fine:
import psycopg2
import threading
import time
class testit(threading.Thread):
def __init__(self, currency):
threading.Thread.__init__(self)
self.currency = currency
def run(self):
global SQLConnection
global cursor
SQ... | [
"global SQLConnection\nglobal cursor\n\nSeems you're accessing globals from multiple threads ? You should never do that unless those globals are thread safe, or you provide the proper locking yourself.\nYou now have 2 threads accessing the same connection and the same cursor. They'll step on eachothers toes. psycop... | [
2,
0
] | [] | [] | [
"postgresql",
"python"
] | stackoverflow_0001148671_postgresql_python.txt |
Q:
MetaPython: Adding Methods to a Class
I would like to add some methods to a class definition at runtime. However, when running the following code, I get some surprising (to me) results.
test.py
class klass(object):
pass
for i in [1,2]:
def f(self):
print(i)
setattr(klass, 'f' + str(i), f)
I ... | MetaPython: Adding Methods to a Class | I would like to add some methods to a class definition at runtime. However, when running the following code, I get some surprising (to me) results.
test.py
class klass(object):
pass
for i in [1,2]:
def f(self):
print(i)
setattr(klass, 'f' + str(i), f)
I get the following when testing on the comma... | [
"It's the usual problem of binding -- you want early binding for the use of i inside the function and Python is doing late binding for it. You can force the earlier binding this way:\nclass klass(object):\n pass\n\nfor i in [1,2]:\n def f(self, i=i):\n print(i)\n setattr(klass, 'f' + str(i), f)\n\n... | [
11,
0
] | [] | [] | [
"binding",
"metaprogramming",
"python"
] | stackoverflow_0001148827_binding_metaprogramming_python.txt |
Q:
Using Task Queues to schedule the fetching/parsing of a number of feeds in App Engine (Python)
Say I had over 10,000 feeds that I wanted to periodically fetch/parse.
If the period were say 1h that would be 24x10000 = 240,000 fetches.
The current 10k limit of the labs Task Queue API would preclude one from
setting ... | Using Task Queues to schedule the fetching/parsing of a number of feeds in App Engine (Python) | Say I had over 10,000 feeds that I wanted to periodically fetch/parse.
If the period were say 1h that would be 24x10000 = 240,000 fetches.
The current 10k limit of the labs Task Queue API would preclude one from
setting up one task per fetch. How then would one do this?
Update: RE: Fetching nurls per task - Given the 3... | [
"Here's the asynchronous urlfetch API:\nhttp://code.google.com/appengine/docs/python/urlfetch/asynchronousrequests.html\nSet of a bunch of requests with a reasonable deadline (give yourself some headroom under your timeout, so that if one request times out you still have time to process the others). Then wait on ea... | [
3,
2,
0
] | [] | [] | [
"feed",
"google_app_engine",
"python"
] | stackoverflow_0001148709_feed_google_app_engine_python.txt |
Q:
Difference in SHA512 between python hashlib and sha512sum tool
I am getting different message digests from the linux 'sha512sum' tool and the python hashlib library.
Here is what I get on my Ubuntu 8.10:
$ echo test | sha512sum
0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be1... | Difference in SHA512 between python hashlib and sha512sum tool | I am getting different message digests from the linux 'sha512sum' tool and the python hashlib library.
Here is what I get on my Ubuntu 8.10:
$ echo test | sha512sum
0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123 -
$ python
Python 2.5.2 ... | [
"I think the difference is that echo adds a newline character to its output.\nTry echo -n test | sha512sum\n",
"echo is adding a newline:\n$ python -c 'import hashlib; print hashlib.sha512(\"test\\n\").hexdigest()'\n0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85... | [
20,
11,
2
] | [] | [] | [
"digest",
"hashlib",
"python",
"sha512"
] | stackoverflow_0001147875_digest_hashlib_python_sha512.txt |
Q:
Python xml.dom and bad XML
I'm trying to extract some data from various HTML pages using a python program. Unfortunately, some of these pages contain user-entered data which occasionally has "slight" errors - namely tag mismatching.
Is there a good way to have python's xml.dom try to correct errors or something of... | Python xml.dom and bad XML | I'm trying to extract some data from various HTML pages using a python program. Unfortunately, some of these pages contain user-entered data which occasionally has "slight" errors - namely tag mismatching.
Is there a good way to have python's xml.dom try to correct errors or something of the sort? Alternatively, is the... | [
"You could use HTML Tidy to clean up, or Beautiful Soup to parse. Could be that you have to save the result to a temp file, but it should work.\nCheers,\n",
"I used to use BeautifulSoup for such tasks but now I have shifted to HTML5lib (http://code.google.com/p/html5lib/) which works well in many cases where Beau... | [
3,
0,
0,
0
] | [] | [] | [
"dom",
"expat_parser",
"python",
"xml"
] | stackoverflow_0001147090_dom_expat_parser_python_xml.txt |
Q:
how would i design a db to contain a set of url regexes (python) that could be matched against an incoming url
Say I have the following set of urls in a db
url data
^(.*)google.com/search foobar
^(.*)google.com/alerts barfoo
^(.*)blah.com/foo/(.*) foofoo
... 100's more
Given any url in t... | how would i design a db to contain a set of url regexes (python) that could be matched against an incoming url | Say I have the following set of urls in a db
url data
^(.*)google.com/search foobar
^(.*)google.com/alerts barfoo
^(.*)blah.com/foo/(.*) foofoo
... 100's more
Given any url in the wild, I would like to check to
see if that url belongs to an existing set of urls and get the
corresponding data ... | [
"\n\"2. django does urlresolution by looping through each regex and checking for a match given that there maybe 1000's of urls is this the best way to approach this?\"\n\"3. Are there any existing implementations I can look at?\"\n\nIf running a large number of regular expressions does turn out to be a problem, you... | [
1,
0,
0,
0,
0
] | [] | [] | [
"python",
"regex",
"url_routing"
] | stackoverflow_0001145955_python_regex_url_routing.txt |
Q:
How to resume program (or exit) after opening webbrowser?
I'm making a small Python program, which calls the webbrowser module to open a URL. Opening the URL works wonderfully.
My problem is that once this line of code is reached, the problem is unresponsive. How do I get the program to proceed past this line of c... | How to resume program (or exit) after opening webbrowser? | I'm making a small Python program, which calls the webbrowser module to open a URL. Opening the URL works wonderfully.
My problem is that once this line of code is reached, the problem is unresponsive. How do I get the program to proceed past this line of code and continue to execute? Below the problematic line is the ... | [
"This looks like it depends on which platform you're running on.\n\nMacOSX - returns True immediately and opens up browser window. Presumably your desired behavior.\nLinux (no X) - Open up links textmode browser. Once this is closed, returns True.\nLinux (with X) - Opens up Konquerer (in my case). Returns True i... | [
6,
4,
0
] | [] | [] | [
"browser",
"if_statement",
"python"
] | stackoverflow_0001149233_browser_if_statement_python.txt |
Q:
Signals registered more than once in django1.1 testserver
I've defined a signal handler function in my models.py file. At the bottom of that file, I use signals.post_save.connect(myhandler, sender=myclass) as recommended in the docs at http://docs.djangoproject.com/en/dev/topics/signals/.
However, when I run the t... | Signals registered more than once in django1.1 testserver | I've defined a signal handler function in my models.py file. At the bottom of that file, I use signals.post_save.connect(myhandler, sender=myclass) as recommended in the docs at http://docs.djangoproject.com/en/dev/topics/signals/.
However, when I run the test server, simple print-statement debugging shows that the mod... | [
"The signature for the connect method is \ndef connect(self, receiver, sender=None, weak=True, dispatch_uid=None)\n\nwhere the dispatch_uid parameter is an identifier used to uniquely identify a particular instance of a receiver. This will usually be a string, though it may be anything hashable. If receivers have a... | [
4
] | [] | [] | [
"django",
"django_models",
"django_signals",
"python"
] | stackoverflow_0001149317_django_django_models_django_signals_python.txt |
Q:
How to create Classes in Python with highly constrained instances
In Python, there are examples of built-in classes with highly constrained instances. For example, "None" is the only instance of its class, and in the bool class there are only two objects, "True" and "False" (I hope I am more-or-less correct so ... | How to create Classes in Python with highly constrained instances | In Python, there are examples of built-in classes with highly constrained instances. For example, "None" is the only instance of its class, and in the bool class there are only two objects, "True" and "False" (I hope I am more-or-less correct so far).
Another good example are integers: if a and b are instances o... | [
"You're talking about giving a class value semantics, which is typically done by creating class instances in the normal way, but remembering each one, and if a matching instance would be created, give the already created instance instead. In python, this can be achieved by overloading a classes __new__ method. \n... | [
5,
4,
3,
2,
2,
1,
1
] | [] | [] | [
"class",
"math",
"python"
] | stackoverflow_0001149253_class_math_python.txt |
Q:
How to Redirect To Same Page on Failed Login
The Django framework easily handles redirecting when a user fails to log in properly. However, this redirection goes to a separate login page. I can set the template to be the same as the page I logged in on, but none of my other objects exist in the new page.
For examp... | How to Redirect To Same Page on Failed Login | The Django framework easily handles redirecting when a user fails to log in properly. However, this redirection goes to a separate login page. I can set the template to be the same as the page I logged in on, but none of my other objects exist in the new page.
For example, I have a front page that shows a bunch of news... | [
"Do you want to redirect to the referring page on failed login?\n... authentication code above\n\nif user.is_authenticated():\n #show success view\nelse:\n return HttpResponseRedirect(request.META.get('HTTP_REFERER', reverse('index'))\n\nyou might want to check that referring page url is set correctly, otherw... | [
6,
1,
0
] | [] | [] | [
"authentication",
"django",
"python",
"redirect"
] | stackoverflow_0001129091_authentication_django_python_redirect.txt |
Q:
Attribute Cache in Django - What's the point?
I was just looking over EveryBlock's source code and I noticed this code in the alerts/models.py code:
def _get_user(self):
if not hasattr(self, '_user_cache'):
from ebpub.accounts.models import User
try:
self._user_cache = User.obje... | Attribute Cache in Django - What's the point? | I was just looking over EveryBlock's source code and I noticed this code in the alerts/models.py code:
def _get_user(self):
if not hasattr(self, '_user_cache'):
from ebpub.accounts.models import User
try:
self._user_cache = User.objects.get(id=self.user_id)
except User.DoesNo... | [
"I don't know why this is an IntegerField; it looks like it definitely should be a ForeignKey(User) field--you lose things like select_related() here and other things because of that, too.\nAs to the caching, many databases don't cache results--they (or rather, the OS) will cache the data on disk needed to get the ... | [
4,
3
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0001150368_django_django_models_python.txt |
Q:
cleaning up when using exceptions and files in python
I'm learning python for a couple of days now and am struggling with its 'spirit'.
I'm comming from the C/C++/Java/Perl school and I understand that python is not C (at all) that's why I'm trying to understand the spirit to get the most out of it (and so far it'... | cleaning up when using exceptions and files in python | I'm learning python for a couple of days now and am struggling with its 'spirit'.
I'm comming from the C/C++/Java/Perl school and I understand that python is not C (at all) that's why I'm trying to understand the spirit to get the most out of it (and so far it's hard)...
My question is especially focused on exception h... | [
"The easiest way to deal with this is to use the fact that file objects in Python 2.5+ are context managers. You can use the with statement to enter a context; the context manager's __exit__ method is automatically called when exiting this with scope. The file object's context management automatically closes the fi... | [
6,
3,
1,
0,
0
] | [] | [] | [
"exception",
"file_io",
"python"
] | stackoverflow_0001149983_exception_file_io_python.txt |
Q:
html form submission in python and php is simple, can a novice do it in java?
I've made two versions of a script that submits a (https) web page form and collects the results. One version uses Snoopy.class in php, and the other uses urllib and urllib2 in python. Now I would like to make a java version.
Snoopy make... | html form submission in python and php is simple, can a novice do it in java? | I've made two versions of a script that submits a (https) web page form and collects the results. One version uses Snoopy.class in php, and the other uses urllib and urllib2 in python. Now I would like to make a java version.
Snoopy makes the php version exceedingly easy to write, and it runs fine on my own (OS X) mach... | [
"Use HttpComponents http://hc.apache.org/. You need:\n\nHttpComponents Core, direct download\nHttpComponents Client, direct download\nCommons Logging\n\nExample code:\nimport org.apache.http.message.BasicNameValuePair;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.HttpResponse;\nimport org.apache.h... | [
3,
2,
2,
2
] | [] | [] | [
"http",
"java",
"php",
"python"
] | stackoverflow_0001116921_http_java_php_python.txt |
Q:
Python 2.5 socket._fileobject is what in Python 3.1?
I'm porting some code that runs on Python 2.5 to Python 3.1. A couple of classes subclass the socket._fileobject:
class X(socket._fileobject):
....
Is there an equivalent to socket._fileobject in Python 3.1? A quick scan of the source code doesn't turn up any... | Python 2.5 socket._fileobject is what in Python 3.1? | I'm porting some code that runs on Python 2.5 to Python 3.1. A couple of classes subclass the socket._fileobject:
class X(socket._fileobject):
....
Is there an equivalent to socket._fileobject in Python 3.1? A quick scan of the source code doesn't turn up anything useful. Thanks!
| [
"Python 3 uses SocketIO instead of _fileobject in the makefile() method, so that's probably the way to go. \n"
] | [
1
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0001150653_python_python_3.x.txt |
Q:
Best Technology for a medical 3D Planning Software
I am looking to build a new Interactive 3D planning software similar to this one http://www.materialise.com/materialise/view/en/131410-SimPlant.html
I was looking for some expert advise about the best technologies to use to build the different components of the so... | Best Technology for a medical 3D Planning Software | I am looking to build a new Interactive 3D planning software similar to this one http://www.materialise.com/materialise/view/en/131410-SimPlant.html
I was looking for some expert advise about the best technologies to use to build the different components of the software (ie: UI, Image processing, visualization, 3D, etc... | [
"The Python Imaging Library, PIL, is a good compromise between speed-to-market and good performance (and you can always use scipy and its core part, numpy, to enrich it for more advanced image-processing needs, if you pick Python as your pivot language!-). Similarly, visualization (including 3D) are excellently cov... | [
2,
2,
0
] | [] | [] | [
"3d",
"c++",
"image_manipulation",
"image_processing",
"python"
] | stackoverflow_0001056600_3d_c++_image_manipulation_image_processing_python.txt |
Q:
python saving unicode into file
i'm having some trouble figuring out how to save unicode into a file in python. I have the following code, and if i run it in a script test.py, it should create a new file called priceinfo.txt, and write what's in price_info to the file. But i do not see the file, can anyone enlight... | python saving unicode into file | i'm having some trouble figuring out how to save unicode into a file in python. I have the following code, and if i run it in a script test.py, it should create a new file called priceinfo.txt, and write what's in price_info to the file. But i do not see the file, can anyone enlighten me on what could be the problem?
T... | [
"I can think of several reasons:\n\nthe file gets created, but in a different directory. Be certain what the working \ndirectory of the script is.\nyou don't have permission to create the file, in the directory where you want to create it.\nyou have some error in your Python script, and it does not get executed at ... | [
3,
1
] | [] | [] | [
"file",
"python",
"unicode"
] | stackoverflow_0001150994_file_python_unicode.txt |
Q:
$_SERVER vs. WSGI environ parameter
I'm designing a site. It is in a very early stage, and I have to make a decision whether or not to use a SingleSignOn service provided by the server. (it's a campus site, and more and more sites are using SSO here, so generally it's a good idea).
The target platform is most prob... | $_SERVER vs. WSGI environ parameter | I'm designing a site. It is in a very early stage, and I have to make a decision whether or not to use a SingleSignOn service provided by the server. (it's a campus site, and more and more sites are using SSO here, so generally it's a good idea).
The target platform is most probably going to be django via mod_wsgi. How... | [
"In Django, the server environment variables are provided as dictionary members of the META attribute on the request object - so in your view, you can always access them via request.META['foo'] where foo is the name of the variable.\nAn easy way to see what is available is to create a view containing assert False t... | [
6,
3,
0
] | [] | [] | [
"django",
"environment_variables",
"php",
"python"
] | stackoverflow_0001149881_django_environment_variables_php_python.txt |
Q:
A question regarding string instance uniqueness in python
I was trying to figure out which integers python only instantiates once (-6 to 256 it seems), and in the process stumbled on some string behaviour I can't see the pattern in. Sometimes, equal strings created in different ways share the same id, sometimes no... | A question regarding string instance uniqueness in python | I was trying to figure out which integers python only instantiates once (-6 to 256 it seems), and in the process stumbled on some string behaviour I can't see the pattern in. Sometimes, equal strings created in different ways share the same id, sometimes not. This code:
A = "10000"
B = "10000"
C = "100" + "00"
D = "%i"... | [
"In terms of language specification, any compliant Python compiler and runtime is fully allowed, for any instance of an immutable type, to make a new instance OR find an existing instance of the same type that's equal to the required value and use a new reference to that same instance. This means it's always incorr... | [
10,
4,
1,
1
] | [] | [] | [
"instance",
"python",
"string",
"uniqueidentifier"
] | stackoverflow_0001150765_instance_python_string_uniqueidentifier.txt |
Q:
How to escape a hash (#) char in python?
I'm using pyodbc to query an AS400 (unfortunately), and some column names have hashes in them! Here is a small example:
self.cursor.execute('select LPPLNM, LPPDR# from BSYDTAD.LADWJLFU')
for row in self.cursor:
p = Patient()
p.last = row.LPPLNM
p.pcp = row.... | How to escape a hash (#) char in python? | I'm using pyodbc to query an AS400 (unfortunately), and some column names have hashes in them! Here is a small example:
self.cursor.execute('select LPPLNM, LPPDR# from BSYDTAD.LADWJLFU')
for row in self.cursor:
p = Patient()
p.last = row.LPPLNM
p.pcp = row.LPPDR#
I get errors like this obviously:
Att... | [
"Use the getattr function\np.pcp = getattr(row, \"LPPDR#\")\n\nThis is, in general, the way that you deal with attributes which aren't legal Python identifiers. For example, you can say\nsetattr(p, \"&)(@#$@!!~%&\", \"Hello World!\")\nprint getattr(p, \"&)(@#$@!!~%&\") # prints \"Hello World!\"\n\nAlso, as JG sug... | [
7,
5,
2,
1
] | [] | [] | [
"escaping",
"odbc",
"pyodbc",
"python"
] | stackoverflow_0001150581_escaping_odbc_pyodbc_python.txt |
Q:
How to get Python syntax highlighting for Visual Studio?
Visual Studio 2008 is great as text editor, but it lacks Python syntax highlighting, can I get this as an add-on? Where can I find it?
A:
Have you considered installing IronPython and using that to edit your work?
http://www.codeplex.com/IronPythonStudi... | How to get Python syntax highlighting for Visual Studio? | Visual Studio 2008 is great as text editor, but it lacks Python syntax highlighting, can I get this as an add-on? Where can I find it?
| [
"Have you considered installing IronPython and using that to edit your work? \n\nhttp://www.codeplex.com/IronPythonStudio\n\n"
] | [
2
] | [] | [] | [
"python",
"syntax_highlighting",
"visual_studio",
"visual_studio_2008"
] | stackoverflow_0001151207_python_syntax_highlighting_visual_studio_visual_studio_2008.txt |
Q:
map raw sql to django orm
Is there a way to simplify this working code?
This code gets for an object all the different vote types, there are like 20 possible, and counts each type.
I prefer not to write raw sql but use the orm. It is a little bit more tricky because I use generic foreign key in the model.
def get_... | map raw sql to django orm | Is there a way to simplify this working code?
This code gets for an object all the different vote types, there are like 20 possible, and counts each type.
I prefer not to write raw sql but use the orm. It is a little bit more tricky because I use generic foreign key in the model.
def get_object_votes(self, obj):
""... | [
"The code Below did the trick for me!\ndef get_object_votes(self, obj, all=False):\n \"\"\"\n Get a dictionary mapping vote to votecount\n \"\"\"\n object_id = obj._get_pk_val()\n ctype = ContentType.objects.get_for_model(obj)\n queryset = self.filter(content_type=ctype, object_id=object_id)\n\n ... | [
1,
0
] | [] | [] | [
"django",
"django_models",
"orm",
"python",
"sql"
] | stackoverflow_0001150898_django_django_models_orm_python_sql.txt |
Q:
How do you make the Python Msqldb module use ? in stead of %s for query parameters?
MySqlDb is a fantastic Python module -- but one part is incredibly annoying.
Query parameters look like this
cursor.execute("select * from Books where isbn=%s", (isbn,))
whereas everywhere else in the known universe (oracle, sqlse... | How do you make the Python Msqldb module use ? in stead of %s for query parameters? | MySqlDb is a fantastic Python module -- but one part is incredibly annoying.
Query parameters look like this
cursor.execute("select * from Books where isbn=%s", (isbn,))
whereas everywhere else in the known universe (oracle, sqlserver, access, sybase...)
they look like this
cursor.execute("select * from Books where is... | [
"I found a lot of information out there about paramstyle that seemed to imply it might be what you wanted, but according to this wiki you have to use the paramstyle your library uses, and most of them do not allow you to change it:\n\nparamstyle is specific to the library you use, and informational - you have to us... | [
2,
2,
1
] | [] | [] | [
"database",
"mysql",
"python",
"sql"
] | stackoverflow_0000825042_database_mysql_python_sql.txt |
Q:
Error on connecting to Oracle from py2exe'd program: Unable to acquire Oracle environment handle
My python program (Python 2.6) works fine when I run it using the Python interpreter, it connects to the Oracle database (10g XE) without error. However, when I compile it using py2exe, the executable version fails wit... | Error on connecting to Oracle from py2exe'd program: Unable to acquire Oracle environment handle | My python program (Python 2.6) works fine when I run it using the Python interpreter, it connects to the Oracle database (10g XE) without error. However, when I compile it using py2exe, the executable version fails with "Unable to acquire Oracle environment handle" at the call to cx_Oracle.connect().
I've tried the fol... | [
"Did you make sure to exclude the OCI.dll when you built with py2exe? If the version of the DLL on your machine is incompatible with the client version on another machine you test it on (I noticed you tried a 11g client but 10g on your machine), then this configuration will not work (I forget the actual error mess... | [
8,
2
] | [] | [] | [
"cx_oracle",
"oracle",
"py2exe",
"python"
] | stackoverflow_0001151557_cx_oracle_oracle_py2exe_python.txt |
Q:
What robot (web) libraries are available for python?
Specifically, are there any libraries that do not use sockets?
I will be running this code in Google App Engine, which does not allow the use of sockets.
Google app engine does allow the use of urllib2 to make web requests.
I've been trying to get mechanize to w... | What robot (web) libraries are available for python? | Specifically, are there any libraries that do not use sockets?
I will be running this code in Google App Engine, which does not allow the use of sockets.
Google app engine does allow the use of urllib2 to make web requests.
I've been trying to get mechanize to work, since that what I've used before, but if there's some... | [
"urlfetch seems to do the same thing that you are looking for.\n",
"To answer your question, twill and webunit are some other Python programmatic web browsing libraries. However, I'd be surprised if any of them worked off the bat with Google App Engine given the restricted stdlib.\n"
] | [
1,
0
] | [] | [] | [
"google_app_engine",
"python",
"robot"
] | stackoverflow_0000957661_google_app_engine_python_robot.txt |
Q:
tkMessageBox
Can anybody help me out in how to activate 'close' button of askquestion() of tkMessageBox??
A:
By 'activate', do you mean make it so the user can close the message box by clicking the close ('X') button?
I do not think it is possible using tkMessageBox. I guess your best bet is to implement a dialo... | tkMessageBox | Can anybody help me out in how to activate 'close' button of askquestion() of tkMessageBox??
| [
"By 'activate', do you mean make it so the user can close the message box by clicking the close ('X') button?\nI do not think it is possible using tkMessageBox. I guess your best bet is to implement a dialog box with this functionality yourself.\nBTW: What should askquestion() return when the user closes the dialog... | [
0
] | [] | [] | [
"python",
"tkmessagebox"
] | stackoverflow_0001151770_python_tkmessagebox.txt |
Q:
Pythonic Swap of 2 lists elements
I found that I have to perform a swap in python and I write something like this:
arr[first], arr[second] = arr[second], arr[first]
I suppose this is not so pythonic. Does somebody know how to do a swap in python more elegant?
EDIT:
I think another example will show my doubts:
sel... | Pythonic Swap of 2 lists elements | I found that I have to perform a swap in python and I write something like this:
arr[first], arr[second] = arr[second], arr[first]
I suppose this is not so pythonic. Does somebody know how to do a swap in python more elegant?
EDIT:
I think another example will show my doubts:
self.memberlist[someindexA], self.memberli... | [
"a, b = b, a\n\nIs a perfectly Pythonic idiom. It is short and readable, as long as your variable names are short enough.\n",
"The one thing I might change in your example code: if you're going to use some long name such as self.memberlist over an over again, it's often more readable to alias (\"assign\") it to a... | [
16,
14,
1,
1
] | [
"I suppose you could take advantage of the step argument of slice notation to do something like this:\nmyarr[:2] = myarr[:2][::-1]\nI'm not sure this is clearer or more pythonic though...\n"
] | [
-1
] | [
"python",
"swap"
] | stackoverflow_0001149802_python_swap.txt |
Q:
Where and how is django Model objects attribute defined?
I'm trying to get my head around Django ORM. I've been reading django.db.models.base.py source code but still could understand how does the Model.objects attributes in our Model object gets defined. Does anybody know how does django adds that objects attribu... | Where and how is django Model objects attribute defined? | I'm trying to get my head around Django ORM. I've been reading django.db.models.base.py source code but still could understand how does the Model.objects attributes in our Model object gets defined. Does anybody know how does django adds that objects attribute into our Model object?
Thanks in advance
| [
"The Django ORM makes heavy use of Python metaclasses. From Wikipedia:\n\nIn object-oriented programming, a metaclass is a class whose instances are classes. Just as an ordinary class defines the behavior of certain objects, a metaclass defines the behavior of certain classes and their instances.\n\nHere's a blog p... | [
5
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001151879_django_python.txt |
Q:
Allowing user to configure cron
I have this bash script on the server that runs every hour, via cron. I was perfectly happy, but now the user wants to be able to configure the frequency through the web interface.
I don't feel comfortable manipulating the cron configuration programmatically, but I'm not sure if the... | Allowing user to configure cron | I have this bash script on the server that runs every hour, via cron. I was perfectly happy, but now the user wants to be able to configure the frequency through the web interface.
I don't feel comfortable manipulating the cron configuration programmatically, but I'm not sure if the other options are any better.
The wa... | [
"Give your users some reasonable choices like every minute, every 5 minutes, every half an hour, ... and translate these values to a cron job string. This is user friendly and forbids users to tamper directly with the cron job string.\n",
"You could use a python scheduler library that does most of the work alread... | [
10,
3,
0,
0,
0
] | [] | [] | [
"bash",
"cron",
"python"
] | stackoverflow_0001136168_bash_cron_python.txt |
Q:
using registered com object dll from .NET
I implemented a python com server and generate an executable and dll using py2exe tool.
then I used regsvr32.exe to register the dll.I got a message that the registration was successful. Then I tried to add reference to that dll in .NET. I browsed to the dll location and s... | using registered com object dll from .NET | I implemented a python com server and generate an executable and dll using py2exe tool.
then I used regsvr32.exe to register the dll.I got a message that the registration was successful. Then I tried to add reference to that dll in .NET. I browsed to the dll location and select it, but I got an error message box that s... | [
"The line:\n_reg_clsid_ = pythoncom.CreateGuid()\n\ncreates a new GUID everytime this file is called. You can create a GUID on the command line:\nC:\\>python -c \"import pythoncom; print pythoncom.CreateGuid()\"\n{C86B66C2-408E-46EA-845E-71626F94D965}\n\nand then change your line:\n_reg_clsid_ = \"{C86B66C2-408E-4... | [
2,
2,
0
] | [] | [] | [
".net",
"com",
"py2exe",
"python"
] | stackoverflow_0001083913_.net_com_py2exe_python.txt |
Q:
Multiple regression in Python
I am currently using scipy's linregress function for single regression. I am unable to find if the same library, or another, is able to do multiple regression, that is, one dependent variable and more than one independent variable. I'd like to avoid R if possible. If you're wondering,... | Multiple regression in Python | I am currently using scipy's linregress function for single regression. I am unable to find if the same library, or another, is able to do multiple regression, that is, one dependent variable and more than one independent variable. I'd like to avoid R if possible. If you're wondering, I am doing FX market analysis with... | [
"Use the OLS class [http://www.scipy.org/Cookbook/OLS] from the SciPy cookbook.\n",
"I'm not sure if this is what you need, but the Modular toolkit for Data Processing (MDP) libray recently implemented multivariate linear regression. It is under LGPL license.\n"
] | [
9,
2
] | [] | [] | [
"math",
"python",
"regression",
"scipy"
] | stackoverflow_0001151088_math_python_regression_scipy.txt |
Q:
django documentation locally setting up
I was trying to setup django . I do have Django-1.1-alpha-1. I was trying to make the documentation which is located at Django-1.1-alpha-1/doc using make utility.
But I am getting some error saying
> C:\django\Django-1.1-alpha-1\docs>C:\cygwin\bin\make.exe html
mkdir -p _b... | django documentation locally setting up | I was trying to setup django . I do have Django-1.1-alpha-1. I was trying to make the documentation which is located at Django-1.1-alpha-1/doc using make utility.
But I am getting some error saying
> C:\django\Django-1.1-alpha-1\docs>C:\cygwin\bin\make.exe html
mkdir -p _build/html _build/doctrees
sphinx-build -b htm... | [
"Install sphinx.\n$ easy_install -U Sphinx\n\n"
] | [
8
] | [] | [] | [
"django",
"python",
"python_sphinx"
] | stackoverflow_0001152479_django_python_python_sphinx.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.