title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
Django: Arbitrary number of unnamed urls.py parameters
249,110
<p>I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:</p> <pre><code>/browse/&lt;name1&gt;/&lt;value1&gt;/&lt;name2&gt;/&lt;value2&gt;/ .... ...
16
2008-10-30T02:18:32Z
255,251
<p>Same answer came to me while reading the question.</p> <p>I believe model_browse view is the best way to sort the query parameters and use it as a generic router.</p>
0
2008-10-31T23:31:03Z
[ "python", "django", "django-urls" ]
Django: Arbitrary number of unnamed urls.py parameters
249,110
<p>I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:</p> <pre><code>/browse/&lt;name1&gt;/&lt;value1&gt;/&lt;name2&gt;/&lt;value2&gt;/ .... ...
16
2008-10-30T02:18:32Z
19,378,600
<p>I think the answer of Adam is more generic than my solution, but if you like to use a fixed number of arguments in the url, you could also do something like this:</p> <p>The following example shows how to get all sales of a day for a location by entering the name of the <code>store</code> and the <code>year</code>,...
0
2013-10-15T10:15:03Z
[ "python", "django", "django-urls" ]
Django: Arbitrary number of unnamed urls.py parameters
249,110
<p>I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:</p> <pre><code>/browse/&lt;name1&gt;/&lt;value1&gt;/&lt;name2&gt;/&lt;value2&gt;/ .... ...
16
2008-10-30T02:18:32Z
35,575,143
<p>I've an alternative solution, which isn't quite different from the previous but it's more refined:</p> <p><code>url(r'^my_app/(((list\/)((\w{1,})\/(\w{1,})\/(\w{1,3})\/){1,10})+)$'</code></p> <p>I've used <a href="https://docs.djangoproject.com/en/1.9/topics/http/urls/#example" rel="nofollow">unnamed url parameter...
0
2016-02-23T10:37:31Z
[ "python", "django", "django-urls" ]
Jython 2.2.1, howto move a file? shutils.move is non-existant!
249,262
<pre><code>'''use Jython''' import shutil print dir(shutil) </code></pre> <p>There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?</p>
0
2008-10-30T04:22:08Z
249,279
<p><code>os.rename()</code> to move, and <code>os.unlink()</code> to delete -- just like Python pre-<code>shutil</code>.</p>
4
2008-10-30T04:28:47Z
[ "java", "python", "jython", "file-handling", "shutil" ]
Jython 2.2.1, howto move a file? shutils.move is non-existant!
249,262
<pre><code>'''use Jython''' import shutil print dir(shutil) </code></pre> <p>There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?</p>
0
2008-10-30T04:22:08Z
250,933
<p>If you need support for moving across filesystems, consider just copying CPython's <code>shutil.py</code> into your project. <A HREF="http://www.python.org/download/releases/2.4.2/license/" rel="nofollow">The Python License</A> is flexible enough to allow this (even for commercial projects), as long as licensing and...
1
2008-10-30T17:00:21Z
[ "java", "python", "jython", "file-handling", "shutil" ]
Jython 2.2.1, howto move a file? shutils.move is non-existant!
249,262
<pre><code>'''use Jython''' import shutil print dir(shutil) </code></pre> <p>There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?</p>
0
2008-10-30T04:22:08Z
2,334,425
<pre><code>f1 = File(filename_old) f1.nameTo(File(filename_new)) </code></pre>
0
2010-02-25T13:58:08Z
[ "java", "python", "jython", "file-handling", "shutil" ]
Virtualenv on Ubuntu with no site-packages
249,283
<p>I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the --no-site-packages option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (with...
24
2008-10-30T04:32:52Z
249,342
<p>One way is to add the paths to your code using sys.path.</p> <pre><code>import sys sys.path.append(somepath) </code></pre> <p>Another way is to use site, which processes .pth files in addition to adding to sys.path.</p> <pre><code>import site site.addsitedir(sitedir, known_paths=None) </code></pre> <p><a href=...
4
2008-10-30T05:22:13Z
[ "python", "ubuntu", "pygtk", "virtualenv" ]
Virtualenv on Ubuntu with no site-packages
249,283
<p>I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the --no-site-packages option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (with...
24
2008-10-30T04:32:52Z
249,708
<p>I find in this situation, symlinks, or even copying specific files (packages, modules, extensions) works really well.</p> <p>It allows the program to emulate being run in the target environment, rather than changing the application to suit the development environment.</p> <p>Same deal for something like AppEngine....
1
2008-10-30T09:57:08Z
[ "python", "ubuntu", "pygtk", "virtualenv" ]
Virtualenv on Ubuntu with no site-packages
249,283
<p>I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the --no-site-packages option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (with...
24
2008-10-30T04:32:52Z
1,670,513
<pre><code>$ virtualenv --no-site-packages --python=/usr/bin/python2.6 myvirtualenv $ cd myvirtualenv $ source bin/activate $ cd lib/python2.6/ $ ln -s /usr/lib/pymodules/python2.6/gtk-2.0/ $ ln -s /usr/lib/pymodules/python2.6/pygtk.pth $ ln -s /usr/lib/pymodules/python2.6/pygtk.py $ ln -s /usr/lib/pymodules/python2...
34
2009-11-03T22:20:07Z
[ "python", "ubuntu", "pygtk", "virtualenv" ]
Virtualenv on Ubuntu with no site-packages
249,283
<p>I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the --no-site-packages option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (with...
24
2008-10-30T04:32:52Z
12,134,232
<p>Check out the postmkvirtualenv hook script here: </p> <p><a href="http://stackoverflow.com/a/9716100/60247">http://stackoverflow.com/a/9716100/60247</a></p> <p>In that case, he's using it to import PyQt and SIP after a new Virtualenv is created, but you can add the packages that you need to LIBS. </p> <p>And vote...
1
2012-08-26T21:56:56Z
[ "python", "ubuntu", "pygtk", "virtualenv" ]
Virtualenv on Ubuntu with no site-packages
249,283
<p>I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the --no-site-packages option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (with...
24
2008-10-30T04:32:52Z
27,471,458
<p>If you want to include the links to the relevant system's python gtk-2.0 in the virtualenv, you can just use pip to install <a href="https://pypi.python.org/pypi/ruamel.venvgtk" rel="nofollow">ruamel.venvgtk</a>:</p> <p>pip install ruamel.venvgtk You don't have import anything, the links are setup during installati...
0
2014-12-14T16:38:33Z
[ "python", "ubuntu", "pygtk", "virtualenv" ]
Translate SVN path to local file system path in Python
249,330
<p>I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository.</p> <p>I have a copy of the files on my local file system and I do an update t...
0
2008-10-30T05:07:18Z
249,444
<p>Hm... That would do it:</p> <pre><code>baselen = len(self.basePath) for path in paths: path = path[baselen:].replace("/", "\\") newPaths.append(path) return newPaths </code></pre> <p>If you like, you can do it like this:</p> <pre><code>baselen = len(self.basePath) return (path[baselen:].replace("/", "\\")...
0
2008-10-30T06:53:28Z
[ "python", "svn" ]
Translate SVN path to local file system path in Python
249,330
<p>I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository.</p> <p>I have a copy of the files on my local file system and I do an update t...
0
2008-10-30T05:07:18Z
249,650
<p>Stay with the slice operator, but do not change the loop variable inside the loop. for fun, try the generator expression (or keep the listcomp).</p> <pre><code>baselen = len(self.basePath) return (path[baselen:].replace("/", "\\") for path in paths) </code></pre> <p>Edit: `lstrip()' is not relevant here. From the ...
2
2008-10-30T09:23:15Z
[ "python", "svn" ]
Translate SVN path to local file system path in Python
249,330
<p>I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository.</p> <p>I have a copy of the files on my local file system and I do an update t...
0
2008-10-30T05:07:18Z
249,743
<p>Your specific solution to the path name copy is reasonable, but your general solution to the entire problem could be improved.</p> <p>I would <code>easy_install anyvc</code>, a library developed for the <a href="http://pida.co.uk/" rel="nofollow">PIDA IDE</a> which is a uniform python interface into version control...
0
2008-10-30T10:10:53Z
[ "python", "svn" ]
Python with PIL and Libjpeg on Leopard
249,388
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
3
2008-10-30T06:00:14Z
249,406
<p>Is the python path still looking at the old binary version of libjpeg?</p> <p>You will need to modify it to point to the new place if it is.</p> <p>When you compiled the new version of the PIL did it say that it found libjpeg? It will compile happily without it (iirc) and the first sign of trouble you will see is ...
0
2008-10-30T06:14:06Z
[ "python", "python-imaging-library", "libjpeg", "python-install" ]
Python with PIL and Libjpeg on Leopard
249,388
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
3
2008-10-30T06:00:14Z
249,414
<p>I had the similar 'jpeg decoder problem' recently when deploying a django project on a product RHEL box that required PIL. I downloaded PIL, and ran 'python setup.py install' instantly, and was happy that everything was working, until I bumped into the problem. Solution: libjpeg was already installed on the system, ...
1
2008-10-30T06:31:00Z
[ "python", "python-imaging-library", "libjpeg", "python-install" ]
Python with PIL and Libjpeg on Leopard
249,388
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
3
2008-10-30T06:00:14Z
1,252,888
<p>I had the same problem and this guy's post provided the solution for me:</p> <p>rm the PIL subdir and the PIL.pth file in the Imaging-1.1.6 subdir</p> <p>full details here:</p> <p><a href="http://blog.tlensing.org/2008/12/04/kill-pil-%E2%80%93-the-python-imaging-library-headache/" rel="nofollow">http://blog.tlens...
1
2009-08-10T02:24:39Z
[ "python", "python-imaging-library", "libjpeg", "python-install" ]
Python with PIL and Libjpeg on Leopard
249,388
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
3
2008-10-30T06:00:14Z
1,475,112
<p>If you build with libjpeg, but selftest fails, you probably have another install of PIL that's confusing things. Try installing it, and see if selftest works then.</p> <p>Also the direct link to the instructions referenced in the OP is <a href="http://timhatch.com/ark/2008/08/12/quick-howto-for-pil-on-leopard" rel...
0
2009-09-25T02:18:15Z
[ "python", "python-imaging-library", "libjpeg", "python-install" ]
Python with PIL and Libjpeg on Leopard
249,388
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
3
2008-10-30T06:00:14Z
4,533,995
<p>I have stuck to this problem for quite a few hours today. And my advice is do NOT do trial and error again and again, unless u could fix the problem in first 15 minutes.</p> <p>there are a few tools for you to diagnose the problem:</p> <p>1.check the if jpeg lib architcture matches your machine architecture:</p> ...
0
2010-12-26T13:34:05Z
[ "python", "python-imaging-library", "libjpeg", "python-install" ]
How to determine if a directory is on same partition
249,775
<p>Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory?</p> <p>What I want to do is the copy a file if it's on a different, but move it if it's the same. For example:</p> <pre><code>target_directory = "/Volumes/externa...
6
2008-10-30T10:45:42Z
249,796
<p>In C, you would use <code>stat()</code> and compare the <code>st_dev</code> field. In python, <code>os.stat</code> should do the same.</p>
11
2008-10-30T10:54:11Z
[ "python", "linux", "osx", "filesystems" ]
How to determine if a directory is on same partition
249,775
<p>Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory?</p> <p>What I want to do is the copy a file if it's on a different, but move it if it's the same. For example:</p> <pre><code>target_directory = "/Volumes/externa...
6
2008-10-30T10:45:42Z
250,149
<p>Another way is the “better to ask forgiveness than permission” approach—just try to rename it, and if that fails, catch the appropriate <code>OSError</code> and try the copy approach. ie:</p> <pre><code>import errno try: os.rename(source, dest): except IOError, ex: if ex.errno == errno.EXDEV: ...
3
2008-10-30T13:21:02Z
[ "python", "linux", "osx", "filesystems" ]
OS X: Determine Trash location for a given path
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
1
2008-10-30T10:50:32Z
249,800
<p>The File Manager API has a pair of functions called FSMoveObjectToTrashAsync and FSPathMoveObjectToTrashSync.</p> <p>Not sure if that is exposed to Python or not.</p>
2
2008-10-30T10:57:06Z
[ "python", "osx", "filesystems" ]
OS X: Determine Trash location for a given path
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
1
2008-10-30T10:50:32Z
251,566
<p>Alternatively, if you're on OS X 10.5, you could use Scripting Bridge to delete files via the Finder. I've done this in Ruby code <a href="http://osx-trash.rubyforge.org/git?p=osx-trash.git;a=blob;f=bin/trash;h=26911131eacafd659b4d760bda1bd4c99dc2f918;hb=HEAD">here</a> via RubyCocoa. The the gist of it is:</p> <p...
5
2008-10-30T20:07:26Z
[ "python", "osx", "filesystems" ]
OS X: Determine Trash location for a given path
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
1
2008-10-30T10:50:32Z
252,920
<p>Based upon code from <a href="http://www.cocoadev.com/index.pl?MoveToTrash" rel="nofollow">http://www.cocoadev.com/index.pl?MoveToTrash</a> I have came up with the following:</p> <pre><code>def get_trash_path(input_file): path, file = os.path.split(input_file) if path.startswith("/Volumes/"): # /Vol...
4
2008-10-31T09:03:45Z
[ "python", "osx", "filesystems" ]
OS X: Determine Trash location for a given path
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
1
2008-10-30T10:50:32Z
621,219
<p>A better way is <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace%5FClass/Reference/Reference.html#//apple%5Fref/doc/c%5Fref/NSWorkspaceRecycleOperation" rel="nofollow">NSWorkspaceRecycleOperation</a>, which is one of the operations you can use with <a href="http://...
3
2009-03-07T03:03:07Z
[ "python", "osx", "filesystems" ]
OS X: Determine Trash location for a given path
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
1
2008-10-30T10:50:32Z
3,654,566
<p>Another one in ruby:</p> <pre><code>Appscript.app('Finder').items[MacTypes::Alias.path(path)].delete </code></pre> <p>You will need <a href="http://rubygems.org/gems/rb-appscript" rel="nofollow">rb-appscript</a> gem, you can read about it <a href="http://appscript.sourceforge.net/rb-appscript/index.html" rel="nofo...
1
2010-09-06T22:14:55Z
[ "python", "osx", "filesystems" ]
OS X: Determine Trash location for a given path
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
1
2008-10-30T10:50:32Z
5,012,645
<p>In Python, without using the scripting bridge, you can do this:</p> <pre><code>from AppKit import NSWorkspace, NSWorkspaceRecycleOperation source = "path holding files" files = ["file1", "file2"] ws = NSWorkspace.sharedWorkspace() ws.performFileOperation_source_destination_files_tag_(NSWorkspaceRecycleOperation, ...
2
2011-02-16T04:56:14Z
[ "python", "osx", "filesystems" ]
How can I add post-install scripts to easy_install / setuptools / distutils?
250,038
<p>I would like to be able to add a hook to my setup.py that will be run post-install (either when easy_install'ing or when doing python setup.py install).</p> <p>In my project, <a href="http://code.google.com/p/pysmell">PySmell</a>, I have some support files for Vim and Emacs. When a user installs PySmell the usual w...
30
2008-10-30T12:42:10Z
253,103
<p>It depends on how the user installs your package. If the user actually runs "setup.py install", it's fairly easy: Just add another subcommand to the install command (say, install_vim), whose run() method will copy the files you want in the places where you want them. You can add your subcommand to install.sub_comman...
7
2008-10-31T10:33:46Z
[ "python", "setuptools", "distutils" ]
How can I add post-install scripts to easy_install / setuptools / distutils?
250,038
<p>I would like to be able to add a hook to my setup.py that will be run post-install (either when easy_install'ing or when doing python setup.py install).</p> <p>In my project, <a href="http://code.google.com/p/pysmell">PySmell</a>, I have some support files for Vim and Emacs. When a user installs PySmell the usual w...
30
2008-10-30T12:42:10Z
7,931,715
<p>As a work-around, you could set the zip_ok option to false so that your project is installed as an unzipped directory, then it will be a little easier for your users to find the editor config file.</p> <p>In distutils2, it will be possible to install things to more directories, including custom directories, and to ...
0
2011-10-28T15:56:28Z
[ "python", "setuptools", "distutils" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
250,158
<p>Just because it is "marketed" (in some general sense) as a special-purpose language for embedded script engines, does not mean that it is limited to that. In fact, WoW could probably just as well have chosen Python as their embedded scripting language.</p>
10
2008-10-30T13:24:26Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
250,168
<p>It's probably because Lua was designed as a scripting and extension language. On the <a href="http://www.lua.org/about.html">official site</a> it's described as a powerful, fast, light-weight, embeddable scripting language. There's nothing stopping you from writing general purpose programs for it (if I recall correc...
9
2008-10-30T13:28:04Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
251,372
<p>Definitely a lack of standard libraries. It's also lesser known than Python, Perl or Ruby.</p>
6
2008-10-30T19:13:31Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
252,900
<p>Lua is a cool language, light-weight and extremely fast!</p> <p>But the point is: <strong>Is performance so important for those tasks you mentioned?</strong></p> <ul> <li>Renaming a bunch of files</li> <li>Download some files from the web</li> <li>Webscraping</li> </ul> <p>You write those programs once, and run t...
33
2008-10-31T08:48:29Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
253,659
<p>I think the answer about it being a "marketing" thing is probably correct, along with the lack of a large set of libraries to choose from. I would like to point out another case of this: Ruby. Ruby is meant to be a general purpose scripting language. The problem is that since Ruby on Rails has risen to be so popula...
3
2008-10-31T14:15:15Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
253,755
<p>Lua has fewer libraries than Python. But be sure to have a look at <a href="http://luaforge.net/">LuaForge</a>. It has a lot of interesting libs, like <a href="http://luaforge.net/projects/luacurl/">LuaCURL</a>, <a href="http://wxlua.sourceforge.net/">wxLua</a> or <a href="http://luaforge.net/projects/getopt/">getop...
21
2008-10-31T14:40:55Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
326,660
<p>This is a sociological question, not a programming question.</p> <p>I use Lua for general-purpose scripting almost exclusively. But I had to write a few hundred lines of code so that Lua would play better with the shell. This included such tricks as </p> <ul> <li>Quoting a string so it is seen as one word by the...
8
2008-11-28T20:56:38Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
370,746
<p>Lack of standard library. Period. Even listing all the files in a directory require <a href="http://www.keplerproject.org/luafilesystem" rel="nofollow">a non-standard module</a>.</p> <p>There are good reasons for that (keeping strict ANSI portability, not requiring POSIX) but the result is that, for general program...
4
2008-12-16T08:56:51Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
568,728
<p>There has been a recent push to create a batteries included installation for Lua on Windows. The result can be found at the <a href="http://luaforge.net/projects/luaforwindows/" rel="nofollow">Lua for Windows</a> project at LuaForge. It includes the interpreter and a large collection of extra modules allowing useful...
4
2009-02-20T08:31:28Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
781,316
<p>In order for Lua to be easy to embed it has to have few dependencies and be small. That makes it poorly suited as a general purpose scripting language. Because using it as a general purpose script language would require a lot of standard libraries. But if Lua had a lot of standard libraries it would be harder to emb...
3
2009-04-23T11:32:02Z
[ "python", "scripting", "lua" ]
Lua as a general-purpose scripting language?
250,151
<p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p> <p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?<...
33
2008-10-30T13:21:41Z
1,537,777
<p>Lua is used in <a href="http://www.luatex.org/" rel="nofollow">LuaTeX</a>, a TeX extension, as an embedded language, and has gained popularity rapidly among TeX developers because of that. It is used as a scripting language for some utilities in the TeX Live distribution, be it only because now there is a <code>lua...
3
2009-10-08T13:24:02Z
[ "python", "scripting", "lua" ]
How can I optimize this Google App Engine code?
250,209
<p>I'm relatively new to the python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
5
2008-10-30T13:40:19Z
250,294
<p>Looks pretty tight to me.</p> <p>I see one thing that may make a small improvement. Your calling, "self.request.get('links')" twice.</p> <p>So adding:</p> <pre><code>unsplitlinks = self.request.get('links') </code></pre> <p>And referencing, "unsplitlinks" could help.</p> <p>Other than that the loop is the only ...
3
2008-10-30T14:13:15Z
[ "python", "google-app-engine", "optimization" ]
How can I optimize this Google App Engine code?
250,209
<p>I'm relatively new to the python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
5
2008-10-30T13:40:19Z
250,318
<p>How frequently is this getting called? This doesn't look that bad... especially after removing the duplicate request.</p>
0
2008-10-30T14:21:41Z
[ "python", "google-app-engine", "optimization" ]
How can I optimize this Google App Engine code?
250,209
<p>I'm relatively new to the python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
5
2008-10-30T13:40:19Z
250,322
<p>You can dramatically reduce the interaction between your app and the database by just storing the complete <code>self.request.get('links')</code> in a text field in the database.</p> <ul> <li>only one <code>put()</code> per <code>post(self)</code></li> <li>the hash isn't stored n-times (for every link, which makes ...
2
2008-10-30T14:22:26Z
[ "python", "google-app-engine", "optimization" ]
How can I optimize this Google App Engine code?
250,209
<p>I'm relatively new to the python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
5
2008-10-30T13:40:19Z
250,395
<p>The main overhead here is the multiple individual puts to the datastore. If you can, store the links as a single entity, as Andre suggests. You can always split the links into an array and store it in a ListProperty.</p> <p>If you do need an entity for each link, try this:</p> <pre><code># For each line in the inp...
7
2008-10-30T14:41:19Z
[ "python", "google-app-engine", "optimization" ]
How can I optimize this Google App Engine code?
250,209
<p>I'm relatively new to the python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
5
2008-10-30T13:40:19Z
250,465
<p>Can I query against the ListProperty?</p> <p>Something like </p> <pre><code>SELECT * FROM LinkGrouping WHERE links.contains('http://www.google.com') </code></pre> <p>I have future plans where I would need that functionality.</p> <p>I'll definitely implement the single db.put() to reduce usage.</p>
0
2008-10-30T14:58:50Z
[ "python", "google-app-engine", "optimization" ]
How can I optimize this Google App Engine code?
250,209
<p>I'm relatively new to the python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
5
2008-10-30T13:40:19Z
264,785
<p>no/ you can not use something like "links.contains('<a href="http://www.google.com" rel="nofollow">http://www.google.com</a>')" GQL not support this</p>
0
2008-11-05T10:25:38Z
[ "python", "google-app-engine", "optimization" ]
Python Regex - How to Get Positions of Matches
250,271
<p>How can I get the start and end positions of all matches using the <code>re</code> module? For example given the pattern <code>r'[a-z]'</code> and the string <code>'a1b2c3d4'</code> I'd want to get the positions where it finds each letter (ideally I'd like to get the text of the match back too).</p>
50
2008-10-30T14:04:33Z
250,303
<pre><code>import re p = re.compile("[a-z]") for m in p.finditer('a1b2c3d4'): print m.start(), m.group() </code></pre>
65
2008-10-30T14:15:39Z
[ "python", "regex" ]
Python Regex - How to Get Positions of Matches
250,271
<p>How can I get the start and end positions of all matches using the <code>re</code> module? For example given the pattern <code>r'[a-z]'</code> and the string <code>'a1b2c3d4'</code> I'd want to get the positions where it finds each letter (ideally I'd like to get the text of the match back too).</p>
50
2008-10-30T14:04:33Z
250,306
<p>Taken from </p> <p><a href="http://docs.python.org/3.3/howto/regex.html"><em>Regular Expression HOWTO</em></a></p> <blockquote> <p>span() returns both start and end indexes in a single tuple. Since the match method only checks if the RE matches at the start of a string, start() will always be zero. However, ...
27
2008-10-30T14:16:02Z
[ "python", "regex" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
250,330
<p>I don't think there's any one module that you can easily download to implement scp, however you might find this helpful: <a href="http://www.ibm.com/developerworks/linux/library/l-twist4.html" rel="nofollow">http://www.ibm.com/developerworks/linux/library/l-twist4.html</a></p>
-2
2008-10-30T14:25:06Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
250,402
<p>if you install putty on win32 you get an pscp (putty scp).</p> <p>so you can use the os.system hack on win32 too.</p> <p>(and you can use the putty-agent for key-managment)</p> <p><hr /></p> <p>sorry it is only a hack (but you can wrap it in a python class)</p>
4
2008-10-30T14:42:42Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
250,786
<p>You might be interested in trying <a href="http://www.noah.org/wiki/Pexpect">Pexpect</a> (<a href="http://sourceforge.net/projects/pexpect/">SourceForge project</a>). This would allow you to deal with interactive prompts for your password.</p> <p>Here's a snip of example usage (for ftp) from the main website:</p> ...
11
2008-10-30T16:18:00Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
250,797
<p>Hmmm, perhaps another option would be to use something like <a href="http://fuse.sourceforge.net/sshfs.html" rel="nofollow">sshfs</a> (there an <a href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS" rel="nofollow">sshfs</a> for Mac too). Once your router is mounted you can just copy the files outright. ...
1
2008-10-30T16:20:46Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
251,625
<p>You could also check out <a href="http://www.lag.net/paramiko/">paramiko</a>. There's no scp module (yet), but it fully supports sftp.</p> <p>[EDIT] Sorry, missed the line where you mentioned paramiko. The following module is simply an implementation of the scp protocol for paramiko. If you don't want to use param...
8
2008-10-30T20:22:43Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
4,282,261
<p>Try the module <a href="https://github.com/jbardin/scp.py">paramiko_scp</a>. It's very easy to use. See the following example:</p> <pre><code>def createSSHClient(server, port, user, password): client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.AutoAd...
62
2010-11-26T03:03:37Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
8,247,987
<p>Have a look at <a href="http://www.fabfile.org/" rel="nofollow">fabric</a>. An example can be found <a href="http://stackoverflow.com/questions/5314711/how-do-i-copy-a-directory-to-a-remote-machine-using-fabric">here</a>.</p>
3
2011-11-23T19:30:26Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
10,685,789
<p>I while ago I put together a python SCP copy script that depends on paramiko. It includes code to handle connections with a private key or SSH key agent with a fallback to password authentication.</p> <p><a href="http://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/" rel="nofollow">http://c...
1
2012-05-21T13:03:59Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
24,049,247
<p>If you are on *nix you can use <a href="http://sourceforge.net/projects/sshpass/" rel="nofollow">sshpass</a></p> <pre><code>sshpass -p password scp -o User=username -o StrictHostKeyChecking=no src dst:/path </code></pre>
0
2014-06-04T23:26:21Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
24,587,238
<p>It has been quite a while since this question was asked, and in the meantime, another library that can handle this has cropped up: You can use the <a href="http://plumbum.readthedocs.org/en/latest/api/path.html#plumbum.path.utils.copy" rel="nofollow">copy</a> function included in the <a href="http://plumbum.readthed...
3
2014-07-05T14:08:32Z
[ "python", "ssh", "scp" ]
How to scp in python?
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside linux-like systems, and which needs help from the Pexpect module to avoid passw...
97
2008-10-30T14:09:21Z
38,556,344
<p>Couldn't find a straight answer, and this "scp.Client" module doesn't exist. Instead, <a href="https://pypi.python.org/pypi/scp" rel="nofollow">this</a> suits me:</p> <pre><code>from paramiko import SSHClient from scp import SCPClient ssh = SSHClient() ssh.load_system_host_keys() ssh.connect('example.com') with S...
1
2016-07-24T20:14:37Z
[ "python", "ssh", "scp" ]
Truncate a string without ending in the middle of a word
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
31
2008-10-30T14:32:20Z
250,373
<p>I actually wrote a solution for this on a recent project of mine. I've compressed the majority of it down to be a little smaller.</p> <pre><code>def smart_truncate(content, length=100, suffix='...'): if len(content) &lt;= length: return content else: return ' '.join(content[:length+1].split...
49
2008-10-30T14:36:03Z
[ "python", "truncate" ]
Truncate a string without ending in the middle of a word
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
31
2008-10-30T14:32:20Z
250,406
<p>Here's a slightly better version of the last line in Adam's solution:</p> <pre><code>return content[:length].rsplit(' ', 1)[0]+suffix </code></pre> <p>(This is slightly more efficient, and returns a more sensible result in the case there are no spaces in the front of the string.)</p>
36
2008-10-30T14:43:16Z
[ "python", "truncate" ]
Truncate a string without ending in the middle of a word
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
31
2008-10-30T14:32:20Z
250,409
<pre><code>def smart_truncate(s, width): if s[width].isspace(): return s[0:width]; else: return s[0:width].rsplit(None, 1)[0] </code></pre> <p>Testing it:</p> <pre><code>&gt;&gt;&gt; smart_truncate('The quick brown fox jumped over the lazy dog.', 23) + "..." 'The quick brown fox...' </code></p...
3
2008-10-30T14:44:05Z
[ "python", "truncate" ]
Truncate a string without ending in the middle of a word
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
31
2008-10-30T14:32:20Z
250,471
<pre><code>def smart_truncate1(text, max_length=100, suffix='...'): """Returns a string of at most `max_length` characters, cutting only at word-boundaries. If the string was truncated, `suffix` will be appended. """ if len(text) &gt; max_length: pattern = r'^(.{0,%d}\S)\s.*' % (max_length-...
7
2008-10-30T14:59:41Z
[ "python", "truncate" ]
Truncate a string without ending in the middle of a word
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
31
2008-10-30T14:32:20Z
250,684
<p>There are a few subtleties that may or may not be issues for you, such as handling of tabs (Eg. if you're displaying them as 8 spaces, but treating them as 1 character internally), handling various flavours of breaking and non-breaking whitespace, or allowing breaking on hyphenation etc. If any of this is desirable...
11
2008-10-30T15:47:04Z
[ "python", "truncate" ]
Truncate a string without ending in the middle of a word
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
31
2008-10-30T14:32:20Z
20,821,663
<pre><code>&gt;&gt;&gt; import textwrap &gt;&gt;&gt; textwrap.wrap('The quick brown fox jumps over the lazy dog', 12) ['The quick', 'brown fox', 'jumps over', 'the lazy dog'] </code></pre> <p>You just take the first element of that and you're done...</p>
4
2013-12-29T02:54:59Z
[ "python", "truncate" ]
What do you like about Django?
250,397
<p>I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.<br /> Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.</p> <p>So i would like to know your opinion about Django. </p> <p>What do y...
6
2008-10-30T14:41:38Z
250,459
<p><strong><em>What do I like about it :</em></strong></p> <ul> <li>Very simple ORM</li> <li>clear separation of template / controller</li> <li>django-admin</li> <li>pluggable apps : it seems to me that the Django community really nailed that one !</li> </ul> <p><strong><em>What made me switch :</em></strong></p> <u...
8
2008-10-30T14:57:22Z
[ "python", "django" ]
What do you like about Django?
250,397
<p>I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.<br /> Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.</p> <p>So i would like to know your opinion about Django. </p> <p>What do y...
6
2008-10-30T14:41:38Z
250,461
<h3>What do you like about it?</h3> <p>URL dispatching: I was never a big fan of "/foo.php" is the file "foo.php" on my server, and if I want nicer URLs I need to mess around with mod_rewrite and keep that in line with what my logic in foo expects.</p> <p>ORM: Because 90%+ of your queries, in my experience, do not n...
8
2008-10-30T14:57:53Z
[ "python", "django" ]
What do you like about Django?
250,397
<p>I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.<br /> Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.</p> <p>So i would like to know your opinion about Django. </p> <p>What do y...
6
2008-10-30T14:41:38Z
250,487
<p>I haven't had had the opportunity to use it much. That said, my absolute favorite part of django is the built in administration console.</p>
3
2008-10-30T15:03:57Z
[ "python", "django" ]
What do you like about Django?
250,397
<p>I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.<br /> Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.</p> <p>So i would like to know your opinion about Django. </p> <p>What do y...
6
2008-10-30T14:41:38Z
251,984
<h2><strong>Likes</strong></h2> <p>The excellent Documentation. Together with help from stackoverflow I have learned a lot in only a few days. It writting in Python. It has the wonderful contrib.admin which is even modular and extensible to embed it into the web app proper.</p> <h2>Dislikes</h2> <p>None so far. I am...
4
2008-10-30T22:26:47Z
[ "python", "django" ]
What do you like about Django?
250,397
<p>I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.<br /> Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.</p> <p>So i would like to know your opinion about Django. </p> <p>What do y...
6
2008-10-30T14:41:38Z
263,440
<h2>What do you like about it?</h2> <ul> <li>the templates, specifically the inheritance feature, was amazing after dealing with jsps</li> <li>not having to write sql anymore</li> </ul> <h2>What made you switch/use it?</h2> <p>A friend had been following its progress before it was publicly released, and I've been us...
4
2008-11-04T21:03:33Z
[ "python", "django" ]
What do you like about Django?
250,397
<p>I started to learn Django a few days ago, and as i dive into it it seems that I'm starting to like it even more.<br /> Trying to migrate from other language. I won't say which one, as the purpose of this question is not to bash anything.</p> <p>So i would like to know your opinion about Django. </p> <p>What do y...
6
2008-10-30T14:41:38Z
264,913
<p>Likes:</p> <ul> <li>Pythonic (I can easily grok the language) and thus extend any part easily</li> <li>Documentation,</li> <li>community (I belong to the french one and they're very nice)</li> <li>a full load of projects around it</li> <li>full-integrated test engine. You can almost test a whole application without...
3
2008-11-05T11:46:12Z
[ "python", "django" ]
How to specify relations using SQLAlchemy declarative syntax?
250,398
<p>I can't find any proper documentation on how to specify relations using the declarative syntax of SQLAlchemy.. Is it unsupported? That is, should I use the "traditional" syntax?<br /> I am looking for a way to specify relations at a higher level, avoiding having to mess with foreign keys etc.. I'd like to just decla...
3
2008-10-30T14:41:50Z
251,077
<p>Assuming you are referring to <a href="http://www.sqlalchemy.org/docs/04/plugins.html#plugins_declarative" rel="nofollow">the declarative plugin</a>, where everything I am about to say is documented with examples:</p> <pre><code>class User(Base): __tablename__ = 'users' id = Column('id', Integer, primary_k...
3
2008-10-30T17:37:28Z
[ "python", "sqlalchemy" ]
How to specify relations using SQLAlchemy declarative syntax?
250,398
<p>I can't find any proper documentation on how to specify relations using the declarative syntax of SQLAlchemy.. Is it unsupported? That is, should I use the "traditional" syntax?<br /> I am looking for a way to specify relations at a higher level, avoiding having to mess with foreign keys etc.. I'd like to just decla...
3
2008-10-30T14:41:50Z
1,094,626
<p>Look at the "Configuring Relations" section of the <a href="http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html" rel="nofollow">Declarative docs</a>. Not quite as high level as "OneToMany" but better than fully specifying the relation. </p> <pre><code>class Address(Base): __tablename__ = 'address...
0
2009-07-07T20:19:52Z
[ "python", "sqlalchemy" ]
Is it possible to communicate with a sub subprocess with subprocess.Popen?
250,700
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl...
5
2008-10-30T15:50:51Z
250,804
<p>The simplest thing to do would be the run the controlling script (the Python script) via <code>sudo</code>. Are you able to do that, or is that not an option?</p>
1
2008-10-30T16:22:51Z
[ "python", "subprocess" ]
Is it possible to communicate with a sub subprocess with subprocess.Popen?
250,700
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl...
5
2008-10-30T15:50:51Z
250,819
<p>I think you should remove the <code>sudo</code> in your <code>Popen</code> call and require the user of <em>your</em> script to type <code>sudo</code>.</p> <p>This additionally makes more explicit the need for elevated privileges in your script, instead of hiding it inside <code>Popen</code>.</p>
3
2008-10-30T16:26:41Z
[ "python", "subprocess" ]
Is it possible to communicate with a sub subprocess with subprocess.Popen?
250,700
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl...
5
2008-10-30T15:50:51Z
251,052
<p>We need more information.</p> <ol> <li>Is sudo asking you for a password?</li> <li>What kind of interface does the mod script have for asking questions?</li> </ol> <p>Because these kind of things are not handled as normal over the pipe.</p> <p>A solution for both of these might be <a href="http://www.noah.org/wik...
0
2008-10-30T17:29:43Z
[ "python", "subprocess" ]
Is it possible to communicate with a sub subprocess with subprocess.Popen?
250,700
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl...
5
2008-10-30T15:50:51Z
252,100
<p>I would choose to go with Pexpect. </p> <pre><code>import pexpect child = pexpect.spawn ('sudo mod -p -c noresource -u dtt -Q') child.expect ('First question:') child.sendline ('Y') child.expect ('Second question:') child.sendline ('Yup') </code></pre>
4
2008-10-30T23:10:26Z
[ "python", "subprocess" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
251,469
<pre><code>my_function.func_name </code></pre> <p>There are also other fun properties of functions. Type <code>dir(func_name)</code> to list them. <code>func_name.func_code.co_code</code> is the compiled function, stored as a string.</p> <pre><code>import dis dis.dis(my_function) </code></pre> <p>will display the co...
32
2008-10-30T19:39:19Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
255,297
<pre><code>my_function.__name__ </code></pre> <p>Using <code>__name__</code> is the preferred method as it applies uniformly. Unlike <code>func_name</code>, it works on built-in functions as well:</p> <pre><code>&gt;&gt;&gt; import time &gt;&gt;&gt; time.time.func_name Traceback (most recent call last): File "&lt;s...
357
2008-11-01T00:07:17Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
13,514,318
<p>You could also use</p> <pre><code>import sys this_function_name = sys._getframe().f_code.co_name </code></pre>
116
2012-11-22T13:59:49Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
18,543,271
<p>sys._getframe() is not guaranteed to be available in all implementations of Python (<a href="http://docs.python.org/2/library/sys.html">see ref</a>) ,you can use the traceback module to do the same thing, eg.</p> <pre><code>import traceback def who_am_i(): stack = traceback.extract_stack() filename, codeline,...
6
2013-08-31T00:34:37Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
20,714,270
<p>This function will return the caller's function name.</p> <pre><code>def func_name(): import traceback return traceback.extract_stack(None, 2)[0][2] </code></pre> <p>It is like Albert Vonpupp's answer with a friendly wrapper.</p>
21
2013-12-21T00:59:58Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
25,130,006
<p>For readability, as string are highlighted by most editors, I would just create an object like this:</p> <pre><code>def my_function(): f_name = 'my_function' </code></pre> <p>Which is less code characters than the "correct" way to fetch:</p> <pre><code>def my_function(): f_name = my_function.__nam...
-6
2014-08-05T01:38:44Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
36,228,241
<p>As an extension of <a href="http://stackoverflow.com/a/20714270/109941">@Demyn's answer</a>, I created some utility functions which print the current function's name and current function's arguments:</p> <pre><code>import inspect import logging import traceback def get_function_name(): return traceback.extract...
1
2016-03-25T21:21:23Z
[ "python", "string", "function" ]
How to get a function name as a string in Python?
251,464
<p>In Python, how do I get a function name as a string without calling the function?</p> <pre><code>def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes </code></pre> <p>should output <code>"my_function"</code>.</p> <p>Is this available in python? If not, any ide...
306
2008-10-30T19:38:24Z
38,453,402
<p>I like using a function decorator. I added a class, which also times the function time. Assume gLog is a standard python logger:</p> <pre><code>class EnterExitLog(): def __init__(self, funcName): self.funcName = funcName def __enter__(self): gLog.debug('Started: %s' % self.funcName) ...
0
2016-07-19T08:37:30Z
[ "python", "string", "function" ]
script languages on windows mobile - something similar to python @ nokia s60
251,506
<p>I try to find something similar to nokia's <strong>python for windows mobile</strong> based devices - a script interpreter [in this case also able to create standalone apps] with easy access to all phone interfaces - ability to make a phone call, send SMS, make a photo, send a file over GPRS, etc...</p> <p>While th...
3
2008-10-30T19:48:59Z
251,533
<p>Well there is <a href="http://www.sto-helit.de/index.php?module=download&amp;action=list&amp;category=18" rel="nofollow">Mortscript</a>. a widely used scripting for Windows Mobile. Not sure if it can access all the phones functions. I believe there is <a href="http://www.kocjan.org/tclmentor/1-tcl/17-tcl-on-windows-...
0
2008-10-30T19:56:46Z
[ "python", "windows-mobile", "mobile" ]
script languages on windows mobile - something similar to python @ nokia s60
251,506
<p>I try to find something similar to nokia's <strong>python for windows mobile</strong> based devices - a script interpreter [in this case also able to create standalone apps] with easy access to all phone interfaces - ability to make a phone call, send SMS, make a photo, send a file over GPRS, etc...</p> <p>While th...
3
2008-10-30T19:48:59Z
252,150
<p>It sounds as if this is an opportunity for you to develop some C extension modules for the PythonCE project.</p>
3
2008-10-30T23:36:00Z
[ "python", "windows-mobile", "mobile" ]
script languages on windows mobile - something similar to python @ nokia s60
251,506
<p>I try to find something similar to nokia's <strong>python for windows mobile</strong> based devices - a script interpreter [in this case also able to create standalone apps] with easy access to all phone interfaces - ability to make a phone call, send SMS, make a photo, send a file over GPRS, etc...</p> <p>While th...
3
2008-10-30T19:48:59Z
252,399
<p>IronPython?</p>
0
2008-10-31T01:53:11Z
[ "python", "windows-mobile", "mobile" ]
What is the best way to serve static web pages from within a Django application?
252,035
<p>I am building a relatively simple <a href="http://en.wikipedia.org/wiki/Django_%28web_framework%29" rel="nofollow">Django</a> application and apart from the main page where most of the dynamic parts of the application are, there are a few pages that I will need that will not be dynamic at all (<em>About</em>, <em>FA...
3
2008-10-30T22:47:20Z
252,039
<p>Have you looked at <a href="http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#ref-contrib-flatpages" rel="nofollow">flat pages</a> in Django? It probably does everything you're looking for.</p>
6
2008-10-30T22:49:35Z
[ "python", "django", "static", "templates" ]
What is the best way to serve static web pages from within a Django application?
252,035
<p>I am building a relatively simple <a href="http://en.wikipedia.org/wiki/Django_%28web_framework%29" rel="nofollow">Django</a> application and apart from the main page where most of the dynamic parts of the application are, there are a few pages that I will need that will not be dynamic at all (<em>About</em>, <em>FA...
3
2008-10-30T22:47:20Z
252,057
<p>If you want to just create a template for each of them, you could use the <a href="https://docs.djangoproject.com/en/1.4/ref/generic-views/#django-views-generic-simple-direct-to-template" rel="nofollow"><code>direct_to_template</code></a> generic view to serve it up.</p> <p>Another option would be the <a href="http...
6
2008-10-30T22:57:13Z
[ "python", "django", "static", "templates" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
252,296
<p>What if it doesn't mean anything, what if it is just a neat design they came up with?</p>
2
2008-10-31T00:58:21Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
252,329
<p>I think Google are just trying to drive their point home - here are a bunch of different representations of the same page, test them, see which is best.</p> <p>Which block do you like best?</p>
5
2008-10-31T01:11:56Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
252,344
<p>Well, I can't see an immediate pattern. But if you are testing IP, why not take two blocks of 4 as a single binary number.</p>
0
2008-10-31T01:18:59Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
252,345
<p>I think it's <em>simply</em> a design, nothing secret, or mysterious.</p>
5
2008-10-31T01:20:12Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
260,580
<p>I emailed the Website Optimizer Team, and they said "There's no secret code, unless you find one. :)"</p>
15
2008-11-04T01:46:39Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
260,595
<p>It says: "You are getting closer".</p>
1
2008-11-04T02:05:50Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
483,491
<p>Probably it's a base 4 notation?</p> <p>I would try that, but I don't have any approach to this.</p>
0
2009-01-27T14:02:38Z
[ "python" ]
Possible Google Riddle?
252,221
<p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p> <p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow">t-shirt</a></p> <p>So, I have a couple of guesses as to what...
11
2008-10-31T00:14:12Z
3,260,996
<p>It reminded me of cellular automata:</p> <p><a href="http://www.wolframalpha.com/input/?i=rule+110" rel="nofollow">http://www.wolframalpha.com/input/?i=rule+110</a></p> <p>Anyone going that direction?</p>
0
2010-07-16T00:01:32Z
[ "python" ]
Bizarre python ImportError
252,287
<p>Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive.</p> <p>I have two files in a directory of my Mac home directory:</p> <h3>foo.py</h3> <pre><code>pass </code></pre> <h3>test.py</h3> <pre><code>import...
3
2008-10-31T00:54:55Z
252,299
<p>Add import sys; print sys.path to the start of test.py. See what it prints out in the failing case. If "." isn't on the list, that may be your problem.</p>
2
2008-10-31T00:58:31Z
[ "python", "import", "windows-xp" ]
Bizarre python ImportError
252,287
<p>Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive.</p> <p>I have two files in a directory of my Mac home directory:</p> <h3>foo.py</h3> <pre><code>pass </code></pre> <h3>test.py</h3> <pre><code>import...
3
2008-10-31T00:54:55Z
254,355
<p>As a random guess: are the permissions on foo.py accessable from the windows client? (eg try opening with notepad from the virtual machine).</p> <p>If that's OK, try running:</p> <pre><code>python -v -v test.py </code></pre> <p>and looking at the output (alternatively, set PYTHONVERBOSE=2). This should list all ...
1
2008-10-31T17:49:25Z
[ "python", "import", "windows-xp" ]