RELEASED Mailman 2.1.7

2005-12-31 Thread Tokio Kikuchi
I'm pleased to announce the release of GNU Mailman 2.1.7.  This
is a significant release, which includes security enhancement
fixes, a new language (ia: Interlingua) support, a couple of new
features, and many bug fixes.

Mailman is free software for managing email mailing lists and
e-newsletters.

This release enhances the fixes for CAN-2005-0202 and CVE-2005-3573
which were fixed in mailman release 2.1.6, and reduces the chance of
list admin privilege abuse.  Because of these and other fixes, it
is highly recommended that all sites update to 2.1.7.

For more information, see:

http://mailman.sourceforge.net/

For links to download the Mailman 2.1.7 source tarball, see:

http://sourceforge.net/project/showfiles.php?group_id=103

Best regards and a happy new year!

-- 
Tokio Kikuchi

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: python coding contest

2005-12-31 Thread Just
In article [EMAIL PROTECTED],
 Christoph Zwerschke [EMAIL PROTECTED] wrote:

 Mark Dickinson wrote:
  Here's a variant of André's brilliant idea that's
  119 characters long, and fully printable:
  
  j=''.join;seven_seg=lambda z:j(j('   _  | |_ _|_|'
  [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z)
  +\nfor u in(3,7,8))
 
 You have an escaped CR (\r) as the last character in your string.

Which is perfectly printable.

 Here is a 118 character fully printable variant without the \r:
 
 j=''.join;seven_seg=lambda x:j(j('   _  |_|_ _| 
 |'[ord('^rm=3|4:s»'[int(c)])%d*2:][:3]for c in x)+\nfor d in(3,8,7))
 
 Note that there is only one non-ascii character in the code.

Which isn't. So I'm not sure what the point is you're trying to make.

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

Re: Memoization and encapsulation

2005-12-31 Thread Just
In article [EMAIL PROTECTED],
 Steven D'Aprano [EMAIL PROTECTED] wrote:

 I was playing around with simple memoization and came up with something
 like this:
 
 _cache = {}
 def func(x):
 global _cache

There's no need to declare _cache as global, since you're not assigning 
to it. So this global isn't all that pesky after all...

 if _cache.has_key(x): 
 return _cache[x]
 else:
 result = x+1  # or a time consuming calculation...
 _cache[x] = result
 return result
 
 when it hit me if I could somehow bind the cache to the function, I could
 get rid of that pesky global variable.
[ ... ]
 What do folks think? Is there a better way?

I actually prefer such a global variable to the default arg trick. The 
idiom I generally use is:

_cache = {}
def func(x):
result = _cache.get(x)
if result is None:
result = x + 1  # or a time consuming calculation...
_cache[x] = result
return result

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


Re: python coding contest

2005-12-31 Thread Just
In article [EMAIL PROTECTED],
 Just [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
  Christoph Zwerschke [EMAIL PROTECTED] wrote:
 
  Mark Dickinson wrote:
   Here's a variant of André's brilliant idea that's
   119 characters long, and fully printable:
   
   j=''.join;seven_seg=lambda z:j(j('   _  | |_ _|_|'
   [ord('^r|=Zm.:v\r'[int(a)])%u*2:][:3]for a in z)
   +\nfor u in(3,7,8))
  
  You have an escaped CR (\r) as the last character in your string.
 
 Which is perfectly printable.
 
  Here is a 118 character fully printable variant without the \r:
  
  j=''.join;seven_seg=lambda x:j(j('   _  |_|_ _| 
  |'[ord('^rm=3|4:s»'[int(c)])%d*2:][:3]for c in x)+\nfor d in(3,8,7))
  
  Note that there is only one non-ascii character in the code.
 
 Which isn't. So I'm not sure what the point is you're trying to make.

Duh, sorry, it's early. 118 is better than 119. Printable or not :) 
Still, a 119 bytes version that is fully printable is pretty cool.

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

py-cocoa?

2005-12-31 Thread Lin-Chieh Shangkuan
It's known that combining GTK+ or Qt with Python could enable the
GUI design with pygtk/pyqt.

In Mac OSX, it's suggested that use Cocoa be the GUI framework.
Is there py-cocoa framework?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread Paddy
So, testosterone wins again!

We get to boast:
  Mine's smaller than your's

Lets wait for Pythonic to go to bed, then sneak downstairs, go to that
tripple-X rated 'shortest solutions' website, and 'whack-off' some
solutions.
Unghhh,  my solution... its coming!!!

Well don't forget to clean up before Pythonic wakes up.

Happy new year :-)

- Pad.

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


Re: py-cocoa?

2005-12-31 Thread Just
In article [EMAIL PROTECTED],
 Lin-Chieh Shangkuan [EMAIL PROTECTED] wrote:

 It's known that combining GTK+ or Qt with Python could enable the
 GUI design with pygtk/pyqt.
 
 In Mac OSX, it's suggested that use Cocoa be the GUI framework.
 Is there py-cocoa framework?

PyObjC.

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


Re: generators in Java?

2005-12-31 Thread Diez B. Roggisch
Tom Sheffler schrieb:
 
 This may have been discussed before, so I apologize.
 
 Does Java have generators?  I am aware of the Iterator interface,
 but it seems much more restrictive.  Python generators are useful
 for many more things than simply list enumeration, but the Java
 Iterator seems limited.

No, it hasn't. One thing people do is to create threads that communicate 
via a queue and block while that queue has an item in it. But  of course 
that comes at additional overhead of thread context switching.


Regards,

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


Re: python coding contest

2005-12-31 Thread Christoph Zwerschke
Just wrote:
 Duh, sorry, it's early. 118 is better than 119. Printable or not :) 
 Still, a 119 bytes version that is fully printable is pretty cool.

No, you're right, I also somehow missed the point. I believed » to be 
printable (opposed to control char's) but technically speaking, the 
consensus is that printable restricts to 7-bit-ascii (in Python, 
string.printable does not even change if you change the locale setting, 
contrary to string.letters; this is a bit unclear in the Python docs).

Mark's point was that his solution was purely 7-bit-ascii printable and 
as such it was good although it was one byte more.

In the next contest, there should be subcategories for solutions that 
are 7-bit-printable and/or have no imports.

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


Re: python encoding bug?

2005-12-31 Thread Vincent Wehren
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
|
| I was playing with python encodings and noticed this:
|
| [EMAIL PROTECTED]:~$ python2.4
| Python 2.4 (#2, Dec  3 2004, 17:59:05)
| [GCC 3.3.5 (Debian 1:3.3.5-2)] on linux2
| Type help, copyright, credits or license for more information.
|  unicode('\x9d', 'iso8859_1')
| u'\x9d'
| 
|
| U+009D is NOT a valid unicode character (it is not even a iso8859_1
| valid character)

That statement is not entirely true. If you check the current 
UnicodeData.txt (on http://www.unicode.org/Public/UNIDATA/)  you'll find:

009D;control;Cc;0;BN;N;OPERATING SYSTEM COMMAND

Regards,

Vincent Wehren

|
| The same happens if I use 'latin-1' instead of 'iso8859_1'.
|
| This caught me by surprise, since I was doing some heuristics guessing
| string encodings, and 'iso8859_1' gave no errors even if the input
| encoding was different.
|
| Is this a known behaviour, or I discovered a terrible unknown bug in 
python encoding
| implementation that should be immediately reported and fixed? :-)
|
|
| happy new year,
|
| -- 
| ---
|| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
|| __..--^^^--..__garabik @ kassiopeia.juls.savba.sk |
| ---
| Antivirus alert: file .signature infected by signature virus.
| Hi! I'm a signature virus! Copy me into your signature file to help me 
spread! 


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

Re: Memoization and encapsulation

2005-12-31 Thread skip

just I actually prefer such a global variable to the default arg
just trick. The idiom I generally use is:

just _cache = {}
just def func(x):
just result = _cache.get(x)
just if result is None:
just result = x + 1  # or a time consuming calculation...
just _cache[x] = result
just return result

None of the responses I've seen mention the use of decorators such as the
one shown here:

http://wiki.python.org/moin/PythonDecoratorLibrary

While wrapping one function in another is obviously a bit slower, you can
memoize any function without tweaking its source.

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


Re: py-cocoa?

2005-12-31 Thread [EMAIL PROTECTED]
PyObjC ( http://pyobjc.sourceforge.net ) is what you are looking for.

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


Re: Memoization and encapsulation

2005-12-31 Thread Steven D'Aprano
On Fri, 30 Dec 2005 21:08:29 -0800, Raymond Hettinger wrote:

 Steven D'Aprano wrote:
 I was playing around with simple memoization and came up with something
 like this:

[snip]

 Try something like this:
 
 def func(x, _cache={}):
 if x in cache:
 return cache[x]
 result = x + 1 # or a time consuming function
 return result

Of course. The most obvious thing is the least obvious :-)


 * If cache hits are the norm, then a try/except version would be a bit
 faster.
 
 * In your original code, the global declaration wasn't needed because
 the assigment to _cache wasn't changed, rather its contents were.

Sure, it isn't needed, but I still like to make it explicit. Call it a
foible of mine :-)



-- 
Steven

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


Re: Memoization and encapsulation

2005-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2005 09:23:05 +0100, Just wrote:

 There's no need to declare _cache as global, since you're not assigning 
 to it. So this global isn't all that pesky after all...

It is still a global variable, with all the potential Badness thereof,
even if you don't have to declare it.



-- 
Steven.

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


Re: python encoding bug?

2005-12-31 Thread Benjamin Niemann
[EMAIL PROTECTED] wrote:

 
 I was playing with python encodings and noticed this:
 
 [EMAIL PROTECTED]:~$ python2.4
 Python 2.4 (#2, Dec  3 2004, 17:59:05)
 [GCC 3.3.5 (Debian 1:3.3.5-2)] on linux2
 Type help, copyright, credits or license for more information.
 unicode('\x9d', 'iso8859_1')
 u'\x9d'

 
 U+009D is NOT a valid unicode character (it is not even a iso8859_1
 valid character)

It *IS* a valid unicode and iso8859-1 character, so the behaviour of the
python decoder is correct. The range U+0080 - U+009F is used for various
control characters. There's rarely a valid use for these characters in
documents, so you can be pretty sure that a document using these characters
is windows-1252 - it is valid iso-8859-1, but for a heuristic guess it's
probably saver to assume windows-1252.

If you want an exception to be thrown, you'll need to implement your own
codec, something like 'iso8859_1_nocc' - mmm.. I could try this myself,
because I do such a test in one of my projects, too ;)

 The same happens if I use 'latin-1' instead of 'iso8859_1'.
 
 This caught me by surprise, since I was doing some heuristics guessing
 string encodings, and 'iso8859_1' gave no errors even if the input
 encoding was different.
 
 Is this a known behaviour, or I discovered a terrible unknown bug in
 python encoding implementation that should be immediately reported and
 fixed? :-)
 
 
 happy new year,
 

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Vector math library

2005-12-31 Thread Martin Vilcans
Hi, I'm new to this mailing list and fairly new to Python as well. I'm 
working on a prototype for a 3D game using OpenGL, and take this 
opportunity to learn Python better.

I'm looking for a good library for vector math. I need to do vector 
addition, cross products, dot products etc. and probably in the future 
I'll need matrix math as well.

So far I've used the Scientific library, which is very nice, but 
unfortunately it crashes when I use the Rotation class under OSX (which 
is my current development environment). I've seen mailing list posts 
that suggests that this crash is because of some problem with 64 bit CPUs.

I guess I can find a workaround for this problem, but first I want to 
check if there's a better library for vector math. When I googled for 
vector libraries, I found people claiming that the Numeric library can 
be used for vector math. But skimming the Numeric documentation, I 
didn't find a cross product function for instance, but it may just that 
I don't understand how to use it.

I also found SciPy, but it doesn't seem to have any vector math in it. 
In fact, I'm a bit confused about the libraries SciPy, Scientific, 
Numeric and NumericArray and the relations between them.

Any suggestions on what library I should use?

Best regards,

Martin Vilcans
http://www.librador.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread Christian Tismer
André wrote:
 For the few that might be interested, I will be posting the details of
 a 117 character long solution to the challenge on my blog
 http://aroberge.blogspot.com/.

Congratulations!
I'm very impressed by this elegant solution.
It seems to be very hard to improve. No idea if this is
possible: One might try to re-order the character string
a bit to change moduli, trying to get one more number in

(3,14,10)

to be one-digit. Haven't tried, yet, and chances are small.

congrats again and a happy new year - chris

-- 
Christian Tismer :^)   mailto:[EMAIL PROTECTED]
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key - http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


advanced module/import/namespace idioms

2005-12-31 Thread chuck
Every once in awhile I run across a python module that might have
statements like:

for c in sys.modules[module].__dict__.values():

or

import __builtin__
__builtin__.__dict__['_'] = lambda x: x

Snurf also does some strange import trickory (see
http://bdash.net.nz/svn/snurf/trunk/snurf/dataStore/).

While I'm sure none of this stuff is rocket science, but rather just
namespace manipulation there is very little explanation in the python
world that explains these techniques.  I've googled around to try to
find articles/papers that explain such techniques but cannot find any.
Can anyone point out any refereces that discuss such
module/import/namespace idioms.

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


Re: predicting function calls?

2005-12-31 Thread Ernst Noch
Roy Smith wrote:
 I think I know the answer to this, but I'll ask it just in case
 there's something I hadn't considered...
 
 I'm working on a python interface to a OODB.  Communication with the
 DB is over a TCP connection, using a model vaguely based on CORBA.
 I'll be creating object handles in Python which are proxies for the
 real objects in the database by doing something like:
 
 handle = connection.getObjectHandle (className, instanceName)
 
 Objects can have attributes (data) and operations associated with
 them.  It would be very convenient to use the . syntax to access
 both of these, i.e. be able to say:
 
 print handle.someAttribute
 print handle.someOperation (arg1, arg2)
 
 I'm using __getattr__() to process both of these constructs, and
 herein lies the rub; I need to do different things depending on
 whether the name is an attribute or an operation.  I can ask the DB
 for a list of the names of all the operations supported by a given
 object, but that's a fairly expensive thing to do, so I'd rather avoid
 it if possible.  It would be really nice if I had some way to find
 out, from inside __getattr__(), if the value I'm about to return will
 get called as a function (i.e., the name is followed by an open
 paren).  I can't see any way to do that, but maybe I'm missing
 something?
 

For various reasons also mentioned by other posters it's also not clear 
to me how relying on user input should work. Esp. for the

x=obj.meth
print x(args)

case.

Couldn't you just, for every access to a member of your object, first 
try to treat is as an access to an operation? If this fails (you 
mentioned the db will throw an error if this is an attribute instead of 
an operation), fall back to ask the db for an attribute of that name.

Or maybe just ask the db to look up this attribute in the list of 
operations, depending which is faster.

Btw. if the system is very dynamic, you might have to think about also 
implementing the attributes as proxies.


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


Re: Vector math library

2005-12-31 Thread Bas
I am not a regular user of the libraries that you mention, but I played
around with some of them because I need a replacement for Matlab.

Numeric, NumArray and SciPy should be more or less compatible. All the
functions you mention should be in there, or otherwise should be
trivial to implement. Have a look at the functions cross(), dot(),
inner(), outer(). Addition is just a+b.

As far as I know Numeric was the original vector lib. NumArray was
written as a successor but ended up as a fork due to some speed
concerns. Scipy is the latest and tries to unite the previous two by
implementing the best of both worlds. For future work you should stick
to SciPy. Right now it is probably somewhere in a beta stage, but
expect a final version in half a year or so. Hopefully it ends up being
THE vector lib for python to avoid confusing beginners like you.

Cheers,
Bas

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


Problem compiling an extension with MS Visual C++ Toolkit 2003

2005-12-31 Thread Andreas
Extension:
---
pyshapelib 0.3 with Python 2.4

Problem:
-
D:\Python24\Lib\site-packages\shapelib\setuppytest.py
Traceback (most recent call last):
  File D:\Python24\Lib\site-packages\shapelib\setup\pytest.py, line
1, in ?
import shapelib, dbflib, shptree
  File D:\Python24\Lib\site-packages\shapelib\setup\shapelib.py, line
2, in ?
import shapelibc
ImportError: DLL load failed: Das angegebene Modul wurde nicht
gefunden.
Windows Message: MSVCR80.dll not found.

Informations:
--
.NET Framework runtime and associated files are installed.

.NET Framework SDK installed.

Windows SDK installed.

Visual C++ Toolkit 2003 installed.

msvccompiler.py edited. Key on my machine is
...\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3.

vcvars32.bat edited.

python setup.py build
 running build
 running build_py
 creating build
 creating build\lib.win32-2.4
 copying shapelib.py - build\lib.win32-2.4
 copying dbflib.py - build\lib.win32-2.4
 running build_ext
 building 'shapelibc' extension
 creating build\temp.win32-2.4
 creating build\temp.win32-2.4\Release
 ...
 cl.exe seems to be o.k.
 ...
 ... Toolkit 2003\bin\link.exe ... ... shapelibc.pyd ... shapelibc.lib
...
==
MSVCRT.lib(crtdll.obj) : warning LNK4229:
invalid directive '/manifestdependency:type='win32'
name='Microsoft.VC80.CRT'
version='8.0.50608.0'
processorArchitecture='x86'
publicKeyToken='1fc8b3b9a1e18e3b'' encountered; ignored
==
...
python setup.py install
 running install
 running build
 running build_py
 running build_ext
 running install_lib
 copying build\lib.win32-2.4\shapelibc.pyd -
D:\Python24\Lib\site-packages
 copying build\lib.win32-2.4\shptree.pyd -
D:\Python24\Lib\site-packages
 copying build\lib.win32-2.4\dbflibc.pyd -
D:\Python24\Lib\site-packages

Question:
--
Has anyone an idea ?

Thanks,
Andreas

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


Re: predicting function calls?

2005-12-31 Thread Roy Smith
In article [EMAIL PROTECTED], Ernst Noch [EMAIL PROTECTED] 
wrote:

 Couldn't you just, for every access to a member of your object, first 
 try to treat is as an access to an operation? If this fails (you 
 mentioned the db will throw an error if this is an attribute instead of 
 an operation), fall back to ask the db for an attribute of that name.
 
 Or maybe just ask the db to look up this attribute in the list of 
 operations, depending which is faster.
 
 Btw. if the system is very dynamic, you might have to think about also 
 implementing the attributes as proxies.

Well, what I ended up doing is having a proxy for each object.  The first 
time I access any instance of a given class, I get from the DB a list of 
operations for that class and cache it (keyed by class).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vector math library

2005-12-31 Thread jelle
martin,

pyformex has a vector module as well.
its not very pythonic, but it could help you out creating a version of
your own.
worth checking out

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


bsddb3 locking questions

2005-12-31 Thread Eric S. Johansson
are there any simple examples of how to do record locking with bsddb3?

the bsddb3 documentation is reasonably opaque.  For example, the DB 
initialization requires a DBEnv instance for certain environmental 
features such as locking.  but if you want locking, what happens next? 
I suspect the pattern goes something like the following but it's not 
clear from the documentation.

dbe = DBEnv.open()
(does the home directory need to be specified or is there a systemwide 
default?  Is this per application or does a common pool work?

dbe.set_lk_detect(...DB_LOCK_YOUNGEST)
(but what about db_deadlock??? do I need a cron job?)

dbe.lock_id()

dbi = db.DB()

dbi.open(..)
(does the filename specified here need to be the same directory as the 
homedir in DBEnv or can it in a totally separate location? any 
advantages to either?)

lock = dbe.get_lock()
dbi.get/put
dbe.lock_put(lock)

(the above pattern is for record locking but for database locking, the 
lock get and put calls would bracket the open/close call)


if you close the database, should you automatically close the env or (as 
I suspect) the database environment can cover one or more database 
specific incarnations but if you have access different databases, each 
one should have its own environment.

anything else I'm missing?

thanks for any guidance,
---eric

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


Array construction from object members

2005-12-31 Thread MKoool
Hi everyone,

I am doing several operations on lists and I am wondering if python has
anything built in to get every member of several objects that are in an
array, for example, if i have a class like the following:

class myClass:
   a = 0.0

And lets say I populate the a element in an array of objects of
myClass.  If I want to retrieve all items in this and perhaps give it
to a mean function, I would need to make a loop now:

mySimpleArray = []
for i in range(0,len(myArray)):
mySimpleArray.append(myArray[i].a)

There must be some more efficient way to do this, can someone point me
to the right direction so that I can review some documentation and get
things a little more efficient?

thanks!

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


Re: Xah's Edu Corner: Examples of Quality Technical Writing

2005-12-31 Thread Brad Baxter

Xah Lee wrote:
 i had the pleasure to read the PHP's manual today.

 http://www.php.net/manual/en/

 although Pretty Home Page is another criminal hack of the unix lineage,
 but if we are here to judge the quality of its documentation, it is a
 impeccability.

 it has or possesses properties of:

 · To the point and useful.

   PHP has its roots in mundaness, like Perl and Apache. Its doc being
 practicality oriented isn't a surprise, as are the docs of Perl and
 Apache.

 · Extreme clarity!

   The doc is extremely well-written. The authors's writing skills
 shows, that they can present their ideas clearly, and also that they
 have put thoughts into what they wanted to say.

 · Ample usage examples.

   As with Perl's doc, PHP doc is not afraid to show example snippets,
 yet not abuse it as if simply slapping on examples in lieu of proper
 spec or discussion.

 · Appropriate functions or keywords are interlinked.

   This aspect is also well done in other quality docs, such as
 Mathematica, Java, MS JScript, Perl's official docs.

 · No abuse of jargons.

   In fact, it's so well written that there's almost no jargons in its
 docs, yet conveys its intentions to a tee. This aspect can also be seen
 in Mathematica's doc, or Microsoft's JScript doc, for examples.

 · No author masturbation. (if fact, you won't see a first-person
 perspective, as is the case with most quality tech writing.)

 We must truely appreciate the authors of the PHP doc. Because, PHP, as
 a free shit in the unix shit culture, with extreme ties to Perl and
 Apache (both of which has extremely motherfucked docs), but can wean
 itself from a shit milieu and stand pure and clean to become a paragon
 of technical writing.


--- originalSat Dec 31 11:44:54 2005
+++ corrected   Sat Dec 31 11:56:59 2005
@@ -1,28 +1,28 @@
-i had the pleasure to read the PHP's manual today.
+I had the pleasure to read the PHP's manual today.

 http://www.php.net/manual/en/

-although Pretty Home Page is another criminal hack of the unix
lineage,
-but if we are here to judge the quality of its documentation, it is a
+Although Pretty Home Page is another criminal hack of the unix
lineage,
+if we are here to judge the quality of its documentation, it is an
 impeccability.

-it has or possesses properties of:
+It has or possesses properties of:

 - To the point and useful.

   PHP has its roots in mundaness, like Perl and Apache. Its doc being
-practicality oriented isn't a surprise, as are the docs of Perl and
+practicality-oriented isn't a surprise; so are the docs of Perl and
 Apache.

 - Extreme clarity!

   The doc is extremely well-written. The authors's writing skills
-shows, that they can present their ideas clearly, and also that they
-have put thoughts into what they wanted to say.
+show, they can present their ideas clearly, and they
+have put thought into what they wanted to say.

 - Ample usage examples.

-  As with Perl's doc, PHP doc is not afraid to show example snippets,
+  As with Perl's doc, PHP's doc is not afraid to show example
snippets,
 yet not abuse it as if simply slapping on examples in lieu of proper
 spec or discussion.

@@ -31,18 +31,18 @@
   This aspect is also well done in other quality docs, such as
 Mathematica, Java, MS JScript, Perl's official docs.

-- No abuse of jargons.
+- No abuse of jargon.

-  In fact, it's so well written that there's almost no jargons in its
-docs, yet conveys its intentions to a tee. This aspect can also be
seen
+  In fact, it's so well written that there's almost no jargon in its
+docs, yet it conveys its intentions to a tee. This aspect can also be
seen
 in Mathematica's doc, or Microsoft's JScript doc, for examples.

-- No author masturbation. (if fact, you won't see a first-person
+- No author masturbation. (In fact, you won't see a first-person
 perspective, as is the case with most quality tech writing.)

-We must truely appreciate the authors of the PHP doc. Because, PHP, as
+We must truly appreciate the authors of the PHP doc. Because PHP, as
 a free shit in the unix shit culture, with extreme ties to Perl and
-Apache (both of which has extremely motherfucked docs), but can wean
+Apache (both of which have extremely motherfucked docs), can wean
 itself from a shit milieu and stand pure and clean to become a paragon
 of technical writing.
 
HTH

-- 
Brad

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


logging module example

2005-12-31 Thread Chris Smith
Hola, pythonisas:
 The documentation for the logging module is good, but a bit obscure.
 In particular, there seems to be a lot of action at a distance.
 The fact that getLogger() can actually be a call to Logger.__init__(),
which is mentioned in para 6.29.1, also bears stressing on 6.29.  I
grasp _why_ you'd implement it that way, but I may not be the only
coder who feels queasy with the word 'get' being used both to fetch
an instance and to trigger instantiation.
 Anyway, after poring over the documentation, unit test, and source code,
I'd like to show a sample script that will eventually be used 
in my vanity project, with four loggers of increasing granularity.
 I realize there are probably more ways to do this (logging seemingly
sporting perl-esque flexibility ;) so please weigh in with thoughts.
 Perhaps now I can go back and get this to work with the
logging.config interface. :)
Best,
Chris

#begin log_test.py--
import logging

#Set up a hierarchy such that we have:
#root - everything, including function arguments
#`trunk   - function calls
# `branch - application state
#  `leaf  - externally visible actions

forest = [root,trunk,branch,leaf]
#relate our logger names to levels
lumber_jack = {forest[0] : logging.DEBUG
  ,forest[1] : logging.INFO
  ,forest[2] : logging.WARNING
  ,forest[3] : logging.ERROR  }
#Used to build up the log names into a hierarchy
log_name = []

for log in forest:
mounty  = logging.FileHandler(%s%s.txt % (/home/smitty/mddl/,log))
log_name.append(log)
print Instantiating %s  % ..join(log_name)
timber  = logging.getLogger(..join(log_name))
timber.setLevel(lumber_jack[log])
timber.addHandler(mounty)
if   lumber_jack[log] == logging.DEBUG:
timber.debug(  %s's a lumberjack, and he's OK. % log)
elif lumber_jack[log] == logging.INFO:
timber.info(   %s's a lumberjack, and he's OK. % log)
elif lumber_jack[log] == logging.WARNING:
timber.warning(%s's a lumberjack, and he's OK. % log)
elif lumber_jack[log] == logging.ERROR:
timber.error(  %s's a lumberjack, and he's OK. % log)

#Force a logging event from the handler for the current logger.
# This hanlder event short-circuits the up-stream propogation
# of the log record, as seen in the file outputs.
mounty.emit( logging.LogRecord( timber
  , 0
  , /mnt/dmz/proj/mddl4/mddl.py
  , 37
  , burp?
  , None
  , None   ))

#end log_test.py--

#
#output:
#
Instantiating root
Instantiating root.trunk
Instantiating root.trunk.branch
Instantiating root.trunk.branch.leaf

#---
#The four files:
#---
$cat root.txt
root's a lumberjack, and he's OK.
burp?
trunk's a lumberjack, and he's OK.
branch's a lumberjack, and he's OK.
leaf's a lumberjack, and he's OK.

$cat trunk.txt
trunk's a lumberjack, and he's OK.
burp?
branch's a lumberjack, and he's OK.
leaf's a lumberjack, and he's OK.

$cat branch.txt
branch's a lumberjack, and he's OK.
burp?
leaf's a lumberjack, and he's OK.

$cat leaf.txt
leaf's a lumberjack, and he's OK.
burp?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Array construction from object members

2005-12-31 Thread Gerard Flanagan
MKoool wrote:

 Hi everyone,

 I am doing several operations on lists and I am wondering if python has
 anything built in to get every member of several objects that are in an
 array, for example, if i have a class like the following:

 class myClass:
a = 0.0

 And lets say I populate the a element in an array of objects of
 myClass.  If I want to retrieve all items in this and perhaps give it
 to a mean function, I would need to make a loop now:

 mySimpleArray = []
 for i in range(0,len(myArray)):
 mySimpleArray.append(myArray[i].a)

 There must be some more efficient way to do this, can someone point me
 to the right direction so that I can review some documentation and get
 things a little more efficient?

 thanks!

not sure if this is what you want to do, but does this help:

class myclass(object):
def __init__(self, a):
self.a = a

mylist = [ myclass('one'), myclass('two'), myclass('three'),
myclass('four') ]

alist = [ A.a for A in mylist ]  #this is called a 'list comprehension'

print alist

output:  ['one', 'two', 'three', 'four']

Gerard

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


Re: Newbie - SOAP return message with embedded ZIP file

2005-12-31 Thread Rodney
I actually tried both SOAPpy and ZSI but both return a error message with 
the incoming SOAP message that basicly said it was not a proper SOAP 
message.




Diez B. Roggisch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Rodney schrieb:
 Hi again, thanks for the help with figuring out how to parse a SOAP 
 return message.  I know have a return message that has an embedded ZIP 
 file in it. Can anyone help me figure out how to extract this file from 
 the SOAP return message.  The message looks as following:

 You've been told before, you'd be told it again and again: use SOAPpy or 
 ZSI to dela with webservices. Then you don't have to bother, yoou just 
 _get_ the ZIP-File (as string of course)


 Regards,

 Diez 


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


Re: logging module example

2005-12-31 Thread Diez B. Roggisch
Chris Smith schrieb:
 Hola, pythonisas:
  The documentation for the logging module is good, but a bit obscure.
  In particular, there seems to be a lot of action at a distance.
  The fact that getLogger() can actually be a call to Logger.__init__(),
 which is mentioned in para 6.29.1, also bears stressing on 6.29.  I
 grasp _why_ you'd implement it that way, but I may not be the only
 coder who feels queasy with the word 'get' being used both to fetch
 an instance and to trigger instantiation.

The reason for this distance is simply that you should be able to get 
a grip on a logger from wherever you are, explicitly _without_ first 
having to instantiate it and possibly pass it around. Think of this 
little example:

class Mixin(object):
 def foo(self):
 logger = logging.getLogger(MixinLogger)
 logger.debug(I'm foo!)

 def bar(self):
 logger = logging.getLogger(MixinLogger)
 logger.debug(I'm bar!)

class User(Mixin):

 def some_random_method(self):
 if relative_moon_humidity()  .8:
 self.foo()
 else:
 self.bar()


So the decoupling makes lots of sense in logging IMHO.

  Anyway, after poring over the documentation, unit test, and source code,
 I'd like to show a sample script that will eventually be used 
 in my vanity project, with four loggers of increasing granularity.
  I realize there are probably more ways to do this (logging seemingly
 sporting perl-esque flexibility ;) so please weigh in with thoughts.
  Perhaps now I can go back and get this to work with the
 logging.config interface. :)

 forest = [root,trunk,branch,leaf]
 #relate our logger names to levels
 lumber_jack = {forest[0] : logging.DEBUG
   ,forest[1] : logging.INFO
   ,forest[2] : logging.WARNING
   ,forest[3] : logging.ERROR  }
 #Used to build up the log names into a hierarchy
 log_name = []
 
 for log in forest:
 mounty  = logging.FileHandler(%s%s.txt % (/home/smitty/mddl/,log))
 log_name.append(log)
 print Instantiating %s  % ..join(log_name)
 timber  = logging.getLogger(..join(log_name))
 timber.setLevel(lumber_jack[log])
 timber.addHandler(mounty)
 if   lumber_jack[log] == logging.DEBUG:
 timber.debug(  %s's a lumberjack, and he's OK. % log)
 elif lumber_jack[log] == logging.INFO:
 timber.info(   %s's a lumberjack, and he's OK. % log)
 elif lumber_jack[log] == logging.WARNING:
 timber.warning(%s's a lumberjack, and he's OK. % log)
 elif lumber_jack[log] == logging.ERROR:

That looks as an misunderstanding or somewhat strange usage of the 
logging-api. It is _very_ uncommon to have loggers level depending on 
_data_. Instead you just invoke

logger.debug(some_data)

and set the level elsewhere. That is a somewhat static rleationship - 
all forests are supposed to share _one_ logging instance, with it's 
current log-level. And you don't check for the level being DEBUG or 
whatever. You just log, and if the level is above (or below, whatever 
stance you take) the currently set level for that logger, the message 
gets displayed.

All in all it seems that you have some difficulties with the loggers 
being a sort of global objects. Keep that in mind when developing using 
them.

Regards,

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


Re: Newbie - SOAP return message with embedded ZIP file

2005-12-31 Thread Diez B. Roggisch
Rodney schrieb:
 I actually tried both SOAPpy and ZSI but both return a error message with 
 the incoming SOAP message that basicly said it was not a proper SOAP 
 message.

Can you show us an actual working (or _not_ working) example of how and 
what you're trying? My mind-reading-skills aren't too well after the 
tiring holidays :)

Regards,

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


Re: Writing pins to the RS232

2005-12-31 Thread Michael Schneider
Jay,

Couple of points that may help you.

1) A serial port does not have data ports 0-n.  A serial port takes a 
byte (8 bits), then shifts them down a single pipe using a chip called a
UART (feel free to google for unfamiliar terms).

example

Bit pattern 1010 1010

would be shifted one bit at a time

1
0
1
0

1
0
1
0

a one is +5 volts on single send line of the UART and 0 is 0 volts.

RS232 uses a different mapping for 1's and 0's (but is still serial)

1 - ~-3V - -12 V
0 0-12 V

So you slap a chip on between the UART and the RS232 pin  (usually a 
MAX232)  that translates the voltages for you.

On the other end of the wire

232 socket
MAC232
UART (usually built into the microcontroller)
Register in Microcontroller


I like playing at this level.   I would recommend using AVR 
microcontroller (easiest to program and there is an open source
gcc compiler).

for $20.00 US you can buy the butterfly eval board with:
- microcontroller
- max232 all wired up for rs232 connection from your computer
- lcd display
- temperature sensor
- light sensor
- the avr mega169 has many goodies
 - analog - digital converter
 - digital - analog converter
 - LCD controller

This is a great bargin.

If you are starting out in microcontrollers.  I would suggest that you 
go to:

http://smileymicros.com/

They sell a nice package for $90.00

- butterfly eval board
- great, easy to follow book on how to develop on microcontrollers for 
the beginer.
- project kit - includes everything you need to build all of the 
projects (even includes the wire ;-)


There are python libs that support Ateml Avr connections:


It is easy to use your rs232 serial with a microcontroller at the other 
end of the wire.  Microcontrollers are cheap.  If you fry why is 
connected to your devices, you are only out the microcontroller.


Have fun,
Mike



[EMAIL PROTECTED] wrote:
 I want to write to the pins of an RS232 without using the serial
 protocol.  The use would be every pin could act to complete a circuit
 in customized hardware.  I could use python to communicate serially to
 a BASIC stamp or a Javelin stamp and then use the stamp to set however
 many pins as 0's or 1's but should it be that hard to do with python.
 I've looked through how python does serial with the serial module but
 it just uses Java's javax.comm libraries.  Is there anyway to do very
 low level device writing to COM ports?
 
 In summary I'm looking for something like:
 ser = serial.Serial(0)
 ser.pin0 = 1
 ser.pin1 = 1
 ser.pin2 = 1
 
 
 
 or
 ser.write('0xFF')
 which would set 8 pins on the RS232 cable to 1's
 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bsddb3 locking questions

2005-12-31 Thread Eric S. Johansson
Eric S. Johansson wrote:
 are there any simple examples of how to do record locking with bsddb3?

got this far with sample code from the activeware site

filename = 'fruit'

# Get an instance of BerkeleyDB
db_env = db.DBEnv()
db.set_lk_detect(db.DB_LOCK_YOUNGEST)
db_env.open(/tmp/bsddb3,db.DB_INIT_LOCK|db.DB_CREATE)


db_env.lock_id()

stuck at lock_id().  it returns a 1 (failure according to the docs and 
there is no hint of where the lock id value is returned so I can use it 
in the lock_get call.  at least that is what I think I need to do.

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


Re: Array construction from object members

2005-12-31 Thread Paul McGuire
MKoool [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi everyone,

 I am doing several operations on lists and I am wondering if python has
 anything built in to get every member of several objects that are in an
 array,
-snip-

Here's some sample code to show you how list comprehensions and generator
expressions do what you want.

-- Paul


class A(object):
def __init__(self,val):
self.a = val

# define _repr_ to make it easy to print list of A's
def __repr__(self):
return A(%s) % str(self.a)

Alist = [ A(i*1.5) for i in range(5) ]

print Alist

# create new list of .a attributes, print, and sum
Alist_avals = [ x.a for x in Alist ]
print Alist_avals
print sum(Alist_avals)

# if original list is much longer...
Alist = [ A(i*1.5) for i in range(50) ]

# ... creating list comprehension will take a while...
print sum( [ x.a for x in Alist ] )

# ... instead use generator expression - avoids creation of new list
print sum( x.a for x in Alist )


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


Re: Vector math library

2005-12-31 Thread Scott David Daniels
Martin Vilcans wrote:
 Hi, I'm new to this mailing list and fairly new to Python as well. I'm 
 working on a prototype for a 3D game using OpenGL, and take this 
 opportunity to learn Python better.
 
 I'm looking for a good library for vector math. I need to do vector 
 addition, cross products, dot products etc. and probably in the future 
 I'll need matrix math as well.
 

Take a quick look at VPython.  Should be great for breadboarding your
display and calculations.


-- 
-Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: advanced module/import/namespace idioms

2005-12-31 Thread Scott David Daniels
chuck wrote:
 Every once in awhile I run across a python module that might have
 statements like:
 
 for c in sys.modules[module].__dict__.values():

Straight-forwardly imported modules wind up in sys.modules,
keyed by their module name.  So  t = sys.modules['name']
is like import name as t.

Work it out in an interactive session, and you can get to know
what is going on here.  If you discover something wonderful you
wish were written up, write it up.


 import __builtin__
 __builtin__.__dict__['_'] = lambda x: x

The __builtin__ module is magical -- the source of predefined names.
_Do_not_muck_about_with_it_in_delivered_code_ (I know it is tempting).
The reason to avoid playing with it is that you are slightly breaking
the Python environment all code runs in.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Application architecture (long post - sorry)

2005-12-31 Thread limeydrink
Hi all,

I want to create a mobile field worker data solution.

Let me explain...

I work for a company that has some software used by call takers to
enter information into a database about faults with electrical
appliances they manufacture, sell to customers, and then provide
maintenance contracts for.

The company has a number of field workers (growing number) servicing
these appliances, and information about the faults and customer
locations is fed to them by printing off job sheets from the call
taking system and then either faxing them to the engineers or the
engineers drop in to the office and collect them.

There are lots of problems with this, such as lost job information,
incomplete forms, incorrect non validated data, the cost of printing
off job sheets and also the engineers having to collect, regular phone
calls to the engineers to update them on call informtion, and then the
fact that all this data then has to be inputted back into another
system manully.

Basically I want to create a means of getting this data to them
electronically.

I know there are a few companies who could provide this solution but
they are very expensive and possibly overkill at the moment, we could
start developing our own basic system then it can grow over time.

I have looked at the options for developing the client for these
electronic job sheets and have decided upon Microsoft Pocket PC and
the .net compact framework.  It seems the easiest environment for
developing and the PDA's can be obtained very cheaply as a package from
a GSM/GPRS data carrier.

The server side is where cost savings can be made and so i have decided
on a linux based server side using a database backend such as
PostgreSQL.

It would be usefull (and preferable) to make the server side of the
applicaiton portable, I have looked at Java and quite frankly I have
gone off the idea, it seems too complicated and I don't need to have my
application tick all the buzzword boxes - basically it doesn't need to
be a fashionable solution and if it did I would run it all under
Windows and .net from client to server.  I have decided on Python
(hopefully your advice will confirm to me it's the correct decision)

I have not developed any software of this type before and the trouble I
am having is deciding on how to interface between the client apps and
the server side.

Problem 1 - Physical connectivity
how would I make the actual network connection in to the server from
the client
Running a VPN connection over GPRS ?
Connecting to the web on the client then using web services ?

The above decisions probably depend on the answer to problem 2...
How to connect to the data
If I have a VPN connection to the network as described above could it
be just as simple as using ODBC to connect to the server and access the
data like just any other database application (not knowing how network
heavy this would be over a much slower connection than a LAN)

Or even simpler I could just export data for the engineers into XML or
.csv files and expose them using a web server the client then just
connects to the server and then downloads the job data , and uploads
completed job information

Or (this is where the bulk of the python part comes into it), I create
a network server in Python that the clients connect to this could be a
two way thing then, as the client app could connect first thing in the
morning and collect jobs but I could also push data to the client such
as job updates and notifications making it much smarter and
interactive.

There are currently around 60 engineers and they will be requesting
data at specific times, first thing in morning and probably midday
being the most busy times where probably all engineers will be
connecting at once.

So if I go down the network server route it will have to handle
multiple connections from clients and then connect to a database to
retrieve job information for each specific engineer and then send over
the connection to the client.

The number of engineers is increasing steadily and so this application
needs to be fairly scaleable.

I have a grander plan for this, as much of the work will be done in my
own time, as sort of a pet project, and if possible I would like to
make the application customizable and maybe even sell to other
companies although lets not run before we can walk eh :)


I know this post isn't Python specific but there are some smart guys on
here that could point me in the right direction or at least give me
something to think about :)

Thanks in advance

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


Re: Application architecture (long post - sorry)

2005-12-31 Thread Mike Meyer
[EMAIL PROTECTED] writes:
 I have looked at the options for developing the client for these
 electronic job sheets and have decided upon Microsoft Pocket PC and
 the .net compact framework.  It seems the easiest environment for
 developing and the PDA's can be obtained very cheaply as a package from
 a GSM/GPRS data carrier.

That seems like overkill for this application.

 Problem 1 - Physical connectivity
 how would I make the actual network connection in to the server from
 the client
 Running a VPN connection over GPRS ?
 Connecting to the web on the client then using web services ?

The physical connectivity isn't your worry. How you access it from
software depends on your chosen platform.

 The above decisions probably depend on the answer to problem 2...
 How to connect to the data
 Or even simpler I could just export data for the engineers into XML or
 .csv files and expose them using a web server the client then just
 connects to the server and then downloads the job data , and uploads
 completed job information

I've gone this route before, and this is why I say your .net solution
looks like overkill. The phones that GSM providers *give away* have
web browsers built into them, and it's been that way for years. No
need for .net or Pocket PC or whatever on the mobile device - just get
a web-enabled phone. This makes half the development trivial - you
don't have to do *any* development on the mobile side of things.

The hard part for you will be finding a competent web designer who
understands the web well enough to write for something other than
WinIE - in particular, who can produce pages that will work properly
on your target platform, no matter what it is.

The second hardest part will be picking the mobile platform. That will
depend on what you want to display, as low-end devices any not have a
big enough display, and on what kind of data entry has to be done in
the field: if cursor motion and select is enough, any thing will do. A
phone keypad is ok for short text. For longer things, you may want
something like Graffiti or even a real keypad. This latter takes you
out of phones and back into Pocket PC land - but only to get the UI,
not for development.

Once you've chosen the platform, you'll know what browser it has
available, and that will provide the requirements for the web
developer. The range is from simple (no frames, limited table nesting,
no CSS, no JS, and similar things) to very complete (Opera runs on
some of these devices.  They call the Pocket PC browser IE, but I've
never dealt with it).  You can design web apps to work around any/all
of these things being missing; all it takes is that competent web
designer.

I normally recommend picking the software first, and lettinng that
drive the choice of hardware. But in this case, the hardware is a
crucial part of the user interface, and you need to make sure that
that's acceptable. And the mobile hardware choice - assuming you go
the web route - isn't going to have a critical effect on the server
software.

 Or (this is where the bulk of the python part comes into it), I create
 a network server in Python that the clients connect to this could be a
 two way thing then, as the client app could connect first thing in the
 morning and collect jobs but I could also push data to the client such
 as job updates and notifications making it much smarter and
 interactive.

Web servers generally don't do push. There are technologies that do -
but then you're limiting your mobile platform choices to things that
support it, or having to port it yourself. Unless there's a real
reason for wanting to push the data, I'd avoid it. That doesn't mean
the your field engineers can't get updates whenever they want - they
just have to ask for them.

There are lots of python choices for building web applications. Maybe
to many. You could use just about any of them.

 There are currently around 60 engineers and they will be requesting
 data at specific times, first thing in morning and probably midday
 being the most busy times where probably all engineers will be
 connecting at once.

You'll need to make sure you have a fast enough machine for that. A
33MHz 386 ought to do the trick :-).

 So if I go down the network server route it will have to handle
 multiple connections from clients and then connect to a database to
 retrieve job information for each specific engineer and then send over
 the connection to the client.

This is a pretty standard architecture for a web application. Any of
the python web application tools can handle this.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python article in Free Software Magazine

2005-12-31 Thread Kirk Strauser
I wrote this article which was published in Free Software Magazine:

http://www.freesoftwaremagazine.com/free_issues/issue_09/intro_zope_1/

It's intended as a high-level overview of the language, and therefore
glosses over some of the details.  For example, I describe its function
calling mechanism as pass-by-reference, because that's close enough for
newcomers to get the gist of it.

Anyway, the article's available under an open license.  If you like it, feel
free to pass it around.  Enjoy!
-- 
Kirk Strauser

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


Re: Vector math library

2005-12-31 Thread [EMAIL PROTECTED]
And then more!

I started out using cgtypes from the cgkit. Lots of other graphics
goodies in there also:

http://cgkit.sourceforge.net/doc/cgtypes.html

In the end I ended up rolling my own to better understand the whole
thing.

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


Re: Python article in Free Software Magazine

2005-12-31 Thread Gerard Flanagan

Kirk Strauser wrote:

 I wrote this article which was published in Free Software Magazine:

 http://www.freesoftwaremagazine.com/free_issues/issue_09/intro_zope_1/

 It's intended as a high-level overview of the language, and therefore
 glosses over some of the details.  For example, I describe its function
 calling mechanism as pass-by-reference, because that's close enough for
 newcomers to get the gist of it.

 Anyway, the article's available under an open license.  If you like it, feel
 free to pass it around.  Enjoy!
 --
 Kirk Strauser

It's a good article and well written.  I've heard Zope mentioned quite
often but don't know a thing about it, so I'll be looking forward to
the next installment!


Gerard

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


Re: python coding contest

2005-12-31 Thread André

Christian Tismer wrote:
 André wrote:
  For the few that might be interested, I will be posting the details of
  a 117 character long solution to the challenge on my blog
  http://aroberge.blogspot.com/.

...
 It seems to be very hard to improve. No idea if this is
 possible: One might try to re-order the character string
 a bit to change moduli, trying to get one more number in

 (3,14,10)

 to be one-digit. Haven't tried, yet, and chances are small.

 congrats again and a happy new year - chris

With the string of  _| I used, starting sub-indices for each
3-character substrings are such that one need modulo 10 (or greater)
for at least two of the three indices.  I have looked at a few other
combinations and, after thinking about it, have convinced myself that
it is unfortunately not possible to do.  I would love to be proven
wrong!  Good idea though!

Happy New Year to you all!

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


Re: Vector math library

2005-12-31 Thread Erik Max Francis
Martin Vilcans wrote:

 Hi, I'm new to this mailing list and fairly new to Python as well. I'm 
 working on a prototype for a 3D game using OpenGL, and take this 
 opportunity to learn Python better.
 
 I'm looking for a good library for vector math. I need to do vector 
 addition, cross products, dot products etc. and probably in the future 
 I'll need matrix math as well.

ZOE has an la a module that helps with linear algebra computations 
including (three-dimensional) vectors and matrices:

http://www.alcyone.com/software/zoe/

-- 
Erik Max Francis  [EMAIL PROTECTED]  http://www.alcyone.com/max/
San Jose, CA, USA  37 20 N 121 53 W  AIM erikmaxfrancis
   You are the lovers rock / The rock that I cling to
   -- Sade
-- 
http://mail.python.org/mailman/listinfo/python-list


PYTHONDOCS

2005-12-31 Thread J. D. Leach
OK, I'm stupid. I have been unable to discern (even Googled) a way to set
the PYTHONDOCS variable to point to where the HTML files are. What to do? I
need to know the process and where theses variables are stored.
-- 
J. D. Leach
Columbus, Indiana USA

Linux/Open Source Computer using:
Mandrakelinux release 10.2 (Limited Edition 2005) for i586 kernel
2.6.11-6mdk

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


Re: scrape url out of brackets?

2005-12-31 Thread homepricemaps
so you recommend using some sort of for statement with the html parser
where i tell it to only parse stuff found in the tr tag for instance?

Ravi Teja wrote:
 Regular Expressions are the most common way.
 http://docs.python.org/lib/module-re.html

 HTML parser is another
 http://docs.python.org/lib/module-htmllib.html

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


Re: python coding contest

2005-12-31 Thread Hans Nowak
André wrote:
 Christian Tismer wrote:

It seems to be very hard to improve. No idea if this is
possible: One might try to re-order the character string
a bit to change moduli, trying to get one more number in

(3,14,10)

to be one-digit. Haven't tried, yet, and chances are small.

congrats again and a happy new year - chris
 
 
 With the string of  _| I used, starting sub-indices for each
 3-character substrings are such that one need modulo 10 (or greater)
 for at least two of the three indices.  I have looked at a few other
 combinations and, after thinking about it, have convinced myself that
 it is unfortunately not possible to do.  I would love to be proven
 wrong!  Good idea though!

I don't know if this suggestion has been made already, but it seems to 
me that the end of the expression

   ...  for u in(3,14,10))

can be written as:

   ...  for u in 3,14,10)

which would shave off a character.  Tuples don't always need parentheses...

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hypergeometric distribution

2005-12-31 Thread Raven
Thanks to all of you guys, I could resolve my problem using the
logarithms as proposed by Robert.  I needed to calculate the factorial
for genomic data, more specifically for the number of genes in the
human genome i.e. about 30.000 and that is a big number :-)
I didn't know gmpy
Thanks a lot, really

Ale

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


Re: PYTHONDOCS

2005-12-31 Thread Fernando Perez
J. D. Leach wrote:

 OK, I'm stupid. I have been unable to discern (even Googled) a way to set
 the PYTHONDOCS variable to point to where the HTML files are. What to do? I
 need to know the process and where theses variables are stored.

It's an environment variable.  In my case:

PYTHONDOCS=/usr/share/doc/python-docs-2.3.4/html

You need to locate the proper dir on your system, and then use your shell's
syntax for this (export/setenv for bash/tcsh).

cheers,

f

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


Re: logging module example

2005-12-31 Thread Chris Smith
 Diez == Diez B Roggisch [EMAIL PROTECTED] writes:

Diez Chris Smith schrieb:
 Hola, pythonisas: The documentation for the logging module is
 good, but a bit obscure.  In particular, there seems to be a
 lot of action at a distance.  The fact that getLogger() can
 actually be a call to Logger.__init__(), which is mentioned in
 para 6.29.1, also bears stressing on 6.29.  I grasp _why_ you'd
 implement it that way, but I may not be the only coder who
 feels queasy with the word 'get' being used both to fetch an
 instance and to trigger instantiation.

Diez The reason for this distance is simply that you should be
Diez able to get a grip on a logger from wherever you are,
Diez explicitly _without_ first having to instantiate it and
Diez possibly pass it around. Think of this little example:

[snip]

Diez So the decoupling makes lots of sense in logging IMHO.

Absolutely.  The fact that it does eventually make sense, however, doesn't
preclude a bout of confusion at the fact that some_lager didn't
already exist before 

pint = logging.getLogger( some_lager )

and that the logging module will merrily brew some_lager on the spot.
I submit that the documentation might be improved by including your
example on 6.29, gearing the neophyte up for how this (can we agree it
operates on slightly different principles than most?) module operates.


 Anyway, after poring over the documentation, unit test, and
 source code, I'd like to show a sample script that will
 eventually be used in my vanity project, with four loggers of
 increasing granularity.  I realize there are probably more ways
 to do this (logging seemingly sporting perl-esque flexibility
 ;) so please weigh in with thoughts.  Perhaps now I can go back
 and get this to work with the logging.config interface. :)

[snip]

Diez That looks as an misunderstanding or somewhat strange usage
Diez of the logging-api. It is _very_ uncommon to have loggers
Diez level depending on _data_. Instead you just invoke

Diez logger.debug(some_data)

Diez and set the level elsewhere. That is a somewhat static
Diez releationship - all forests are supposed to share _one_
Diez logging instance, with it's current log-level. And you don't
Diez check for the level being DEBUG or whatever. You just log,
Diez and if the level is above (or below, whatever stance you
Diez take) the currently set level for that logger, the message
Diez gets displayed.

My use-case is a desire to interpret an input file, and log traces at
varying output depth.  I used the default labels, just to keep the
sample script small.  However, I will (once I have grokked
that corner of the module more fully) follow your advice there, for
I'm really only talking about four densities of debug information.
Thank you for this feedback.

Diez All in all it seems that you have some difficulties with the
Diez loggers being a sort of global objects. Keep that in mind
Diez when developing using them.

Yep, got to play the tune sloppy a few times before it's tight.
Nochmals vielen Dank. :)
Chris

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


