A Byte of Python - Kraut Version

2006-03-11 Thread Christoph Zwerschke
The German translation of Swaroop's Python beginner tutorial
A Byte of Python (current version 1.20) has been finished.

The German version is available at: http://abop-german.berlios.de

Original (English) version at: http://www.byteofpython.info

Other translations: http://www.byteofpython.info/translations/

'A Byte of Python' is a book on programming using the Python language. 
It serves as a tutorial or guide to the Python language for a beginner 
audience. If all you know about computers is how to save text files, 
then this is the book for you.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANNOUNCE: kiwi 1.9.7

2006-03-11 Thread Johan Dahlin
New in this released is API documentation which is generated using
epydoc[3]. It's still being written but at this point I feel that
it's good enough to be a very useful resource to help understand
kiwi. Kiwi is a PyGTK framework for building graphical applications loosely
based on MVC Model-View-Controller (MVC) and Allen Holub's Visual proxy
[1]. Think of Kiwi as a high-level, object-oriented layer built on
PyGTK.

Its design is based on real-world experience using PyGTK to develop
large desktop applications, which use many concepts common to most
graphical applications: multiple windows and dialogs, forms, data
persistence, lists and high-level classes that support domain objects
directly.


Download


Grab the latest sources from:

  http://www.async.com.br/projects/kiwi/download/kiwi-1.9.7.tar.gz


What's new since 1.9.6?
===

- Much improved mask support
- DateEntry widget
- Re-add ProxyDelegate (lost since kiwi1)
- Draw validation icon on the left side for right align entries
- Many ComboEntry bug fixes
- Distribution helper improvements
- Limited support for zope.interfaces
- Add a better HIG alert dialog
- Improved logging (a la GStreamer)


Features


* An MVC-derived framework of classes:
  * Views, which represent the graphical display
  * Controllers, which handles user interaction with the widgets
in a View.
  * Delegates, combines a View and a Controller.
  * Models, which are special mixins for your domain objects
  * Proxies, special types of Delegate designed to implement forms

* Validation: Kiwi supports validation on different levels:
  data type validation and verification on the Model/Proxy level,
  View validation and hooks for visually displaying validation state.

* ObjectList widget, which provides a higher level abstraction of
  GtkTreeView and all its classes (GtkTreeModel, GtkTreeViewColumn,
  GtkCellRenderer) with hooks to easily integrate into the
  Kiwi Framework.

* Mask suport: You can set a mask on entries to force the input to
  follow a certain standard, such as zip code, social security, ip address

* Gazpacho integration for most (non-deprecated) interactive
  widgets with attributes for handling validation and proxy
  attributes.

* UI Test framework
  Features a recorder and a player. The recorder allows you to record
  different tasks, a script will be saved which will reproduce the
  actions you made in the interface.

* Kiwi Tasklets
  Tasklet is a small coroutines framework written by Gustavo Carneiro,
  it was previously known as gtasklets.

* PyGTK utilities, to make it easier to add signals and properties to
  your objects.

* i18n translation utilities, to help you translate PyGTK applications,
  currently depends on gettext and intltool.

* and many other things!


Requirements


Python 2.3 or higher (2.4 recommended)  http://www.python.org/
PyGTK 2.6.0 or higher (2.8 recommended) http://www.pygtk.org/
gazpacho 0.6.2 (svn recommenced)http://gazpacho.sicem.biz/


Documentation
=
Kiwi provides API documentation generated by epydoc, it can be found at

 http://www.async.com.br/projects/kiwi/api/

Included in the tarball are also a number of examples, which serves as a
good starting point. Keep in mind that most of them require gazpacho to
be installed.


Thanks
==
Christian Robottom Reis: Original author and design
Lorenzo Gil Sanchez: PyGTK 2.x port

Also thanks to the following people which has contributed features
or bug reports:
Ali Afshar, Henrique Romano, Daniel Saran R. da Cunha, Evandro Vale
Miquelito, Gustavo Barbieri, Gustavo Carneiro, Sidnei da Silva
Patrick O'Brien

Resources
=

Homepage http://www.async.com.br/projects/kiwi/
Download http://www.async.com.br/projects/kiwi/download/
Repository   http://svn.async.com.br/cgi-bin/viewcvs.cgi/kiwi/
Report a bug http://bugs.async.com.br/enter_bug.cgi?product=Kiwi
API docs http://www.async.com.br/projects/kiwi/api/
Open bugshttp://tinyurl.com/cyrms
Mail. list   http://www.async.com.br/mailman/listinfo/kiwi/

[1] http://en.wikipedia.org/wiki/Model-view-controller
[2] http://tinyurl.com/2ccch
[3] http://epydoc.sourceforge.net/

-- 
Johan Dahlin [EMAIL PROTECTED]
Async Open Source




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

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


Using len()

2006-03-11 Thread ctilly
I have what I think is a very simple question.  I have a Python script
that I found that I want to tweek a little bit.  All I want to do is
add in a validator to make sure a value has been keyed into the imput
box.

The code currently is...
while yourguess != mynum:

tries = tries + 1
yourguess = input(Your guess? )

if  (yourguess != mynum):

#blah blah blah

# end of the if statement
# repeat until user gets it right

But I would like to change it to be something like

while yourguess != mynum:

tries = tries + 1
yourguess = input(Your guess? )

if len(yourguess)==0:
continue

elif (yourguess != mynum):

#blah blah blah

# end of the if statement
# repeat until user gets it right

But this throws the following error and I have no idea why.  Please
enlighten.

My error ==  len() of unsized object

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


Re: Performance impact of using decorators

2006-03-11 Thread Peter Otten
vinjvinj wrote:

 I'm building an application with cherrypy and have started using
 decorators quite extensively. A lot of my exposed functions look like:
 
 @expose
 @startTransactrionAndBuildPage
 @partOfTabUi(tabId)
 @convert(arg1=int, arg2=str)
 def do_main_page(self, arg1, arg2):
some code
 
 
 I've become really fond of decorators and use them quite a lot. I've
 also ready that function calls are expensive in python. In the above
 example, does the interpreter call 5 different functions?

A typical function calls a few other functions already, so three extra
function calls (I suppose expose just sets an attribute) shouldn't matter
much. You shouldn't even start rewriting your code unless you have
identified do_main_page() as a performance bottleneck. In a web app,
candidates would be functions that are called hundred or thousand times per
rendered page rather than once. Does do_main_page() render a complete page?
Forget optimizing three function calls away. You will see no effect.

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


ERROR when hitting RETURN on INPUT

2006-03-11 Thread ctilly
How do you prevent getting the following error when you hit the RETURN
key on an empty INPUT prompt from windows?

If I am at the Interactive Window and I type in: input(blah), I get
an input dialog.  If I then hit ENTER w/o keying in a value I get the
following error.  WHY

SyntaxError: unexpected EOF while parsing

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


Re: Using len()

2006-03-11 Thread Bryan Olson
[EMAIL PROTECTED] wrote:
[...]
 But I would like to change it to be something like
 
 while yourguess != mynum:
 
   tries = tries + 1
   yourguess = input(Your guess? )
 
   if len(yourguess)==0:
   continue
[...]
 But this throws the following error and I have no idea why.  Please
 enlighten.
 
 My error ==  len() of unsized object

The innocent sounding function input() actually invokes the perilous
eval(). Read about it at:

http://docs.python.org/lib/built-in-funcs.html

Try rawinput() instead.


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


Re: Using len()

2006-03-11 Thread ctilly
That works, thanks.  Can you tell me why the differences exist?

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


Re: counting number of (overlapping) occurances

2006-03-11 Thread Fredrik Lundh
Steven D'Aprano wrote

 You should always quote enough of the previous poster's message to give
 context. Messages sometimes go missing in Usenet, and people won't have
 the foggiest idea what you are talking about.

one would think that given how many Pythoneers we now have working
for google, at least one of them could go fix the horridly broken posting
interface in googlegroups...

:::

for those who use googlegroups and prefer to make a least a little sense
to people read this newsgroup/mailing list using other tools, please click
show options and use the reply link at the top of the message instead
of the link with the same name at the bottom.

/F



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


OT: Sixteen Thousand Oranges

2006-03-11 Thread Gerard Flanagan
Dennis Lee Bieber wrote:
 On Sat, 11 Mar 2006 13:30:43 +1100, Tim Churches
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:

  Would it be possible to rename Cheese Shop as Bright Side of Life?
 
   I think I'd prefer The Larch...

   Or just SPAM (something Python something Modules ?)
 --

 ...nostalgic flashback to D.R. and Quinch - 'Something Something
Oranges Something',

and Google provides:  http://mindtheoranges.net/

lol. :-)

Gerard

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


Re: Cheese Shop - BSOL?

2006-03-11 Thread Just
In article [EMAIL PROTECTED],
 Dennis Lee Bieber [EMAIL PROTECTED] wrote:

 On Sat, 11 Mar 2006 13:30:43 +1100, Tim Churches
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
  Would it be possible to rename Cheese Shop as Bright Side of Life?
 
   I think I'd prefer The Larch...
 
   Or just SPAM (something Python something Modules ?)

Standard Python Archive (of) Modules?

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


Re: Using len()

2006-03-11 Thread Fredrik Lundh
Bryan Olson wrote:

 Try rawinput() instead.

or, less likely to give a NameError,

raw_input()

/F



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


Re: Using len()

2006-03-11 Thread Jonathan Gardner
Methinks you are confused about the structure of your program.

If we write the program out in plain English in the form of a recipe,
it should look something like this:

1. Get input.
2. Check to see if they guessed right.
3. If not, go back to 1.

This structure hints at an infinite loop. The breakout condition is a
correct guess. You always need a breakout condition, or the loop goes
on forever. (Sometimes you do want an infinite loop. Think about how
you would write a web server.)

