Results 1 through
20
while searching for:
"python"
How can you avoid having to manually compile a Cheetah template all the time?
Try something like this:
user# cd location-of-templates
user# dnotify -MCDR -r -q 0 . -e cheetah c -R --nobackup --odir ../template-bin .
http://rockfloat.com/board/post/?id=573
May 26, 2007 @06:59
(Replies: 0)
(Rank: 0.076)
python
How do you avoid restarting Apache all the time when working with mod_python?
First put this in your Apache vhost configuration:
PythonAutoReload On
PythonDebug On
Then make sure Apache isn't running, and start it up manually telling it to run as a single process. Here's how I do it on Gentoo Linux:
user$ sudo /usr/
[...]
http://rockfloat.com/board/post/?id=574
May 26, 2007 @07:07
(Replies: 0)
(Rank: 0.076)
python
How do you properly return the fqdn (domain.hostnname) using python?
You can get these from the socket module.
user# python
user# >>> import socket
user# >>> print socket.getfqdn(socket.gethostname())
It's important to note here, that hostname when called under unix should not return the full fqdn. If it does
[...]
http://rockfloat.com/board/post/?id=604
January 19, 2009 @21:43
(Replies: 0)
(Rank: 0.061)
python
How do you install python bindings to gtksourceview in Gentoo?
try:
root# emerge -a gnome-python-desktop
John M.
http://rockfloat.com/board/post/?id=572
May 25, 2007 @03:48
(Replies: 0)
(Rank: 0.061)
python
How do you sort a list of dictionaries? Or sort a list based on the it's contents?
Try this:
a = []
a.append({'name':'chris 4', 'count':4})
a.append({'name':'chris 40', 'count':40})
a.append({'name':'chris3', 'count':3})
a.append({'name':'chris400', 'count':400})
from operator import itemgetter
result = sorted(a, key=i
[...]
http://rockfloat.com/board/post/?id=518
May 21, 2006 @00:13
(Replies: 0)
(Rank: 0.061)
python
How do you best generate a pdf of python code?
Try:
user# a2ps -2 --medium=LETTER --line-numbers=1 -o ~/Desktop/code.ps /path/to/code/*.py
user# ps2pdf code.ps
John M.
http://rockfloat.com/board/post/?id=577
June 08, 2007 @13:44
(Replies: 0)
(Rank: 0.000)
What are the mod_python apache code constants?
From /usr/lib/python2.3/site-packages/mod_python/apache.py
## Some constants
HTTP_CONTINUE = 100
HTTP_SWITCHING_PROTOCOLS = 101
HTTP_PROCESSING = 102
HTTP_OK = 200
H
[...]
http://rockfloat.com/board/post/?id=61
May 15, 2005 @01:21
(Replies: 0)
(Rank: 0.000)
how do you install the Apple python class?
Try:
user# tar zxvf Apple-1.2.3.tar.gz
user# cd Apple-1.2.3
user# sudo python setup.py install
after doing this you can then use the Apple class from anywhere, here's a hello world to test with:
-----
#!/usr/bin/env python
import app
[...]
http://rockfloat.com/board/post/?id=90
November 16, 2003 @05:17
(Replies: 0)
(Rank: 0.000)
How do you run test.py after installing mod_python via portage?
Here's what I use:
http://rockfloat.com/files/public/?d=/ebuilds/mod_python
user# sudo emerge -a mod_python
user# tar zxvf mod_python-3.2.5b.tgz
user# cd mod_python-3.2.5b
user# ./configure --with-apxs=/usr/sbin/apxs2
user# cp /usr/lib/apac
[...]
http://rockfloat.com/board/post/?id=497
November 15, 2005 @07:41
(Replies: 0)
(Rank: 0.000)
Re: Graphs
I find the python module Matplotlib to be very good. Here is a quick tutorial on how to use it:
http://rockfloat.com/howto/python-matplotlib.html
Here's a snippet:
#! /usr/bin/env python
from matplotlib.matlab import *
t = arange(0.
[...]
http://rockfloat.com/board/post/?id=484
October 01, 2005 @18:16
(Replies: 0)
(Rank: 0.000)
Graphs
hello
I am Adam in Mr. Deprato's computer class.
I was wondering
What would be the best way to create linear graphs in Python??
http://rockfloat.com/board/post/?id=482
October 01, 2005 @07:54
(Replies: 1)
(Rank: 0.000)
How do you test Python speed using timeit?
try something like this:
import timeit
timeit.Timer('a = [2, 5, 99, 5, 3, 4]; a.sort(); a.reverse()', 'gc.enable()').timeit()
John M.
http://rockfloat.com/board/post/?id=521
May 24, 2006 @03:38
(Replies: 0)
(Rank: 0.000)
How do you base64 encode a file in dotnet?
This should get you started:
'# Example in vb.net:
Dim str_file As String
Dim arr_data() As Byte
Dim str_base64 As String
Dim fs_outputfile As New System.IO.StreamWriter("test-base64.txt")
str_file = New System.IO.StreamReader("test.txt").Rea
[...]
http://rockfloat.com/board/post/?id=515
May 08, 2006 @20:13
(Replies: 0)
(Rank: 0.000)
Re: Re: Looping
For example, we're working on a simple math game in class, and at the end of the game, we want to have a "play again" option. How would we command python to restart the game, although not discard the old game just played.
In other words, the game is
[...]
http://rockfloat.com/board/post/?id=489
October 05, 2005 @08:17
(Replies: 0)
(Rank: 0.000)
Re: Global Variables
Very good question. I'm no expert, but I believe global variables should be avoided if possible. Python is very namespace centric, which makes it very clear where information is comming from. If you specify a variable to be global it makes it much e
[...]
http://rockfloat.com/board/post/?id=485
October 01, 2005 @18:20
(Replies: 0)
(Rank: 0.000)
Global Variables
Are global variable good to use in Python or should they be avoided? I have heard different arguements on this topic.
TD
http://rockfloat.com/board/post/?id=486
October 01, 2005 @07:47
(Replies: 1)
(Rank: 0.000)
How do you check for gentoo security updates not found in emerge -uDa world?
Try:
user# glsa-check --list $(glsa-check --test new)
Just remember you'll probably see all sorts of glsa's that don't make sense. This is usually because you have stuff installed that was masked (because of old age) before you uninstalled it
[...]
http://rockfloat.com/board/post/?id=510
September 22, 2005 @04:12
(Replies: 1)
(Rank: 0.000)
Having problems with py2html and viewcvs where the python syntax and color formatting isn't working
You probably need an updated py2html.py and PyFontify.py
Place the above files from: http://openlook.org/distfiles/py2html-0.7.tar.gz
into: /var/www/localhost/viewcvs/lib
John M.
http://rockfloat.com/board/post/?id=43
June 15, 2005 @13:19
(Replies: 0)
(Rank: 0.000)
Is there a dateAdd() function for python?
it sucks, but no.
try this:
<div class="code">
def dateAdd(strUnit, intDelta, objDate):
"""Return a date object x units from a given date:
Usage: functions.dateAdd('days', -5, datetime.datetime.now())
this would return a
[...]
http://rockfloat.com/board/post/?id=80
November 08, 2004 @21:50
(Replies: 0)
(Rank: 0.000)
how to you configure python on freebsd to use tkinter?
very easy:
just install the py23-tkinter port:
/usr/ports/x11-toolkits/py-tkinter
then you can make and execute your hello world script:
#!/usr/bin/env python
from sys import exit
from Tkinter import *
root = Tk()
Button(root, te
[...]
http://rockfloat.com/board/post/?id=105
September 15, 2003 @01:52
(Replies: 0)
(Rank: 0.000)