Re: PYTHONDOCS

2005-12-31 Thread Chris Smith
 J == J D Leach [EMAIL PROTECTED] writes:

J OK, I'm stupid. I have been unable to discern (even Googled) a
J way to set the PYTHONDOCS variable to point to where the HTML
J files are. What to do? I need to know the process and where
J theses variables are stored.  -- J. D. Leach Columbus, Indiana
J USA

J Linux/Open Source Computer using: Mandrakelinux release 10.2
J (Limited Edition 2005) for i586 kernel 2.6.11-6mdk

J,
I'm stupider; I can't ATFQ for you.
But last night I stayed at a Holiday Inn Express, and can recommend

http://projects.edgewall.com/python-sidebar/
 
Which, assuming you've got connectivity, is teh shiznit.
HTH,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread André
Hans Nowak wrote:
 André wrote:


 I don't know if this suggestion has been made already, but it seems to
 me that the end of the expression

...  for u in(3,14,10))

 can be written as:

...  for u in 3,14,10)

 which would shave off a character.  Tuples don't always need parentheses...

I tried ... but, in this case, it appears that they do, unfortunately
:-(

André

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


Re: python coding contest

2005-12-31 Thread Hans Nowak
André wrote:
 Hans Nowak wrote:
 
André wrote:
 
 
I don't know if this suggestion has been made already, but it seems to
me that the end of the expression

   ...  for u in(3,14,10))

