Re: converting 64-bit fixed-point to float

2007-07-21 Thread John Machin
On Jul 22, 10:34 am, [EMAIL PROTECTED] (John Fisher) wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > On Jul 20, 5:59 pm, [EMAIL PROTECTED] (John Fisher) wrote:
> > > Hi Group,
>
> > > troubles with converting signed 32.32, little-endian, 2's complement
> > > back to floating point. I have been trying to brew it myself. I am
> > > running Python 2.5 on a Mac. Here is the C-code I have been trying to
> > > leverage:
>
> > >  double FPuint8ArrayToFPDouble(uint8 *buffer, int startIndex)
> > > {
> > >   uint32 resultDec = 0;
> > >   uint32 resultWh = 0;
> > >   int i;
>
> > >   for(i = 0; i < 4; i++)
> > >   {
> > > resultDec += (uint32)buffer[startIndex + i] * pow(2, (i*8));
> > > resultWh += (uint32)buffer[startIndex + i + 4] * pow(2, (i*8));
> > >   }
>
> > >   return ( (double)((int)resultWh) + (double)(resultDec)/4294967296.0 );
>
> > > }
>
> > There are a few problem spots in that C code.  I tend to
> > think that it "works" because you're on a system that has
> > 4-byte int and CHAR_BIT == 8.  When the most-significant-bit (MSB)
> > of resultWh is 1, then casting to int makes that a negative
> > value (i.e., MSB == the sign bit).
>
> > I presume that somewhere you include  (from C99)
> > and that uint32 is really uint32_t, etc.  For that to be
> > portable, you should probably cast to int32_t?
>
> > #include 
> > #include 
> > #include 
>
> > double arr2dbl (uint8_t *buffer, int startIndex)
> > {
> > uint32_t decimal = 0;
> > uint32_t whole = 0;
> > size_t i;
> > for (i = 0; i < 4; ++i)
> > {
> > decimal += (buffer[startIndex + i] << (i*8));
> > whole += (buffer[startIndex + i + 4] << (i*8));
> > }
> > return (int32_t)whole + (decimal/(UINT32_MAX+1.0));
> > }
>
> > int main (void)
> > {
> > uint8_t arr[7][8] = {
> > {0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff},
> > {0, 0, 0, 0, 0, 0, 0, 0},
> > {51, 51, 51, 51, 0, 0, 0, 0},
> > {0, 0, 0, 0, 1, 0, 0, 0},
> > {0, 0, 0, 0, 2, 0, 0, 0},
> > {102, 102, 102, 38, 42, 1, 0, 0 },
> > {205, 204, 204, 204, 0xff, 0xff, 0xff, 0xff}};
> > size_t i;
> > double result;
> > for (i = 0; i < sizeof arr/sizeof arr[0]; ++i)
> > {
> > result = arr2dbl(arr[i], 0);
> > printf("%f\n", result);
> > }
> > return 0;
> > }
>
> > > Here is my version in Python, with some test code built in:
>
> > > from ctypes import *
>
> > > def conv64(input):
> > > input1=[0]*8
> > > input1[0]=c_ushort(input[0])
> > > input1[1]=c_ushort(input[1])
> > > input1[2]=c_ushort(input[2])
> > > input1[3]=c_ushort(input[3])
> > > input1[4]=c_ushort(input[4])
> > > input1[5]=c_ushort(input[5])
> > > input1[6]=c_ushort(input[6])
> > > input1[7]=c_ushort(input[7])
> > > #print input1[0].value,
> > > input1[1].value,input1[2].value,input1[3].value
> > > #print
> > > input1[4].value,input1[5].value,input1[6].value,input1[7].value
> > > #print
> > > resultDec=c_ulong(0)
> > > resultWh=c_ulong(0)
> > > for i in range(4):
> > > dec_c=c_ulong(input1[i].value)
> > > Wh_c=c_ulong(input1[i+4].value)
> > > resultDec.value=resultDec.value+dec_c.value*2**(i*8)
> > > resultWh.value=resultWh.value+Wh_c.value*2**(i*8)
> > >conval=float(int(resultWh.value))+float(resultDec.value)/4294967296.0
> > > #print conval
> > > return conval
> > > #tabs got messed up bringing this into MacSoup
>
> > (snipped)
>
> > > Finally, here is the output I get from my code:
>
> > > output should be -1 is 4294967296.0
> > > output should be 0 is 0.0
> > > output should be 0.2 is 0.1953
> > > output should be 1 is 1.0
> > > output should be 2 is 2.0
> > > output should be 298.15 is 298.15
> > > output should be -0.2 is 4294967295.8
>
> > > Thanks for any light you can shed on my ignorance.
>
> > > wave_man
>
> > This is my translation:
>
> > from ctypes import *
>
> > def conv64(input):
> > input1 = [c_uint8(item) for item in input]
> > dec = c_uint32(0)
> > whl = c_uint32(0)
> > for i in xrange(4):
> > dec.value += (input1[i].value << (i*8))
> > whl.value += (input1[i+4].value << (i*8))
> > cast_whl_to_int = c_int32(whl.value)
> > return float(cast_whl_to_int.value + dec.value/4294967296.0)
>
> > for arr in [[0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff],
> > [0, 0, 0, 0, 0, 0, 0, 0],
> > [51, 51, 51, 51, 0, 0, 0, 0],
> > [0, 0, 0, 0, 1, 0, 0, 0],
> > [0, 0, 0, 0, 2, 0, 0, 0],
> > [102, 102, 102, 38, 42, 1, 0, 0],
> > [205,204,204,204,255,255,255,255]]:
> > print "%f" % conv64(arr)
>
> > However, I've not looked deeply into ctypes so I
> > don't know if c_int32 is really C's int, or int32_t, or ???
>
> > --
> > Hope this helps,
> > Steven
>
> Actually this was very helpful, thanks.
>

Holy code bloat, Batman! The following appears to give the same
results as Steven's code ...

def conv64jm(input):
# 

Re: Sort lines in a text file

2007-07-21 Thread John Machin
On Jul 22, 1:03 pm, leegold <[EMAIL PROTECTED]> wrote:
> say I have a text file:
>
> zz3 uaa4a ss 7 uu
>   zz 3 66 ppazz9
> a0zz0
>
> I want to sort the text file. I want the key to be the number after
> the two "zz".  Or I guess a string of two zz then a numberSo
> that's 3, 9, 0
>
> I'm trying to say that I want to sort lines in a file based on a
> regular expression. How could I do that in Python? I'm limited to
> Python 2.1, I can't add any 2nd party newer tools.