(Note on variable names: your and my are not clear. Usually, first
person (I, me, my) refers to the programmer. The second person
(you, your) is rarely used. You could be the user, the computer,
or another programmer. Just use third person (it, he, they).

So, we write an infinite loop in Python:

while True:

  # Get input
  guess = raw_input()

  # Is the guess right?
  if guess == num:
# Yep. Break out of the loop.
break

  # Otherwise, loop again.

You could put the breaking condition in the while line. But since it
appears in the middle of the loop, this is difficult to do. So just put
it in explicitly in the middle and call it a day.

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


Re: Using len()

2006-03-11 Thread Steven D'Aprano
On Sat, 11 Mar 2006 01:05:48 -0800, ctilly wrote:

 That works, thanks.  Can you tell me why the differences exist?

For those who have just joined us, that is using raw_input() instead of
input().

I don't know why input() is the equivalent of eval(raw_input(prompt)), but
it is. Presumably Guido thought it was a good idea at the time. I recall
hearing somewhere that Guido is planning to rename raw_input() to input()
some time in Python 3.


-- 
Steven.

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


Inconsistency of special class method lookup?

2006-03-11 Thread anne . nospam01
Folks,

I'm running into the following issue. A staticmethod of a class seems
not to be accepted as a special class method of the class object
itself. For example:

class Foo(object):
def __len__(): return 2
__len__ = staticmethod(__len__)
print len(Foo)

Traceback (most recent call last):
  File C:/Dokumente und Einstellungen/All Users/Dokumente/foo.py,
line 4, in ?
print len(Foo)
TypeError: len() of unsized object

However, the following works:

class FooType(type):
def __len__(self): return self.l()
class Foo(object):
__metaclass__ = FooType
def l(): return 3
l = staticmethod(l)
print len(Foo)

3

Any good reason why the lookup process doesn't find __len__ as
staticmethod of the class?

Regards,
Sebastian (posting using the account of my wife)

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


Re: Using len()

2006-03-11 Thread Fredrik Lundh
Steven D'Aprano wrote:

 I don't know why input() is the equivalent of eval(raw_input(prompt)), but
 it is. Presumably Guido thought it was a good idea at the time.

possibly inspired by ABC's READ and READ RAW commands:

http://homepages.cwi.nl/~steven/abc/qr.html

/F



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


Re: why no block comments in Python?

2006-03-11 Thread Jonathan Gardner
Warby wrote:
 ...and I forgot to mention that the output of grep and diff is far more
 understandable in the absence of block comments!

Which is why people do this /anyway/. (Kind of makes block comments
pointless, doesn't it?

/* This is a 
 * really
 * really
 * long
 * block comment */

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


Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I use python in Windows XP platform. I find that if I write a .py file
in a directory, such as windows desktop, in which a file named
'ticket.txt' is located:

f=open(\ticket.txt)
print f.read()

In IDLE, this py file work all right. But if I launch python
interpretor in the command shell like this:

C:\Documents and Settings\Xiaozhong Zhengpython C:\Documents and
Settings\Xiao
zhong Zheng\Desktop\t.py

The interpretor would not find the file.

Traceback (most recent call last):
  File C:\Documents and Settings\Xiaozhong Zheng\Desktop\t.py, line
1, in ?
f=open(ticket.txt)
IOError: [Errno 2] No such file or directory: 'ticket.txt'

Anyone knows why?


In addition, if I start IIS web service that runs .py file as CGI
program, then this .py file also works.

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


Re: MS Access db (mdb): viewing table attributes

2006-03-11 Thread Steve Holden
BartlebyScrivener wrote:
 Gau,
 
 This prints the names of the columns in my database.
 
 # Modification of
 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/389535
 # Instructions for customizing are at:
 # http://www.egenix.com/files/python/mxODBC.html
 
 import mx.ODBC.Windows as odbc
 
 driv='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:/Access
 Databases/Quotations2005'
 
 conn = odbc.DriverConnect(driv)
 c = conn.cursor()
 
 # get the column names from Table1
 c.execute (SELECT * FROM Table1)
 
 # get column names
 cols= [ i[0] for i in c.description ]
 print '\n\ncols=',cols
 
Note that there's no requirement that the SELECT actually retrieve any 
data, son the normal technique is to use a query guaranteed to return no 
rows, such as

 SELECT * FROM Table1 WHERE 1=0

See also

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81189

for an algorithm that will show data fron an arbitrary query in a 
reasonably tidy display.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: time series calculation in list comprehension?

2006-03-11 Thread Peter Otten
Lonnie Princehouse wrote:

 You really want to use the value calculated for the i_th term in the
 (i+1)th term's evaluation.   

It may sometimes be necessary to recalculate the average for every iteration
to avoid error accumulation. Another tradeoff with your optimization is
that it becomes harder to switch the accumulation function from average to
max, say.

 While it's not easy (or pretty) to store state between iterations in a
 list comprehension, this is the perfect use for a generator:
 
   def generator_to_list(f):
 return lambda *args,**keywords: list(f(*args,**keywords))
 
 [EMAIL PROTECTED]
   def moving_average(sequence, n):
 assert len(sequence) = n and n  0
 average = sum(sequence[:n]) / n
 yield average
 for i in xrange(1, len(sequence)-n+1):
   average += (sequence[i+n-1] - sequence[i-1]) / n
   yield average

Here are two more that work with arbitrary iterables:

from __future__ import division

from itertools import islice, tee, izip
from collections import deque

def window(items, n):
it = iter(items)
w = deque(islice(it, n-1))
for item in it:
w.append(item)
yield w # for a robust implementation:
# yield tuple(w)
w.popleft()

def moving_average1(items, n):
return (sum(w)/n for w in window(items, n))

def moving_average2(items, n):
first_items, last_items = tee(items)
accu = sum(islice(last_items, n-1))
for first, last in izip(first_items, last_items):
accu += last
yield accu/n
accu -= first

While moving_average1() is even slower than your inefficient variant,
moving_average2() seems to be a tad faster than the efficient one.

Peter

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


Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I use python on Windows XP platform. I find that if I write a .py file
in a directory, such as windows desktop, in which a file named
'ticket.txt' is located:

f=open(ticket.txt)
print f.read()


In IDLE, this py file work all right. But if I launch python
interpretor in the command shell like this:


C:\Documents and Settings\Xiaozhong Zhengpython C:\Documents and
Settings\Xiaozhong Zheng\Desktop\t.py


The interpretor would not find the file.


Traceback (most recent call last):
  File C:\Documents and Settings\Xiaozhong Zheng\Desktop\t.py, line
1, in ?
f=open(ticket.txt)
IOError: [Errno 2] No such file or directory: 'ticket.txt'


Anyone knows why?


In addition, if I start IIS web service that runs .py file as CGI
program, then this .py file also works.

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


Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Fredrik Lundh
Sullivan WxPyQtKinter wrote:

 I use python in Windows XP platform. I find that if I write a .py file
 in a directory, such as windows desktop, in which a file named
 'ticket.txt' is located:

 f=open(\ticket.txt)
 print f.read()

\t is a tab character:

 print '\ticket.txt'
icket.txt

try opening r\ticket.txt or /ticket.txt instead.

/F



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


Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
Sorry, I mistyped the line. In the program it IS:
f=open(ticket.txt), no '\' included.

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


Re: put multiple condition in if statement

2006-03-11 Thread Terry Hancock
On 10 Mar 2006 21:12:57 -0800
[EMAIL PROTECTED] wrote:
 How can I put multiple condition in if statement?
 I try this, but I can't get that to work.
 
 if ( (str !=  )  (str != ) ):

if s!=' ' and s!='':

1) logical operators are words
2) don't overload standard type names

this is actually better style:

if s not in (' ', ''):



-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

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


Re: ERROR when hitting RETURN on INPUT

2006-03-11 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 How do you prevent getting the following error when you hit the RETURN
 key on an empty INPUT prompt from windows?
 
 If I am at the Interactive Window and I type in: input(blah), I get
 an input dialog.  If I then hit ENTER w/o keying in a value I get the
 following error.  WHY
 
 SyntaxError: unexpected EOF while parsing
 
Because the input() function expects a Python expression that it can 
evaluate to return a result. You probably want raw_input() instead.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: Inconsistency of special class method lookup?

2006-03-11 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 class Foo(object):
 def __len__(): return 2
 __len__ = staticmethod(__len__)
 print len(Foo)
 
 Traceback (most recent call last):
   File C:/Dokumente und Einstellungen/All Users/Dokumente/foo.py,
 line 4, in ?
 print len(Foo)
 TypeError: len() of unsized object
 
 However, the following works:
 
 class FooType(type):
 def __len__(self): return self.l()
 class Foo(object):
 __metaclass__ = FooType
 def l(): return 3
 l = staticmethod(l)
 print len(Foo)
 
 3
 
 Any good reason why the lookup process doesn't find __len__ as
 staticmethod of the class?

Special methods of newstyle objects are always looked up in the class, and
the class of a class is its metaclass. Therefore 

len(Foo()) invokes type(Foo()).__len__ which is the same as Foo.__len__

and

len(Foo) invokes type(Foo).__len__ which (in your example) is the same as
FooType.__len__.


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


Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Fredrik Lundh
Sullivan WxPyQtKinter wrote:

 In IDLE, this py file work all right. But if I launch python
 interpretor in the command shell like this:


 C:\Documents and Settings\Xiaozhong Zhengpython C:\Documents and
 Settings\Xiaozhong Zheng\Desktop\t.py

 The interpretor would not find the file.

open(ticket.txt) means look for ticket.txt in the current directory,
not in the directory where the PY file lives.  if you change to the Desk-
top directory before you run the Python interpreter, your script should
work as expected.

to fix this, you can

- use a full path

or

- use os.path.basedir(__file__) to get the directory where the module
  lives, and do something like

root = os.path.basedir(__file__)
ticketfile = os.path.join(root, ticket.txt)
f = open(ticketfile)

/F



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


New python.org site

2006-03-11 Thread Bertrand Mansion
Hi,

First some introduction, my name is Bertrand Mansion, I am still
learning Python and I am new to this list. I have been developping
websites since 1995 and I use PHP since 1999. I have been contributing
to open source projects in the PHP and Apple Objective-C Cocoa
framework community. I studied business at school...

I will go straight to the point, I don't like the new Python.org
website. I didn't like the old one neither. The new one is not better
nor worse than the old one, it's just a different shell. But in my
opinion, it misses the point as well.

I am motivated to make a better website for python.org. Why ? Because
I am learning the language and I need a good resource to learn from.
In its current state, I wouldn't want to use python.org because it's
messy and doesn't match what I expect. It simply doesn't match the
quality of the language.

Note that I don't care about the logo, the colors, whatever is
personal tastes related and that's not my point. In my opinion, the
design has to fit a mission. I don't think a list of objectives was
defined prior to the new redesign. Here would be my list of objectives
for a new website, feel free to add your own:

1. Give a clear overview of what's available on python.org
2. Organize content and make it easy to access it
3. Be a gathering point for the existing community
4. Reinforce the Python image among the would-be python developers/users
5. Make it easy to add new features in the future

Each of these points would need to be extended and detailed.

Now I have a few questions:

* Is there a community interested in building a better python.org website ?
  - An active mailing list dedicated to python.org ?
  - A wiki with some improvement ideas ?

* Where is the current source code of python.org ?
  - Where are the scripts ?
  - Where are the designs ?
  - Is there a SCM available for checkout ?

* Who is currently maintaining python.org ?
  - Design
  - Code
  - Goals and objectives

* Was the last redesign a community effort or the work of one or a company ?

* How about organizing a community contest for both the logo and the
site design ?
Many people are concerned, I am pretty sure there will be a lot of
contributions, even from outside the Python community (for the
fame...). The winners could be decided by half a jury and half the
community votes. There would be a website to be done to take care of
the applications. Maybe some companies would be willing to sponsor.