can be written as:

   ...  for u in 3,14,10)

which would shave off a character.  Tuples don't always need parentheses...

 
 I tried ... but, in this case, it appears that they do, unfortunately
 :-(

Ah, you are right.  It works for a list comprehension, but not for a 
genexp. :-(

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread Christian Tismer
Hans Nowak wrote:

...  for u in(3,14,10))
 
 can be written as:
 
...  for u in 3,14,10)
 
 which would shave off a character.  Tuples don't always need parentheses...

This would work with a list comprehension.
Doesn't work with a generator expression
(thought of it, too, and the list comprehension eats one char)

cheers - chris
-- 
Christian Tismer :^)   mailto:[EMAIL PROTECTED]
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key - http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread Claudio Grondi
 Please send me comments, suggestions and ideas.

Now, after the contest is over I analysed the outcome of it and have 
come to the conclusion, that there were two major factors which 
contributed to squeezing of code:

   (1). usage of available variants for coding of the same thing
   (2). sqeezing the size of used numeric and string literals

As (1) leads to less readable cryptic code it makes not much sense from 
my point of view to dig deeper in that direction. As already mentioned 
in this thread by Tim Peters ( pointing to 
http://spoj.sphere.pl/problems/KAMIL/ ) it seems, that Pearl is here the 
proper language of choice for such kind of problems anyway.

Trying to improve on (2) belongs in my eyes much more into the area of 
problems discussed in comp.compression than to problems belonging into 
comp.lang.python .

So what is my point? Ok, I will mention it at the end of this post.

Before that I want to thank the originators of the contest and 
especially the participants for providing insight into the techniques 
they have used. I have learned from the contest what lambda expression 
is good for and how it works  where I failed to grasp it from reading 
tutorials only.

I have detected, that it would be a nice thing to have in Python a 
function able to convert values from binary string to an integer 
representation as in my eyes both in case of long integer values are 
more or less the same thing/object. The only difference is probably in 
the header not in the representation of the actual value in memory - am 
I right here? Will it make sense to have a string-integer object which 
value can be used in both contexts as a binary string and a long integer 
value?
Is there in Python any simple way to do the same as the following two 
following functions I have put together today:

def longIntWithBitsOfBinaryString(stringToConvert):
   intWithBitsOfBinaryString = 0L
   for singleChar in stringToConvert:
 intWithBitsOfBinaryString = (intWithBitsOfBinaryString8) + 
ord(singleChar)
   #:for
   return intWithBitsOfBinaryString
#:def longIntWithBitsOfBinaryString(s)

def binaryStringWithBitsOfLongInt(i):
   listOfCharsOfStringWithThePackedInt = []
   exponent = 1
   while i  256**exponent: exponent+=1
   for byteNo in range(0,exponent):
 noOfBitsToShift = byteNo*8
 
listOfCharsOfStringWithThePackedInt.append(chr(inoOfBitsToShift0xFF))
   #:for
   # reverse (in place) in order to get the highest bits of the integer 
as leftmost byte
   listOfCharsOfStringWithThePackedInt.reverse()
   stringWithThePackedInt = ''.join(listOfCharsOfStringWithThePackedInt)
   return stringWithThePackedInt
#:def binaryStringWithBitsOfLongInt(i)

print longIntWithBitsOfBinaryString('ABBA') = 
%i%longIntWithBitsOfBinaryString('ABBA')
print 
binaryStringWithBitsOfLongInt(longIntWithBitsOfBinaryString('ABBA')) = 
'%s'%binaryStringWithBitsOfLongInt(longIntWithBitsOfBinaryString('ABBA'))

which gives:

longIntWithBitsOfBinaryString('ABBA') = 1094861377
binaryStringWithBitsOfLongInt(longIntWithBitsOfBinaryString('ABBA')) = 
'ABBA'

?

And now my point I have promised to write about:

If squeezing code makes it bad code and compressing literals is more or 
less compression technique and not Python programming, it is maybe a 
good idea to try to explore what Python distribution provides as data 
and modules and rewrite the  seven_seg  module, but with following 
limitations:

1. it is not allowed to use any literals in the provided code
2. it is not allowed to misuse the names of the identifiers as a kind of 
literals providing data
3. it is not allowed to use modules or files which doesn't come with the 
Python distribution.

I have no slightest idea if it is possible to program a  seven_seg 
module under such conditions. It could be a sign, that it would be a 
very interesting challenge worth to get involved into or a sign I have 
no slightest idea about Python and programming.

What do you all think about it?

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


Re: Global Variables in OOP and Python

2005-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2005 21:21:29 +, Dennis Lee Bieber wrote:

 On Sat, 31 Dec 2005 11:37:38 +1100, Steven D'Aprano
 [EMAIL PROTECTED] declaimed the following in
 comp.lang.python:
 
 
 Do you mean something like this?
 
 # Module care_and_feeding
 
 import birds
 import foods
 
 def feed_my_pet():
 pet = birds.Parrot(Norwegian Blue)
 snack = foods.Spam(A tasty meat-like treat)
 pet.eats(snack)
 return Yummy!
 
 
 That is a good way of handling the problem.

   Except for the minor facet that you are buying a new parrot each
 time, and the bird dies after going Yummy! G

It's a Norwegian Blue with beautiful plumage. It's not dead, it's just
pining for the fjords.



-- 
Steven.

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


Re: PYTHONDOCS

2005-12-31 Thread Mike Meyer
Chris Smith [EMAIL PROTECTED] writes:
 J == J D Leach [EMAIL PROTECTED] writes:
 I'm stupider; I can't ATFQ for you.
 But last night I stayed at a Holiday Inn Express, and can recommend

 http://projects.edgewall.com/python-sidebar/
  
 Which, assuming you've got connectivity, is teh shiznit.

Along the same lines, the OS X application launcher Butler comes
pre-configured with a search python reference materials
shortcut. I launch the shortcut, type in what I want,and hit enter,
and a browser window opens displaying the results of the
search. Adding other things - like searching the Python cookbook - is
relatively easy.

   mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Weekly Python Patch/Bug Summary

2005-12-31 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  382 open ( +3) /  3003 closed ( +1) /  3385 total ( +4)
Bugs:  903 open (-11) /  5479 closed (+27) /  6382 total (+16)
RFE :  203 open ( -1) /   195 closed ( +2) /   398 total ( +1)

New / Reopened Patches
__

NotImplemented-TypeError in __add__ and __mul__  (2005-12-26)
CLOSED http://python.org/sf/1390657  opened by  Armin Rigo

dict.merge  (2005-12-27)
   http://python.org/sf/1391204  opened by  Nicolas Lehuen

cookielib LWPCookieJar and MozillaCookieJar exceptions  (2005-02-06)
   http://python.org/sf/1117398  reopened by  jjlee

Optional second argument for startfile  (2005-12-29)
   http://python.org/sf/1393157  opened by  Thomas Heller

Add restart debugger command to pdb.py  (2005-12-30)
   http://python.org/sf/1393667  opened by  Rocky Bernstein

Patches Closed
__

NotImplemented-TypeError in __add__ and __mul__  (2005-12-26)
   http://python.org/sf/1390657  closed by  arigo

weakref callbacks are called only if the weakref is alive  (2005-12-12)
   http://python.org/sf/1379023  closed by  arigo

New / Reopened Bugs
___

Incorrectly docs for return values of set update methods  (2005-12-24)
CLOSED http://python.org/sf/1389673  opened by  Collin Winter

Fxn call in _elementtree.c has incorrect signedness  (2005-12-24)
CLOSED http://python.org/sf/1389809  opened by  Brett Cannon

_winreg specifies EnvironmentError instead of WindowsError  (2005-12-21)
CLOSED http://python.org/sf/1386675  reopened by  birkenfeld

ScrolledText hungs up in some conditions  (2005-12-25)
   http://python.org/sf/1390086  opened by  dani_filth

README mention --without-cxx  (2005-12-25)
   http://python.org/sf/1390321  opened by  Aahz

time docs lack %F in strftime!  (2005-12-26)
CLOSED http://python.org/sf/1390605  opened by  Nikos Kouremenos

split() breaks no-break spaces  (2005-12-26)
CLOSED http://python.org/sf/1390608  opened by  MvR

time.strftime('%F', local_time) is okay but time.strptime no  (2005-12-26)
CLOSED http://python.org/sf/1390629  opened by  Nikos Kouremenos

lambda functions confused when mapped in dictionary object  (2005-12-27)
CLOSED http://python.org/sf/1390991  opened by  Samuel Hsiung

missing module names in email package  (2005-12-27)
   http://python.org/sf/1391608  opened by  Gabriel Genellina

floating point literals don't work in non-US locale in 2.5  (2005-12-28)
   http://python.org/sf/1391872  opened by  Fredrik Lundh

build fails on BSD 3.8  (2005-12-30)
   http://python.org/sf/1392915  opened by  George Yoshida

cannot build SVN trunk on old systems  (2005-12-29)
   http://python.org/sf/1393109  opened by  Fredrik Lundh

Deleting first item causes anydbm.first() to fail  (2005-12-30)
   http://python.org/sf/1394135  opened by  Dan Bisalputra

urllib2 raises exception when page redirects to itself  (2005-12-31)
CLOSED http://python.org/sf/1394453  opened by  René Pijlman

SimpleHTTPServer doesn't understand query arguments  (2005-12-31)
   http://python.org/sf/1394565  opened by  Aaron Swartz

'Plus' filemode exposes uninitialized memory on win32  (2005-12-31)
   http://python.org/sf/1394612  opened by  Cory Dodt

Bugs Closed
___

Decimal sqrt() ignores rounding  (2005-12-23)
   http://python.org/sf/1388949  closed by  facundobatista

Incorrect docs for return values of set update methods  (2005-12-24)
   http://python.org/sf/1389673  closed by  birkenfeld

Fxn call in _elementtree.c has incorrect signedness  (2005-12-25)
   http://python.org/sf/1389809  closed by  effbot

_winreg specifies EnvironmentError instead of WindowsError  (2005-12-21)
   http://python.org/sf/1386675  closed by  birkenfeld

time docs lack %F in strftime!  (2005-12-26)
   http://python.org/sf/1390605  closed by  birkenfeld

split() breaks no-break spaces  (2005-12-26)
   http://python.org/sf/1390608  closed by  lemburg

time.strftime('%F', local_time) is okay but time.strptime no  (2005-12-26)
   http://python.org/sf/1390629  closed by  birkenfeld

metaclasses, __getattr__, and special methods  (2003-04-29)
   http://python.org/sf/729913  closed by  arigo

special methods become static  (2004-11-15)
   http://python.org/sf/1066490  closed by  arigo

len() on class broken  (2005-12-16)
   http://python.org/sf/1382740  closed by  arigo

urllib.url2pathname, pathname2url doc strings inconsistent  (2002-12-07)
   http://python.org/sf/649974  closed by  birkenfeld

PyLong_AsVoidPtr()/PyLong_FromVoidPtr()  (2002-12-14)
   http://python.org/sf/653542  closed by  birkenfeld

Acrobat Reader 5 compatibility  (2003-04-14)
   http://python.org/sf/721160  closed by  birkenfeld

Calling socket.recv() with a large number breaks  (2003-06-17)
   http://python.org/sf/756104  closed by  birkenfeld

Automated daily documentation builds  (2002-06-26)
   http://python.org/sf/574241  closed by  

Re: python coding contest

2005-12-31 Thread Steven D'Aprano
On Sun, 01 Jan 2006 03:34:33 +0100, Claudio Grondi wrote:

 Please send me comments, suggestions and ideas.
 
 Now, after the contest is over I analysed the outcome of it and have 
 come to the conclusion, that there were two major factors which 
 contributed to squeezing of code:
 
(1). usage of available variants for coding of the same thing
(2). sqeezing the size of used numeric and string literals

[snip]

 Is there in Python any simple way to do the same as the following two 
 following functions I have put together today:

They are already pretty simple. You can make them even more simple by
using less complicated names and getting rid of the explicit end block
markers. It is sometimes useful to put in explicit end block markers when
you have long blocks, but when the block is just a single line, well,
I don't see the point.

Here is another possibility.

 import array
 A = array.array('b')
 n = 100
 while n:
... A.append(n255); n = n  8
... 
 A.reverse()
 A
array('b', [15, 66, 64])
 15*256**2 + 66*256 + 64
100
 A.tostring()
'\x0fB@'

The reverse transformation is just as easy:

 A = array.array('b', \x0fB@)  # initialise from a byte string
 n = 0L
 for b in A:
... n = n  8 | b
...
 n
100L

And of course these can be turned into functions.



-- 
Steven.

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


IDE for Python ?

2005-12-31 Thread news
I'm getting realy tired of learning new languages.
And especially frustrated at the 'syntax errors' when switching
between them.

There are basically only a few common concepts needed for 
all the languages.   Hence linux's p2c: Pascal to C translator.

A good IDE could hide the irrelevant details of the syntax,
much like DOS/Norton-commander--Linux/mc hides the
details, and makes visual, the common actions on files:
move, copy, view ...edit ...search etc.

Besides, I guess Python itself would be good to make such
an IDE ?   Is there any such tool available/recomended ?

== Chris Glur.

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


Re: Array construction from object members

2005-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2005 09:01:44 -0800, MKoool wrote:

 Hi everyone,
 
 I am doing several operations on lists and I am wondering if python has
 anything built in to get every member of several objects that are in an
 array, for example, if i have a class like the following:
 
 class myClass:
a = 0.0

Did you mean for a to be a class attribute? You possibly want something
like this:

class myClass:
def __init__(self, value=0.0):
self.a = value  # a for attribute

Then you can create new instances:

fred = myClass(2.7)
wilma = myClass()  # just use the default
betty = myClass(1.3)
barney = myClass(0.9)


 And lets say I populate the a element in an array of objects of
 myClass.  If I want to retrieve all items in this and perhaps give it
 to a mean function, I would need to make a loop now:
 
 mySimpleArray = []
 for i in range(0,len(myArray)):
 mySimpleArray.append(myArray[i].a)
 
 There must be some more efficient way to do this, can someone point me
 to the right direction so that I can review some documentation and get
 things a little more efficient?

myArray = [fred, wilma, betty, barney]

mySimpleArray = []
for person in myArray:
mySimpleArray.append(person.a)


Or try this:

mySimpleArray = [person.a for person in myArray]

Or this:

def mean_value(*people):
Takes a list of people and returns the mean of their attributes
total = 0.0
for person in people:
total += person.a
return total/len(people)

mean_value(fred, betty, barney, wilma)

That last version is not recommended, because it requires a separate
function for everything you want to calculate. For instance, if you add a
second attribute height to myClass, and want to work out the mean
height, you would need a second function to do it.



-- 
Steven.

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


Re: Python article in Free Software Magazine

2005-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2005 14:42:36 -0600, Kirk Strauser wrote:

 I wrote this article which was published in Free Software Magazine:
 
 http://www.freesoftwaremagazine.com/free_issues/issue_09/intro_zope_1/
 
 It's intended as a high-level overview of the language, and therefore
 glosses over some of the details.  For example, I describe its function
 calling mechanism as pass-by-reference, because that's close enough for
 newcomers to get the gist of it.

Then what you are describing is not Python, it is some mythical language
that is almost like Python, but just enough like C to confuse programmers
who think they have discovered a bug when the following doesn't work:

def increment(n, inc=1):
n += inc

n = 1
increment(n)
assert n == 2


Firstly, do no harm: if you aren't prepared to bite the bullet and say
call by object or call by object reference, then just don't do
it. It is better to not say what Python is than to describe it as
something it is not. Please don't invoke all the C baggage in developers'
minds by calling it call by reference.

I don't want to nit-pick all my way through the article, which
is very decent and is worth reading, but I will say one more thing: you
describe Python as an expressive, interpreted language. Python is no
more interpreted than Java. Like Java, it is compiled into byte-code which
is then executed by a virtual machine. It has a separate compilation and
execution step.

(Amazing how the Java virtual machine is one of the great buzz-word
selling features of the language, and yet Python people take it utterly
for granted.)

We both know that rational people shouldn't care about the difference
between compilers and interpreters: it is performance that counts, not
how you get it. We know that Python doesn't literally analyse the source
code over and over again, and no major interpreted language has done this
for probably two decades or more. We can argue about the differences
between interpretation, tokenization, compilation and execution, and
pedants like me will mention that machine code is interpreted by the CPU.

But sadly, many decision makers don't understand these subtleties. To
them, compiled languages like C++ and Java are Good, interpreted languages
are Bad and doomed to be slow and weak. As soon as you describe
Zope/Python as interpreted, you turn off maybe 25% or 50% of the Pointy
Haired Bosses who are making the decision of what technologies are used.

Buzz-words like interpreted and compiled trigger frames in the
reader's mind. They have connotations. You, as the author, aren't
responsible for the wrong-headed frames that many readers will bring
to the article, but you should be aware of them and work around them if
you can.



-- 
Steven.

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


[ python-Bugs-1394565 ] SimpleHTTPServer doesn't understand query arguments

2005-12-31 Thread SourceForge.net
Bugs item #1394565, was opened at 2005-12-31 15:46
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394565group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Aaron Swartz (aaronsw)
Assigned to: Nobody/Anonymous (nobody)
Summary: SimpleHTTPServer doesn't understand query arguments

Initial Comment:
If you set the SimpleHTTPServer to serve files and visit /filename it works 
but if you visit /filename?f=1 it returns a 404. It should strip off the query 
argument and visit /filename

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394565group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1394612 ] 'Plus' filemode exposes uninitialized memory on win32