To save anybody who's tempted to write the whole shebang for you,
please specify which part(s) of the exercise you are having problems
with:
(a) reading lines from a file
(b) extracting a sort key from a line [presuming "number" means
"positive integer"; what do you want to do if multiple lines have the
same number? what if no number at all"]
(c) creating a list of tuples, where each tuple is (key,
line_contents)
(d) sorting the list
(e) creating the output file from the sorted list.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Jay Loden
Gilles Ganault wrote:
> Problem is, when I add re.DOTLINE, the search takes less than a second
> for a 500KB file... and about 1mn30 for a file that's 1MB, with both
> files holding similar contents.
> 
> Why such a huge difference in performance?
> 
> = Using Re =
> import re
> import time
> 
> pattern = "(\d+:\d+).*?"
> 
> pages = ["500KB.html","1MB.html"]
> 
> #Veeery slow when parsing 1MB file !
> p = re.compile(pattern,re.IGNORECASE|re.MULTILINE|re.DOTALL)
> #p = re.compile(pattern,re.IGNORECASE|re.MULTILINE)
> 
> for page in pages:
>   f = open(page, "r") 
>   response = f.read() 
>   f.close()
> 
>   start = time.strftime("%H:%M:%S", time.localtime(time.time()))
>   print "before findall @ " + start
>   packed = p.findall(response)
>   if packed:
>   for item in packed:
>   print item
> ===
> 

I don't know if it'll result in a performance difference, but since you're just 
saving the result of re.findall() to a variable in order to iterate over it, 
you might as well just use re.finditer() instead:

for item in p.finditer(response):
print item

At least then it can start printing as soon as it hits a match instead of 
needing to find all the matches first.

-Jay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Gilles Ganault
On Sat, 21 Jul 2007 22:18:56 -0400, Carsten Haese
<[EMAIL PROTECTED]> wrote:
>That's your problem right there. RE is not the right tool for that job.
>Use an actual HTML parser such as BeautifulSoup

Thanks a lot for the tip. I tried it, and it does look interesting,
although I've been unsuccessful using a regex with BS to find all
occurences of the pattern.

Incidently, as far as using Re alone is concerned, it appears that
re.MULTILINE isn't enough to get Re to include newlines: re.DOTLINE
must be added.

Problem is, when I add re.DOTLINE, the search takes less than a second
for a 500KB file... and about 1mn30 for a file that's 1MB, with both
files holding similar contents.

Why such a huge difference in performance?

= Using Re =
import re
import time

pattern = "(\d+:\d+).*?"

pages = ["500KB.html","1MB.html"]

#Veeery slow when parsing 1MB file !
p = re.compile(pattern,re.IGNORECASE|re.MULTILINE|re.DOTALL)
#p = re.compile(pattern,re.IGNORECASE|re.MULTILINE)

for page in pages:
f = open(page, "r") 
response = f.read() 
f.close()

start = time.strftime("%H:%M:%S", time.localtime(time.time()))
print "before findall @ " + start
packed = p.findall(response)
if packed:
for item in packed:
print item
===

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Sort lines in a text file

2007-07-21 Thread leegold
say I have a text file:

zz3 uaa4a ss 7 uu
  zz 3 66 ppazz9
a0zz0

I want to sort the text file. I want the key to be the number after
the two "zz".  Or I guess a string of two zz then a numberSo
that's 3, 9, 0

I'm trying to say that I want to sort lines in a file based on a
regular expression. How could I do that in Python? I'm limited to
Python 2.1, I can't add any 2nd party newer tools.

Thanks
Lee G.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regex doesn't support MULTILINE?

2007-07-21 Thread Tony Meyer
> I'm trying to extract information from a web page using the Re module,
> but it doesn't seem to support MULTILINE:
[...]
> Do I need to add something else to have Re work as intended?

I believe you are looking for DOTALL, not MULTILINE.  From the
documentation:

"""
M
MULTILINE
When specified, the pattern character "^" matches at the beginning of
the string and at the beginning of each line (immediately following
each newline); and the pattern character "$" matches at the end of the
string and at the end of each line (immediately preceding each
newline). By default, "^" matches only at the beginning of the string,
and "$" only at the end of the string and immediately before the
newline (if any) at the end of the string.

S
DOTALL
Make the "." special character match any character at all, including a
newline; without this flag, "." will match anything except a newline.
"""

If you do a lot of working with regular expressions, then I highly
recommend Kodos (http://kodos.sourceforge.net) as a tool for
interactively figuring out issues.

Cheers,
Tony Meyer

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] Python documentation team looking for members!

2007-07-21 Thread george williams
Take me off mailing list
thank you
george
- Original Message - 
From: "Georg Brandl" <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python.announce
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 21, 2007 4:10 AM
Subject: [ANN] Python documentation team looking for members!


> Dear fellow Pythonistas,
>
> as you may have heard, Python is going to get a new documentation system
> soon [1].  As part of that effort, and in order to maintain the excellent
> quality of the docs, we are looking for members of the maintainers team.
> This is your chance to get involved with Python development!
>
> There will be two main objectives of the group, or maybe two subgroups can
> be formed:
>
> * Maintaining the documentation contents:
>- processing user submitted comments, bugs and patches
>- helping out developers with docs-related matters, keeping an eye
>  on commits to ensure quality
>- keeping the docs up-to-date, e.g. write new sections for new
>  Python 3000 features
>
>The docs source will be in reStructuredText, which is already known to 
> a
>relatively high percentage of Python developers.
>
>The new online version of the docs will contain features to add 
> comments
>and suggest changes, so it is expected that there will be some amount
>of user involvement.
>
>
> * Development of the toolset:
>- fixing bugs in the package
>- adding new output formats, e.g. info or pdf
>- adding new features to the web application
>- adapting it to new docutils features
>
>The software is written in pure Python. It is currently located in the
>docutils Subversion repository, at
>http://svn.berlios.de/viewcvs/docutils/trunk/sandbox/py-rest-doc/
>
>The README file gives you a rough idea what you find there and how to
>get started, all other questions can be directed to [EMAIL PROTECTED],
>I'll answer them gladly.
>
>
> An additional objective in the near future will, of course, be handling 
> the
> switch to the new system.
>
> Okay, so you've read until here? And you're interested in joining the 
> team?
> Wow! Write to the [EMAIL PROTECTED] and become a documentation maintainer!
>
> cheers,
> Georg
>
>
> [1] see http://pyside.blogspot.com/2007/06/introducing-py-rest-doc.html
>  for some details, and http://pydoc.gbrandl.de:3000/ [2] for a demo.
>  (Commenting doesn't work yet, but it's worked upon fiercely...)
>
> [2] the demo server is a small vserver with the application served by a
>  single wsgiref instance, and as such not fit to handle large amounts
>  of requests, so it may well be that you don't get good reponse times.
> -- 
> http://mail.python.org/mailman/listinfo/python-announce-list
>
>Support the Python Software Foundation:
>http://www.python.org/psf/donations.html
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Carsten Haese
On Sat, 2007-07-21 at 19:22 -0700, Paul Rubin wrote:
> Carsten Haese <[EMAIL PROTECTED]> writes:
> > Use an actual HTML parser such as BeautifulSoup
> > (http://www.crummy.com/software/BeautifulSoup/) and your life will be
> > much easier.
> 
> BeautifulSoup is a lot simpler to use than RE's but a heck of a lot
> slower.  I ended up having to use RE's last time I had to scrape a lot
> of pages.

True, but the OP said "extract information from a web page", not "from a
lot of pages." Until BeautifulSoup is actually too slow for that job,
going straight to RE is premature optimization.

-- 
Carsten Haese
http://informixdb.sourceforge.net


-- 
http://mail.python.org/mailman/listinfo/python-list


simpleJSON pack binary data

2007-07-21 Thread Andrey
Hi

I donno if this is the right place to ask for this question, anyway

Is it possible to pack binary data into simplejson?

d={}
d['date'] = xx
d['name'] = xx
d['size'] = x

d['imageBinaryDataJpeg'] = jpegBinaryDataFromcStringIOStringIO

simplejson.dumps(d)

when i do this, it raises a UTF8 decode error, probably about the binary 
image data

My question is, anyone will suggest a workaround to this error?
i really like to pack my raw image data into the JSON, so my other 
programming script can read the array easily

Thanks
An K




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Paul Rubin
Carsten Haese <[EMAIL PROTECTED]> writes:
> Use an actual HTML parser such as BeautifulSoup
> (http://www.crummy.com/software/BeautifulSoup/) and your life will be
> much easier.

BeautifulSoup is a lot simpler to use than RE's but a heck of a lot
slower.  I ended up having to use RE's last time I had to scrape a lot
of pages.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Carsten Haese
On Sun, 2007-07-22 at 04:09 +0200, Gilles Ganault wrote:
> Hello
> 
> I'm trying to extract information from a web page using the Re module,

That's your problem right there. RE is not the right tool for that job.
Use an actual HTML parser such as BeautifulSoup
(http://www.crummy.com/software/BeautifulSoup/) and your life will be
much easier.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyodbc on linux

2007-07-21 Thread ajaksu
On Jul 21, 5:54 pm, Sean Davis <[EMAIL PROTECTED]> wrote:
> I have read a couple of blogs suggesting that pyodbc is buildable
> under linux.

It is, following these wise words:
"Aargghh! I see that possibly there was a typo in cursor.cpp at line
1385:

Py_UNICODE* pNull = (Py_UNICODE*)wmemchr(pT, 0, cch)

should be

Py_UNICODE* pNull = (Py_UNICODE*)memchr(pT, 0, cch)


Anyway, uncommented what I had commented out and changed the wmemchr
to
wmemchr and everything compiled."
>From 
>http://sourceforge.net/tracker/index.php?func=detail&aid=1731205&group_id=162557&atid=824254
(I just did it a few hours ago, quite a coincidence :))

HTH,
Daniel


-- 
http://mail.python.org/mailman/listinfo/python-list


[2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Gilles Ganault
Hello

I'm trying to extract information from a web page using the Re module,
but it doesn't seem to support MULTILINE:

=
import re

#NO CRLF : works
response = "Blablabla"
#CRLF : doesn't work
response = "Blablabla\r\n"

pattern = "Bla.+?"

p = re.compile(pattern,re.IGNORECASE|re.MULTILINE)
m = p.search(response)

if m:
print m.group(1)
else:
print "Not found"
=

Do I need to add something else to have Re work as intended?

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: converting 64-bit fixed-point to float

2007-07-21 Thread John Fisher
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> On Jul 20, 5:59 pm, [EMAIL PROTECTED] (John Fisher) wrote:
> > Hi Group,
> >
> > troubles with converting signed 32.32, little-endian, 2's complement
> > back to floating point. I have been trying to brew it myself. I am
> > running Python 2.5 on a Mac. Here is the C-code I have been trying to
> > leverage:
> >
> >  double FPuint8ArrayToFPDouble(uint8 *buffer, int startIndex)
> > {
> >   uint32 resultDec = 0;
> >   uint32 resultWh = 0;
> >   int i;
> >
> >   for(i = 0; i < 4; i++)
> >   {
> > resultDec += (uint32)buffer[startIndex + i] * pow(2, (i*8));
> > resultWh += (uint32)buffer[startIndex + i + 4] * pow(2, (i*8));
> >   }
> >
> >   return ( (double)((int)resultWh) + (double)(resultDec)/4294967296.0 );
> >
> > }
> 
> 
> There are a few problem spots in that C code.  I tend to
> think that it "works" because you're on a system that has
> 4-byte int and CHAR_BIT == 8.  When the most-significant-bit (MSB)
> of resultWh is 1, then casting to int makes that a negative
> value (i.e., MSB == the sign bit).
> 
> I presume that somewhere you include  (from C99)
> and that uint32 is really uint32_t, etc.  For that to be
> portable, you should probably cast to int32_t?
> 
> #include 
> #include 
> #include 
> 
> double arr2dbl (uint8_t *buffer, int startIndex)
> {
> uint32_t decimal = 0;
> uint32_t whole = 0;
> size_t i;
> for (i = 0; i < 4; ++i)
> {
> decimal += (buffer[startIndex + i] << (i*8));
> whole += (buffer[startIndex + i + 4] << (i*8));
> }
> return (int32_t)whole + (decimal/(UINT32_MAX+1.0));
> }
> 
> int main (void)
> {
> uint8_t arr[7][8] = {
> {0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff},
> {0, 0, 0, 0, 0, 0, 0, 0},
> {51, 51, 51, 51, 0, 0, 0, 0},
> {0, 0, 0, 0, 1, 0, 0, 0},
> {0, 0, 0, 0, 2, 0, 0, 0},
> {102, 102, 102, 38, 42, 1, 0, 0 },
> {205, 204, 204, 204, 0xff, 0xff, 0xff, 0xff}};
> size_t i;
> double result;
> for (i = 0; i < sizeof arr/sizeof arr[0]; ++i)
> {
> result = arr2dbl(arr[i], 0);
> printf("%f\n", result);
> }
> return 0;
> }
> 
> 
> 
> 
> 
> 
> 
> > Here is my version in Python, with some test code built in:
> >
> > from ctypes import *
> >
> > def conv64(input):
> > input1=[0]*8
> > input1[0]=c_ushort(input[0])
> > input1[1]=c_ushort(input[1])
> > input1[2]=c_ushort(input[2])
> > input1[3]=c_ushort(input[3])
> > input1[4]=c_ushort(input[4])
> > input1[5]=c_ushort(input[5])
> > input1[6]=c_ushort(input[6])
> > input1[7]=c_ushort(input[7])
> > #print input1[0].value,
> > input1[1].value,input1[2].value,input1[3].value
> > #print
> > input1[4].value,input1[5].value,input1[6].value,input1[7].value
> > #print
> > resultDec=c_ulong(0)
> > resultWh=c_ulong(0)
> > for i in range(4):
> > dec_c=c_ulong(input1[i].value)
> > Wh_c=c_ulong(input1[i+4].value)
> > resultDec.value=resultDec.value+dec_c.value*2**(i*8)
> > resultWh.value=resultWh.value+Wh_c.value*2**(i*8)
> >conval=float(int(resultWh.value))+float(resultDec.value)/4294967296.0
> > #print conval
> > return conval
> > #tabs got messed up bringing this into MacSoup
> 
> 
> (snipped)
> 
> 
> >
> > Finally, here is the output I get from my code:
> >
> >
> >
> > output should be -1 is 4294967296.0
> > output should be 0 is 0.0
> > output should be 0.2 is 0.1953
> > output should be 1 is 1.0
> > output should be 2 is 2.0
> > output should be 298.15 is 298.15
> > output should be -0.2 is 4294967295.8
> >
> > Thanks for any light you can shed on my ignorance.
> >
> > wave_man
> 
> 
> This is my translation:
> 
> from ctypes import *
> 
> def conv64(input):
> input1 = [c_uint8(item) for item in input]
> dec = c_uint32(0)
> whl = c_uint32(0)
> for i in xrange(4):
> dec.value += (input1[i].value << (i*8))
> whl.value += (input1[i+4].value << (i*8))
> cast_whl_to_int = c_int32(whl.value)
> return float(cast_whl_to_int.value + dec.value/4294967296.0)
> 
> 
> for arr in [[0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff],
> [0, 0, 0, 0, 0, 0, 0, 0],
> [51, 51, 51, 51, 0, 0, 0, 0],
> [0, 0, 0, 0, 1, 0, 0, 0],
> [0, 0, 0, 0, 2, 0, 0, 0],
> [102, 102, 102, 38, 42, 1, 0, 0],
> [205,204,204,204,255,255,255,255]]:
> print "%f" % conv64(arr)
> 
> 
> 
> However, I've not looked deeply into ctypes so I
> don't know if c_int32 is really C's int, or int32_t, or ???
> 
> --
> Hope this helps,
> Steven

Actually this was very helpful, thanks. 

Rgds,

wave_man
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with exec

2007-07-21 Thread Steven D'Aprano
On Sat, 21 Jul 2007 16:31:38 -0400, Steve Holden wrote:

> I'm afraid I don't understand this question. If you are talking about 
> the indentation of the code, if you don't want indentation you will have 
> to use braces - { and } - to indicate the nesting structure of your program.

Oh my, teasing the n00bs like that is not nice. You know Python doesn't
uses braces, it uses BEGIN ... END blocks.


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way for missing dict keys

2007-07-21 Thread genro
On Jul 19, 6:29 am, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>
> Myobject will be instanciated each time, yes.
>
> > and so if the initialization is expensive you
> > will probably see surprises.
>
> No "surprise" here, but it can indeed be suboptimal if instanciating
> myobject is costly.

What about this way ?

my_obj = my_dict.get(key) or my_dict.setdefault(key,myobject())

Ciao
G.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UTF-8 Support of Curses in Python 2.5

2007-07-21 Thread Andrey
Yes, it does solve the problem.
Compile python with ncursesw library.
Btw Ubuntu 7 has it "out of the box".


> Hi All,
> 
> Recently I ran into a problem with UTF-8 surrport when using curses
> library in python 2.5 in Fedora 7. I found out that the program using
> curses cannot print out unicode characters correctly on UTF-8 enabled
> console. I googled around and got an impression that the reason for
> this problem is that python is linked with libcurses library instead
> of libcursesw. The latter one is said to be able to solve this
> problem. Has anybody tried this? How to manually let python use
> libcursesw? Thanks a lot!
> 
> Here is a test program:
> 
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> import curses
> def keyloop(stdscr):
> # Clear the screen and display the menu of keys
> stdscr_y, stdscr_x = stdscr.getmaxyx()
> menu_y = (stdscr_y-3)-1
> str = u'This is my first curses python program. Press \'q\' to
> exit. (¤£™)'
> stdscr.addstr(menu_y, 4, str.encode('utf-8'))
> xpos = stdscr_x / 2
> ypos = stdscr_y / 2
> while (1):
> stdscr.move(ypos, xpos)
> c = stdscr.getch()
> if 0 < c < 256:
> c = chr(c)
> if c in 'Qq': break
> else: pass
> elif c == curses.KEY_UP and ypos > 0:   ypos -= 1
> elif c == curses.KEY_DOWN and ypos < stdscr_y - 1:  ypos += 1
> elif c == curses.KEY_LEFT and xpos > 0: xpos -= 1
> elif c == curses.KEY_RIGHT and xpos < stdscr_x - 1: xpos += 1
> else: pass
> def main(stdscr):
> keyloop(stdscr)
> if __name__ == '__main__':
> curses.wrapper(main)

-- 
http://mail.python.org/mailman/listinfo/python-list

The Convenience of Online Learning. The Benefits of a Respected Degree.Try Ellis College for Free.

2007-07-21 Thread KU
A fully accredited extension of The New York Institute of Technology
(NYIT),
Ellis College gives you the prestige of earning your Bachelor's Degree
from a respected university with the convenience of learning online on
your own schedule.
Whether you're looking to begin a new career or advance an existing
one, Ellis offers an array of flexible online
Undergraduate Degree programs to help you achieve your goal.

Fully Accredited. Esteemed Faculty.
An academic division of the New York Institute of Technology, Ellis
College is accredited by the Middle States Commission on Higher
Education, one of six regional accrediting bodies for higher education
recognized by the U.S. Secretary of Education.
Every Ellis instructor holds a Ph.D. or Masters Degree in their
subject matter, with nearly half of all teaching faculty holding a
Doctorate or other terminal degree.

Get a free guest pass to Ellis College and experience a fully-
accredited online college like no other.
You'll have access to Ellis CourseBites™ mini-courses, educational
Webcasts, and our interactive course demonstrations.
Getting started is easy! Just fill out the form to get your free pass.
Click Here:http://www.anrdoezrs.net/ot114fv2rz1GJKJOOOIGIHLOJLKI

-- 
http://mail.python.org/mailman/listinfo/python-list

The Convenience of Online Learning. The Benefits of a Respected Degree.Try Ellis College for Free.

2007-07-21 Thread KU
A fully accredited extension of The New York Institute of Technology
(NYIT),
Ellis College gives you the prestige of earning your Bachelor's Degree
from a respected university with the convenience of learning online on
your own schedule.
Whether you're looking to begin a new career or advance an existing
one, Ellis offers an array of flexible online
Undergraduate Degree programs to help you achieve your goal.

Fully Accredited. Esteemed Faculty.
An academic division of the New York Institute of Technology, Ellis
College is accredited by the Middle States Commission on Higher
Education, one of six regional accrediting bodies for higher education
recognized by the U.S. Secretary of Education.
Every Ellis instructor holds a Ph.D. or Masters Degree in their
subject matter, with nearly half of all teaching faculty holding a
Doctorate or other terminal degree.

Get a free guest pass to Ellis College and experience a fully-
accredited online college like no other.
You'll have access to Ellis CourseBites™ mini-courses, educational
Webcasts, and our interactive course demonstrations.
Getting started is easy! Just fill out the form to get your free pass.
Click Here:http://www.anrdoezrs.net/ot114fv2rz1GJKJOOOIGIHLOJLKI

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python in Nashville

2007-07-21 Thread Erik Jones
Me!  Did you just move here?

On Jul 20, 2007, at 10:22 PM, Patrick Altman wrote:

> Anyone on this group writing Python code in Nashville, TN?
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list

Erik Jones

Software Developer | Emma®
[EMAIL PROTECTED]
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError

2007-07-21 Thread Ken Seehart
Um, never mind.  The recent unicode conversation gave me my answer  :-)
unicode(s, 'Windows-1252')

Ken Seehart wrote:
> I get this whenever I encounter a non-ascii character in a non-unicode 
> string:
>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 23: 
> ordinal not in range(128)
>
> The string in question is "... ESPA\xd1OL ..."
>
> I completely understand why I get the error, and my solution will be to 
> simply convert to unicode (since the code that uses the string is 
> unicode ready).
>
> I am wondering if anyone knows where I can find a mapping from this 
> particular extended ascii code (where \xd1 is Ñ), to the corresponding 
> unicode characters.
>
> Ken
>
>
>   

-- 
http://mail.python.org/mailman/listinfo/python-list


pyodbc on linux

2007-07-21 Thread Sean Davis
I have read a couple of blogs suggesting that pyodbc is buildable
under linux.  I am running suse 10.2 on a 64-bit intel machine with
unixODBC installed.  Upon building, I get a slew of pretty horrid
looking errors that make me wonder if this is supposed to work.  Can
anyone at least confirm that this is possible before I try to pursue
things further?

Thanks,
Sean

-- 
http://mail.python.org/mailman/listinfo/python-list


UnicodeDecodeError

2007-07-21 Thread Ken Seehart
I get this whenever I encounter a non-ascii character in a non-unicode 
string:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 23: 
ordinal not in range(128)

The string in question is "... ESPA\xd1OL ..."

I completely understand why I get the error, and my solution will be to 
simply convert to unicode (since the code that uses the string is 
unicode ready).

I am wondering if anyone knows where I can find a mapping from this 
particular extended ascii code (where \xd1 is Ñ), to the corresponding 
unicode characters.

Ken


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with exec

2007-07-21 Thread Steve Holden
...:::JA:::... wrote:
> Hello,
> 
> After my program read and translate this code:
> 
> koristi os,sys;
> ispisi 'bok kaj ima';
> 
> into the:
> 
> import os,sys;
> print 'bok kaj ima';
> 
> and when it run this code with "exec", I always get error like this, but I
> still dont't know what is a problem:
> 
> Traceback (most recent call last):
>   File "C:\Python24\Lib\site-packages\VL\__init__.py", line 188, in 
> kompajlati
> kompajlati_proces()
>   File "C:\Python24\Lib\site-packages\VL\__init__.py", line 183, in 
> kompajlati_proces
> h2=Konzola()
>   File "C:\Python24\Lib\site-packages\VL\__init__.py", line 158, in __init__
> k=kod(ZTextCtrl.GetLabel())
>   File "C:\Python24\Lib\site-packages\VL\__init__.py", line 83, in kod
> exec(str_ngh)
>   File "", line 1
> import os ,sys ;
> ^
> SyntaxError: invalid syntax
> 
This is almost certainly because the code contains embedded carriage 
returns:

 >>> code = """import os,sys;\nprint 'bok kaj ima';"""
 >>> exec code
bok kaj ima
 >>> code = """import os,sys;\r\nprint 'bok kaj ima';"""
 >>> exec code
Traceback (most recent call last):
   File "", line 1, in 
   File "", line 1
 import os,sys;
   ^
SyntaxError: invalid syntax
 >>>

> PS: How can I change when user write script with my program to he don't need
>   aspirate the lines of his source code
> e.g.
>  import os,sys
>  n=90
>  if n==90:print "OK"
>  else:print "No"
> 
>  
I'm afraid I don't understand this question. If you are talking about 
the indentation of the code, if you don't want indentation you will have 
to use braces - { and } - to indicate the nesting structure of your program.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

-- 
http://mail.python.org/mailman/listinfo/python-list


problem with exec

2007-07-21 Thread ...:::JA:::...
Hello,

After my program read and translate this code:

koristi os,sys;
ispisi 'bok kaj ima';

into the:

import os,sys;
print 'bok kaj ima';

and when it run this code with "exec", I always get error like this, but I
still dont't know what is a problem:

Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\VL\__init__.py", line 188, in 
kompajlati
kompajlati_proces()
  File "C:\Python24\Lib\site-packages\VL\__init__.py", line 183, in 
kompajlati_proces
h2=Konzola()
  File "C:\Python24\Lib\site-packages\VL\__init__.py", line 158, in __init__
k=kod(ZTextCtrl.GetLabel())
  File "C:\Python24\Lib\site-packages\VL\__init__.py", line 83, in kod
exec(str_ngh)
  File "", line 1
import os ,sys ;
^
SyntaxError: invalid syntax

PS: How can I change when user write script with my program to he don't need
  aspirate the lines of his source code
e.g.
 import os,sys
 n=90
 if n==90:print "OK"
 else:print "No"

 
  Regards,
 
  Vedran


__ Vedran
veki ICQ#: 264412055 Current ICQ status: + More ways to contact me Get ICQ!
__




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-21 Thread John Nagle
Paul Rubin wrote:
> Kay Schluehr <[EMAIL PROTECTED]> writes:
> 
>>When I remember correctly the FDIV bug was due to a wrongly filled
>>lookup table and occurred only for certain bitpattern in the divisor.
>>I'm not sure how a formal proof on the structure of the algorithm
>>could help here? Intel repaired the table i.e. the data not the
>>algorithm that acted upon it.

No, Intel had assumed a symmetry that wasn't actually true.

> I would expect the table contents to be part of the stuff being
> proved.  I hear that they do use formal proofs for their floating
> point stuff now, as does AMD.  AMD apparently uses ACL2 (a theorem
> prover written in Common Lisp, info about AMD is from the ACL2 web
> site) but I don't know what Intel uses.  I've figured that the FDIV
> problem was one of the motivations for this but I'm not certain of it.

 Yes, here's two of the papers describing proofs of AMD
floating point unit correctness.

Division: "http://citeseer.ist.psu.edu/53148.html";

Square root: "http://portal.acm.org/citation.cfm?id=607571";

A longer paper:

http://www.computationallogic.com/news/amd.html

This stuff is hard to do, but notice that AMD hasn't had any recalls
for floating point problems.

John Nagle
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interpreting os.lstat()

2007-07-21 Thread Martin v. Löwis
> Absolutely, which is why I consider it foolish for the OP to be
> trying to deduce the meaning of os.stat by looking at the output
> of the stat program, rather than studying the man page for the
> stat system call.

Ah, ok. I missed that the OP had brought stat(1) into the
discussion. Now it's all clear.

Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interpreting os.lstat()

2007-07-21 Thread Sion Arrowsmith
=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=  <[EMAIL PROTECTED]> wrote:
>> But it obviously does a lot of other stuff, including formatting
>> the results of the system call for display. 
>It most decisively does *not* format the results of the system call
>"for display".

"It" here refers to the program stat, which on most systems I use
is in /usr/bin/stat and most assuredly *does* format the results of
the system call for display. 

> I think it is important
>to understand that Python does *not* do any significant code
>to os.stat and os.lstat;

Absolutely, which is why I consider it foolish for the OP to be
trying to deduce the meaning of os.stat by looking at the output
of the stat program, rather than studying the man page for the
stat system call.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way for missing dict keys

2007-07-21 Thread Zentrader
On Jul 21, 7:48 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
> "Rustom Mody" <[EMAIL PROTECTED]> wrote:
> > Can someone who knows about python internals throw some light on why
>  x in dic
> > is cheaper than
>  dic.has_key(x)
>
> > ??
>

>From the 2.6 PEP #361 (looks like dict.has_key is deprecated)
Python 3.0 compatability: ['compatibility'-->someone should use a
spell-checker for 'official' releases]
- warnings were added for the following builtins which no
longer exist in 3.0:
 apply, callable, coerce, dict.has_key, execfile, reduce,
reload

-- 
http://mail.python.org/mailman/listinfo/python-list


►►YOUR VALUABLE OPINION COULD EARN YOU $3000 ◄◄

2007-07-21 Thread Ana Clark
Do You Know Your VALUABLE OPINION Can Earn You Upto $3000 Per Month

>> Get Paid to Try New Products, Drive Car, Travel etc...

Know more about these Opportunities, Just follow the link:

http://shortlinks.co.uk/35x

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-21 Thread Paul Rubin
Kay Schluehr <[EMAIL PROTECTED]> writes:
> When I remember correctly the FDIV bug was due to a wrongly filled
> lookup table and occurred only for certain bitpattern in the divisor.
> I'm not sure how a formal proof on the structure of the algorithm
> could help here? Intel repaired the table i.e. the data not the
> algorithm that acted upon it.

I would expect the table contents to be part of the stuff being
proved.  I hear that they do use formal proofs for their floating
point stuff now, as does AMD.  AMD apparently uses ACL2 (a theorem
prover written in Common Lisp, info about AMD is from the ACL2 web
site) but I don't know what Intel uses.  I've figured that the FDIV
problem was one of the motivations for this but I'm not certain of it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: converting 64-bit fixed-point to float

2007-07-21 Thread [EMAIL PROTECTED]
On Jul 20, 5:59 pm, [EMAIL PROTECTED] (John Fisher) wrote:
> Hi Group,
>
> troubles with converting signed 32.32, little-endian, 2's complement
> back to floating point. I have been trying to brew it myself. I am
> running Python 2.5 on a Mac. Here is the C-code I have been trying to
> leverage:
>
>  double FPuint8ArrayToFPDouble(uint8 *buffer, int startIndex)
> {
>   uint32 resultDec = 0;
>   uint32 resultWh = 0;
>   int i;
>
>   for(i = 0; i < 4; i++)
>   {
> resultDec += (uint32)buffer[startIndex + i] * pow(2, (i*8));
> resultWh += (uint32)buffer[startIndex + i + 4] * pow(2, (i*8));
>   }
>
>   return ( (double)((int)resultWh) + (double)(resultDec)/4294967296.0 );
>
> }


There are a few problem spots in that C code.  I tend to
think that it "works" because you're on a system that has
4-byte int and CHAR_BIT == 8.  When the most-significant-bit (MSB)
of resultWh is 1, then casting to int makes that a negative
value (i.e., MSB == the sign bit).

I presume that somewhere you include  (from C99)
and that uint32 is really uint32_t, etc.  For that to be
portable, you should probably cast to int32_t?

#include 
#include 
#include 

double arr2dbl (uint8_t *buffer, int startIndex)
{
uint32_t decimal = 0;
uint32_t whole = 0;
size_t i;
for (i = 0; i < 4; ++i)
{
decimal += (buffer[startIndex + i] << (i*8));
whole += (buffer[startIndex + i + 4] << (i*8));
}
return (int32_t)whole + (decimal/(UINT32_MAX+1.0));
}

int main (void)
{
uint8_t arr[7][8] = {
{0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff},
{0, 0, 0, 0, 0, 0, 0, 0},
{51, 51, 51, 51, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 2, 0, 0, 0},
{102, 102, 102, 38, 42, 1, 0, 0 },
{205, 204, 204, 204, 0xff, 0xff, 0xff, 0xff}};
size_t i;
double result;
for (i = 0; i < sizeof arr/sizeof arr[0]; ++i)
{
result = arr2dbl(arr[i], 0);
printf("%f\n", result);
}
return 0;
}







> Here is my version in Python, with some test code built in:
>
> from ctypes import *
>
> def conv64(input):
> input1=[0]*8
> input1[0]=c_ushort(input[0])
> input1[1]=c_ushort(input[1])
> input1[2]=c_ushort(input[2])
> input1[3]=c_ushort(input[3])
> input1[4]=c_ushort(input[4])
> input1[5]=c_ushort(input[5])
> input1[6]=c_ushort(input[6])
> input1[7]=c_ushort(input[7])
> #print input1[0].value,
> input1[1].value,input1[2].value,input1[3].value
> #print
> input1[4].value,input1[5].value,input1[6].value,input1[7].value
> #print
> resultDec=c_ulong(0)
> resultWh=c_ulong(0)
> for i in range(4):
> dec_c=c_ulong(input1[i].value)
> Wh_c=c_ulong(input1[i+4].value)
> resultDec.value=resultDec.value+dec_c.value*2**(i*8)
> resultWh.value=resultWh.value+Wh_c.value*2**(i*8)
>conval=float(int(resultWh.value))+float(resultDec.value)/4294967296.0
> #print conval
> return conval
> #tabs got messed up bringing this into MacSoup


(snipped)


>
> Finally, here is the output I get from my code:
>
>
>
> output should be -1 is 4294967296.0
> output should be 0 is 0.0
> output should be 0.2 is 0.1953
> output should be 1 is 1.0
> output should be 2 is 2.0
> output should be 298.15 is 298.15
> output should be -0.2 is 4294967295.8
>
> Thanks for any light you can shed on my ignorance.
>
> wave_man


This is my translation:

from ctypes import *

def conv64(input):
input1 = [c_uint8(item) for item in input]
dec = c_uint32(0)
whl = c_uint32(0)
for i in xrange(4):
dec.value += (input1[i].value << (i*8))
whl.value += (input1[i+4].value << (i*8))
cast_whl_to_int = c_int32(whl.value)
return float(cast_whl_to_int.value + dec.value/4294967296.0)


for arr in [[0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff],
[0, 0, 0, 0, 0, 0, 0, 0],
[51, 51, 51, 51, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 2, 0, 0, 0],
[102, 102, 102, 38, 42, 1, 0, 0],
[205,204,204,204,255,255,255,255]]:
print "%f" % conv64(arr)



However, I've not looked deeply into ctypes so I
don't know if c_int32 is really C's int, or int32_t, or ???

--
Hope this helps,
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-21 Thread Kay Schluehr
On Jul 20, 6:28 pm, Paul Rubin  wrote:

> As the Intel FDIV bug
> incident reminds us, even billions of test inputs are not enough to
> show that the routine does the right thing for EVERY input.

When I remember correctly the FDIV bug was due to a wrongly filled
lookup table and occurred only for certain bitpattern in the divisor.
I'm not sure how a formal proof on the structure of the algorithm
could help here? Intel repaired the table i.e. the data not the
algorithm that acted upon it.

-- 
http://mail.python.org/mailman/listinfo/python-list


importing a module from a specific directory

2007-07-21 Thread Yoav Goldberg

I'm using python for research related programming, and so I write many
experimental small pieces of code.

I would like to organize them into directory structure in
which there is a 'main' directory, and under it directories for
specific sub-tasks, or sub-experiments, I'm running (let's call them
'A', 'B', 'C').

I would like to have some common library code sit in 'main', and then use
it from scripts in the sub-tasks directories.

I also want the code in the sub-tasks to be quick-and-dirty fast to write,
so things like 'import sys; sys.append('..');' on the top of each script is
a bit awkward.

Is there a neat clean way of achieving the code organization?


How do you organize your code in such settings?

Thanks,
Yoav
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Subprocess module

2007-07-21 Thread Dave Sampson

> You probably 
> mean:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554
>
> Why is that not sufficient?  It will allow interaction with a called
> subprocess, in a cross-platform manner, etc.
>
>   - Josiah

Sorry maybe 'not sufficient' was the wrong excuse. Maybe the right
thing to say is that when I look at it I don't know if I'm supposed to
copy paste in my own module, or paste into a seprate module, or use it
in a pre-existing module. Does the liscence for the content through
ASPN even allow reuse of code. or Am I supposed to modify it?

If I use, how is it to be used?. Wher eare the exmpales and
documentation.

By sufficient I mean I don't have sufficient info from the site to
implement it. And I don't have sufficient know how to implement it
base don the comments in the source code.

IN SHORT... IT'S SCARY

So if you can answer any of those questions I am open.




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Subprocess module

2007-07-21 Thread Dave Sampson
Thanks for your response. It;s good to see you're promtoing Pexpect. I
was actualy wokring on a project at work that could have used Pexpect
to automate the creation of maps by tieing togethr a bunch of
processes through SSH and Pexpect looked like the money shot.

however it was enough of a battle to bring Python into the game since
it is government that bringing CYGWIN was a battle not worth
fighting.  Which is unfortunate because I think Pexpect was exactly
what we needed in that case
>
> You need Pexpect.
>

> There is nothing you can do about this when using a pipe.
> This is because stdio will change the type of buffering when sending
> stdout and stderr to a pipe. From the client side there is no way you
> can change the buffer mode (you CAN change the mode, but it only
> changes
> it on YOUR side of the pipe -- not your child application's side).


I obviously lack skills and understanding in many aspects of
programming. After all I'm a geographer / recreologist not a comp-sci
professional.

I understand the CONCEPT of pipes but don't know how to use or
implement.. the bigest things I ever do is something like

dmesg | grep wlan0

Where | is my pipe... but that is the extent of my knowledge and
skill.

Pexpect may very well be the option I need, and having a project that
supports the module is great. I am curous what is stopping Pexpect
from becoming cross platform.

Above, a user suggested implementing send keys in windows. Why not
include that as an try/except in Pexpect instead of my wrapper?  That
way it can benifit many more people?

Cheers


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Subprocess module

2007-07-21 Thread Dave Sampson
send keys for the p.c. you can use a try: except: concept and on the
> windows platform there is also a way to use autoit in python  using
> pywin.

thanks for the uggestion about sendkeys. I might be able to build that
into the wrapper.

So you're sugesting:

NIX = Pexpect

WINDOZE = sendkeys

Correct?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Subprocess module

2007-07-21 Thread Dave Sampson
On Jul 13, 7:50 pm, Dan Stromberg - Datallegro
<[EMAIL PROTECTED]> wrote:
> You could start up a pty and do your own Pexpect-like thing, using
> read/readline/write.
>
> However, this may not be portable to windows.  Maybe if you get the python
> that comes with cygwin, or build your own python under the cygwin


thanks for the suggestion. I will follow up on Noah's pexpect
sugestion bellow.

thanks for the input, cross platform is key with low overhead.

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: code packaging

2007-07-21 Thread Alex Popescu
"Ryan Ginstrom" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

>> On Behalf Of Paul Rubin
>> I'm wondering how other projects go about this.
> 
> I develop an automated build system from the very beginning. Running
> the build script:
> * Creates the API documentation (epydoc)
> * Creates the help files (extracting some information from the source)
> * Builds a windows executable (py2exe)
> * Builds an installer (Inno Setup)
> * Runs the installer (AutoIt)
> * Runs a smoke test on the installed application (AutoIt)
> 
> The program must at least install and pass the smoke tests at any
> given point in development.
> 
> Another script uploads the installer to my server, and sends an email
> to the testers stating that a new version is ready, with a list of
> additions/improvements.
> 
> Regards,
> Ryan Ginstrom
> 

What "build" tools are available in Python? Any initial hints are highly 
appreciated.

bests,
./alex
--
.w( the_mindstorm )p.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way for missing dict keys

2007-07-21 Thread Duncan Booth
"Rustom Mody" <[EMAIL PROTECTED]> wrote:

> Can someone who knows about python internals throw some light on why
 x in dic
> is cheaper than
 dic.has_key(x)
> 
> ??
> 
Some special methods are optimised by having a reserved slot in the data 
structure used to implement a class. The 'in' operator uses one of these 
slots so it can bypass all the overheads of looking up an attribute such as 
'has_key'.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code packaging

2007-07-21 Thread John J. Lee
Paul Rubin  writes:
[...]
> I'm now wondering where this type of thing is best addressed in more
> general terms.  What I usually see happening, in projects I've worked
> on and in others, is that developers get the code working on their own
> computers, using source control tools and (if we're lucky) tests
> developed in parallel with the code, but without much attention to
> final packaging until the very end when the code is about to be
> shipped.
>
> Is this appropriate?  Inappropriate?  Do your projects start using
> serious packaging and distribution tools very early in development,
> before the code is anywhere near usable?  Should they?
>
> I'm involved in something that I wish was that way, mainly because I
> really don't have any way to put a complete installation on my own
> computers; I have to develop my subsystem more or less independently
> of the overall app, then toss stuff over the wall to the more central
> application guys for integration, which gets slow sometimes because
> we're distributed all over.  This is a fairly complex server app that
> depends on a lot of external packages and programs running across
> multiple machines, so I could see the packaging problem being messy.
> It would cause a significant interruption in development to try to
> package things so that the non-central developers could install and
> hack it without a lot of assistance.  But I think it would be
> worthwhile given how much easier it would become to test changes.  We
> do plan to bundle up and release the code sometime (maybe as a Debian
> package) but for now that's deferred until the code is more complete
> and stable.
>
> I'm wondering how other projects go about this.

You can go further: in addition to developing a Debian package (or a
few of them) for your own project, build your OS image using
debootstrap (you'll probably want your own local repository(ies), for
reproducibility).  Then you do your development in a virtual machine
or chroot environment.  That way you develop in the same (or very
similar) environment to the one in which your code will eventually be
deployed (one difference being the use of an version control checkout
rather a .deb install for the code you're actually working on, unless
troubleshooting problems that are somehow tied up with that particular
aspect of deployment).  I've seen this working in a real-world
project.

Of course, you can set up a server that does a complete build-and-test
every night, and a separate continuous integration server that just
does an "svn up" (rather than a full rebuild) every time somebody
checks in, so that test failures can be detected quickly and the
guilty party suitably humiliated :-)


John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way for missing dict keys

2007-07-21 Thread Alex Popescu
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

> Alex Popescu a écrit :
>> Jakub Stolarski <[EMAIL PROTECTED]> wrote in 
> 

>
> [snip...]
>
> 
> d = dict()
> answer = d.get('answer', 42)
> answer in d
> => False
> 

Thanks. I think to make the 3rd approach completely equivalent I should 
have been using d.setdefault(key, myojbect()).

./alex
--
.w( the_mindstorm )p.



-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way for missing dict keys

2007-07-21 Thread Alex Martelli
Carsten Haese <[EMAIL PROTECTED]> wrote:

> On Sat, 21 Jul 2007 09:22:32 +0530, Rustom Mody wrote
> > Can someone who knows about python internals throw some light on why
> > >>> x in dic
> > is cheaper than
> > >>> dic.has_key(x)
> > 
> > ??
> 
> I won't claim to know Python internals, but compiling and disassembling the
> expressions in question reveals the reason:
> 
> >>> from compiler import compile
> >>> from dis import dis
> >>> dis(compile("dic.has_key(x)","","eval"))
>   1   0 LOAD_NAME0 (dic)
>   3 LOAD_ATTR1 (has_key)
>   6 LOAD_NAME2 (x)
>   9 CALL_FUNCTION1
>  12 RETURN_VALUE
> >>> dis(compile("x in dic","","eval"))
>   1   0 LOAD_NAME0 (x)
>   3 LOAD_NAME1 (dic)
>   6 COMPARE_OP   6 (in)
>   9 RETURN_VALUE
> 
> "dic.has_key(x)" goes through an attribute lookup to find the function that
> looks for the key. "x in dic" finds the function more directly.

Yup, it's mostly that, as microbenchmarking can confirm:

brain:~ alex$ python -mtimeit -s'd={}; f=d.has_key' 'f(23)'
1000 loops, best of 3: 0.146 usec per loop
brain:~ alex$ python -mtimeit -s'd={}; f=d.has_key' '23 in d'
1000 loops, best of 3: 0.142 usec per loop
brain:~ alex$ python -mtimeit -s'd={}; f=d.has_key' 'f(23)'
1000 loops, best of 3: 0.146 usec per loop
brain:~ alex$ python -mtimeit -s'd={}; f=d.has_key' '23 in d'
1000 loops, best of 3: 0.142 usec per loop
brain:~ alex$ python -mtimeit -s'd={}; f=d.has_key' 'd.has_key(23)'
100 loops, best of 3: 0.278 usec per loop
brain:~ alex$ python -mtimeit -s'd={}; f=d.has_key' 'd.has_key(23)'
100 loops, best of 3: 0.275 usec per loop

the in operator still appears to have a tiny repeatable advantage (about
4 nanoseconds on my laptop) wrt even the hoisted method, but the
non-hoisted method, due to repeated lookup, is almost twice as slow
(over 100 nanoseconds penalty, on my laptop).


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting dict keys

2007-07-21 Thread zacherates
>From ESR's "Why python?"

b = a.keys(); b.sort()

Two statements, one line.  Doesn't create an incidental copy the way
sorted does but I'm not sure how much you like to jam on one line.

Cheers,
   Aaron

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: class C: vs class C(object):

2007-07-21 Thread Bruno Desthuilliers
George Sakkis a écrit :
> On Jul 20, 5:40 am, Bruno Desthuilliers  [EMAIL PROTECTED]> wrote:
> 
>>Aahz a écrit :
>>
>>
>>>In article <[EMAIL PROTECTED]>,
>>>Bruno Desthuilliers  <[EMAIL PROTECTED]> wrote:
>>>
To make a long story short: Python 2.2 introduced a new object model
which is more coherent and more powerful than the original one. The old
one was kept so far for compatibility reasons, but there's absolutely no
reason to use it no more since "new-style" classes can do anything
"Classic" classes did and much more. IOW, don't even bother with
old-style classes.
>>
>>>And I'll make my usual knee-jerk response disagreeing with this.  For
>>>more info, search groups.google.com.
>>
>>And you'll still make it harder for newcomers to understand why a lot of
>>things don't work correctly with their classes. How helpful...
>>
>>Aahz, the object model switch happened *years* ago, and it's quite clear
>>that old style classes have been kept so far for compatibility reasons
>>only. It's obvious that one doesn't gain *anything* - except compat with
>>years-old pre-2.2 versions of Python - using old-style classes. So *why*
>>on earth are you still *advocating* the use of old style classes ??
> 
> 
> FWIW, I am not advocating old style classes and I rarely (if ever) use
> them in new code, but I occasionally miss the following feature, which
> by the way disproves the assertion that "new-style classes can do
> anything Classic classes did":
> 
> class Classic: pass
> class NewStyle(object):pass
> 
> for o in Classic(),NewStyle():
> o.__str__ = lambda: 'Special method overriding works on
> instances!'
> print '%s object: %s' % (o.__class__.__name__, o)
> 

Good point. There are effectively a couple of things that did work with 
the old object model and don't with the new one. OTOH, and while I tend 
to make heavy use of Python's dynamism and advanced features, I never 
had the need to dynamically override special methods on a per-instance 
basis yet. Not to say this is useless, just that it's probably enough of 
a corner case to justify the design choice (YMMV of course).

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Weird errors when trying to access a dictionary key

2007-07-21 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> I have a data structure that looks like this:
> 
(snip)
> 
> I get the following error:
(snip)
> AttributeError: 'list' object has no attribute 'keys'

Already answered.

> Here is where it gets weird:
> 
> type(song)
(snip)
> TypeError: 'str' object is not callable

You code snippet started with:
if type == 'artist':

which implies you bound the name 'type' to a string. Then you try to use 
  the object bound to name 'type' as a callable. Python's bindings are 
just name=>object mappings, and nothing prevents you to rebind a builtin 
name. IOW, avoid using builtins types and functions as identifiers.

HTH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way for missing dict keys

2007-07-21 Thread Bruno Desthuilliers
Alex Popescu a écrit :
> Jakub Stolarski <[EMAIL PROTECTED]> wrote in 
> news:[EMAIL PROTECTED]:
> 
> 
>>Version 1 and 2 do different thing than version 3. The latter doesn't
>>add value to dict.
>>
>>As it was mentioned before, use:
>>1 - if you expect that there's no key in dict
>>2 - if you expect that there is key in dict
>>
> 
> 
> I may be missing something

You are.

> but I think the 3 approaches are completely 
> equivalent in terms of functionality.

d = dict()
answer = d.get('answer', 42)
answer in d
=> False


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic way for missing dict keys

2007-07-21 Thread Bruno Desthuilliers
Alex Popescu a écrit :
> Hi all!
> 
> I am pretty sure this has been asked a couple of times, but I don't seem 
> to find it on the archives (Google seems to have a couple of problems 
> lately).
> 
> I am wondering what is the most pythonic way of dealing with missing 
> keys and default values.
> 
> According to my readings one can take the following approaches:
> 
> 1/ check before (this has a specific name and acronym that I haven't 
> learnt yet by heart)
> 
> if not my_dict.has_key(key):
>   my_obj = myobject()
>   my_dict[key] = my_obj
> else:
>   my_obj = my_dict[key]

if key not in my_dict:
   my_obj = my_dict[key] = myobject()
else:
   my_obj = my_dict[key]

> 2/ try and react on error (this has also a specific name, but...)
> 
> try:
>   my_obj = my_dict[key]
> except AttributeError:
>   my_obj = myobject()
>   my_dict[key] = my_obj

cf above for a shortcut...

> 3/ dict.get usage:
> 
> my_obj = my_dict.get(key, myobject())

Note that this last one won't have the same result, since it won't store 
my_obj under my_dict[key]. You'd have to use dict.setdefault :

my_obj = my_dict.setdefault(key, myobject())

> I am wondering which one is the most recommended way?

It depends on the context. wrt/ 1 and 2, use 1 if you expect that most 
of the time, my_dict[key] will not be set, and 2 if you expect that most 
of the time, my_dict[key] will be set.

> get usage seems 
> the clearest, but the only problem I see is that I think myobject() is 
> evaluated at call time,

Myobject will be instanciated each time, yes.

> and so if the initialization is expensive you 
> will probably see surprises.

No "surprise" here, but it can indeed be suboptimal if instanciating 
myobject is costly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: class C: vs class C(object):

2007-07-21 Thread Aahz
In article <[EMAIL PROTECTED]>,
Bruno Desthuilliers  <[EMAIL PROTECTED]> wrote:
>Aahz a écrit :
>> In article <[EMAIL PROTECTED]>,
>> Bruno Desthuilliers  <[EMAIL PROTECTED]> wrote:
>>>
>>> To make a long story short: Python 2.2 introduced a new object model 
>>> which is more coherent and more powerful than the original one. The old 
>>> one was kept so far for compatibility reasons, but there's absolutely no 
>>> reason to use it no more since "new-style" classes can do anything 
>>> "Classic" classes did and much more. IOW, don't even bother with 
>>> old-style classes.
>> 
>> And I'll make my usual knee-jerk response disagreeing with this.  For
>> more info, search groups.google.com.
>
>And you'll still make it harder for newcomers to understand why a lot of 
>things don't work correctly with their classes. How helpful...

Enh.  *All* of the standard Python documentation currently starts with
teaching classic classes, so it seems to me that this comment in fact
points toward difficulty understanding why things don't work correctly in
new-style classes.

>Aahz, the object model switch happened *years* ago, and it's quite
>clear that old style classes have been kept so far for compatibility
>reasons only. It's obvious that one doesn't gain *anything* - except
>compat with years-old pre-2.2 versions of Python - using old-style
>classes. So *why* on earth are you still *advocating* the use of old
>style classes ??

Saying that I'm "advocating" the use of old-style classes is not
precisely correct.  The simple fact is that you are wrong about the
switch having happened already.  There is almost no basic documentation
that starts with new-style classes; the vast majority of the Python
Standard Library still uses classic classes; there is no requirement in
PEP8 that new code for adding into Python 2.x use new-style classes.

Moreover, there are still plenty of people (me included) who use Python
2.2 for production purposes, and because of the small but critical
differences between new-style classes in 2.2 and 2.3+, I cannot
recommend new-style classes for anyone who has not switched to using
only 2.3+.  (For that matter, there are still people using 2.1 and
earlier, which is why some developers such as Fredrik Lundh still support
all the way back to 1.5.2.)

*YOU* are the one confusing people by your dogmatic insistance that
classic classes should be ignored.  Grow up.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

I support the RKAB
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-21 Thread Steve Holden
Paul Rubin wrote:
> Steve Holden <[EMAIL PROTECTED]> writes:
>> The issue I have with correctness proofs (at least as they were
>> presented in the 1980s - for all I know the claims may have become
>> more realistic now) is that the proof of correctness can only relate
>> to some highly-formal specification so complex that it's only
>> comprehensible to computer scientists.
> 
> Just like software as it is now, is only comprehensible to
> programmers.  A long while back there was a language called COBOL
> designed to be comprehensible to non-programmers, and it actually did
> catch on, but it was cumbersome and limited even in its time and in
> its application era, not so readable to non-programmers after all, and
> is not used much in new projects nowadays.
> 
The trouble there, though, is that although COBOL was comprehensible (to 
a degree) relatively few people have the rigor of thought necessary to 
construct, or even understand, an algorithm of any kind.

>> In other words, we can never "prove" that a program does what the
>> customer wants, because the semantics are communicated in different
>> ways, involving a translation which, since it is necessarily performed
>> by humans using natural language, will always be incomplete at best
>> and inaccurate at worst.
> 
> The types of things one tries to prove are similar to what is less
> formally expressed as localized test cases in traditional software.
> E.g. for a sorting routine you'd want to prove that output[n+1] >=
> output[n] for all n and for all inputs.  As the Intel FDIV bug
> incident reminds us, even billions of test inputs are not enough to
> show that the routine does the right thing for EVERY input.

Well I can buy that as a reasonable answer to my point. The early claims 
of the formal proof crowd were somewhat overblown and unrealistic, but 
that certainly doesn't negate the value of proofs such as the one you 
describe.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pickled objects over the network

2007-07-21 Thread Steve Holden
Hendrik van Rooyen wrote:
> "Steve Holden" <[EMAIL PROTECTED]> wrote:
> 
>> Hmm, I suspect I detect the sounds of the square wheel being reinvented.
> 
> Very helpful, thank you, Steve - Now how about pointing out in which
> direction the round wheels are kept, and what their monikers are?
> 
I think someone has already pointed out netstrings, which will allow you 
to send arbitrary strings over network connections deterministically. 
I'm afraid for the rest it's just a matter of encoding your information 
in a way that you can decode without allowing a malicious sender to 
cause arbitrary code to be called.

The issue with pickle is that it's way too general a mechanism to be 
secure in open network applications, so a suggestion to beef up its 
security was misguided. Trying to "beef up pickle's security" is like 
trying to make a shotgun that can't kill anything.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam filter?

2007-07-21 Thread Steve Holden
Danyelle Gragsone wrote:
> So,
> 
> Can mailing lists have its mail filtered?  I get more spam via mailing
> lists than I do in my own inbox.  I am not just singling this mailing
> list.  I see it a lot now.
> 
If you had searched the list you would have found that this topic has 
been discussed from time to time. The fact of the matter is that a lot 
of effort does go into spam filtering this list, and the residual spam 
that you see actually represents a very low false negative rate. You 
wouldn't believe how much spam gets sent to the active mailing lists and 
newsgroups.

If your own spam filtering is so good then maybe you should just 
subscribe to python-list instead of using a newsgroup, then your email 
filters will be applied to incoming articles from the list too.

Oh, I see you *are* using python-list. So how come your filters don't 
work for the spam that gets posted?

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

-- 
http://mail.python.org/mailman/listinfo/python-list


h grup

2007-07-21 Thread kasim
Dear __,


I recently joined AGLOCO because of a friend recommended it to me. I
am now promoting it to you because I like the idea and I want you to
share in what I think will be an exciting new Internet concept.


AGLOCO's story is simple:


Do you realize how valuable you are? Advertisers, search providers and
online retailers are paying billions to reach you while you surf.  How
much of that money are you making? NONE!


AGLOCO thinks you deserve a piece of the action.


AGLOCO collects money from those companies on behalf of its members.
(For example, Google currently pays AOL 10 cents for every Google
search by an AOL user. And Google still has enough profit to pay $1.6
billion dollars for YouTube, an 18-month old site full of content that
YouTube's users did not get paid for!


AGLOCO will work to get its Members their share of this and more.


AGLOCO is building a new form of online community that they call an
Economic Network. They are not only paying Members their fair share,
but they're building a community that will generate the kind of
fortune that YouTube made. But instead of that wealth making only a
few people rich, the entire community will get its share.


What's the catch? No catch - no spyware, no pop-ups and no spam -
membership and software are free and AGLOCO is 100% member owned.
Privacy is a core value and AGLOCO never sells or rents member
information.


So do both of us a favor: Sign up for AGLOCO right now! If you use
this link to sign up, I automatically get credit for referring you and
helping to build AGLOCO. http://www.agloco.com/r/BBFR2592

http://www.PassportToWealth.com/?id=kasim
http://www.perfectwealthformula.com/?id=kasim
http://dealsncash.com/members/index.cgi?kasim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting dict keys

2007-07-21 Thread Bjoern Schliessmann
 [EMAIL PROTECTED] wrote:

> I'd like to do it in one line because what I am trying to do is,
> after all, a single, simple enough action. 

No, it's two actions: 

1. You extract a list of keys from the dict
2. you sort it

> I find the suggested b = sorted(a.keys()) much more readable than
> breaking it up in two lines. In the long run, I guess it's a
> matter of personal taste... 

Yes. You'll see, at least if you do a third thing with the list it
will start to become less well-readable.

Regards,


Björn

-- 
BOFH excuse #450:

Terrorists crashed an airplane into the server room, have to
remove /bin/laden. (rm -rf /bin/laden)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Permutations with generators

2007-07-21 Thread Bjoern Schliessmann
Pablo Torres wrote:

> AttributeError: 'NoneType' object has no attribute 'insert'
> 
> Could somebody please explain to me why my p variable has no type
> at all?

It does have a type, NoneType. As already explained, only None
normally is of type NoneType.

Regards,


Björn

-- 
BOFH excuse #281:

The co-locator cannot verify the frame-relay gateway to the ISDN
server.

-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: eric 4.0.1 release

2007-07-21 Thread Detlev Offenbach
Hi,

I would like to announce the immediate availability of eric 4.0.1. This
is a bug fix release. As usual it is available via

http://www.die-offenbachs.de/eric/index.html

Just follow the eric4 download link.

What is eric

eric is a Python IDE with all batteries included. For details see the
a.m. link.

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting dict keys

2007-07-21 Thread montyphyton
On 21 srp, 02:31, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Fri, 20 Jul 2007 15:27:51 -0700, montyphyton wrote:
>  b = a.keys()
>  b.sort()
> > [1, 2, 3]
>
> > Works fine, but I would really like it if I could somehow do it in one
> > line.
>
> Why? Is the Enter key on your keyboard broken? Is there a global shortage
> of newline characters that I haven't been told about? Does your employer
> pay you less if you write more lines?
>
> --
> Steven.

I'd like to do it in one line because what I am trying to do is, after
all, a single, simple enough action. I find the suggested
b = sorted(a.keys()) much more readable than breaking it up in two
lines. In the long run, I guess it's a matter of personal taste...
Do I get payed less for more source code? Since I'm a student, I don't
get payed at all, regardless of number of lines :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dejagnu equivalent

2007-07-21 Thread Paddy
On Jul 18, 7:05 am, "Rustom Mody" <[EMAIL PROTECTED]> wrote:
> Does anyone know if a dejagnu equivalent exists for python?
> [Dejagnu is in tcl]

Maybe http://www.codesourcery.com/public/qmtest/whitepaper.pdf ?
I have not used it though.

-- 
http://mail.python.org/mailman/listinfo/python-list


Professional Grant Proposal Writing Workshop (September 2007: Simon Fraser University)

2007-07-21 Thread Anthony Jones


The Grant Institute's Grants 101: Professional Grant Proposal Writing Workshop will be held at Simon Fraser University at Harbour Centre, September 12 - 14
, 2007. Interested development professionals, researchers, faculty, and graduate students should register as soon as possible, as demand means that seats will fill up quickly. Please forward, post, and distribute this e-mail to your colleagues and listservs. 
 
All participants will receive certification in professional grant writing from the Institute. For more information call (213) 817 - 5308 or visit The Grant Institute at www.thegrantinstitute.com.
 
Please find the program description below:
 
The Grant Institute
Grants 101: Professional Grant Proposal Writing Workshop
will be held at
Simon Fraser University at Harbour Centre
Vancouver,  British Columbia
September 12 - 14, 2007
8:00 AM - 5:00 PM
 

The Grant Institute's Grants 101 course is an intensive and detailed introduction to the process, structure, and skill of professional proposal writing. This course is characterized by its ability to act as a thorough overview, introduction, and refresher at the same time. In this course, participants will learn the entire proposal writing process and complete the course with a solid understanding of not only the ideal proposal structure, but a holistic understanding of the essential factors, 
which determine whether or not a program gets funded. Through the completion of interactive exercises and activities, participants will complement expert lectures by putting proven techniques into practice. This course is designed for both the beginner looking for a thorough introduction and the intermediate looking for a refresher course that will strengthen their grant acquisition skills. This class, simply put, is designed to get results by creating professional grant proposal writers. 

 
Participants will become competent program planning and proposal writing professionals after successful completion of the Grants 101 course. In three active and informative days, students will be exposed to the art of successful grant writing practices, and led on a journey that ends with a masterful grant proposal. 
 
Grants 101 consists of three (3) courses that will be completed during the three-day workshop. 
 
(1) Fundamentals of Program Planning
 
This course is centered on the belief that "it's all about the program." This intensive course will teach professional program development essentials and program evaluation. While most grant writing "workshops" treat program development and evaluation as separate from the writing of a proposal, this class will teach students the relationship between overall program planning and grant writing. 
 
(2) Professional Grant Writing
 

Designed for both the novice and experienced grant writer, this course will make each student an overall proposal writing specialist. In addition to teaching the basic components of a grant proposal, successful approaches, and the do's and don'ts of grant writing, this course is infused with expert principles that will lead to a mastery of the process. Strategy resides at the forefront of this course's intent to illustrate grant writing as an integrated, multidimensional, and dynamic endeavor. 
Each student will learn to stop writing the grant and to start writing the story. Ultimately, this class will illustrate how each component of the grant proposal represents an opportunity to use proven techniques for generating support.
 
(3) Grant Research
 

At its foundation, this course will address the basics of foundation, corporation, and government grant research. However, this course will teach a strategic funding research approach that encourages students to see research not as something they do before they write a proposal, but as an integrated part of the grant seeking process. Students will be exposed to online and database research tools, as well as publications and directories that contain information about foundation, corporation, and 
government grant opportunities. Focusing on funding sources and basic social science research, this course teaches students how to use research as part of a strategic grant acquisition effort.
 
Registration
$597.00 USD tuition includes all materials and certificates.
 
Each student will receive:
*The Grant Institute Certificate in Professional Grant Writing
*The Grant Institute's Guide to Successful Grant Writing
*The Grant Institute Grant Writer's Workbook with sample proposals, forms, and outlines
 
Registration Methods
 
1) On-Line - Complete the online registration form at www.thegrantinstitute.com under Register Now. We'll send your confirmation by e-mail. 
 
2) By Phone - Call (213) 817 - 5308 to register by phone. Our friendly Program Coordinators will be happy to assist you and answer your questions. 
 
3) By E-mail - Send an e-mail with your name, organization, and basic contact information to [EMAIL PROTECTED] and we will reserve your slot and send you