Thanks for your replies,


Bertrand Mansion
Mamasam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to best update remote compressed, encrypted archives incrementally?

2006-03-11 Thread robert
Steven D'Aprano wrote:
 On Fri, 10 Mar 2006 15:13:07 +0100, robert wrote:
 
 
Hello,

I want to put (incrementally) changed/new files from a big file tree 
directly,compressed and password-only-encrypted to a remote backup 
server incrementally via FTP,SFTP or DAV  At best within a closed 
algorithm inside Python without extra shell tools.
 
 
 What do you mean by closed algorithm?
 
 The only thing I can think of is you mean a secret algorithm, one which
 nobody but yourself will know. So let's get this straight... you are
 asking a public newsgroup dedicated to an open-source language for
 somebody to tell you a secret algorithm that only you will know?
 
 Please tell me I've misunderstood.

no. I meant it terms of 'cohesive' : A Python solution without a lot of 
other tools. (Only the password has to be secret)

(The method should work with any protocol which allows somehow read, 
write  seek to a remote file.)
On the server and the transmission line there should never be 
unencrypted data.
 
 
 Break the job into multiple pieces. Your task is:
 
 - transmit information to the remote server;
 
 Can you use SSH for that? SSH will use industrial strength encryption,
 likely better than anything you can create.

Yes, sftp (=SSH) or ftp with TSL (=SSL) are good protocols. They can 
also read/navigate in a remote fila and append-to-file. But how about 
incremental+encrypted?

 - you want to update the files at the other end;
 
 Sounds like a job for any number of already existing technologies, like
 rsync (which, by the way, already uses ssh for the encrypted transmission
 of data).

As far as I know, rsync cannot update compressed+encrypted into an 
existing file(set) ?
I any case with rsync I would have to have a duplicate of the backup 
file geometry on the local machine (consuming another magnitude of the 
file stuff itself) ?

Thats why I ask: how to get all these tasks into a cohesive encrypted 
backup solution not wasting disk space and network bandwidth?

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


RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread robert
In very rare cases a program crashes (hard to reproduce) :

* several threads work on an object tree with dict's etc. in it. Items 
are added, deleted, iteration over .keys() ... ). The threads are good 
in such terms, that this core data structure is changed only by atomic 
operations, so that the data structure is always consistent regarding 
the application. Only the change-operations on the dicts and lists 
itself seem to cause problems on a Python level ..

* one thread periodically pickle-dumps the tree to a file:
cPickle.dump(obj, f)

RuntimeError: dictionary changed size during iteration is raised by 
.dump ( or a similar ..list changed ... )

What can I do about this to get a stable pickle-dump without risiking 
execution error or even worse - errors in the pickled file ?

Is a copy.deepcopy  ( - cPickle.dump(copy.deepcopy(obj),f) ) an 
atomic opertion with a guarantee to not fail?

Or can I only retry several times in case of RuntimeError?  (which would 
apears to me as odd gambling; retry how often?)

Robert


PS: Zope dumps thread exposed data structes regularly. How does the ZODB 
in Zope handle dict/list changes during its pickling operations?