2005-12-31 Thread SourceForge.net
Bugs item #1394612, was opened at 2005-12-31 16:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394612group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Cory Dodt (corydodt)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'Plus' filemode exposes uninitialized memory on win32

Initial Comment:
(Note: I'm using cygwin zsh, hence the prompts.  I am
using standard, python.org Python for these tests.)

% echo abcdef  foo
% python
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200
32 bit (Intel)] on win32
Type help, copyright, credits or license for
more information.
 f = file('foo','r+b')
 f.write('ghi')
 f.read()
'\x00x\x01\x83\x00\xe8\x03\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00e\x00\x00i\x01
\x00d\x00\x00\x83\x01\x00Fd\x01\x00S\x00S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00[...lots and lots and lots of
uninitialized memory deleted...]\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00abcdef\n'
 f.close()


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394612group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1394612 ] 'Plus' filemode exposes uninitialized memory on win32

2005-12-31 Thread SourceForge.net
Bugs item #1394612, was opened at 2006-01-01 00:06
Message generated for change (Comment added) made by clintonroy
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394612group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Cory Dodt (corydodt)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'Plus' filemode exposes uninitialized memory on win32

Initial Comment:
(Note: I'm using cygwin zsh, hence the prompts.  I am
using standard, python.org Python for these tests.)

% echo abcdef  foo
% python
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200
32 bit (Intel)] on win32
Type help, copyright, credits or license for
more information.
 f = file('foo','r+b')
 f.write('ghi')
 f.read()
'\x00x\x01\x83\x00\xe8\x03\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00e\x00\x00i\x01
\x00d\x00\x00\x83\x01\x00Fd\x01\x00S\x00S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00[...lots and lots and lots of
uninitialized memory deleted...]\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00abcdef\n'
 f.close()


--

Comment By: Clinton Roy (clintonroy)
Date: 2006-01-01 05:38

Message:
Logged In: YES 
user_id=31446

Hi Cory, I don't think r+ mode will create the file if it
doesn't exist, so at a guess I think what you're seeing is
the actual contents of a file named foo that are on the
disk, not junk. If you delete the file foo and run your test
again, you should get an error to that effect.

cheers,

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394612group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1394612 ] 'Plus' filemode exposes uninitialized memory on win32

2005-12-31 Thread SourceForge.net
Bugs item #1394612, was opened at 2005-12-31 19:06
Message generated for change (Settings changed) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394612group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Not a Bug
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Cory Dodt (corydodt)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'Plus' filemode exposes uninitialized memory on win32

Initial Comment:
(Note: I'm using cygwin zsh, hence the prompts.  I am
using standard, python.org Python for these tests.)