---
Python 2.4.1 (#2, May  5 2005, 11:32:06)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop - BSOL?

2006-03-11 Thread Paul Boddie
Tim Churches wrote:
 Would it be possible to rename Cheese Shop as Bright Side of Life?

Well, you could replay the conversation I gave as an example elsewhere
to see if it sounds ridiculous or not, but what we've encountered here
is the problem of whether something should be given a distinctive
identity or a derivative identity. A long time ago, and possibly
continuing to this day, people complained about how nearly every Python
package, module or program had names starting or ending with Py -
announcing a module in a Python newsgroup and giving it a name starting
with Py seemed somewhat redundant, and there was always the issue of
not being able to scan long lists of packages comfortably, just like
with all the KDE application names that start with the letter K.

But even without the curse of Py, many people don't just choose
arbitrary names for their packages: it often makes sense to include
related technologies in the name (eg. XML, XSLT, ado, dav), or to use a
descriptive component, possibly in shortened form (eg. auth, bayes,
bio, Cal). Yes, a search will often bring forth the right resource
regardless of what it's called, but many people underestimate their own
searching skills and overestimate what other people can find via things
like Google.

Of course, programs may downplay Python as the implementation
technology because the underlying technical details are mostly
irrelevant to end-users (eg. BitTorrent, b3, Eric, Glarf), but if we
look at distinctively named packages, we can see that they often
attempt to define their own identity distinct from Python (eg.
BeautifulSoup, Dabo, DejaVu, Django, Twisted, Zope), frequently because
they seek to be the primary point of reference for developers -
developing in Twisted or Zope is more specialised than just developing
things in Python. Some of the distinctively named package names employ
metaphors and/or cultural references that possibly make them more
memorable, but they don't necessarily make the names easy to guess.

So should a service for finding Python packages have a distinct
identity? It is possible that a package index could be someone's
principal view of the Python world (I go to Camelot to get... what is
it I get there?), but the things that emerge from such a service
aren't just downloads that have little in common with each other.
Consequently, I don't think a descriptive name, derived from the name
of the technology, is sensibly avoided in this case.

Paul

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


Re: Inconsistency of special class method lookup?

2006-03-11 Thread anne . nospam01
Thanks.

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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread robert

 Is a copy.deepcopy  ( - cPickle.dump(copy.deepcopy(obj),f) ) an 
 atomic opertion with a guarantee to not fail?
 
 Or can I only retry several times in case of RuntimeError?  (which would 
 apears to me as odd gambling; retry how often?)

For an intermediate solution, I'm playing roulette:

 for i in 1,2,3:
 try:
 cPickle.dump(obj, f)
 break
 except RuntimeError,v:
 pass


I hope this works for some million years ...



 PS: Zope dumps thread exposed data structes regularly. How does the ZODB 
 in Zope handle dict/list changes during its pickling operations?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread robert
robert wrote:

 
 Is a copy.deepcopy  ( - cPickle.dump(copy.deepcopy(obj),f) ) an 
 atomic opertion with a guarantee to not fail?

 Or can I only retry several times in case of RuntimeError?  (which 
 would apears to me as odd gambling; retry how often?)
 
 
 For an intermediate solution, I'm playing roulette:
 
 for i in 1,2,3:
 try:
 cPickle.dump(obj, f)
 break
 except RuntimeError,v:
 pass
 

hmm..

 for i in 1,2,3:
 try:
 cPickle.dump(obj, f)
 break
 except RuntimeError,v:
 f.seek(0);f.truncate(0)


Meanwhile I think this is a bug of cPickle.dump: It should use .keys() 
instead of free iteration internally, when pickling elementary dicts. 
I'd file a bug if no objection.

Robert


 I hope this works for some million years ...
 
 
 
 PS: Zope dumps thread exposed data structes regularly. How does the 
 ZODB in Zope handle dict/list changes during its pickling operations?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread Felipe Almeida Lessa
Em Sáb, 2006-03-11 às 12:49 +0100, robert escreveu:
 Meanwhile I think this is a bug of cPickle.dump: It should use .keys() 
 instead of free iteration internally, when pickling elementary dicts. 
 I'd file a bug if no objection.

AFAICS, it's a problem with your code. You should lock your object while
using it. That's what Threading.Lock is supposed to work for. If you
want to use threads, you have to know in what parts of your code there
should be locks.

Cya,
Felipe.

-- 
Quem excele em empregar a força militar subjulga os exércitos dos
outros povos sem travar batalha, toma cidades fortificadas dos outros
povos sem as atacar e destrói os estados dos outros povos sem lutas
prolongadas. Deve lutar sob o Céu com o propósito primordial da
'preservação'. Desse modo suas armas não se embotarão, e os ganhos
poderão ser preservados. Essa é a estratégia para planejar ofensivas.

  -- Sun Tzu, em A arte da guerra

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

Re: How to best update remote compressed, encrypted archives incrementally?

2006-03-11 Thread Steven D'Aprano
On Sat, 11 Mar 2006 11:46:24 +0100, robert wrote:

 Sounds like a job for any number of already existing technologies, like
 rsync (which, by the way, already uses ssh for the encrypted transmission
 of data).
 
 As far as I know, rsync cannot update compressed+encrypted into an 
 existing file(set) ?
 I any case with rsync I would have to have a duplicate of the backup 
 file geometry on the local machine (consuming another magnitude of the 
 file stuff itself) ?

Let me see if I understand you.

On the remote machine, you have one large file, which is compressed and
encrypted. Call the large file Archive. Archive is made up of a number
of virtual files, call them A, B, ... Z. Think of Archive as a compressed
and encrypted tar file.

On the local machine, you have some, but not all, of those smaller
files, let's say B, C, D, and E. You want to modify those smaller files,
compress them, encrypt them, transmit them to the remote machine, and
insert them in Archive, replacing the existing B, C, D and E.

Is that correct?

 Thats why I ask: how to get all these tasks into a cohesive encrypted 
 backup solution not wasting disk space and network bandwidth?

What's your budget for developing this solution? $100? $1000? $10,000?
Stop me when I get close. Remember, your time is money, and if you are a
developer, every hour you spend on this is costing your employer anything
from AUD$25 to AUD$150. (Of course, if you are working for yourself, you
might value your time as Free.)

If you have an unlimited budget, you can probably create a solution to do
this, keeping in mind that compressed/encrypted and modify-in-place
*rarely* go together. 

If you have a lower budget, I'd suggest you drop the single file
requirement. Hard disks are cheap, less than an Australian dollar a
gigabyte, so don't get trapped into the false economy of spending $100 of
developer time to save a gigabyte of data. Using multiple files makes it
*much* simpler to modify-in-place: you simply replace the modified file.
Of course the individual files can be compressed and encrypted, or you can
use a compressed/encrypted file system. 

Lastly, have you considered that your attempted solution is completely the
wrong way to solve the problem? If you explain _what_ you are wanting to
do, rather than _how_ you want to do it, perhaps there is a better way.


-- 
Steven.

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


why g.count('')==2 ?

2006-03-11 Thread ygao
my question is as title!
thanks!

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


Re: why g.count('')==2 ?

2006-03-11 Thread Fredrik Lundh
ygao wrote:

 my question is as title!

my answer as code:

 s = g
 t = 
 s[0:0+len(t)] == t
True
 s[1:1+len(t)] == t
True

/F



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


Re: %r

2006-03-11 Thread Fredrik Lundh
Blackbird wrote:

 By cargo cult programming, do you mean actually *running* the code?

no, I mean basing your mental model of something on distant observations
of superficial (or accidental) artifacts (like the perceived similarity between
the output from repr() and the raw string literal syntax), rather than on an
attempt to understand what's really going on, and what causes what.

or something like that.

/F



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


Re: why g.count('')==2 ?

2006-03-11 Thread Steven D'Aprano
On Sat, 11 Mar 2006 13:37:05 +0100, Fredrik Lundh wrote:

 ygao wrote:
 
 my question is as title!
 
 my answer as code:
 
 s = g
 t = 
 s[0:0+len(t)] == t
 True
 s[1:1+len(t)] == t
 True


Or in other words, imagine that Python is walking the string looking to
match the target. The empty string matches the boundary of every character
with the next character, or in other words, for a string s of length N,
s.count('') will equal N+1.

I'm not sure what to describe this surprising result as. It isn't a bug;
it isn't even really a gotcha. I guess the best description is that it is
just a surprising, but logical, result.

(Well, I was surprised -- but I can't fault the logic.)


-- 
Steven.

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


Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I see. I once was a VB programmer. In VB, the current directory is
always set to where the module locates before it runs.

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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread EleSSaR^
robert si è profuso/a a scrivere su comp.lang.python tutte queste
elucubrazioni: 

[cut]

I don't know what's your code like, but a similar error occurred in some of
my software and it was my fault indeed. I think you should either use a
lock, or implement a deepcopy method of your own.

-- 
EleSSaR^ [EMAIL PROTECTED]
--
Togli .xyz dalla mia email per contattarmi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop - BSOL?

2006-03-11 Thread Kay Schluehr

Paul Boddie wrote:
 Tim Churches wrote:
  Would it be possible to rename Cheese Shop as Bright Side of Life?

 Well, you could replay the conversation I gave as an example elsewhere
 to see if it sounds ridiculous or not, but what we've encountered here
 is the problem of whether something should be given a distinctive
 identity or a derivative identity. A long time ago, and possibly
 continuing to this day, people complained about how nearly every Python
 package, module or program had names starting or ending with Py -
 announcing a module in a Python newsgroup and giving it a name starting
 with Py seemed somewhat redundant, and there was always the issue of
 not being able to scan long lists of packages comfortably, just like
 with all the KDE application names that start with the letter K.

 But even without the curse of Py, many people don't just choose
 arbitrary names for their packages: it often makes sense to include
 related technologies in the name (eg. XML, XSLT, ado, dav), or to use a
 descriptive component, possibly in shortened form (eg. auth, bayes,
 bio, Cal). Yes, a search will often bring forth the right resource
 regardless of what it's called, but many people underestimate their own
 searching skills and overestimate what other people can find via things
 like Google.

 Of course, programs may downplay Python as the implementation
 technology because the underlying technical details are mostly
 irrelevant to end-users (eg. BitTorrent, b3, Eric, Glarf), but if we
 look at distinctively named packages, we can see that they often
 attempt to define their own identity distinct from Python (eg.
 BeautifulSoup, Dabo, DejaVu, Django, Twisted, Zope), frequently because
 they seek to be the primary point of reference for developers -
 developing in Twisted or Zope is more specialised than just developing
 things in Python. Some of the distinctively named package names employ
 metaphors and/or cultural references that possibly make them more
 memorable, but they don't necessarily make the names easy to guess.

 So should a service for finding Python packages have a distinct
 identity? It is possible that a package index could be someone's
 principal view of the Python world (I go to Camelot to get... what is
 it I get there?), but the things that emerge from such a service
 aren't just downloads that have little in common with each other.
 Consequently, I don't think a descriptive name, derived from the name
 of the technology, is sensibly avoided in this case.

 Paul

The problem I have with the cheese-shop is less a naming but a
usability issue. In some commercial projects that involve Python I
already integrated SQLite as a local database for storing and
retrieving all kind of configuration data as well as session data,
failure statistics etc. I also extended a Python console in order to
send SQL commands directly using this syntax $ select * from reports
where I should mention that this kind of integration was one of
the most acknowledged features by those who where Python sceptics. I
wonder if creating a database client, integreting it with a Python
console and shipping it with a Python setup would not leave behind all
other solutions in the field? BTW I'm not only intererested in the
functionality of a package but how well it performs how well it is
tested etc. The packages checked into the cheese-shop obtain already a
rough classification. If classification schemes become more usable it
is likely that they could be extended. 

Kay

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


Re: Can not find a file in CMD model python when everything is OK in IDLE

2006-03-11 Thread Sullivan WxPyQtKinter
I see. I once was a VB programmer. In VB, the current directory is
always set to where the module locates before it runs.

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


Re: why use special config formats?

2006-03-11 Thread gangesmaster
 Huh? You think a competent sys admin can't learn enough Python to hack
 your pickled file?

 Binary configs only keep out legitimate users who don't have the time or
 ability to learn how to hack the binary format. Black hats and power users
 will break your binary format and hack them anyway.

then you dont know what pickle is. pickle code is NOT python bytecode.
it's a bytecode they made in order to represent objects. you cannot
exploit in in the essence of running arbitrary code, unless you find
a bug in the pickle module. and that's less likely than you find a bug
in the parser of the silly config file formats you use.

i'm not hiding the configuration in binary files, that's not the
point. pickle is just more secure by definition.

aah. you all are too stupid.


-tomer

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


Re: New python.org site

2006-03-11 Thread Thorsten Kampe
* Bertrand Mansion (2006-03-11 10:23 +)
 I will go straight to the point, I don't like the new Python.org
 website.

Well, I like it.

 I didn't like the old one neither.

Yeah, the old one was a mess.

 The new one is not better nor worse than the old one, it's just a
 different shell. But in my opinion, it misses the point as well.
 
 I am motivated to make a better website for python.org. Why ? Because
 I am learning the language and I need a good resource to learn from.
 In its current state, I wouldn't want to use python.org because it's
 messy and doesn't match what I expect. It simply doesn't match the
 quality of the language.
 
 Note that I don't care about the logo, the colors, whatever is
 personal tastes related and that's not my point. In my opinion, the
 design has to fit a mission. I don't think a list of objectives was
 defined prior to the new redesign. Here would be my list of objectives
 for a new website, feel free to add your own:
 
 1. Give a clear overview of what's available on python.org
 2. Organize content and make it easy to access it
 3. Be a gathering point for the existing community
 4. Reinforce the Python image among the would-be python developers/users
 5. Make it easy to add new features in the future

Good points.
 
 Each of these points would need to be extended and detailed.
 
 Now I have a few questions:
 [...]

There have recently been threads here about the website. Maybe the
discussion there gives you some information needed:

* 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/f4c1585fe379d8ad/11fd0062787e374c?tvc=2q=group%3Acomp.lang.python+insubject%3Apython.orghl=en#11fd0062787e374c
* 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/23c5ee82f22757f3/2696c44b8385a8e8?tvc=2q=group%3Acomp.lang.python+insubject%3Apython.orghl=en#2696c44b8385a8e8
* 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/330af3b245145f7e/667bb15d53f0c555?tvc=2q=group%3Acomp.lang.python+insubject%3Apython.orghl=en#667bb15d53f0c555
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why use special config formats?

2006-03-11 Thread gangesmaster
 Why is the first uglier than the second?
YES THATS THE POINT. PYTHON CAN BE USED JUST LIKE A CONFIG FILE.

and if your users did
timeout = 300
instead of
timeout = 300

then either your config parser must be uber-smart and all-knowing, and
check the types of key-value pairs, or your server would crash. either
way is bad, and i prefer crash-on-use then
know-everything-and-check-at-the-parser-level.



good night,
-tomer

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


Re: why no block comments in Python?

2006-03-11 Thread Roy Smith
In article [EMAIL PROTECTED],
 Jonathan Gardner [EMAIL PROTECTED] wrote:

 Warby wrote:
  ...and I forgot to mention that the output of grep and diff is far more
  understandable in the absence of block comments!
 
 Which is why people do this /anyway/. (Kind of makes block comments
 pointless, doesn't it?
 
 /* This is a 
  * really
  * really
  * long
  * block comment */

Habit left over from the C days.  It was the only way of making a block 
comment stand out visually.  C++ has // comments, just like Python has #, 
but old habits die hard.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New python.org site

2006-03-11 Thread Bertrand Mansion
On 3/11/06, Thorsten Kampe [EMAIL PROTECTED] wrote:

 There have recently been threads here about the website. Maybe the
 discussion there gives you some information needed:

 * 
 http://groups.google.com/group/comp.lang.python/browse_thread/thread/f4c1585fe379d8ad/11fd0062787e374c?tvc=2q=group%3Acomp.lang.python+insubject%3Apython.orghl=en#11fd0062787e374c
 * 
 http://groups.google.com/group/comp.lang.python/browse_thread/thread/23c5ee82f22757f3/2696c44b8385a8e8?tvc=2q=group%3Acomp.lang.python+insubject%3Apython.orghl=en#2696c44b8385a8e8
 * 
 http://groups.google.com/group/comp.lang.python/browse_thread/thread/330af3b245145f7e/667bb15d53f0c555?tvc=2q=group%3Acomp.lang.python+insubject%3Apython.orghl=en#667bb15d53f0c555

I have read those, they look like Slashdot comments where you get some
people trying to post a good joke... They don't answer my simple
questions:

1. Who is maintaining python.org ?

2. Where is the site code/design available ?

3. Is the last redesign a solo or a community effort ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why property works only for objects?

2006-03-11 Thread Bruno Desthuilliers
Michal Kwiatkowski a écrit :
 Bruno Desthuilliers napisał(a):
 
Let me understand it clearly. If I change __class__ of an object,
existing attributes (so methods as well) of an object are still
accessible the same way and don't change its values. Only resolution of
attributes/methods not found in object is changed, as it uses new
version of __class__ to lookup names. Is this right?

Attributes, yes. Not methods. Methods are looked up in the class.
 
 
 My experience shows exactly the opposite. Any attribute/method you try
 to access is first looked up in object dictionary, then inside class
 definition.

Yes, that's what I said.

You wrote:

existing attributes (so methods as well) of an object are still
accessible the same way and don't change its values


Attributes (I mean instance attributes) living in the object's dict, 
they aren't impacted by the runtime class change. Methods being in the 
most common case (I'd say  99.9 %) defined *in the class*, if you 
change the class of an object, this is very likely to impact resolution 
of methods lookup.

Now I agree that the statement methods are looked up in the class is 
wrong. Methods are of course first looked up in the object, then in the 
class. But the case of a method living in the object's dict is not that 
common...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New python.org site

2006-03-11 Thread skip

Bertrand 1. Who is maintaining python.org ?

Start with mail to [EMAIL PROTECTED]

Bertrand 2. Where is the site code/design available ?

It's in Subversion.  Start here:

http://psf.pollenation.net/

Bertrand 3. Is the last redesign a solo or a community effort ?

Small community.  One person did the bulk of the work.  A sprint at the
recent PyCon a week ago finished many things off and got a lot of content
converted from the old site to the new.  Stuff that hasn't yet been
converted and hasn't had proper redirects set up falls through to the old
site (that is obvious when it happens).  Hopefully the number of pages where
that occurs is dropping.

Now the developers are tackling a lot of bug reports, converting the last
content and fixing redirect problems.

The conversion has been particularly challenging because not only was the
site redesigned from an appearance standpoint, it was restructured (almost
all content got new URLs) and a new content management system was written to
support the content (http://pyramid.pollenation.net/).  Oh, the Subversion
repository holding the content changed as well.

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


Re: How to best update remote compressed, encrypted archives incrementally?

2006-03-11 Thread robert
Steven D'Aprano wrote:


 Let me see if I understand you.
 
 On the remote machine, you have one large file, which is compressed and
 encrypted. Call the large file Archive. Archive is made up of a number
 of virtual files, call them A, B, ... Z. Think of Archive as a compressed
 and encrypted tar file.
 
 On the local machine, you have some, but not all, of those smaller
 files, let's say B, C, D, and E. You want to modify those smaller files,
 compress them, encrypt them, transmit them to the remote machine, and
 insert them in Archive, replacing the existing B, C, D and E.
 
 Is that correct?

Yes, that is it. In addition a possiblity for (fast) comparison of 
individual files would be optimal.

Thats why I ask: how to get all these tasks into a cohesive encrypted 
backup solution not wasting disk space and network bandwidth?
 
 What's your budget for developing this solution? $100? $1000? $10,000?
 Stop me when I get close. Remember, your time is money, and if you are a
 developer, every hour you spend on this is costing your employer anything
 from AUD$25 to AUD$150. (Of course, if you are working for yourself, you
 might value your time as Free.)
 
 If you have an unlimited budget, you can probably create a solution to do
 this, keeping in mind that compressed/encrypted and modify-in-place
 *rarely* go together. 
 
 If you have a lower budget, I'd suggest you drop the single file
 requirement. Hard disks are cheap, less than an Australian dollar a
 gigabyte, so don't get trapped into the false economy of spending $100 of
 developer time to save a gigabyte of data. Using multiple files makes it
 *much* simpler to modify-in-place: you simply replace the modified file.
 Of course the individual files can be compressed and encrypted, or you can
 use a compressed/encrypted file system. 
 
 Lastly, have you considered that your attempted solution is completely the
 wrong way to solve the problem? If you explain _what_ you are wanting to
 do, rather than _how_ you want to do it, perhaps there is a better way.

So, there seems to be a big barrier for that task, when encryption is on 
the whole archive. A complex block navigation within a block cipher 
would be required, and obviously there is no such (handy) code already 
existing. Or is there a encryption/decryption method which you can can 
use like a file pipe _and_ which supports 'seek'?

Thus, a simple method would use a common treshold timestamp or 
archive-bits and create multiple archive slices. (Instable when the file 
set is dynamic and older files are copied to the tree.)

2 nearly optimal solutions which allows comparing individual files

1st:
+ an (s)ftp(s)-to-zip/tar bridge seems to be possible. E.g. by hooking 
ZipFile to use a virtual self.fp
+ the files would be individually encrypted by a password
- an external tool like gpg -c is necessary; (or is there a good 
encryption with a native python module? Is PGP (password only) possible 
with a native python module? )
- the filenames would be visible

2nd:
+ manage a dummy file-tree locally for speedy comparision (with 0-length 
files)
+ create encrypted archive slices for upload with iterated filenames
- an external tool like gpg -c is necessary
- extra file tree or file attribute database
- unrolling status from multiple archive slices is arduous

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


Re: why use special config formats?

2006-03-11 Thread Fredrik Lundh
gangesmaster wrote:

  Binary configs only keep out legitimate users who don't have the time or
  ability to learn how to hack the binary format. Black hats and power users
  will break your binary format and hack them anyway.

 then you dont know what pickle is. pickle code is NOT python bytecode.
 it's a bytecode they made in order to represent objects. you cannot
 exploit in in the essence of running arbitrary code

import pickle
print pickle.loads(cos\nsystem\np0\n(S'echo really?'\np1\ntp2\nRp3\n.)

/F



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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread robert
Felipe Almeida Lessa wrote:

 Em Sáb, 2006-03-11 às 12:49 +0100, robert escreveu:
 
Meanwhile I think this is a bug of cPickle.dump: It should use .keys() 
instead of free iteration internally, when pickling elementary dicts. 
I'd file a bug if no objection.
 
 
 AFAICS, it's a problem with your code. You should lock your object while
 using it. That's what Threading.Lock is supposed to work for. If you
 want to use threads, you have to know in what parts of your code there
 should be locks.

99.99% no. I would have to use a lock everywhere, where I add or remove 
something into a dict or list of the struct. Thats not the purpose of 
big thread locks. Such simple operations are already atomic by the 
definition of Python - and thanks to the global interpreter lock. 
(Otherwise I would leave the Python language, God beware ... :-) )

I'm of course aware, where to use locks for resons of the application. 
But this is an issue on Python level. And it can be solved gracly and 
simple in Python  - I guess:

If cPickle.dump (and maybe also copy/deepcopy?) is corrected to work 
atomic on dicts (use .keys()) and list-copies or locks python threads) 
the problem is solved gracely and generally.

Robert







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

Re: put multiple condition in if statement

2006-03-11 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 Hi,
 
 How can I put multiple condition in if statement?

With ands and ors.

 
 I try this, but I can't get that to work.
 
 if ( (str !=  )  (str != ) ):

joke type=lame
FWIW, I would not hope a type to be equal to a string !-)
/joke

 Any help is appreciated.

doesn't work is the most useless possible description of a problem. As 
a general rule, please:
- post the minimal running code that exhibit the problem
- clearly state the result you hoped and the result you got.

Also, don't use builtin names as identifier. str is the string type, 
so using str as an identifier will shadow the str type.

And, finally, you don't even need multiple conditions here - this should 
be enough (using 'my_string' instead of 'str'):

if my_string.strip() :
   ...

In Python, an empty sequence (strings, lists, tuples, ...), an empty 
mapping (dict, ...), the integer 0 and the float 0.0 are all evalued to 
False in a boolean expression. So any non-empty string evals to True. 
The method strip() of type str returns a copy of the string with leading 
and trailing whitespaces removed, so  .strip() will return .

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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread robert
EleSSaR^ wrote:

 robert si è profuso/a a scrivere su comp.lang.python tutte queste
 elucubrazioni: 
 
 [cut]
 
 I don't know what's your code like, but a similar error occurred in some of
 my software and it was my fault indeed. I think you should either use a
 lock, or implement a deepcopy method of your own.

100s of locks? no (see other message). It should be

own deepcopy: thus, do you already know if the existing deepcopy has the 
same problem as cPickle.dump ?(as the problem araises rarely, it is 
difficult for me to test it out)

Robert

PS: how does ZODB work with this kind of problem? I thought is uses cPickle?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which GUI toolkit is THE best?

2006-03-11 Thread David Boddie
Alan Franzoni wrote:

 FLTK was interesting but seems to lack maintenance and support,

Looking at the News section of the project's home page, I can see
that updates were few and far between in 2004 and 2005, but the
action seems to have picked up again since:

  http://pyfltk.sourceforge.net/#news

 pyQT is a bit 'unfree' for most uses.

Unfree as in the opposite of freedom, or unfree as in the price of
beer?

PyQt for Qt 3 is available under the GNU General Public License on
Mac OS X and Linux. Since Qt 4 can be used under the GPL on all
platforms, you'll even be able to write software on Windows with PyQt4
that's licensed under a GPL-compatible license.

  FAQ: http://www.riverbankcomputing.co.uk/pyqt/faq.php
  Roadmap: http://www.riverbankcomputing.co.uk/pyqt/roadmap.php

 Tkinter is quite old stuff.

But actively supported and promoted:

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

And I'm sure there are plenty of other solutions that deserve to be
mentioned:

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

David

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


Re: why use special config formats?

2006-03-11 Thread Steve Holden
gangesmaster wrote:
Huh? You think a competent sys admin can't learn enough Python to hack
your pickled file?

Binary configs only keep out legitimate users who don't have the time or
ability to learn how to hack the binary format. Black hats and power users
will break your binary format and hack them anyway.
 
 
 then you dont know what pickle is. pickle code is NOT python bytecode.
 it's a bytecode they made in order to represent objects. you cannot
 exploit in in the essence of running arbitrary code, unless you find
 a bug in the pickle module. and that's less likely than you find a bug
 in the parser of the silly config file formats you use.
 
 i'm not hiding the configuration in binary files, that's not the
 point. pickle is just more secure by definition.
 
 aah. you all are too stupid.
 
Great way to win an argument. Pity we aren't as intelligent as you ...

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: why use special config formats?

2006-03-11 Thread Sybren Stuvel
gangesmaster enlightened us with:
 YES THATS THE POINT. PYTHON CAN BE USED JUST LIKE A CONFIG FILE.

AND CAN ALSO BE MISUSED AND HARDER TO USE THAN A SIMPLE CONFIG FILE.
Get it into your thick head that you're plain wrong here.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why use special config formats?

2006-03-11 Thread Rick Zantow
gangesmaster [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 aah. you all are too stupid.

-1 QOTW.

-- 
rzed

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


Re: How to best update remote compressed, encrypted archives incrementally?

2006-03-11 Thread Steven D'Aprano
On Sat, 11 Mar 2006 16:09:22 +0100, robert wrote:

 Lastly, have you considered that your attempted solution is completely the
 wrong way to solve the problem? If you explain _what_ you are wanting to
 do, rather than _how_ you want to do it, perhaps there is a better way.
 
 So, there seems to be a big barrier for that task, when encryption is on 
 the whole archive. A complex block navigation within a block cipher 
 would be required, and obviously there is no such (handy) code already 
 existing. Or is there a encryption/decryption method which you can can 
 use like a file pipe _and_ which supports 'seek'?

[snip]

Let's try again: rather than you telling us what technology you want to
use, tell us what your aim is. I suspect you are too close to the trees to
see the forest -- you are focusing on the fine detail. Let's hear the big
picture: what is the problem you are trying to solve? Because, frankly, as
far as I can see, the solution you are looking for doesn't exist. But
maybe I'm too far from the forest to see the individual trees.

I need encryption that supports seek -- no, that's you telling us _how_
you want to solve your problem.

Perhaps you can tick some/all of the following requirements:

- low bandwidth usage when updating the remote site

- transmission needs to be secure

- data on the remote site needs to be secure in case of theft or break-ins

- remote site is under the control of untrusted parties; 
or remote site is trusted

- remote site is an old machine with limited processing power and very
small disk storage; 
or remote site can be any machine we choose

- local site needs to run Windows/Macintosh/Linux/BSD/all of the above

- remote site runs on Windows/Macintosh/Linux/BSD/anything we like

- we are updating text files/binary files 

- anything else you can tell us about the nature of your problem 



-- 
Steven.

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


Re: why use special config formats?

2006-03-11 Thread Steven D'Aprano
On Sat, 11 Mar 2006 05:49:38 -0800, gangesmaster wrote:

 Why is the first uglier than the second?
 YES THATS THE POINT. PYTHON CAN BE USED JUST LIKE A CONFIG FILE.
 
 and if your users did
 timeout = 300
 instead of
 timeout = 300
 
 then either your config parser must be uber-smart and all-knowing, and
 check the types of key-value pairs, or your server would crash. either
 way is bad, and i prefer crash-on-use then
 know-everything-and-check-at-the-parser-level.

Well, I think this puts a new light on the argument from Tomer: he'd
prefer his server to crash than to spend some time validating his data.

Would you mind telling us what software you've been involved in writing,
so we know what software to avoid?


-- 
Steven.

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


What has become of the Python 2004 papers?

2006-03-11 Thread Andrew Koenig
http://www.python.org/community/pycon/dc2004 seems to have vanished...


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


Re: New python.org site

2006-03-11 Thread Luis M. González
I wouldn't want to sound like I'm criticizing other people's work.
To those who offered their time to create this site, which is quite an
improvement over the old one, thank you!

However, I like the idea of a contest. Both for the site and for the
logo.
Perhaps something cool could come up from the new crop of
Django/TurboGears fans our there...

For many people, these things may seem superfluos or not important at
all, but good marketing and good design helps to create an image and an
identity.

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


Re: why use special config formats?

2006-03-11 Thread Fredrik Lundh
  YES THATS THE POINT. PYTHON CAN BE USED JUST LIKE A CONFIG FILE.

 AND CAN ALSO BE MISUSED AND HARDER TO USE THAN A SIMPLE CONFIG FILE.
 Get it into your thick head that you're plain wrong here.

comp.lang.python sure isn't what it used to be :-(

/F



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


Old Python Logo

2006-03-11 Thread Spinchange

Can someone post a link or email me an image of the old Python logo?
I'd like to save a copy of it, I rather liked it - very retro.

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


Re: Old Python Logo

2006-03-11 Thread Fredrik Lundh
Spinchange wrote:

 Can someone post a link or email me an image of the old Python logo?
 I'd like to save a copy of it, I rather liked it - very retro.

the dot matrix logo ?

you can get a copy from this page:

http://pydotorg.dyndns.org:8000/PythonOrg.html

/F



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


Re: why g.count('')==2 ?

2006-03-11 Thread Terry Reedy
For the same reason as
 .count()
1
 ab.count()
3

This is counting slice positions, which is one more that the length of the 
string.



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


Re: why g.count('')==2 ?

2006-03-11 Thread Felipe Almeida Lessa
Em Sáb, 2006-03-11 às 04:25 -0800, ygao escreveu:
 my question is as title!
 thanks!

Forget it. Just look:

$ python2.4 -mtimeit 'g.count()'
100 loops, best of 3: 0.516 usec per loop
$ python2.4 -mtimeit 'len(g)+1'
100 loops, best of 3: 0.26 usec per loop


-- 
Quem excele em empregar a força militar subjulga os exércitos dos
outros povos sem travar batalha, toma cidades fortificadas dos outros
povos sem as atacar e destrói os estados dos outros povos sem lutas
prolongadas. Deve lutar sob o Céu com o propósito primordial da
'preservação'. Desse modo suas armas não se embotarão, e os ganhos
poderão ser preservados. Essa é a estratégia para planejar ofensivas.

  -- Sun Tzu, em A arte da guerra

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

Re: How to best update remote compressed, encrypted archives incrementally?

2006-03-11 Thread robert
Steven D'Aprano wrote:

 On Sat, 11 Mar 2006 16:09:22 +0100, robert wrote:
 
 
Lastly, have you considered that your attempted solution is completely the
wrong way to solve the problem? If you explain _what_ you are wanting to
do, rather than _how_ you want to do it, perhaps there is a better way.

So, there seems to be a big barrier for that task, when encryption is on 
the whole archive. A complex block navigation within a block cipher 
would be required, and obviously there is no such (handy) code already 
existing. Or is there a encryption/decryption method which you can can 
use like a file pipe _and_ which supports 'seek'?
 
 
 [snip]
 
 Let's try again: rather than you telling us what technology you want to
 use, tell us what your aim is. I suspect you are too close to the trees to
 see the forest -- you are focusing on the fine detail. Let's hear the big
 picture: what is the problem you are trying to solve? Because, frankly, as
 far as I can see, the solution you are looking for doesn't exist. But
 maybe I'm too far from the forest to see the individual trees.
 
 I need encryption that supports seek -- no, that's you telling us _how_
 you want to solve your problem.
 
 Perhaps you can tick some/all of the following requirements:
 
 - low bandwidth usage when updating the remote site
 
 - transmission needs to be secure
 
 - data on the remote site needs to be secure in case of theft or break-ins
 
 - remote site is under the control of untrusted parties; 
 or remote site is trusted
 
 - remote site is an old machine with limited processing power and very
 small disk storage; 
 or remote site can be any machine we choose
 
 - local site needs to run Windows/Macintosh/Linux/BSD/all of the above
 
 - remote site runs on Windows/Macintosh/Linux/BSD/anything we like
 
 - we are updating text files/binary files 
 
 - anything else you can tell us about the nature of your problem 

The main requirement is, that it has to be become a cohesive, reusable, 
portable (FTP/SFTP standard) functionality as mentioned in the OP. A 
Python module at best. For integration in a bigger Python app. not a 
one-time admin hack with a bunch of tools to be fiddled together on each 
user machine. So the 'how' is mostly =='what'. Its a Python question so far.

The last 2 methods I mentioned already are maybe a way to a compromise, 
  (if integrated one-stream encryption cannot be managed)

The only issue remaining: A native Python module for pgp-(pwd 
only)-encryption or another kind of good (commonly supported) 
encryption. ZIP2-encryption itself seems to be too weak? (Still so in 
recent ZIP formats? what about the mode of 7zip etc?)  But I found no 
python modules for either.

http://www.amk.ca/python/code/gpg  just calls into an external gpg 
installation.

Can the functionality of gpg -c  maybe fiddled together with PyCrypto
easily ?  (variable length key/pwd only - no public key stuff required)

And what about ZIP password-only encryption itself?  Are there maybe any 
usable improvents ?

And: when there are many files encrypted with the same password (both 
PGP and ZIP), will this decrease the strength of encryption?

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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread Alex Martelli
robert [EMAIL PROTECTED] wrote:
   ...
 99.99% no. I would have to use a lock everywhere, where I add or remove
 something into a dict or list of the struct. Thats not the purpose of
 big thread locks. Such simple operations are already atomic by the 
 definition of Python - and thanks to the global interpreter lock. 
 (Otherwise I would leave the Python language, God beware ... :-) )

You have misread the Python Language Reference -- if you can give the
URL on which you have read any such promise of atomicity, I will be glad
to fix the docs to make that unambiguous.

There is no such promise (there may be implementation accidents in some
specific implementation which happen to make some operation atomic, but
NO guarantee even there that the next bugfix won't break that).

Farwell and best of luck in finding other languages which support
threads in a way that is more to your liking than Python -- maybe Ruby
suits you, I don't know for sure though.


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


Python Love :)

2006-03-11 Thread mwt
I've only been goofing around with Python for about a month now, but
already I am in love.
I never get that feeling -- so common with Java -- that I'm swimming
upstream, struggling to force the language to do what I want.
Python makes it feel effortless and easy.

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


Re: What has become of the Python 2004 papers?

2006-03-11 Thread skip

Andrew http://www.python.org/community/pycon/dc2004 seems to have
Andrew vanished...

Andrew,

Try here:

http://us.pycon.org/zope/original/pycon/pastevents/dc2004

I found it by going to http://www.python.org/community/pycon/ then clicking
the 2004 link in the Past Conferences section.

I believe the plan is to move most/all the PyCon-related stuff to the
pycon.org domain, though I'm not certain about that.

Skip

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


Re: Cheese Shop - BSOL?

2006-03-11 Thread Michael Tobis
I like cheeseshop just fine, but have been a Monty Python fan since
they appeared on the CBC in, I think, 1969. I'm one of those people who
is always surprised when a MP bon mot is greeted with confusion and the
suspicion that I have finally lost my mind altogether. So...

If we are moving to the snake motif (which probably would be better
marketing):

Pythons lay eggs which they arrange in a pile. They coil around the
pile until all eggs have hatched. Since pythons cannot regulate their
internal body temperature, they cannot incubate their eggs per se;
instead, they raise the temperature of their eggs by small movements of
their body-essentially, they shiver. This is one of only a few
documented cases of parental behaviour in snakes.
--Wikipedia article python

Pythons build no nests. Their eggs are found in coils. coil.python.org
?

Tadpoles ( http://python.org/images/python-logo.gif ) are immature
frogs. If we keep the logo, we can change the name of the language to
frog. Then the eggs would be found in lilypad.frog.org . I personally
do not like this choice but it would have the virtue of consistency.
(Did I mention that I don't like the logo?)

mt

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


Python source cross reference doc generator?

2006-03-11 Thread Harry Fuecks
Hi All,

Wondering if a tool exists to generate cross reference documentation
for Python code bases?

Particularly after something like phpxref -
http://phpxref.sourceforge.net/ : written in Perl, scans a bunch of
PHP scripts and generates HTML output that allows you to see all the
classes / methods / functions / variables defined and (what I'm
interested in) where they are referenced. Essentially something like
API docs but with the addition of being able to see who's using a
particular method

Is there anything like this for Python? Have done much looking without success.

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


Re: Cheese Shop - BSOL?

2006-03-11 Thread Torsten Bronger
Hallöchen!

Michael Tobis [EMAIL PROTECTED] writes:

 [...]

 Pythons build no nests. Their eggs are found in coils. coil.python.org
 ?

Better eggs.python.org.  Would support the spread of the new file
format, too.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetusICQ 264-296-646
-- 
http://mail.python.org/mailman/listinfo/python-list


Advice for creating a web app

2006-03-11 Thread Jumping until blue
I'm confused ... and need some advice

Here is what I want to do:

I have a number of files, mostly text files formatted using Markdown
syntax but also pdfs and other types of files, that are stored in a
folder hierarchy and I want to develop a web application where I can
brows, view and search these files. The documents can be
cross-linked.

Currently I use a basic CGI to view/format the markdown files but I
don't know if I should continue to make my own system or if I should
take advantage of some existing framework.

My requirements are:

+   It should work with the text files I have in my
hierarchy (so a system that stores everything
in a database is out of the question)

+   I want to be able to copy the folder hierarchy
to a memory stick and run my system on another
computer without having to install any software
(I'm thinking of using something like Movable 
Python). I'll mostly be running this on Macs
but would like to have the option to run it
on Windows/Linux

+   Searching should be fairly fast

+   I should be able to edit the text files using a
standard text editor without messing up the system.

+   I will use subversion to keep different computers
in sync.

So my question is: should I use some existing framwork? and if so,
which ones should I look at? TurboGears, Django, etc seem to be much
too elaborate for my modest needs.

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


Re: How to pop random item from a list?

2006-03-11 Thread Andrew Gwozdziewycz

On Mar 11, 2006, at 11:21 AM, Peter Otten wrote:

 Am Freitag, 10. März 2006 19:38 schrieben Sie:

 item = mylist.pop(random.randint(0,len(mylist)))

 This is broken because randint(a, b) may return b.
 I prefer randrange(len(mylist)) over randint(0, len(mylist)-1) as  
 a fix.

 This brings up an interesting proposal.
 random.choice(seq) brings back a random element from a list, why not
 add an optional second argument which is a flag to pop the element
 instead of choosing?

 ie.

 import random
 def choice(seq, pop=False):

 ... if not pop:
 ... return seq[random.randrange(len(seq))]
 ... else:
 ... return seq.pop(random.randrange(len(seq)))
 ...

 x = [1, 2, 3]
 choice(x)

 1

 x

 [1, 2, 3]

 choice(x, True)

 1

 x

 [2, 3]

 [The main reason I am answering your mail is because you may have  
 intended to
 post on c.l.py]

 Regarding your enhancement, I don't see any use cases that aren't  
 handled by
 random.sample() already.

 Regards,
 Peter

I can see a use case. Think of a bag datastructure. You push things  
into some container
and pop them out randomly. If random.choice was capable of 'pop' it  
would be
implemented implicitly.

random.sample, select elements from a list, but the original list  
remains intact. This would
not be the desired 'bag' behavior.


---
Andrew Gwozdziewycz
[EMAIL PROTECTED]
http://ihadagreatview.org
http://and.rovir.us


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


Re: New python.org site

2006-03-11 Thread Steve Holden
Luis M. González wrote:
 I wouldn't want to sound like I'm criticizing other people's work.
 To those who offered their time to create this site, which is quite an
 improvement over the old one, thank you!
 
 However, I like the idea of a contest. Both for the site and for the
 logo.
 Perhaps something cool could come up from the new crop of
 Django/TurboGears fans our there...
 
 For many people, these things may seem superfluos or not important at
 all, but good marketing and good design helps to create an image and an
 identity.
 
I think you seriously underestimate the work it would take (and indeed 
has just taken and is currently taking) to reimplement the site.

A competition sounds like a wonderful idea, but suppose there were to 
be one, and a winner were to be declared, where do we go from there to 
get the winning design up on a server behind www.python.org?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: Python and C

2006-03-11 Thread Thomas Heller
Terry Reedy wrote:
 P Boy [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 Has anyone yet written a program to grab C struct declaration from the 
 .h
 to produce code like

 # Overlay configuration
 class OverlayStoreConfig(ctypes.Structure):
 _fields_ = [('FormatVersion',   ctypes.c_ulong),
 ('VolumeSize',  ctypes.c_longlong),
 etc
 http://starship.python.net/crew/theller/ctypes/codegen.html says it can
 be done. However, it requires MSVC 7.1 and I have not yet install it
 since I already have MSVC (6,7,8) on my PC.
 
 Or vc6.  Neither of which most people have, especially those not using Swig 
 because they don't do C.  Ok, we need program entirely in Python.  Possible 
 exercise for someone.
 

Alan Green apparently has got it to work with the free vctoolkit:

http://cardboard.nu/blog/2005_07_14/ctypes_code_generator_for_chea.html


Thomas

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


RE: What has become of the Python 2004 papers?

2006-03-11 Thread Andrew Koenig
 Try here:
 
 http://us.pycon.org/zope/original/pycon/pastevents/dc2004
 

I see summaries of the paper, but when I follow the link for the papers
themselves, it leads to the same dead end.



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


Re: New python.org site

2006-03-11 Thread Kay Schluehr

Luis M. González wrote:
 I wouldn't want to sound like I'm criticizing other people's work.
 To those who offered their time to create this site, which is quite an
 improvement over the old one, thank you!

 However, I like the idea of a contest. Both for the site and for the
 logo.
 Perhaps something cool could come up from the new crop of
 Django/TurboGears fans our there...

 For many people, these things may seem superfluos or not important at
 all, but good marketing and good design helps to create an image and an
 identity.

I'm 0 on this. And besides the marketing or evangelizing aspect it
may happen that a new site is not only cool but also innovative? I'm
just not sure what will follow up? In a public competition among
architects the winner will finally be commissioned to create the
building and earn money for it. What could be the gift to an imaginary
winner of a Python site design competition? Sponsoring is a fine idea
but should banner advertisment be actually a part of the design
requirement?

Kay

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


Re: What has become of the Python 2004 papers?

2006-03-11 Thread A.M. Kuchling
On Sat, 11 Mar 2006 12:00:26 -0600, 
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I believe the plan is to move most/all the PyCon-related stuff to the
 pycon.org domain, though I'm not certain about that.

No, that's not the plan.  The PSF doesn't own the domain, and I want
the data to be available as static files, not via a web application.

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


Re: Cheese Shop: some history for the new-comers

2006-03-11 Thread A.M. Kuchling
On Sat, 11 Mar 2006 16:50:26 +1100, 
richard [EMAIL PROTECTED] wrote:
 So I did what people always do in this situation, I asked Barry Warsaw to
 name. it. And he did, Cheese Shop. I liked the name, so it was done. When
 the new pydotorg machines went live last year, so too did the name
 cheeseshop.python.org

Given the endless whiny complaints about the name, though, I think we
should just give up and go back to PyPI (pronounced 'Pippy').

--amk

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


Re: API/C memory mananegemnt problem

2006-03-11 Thread Alex Martelli
[EMAIL PROTECTED] wrote:

 Sorry for responding to my own post.
 
 I think I understand the original statement now.  What you are really
 saying is that there is a pool of Python float objects (which can, at
 different times, wrap different values) which can grow but never
 decrease in size.  So the memory held by this pool is dictated by the
 maximum number of floats that have ever been simultaneously active
 (accessible).
 
 The same goes for integers.  All the more reason to avoid range(.) and
 use xrange(.).

Uh? The integers produced as you loop over xrange will be just immortal
as those that get into the list built by range, so why is int
immortality any reason to use one over the other?

If you know you're probably not going to loop over ALL the range or
xrange, sure, but that's relatively rare -- and, when it does occur,
xrange is seriously preferable:

helen:~ alex$ python -mtimeit 'for x in range(100): pass'
10 loops, best of 3: 15.9 usec per loop

helen:~ alex$ python -mtimeit 'for x in xrange(100): pass'
10 loops, best of 3: 12.2 usec per loop

helen:~ alex$ python -mtimeit 'for x in range(100): break'
10 loops, best of 3: 7.57 usec per loop

helen:~ alex$ python -mtimeit 'for x in xrange(100): break'
100 loops, best of 3: 1.5 usec per loop

The immediate break only halves the time requirements of the range-based
loop, but it slashes by 8 times those of the xrange-based one -- now
THAT is big enough to matter, as opposed to the 20% or so difference in
overhead when you're always looping all the way, which is unlikely to
make an important difference in overall application speed.


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


Re: API/C memory mananegemnt problem

2006-03-11 Thread Aahz
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
 
 I think I understand the original statement now.  What you are really
 saying is that there is a pool of Python float objects (which can, at
 different times, wrap different values) which can grow but never
 decrease in size.  So the memory held by this pool is dictated by the
 maximum number of floats that have ever been simultaneously active
 (accessible).
 
 The same goes for integers.  All the more reason to avoid range(.) and
 use xrange(.).

Uh? The integers produced as you loop over xrange will be just immortal
as those that get into the list built by range, so why is int
immortality any reason to use one over the other?

Because unless you save the ints produced by xrange(), you're reusing
slots in the free list as you go through the loop, whereas range() chews
up a gob of memory that will never get released even if you never
otherwise use all the ints it produces.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

19. A language that doesn't affect the way you think about programming,
is not worth knowing.  --Alan Perlis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New python.org site

2006-03-11 Thread Bertrand Mansion
On 3/11/06, Steve Holden [EMAIL PROTECTED] wrote:

 A competition sounds like a wonderful idea, but suppose there were to
 be one, and a winner were to be declared, where do we go from there to
 get the winning design up on a server behind www.python.org?

That's not the problem IMO.

Before launching any contest, it should be made clear what needs to be
done by contestants. This involves writing an organized chart of
existing (or not) content and detailed guidelines.

For the contest, contestants will get a copy of these guidelines:
- First, second, third navigation levels.
- Python history, positioning, etc.

If these guidelines are clear and respecting these guidelines becomes
a part of the final applications evaluation, then it will be easy to
adapt the winning results to the site. I have looked at
http://psf.pollenation.net, the current python.org svn, and it seems
python.org currently doesn't work with any database backend... It
seems to be just a plain ol' html site built upon YAML files. There
can't probably be an easier configuration.

BTW, this is a interesting read and could be used as a basis for the guidelines:
http://psf.pollenation.net/cgi-bin/trac.cgi/browser/trunk/resources/docs/pydotorg-redesign.pdf?format=raw

The big part is really deciding what is proposed and what goes where.


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


Re: Why property works only for objects?

2006-03-11 Thread Michal Kwiatkowski
Alex Martelli napisał(a):
 First, let's forget legacy-style classes, existing only for backwards
 compatibility, and focus on new-style ones exclusively -- never use
 legacy classes if you can avoid that.

Ok, let's cover only new-style classes in our discussion.

I've read your comments and am on a way of reading your articles. Still,
with my current knowledge I'm trying to write pure python attributes
lookup function. I've failed for example given below:

class C(object):
__dict__ = {}

obj = C()
obj.a = 7
obj.__dict__ = {}
print object.__getattribute__(obj, '__dict__')
print object.__getattribute__(C, '__dict__')
print obj.a  # = 7 !!!

First print returns {} and the second returns

{'__dict__': {},
 '__module__': '__main__',
 '__weakref__': attribute '__weakref__' of 'C' objects,
 '__doc__': None}

Neither of them have a attribute. How come obj.a doesn't raise an
exception? Where obj.a is kept?

mk
-- 
 . o . http://joker.linuxstuff.pl  
 . . o   It's easier to get forgiveness for being wrong
 o o o   than forgiveness for being right.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python source cross reference doc generator?

2006-03-11 Thread Colin J. Williams
Harry Fuecks wrote:
 Hi All,
 
 Wondering if a tool exists to generate cross reference documentation
 for Python code bases?
 
 Particularly after something like phpxref -
 http://phpxref.sourceforge.net/ : written in Perl, scans a bunch of
 PHP scripts and generates HTML output that allows you to see all the
 classes / methods / functions / variables defined and (what I'm
 interested in) where they are referenced. Essentially something like
 API docs but with the addition of being able to see who's using a
 particular method
 
 Is there anything like this for Python? Have done much looking without 
 success.
 
 Many thanks.
epydoc and pydoc each provides an index.  If you are looking for info on 
where a name is defined or used, PyScripter is helpful.

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


Re: Advice for creating a web app

2006-03-11 Thread Olivier
Hi there,


Jumping until blue a écrit :
 I have a number of files, mostly text files formatted using Markdown
 syntax but also pdfs and other types of files, that are stored in a
 folder hierarchy and I want to develop a web application where I can
 brows, view and search these files. The documents can be
 cross-linked.
 
 Currently I use a basic CGI to view/format the markdown files but I
 don't know if I should continue to make my own system or if I should
 take advantage of some existing framework.
 
 My requirements are:

...

You may be interested in pyblosxom (http://pyblosxom.sourceforge.net/).

It's filesystem based, allows different input formats (html, rest, plain 
text, I don't know about Markdown syntax), allows also to serve what 
they call static files (like your pdfs), and you can plug some search 
capacities (for instance, a wrap around grep).

I used to run it behind apache with cgi, but it should be possible to 
use it with a lightweight-no install web server.

HTH,

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


Re: New python.org site

2006-03-11 Thread Kay Schluehr

Bertrand Mansion wrote:
 On 3/11/06, Steve Holden [EMAIL PROTECTED] wrote:

  A competition sounds like a wonderful idea, but suppose there were to
  be one, and a winner were to be declared, where do we go from there to
  get the winning design up on a server behind www.python.org?

 That's not the problem IMO.

Em, why not IYO? Because you will implement it however advanced the
design might be as part of your Python exercises?

Kay

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


Help Create Good Data Model

2006-03-11 Thread mwt
Hi. I'm reworking a little app I wrote, in order to separate the data
from the UI. As a start, I wanted to create a iron-clad data recepticle
that will hold all the important values, and stand up to being queried
by various sources, perhaps concurrently. In all likelihood, the app
will never need anything that robust, but I want to learn to write it
anyway, as an exercise. So here is my code. It's really simple, and I'm
sure you can see my Java background. Are there any problems here?
Something I'm missing or screwing up? I welcome any and alll feedback,
especially if it includes the *why's.* Thanks!

#!/usr/bin/python
# author mwt
# Mar '06

import copy, threading

class FAHData(object):
The data model for the [EMAIL PROTECTED] monitor.

def __init__(self):
self.data = {}#this dict will hold all data
self.mutex = threading.RLock()

def get_all_data(self):
Returns a COPY of entire data dict.
#not sure deepcopy() is really necessary here
#but using it for now
#might cause some weird synchronization problems...
try:
self.mutex.acquire()
return copy.deepcopy(self.data)
finally:
self.mutex.release()

def get_data(self, key):
Returns a COPY of key data element.
try:
self.mutex.acquire()
return copy.deepcopy(self.data[key])
finally:
self.mutex.release()

def set_value(self, key, value):
Sets value of key data element.
try:
self.mutex.acquire()
self.data[key] = value
finally:
self.mutex.release()

def set_data(self, data):
Sets entire data dictionary.
try:
self.mutex.acquire()
self.data = data
finally:
self.mutex.release()

def clear_data(self):
Clears entire data dictionary.
try:
self.mutex.acquire()
self.data = {}
finally:
self.mutex.release()

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


Re: Why property works only for objects?

2006-03-11 Thread Alex Martelli
Michal Kwiatkowski [EMAIL PROTECTED] wrote:

 class C(object):
 __dict__ = {}
 
 obj = C()
 obj.a = 7
 obj.__dict__ = {}
 print object.__getattribute__(obj, '__dict__')
 print object.__getattribute__(C, '__dict__')
 print obj.a  # = 7 !!!
 
 First print returns {} and the second returns
 
 {'__dict__': {},
  '__module__': '__main__',
  '__weakref__': attribute '__weakref__' of 'C' objects,
  '__doc__': None}
 
 Neither of them have a attribute. How come obj.a doesn't raise an
 exception? Where obj.a is kept?

It's easier to trace if you use a unique value rather than 7 ...:

 class C(object):
...   __dict__ = {}
... 
 obj = C()
 obj.a = object()
 import gc
 gc.get_referrers(obj.a)
[{'a': object object at 0x3d438}]

so, at this point, you know that obj.a is kept in a dictionary where
it's the only value.  That's the dictionary you would USUALLY be able to
get to as obj.__dict__, but...:

 obj.__dict__
{}

...the presence of '__dict__' as an entry in C is confusing the issue,
because that's what you get in this case as obj.__dict__.

C.__dict__ gives you a dictproxy, not a real dict, by the way:

 obj.__dict__ is C.__dict__['__dict__']
True

The funny thing is that builtins like var, which should know better,
also get fooled...:

 vars(obj)
{}
 vars(obj) is C.__dict__['__dict__']
True

...and so does the assignment to obj.__dict__...:

 obj.__dict__ = {}
 gc.get_referrers(obj.a)
[{'a': object object at 0x3d438, '__dict__': {}}]

Now, both obj.a and obj.__dict__ are entries in a dictionary where
they're the only two entries -- exactly the dictionary that would
NORMALLY be obj.__dict__.

I think a fair case can be made that you've found a bug in Python here:
the existence of that __dict__ in C's class body is clearly causing
unintended anomalies.  Fortunately, getattr and friends don't in fact
get confused, but vars does, as does assignment to obj.__dict__...


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


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread EleSSaR^
robert si è profuso/a a scrivere su comp.lang.python tutte queste
elucubrazioni: 

 own deepcopy: thus, do you already know if the existing deepcopy has the 
 same problem as cPickle.dump ?(as the problem araises rarely, it is 
 difficult for me to test it out)

I don't know the exact specs of your object, and I don't know what
operations are you performing on that object, nor the way they're atomic.

It seems like you're trying to save periodically the state of such object
while it is being modified (a sort of backup?), and Python complains about
that. A self-implemented deepcopy might raise anomalies (i.e. your dumped
object may be partly a 'before' object and partly an 'after' object ) as
well. 

By the way, you could try employing locks from other threads to dump the
object as well... this would prevent additional locking.
 
 PS: how does ZODB work with this kind of problem? I thought is uses cPickle?

I have no idea about this.


-- 
EleSSaR^ [EMAIL PROTECTED]
--
Togli .xyz dalla mia email per contattarmi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RuntimeError: dictionary changed size during iteration ; Good atomic copy operations?

2006-03-11 Thread EleSSaR^
robert si è profuso/a a scrivere su comp.lang.python tutte queste
elucubrazioni: 

[cut]

P.S.
I'm very bad at threaded programming. Please verify any of my suggestions
^_^


-- 
EleSSaR^ [EMAIL PROTECTED]
--
Togli .xyz dalla mia email per contattarmi.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
When debugging using 'print' statement, I usually want to print some
important values together with the function name as the context of the
values printed out. So my hope is that I could get the name of the
function.

Since every function object actually has a private __name__ attribute
that gives its name, but when I

print __name__

in a function, it usually print the public module-level __name__
attribute, ie, 'main', rather than the function level __name__. So how
could I refer to the function object per se, in the body of the
function itself?

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


Re: Help Create Good Data Model

2006-03-11 Thread fumanchu
There's nothing really *broken* jumping out at me. The last three
methods (set_value, set_data, and clear_data) probably don't need a
mutex, since they will each have their own frame, and the operations
are atomic. If that makes no sense, Google for Python GIL ;). If you
just returned a value from the dict instead of using copy, the same
might be said for the get methods--it depends on whether you're storing
mutable objects in self.data or not.

When you're done with the exercise and want to persist those values
somewhere, give Dejavu a try: http://projects.amor.org/dejavu/


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]

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


Re: Help Create Good Data Model

2006-03-11 Thread Sybren Stuvel
mwt enlightened us with:
 I'm reworking a little app I wrote, in order to separate the data
 from the UI.

Good idea.

 As a start, I wanted to create a iron-clad data recepticle that will
 hold all the important values, and stand up to being queried by
 various sources, perhaps concurrently.

Why do that yourself, if you can have SQLite databases? SQLite is even
capable of in-memory databases. No need to re-invent the wheel.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New python.org site

2006-03-11 Thread Bertrand Mansion
On 11 Mar 2006 11:52:35 -0800, Kay Schluehr [EMAIL PROTECTED] wrote:

 Em, why not IYO? Because you will implement it however advanced the
 design might be as part of your Python exercises?

Look at the current code, there is nothing to implement. Most of the
work to be done is related to presentation and content organization.

Now, there are also new features we might want:

- documentation with user comments (like in PHP, Postgres, MySQL...)
- RSS feeds
- Efficient search engine (hyperestraier ?)
- Database backend and CMS

Those will certainly need code. Feel free to exercise your Python
skills on that, it would be more useful than your unconstructive
comments.


Bertrand Mansion
Mamasam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheese Shop: some history for the new-comers

2006-03-11 Thread Tim Churches
A.M. Kuchling wrote:
 On Sat, 11 Mar 2006 16:50:26 +1100, 
   richard [EMAIL PROTECTED] wrote:
 So I did what people always do in this situation, I asked Barry Warsaw to
 name. it. And he did, Cheese Shop. I liked the name, so it was done. When
 the new pydotorg machines went live last year, so too did the name
 cheeseshop.python.org
 
 Given the endless whiny complaints about the name,

I was just hoping that honour would be bestowed upon me for suggesting a
brilliant alternative name, but I sense it is not to be...oh well
(whistles tune to himself).

 though, I think we
 should just give up and go back to PyPI (pronounced 'Pippy').

Perusable Index of Packages for PYthon - PIPPY (or PipPy if CamelCase
is preferred, or pippy...).

PyPi is doomed to be mispronounced pie-pie.

Anyway, thanks to Richard Jones for all his work on PyPI/Cheese Shop,
whining about the name notwithstanding.

Tim C

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


Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Duncan Booth
Sullivan WxPyQtKinter wrote:
 So how
 could I refer to the function object per se, in the body of the
 function itself?
 
 
I don't believe you can easily get at the function object, but you can get 
at the code object which also has a name (which will be the same as the 
function's name unless you've been doing strange things):

 import inspect
 def f():
print inspect.currentframe().f_code.co_name


 f()
f

For convenience you might want to put this inside a function:

 def myname():
f = inspect.currentframe().f_back
return f.f_code.co_name

 def f():
print myname()


 f()
f

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


  1   2   >