% echo abcdef  foo
% python
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200
32 bit (Intel)] on win32
Type help, copyright, credits or license for
more information.
 f = file('foo','r+b')
 f.write('ghi')
 f.read()
'\x00x\x01\x83\x00\xe8\x03\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00e\x00\x00i\x01
\x00d\x00\x00\x83\x01\x00Fd\x01\x00S\x00S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00[...lots and lots and lots of
uninitialized memory deleted...]\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
x00\x00\x00\x00abcdef\n'
 f.close()


--

Comment By: Tim Peters (tim_one)
Date: 2006-01-01 01:06

Message:
Logged In: YES 
user_id=31435

This is actually pilot error (not a bug!), although it's
subtle:  Python uses the platform C I/O implementation, and
in standard C mixing reads with writes yields undefined
behavior unless a file-positioning operation (typically a
seek()) occurs between switching from reading to writing (or
vice versa); here from the C standard:

When a file is opened with update mode (’+’ as the
second or third character in the above list of mode
argument values), both input and output may be
performed on the associated stream. However, output
shall not be directly followed by input without an
intervening call to the fflush function or to a file
positioning function (fseek, fsetpos, or rewind), and
input shall not be directly followed by output
without an intervening call to a file positioning
function, unless the input operation encounters
end-of-file.

In other words, the result of running your sample code is
undefined:  nothing is guaranteed about its behavior, which
both can and does vary across platforms.

If you want defined behavior, then, for example, add

 f.seek(0)

between your write() and read() calls.

--

Comment By: Clinton Roy (clintonroy)
Date: 2006-01-01 00:38

Message:
Logged In: YES 
user_id=31446

Hi Cory, I don't think r+ mode will create the file if it
doesn't exist, so at a guess I think what you're seeing is
the actual contents of a file named foo that are on the
disk, not junk. If you delete the file foo and run your test
again, you should get an error to that effect.

cheers,

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1394612group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com