Re: nested structure with "internal references"

2009-09-25 Thread akonsu
On Sep 25, 1:11 pm, Torsten Mohr  wrote:
> Hi,
>
> sorry for posting in german before, that was a mistake.
>
> I'd like to use a nested structure in memory that consists
> of dict()s and list()s, list entries can be dict()s, other list()s,
> dict entries can be list()s or other dict()s.
>
> The lists and dicts can also contain int, float, string, ...
>
> But i'd also like to have something like a "reference" to another
> entry.
> I'd like to refer to another entry and not copy that entry, i need to
> know later that this is a reference to another entry, i need to find
> also access that entry then.
>
> Is something like this possible in Python?
>
> The references only need to refer to entries in this structure.
> The lists may change at runtime (entries removed / added), so
> storing the index may not help.
>
> Thanks for any hints,
> Torsten.

hello,

maybe i know less python than you do, but i am talking from the point
of view of my common sense and experience. if you store an object in a
list more than once, i doubt that python creates a duplicate. unless
the object is a value type. thus you have a reference to this object
in both elements. and then if you are asking this question, maybe your
design is not good enough? would you explain the problem?
konstantin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: importing with .m instead of .py

2009-09-25 Thread Andrew Svetlov
On Sep 25, 1:16 pm, Wanderer  wrote:
> execfile(x) does what I'm looking for.
>

Perhaps you are looking for Python import hook: 
http://www.python.org/dev/peps/pep-0302/

In you import hook you can do everything (and locate/import file with
any extension :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Alejandro Valdez
Hello I sent this e-mail to the python-help list but I'm not sure if
that list is active... so I post it again here:

I'm trying to build Python 2.6.2 from the sources downloaded from the
python official site on OpenSuSE 11.1 (32 bit). After installation the
python command line interpreter seems to run ok, but when I try to
install setuptools I get:

u...@linux-ba2a:~/tmp> bash setuptools-0.6c9-py2.6.egg
--install-dir=/home/user/python/lib/python2.6/site-packages/
Traceback (most recent call last):
 File "", line 1, in 
 File 
"/home/user/tmp/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py",
line 15, in 
 File "/home/user/tmp/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py",
line 1, in 
ImportError: /home/user/python/lib/python2.6/lib-dynload/operator.so:
undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString


To compile Python I executed:

./configure --prefix=/home/user/python
./make
./make install

The compile process seems to be ok, so I'm kind of clueless :-(

Any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most "active" coroutine library project?

2009-09-25 Thread Jason Tackaberry
On Fri, 2009-09-25 at 15:42 +, Grant Edwards wrote:
> You can't call a function that yields control back to the other
> coroutine(s).  By jumping through some hoops you can get the
> same effect, but it's not very intuitive and it sort of "feels
> wrong" that the main routine has to know ahead of time when
> calling a function whether that function might need to yield or
> not.

Not directly, but you can simulate this, or at least some pseudo form of
it which is useful in practice.  I suppose you could call this "jumping
through some hoops," but from the point of view of the coroutine, it can
be done completely transparently, managed by the coroutine scheduler.

In kaa, which I mentioned earlier, this might look like:

import kaa

@kaa.coroutine()
def task(name):
   for i in range(10):
  print name, i
  yield kaa.NotFinished  # kind of like a time slice

@kaa.coroutine()
def fetch_google():
   s = kaa.Socket()
   try:
  yield s.connect('google.com:80')
   except:
  print 'Connection failed'
  return
   yield s.write('GET / HTTP/1.1\nHost: google.com\n\n')
   yield (yield s.read())

@kaa.coroutine()
def orchestrate():
task('apple')
task('banana')
page = yield fetch_google()
print 'Fetched %d bytes' % len(page)

orchestrate()
kaa.main.run()


The two task() coroutines spawned by orchestrate() continue to "run in
the background" while any of the yields in fetch_google() are pending
(waiting on some network resource).

It's true that the yields in fetch_google() aren't yielding control
_directly_ to one of the task() coroutines, but it _is_ doing so
indirectly, via the coroutine scheduler, which runs inside the main
loop.

Cheers,
Jason.

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


Re: nested structure with "internal references"

2009-09-25 Thread Carl Banks
On Sep 25, 10:11 am, Torsten Mohr  wrote:
> Hi,
>
> sorry for posting in german before, that was a mistake.
>
> I'd like to use a nested structure in memory that consists
> of dict()s and list()s, list entries can be dict()s, other list()s,
> dict entries can be list()s or other dict()s.
>
> The lists and dicts can also contain int, float, string, ...
>
> But i'd also like to have something like a "reference" to another
> entry.
> I'd like to refer to another entry and not copy that entry, i need to
> know later that this is a reference to another entry, i need to find
> also access that entry then.
>
> Is something like this possible in Python?
>
> The references only need to refer to entries in this structure.
> The lists may change at runtime (entries removed / added), so
> storing the index may not help.

Hmm, I think I understand what you're asking but I don't think there's
an easy way.

Probably the most straightforward way is to use "cells" of some sort
to contain the entries in a list or dict; then take references to the
cells.  That way you can change the cell's value while still
maintaining the reference.  For instance, suppose you have a list like
this:

lst = [ 1, 2, 3, 4 ]

Convert it to this:

lst = [ [1], [2], [3], [4] ]

where you are using a nested singleton list as the cell type.  Then,
you can take a reference like this:

ref = lst[2]

If you insert an item into the list, the reference remains valid:

lst.insert(0,[0])

And, if you change the value of the cell, the reference will see the
updated value.

lst[3][0] = 5

The downside is that you have to add [0] everywhere.  The reference's
value is ref[0], not just ref.  The third item in the list is lst[2]
[0], not just lst[2].  You could define custom list- and dict-like
classes that automatically do this, mitigating the problem somewhat.

I hope you could understand that suggestion, it's tough to describe.


Other than that, you are stuck with massive use of Observer pattern
(you'd have to create list- and dict-like types that know when
something is referencing them, and that notify the references whenever
they change).


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


Re: Most "active" coroutine library project?

2009-09-25 Thread Grant Edwards
On 2009-09-25, Jason Tackaberry  wrote:
> On Fri, 2009-09-25 at 15:42 +, Grant Edwards wrote:
>> You can't call a function that yields control back to the other
>> coroutine(s).  By jumping through some hoops you can get the
>> same effect, but it's not very intuitive and it sort of "feels
>> wrong" that the main routine has to know ahead of time when
>> calling a function whether that function might need to yield or
>> not.
>
> Not directly, but you can simulate this, or at least some pseudo form of
> it which is useful in practice.  I suppose you could call this "jumping
> through some hoops,"

It's nice that I could, because I did. :)

> but from the point of view of the coroutine, it can be done
> completely transparently, managed by the coroutine scheduler.
>
> In kaa, which I mentioned earlier, this might look like:
>
> import kaa
> 
> @kaa.coroutine()
> def task(name):
>for i in range(10):
>   print name, i
>   yield kaa.NotFinished  # kind of like a time slice
> 
> @kaa.coroutine()
> def fetch_google():
>s = kaa.Socket()
>try:
>   yield s.connect('google.com:80')

That's not comletely transparently.  The routine fetch_google()
has to know a priori that s.connect() might want to yield and
so has to invoke it with a yield statement.  Completely
transparent would be this:

 try:
 s.connect('google.com:80')
 except:
 print 'Connection faild'
 return

>yield s.write('GET / HTTP/1.1\nHost: google.com\n\n')
>yield (yield s.read())

Again, you have to know ahead of time which functions might
yeild and which ones don't and call them differently.  That's
the "hoop".  If somewhere in the implementation of a function
you dicover a need to yield, you have to modify all the "calls"
all the way up to the top frame.

> It's true that the yields in fetch_google() aren't yielding control
> _directly_ to one of the task() coroutines, but it _is_ doing so
> indirectly, via the coroutine scheduler, which runs inside the main
> loop.

True.  But I wouldn't call that transparent.

-- 
Grant Edwards   grante Yow! Can I have an IMPULSE
  at   ITEM instead?
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: nested structure with "internal references"

2009-09-25 Thread akonsu
put a (name, value) pair in each list element instead of just value
and reference them by name, you can use uuid to generate names

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


Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Mark Dickinson
On Sep 25, 7:05 pm, Alejandro Valdez 
wrote:
> Hello I sent this e-mail to the python-help list but I'm not sure if
> that list is active... so I post it again here:
>
> I'm trying to build Python 2.6.2 from the sources downloaded from the
> python official site on OpenSuSE 11.1 (32 bit). After installation the
> python command line interpreter seems to run ok, but when I try to
> install setuptools I get:
> [...]
> To compile Python I executed:
>
> ./configure --prefix=/home/user/python
> ./make
> ./make install
>
> The compile process seems to be ok, so I'm kind of clueless :-(
>
> Any ideas?

This is just a guess, but try configuring with:

./configure --enable-unicode=ucs4 --prefix=/home/user/python

On Linux, by default, a self-compiled Python uses UCS2
internally for its unicode support (with some support
for UTF16).  Most Linux distributions, however, distribute
a Python that uses UCS4 (aka UTF32) instead, so it seems
possible that your setuptools egg is expecting to find a
UCS4 build.

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


flow control and nested loops

2009-09-25 Thread kj


In Perl, one can label loops for finer flow control.  For example:

X: for my $x (@X) {
  Y: for my $y (@Y) {
for my $z (@Z) {
  next X if test1($x, $y, $z);
  next Y if test2($x, $y, $z);
  frobnicate($x, $y, $z);
}
glortz($x, $y); 
  }
  splat($x); 
}

What's considered "best practice" in the Python world for this sort
of situation?  The only approach I can think of requires setting
up indicator variables that must be set and tested individually;
e.g.

for x in X:
next_X = False
for y in Y:
next_Y = False
for z in Z:
if test1(x, y, z):
next_X = True
break
if test2(x, y, z):
next_Y = True
break
frobnicate(x, y, z)
if next_X:
break
if next_Y:
continue
glortz(x, y) 
if next_X:
continue
splat(x) 

Whereas I find the Perl version reasonably readable, the Python
one I find nearly incomprehensible.  In fact, I'm not even sure
that the Python version faithfully replicates what the Perl one is
doing!

Is there a better approach?

TIA!

kynn

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


Re: nested structure with "internal references"

2009-09-25 Thread Kent Turbo
On Sep 25, 9:11 pm, Torsten Mohr  wrote:
> I'd like to refer to another entry and not copy that entry, i need to
> know later that this is a reference to another entry, i need to find
> also access that entry then.
>
> The references only need to refer to entries in this structure.
> The lists may change at runtime (entries removed / added), so
> storing the index may not help.

Python already stores everything as a reference, no need to invent
your own.
Consider this example:

>>> data = "This is real data"
>>> container = [ data, [ data ]]
>>> container
['This is real data', ['This is real data']]

'container' contains a reference to the data, and another list, with
another reference. You can easily check this by using a built-in
function id() which returns an object's identity:

>>> id(container[0])
140191569359088
>>> id(container[1][0])
140191569359088
>>> id(data)
140191569359088

So all python lists and dicts hold are references, and the real data
is elsewhere. Do you really need to have real reference to your data
in one place, or you are trying to avoid infinite loops in your data
(python handles this as well)?
-- 
http://mail.python.org/mailman/listinfo/python-list


What does the list_folders() method of mailbox.Maildir actually do (if anything)?

2009-09-25 Thread tinnews
I can't get the list_folders() method of the mailbox.Maildir class to
do anything remotely useful.  It seems to do nothing at all.  I have a
directory which contains a number of maildir malboxes:-

chris$ ls -l /home/chris/Mail/apex
total 24
drwx-- 5 chris chris 4096 2009-04-30 09:45 charles.rustin
drwx-- 5 chris chris 4096 2009-04-30 09:45 greg
drwx-- 5 chris chris 4096 2009-04-30 09:45 maureenMcgoldrick
drwx-- 5 chris chris 4096 2009-04-30 09:45 ram
drwx-- 5 chris chris 4096 2009-04-30 09:46 sarahLagley
drwx-- 5 chris chris 4096 2009-04-30 09:46 symonSmith
chris$ ls -l /home/chris/Mail/apex/ram
total 12
drwx-- 2 chris chris 4096 2009-04-30 09:45 cur
drwx-- 2 chris chris 4096 2009-04-30 09:45 new
drwx-- 2 chris chris 4096 2009-04-30 09:45 tmp


If I run the following code:-

#!/usr/bin/python
#
#
# Mail archiving utility
#
import mailbox
 
topLevel=mailbox.Maildir("/home/chris/Mail/apex")
print topLevel.list_folders()

It just outputs "[]".

Am I doing something totally wrong or is list_folders() completely broken?


-- 
Chris Green

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


Re: Most "active" coroutine library project?

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 2:07 PM, Jason Tackaberry  wrote:
> On Fri, 2009-09-25 at 15:42 +, Grant Edwards wrote:
>> You can't call a function that yields control back to the other
>> coroutine(s).  By jumping through some hoops you can get the
>> same effect, but it's not very intuitive and it sort of "feels
>> wrong" that the main routine has to know ahead of time when
>> calling a function whether that function might need to yield or
>> not.
>
> Not directly, but you can simulate this, or at least some pseudo form of
> it which is useful in practice.  I suppose you could call this "jumping
> through some hoops," but from the point of view of the coroutine, it can
> be done completely transparently, managed by the coroutine scheduler.
>
> In kaa, which I mentioned earlier, this might look like:
>
>        import kaa
>
>       �[email protected]()
>        def task(name):
>           for i in range(10):
>              print name, i
>              yield kaa.NotFinished  # kind of like a time slice
>
>       �[email protected]()
>        def fetch_google():
>           s = kaa.Socket()
>           try:
>              yield s.connect('google.com:80')
>           except:
>              print 'Connection failed'
>              return
>           yield s.write('GET / HTTP/1.1\nHost: google.com\n\n')
>           yield (yield s.read())
>
>       �[email protected]()
>        def orchestrate():
>            task('apple')
>            task('banana')
>            page = yield fetch_google()
>            print 'Fetched %d bytes' % len(page)
>
>        orchestrate()
>        kaa.main.run()
>
>
> The two task() coroutines spawned by orchestrate() continue to "run in
> the background" while any of the yields in fetch_google() are pending
> (waiting on some network resource).
>
> It's true that the yields in fetch_google() aren't yielding control
> _directly_ to one of the task() coroutines, but it _is_ doing so
> indirectly, via the coroutine scheduler, which runs inside the main
> loop.
>
> Cheers,
> Jason.
>



So Kaa is essentially implementing the trampoline function.

If I understand it correctly MyHDL does something similar (to
implement models of hardware components running concurrently.)
http://www.myhdl.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most "active" coroutine library project?

2009-09-25 Thread Jason Tackaberry
On Fri, 2009-09-25 at 18:36 +, Grant Edwards wrote:
> That's not comletely transparently.  The routine fetch_google()
> has to know a priori that s.connect() might want to yield and
> so has to invoke it with a yield statement.

With my implementation, tasks that execute asynchronously (which may be
either threads or coroutines) return a special object called an
InProgress object.  You always yield such calls.

So you're right, it does require knowing a priori what invocations may
return InProgress objects.  But this isn't any extra effort.  It's
difficult to write any non-trivial program without knowing a priori what
callables will return, isn't it?


> Completely transparent would be this:
[...]
>  try:
>  s.connect('google.com:80')
>  except:

Jean-Paul made the same argument.  In my view, the requirement to yield
s.connect() is a feature, not a bug.  Here, IMO explicit truly is better
than implicit.  I prefer to know at what specific points my routines may
branch off.

And I maintain that requiring yield doesn't make it any less a
coroutine.

Maybe we can call this an aesthetic difference of opinion?


> Again, you have to know ahead of time which functions might
> yeild and which ones don't and call them differently.  That's
> the "hoop".

To the extent it should be considered jumping through hoops to find what
any callable returns, all right.


> > It's true that the yields in fetch_google() aren't yielding control
> > _directly_ to one of the task() coroutines, but it _is_ doing so
> > indirectly, via the coroutine scheduler, which runs inside the main
> > loop.
> 
> True.  But I wouldn't call that transparent.

What I meant by transparent is the fact that yield inside fetch_google()
can "yield to" (indirectly) any active coroutine.  It doesn't (and
can't) know which.  I was responding to your specific claim that: 

> [...] the "mis-feature" in Python co-routines that's being discussed
> is the fact that you can only yeild/resume from the main coroutine
> function.

With my implementation this is only half true.  It's true that for other
active coroutines to be reentered, "main" coroutines (there can be more
than one in kaa) will need to yield, but once control is passed back to
the coroutine scheduler (which is hooked into main loop facility), any
active coroutine may be reentered.

Cheers,
Jason.

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


Re: Most "active" coroutine library project?

2009-09-25 Thread Jason Tackaberry
On Fri, 2009-09-25 at 15:25 -0400, Simon Forman wrote:
> So Kaa is essentially implementing the trampoline function.

Essentially, yeah.  It doesn't require (or support, depending on your
perspective) a coroutine to explicitly yield the next coroutine to be
reentered, but otherwise I'd say it's the same basic construct.

Cheers,
Jason.

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


Re: What does the list_folders() method of mailbox.Maildir actually do (if anything)?

2009-09-25 Thread Jeff McNeil
On Sep 25, 3:22 pm, [email protected] wrote:
> I can't get the list_folders() method of the mailbox.Maildir class to
> do anything remotely useful.  It seems to do nothing at all.  I have a
> directory which contains a number of maildir malboxes:-
>
>     chris$ ls -l /home/chris/Mail/apex
>     total 24
>     drwx-- 5 chris chris 4096 2009-04-30 09:45 charles.rustin
>     drwx-- 5 chris chris 4096 2009-04-30 09:45 greg
>     drwx-- 5 chris chris 4096 2009-04-30 09:45 maureenMcgoldrick
>     drwx-- 5 chris chris 4096 2009-04-30 09:45 ram
>     drwx-- 5 chris chris 4096 2009-04-30 09:46 sarahLagley
>     drwx-- 5 chris chris 4096 2009-04-30 09:46 symonSmith
>     chris$ ls -l /home/chris/Mail/apex/ram
>     total 12
>     drwx-- 2 chris chris 4096 2009-04-30 09:45 cur
>     drwx-- 2 chris chris 4096 2009-04-30 09:45 new
>     drwx-- 2 chris chris 4096 2009-04-30 09:45 tmp
>
> If I run the following code:-
>
>     #!/usr/bin/python
>     #
>     #
>     # Mail archiving utility
>     #
>     import mailbox
>
>     topLevel=mailbox.Maildir("/home/chris/Mail/apex")
>     print topLevel.list_folders()
>
> It just outputs "[]".
>
> Am I doing something totally wrong or is list_folders() completely broken?
>
> --
> Chris Green

The Maildir++ spec states that folders need to begin with a period.
The list_folders method enforces that:

def list_folders(self):
"""Return a list of folder names."""
result = []
for entry in os.listdir(self._path):
if len(entry) > 1 and entry[0] == '.' and \
   os.path.isdir(os.path.join(self._path, entry)):
result.append(entry[1:])
return result

The above example is from 2.6.  Your structure is simply a list of
Maildir compliant directories below '/home/chris/Mail/apex.' They're
not, in the Maildir++ sense of the word, folders.

--
Thanks,

Jeff
mcjeff.blospot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: importing with .m instead of .py

2009-09-25 Thread Wanderer
On Sep 25, 2:05 pm, Andrew Svetlov  wrote:
> On Sep 25, 1:16 pm, Wanderer  wrote:
>
> > execfile(x) does what I'm looking for.
>
> Perhaps you are looking for Python import 
> hook:http://www.python.org/dev/peps/pep-0302/
>
> In you import hook you can do everything (and locate/import file with
> any extension :)

I'm just porting a bunch of octave functions into pylab that use data
I collected in files like I show above. The execfile() method lets me
verify I get the same results in Octave and Python. It is in the NumPy
for Matlab users page at Mathesaurus 
http://mathesaurus.sourceforge.net/matlab-numpy.html,
but they make it look like it needs a .py extension. Like Ishwor said
'Trivial', now that I know how :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Mark Dickinson
On Sep 25, 7:56 pm, Mark Dickinson  wrote:
> On Sep 25, 7:05 pm, Alejandro Valdez 
> wrote:
> > Hello I sent this e-mail to the python-help list but I'm not sure if
> > that list is active... so I post it again here:
>
> > I'm trying to build Python 2.6.2 from the sources downloaded from the
> > python official site on OpenSuSE 11.1 (32 bit). After installation the
> > python command line interpreter seems to run ok, but when I try to
> > install setuptools I get:
> > [...]
> > To compile Python I executed:
>
> > ./configure --prefix=/home/user/python
> > ./make
> > ./make install
>
> > The compile process seems to be ok, so I'm kind of clueless :-(
>
> > Any ideas?
>
> This is just a guess, but try configuring with:
>
> ./configure --enable-unicode=ucs4 --prefix=/home/user/python
>
> On Linux, by default, a self-compiled Python uses UCS2
> internally for its unicode support (with some support
> for UTF16).  Most Linux distributions, however, distribute
> a Python that uses UCS4 (aka UTF32) instead, so it seems
> possible that your setuptools egg is expecting to find a
> UCS4 build.

Also, make sure that setuptools is picking up the right python2.6
executable:  you want it to be using the one in /home/user/python/bin,
not the one in /usr/bin (or where-ever SuSE keeps its python).
What does 'which python2.6' give on your system, after the python
install
but before the setuptools install?

It may be necessary to set the PYTHONPATH environment variable too;
I'm not sure about this.

I admit I don't really understand how you could be getting an
undefined _PyUnicodeUCS2* symbol;  undefined _PyUnicodeUCS4* would
make more sense.

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


Re: flow control and nested loops

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 3:01 PM, kj  wrote:
>
>
> In Perl, one can label loops for finer flow control.  For example:
>
> X: for my $x (@X) {
>  Y: for my $y (@Y) {
>    for my $z (@Z) {
>      next X if test1($x, $y, $z);
>      next Y if test2($x, $y, $z);
>      frobnicate($x, $y, $z);
>    }
>    glortz($x, $y);
>  }
>  splat($x);
> }
>
> What's considered "best practice" in the Python world for this sort
> of situation?  The only approach I can think of requires setting
> up indicator variables that must be set and tested individually;
> e.g.
>
> for x in X:
>    next_X = False
>    for y in Y:
>        next_Y = False
>        for z in Z:
>            if test1(x, y, z):
>                next_X = True
>                break
>            if test2(x, y, z):
>                next_Y = True
>                break
>            frobnicate(x, y, z)
>        if next_X:
>            break
>        if next_Y:
>            continue
>        glortz(x, y)
>    if next_X:
>        continue
>    splat(x)
>
> Whereas I find the Perl version reasonably readable, the Python
> one I find nearly incomprehensible.  In fact, I'm not even sure
> that the Python version faithfully replicates what the Perl one is
> doing!
>
> Is there a better approach?
>
> TIA!
>
> kynn
>

The best approach would be to reorganize your code so you
didn't have to do that.

Seriously though, I find both the perl and python versions
non-obvious.  You have had to use constructs like this in practice?

Generally, I would use "flags" in tricky nested loops just like you
did, perhaps with some comments to clarify things.   An alternative
might be to use custom exceptions.  Hopefully someone smarter than me
will come along and show an even better approach.


class NextX(Exception): pass
class NextY(Exception): pass


for x in X:
try:
for y in Y:
try:
for z in Z:

if test1(x, y, z):
raise NextX

if test2(x, y, z):
raise NextY

frobnicate(x, y, z)

except NextY:
continue

glortz(x, y)

except NextX:
continue

splat(x)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: flow control and nested loops

2009-09-25 Thread Terry Reedy

kj wrote:


In Perl, one can label loops for finer flow control.  For example:

X: for my $x (@X) {
  Y: for my $y (@Y) {
for my $z (@Z) {
  next X if test1($x, $y, $z);
  next Y if test2($x, $y, $z);
  frobnicate($x, $y, $z);
}
glortz($x, $y); 
  }
  splat($x); 
}


What's considered "best practice" in the Python world for this sort
of situation?  The only approach I can think of requires setting
up indicator variables that must be set and tested individually;
e.g.

for x in X:
next_X = False
for y in Y:
next_Y = False
for z in Z:
if test1(x, y, z):
next_X = True
break
if test2(x, y, z):
next_Y = True
break
frobnicate(x, y, z)
if next_X:
break
if next_Y:
continue
glortz(x, y) 
if next_X:

continue
splat(x) 


Whereas I find the Perl version reasonably readable, the Python
one I find nearly incomprehensible.  In fact, I'm not even sure
that the Python version faithfully replicates what the Perl one is
doing!

Is there a better approach?


1. Put inner loops in a function and return instead of break.

2. Put inner loops in
try:
  for..
for
  if cond: raise Something
  # or do operation that raises exception if cond is true
except e:
  whatever

tjr

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


Re: What does the list_folders() method of mailbox.Maildir actually ?do (if anything)?

2009-09-25 Thread tinnews
Jeff McNeil  wrote:
> On Sep 25, 3:22 pm, [email protected] wrote:
> > I can't get the list_folders() method of the mailbox.Maildir class to
> > do anything remotely useful.  It seems to do nothing at all.  I have a
> > directory which contains a number of maildir malboxes:-
> >
> >     chris$ ls -l /home/chris/Mail/apex
> >     total 24
> >     drwx-- 5 chris chris 4096 2009-04-30 09:45 charles.rustin
> >     drwx-- 5 chris chris 4096 2009-04-30 09:45 greg
> >     drwx-- 5 chris chris 4096 2009-04-30 09:45 maureenMcgoldrick
> >     drwx-- 5 chris chris 4096 2009-04-30 09:45 ram
> >     drwx-- 5 chris chris 4096 2009-04-30 09:46 sarahLagley
> >     drwx-- 5 chris chris 4096 2009-04-30 09:46 symonSmith
> >     chris$ ls -l /home/chris/Mail/apex/ram
> >     total 12
> >     drwx-- 2 chris chris 4096 2009-04-30 09:45 cur
> >     drwx-- 2 chris chris 4096 2009-04-30 09:45 new
> >     drwx-- 2 chris chris 4096 2009-04-30 09:45 tmp
> >
> > If I run the following code:-
> >
> >     #!/usr/bin/python
> >     #
> >     #
> >     # Mail archiving utility
> >     #
> >     import mailbox
> >
> >     topLevel=mailbox.Maildir("/home/chris/Mail/apex")
> >     print topLevel.list_folders()
> >
> > It just outputs "[]".
> >
> > Am I doing something totally wrong or is list_folders() completely broken?
> >
> > --
> > Chris Green
> 
> The Maildir++ spec states that folders need to begin with a period.
> The list_folders method enforces that:
> 
> def list_folders(self):
> """Return a list of folder names."""
> result = []
> for entry in os.listdir(self._path):
> if len(entry) > 1 and entry[0] == '.' and \
>os.path.isdir(os.path.join(self._path, entry)):
> result.append(entry[1:])
> return result
> 
> The above example is from 2.6.  Your structure is simply a list of
> Maildir compliant directories below '/home/chris/Mail/apex.' They're
> not, in the Maildir++ sense of the word, folders.
> 
So where does it say in the Python documentation that list_folders()
works only with Maildir++?  It's a big and non-obvious limitation to
my mind.

My maildir hierarchy is created by mutt which is a *very* standards
compliant MUA, surely standard python libraries should work with
standard maildirs not some wierd extension thereof.

-- 
Chris Green

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


Re: Repeated output when logging exceptions

2009-09-25 Thread Vinay Sajip
On Sep 24, 8:43 pm, John Gordon  wrote:
> Why is this happening?  I suspect it's because I'm declaring two instances
> of the exceptionLogger class, which ends up calling logger.addHandler()
> twice.  Is that right?
>

Yes, that's why you get duplicated lines in the log.

> What would be a better way to handle this?

I'm not sure why you need all the code you've posted. The logging
package allows you to add tracebacks to your logs by using the
exception() method, which logs an ERROR with a traceback and is
specifically intended for use from within exception handlers. All that
stuff with temporary files seems completely unnecessary, even with
Python 2.3.

In general, avoid adding handlers more than once - which you are
almost guaranteed to not avoid if you do this kind of processing in a
constructor. If you write your applications without using the
exceptionLogger class (not really needed, since logging exceptions
with tracebacks is part and parcel of the logging package's
functionality since its introduction with Python 2.3), what
functionality do you lose?

Regards,

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


Re: What does the list_folders() method of mailbox.Maildir actually ?do (if anything)?

2009-09-25 Thread Jeff McNeil
On Sep 25, 4:13 pm, [email protected] wrote:
> Jeff McNeil  wrote:
> > On Sep 25, 3:22 pm, [email protected] wrote:
> > > I can't get the list_folders() method of the mailbox.Maildir class to
> > > do anything remotely useful.  It seems to do nothing at all.  I have a
> > > directory which contains a number of maildir malboxes:-
>
> > >     chris$ ls -l /home/chris/Mail/apex
> > >     total 24
> > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 charles.rustin
> > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 greg
> > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 maureenMcgoldrick
> > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 ram
> > >     drwx-- 5 chris chris 4096 2009-04-30 09:46 sarahLagley
> > >     drwx-- 5 chris chris 4096 2009-04-30 09:46 symonSmith
> > >     chris$ ls -l /home/chris/Mail/apex/ram
> > >     total 12
> > >     drwx-- 2 chris chris 4096 2009-04-30 09:45 cur
> > >     drwx-- 2 chris chris 4096 2009-04-30 09:45 new
> > >     drwx-- 2 chris chris 4096 2009-04-30 09:45 tmp
>
> > > If I run the following code:-
>
> > >     #!/usr/bin/python
> > >     #
> > >     #
> > >     # Mail archiving utility
> > >     #
> > >     import mailbox
>
> > >     topLevel=mailbox.Maildir("/home/chris/Mail/apex")
> > >     print topLevel.list_folders()
>
> > > It just outputs "[]".
>
> > > Am I doing something totally wrong or is list_folders() completely broken?
>
> > > --
> > > Chris Green
>
> > The Maildir++ spec states that folders need to begin with a period.
> > The list_folders method enforces that:
>
> >     def list_folders(self):
> >         """Return a list of folder names."""
> >         result = []
> >         for entry in os.listdir(self._path):
> >             if len(entry) > 1 and entry[0] == '.' and \
> >                os.path.isdir(os.path.join(self._path, entry)):
> >                 result.append(entry[1:])
> >         return result
>
> > The above example is from 2.6.  Your structure is simply a list of
> > Maildir compliant directories below '/home/chris/Mail/apex.' They're
> > not, in the Maildir++ sense of the word, folders.
>
> So where does it say in the Python documentation that list_folders()
> works only with Maildir++?  It's a big and non-obvious limitation to
> my mind.
>
> My maildir hierarchy is created by mutt which is a *very* standards
> compliant MUA, surely standard python libraries should work with
> standard maildirs not some wierd extension thereof.
>
> --
> Chris Green


The doc says that "Folders of the style introduced by the Courier mail
transfer agent are also supported. Any subdirectory of the main
mailbox is considered a folder if '.' is the first character in its
name."  It's not an explicit endorsement of Maildir++, but it touches
on what it considers a folder definition. I'm treading on hazy memory
here, but I believe Maildir++ is the definition provided by the
Courier folks.

--
Thanks,

Jeff
mcjeff.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does the list_folders() method of mailbox.Maildir actually ?do (if anything)?

2009-09-25 Thread Jeff McNeil
On Sep 25, 4:28 pm, Jeff McNeil  wrote:
> On Sep 25, 4:13 pm, [email protected] wrote:
>
>
>
>
>
> > Jeff McNeil  wrote:
> > > On Sep 25, 3:22 pm, [email protected] wrote:
> > > > I can't get the list_folders() method of the mailbox.Maildir class to
> > > > do anything remotely useful.  It seems to do nothing at all.  I have a
> > > > directory which contains a number of maildir malboxes:-
>
> > > >     chris$ ls -l /home/chris/Mail/apex
> > > >     total 24
> > > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 charles.rustin
> > > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 greg
> > > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 maureenMcgoldrick
> > > >     drwx-- 5 chris chris 4096 2009-04-30 09:45 ram
> > > >     drwx-- 5 chris chris 4096 2009-04-30 09:46 sarahLagley
> > > >     drwx-- 5 chris chris 4096 2009-04-30 09:46 symonSmith
> > > >     chris$ ls -l /home/chris/Mail/apex/ram
> > > >     total 12
> > > >     drwx-- 2 chris chris 4096 2009-04-30 09:45 cur
> > > >     drwx-- 2 chris chris 4096 2009-04-30 09:45 new
> > > >     drwx-- 2 chris chris 4096 2009-04-30 09:45 tmp
>
> > > > If I run the following code:-
>
> > > >     #!/usr/bin/python
> > > >     #
> > > >     #
> > > >     # Mail archiving utility
> > > >     #
> > > >     import mailbox
>
> > > >     topLevel=mailbox.Maildir("/home/chris/Mail/apex")
> > > >     print topLevel.list_folders()
>
> > > > It just outputs "[]".
>
> > > > Am I doing something totally wrong or is list_folders() completely 
> > > > broken?
>
> > > > --
> > > > Chris Green
>
> > > The Maildir++ spec states that folders need to begin with a period.
> > > The list_folders method enforces that:
>
> > >     def list_folders(self):
> > >         """Return a list of folder names."""
> > >         result = []
> > >         for entry in os.listdir(self._path):
> > >             if len(entry) > 1 and entry[0] == '.' and \
> > >                os.path.isdir(os.path.join(self._path, entry)):
> > >                 result.append(entry[1:])
> > >         return result
>
> > > The above example is from 2.6.  Your structure is simply a list of
> > > Maildir compliant directories below '/home/chris/Mail/apex.' They're
> > > not, in the Maildir++ sense of the word, folders.
>
> > So where does it say in the Python documentation that list_folders()
> > works only with Maildir++?  It's a big and non-obvious limitation to
> > my mind.
>
> > My maildir hierarchy is created by mutt which is a *very* standards
> > compliant MUA, surely standard python libraries should work with
> > standard maildirs not some wierd extension thereof.
>
> > --
> > Chris Green
>
> The doc says that "Folders of the style introduced by the Courier mail
> transfer agent are also supported. Any subdirectory of the main
> mailbox is considered a folder if '.' is the first character in its
> name."  It's not an explicit endorsement of Maildir++, but it touches
> on what it considers a folder definition. I'm treading on hazy memory
> here, but I believe Maildir++ is the definition provided by the
> Courier folks.
>
> --
> Thanks,
>
> Jeff
> mcjeff.blogspot.com

http://wiki.mutt.org/?MuttFaq/Maildir

That might help as well. You can have Mutt setup your folders using
that extended method.

--
Thanks,

Jeff
mcjeff.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparison of parsers in python?

2009-09-25 Thread Nobody
On Tue, 22 Sep 2009 17:07:33 +1200, greg wrote:

>> What I want: a tokeniser generator which can take a lex-style grammar (not
>> necessarily lex syntax, but a set of token specifications defined by
>> REs, BNF, or whatever), generate a DFA, then run the DFA on sequences of
>> bytes. It must allow the syntax to be defined at run-time.
> 
> You might find my Plex package useful:
> 
> http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/

I haven't had time to play around with this yet, but it appears to be
essentially what I'm looking for.

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Paul Boddie
On 25 Sep, 13:21, Olof Bjarnason  wrote:
>
> I am thinking of two target audiences:
>
> 1. Early adopters/beta-testers. This would include:
>   - my non-computer-geek brother on a windows-machine. I'll go for py2exe.
>   - any non-geek visiting my blog using windows (py2exe)

I'd really like to hear of any positive experiences making installers
involving PyGame for any system, but especially for Windows using
cross-compilation of Python and library dependencies from non-Windows
systems with tools such as gcc for mingw32.

>   - any geeks visiting my blog that use Ubuntu (tell them about the 
> PPA-system)
>   - any geeks visiting my blog that are non-Ubuntu (i'll just provide
> the source code and tell them to apt-get python-pygame)

Typically, applications such as games written to use PyGame can just
run out of their distribution directory if that's good enough. You can
go to all kinds of lengths to make the game comply with packaging
standards and appear in the desktop menus - the latter is actually
quite easy within the Debian packaging infrastructure once you know
how - but it's not really necessary.

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


Re: Most "active" coroutine library project?

2009-09-25 Thread Grant Edwards
On 2009-09-25, Jason Tackaberry  wrote:

> Jean-Paul made the same argument.  In my view, the requirement to yield
> s.connect() is a feature, not a bug.  Here, IMO explicit truly is better
> than implicit.  I prefer to know at what specific points my routines may
> branch off.
>
> And I maintain that requiring yield doesn't make it any less a
> coroutine.
>
> Maybe we can call this an aesthetic difference of opinion?

Certainly.

You've a very valid point that "transparent" can also mean
"invisible", and stuff happening "invisibly" can be a source of
bugs.  All the invisible stuff going on in Perl and C++ has
always caused headaches for me.

-- 
Grant

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


Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Alejandro Valdez
Hello Mark, thank you a lot for your hints, I compiled python using
the --enable-unicode=ucs4 parameter in configure and I could
successfully install setuptools (Anyway I'm a little suspicious about
my compiled binaries...).

You are right about the environment variables, I have set PYTHONPATH
and PYTHONHOME to:
PYTHONPATH=$HOME/python/lib/python2.6/site-packages
PYTHONHOME=$HOME/python

The compiler issued some warnings, two of them (related to Unicode)
called my attention:

In file included from Python/formatter_unicode.c:13:
Python/../Objects/stringlib/formatter.h: In function
‘unknown_presentation_type’:
Python/../Objects/stringlib/formatter.h:35: warning: format ‘%c’
expects type ‘int’, but argument 3 has type ‘Py_UNICODE’

Should I ignore them?




Other warning messages:

libpython2.6.a(posixmodule.o): In function `posix_tmpnam':
/home/mailstat/Python-2.6.2/./Modules/posixmodule.c:7129: warning: the
use of `tmpnam_r' is dangerous, better use `mkstemp'
libpython2.6.a(posixmodule.o): In function `posix_tempnam':
/home/mailstat/Python-2.6.2/./Modules/posixmodule.c:7084: warning: the
use of `tempnam' is dangerous, better use `mkstemp'
/home/mailstat/Python-2.6.2/Modules/_struct.c:187: warning:
‘get_ulong’ defined but not used
/home/mailstat/Python-2.6.2/Modules/_cursesmodule.c: In function
‘PyCurses_getsyx’:
/home/mailstat/Python-2.6.2/Modules/_cursesmodule.c:1766: warning:
‘y’ may be used uninitialized in this function
/home/mailstat/Python-2.6.2/Modules/_cursesmodule.c:1766: warning:
‘x’ may be used uninitialized in this function

On Fri, Sep 25, 2009 at 3:56 PM, Mark Dickinson  wrote:
> On Sep 25, 7:05 pm, Alejandro Valdez 
> wrote:
>> Hello I sent this e-mail to the python-help list but I'm not sure if
>> that list is active... so I post it again here:
>>
>> I'm trying to build Python 2.6.2 from the sources downloaded from the
>> python official site on OpenSuSE 11.1 (32 bit). After installation the
>> python command line interpreter seems to run ok, but when I try to
>> install setuptools I get:
>> [...]
>> To compile Python I executed:
>>
>> ./configure --prefix=/home/user/python
>> ./make
>> ./make install
>>
>> The compile process seems to be ok, so I'm kind of clueless :-(
>>
>> Any ideas?
>
> This is just a guess, but try configuring with:
>
> ./configure --enable-unicode=ucs4 --prefix=/home/user/python
>
> On Linux, by default, a self-compiled Python uses UCS2
> internally for its unicode support (with some support
> for UTF16).  Most Linux distributions, however, distribute
> a Python that uses UCS4 (aka UTF32) instead, so it seems
> possible that your setuptools egg is expecting to find a
> UCS4 build.
>
> Mark
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Olof Bjarnason
2009/9/25 Paul Boddie :
> On 25 Sep, 13:21, Olof Bjarnason  wrote:
>>
>> I am thinking of two target audiences:
>>
>> 1. Early adopters/beta-testers. This would include:
>>   - my non-computer-geek brother on a windows-machine. I'll go for py2exe.
>>   - any non-geek visiting my blog using windows (py2exe)
>
> I'd really like to hear of any positive experiences making installers
> involving PyGame for any system, but especially for Windows using
> cross-compilation of Python and library dependencies from non-Windows
> systems with tools such as gcc for mingw32.

I'm using VirtualBox+WinXP on my Ubuntu development computer. Good
enough for me..

>
>>   - any geeks visiting my blog that use Ubuntu (tell them about the 
>> PPA-system)
>>   - any geeks visiting my blog that are non-Ubuntu (i'll just provide
>> the source code and tell them to apt-get python-pygame)
>
> Typically, applications such as games written to use PyGame can just
> run out of their distribution directory if that's good enough. You can
> go to all kinds of lengths to make the game comply with packaging
> standards and appear in the desktop menus - the latter is actually
> quite easy within the Debian packaging infrastructure once you know
> how - but it's not really necessary.

So what approach do you suggest? I've gotten as far as understanding
how to add menu-items to the Ubuntu menus, simple .desktop file format
to do that.

One could "cheat" and write an install.sh script that adds the
appropriate menu item, sudo-apt-gets the PyGame dependency (python is
there by default in Ubuntu). The menu item could point to the download
directory simply..

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



-- 
twitter.com/olofb
olofb.wordpress.com
olofb.wordpress.com/tag/english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Help required

2009-09-25 Thread vince spicer
On Fri, Sep 25, 2009 at 1:56 PM, waqas ahmad  wrote:

>
>
>  Hi,
>
> I dont know it is the right place to post this question. I need help to
> change one search code line . can you help me please.
>
> here is my search method code:
>
> search=re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext)
> if search:
> ret=search.group()
> else:
> ret='not defined'
> return ret
>
> here i am searching for "#acl InternationalGroup" in the pageText and when
> it true is then give me search group.
>
>
> I want to change this for following requirement:
>
> I want to search  for "#acl InternationalGroup" and  "CatInternational" for
> both in the pageText.
> when "#acl InternationalGroup" is not there but only "CatInternational" is
> there. then return me search group.
>
> I shall be thankful to you for any help.
>
> Best Regards,
> Waqas
>
>
>
> --
> What can you do with the new Windows Live? Find 
> out
>
> ___
> Tutor maillist  -  [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
i think this is what you are looking for:



search=re.compile("(#acl\sInternationalGroup|CatInternational).*\n",
re.M).search(pagetext)
if search:
ret=search.findall()
else:
ret='not defined'
return ret
-- 
http://mail.python.org/mailman/listinfo/python-list


variable scope

2009-09-25 Thread Joel Juvenal Rivera Rivera
Hi i was playing around with my code the i realize of this

###
_uno__a = 1
class uno():
__a = 2
def __init__(self):
print __a
uno()
###
and prints 1

So when i create class uno in the __init__ calls the global _uno__a when
i refer just __a ? it's some kind of "private global" variable?

Regards

Joel Rivera

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


Re: variable scope

2009-09-25 Thread Ethan Furman

Joel Juvenal Rivera Rivera wrote:

Hi i was playing around with my code the i realize of this

###
_uno__a = 1
class uno():
__a = 2
def __init__(self):
print __a
uno()
###
and prints 1

So when i create class uno in the __init__ calls the global _uno__a when
i refer just __a ? it's some kind of "private global" variable?

Regards

Joel Rivera




Wow, that's interesting.  Looks like you have simultaneously kicked in 
name mangling[1], while not using the 'self' notation to specify an 
instance variable and not a global variable.


For an instance variable you should use self.__a, not just __a.  And you 
don't want to use two leading underscores until you know what you're 
doing.  :-)


[1] http://www.python.org/doc/1.5/tut/node67.html
http://docs.python.org/reference/expressions.html
 in 5.2.1 Identifiers


Hope this helps!

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


Re: variable scope

2009-09-25 Thread Joel Juvenal Rivera Rivera
Yeah i forgot the self an try the code then i see
an error that it was not defines _uno__a so that's
where i define the global and see that behavior.

Thanks for your answers

El vie, 25-09-2009 a las 15:14 -0700, Ethan Furman escribió:
> Joel Juvenal Rivera Rivera wrote:
> > Hi i was playing around with my code the i realize of this
> > 
> > ###
> > _uno__a = 1
> > class uno():
> > __a = 2
> > def __init__(self):
> > print __a
> > uno()
> > ###
> > and prints 1
> > 
> > So when i create class uno in the __init__ calls the global _uno__a when
> > i refer just __a ? it's some kind of "private global" variable?
> > 
> > Regards
> > 
> > Joel Rivera
> > 
> 
> 
> Wow, that's interesting.  Looks like you have simultaneously kicked in 
> name mangling[1], while not using the 'self' notation to specify an 
> instance variable and not a global variable.
> 
> For an instance variable you should use self.__a, not just __a.  And you 
> don't want to use two leading underscores until you know what you're 
> doing.  :-)
> 
> [1] http://www.python.org/doc/1.5/tut/node67.html
>  http://docs.python.org/reference/expressions.html
>   in 5.2.1 Identifiers
> 
> 
> Hope this helps!
> 
> ~Ethan~

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Paul Boddie
On 25 Sep, 23:14, Olof Bjarnason  wrote:
>
> So what approach do you suggest? I've gotten as far as understanding
> how to add menu-items to the Ubuntu menus, simple .desktop file format
> to do that.

Yes, xdg-desktop-menu will probably do the trick.

> One could "cheat" and write an install.sh script that adds the
> appropriate menu item, sudo-apt-gets the PyGame dependency (python is
> there by default in Ubuntu). The menu item could point to the download
> directory simply..

I suppose the distribution of simple archives isn't enough if you want
the dependency to be pulled in. I personally would therefore just make
some quite simple Debian/Ubuntu packaging and distribute a .deb file -
I believe most distributions of this flavour have a graphical tool
which will offer to install such packages if downloaded, and the whole
sudo business would be taken care of by such a tool. This isn't how I
obtain software, however, so you might want to experiment a little.

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


Re: setting up dynamic descriptors in Python

2009-09-25 Thread Gabriel Genellina
En Thu, 24 Sep 2009 12:14:39 -0300, brian huggins   
escribió:



I want to set up descriptors at runtine, but it isn't working the way
i would expect.  Does anybody know if this is possible?

class TestDesc (object):
x=Descriptor ("x")
def __init__ (self):
self.y=Descriptor("y")


test=TestDesc()
test.y



When i access y, it appears to be a regular object and not a
descriptor type object like x.  Is there a way to make y work the same
as x but setting it up during object creation?


The descriptor "magic" only happens when the attribute is looked up on the  
class; when it's found in the instance itself, nothing special happens.
You cannot attach descriptors to a specific instance, but you can alter  
its class at runtime. Basically you have to create a new class (that  
inherits from the "real" class and adds the desired descriptor) and set it  
as the instance __class__ attribute.
(This was discussed some time ago, try searching the list archives. Uh, I  
found this:  
http://groups.google.com/group/comp.lang.python/t/bfc093464dd6ba9/

but you should be able to find other threads)

--
Gabriel Genellina

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Florian Diesch
Ben Finney  writes:

> Olof Bjarnason  writes:
>
>>   - any geeks visiting my blog that are non-Ubuntu (i'll just provide
>> the source code and tell them to apt-get python-pygame)
>
> Note that for several years now the recommended command-line tool for
> package installation is not ‘apt-get’, but ‘aptitude’ [0]. 

That's only true for Debian but not for Ubuntu; the official
Ubuntu Server guide uses apt-get: 



   Florian
-- 

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


Re: IDE for python similar to visual basic

2009-09-25 Thread Threader Slash
On Sat, Sep 26, 2009 at 12:58 AM, Dave Angel  wrote:

> Threader Slash wrote:
>
>> -- Forwarded message --
>>> From: J Sisson 
>>> To: Nobody 
>>> Date: Thu, 24 Sep 2009 19:18:03 -0500
>>> Subject: Re: IDE for python similar to visual basic
>>>
>>>
>>> On Sun, Sep 13, 2009 at 6:25 AM, Nobody  wrote:
>>>
>>>
>>>
 On Fri, 11 Sep 2009 05:27:59 -0700, r wrote:



>>>
>>>
  > Sounds like "somebody" failed to get input


> from their users at design time. Or "somebody" has the inability to
> relate to their end users.
>
>
 You're assuming that there is some "right" answer which is appropriate
 for
 all users. There isn't.



>>> I worked for a company that had a team composed of graphic artists, QA
>>> types, etc...that did nothing but draw up GUI's, show them to customers,
>>> revise them, write up runnable "dummies" of the approved GUI's, performed
>>> usability studies with our customers using the dummy GUI's, and finally
>>> handed the GUI's over to dev so they could put in the guts to make it "do
>>> stuff".
>>>
>>> "Bugs" or "Cases" involving the GUI needing revision because a button
>>> needed to be moved for usability were *extremely* rare, and the GUI
>>> didn't
>>> require an additional toolset that allowed end users to tweak them.
>>>
>>>
>>>
>>>
>>  My favorite IDE : Eclipse
>>
>> http://pydev.org/download.html
>>
>>
>> http://www.ibm.com/developerworks/opensource/library/os-eclipse-visualstudio
>>
>> http://www.eclipse.org
>>
>> Of course you have also the Mono:
>> http://monodevelop.com
>>
>> Cheers.|:0),
>>
>>
>>
> But where's the GUI designer for Eclipse/Python?  That's what the OP was
> asking about.
>
> GUI builders I've heard of, but not evaluated include:
>
>  Boa
>  wxGlade
>  wxFormBuilder
>  Wing IDE
>
> DaveA
>
>
Hi Dave,

Sorry, I just read and answer your post quickly... so, here again about the
IDE development for Python

http://pydev.org/download.html
http://pydev.org/screenshots.html

Also, please read and follow instructions:
http://pydev.org/manual_101_root.html
http://pydev.org/manual_101_project_conf2.html

About IDE you can install the Qt 2.5 or 2.6 SDK, it comes with the Qt
Designer. You just generates the design you want, then you save it as
myGUI.ui.

The only point is, if you are working on Windows with Python Qt, when you
have to run on console the command pyuic4 that will generate your
ui_myGUI.py source file to link it to your system, it doesn't work.

After reading and googling around, I find out that aparently there is a bug
on it for the free edtion of Qt for Windows. Hope that it can be fixed soon.
This means, that the GUI has to done code by yourself using Qt programming.

The Qt Design should just work fine for Linux, because I didn't hear about
any similar problem.

For Qt C++ on Windows it is apparently working -- but I didn't try yet:
http://labs.trolltech.com/blogs/2007/07/11/develop-qt-applications-in-eclipse

I hope this help. cheers.
-- 
http://mail.python.org/mailman/listinfo/python-list


super() and multiple inheritance failure

2009-09-25 Thread Steven D'Aprano
I don't understand why I'm getting the following behaviour when using 
super() with multiple inheritance. The following is a minimal example 
demonstrating the behaviour.

I have a diamond class hierarchy as follows:

 o
 |
 B
/ \
P  N
\ /
 M

where:
o = object
B = BaseClass
P = PClass
N = NClass
M = MyClass

Inside MyClass().method(n), I dispatch to either NClass.method() or 
PClass.method() depending on the value of the argument n. The correct 
class is called, but then the *other* class method is called as well. 
E.g. this is what I expect:

MyClass().method(2)
->  calls PClass.method
-> calls BaseClass.method

but this is what I get:

MyClass().method(2)
->  calls PClass method
->  calls NClass.method
-> calls BaseClass.method


and similarly for negative arguments, swapping PClass and NClass.

First off, is this the expected behaviour? I seems strange to me, can 
somebody explain why it is the nominally correct behaviour?

Secondly, how should I deal with this situation? Avoid super() 
altogether? Avoid multiple inheritance? Do something else?


Demonstration code follows, using doctest to demonstrate the failure and 
the call pattern.


### fail.py

import sys

class BaseClass(object):
def method(self, n):
"""Return something. n must not be 0, 1 or -1.

>>> instance = BaseClass()
>>> instance.method(7)
8
>>> instance.method(-5)
-4
"""
assert int(n) == n and n not in (-1, 0, 1)
return n + 1

class PClass(BaseClass):
"""Deal with positive n."""
def method(self, n):
"""Return something. n must be strictly > 1.

>>> instance = PClass()
>>> instance.method(4)
6
"""
print >>sys.stderr, "Called from PClass"
assert int(n) == n and n > 1
return 1 + super(PClass, self).method(n)

class NClass(BaseClass):
"""Deal with negative n."""
def method(self, n):
"""Return something. n must be strictly < -1.

>>> instance = NClass()
>>> instance.method(-4)
-2
"""
print >>sys.stderr, "Called from NClass"
assert int(n) == n and n < -1
return 1 + super(NClass, self).method(n)


class MyClass(PClass, NClass):
def method(self, n):
"""Return something useful.

>>> instance = MyClass()
>>> instance.method(12)
14
>>> instance.method(-12)
-10
"""
#print >>sys.stderr, "Calling itoa with base=%d" % base
if n > 0:
print >>sys.stderr, "About to call PClass"
parent = PClass
else:
print >>sys.stderr, "About to call NClass"
parent = NClass
return parent.method(self, n)


if __name__ == '__main__':
import doctest
doctest.testmod()



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


Re: Finding application data after install - a solution?

2009-09-25 Thread Gabriel Genellina
En Fri, 25 Sep 2009 06:53:18 -0300, Wolodja Wentland  
 escribió:



How do you you *install* this file within /etc ? Do users have to copy
it themselves into /etc from DATA_DIR/foo/etc/fooapplication.conf.sample
?


Nothing fancy here:

setup(data_files=[
   ('/etc/foo.conf', ['foo.conf.sample']),

If --install-data is used, one has to edit the /etc/foo.conf file by hand.  
I understand you want this step to be automatic, and I admit it would be  
great, but none of my users complained until now (not that there are so  
many...!)


--
Gabriel Genellina

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


Re: super() and multiple inheritance failure

2009-09-25 Thread Chris Rebert
On Fri, Sep 25, 2009 at 7:36 PM, Steven D'Aprano
 wrote:
> I don't understand why I'm getting the following behaviour when using
> super() with multiple inheritance. The following is a minimal example
> demonstrating the behaviour.
>
> I have a diamond class hierarchy as follows:
>
>  o
>  |
>  B
> / \
> P  N
> \ /
>  M
>
> where:
> o = object
> B = BaseClass
> P = PClass
> N = NClass
> M = MyClass
>
> Inside MyClass().method(n), I dispatch to either NClass.method() or
> PClass.method() depending on the value of the argument n. The correct
> class is called, but then the *other* class method is called as well.
> E.g. this is what I expect:
>
> MyClass().method(2)
> ->  calls PClass.method
>    -> calls BaseClass.method
>
> but this is what I get:
>
> MyClass().method(2)
> ->  calls PClass method
>    ->  calls NClass.method
>        -> calls BaseClass.method
>
>
> and similarly for negative arguments, swapping PClass and NClass.
>
> First off, is this the expected behaviour? I seems strange to me, can
> somebody explain why it is the nominally correct behaviour?

Pretty darn sure it's expected. super() follows the MRO, which in this
case is M, P, N, B, o; thus, the super() of an M instance from a P
method is indeed N.
This would normally be useful as one typically wants to call the
"parent" methods of all ancestor classes for which the method is
defined, rather than picking-and-choosing as MyClass.method() does. To
put it another way, if super() didn't act like it does, other people
would complain about N.method() getting skipped (e.g. "What then was
the point of my subclassing N if its methods don't get called?").

Remember that super() is sorta misnamed; Dylan's equivalent is named
"next-method" (Dylan is where Python cribbed much of its multiple
inheritance system from).

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Signing extensions

2009-09-25 Thread Roger Binns
I would like to digitally sign the open source Python extensions I produce.
 I produce source code (zip file) as well as pre-built binaries for Windows
(all Python versions from 2.3 to 3.1).

I can sign the source using my PGP key no problem.  I could also sign the
Windows binaries that way but Windows users are unlikely to have PGP and the
Google code downloads page would look even worse having another 8 or 9 .asc
files.

The Windows Python distribution is signed by PGP and the normal Microsoft
way using a Verisign class 3 cert.  (If you read their issuer statement it
ultimately says the cert isn't worth the bits it is printed on :-)  One of
those certs is $500 per year which is out of the question for me.

Does anyone have any other suggestions?  Has the PSF considered running a
certificate authority for extension developers, and other Python developers
for that matter?

Roger

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


Re: Format string with single quotes in it

2009-09-25 Thread Gabriel Genellina
En Fri, 25 Sep 2009 09:42:11 -0300, Bahadir   
escribió:



still struggling to get this right: How do I format a string that
contains single quotes in it?


Forget single quotes. Your problem doesn't appear to be related to those  
quotes.



I am reading a file with lines of the form:

CONT%d_VIRTMEM_REGIONS  'Container %d number of virtual regions'

and trying to format this as follows:

str % (0, 0)


It works fine for me:

py> str = "CONT%d_VIRTMEM_REGIONS  'Container %d number of virtual  
regions'"

py> str % (0, 0)
"CONT0_VIRTMEM_REGIONS  'Container 0 number of virtual regions'"


I get the error:

ValueError: unsupported format character '
' (0xa) at index 5541


0xa is \n, the end-of-line marker.

py> str = "test%\n"
py> str % 0
Traceback (most recent call last):
  File "", line 1, in 
ValueError: unsupported format character '
' (0xa) at index 5

So, look in your file for lines ending in %

--
Gabriel Genellina

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


Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 4:36 am, Steven D'Aprano  wrote:
> I don't understand why I'm getting the following behaviour when using
> super() with multiple inheritance.

super is working as intended. If you do not want cooperative methods,
don't use super
and call directly the superclass. I usually recommend avoiding
multiple inheritance
altogether. You may want to read "Things to know about super":

http://www.artima.com/weblogs/viewpost.jsp?thread=236275
http://www.artima.com/weblogs/viewpost.jsp?thread=236278
http://www.artima.com/weblogs/viewpost.jsp?thread=237121
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: super() and multiple inheritance failure

2009-09-25 Thread Daniel Stutzbach
On Fri, Sep 25, 2009 at 9:36 PM, Steven D'Aprano <
[email protected]> wrote:

> I don't understand why I'm getting the following behaviour when using
> super() with multiple inheritance. The following is a minimal example
> demonstrating the behaviour.
>

super() does not have the behavior that I would have expected, either, and
IMO the documentation is unenlightening.

I found the following website helpful in understanding what super()
*actually* does (though I do not support the author's hyperbolic
criticisms):
http://fuhm.net/super-harmful/

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: super() and multiple inheritance failure

2009-09-25 Thread Steven D'Aprano
On Fri, 25 Sep 2009 20:15:54 -0700, Chris Rebert wrote:

>> Inside MyClass().method(n), I dispatch to either NClass.method() or
>> PClass.method() depending on the value of the argument n. The correct
>> class is called, but then the *other* class method is called as well.
>> E.g. this is what I expect:
>>
>> MyClass().method(2)
>> ->  calls PClass.method
>>    -> calls BaseClass.method
>>
>> but this is what I get:
>>
>> MyClass().method(2)
>> ->  calls PClass method
>>    ->  calls NClass.method
>>        -> calls BaseClass.method
>>
>>
>> and similarly for negative arguments, swapping PClass and NClass.
>>
>> First off, is this the expected behaviour? I seems strange to me, can
>> somebody explain why it is the nominally correct behaviour?
> 
> Pretty darn sure it's expected. super() follows the MRO, which in this
> case is M, P, N, B, o; thus, the super() of an M instance from a P
> method is indeed N.

I was expecting super() to look at the class, not the instance. So if I 
call super(PClass, self), I expected that since PClass does not inherit 
from NClass, nothing should be inherited from NClass.


> This would normally be useful as one typically wants to call the
> "parent" methods of all ancestor classes for which the method is
> defined, rather than picking-and-choosing as MyClass.method() does. 

Gotcha. I was expecting super() to call the first matching ancestor 
method, not all of them.



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


Re: super() and multiple inheritance failure

2009-09-25 Thread Steven D'Aprano
On Fri, 25 Sep 2009 21:03:09 -0700, Michele Simionato wrote:

> On Sep 26, 4:36 am, Steven D'Aprano  cybersource.com.au> wrote:
>> I don't understand why I'm getting the following behaviour when using
>> super() with multiple inheritance.
> 
> super is working as intended. If you do not want cooperative methods,
> don't use super and call directly the superclass. 

Gotcha.

Is there a standard name for what I'm trying to do, versus what super() 
does? I assume the term for what super() does is "cooperative multiple 
inheritance". What should I call what I'm doing? "Non-cooperative MI" 
perhaps?


> I usually recommend avoiding multiple inheritance altogether.

In my case, PClass and NClass are actually private classes, and it seemed 
like a nice way to avoid having to fill MyClass with slightly-different 
versions of each method to deal with slight variations in the arguments. 
I'm aiming for some sort of polymorphic inheritance: in a method, if the 
argument meets some condition, inherit from PClass, if it meets another 
condition inherit from NClass, and so on. Is there are standard name for 
this idea?


> You may want to read "Things to know about super":
> 
> http://www.artima.com/weblogs/viewpost.jsp?thread=236275
> http://www.artima.com/weblogs/viewpost.jsp?thread=236278
> http://www.artima.com/weblogs/viewpost.jsp?thread=237121

Nice, thank you. It will take me a while to digest all that, this is my 
first attempt at deliberate multiple inheritance, and obviously my 
expectations were completely different.



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


Things to know about ‘super’ (was: super() and multiple inheritance failure)

2009-09-25 Thread Ben Finney
Michele Simionato  writes:

> You may want to read "Things to know about super":
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=236275
> http://www.artima.com/weblogs/viewpost.jsp?thread=236278
> http://www.artima.com/weblogs/viewpost.jsp?thread=237121

Thanks for these articles. Any chance they will appear in a single
location, so we don't need three separate URLs for them?

Also, one article passes on this recommendation:

use super consistently, and document that you use it, as it is part
of the external interface for your class, like it or not.

So, if use classes coming from a library in a multiple inheritance
situation, you must know if the classes were intended to be
cooperative (using super) or not. Library author should always
document their usage of super.

I can see lots of ways this fact could be documented, none of them
terribly concise. It's a simple “yes/no” fact about a class, after all;
what's the best way of succinctly conveying this information in a world
where the problem is barely known, let alone the solution?

-- 
 \   “If trees could scream, would we be so cavalier about cutting |
  `\   them down? We might, if they screamed all the time, for no good |
_o__)reason.” —Jack Handey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: super() and multiple inheritance failure

2009-09-25 Thread Ben Finney
Steven D'Aprano  writes:

> On Fri, 25 Sep 2009 21:03:09 -0700, Michele Simionato wrote:
> > I usually recommend avoiding multiple inheritance altogether.
>
> In my case, PClass and NClass are actually private classes, and it
> seemed like a nice way to avoid having to fill MyClass with
> slightly-different versions of each method to deal with slight
> variations in the arguments. I'm aiming for some sort of polymorphic
> inheritance: in a method, if the argument meets some condition,
> inherit from PClass, if it meets another condition inherit from
> NClass, and so on. Is there are standard name for this idea?

Your description makes me suspect a code smell. If you want to decide at
method-invocation time whether branch A or branch B should be taken, it
doesn't sound much like a good use of inheritance at all.

The correct semantic of inheritance, after all, is the “is-a”
relationship; if you don't know at the time of writing the ‘MyClass’
whether it is-a ‘PClass’ or is-a ‘NClass’, then it's probably neither.

Instead, I would be reassessing the design and seeing whether object
composition (“has-a” relationships) fits better than inheritance.

-- 
 \ “He may look like an idiot and talk like an idiot but don't let |
  `\  that fool you. He really is an idiot.” —Groucho Marx |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Things to know about ‘super’ (was: super() a nd multiple inheritance failure)

2009-09-25 Thread Michele Simionato
On Sep 26, 6:56 am, Ben Finney  wrote:
> Michele Simionato  writes:
> > You may want to read "Things to know about super":
>
> >http://www.artima.com/weblogs/viewpost.jsp?thread=236275
> >http://www.artima.com/weblogs/viewpost.jsp?thread=236278
> >http://www.artima.com/weblogs/viewpost.jsp?thread=237121
>
> Thanks for these articles. Any chance they will appear in a single
> location, so we don't need three separate URLs for them?

Good idea. I have collect them in PDF form here:
http://www.phyast.pitt.edu/~micheles/python/super.pdf

> Also, one article passes on this recommendation:
>
>     use super consistently, and document that you use it, as it is part
>     of the external interface for your class, like it or not.

(this is a literal citation from "super considered harmful" by James
Knight)

>     So, if use classes coming from a library in a multiple inheritance
>     situation, you must know if the classes were intended to be
>     cooperative (using super) or not. Library author should always
>     document their usage of super.
>
> I can see lots of ways this fact could be documented, none of them
> terribly concise. It's a simple “yes/no” fact about a class, after all;
> what's the best way of succinctly conveying this information in a world
> where the problem is barely known, let alone the solution?

Difficult question. You know that in an ideal world I would just
throw
away multiple inheritance, it is just not worth the complication.
In the real world, this is how a developer can document his hierarchy
in one-line:

class Base(object):
"This hierarchy use super. See http://fuhm.net/super-harmful";

or

class Base(object):
"This hierarchy does not use super. See http://fuhm.net/super-harmful";

That's all that is needed to third party code wanting to inherit from
the hierarchy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: super() and multiple inheritance failure

2009-09-25 Thread Gabriel Genellina
En Sat, 26 Sep 2009 01:48:08 -0300, Steven D'Aprano  
 escribió:



I'm aiming for some sort of polymorphic inheritance: in a method, if the
argument meets some condition, inherit from PClass, if it meets another
condition inherit from NClass, and so on. Is there are standard name for
this idea?


That doesn't look like an inheritance relationship ("is a").
If you say "from now on, act as a PClass, until further notice" and later  
"now, act as a NClass" you're using the Strategy pattern.


If you decide at every invocation which method to call, it's a dispatcher;  
you may use a dictionary to map each alternative to the function to be  
invoked. If it only depends on the type of the argument, there is a hidden  
gem in pkgutil (simplegeneric) that can help you.


--
Gabriel Genellina

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


Re: Signing extensions

2009-09-25 Thread Neil Hodgson
Roger Binns:

> The Windows Python distribution is signed by PGP and the normal Microsoft
> way using a Verisign class 3 cert.  (If you read their issuer statement it
> ultimately says the cert isn't worth the bits it is printed on :-)  One of
> those certs is $500 per year which is out of the question for me.

   Code signing certificates that will be be valid for Windows
Authenticode cost $129 per year through CodeProject

http://www.codeproject.com/services/certificates/index.aspx

> Does anyone have any other suggestions?  Has the PSF considered running a
> certificate authority for extension developers, and other Python developers
> for that matter?

   I'd like to see a certificate authority for open source projects
based mainly on project reputation and longevity. There may need to be
some payment to avoid flooding the CA with invalid requests - say $30
per year. It would be great if this CA was recognised by Microsoft and
Apple as well as Linux and BSD distributions.

   There are some issues about identity here. Should the certificate be
 for the project, an individual, or an individual within a project? You
want to know that PyExt1 comes from the genuine Ext1 project but the
build will commonly be initiated by an individual who may later be found
to be malicious. The Ext1 project should be able to revoke "Mal Icious
of Ext1" and have future releases signed by "Trust Worthy of Ext1".

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


Re: super() and multiple inheritance failure

2009-09-25 Thread Chris Rebert
On Fri, Sep 25, 2009 at 9:30 PM, Steven D'Aprano
 wrote:
> On Fri, 25 Sep 2009 20:15:54 -0700, Chris Rebert wrote:
>
>>> Inside MyClass().method(n), I dispatch to either NClass.method() or
>>> PClass.method() depending on the value of the argument n. The correct
>>> class is called, but then the *other* class method is called as well.
>>> E.g. this is what I expect:
>>>
>>> MyClass().method(2)
>>> ->  calls PClass.method
>>>    -> calls BaseClass.method
>>>
>>> but this is what I get:
>>>
>>> MyClass().method(2)
>>> ->  calls PClass method
>>>    ->  calls NClass.method
>>>        -> calls BaseClass.method
>>>
>>>
>>> and similarly for negative arguments, swapping PClass and NClass.
>>>
>>> First off, is this the expected behaviour? I seems strange to me, can
>>> somebody explain why it is the nominally correct behaviour?
>>
>> Pretty darn sure it's expected. super() follows the MRO, which in this
>> case is M, P, N, B, o; thus, the super() of an M instance from a P
>> method is indeed N.
>
> I was expecting super() to look at the class, not the instance.

To be pedantic, it looks at the type of instance, taking into account
the class passed to it.

>> This would normally be useful as one typically wants to call the
>> "parent" methods of all ancestor classes for which the method is
>> defined, rather than picking-and-choosing as MyClass.method() does.
>
> Gotcha. I was expecting super() to call the first matching ancestor
> method, not all of them.

Well, it doesn't call all of them, it's just that each method
implementation usually calls super() itself; thus, in concert, in
normal usage, all the methods end up getting called.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: super() and multiple inheritance failure

2009-09-25 Thread Michele Simionato
On Sep 26, 8:02 am, "Gabriel Genellina" 
wrote:
> If you decide at every invocation which method to call, it's a dispatcher;  
> you may use a dictionary to map each alternative to the function to be  
> invoked. If it only depends on the type of the argument, there is a hidden  
> gem in pkgutil (simplegeneric) that can help you.

And here is an example:

http://www.artima.com/weblogs/viewpost.jsp?thread=237764

(a lot of use case for multiple inheritance are better solved with
multimethods).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most "active" coroutine library project?

2009-09-25 Thread Hendrik van Rooyen
On Thursday, 24 September 2009 15:42:36 Antoine Pitrou wrote:
> Grant Edwards  invalid.invalid> writes:
> > Back when I worked on one of the first hand-held cellular
> > mobile phones, it used co-routines where the number of
> > coroutines was fixed at 2 (one for each register set in a Z80
> > CPU).
>
> Gotta love the lightning-fast EXX instruction. :-)

Using it in the above context is about equivalent to slipping a hand grenade 
in amongst the other eggs in a nest.

:-)

- Hendrik

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Javier Collado
Hello,

I recommend you to check this:
https://wiki.ubuntu.com/PackagingGuide/Complete

The best way to release the software to Ubuntu users is by means of a
PPA (https://help.launchpad.net/Packaging/PPA) so that people can
track your application updates automatically. Before the PPA is
created you need to have a launchpad account and a sign the Ubuntu
Code of Conduct. However isn't that hard and you just have to do all
this setup for the first time.

A tool that might be used to automate package creation for an
application is Quickly (https://wiki.ubuntu.com/Quickly). However, if
the project development has already started, probably it won't be
useful for you.

Best regards,
Javier

2009/9/25 Olof Bjarnason :
> Hi!
>
> I write small games in Python/PyGame. I want to find a way to make a
> downloadable package/installer/script to put on my webpage, especially
> for Ubuntu users.
>
> I've skimmed a couple of tutorials on how to generate .deb-files, but,
> wow, it's a whole new skill set to do that!
>
> Does anyone have any hint on a more economic way of creating
> single-file distribution packages for Python+PyGame projects? Maybe
> some GUI-tool that automates the .deb file creation process, but
> targetting Python specifically and not C++.
>
> /Olof
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Donn
On Friday 25 September 2009 08:15:18 Olof Bjarnason wrote:
> Does anyone have any hint on a more economic way of creating
> single-file distribution packages
You could use distutils (setup.py) and include a readme that explains what 
apt-get commands to use to install pygame, etc. Generally it's better to *not* 
include the kitchen-sink with your apps; rather expect the user to have those 
libraries already or be able to fetch them with ease.
I did my best at explaining that deeply confusing setup.py process here:
http://wiki.python.org/moin/Distutils/Tutorial

I have also seen two other approaches:
1. A new app called 'Quickly' which is some kind of magical auto-do-
everything-ubuntu connected to Launchpad. From what I hear it sounds very 
cool. https://wiki.ubuntu.com/DesktopTeam/Specs/Karmic/Quickly
2. The Ubuntu PPA repositories -- google around. (Seems Quickly does this too)

hth,
\d
-- 
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fontypython/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DBHandler class for logging?

2009-09-25 Thread Nebur
With a similar requirement, I made a small logging tool (usable as
handler) which logs into nearly every DB (including Postgres - thanks
to the SQLAlchemy library.)
It has BSD license. You may use it (or parts of the code):
http://www.reifenberg.de/rrlog/
(It does some more things you may not need, like rotation handling.)
Regards,
 Nebur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Jean Daniel
Maybe the distutils list is more adapted for this question:

The Zope community uses zc.sourcerelease to build rpm
http://www.mail-archive.com/[email protected]/msg06599.html

Buildout is said to have undocumented features to build packages.

Tarek Ziade is working debian package with 'distribute'.

Cheers,


On Fri, Sep 25, 2009 at 8:15 AM, Olof Bjarnason
 wrote:
> Hi!
>
> I write small games in Python/PyGame. I want to find a way to make a
> downloadable package/installer/script to put on my webpage, especially
> for Ubuntu users.
>
> I've skimmed a couple of tutorials on how to generate .deb-files, but,
> wow, it's a whole new skill set to do that!
>
> Does anyone have any hint on a more economic way of creating
> single-file distribution packages for Python+PyGame projects? Maybe
> some GUI-tool that automates the .deb file creation process, but
> targetting Python specifically and not C++.
>
> /Olof
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Rasterization Zion babylon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Olof Bjarnason
2009/9/25 Jean Daniel :
> Maybe the distutils list is more adapted for this question:

Yes

>
> The Zope community uses zc.sourcerelease to build rpm
> http://www.mail-archive.com/[email protected]/msg06599.html
>
> Buildout is said to have undocumented features to build packages.
>
> Tarek Ziade is working debian package with 'distribute'.

Thanks Jean!

>
> Cheers,
>
>
> On Fri, Sep 25, 2009 at 8:15 AM, Olof Bjarnason
>  wrote:
>> Hi!
>>
>> I write small games in Python/PyGame. I want to find a way to make a
>> downloadable package/installer/script to put on my webpage, especially
>> for Ubuntu users.
>>
>> I've skimmed a couple of tutorials on how to generate .deb-files, but,
>> wow, it's a whole new skill set to do that!
>>
>> Does anyone have any hint on a more economic way of creating
>> single-file distribution packages for Python+PyGame projects? Maybe
>> some GUI-tool that automates the .deb file creation process, but
>> targetting Python specifically and not C++.
>>
>> /Olof
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
> --
> Rasterization Zion babylon
>



-- 
twitter.com/olofb
olofb.wordpress.com
olofb.wordpress.com/tag/english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read header and data from a binary file [LONG]

2009-09-25 Thread Gabriel Genellina
En Tue, 22 Sep 2009 18:18:16 -0300, Jose Rafael Pacheco  
 escribió:



Hello,

I want to read from a binary file called myaudio.dat
Then I've tried the next code:

import struct
name = "myaudio.dat"
f = open(name,'rb')
f.seek(0)
chain = "< 4s 4s I 4s I 20s I I i 4s I 67s s 4s I"
s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1)



a = struct.unpack(chain, s)


Easier:
fmt = struct.Struct(chain)
s = f.read(fmt.size)
a = fmt.unpack(s)


The audio data length is 300126, now I need a clue to build an array with
the audio data (The Chunk SDA_), would it possible with struct?, any  
help ?


The chunk module (http://docs.python.org/library/chunk.html) is designed  
to work with such file format.


--
Gabriel Genellina

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


Re: Poll: Do you use csv.Sniffer?

2009-09-25 Thread Tim Chase

Why do you need the sniffer? If your client can't do "save as" the
same way twice, just read the spreadsheets directly!


If I only had one contact and one client, it would be this 
easy...If you can get multiple points of contact at multiple 
client sites to reliably & competently agree on a format, what 
are you doing here on c.l.py instead of making your billions as a 
business-integration consultant? ;-)


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


Python und Referenzen auf Variablen?

2009-09-25 Thread Torsten Mohr
Hallo,

ich möchte im Speicher eine verschachtelte Struktur aufbauen in der
dict()s und list()s verwendet werden und tief ineinander verschachtelt sind.
D.h. mehrere lists und dicts können jeweils wieder lists und dicts 
enthalten.

Ich möchte als Einträge hauptsächlich int, float und string verwenden, ich
muß aber auch Referenzen auf die anderen Einträge eintragen können,
die vom Programm anders behandelt werden müssen.

Die Schlüssel der dict()s werden sich vermutlich nicht mehr ändern
wenn sie einmal zugewiesen sind.
Die Indizes der list()s können sich zur Laufzeit allerdings schon ändern,
wenn z.B. aus einer list() ein Eintrag gelöscht wird.
Der nachfolgende Eintrag würde dann nachrücken und sich damit sein
Index ändern.

Wie könnte ich in so einer verschachtelten Struktur Referenzen abbilden?


Viele Grüße,
Torsten.


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


Re: Python und Referenzen auf Variablen?

2009-09-25 Thread Martin
Hi,

this list is english only. I won't translate for you as I think you
wouldn't be happy with it - as you can't read the recommendations - if
you don't speak english. In that case you might want to try
[email protected])

(die Liste ist eigentlich nur english, ich übersetze das mal nicht, da
du mit englischen antworten nicht glücklich sein wirst. Kurzes google
hat mich zu [email protected] geführt falls du lieber auf Deutsch
unterwegs bist)

2009/9/25 Torsten Mohr :
> Hallo,
>
> ich möchte im Speicher eine verschachtelte Struktur aufbauen in der

-- 
http://www.xing.com/profile/Martin_Marcher
http://www.linkedin.com/in/martinmarcher

You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Ben Finney
Olof Bjarnason  writes:

> I write small games in Python/PyGame. I want to find a way to make a
> downloadable package/installer/script to put on my webpage, especially
> for Ubuntu users.

As a program developer, you should be less concerned with the specifics
of any particular distribution, and aim first to make your work easily
adopted by those with motivation for that particular distribution.

This goal is made easier for program developers by standards and
specifications aimed at that purpose. A major one is the Filesystem
Hierarchy Standard http://www.pathname.com/fhs/>, and desktop
application programs should comply with the relevant specifications at
http://www.freedesktop.org/wiki/Specifications>.

> I've skimmed a couple of tutorials on how to generate .deb-files, but,
> wow, it's a whole new skill set to do that!

Right. A major benefit of the Debian (and hence Ubuntu) operating system
is a detailed, comprehensive policy on how to package the works for
integration with the whole operating system, and strict enforcement of
that policy.

That benefit comes at a cost: Packaging the work in such a way that it
complies with the Debian policy requires a certain amount of study and
discipline, and so is not a task that you should take on lightly. It's
often much better to form a relationship with someone who knows the
topic well who is also motivated to package your software. That person
(or group) becomes the “maintainer” of your work in Debian, and as you
have noted has a big enough job as it is.

Likewise for Ubuntu, Fedora, etc. to the extent that the distribution
has such a packaging policy.

> Does anyone have any hint on a more economic way of creating
> single-file distribution packages for Python+PyGame projects? Maybe
> some GUI-tool that automates the .deb file creation process, but
> targetting Python specifically and not C++.

Such tools do exist, but in my opinion they do more harm than good.
Their results cannot be anywhere near as suitable as the result of
someone who knows both your specific work and the relevant policy.
Better to lay solid groundwork by conforming firstly to the
distribution-agnostic specifications.

A sufficiently useful program that is also conformant with relevant
standards will be highly attractive to skilled packagers, and they will
be grateful to not have to fight against your work to get it to
integrate properly.

-- 
 \ “There is something wonderful in seeing a wrong-headed majority |
  `\   assailed by truth.” —John Kenneth Galbraith, 1989-07-28 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


lxml and xmlsec

2009-09-25 Thread Roland Hedberg

Hi!

Anyone know if it is possible to use xmlsec together with lxml ?

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


Re: Crypto and export laws

2009-09-25 Thread M.-A. Lemburg
Austin Bingham wrote:
> I'm trying to get a handle on how python intersects with
> crypto-related export control laws in the US and elsewhere. My current
> understanding, per the PSF's wiki, is that any crypto related and
> potentially export-sensitive code is in the ssl wrapper, and that, in
> fact, this only links to the actual encryption implementation
> (presumably libssl or something.) One caveat is that windows
> installations may include the ssl implementation.
> 
> Does this effectively sum up python's exposure to export laws? On a
> technical level, does removing the ssl module from a distribution
> remove all references to encryption? Of course I'm not asking for
> actual legal advice, but can anyone think of any other part of the
> code that might run afoul of export rules? Thanks.

Here's a summary:

 * Python uses OpenSSL in the ssl module and the hashlib module.

 * hashlib falls back to its own implementations of the md5 and
   sha algorithms.

 * ssl doesn't work without OpenSSL installed on the system.

 * The Windows intaller of Python ships with the OpenSSL libs.

 * The only Python module that actually contained crypto code
   was the rotor module (implementing an enigma-style cipher),
   but that was removed a long time ago.

Depending on how close a country follows the Wassenaar
Arrangement (http://www.wassenaar.org/) OpenSSL, Python
and all other open-source software falls under the
GENERAL SOFTWARE NOTE part 2.:

"""
The Lists do not control "software" which is either:
1. ...
2. "In the public domain".
"""

If you're shipping a closed-source product that includes
OpenSSL, then you'd have to follow the rules in category 5
part 2 of the dual-use list:

http://www.wassenaar.org/publicdocuments/index_CL.html

However, some countries add some extra requirements to the
WA dual-use list, so you need check those as well.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 25 2009)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: iterate over list while changing it

2009-09-25 Thread Warpcat
iterate over a copy of the list:

for i, x in enumerate(a[:]):

Always worked for me ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


can i use the browser to show the result of python

2009-09-25 Thread Hacken
I have write some python script

i want to use browser(IE or FF) to call it, an show the returns!

how to?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Poll: Do you use csv.Sniffer?

2009-09-25 Thread John Machin

On 25/09/2009 7:04 PM, Tim Chase wrote:

Why do you need the sniffer? If your client can't do "save as" the
same way twice, just read the spreadsheets directly!


If I only had one contact and one client, it would be this easy...If you 
can get multiple points of contact at multiple client sites to reliably 
& competently agree on a format, what are you doing here on c.l.py 
instead of making your billions as a business-integration consultant? ;-)


Because like everyone else, I can't get the same contact at the same 
site to do the same thing twice in a row :-(


My point is that "save as CSV" is (a) a potentially lossy process and 
(b) an unnecessary step when you can read straight from the XLS file.

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


Re: Date using input

2009-09-25 Thread Dave Angel

[email protected] wrote:
I don't think I am using re.compile properly, but thought as this 
would make my output an object it would be better for later, is that 
correct?


#Obtain date
def ObtainDate(date):
date = raw_input("Type Date dd/mm/year: ")
re.split('[/]+', date)
date
year = date[-1]
month = date[1]
day = date[0]
re.compile('year-month-day')


You persist in top-posting (putting your reply ahead of the sequence of 
messages you're quoting).


Regular expressions are an advanced technique.  You need to learn how 
strings work, how names clash, how functions return values.  Learn how 
the fundamental types can be manipulated before messing with datetime 
module, or re module.  As I said in an earlier message:


>>Do you understand what kind of data is returned by raw_input() ?  If 
so, look at the available
>>methods of that type, and see if there's one called split() that you 
can use to separate out the
>>multiple parts of the user's response.  You want to separate the dd 
from the mm and from the year.


You've done the same with the more complex and slower re module.  You 
could have just used the code I practically handed you:


   date_string = raw_input("Type Date dd/mm/year: ")
   date_list = datestring.split("/")

Then, you have correctly parsed the list into separate string 
variables.  Easier would have been:


   day, month, year = date_list

or just combining the last two lines:
day, month, year = date_string.split("/")

Now you'd like to put them together in a different order, with a 
different separator.  The re module doesn't do that, but again, you 
don't need it.  Look up str.join(), which is pretty much the inverse of 
split, or simply look up how to concatenate strings with the "+" operator.


Now, consider the calling and return of that function.  What are you 
using the formal parameter "date" for?  Why is it even there?  And what 
value are you intending to return?


Try writing one complete script, complete with a single definition, and 
a single call to that definition, perhaps printing the result calling 
that definition.  Master chapters 1-3  before jumping to chapter 12.


DaveA


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


Re: Finding application data after install - a solution?

2009-09-25 Thread Wolodja Wentland
On Fri, Sep 25, 2009 at 02:24 -0300, Gabriel Genellina wrote:
> En Thu, 24 Sep 2009 08:21:59 -0300, Wolodja Wentland
> >How do *you* deal with application data in your programs? Is there a way
> >that works on as many platforms as possible?

> On linux, using a configuration file like /etc/fooapplication.conf
> On Windows, using a registry key under
> HKEY_LOCAL_MACHINE\Software\My Bussiness Name\Foo Application.
> In either place, there is an entry pointing to the actual directory
> where data is stored.

How do you you *install* this file within /etc ? Do users have to copy
it themselves into /etc from DATA_DIR/foo/etc/fooapplication.conf.sample
?

> I never had the problem you want to solve, probably I'm just lucky
> (or perhaps my users are "geek" enough to know how to edit a config
> file, or dumb enough to never change the system settings...)

I am just trying to support all installation schemes supported by
distutils. That's all ;-)

so long

Wolodja


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PExpect on Windows System Using Cygwin

2009-09-25 Thread Dave Angel

Sean DiZazzo wrote:

On Sep 24, 4:37 pm, Dave Angel  wrote:
  


  

Why not just use the subprocess module?   It's built into the Windows
distribution, and doesn't need cygwin.

DaveA



Can subprocess pass things like passwords to running processes like
pexpect can?

~Sean

  
I don't know what pexpect is/was capable of, since it's not apparently 
part of the current Python distributions.  I thought it had the ability 
to fork or spawn a child process, with pipes connected.


Anyway, subprocess can launch a new process, with pipes optionally 
connected back to your code.  I don't think it can attach to an 
already-running process.


There are things in pywin32 that might help (even for controlling GUI 
programs), but I suspect there'd be a big learning curve.  And of course 
it'd then be very Windows-dependent.


pywin32 - http://python.net/crew/skippy/win32/Downloads.html
or get it as part of the ActiveState python distro.  
http://www.activestate.com/activepython/



DaveA

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


Re: can i use the browser to show the result of python

2009-09-25 Thread Dave Angel

Hacken wrote:

I have write some python script

i want to use browser(IE or FF) to call it, an show the returns!

how to?

  
You don't say much about your environment, nor the nature of your 
script. So my response will be very generic.



If your script writes a valid html/xml/xhtml format to stdout, then you 
could put the script onto a web server with cgi enabled, and mark it 
executable.  Then you could enter the URL for that cgi file into your 
browser, and see that generated web page.


Interesting additional gotchas:  You need rights to upload (ftp) to such 
a server.  The server needs to have an appropriate Python available, and 
configured to permit cgi access for files with the .py extension.  
Further, if the server is Unix, your file must be in Unix text format, 
with a shebang line that matches the location of the appropriate version 
of python on that particular server.


DaveA

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Paul Boddie
On 25 Sep, 08:15, Olof Bjarnason  wrote:
> Hi!
>
> I write small games in Python/PyGame. I want to find a way to make a
> downloadable package/installer/script to put on my webpage, especially
> for Ubuntu users.
>
> I've skimmed a couple of tutorials on how to generate .deb-files, but,
> wow, it's a whole new skill set to do that!

If you start simple and don't have to produce extension modules, it's
not too bad, but finding all the right tools is an awkward task. I'm
not sure that I've really mastered the craft yet.

> Does anyone have any hint on a more economic way of creating
> single-file distribution packages for Python+PyGame projects? Maybe
> some GUI-tool that automates the .deb file creation process, but
> targetting Python specifically and not C++.

You could take a look at this PyGame project:

http://www.infukor.com/rally7.html

The sources contain packaging infrastructure for Debian/Ubuntu, and
you could certainly adapt that for your own purposes.

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


problems trying to build python 2.6 as a shared library

2009-09-25 Thread Chris Withers

Hi All,

I'm trying to build Python 2.6 as a shared library, so I did:

  ./configure --enable-shared
  make
  make altinstall

No obvious signs of failure, but when I try and use the resulting 
python, I get:


python2.6: error while loading shared libraries: libpython2.6.so.1.0: 
cannot open shared object file: No such file or directory


Why might that be?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Olof Bjarnason
2009/9/25 Paul Boddie :
> On 25 Sep, 08:15, Olof Bjarnason  wrote:
>> Hi!
>>
>> I write small games in Python/PyGame. I want to find a way to make a
>> downloadable package/installer/script to put on my webpage, especially
>> for Ubuntu users.
>>
>> I've skimmed a couple of tutorials on how to generate .deb-files, but,
>> wow, it's a whole new skill set to do that!
>
> If you start simple and don't have to produce extension modules, it's
> not too bad, but finding all the right tools is an awkward task. I'm
> not sure that I've really mastered the craft yet.
>
>> Does anyone have any hint on a more economic way of creating
>> single-file distribution packages for Python+PyGame projects? Maybe
>> some GUI-tool that automates the .deb file creation process, but
>> targetting Python specifically and not C++.
>
> You could take a look at this PyGame project:
>
> http://www.infukor.com/rally7.html

Thanks this might come in handy.

>
> The sources contain packaging infrastructure for Debian/Ubuntu, and
> you could certainly adapt that for your own purposes.
>
> Paul
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
twitter.com/olofb
olofb.wordpress.com
olofb.wordpress.com/tag/english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Paul Boddie
On 25 Sep, 09:26, Donn  wrote:
>
> You could use distutils (setup.py) and include a readme that explains what
> apt-get commands to use to install pygame, etc. Generally it's better to *not*
> include the kitchen-sink with your apps; rather expect the user to have those
> libraries already or be able to fetch them with ease.

The various package installers and dpkg will probably complain about
missing packages, but one could go all the way and set up a repository
which works with apt-get. I did something elementary of this nature
with some Shed Skin packages:

http://packages.boddie.org.uk/

There will undoubtedly be things I haven't quite done right here, but
it would give a reasonable installation experience, although there
would need to be a number of packages available through the repository
for the configuration exercise to be worthwhile.

> I did my best at explaining that deeply confusing setup.py process 
> here:http://wiki.python.org/moin/Distutils/Tutorial

This is a nice tutorial, and I'll have to see if I can contribute
anything to it later.

> I have also seen two other approaches:
> 1. A new app called 'Quickly' which is some kind of magical auto-do-
> everything-ubuntu connected to Launchpad. From what I hear it sounds very
> cool.https://wiki.ubuntu.com/DesktopTeam/Specs/Karmic/Quickly
> 2. The Ubuntu PPA repositories -- google around. (Seems Quickly does this too)

The problem with some Ubuntu stuff, sadly, is that the maintainers
like to have their own special toolset which isolates them from the
more general Debian ways of working. In addition, Launchpad, despite
its recent open-sourcing (in most respects), is perceived as something
of a walled garden. Still, if it contributes good ideas to the
mainstream, I suppose it's not all bad.

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Olof Bjarnason
2009/9/25 Paul Boddie :
> On 25 Sep, 09:26, Donn  wrote:
>>
>> You could use distutils (setup.py) and include a readme that explains what
>> apt-get commands to use to install pygame, etc. Generally it's better to 
>> *not*
>> include the kitchen-sink with your apps; rather expect the user to have those
>> libraries already or be able to fetch them with ease.
>
> The various package installers and dpkg will probably complain about
> missing packages, but one could go all the way and set up a repository
> which works with apt-get. I did something elementary of this nature
> with some Shed Skin packages:
>
> http://packages.boddie.org.uk/
>
> There will undoubtedly be things I haven't quite done right here, but
> it would give a reasonable installation experience, although there
> would need to be a number of packages available through the repository
> for the configuration exercise to be worthwhile.
>
>> I did my best at explaining that deeply confusing setup.py process 
>> here:http://wiki.python.org/moin/Distutils/Tutorial
>
> This is a nice tutorial, and I'll have to see if I can contribute
> anything to it later.
>
>> I have also seen two other approaches:
>> 1. A new app called 'Quickly' which is some kind of magical auto-do-
>> everything-ubuntu connected to Launchpad. From what I hear it sounds very
>> cool.https://wiki.ubuntu.com/DesktopTeam/Specs/Karmic/Quickly
>> 2. The Ubuntu PPA repositories -- google around. (Seems Quickly does this 
>> too)
>
> The problem with some Ubuntu stuff, sadly, is that the maintainers
> like to have their own special toolset which isolates them from the
> more general Debian ways of working. In addition, Launchpad, despite
> its recent open-sourcing (in most respects), is perceived as something
> of a walled garden. Still, if it contributes good ideas to the
> mainstream, I suppose it's not all bad.
>
> Paul
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Thanks for you answers.

I am thinking of two target audiences:

1. Early adopters/beta-testers. This would include:
  - my non-computer-geek brother on a windows-machine. I'll go for py2exe.
  - any non-geek visiting my blog using windows (py2exe)
  - any geeks visiting my blog that use Ubuntu (tell them about the PPA-system)
  - any geeks visiting my blog that are non-Ubuntu (i'll just provide
the source code and tell them to apt-get python-pygame)

2. Future players
  - I'll try to find people that want me to help package the game for
different OSs. This list might come in handy ;)




-- 
twitter.com/olofb
olofb.wordpress.com
olofb.wordpress.com/tag/english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems trying to build python 2.6 as a shared library

2009-09-25 Thread Marco Nawijn
On Sep 25, 1:08 pm, Chris Withers  wrote:
> Hi All,
>
> I'm trying to build Python 2.6 as a shared library, so I did:
>
>    ./configure --enable-shared
>    make
>    make altinstall
>
> No obvious signs of failure, but when I try and use the resulting
> python, I get:
>
> python2.6: error while loading shared libraries: libpython2.6.so.1.0:
> cannot open shared object file: No such file or directory
>
> Why might that be?
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Batch Processing & Python Consulting
>             -http://www.simplistix.co.uk

Hello Chris,

The dynamic loader cannot find the python shared library.  There are
at least 2 options:
1. Add path that contains the shared library to the
LD_LIBRARY_PATH environment variable. In a bash shell this can be
accomplished by:  export LD_LIBRARY_PATH=/path/to/python_shared_lib:
$LD_LIBRARY_PATH
2. Add path to dynamic linker configuration file. This typically
is in '/etc/ld.so.conf'. See man page for ld for more information.

Note that I assumed that you are on a Unix/Linux machine.

Regards,

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


Re: problems trying to build python 2.6 as a shared library

2009-09-25 Thread Christian Heimes
Marco Nawijn wrote:
> The dynamic loader cannot find the python shared library.  There are
> at least 2 options:
> 1. Add path that contains the shared library to the
> LD_LIBRARY_PATH environment variable. In a bash shell this can be
> accomplished by:  export LD_LIBRARY_PATH=/path/to/python_shared_lib:
> $LD_LIBRARY_PATH
> 2. Add path to dynamic linker configuration file. This typically
> is in '/etc/ld.so.conf'. See man page for ld for more information.


3. Set LD_RUN_PATH before you link the shared library or use the -rlink
option of the linker, see man(1) ld.

Christian

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


Re: Evaluate coding and style

2009-09-25 Thread Jean-Michel Pichavant

Rhodri James wrote:
On Thu, 24 Sep 2009 21:11:36 +0100, Brown, Rodrick  
 wrote:


I recently started playing with Python about 3 days now (Ex Perl guy) 
and wanted some input on style and structure of what I'm doing before 
I really start picking up some bad habits here is a simple test tool 
I wrote to validate home dirs on my system.


Ethan's made some good points.  Here are a couple more.

[snip]

try:
  fh = open(filename)
except IOError:
  print "No such filename: %s" % (filename)

[snip]

It's is usually a bad idea to loose information when giving feedback to 
the user.

try:
 fh = open(filename)
except IOError, exception:
 print "Error openning %s : " % (filename, exception)

In general, if you want to improve your coding style/rules, read PEP 8 
and this  page :

http://tottinge.blogsome.com/meaningfulnames/

This is a must read (yet you still can disagree).
Regarding this,
fh = open(filename) would become
fileHandler = open(fileName)

Much nicer to read :o)

These are just suggestions, cheers.

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


Re: Crypto and export laws

2009-09-25 Thread Piet van Oostrum
> "M.-A. Lemburg"  (M-L) wrote:

>M-L> Depending on how close a country follows the Wassenaar
>M-L> Arrangement (http://www.wassenaar.org/) OpenSSL, Python
>M-L> and all other open-source software falls under the
>M-L> GENERAL SOFTWARE NOTE part 2.:

>M-L> """
>M-L> The Lists do not control "software" which is either:
>M-L> 1. ...
>M-L> 2. "In the public domain".
>M-L> """

>M-L> If you're shipping a closed-source product that includes
>M-L> OpenSSL, then you'd have to follow the rules in category 5
>M-L> part 2 of the dual-use list:

>M-L> http://www.wassenaar.org/publicdocuments/index_CL.html

But Python is not in the public domain. Open source != public domain.
Public domain means there is no copyright and no license attached to it,
AFAIK. 
-- 
Piet van Oostrum 
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: [email protected]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PExpect on Windows System Using Cygwin

2009-09-25 Thread Kevin Holleran
On Fri, Sep 25, 2009 at 6:09 AM, Dave Angel  wrote:

> Sean DiZazzo wrote:
>
>> On Sep 24, 4:37 pm, Dave Angel  wrote:
>>
>>
>>> 


>>> Why not just use the subprocess module?   It's built into the Windows
>>> distribution, and doesn't need cygwin.
>>>
>>> DaveA
>>>
>>>
>>
>> Can subprocess pass things like passwords to running processes like
>> pexpect can?
>>
>> ~Sean
>>
>>
>>
> I don't know what pexpect is/was capable of, since it's not apparently part
> of the current Python distributions.  I thought it had the ability to fork
> or spawn a child process, with pipes connected.
>
> Anyway, subprocess can launch a new process, with pipes optionally
> connected back to your code.  I don't think it can attach to an
> already-running process.
>
> There are things in pywin32 that might help (even for controlling GUI
> programs), but I suspect there'd be a big learning curve.  And of course
> it'd then be very Windows-dependent.
>
> pywin32 - http://python.net/crew/skippy/win32/Downloads.html
> or get it as part of the ActiveState python distro.
> http://www.activestate.com/activepython/
>
>
> DaveA
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Thanks for the suggestions.  My script is already written and works great
with PExpect as long as I run it in my cygwin environment.  My question I
think is better suited to a cygwin list actually as I am hoping that I can
simply move the appropriate .dll's up to the server without actually
installing cygwin on the server.

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


Format string with single quotes in it

2009-09-25 Thread Bahadir
Hi there,

My question is simple, but I've been spending some hours over the web
and still struggling to get this right: How do I format a string that
contains single quotes in it?

I am reading a file with lines of the form:

CONT%d_VIRTMEM_REGIONS  'Container %d number of virtual regions'

and trying to format this as follows:

str % (0, 0)

I get the error:

ValueError: unsupported format character '
' (0xa) at index 5541

I also tried:

# Replace single quotes with \'
str = str.replace("'", "\'")

and doubling the backward slash as well.

What am I doing wrong?

Thank you,

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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Ben Finney
Olof Bjarnason  writes:

>   - any geeks visiting my blog that are non-Ubuntu (i'll just provide
> the source code and tell them to apt-get python-pygame)

Note that for several years now the recommended command-line tool for
package installation is not ‘apt-get’, but ‘aptitude’ [0]. Compatible
command-line interface, uses the same back-end library and package
system, but many improvements in behaviour; especially the distinction
between manually-requested packages versus automatically-installed
packages that can be later removed when they're no longer needed.

[0] 
http://www.debian.org/doc/manuals/reference/ch02.en.html#_basic_package_management_operations>

-- 
 \“The problem with television is that the people must sit and |
  `\keep their eyes glued on a screen: the average American family |
_o__) hasn't time for it.” —_The New York Times_, 1939 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crypto and export laws

2009-09-25 Thread Mel
Piet van Oostrum wrote:

>> "M.-A. Lemburg"  (M-L) wrote:
[ ... ]
>>M-L> """
>>M-L> The Lists do not control "software" which is either:
>>M-L> 1. ...
>>M-L> 2. "In the public domain".
>>M-L> """
[ ... ]
> But Python is not in the public domain. Open source != public domain.
> Public domain means there is no copyright and no license attached to it,
> AFAIK.

I believe that "public domain" has different meanings in copyright law and 
in crypto law.  In crypto law I think it means "generally available", in 
that it's silly to impose import or export restrictions on something that's 
already obtainable everywhere.

Mel.


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


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Olof Bjarnason
2009/9/25 Ben Finney :
> Olof Bjarnason  writes:
>
>>   - any geeks visiting my blog that are non-Ubuntu (i'll just provide
>> the source code and tell them to apt-get python-pygame)
>
> Note that for several years now the recommended command-line tool for
> package installation is not ‘apt-get’, but ‘aptitude’ [0]. Compatible
> command-line interface, uses the same back-end library and package
> system, but many improvements in behaviour; especially the distinction
> between manually-requested packages versus automatically-installed
> packages that can be later removed when they're no longer needed.

Great thanks for this info. I just tried running it on a vanilla
Ubuntu system, and it is there.

Most tutorials on the web still (I've read mostly Ubuntu-related
forums) mention apt-get; seems like an error?

>
> [0] 
> http://www.debian.org/doc/manuals/reference/ch02.en.html#_basic_package_management_operations>
>
> --
>  \        “The problem with television is that the people must sit and |
>  `\    keep their eyes glued on a screen: the average American family |
> _o__)                 hasn't time for it.” —_The New York Times_, 1939 |
> Ben Finney
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
twitter.com/olofb
olofb.wordpress.com
olofb.wordpress.com/tag/english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Format string with single quotes in it

2009-09-25 Thread Xavier Ho
On Fri, Sep 25, 2009 at 10:42 PM, Bahadir  wrote:

> Hi there,
>
> My question is simple, but I've been spending some hours over the web
> and still struggling to get this right: How do I format a string that
> contains single quotes in it?
>

I don't know what you're doing wrong, but I've tried both Python 2.6.2 and
3.1.1, and the following worked perfectly for me:

>>> a = "Mrra%d 'Mrraa!!%d'"
>>> a %(1,2)
"Mrra1 'Mrraa!!2'"

Maybe if you share a snippet of the code, or do more actual testing that
might help?

Good luck,
Xav
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Format string with single quotes in it

2009-09-25 Thread Mark Tolonen


"Bahadir"  wrote in message 
news:65b6ce03-62c7-4e56-a746-d85ce87ad...@l31g2000vbp.googlegroups.com...

Hi there,

My question is simple, but I've been spending some hours over the web
and still struggling to get this right: How do I format a string that
contains single quotes in it?

I am reading a file with lines of the form:

CONT%d_VIRTMEM_REGIONS  'Container %d number of virtual regions'

and trying to format this as follows:

str % (0, 0)

I get the error:

ValueError: unsupported format character '
' (0xa) at index 5541

I also tried:

# Replace single quotes with \'
str = str.replace("'", "\'")

and doubling the backward slash as well.

What am I doing wrong?


A short, working example that exhibits the problem would be helpful, but I 
suspect you have a line in your file that ends in a %.  The code below 
produces the same error.


   s = "Here's a percentage: %d%\n"
   print s % (0,0)

OUTPUT:

   Traceback (most recent call last):
 File 
"C:\dev\python\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", 
line 436, in ImportFile

   my_reload(sys.modules[modName])
 File "w.py", line 2, in 
   print s % (0,0)
   ValueError: unsupported format character '
   ' (0xa) at index 24

Inspect your input file.  If you want a percent sign in a format string, use 
%%.


   s = "Here's percentages: %d%% %d%%\n"
   print s % (0,0)

OUTPUT:

   Here's percentages: 0% 0%

-Mark


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


IDE for python similar to visual basic

2009-09-25 Thread Threader Slash
> -- Forwarded message --
> From: J Sisson 
> To: Nobody 
> Date: Thu, 24 Sep 2009 19:18:03 -0500
> Subject: Re: IDE for python similar to visual basic
>
>
> On Sun, Sep 13, 2009 at 6:25 AM, Nobody  wrote:
>
>> On Fri, 11 Sep 2009 05:27:59 -0700, r wrote:
>>
>
>
>>  > Sounds like "somebody" failed to get input
>> > from their users at design time. Or "somebody" has the inability to
>> > relate to their end users.
>>
>> You're assuming that there is some "right" answer which is appropriate for
>> all users. There isn't.
>>
>
> I worked for a company that had a team composed of graphic artists, QA
> types, etc...that did nothing but draw up GUI's, show them to customers,
> revise them, write up runnable "dummies" of the approved GUI's, performed
> usability studies with our customers using the dummy GUI's, and finally
> handed the GUI's over to dev so they could put in the guts to make it "do
> stuff".
>
> "Bugs" or "Cases" involving the GUI needing revision because a button
> needed to be moved for usability were *extremely* rare, and the GUI didn't
> require an additional toolset that allowed end users to tweak them.
>
>
 My favorite IDE : Eclipse

http://pydev.org/download.html

http://www.ibm.com/developerworks/opensource/library/os-eclipse-visualstudio

http://www.eclipse.org

Of course you have also the Mono:
http://monodevelop.com

Cheers.|:0),
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Format string with single quotes in it

2009-09-25 Thread Jon Clements
On 25 Sep, 13:42, Bahadir  wrote:
> Hi there,
>
> My question is simple, but I've been spending some hours over the web
> and still struggling to get this right: How do I format a string that
> contains single quotes in it?
>
> I am reading a file with lines of the form:
>
> CONT%d_VIRTMEM_REGIONS  'Container %d number of virtual regions'
>
> and trying to format this as follows:
>
> str % (0, 0)


Don't call variables 'str' as it'll mask the builtin string type.

>
> I get the error:
>
> ValueError: unsupported format character '
> ' (0xa) at index 5541
>

Index 5541!? I would guess the lines in the file aren't quite what you
think. The message you're receiving suggests you've got a % character,
followed by a linefeed character -- are you opening the file in text
mode, if not, do so... and if your file has mixed newline sequences,
try using the universal newline option: infile = open
('filename','rU').

> I also tried:
>
> # Replace single quotes with \'
> str = str.replace("'", "\'")
>
> and doubling the backward slash as well.

None of that is needed AFAICT.

>
> What am I doing wrong?
>
> Thank you,
>
> Bahadir

In summary:

j...@jon-desktop:~$ cat test.txt
line 1 SOMELINE%d and some value of %d
line 2 SOMELINE%d and some value of %d
line 3 SOMELINE%d and some value of %d
line 4 SOMELINE%d and some value of %d

j...@jon-desktop:~$ cat test.py
for line in open('test.txt'):
print line.rstrip('\n') % (0, 0)

j...@jon-desktop:~$ python test.py
line 1 SOMELINE0 and some value of 0
line 2 SOMELINE0 and some value of 0
line 3 SOMELINE0 and some value of 0
line 4 SOMELINE0 and some value of 0


hth,
Jon.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Ben Finney
Olof Bjarnason  writes:

> Most tutorials on the web still (I've read mostly Ubuntu-related
> forums) mention apt-get; seems like an error?

Not quite an error (since ‘apt-get’ continues to work), just habit of
old-timers, and cargo-cult administration by newcomers.

-- 
 \“Science doesn't work by vote and it doesn't work by |
  `\authority.” —Richard Dawkins, _Big Mistake_ (The Guardian, |
_o__)  2006-12-27) |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Poll: Do you use csv.Sniffer?

2009-09-25 Thread nn
On Sep 24, 10:26 pm, [email protected] wrote:
> If you are a csv module user, I have a question for you:  Do you use the
> csv.Sniffer class?
>
>     o Yes, frequently
>     o Yes, on occasion
>     o I tried it a few times but don't use it now
>     o No, I don't need it
>     o No, never heard of it
>     o No (some other reason)
>
> If you don't use it, how do you figure out the structure of your csv files?
>
>     o I just know
>     o I stumble around in the dark trying different parameters until the csv
>       reader starts to spit out useful data
>
> If csv.Sniff was to be removed from a future version of Python, how
> difficult would it be to adapt?
>
>     o No problem
>     o No problem as long as you make it available via PyPI
>     o It would be a problem
>
> If it would be a problem for you (which would not easily be solved by adding
> it to PyPI), feel free to describe why it would be a challenge for you.  In
> fact, please feel free to add any other comments you like to your response.
>
> Private replies please.
>
> Thanks,
>
> --
> Skip Montanaro - [email protected] -http://www.smontanaro.net/
>     Getting old sucks, but it beats dying young

Do you use the csv.Sniffer class? No. Don't use it right now.

how do you figure out the structure of your csv files? "head -2
filename" + visual inspection + guesswork

If csv.Sniff was to be removed from a future version of Python, how
difficult would it be to adapt? No problem.

It would still be nice if the code was available somewhere on the net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python-programs to Ubuntu users

2009-09-25 Thread Paul Rudin
Ben Finney  writes:

> Olof Bjarnason  writes:
>
>> Most tutorials on the web still (I've read mostly Ubuntu-related
>> forums) mention apt-get; seems like an error?
>
> Not quite an error (since ‘apt-get’ continues to work), just habit of
> old-timers, and cargo-cult administration by newcomers.

It also appears that the installed software advises it, e.g.: 

p...@sleeper-service:~$ sbcl
The program 'sbcl' is currently not installed.  You can install it by typing:
sudo apt-get install sbcl
bash: sbcl: command not found
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Intercepting binding?

2009-09-25 Thread Carl Banks
On Sep 24, 5:39 am, andrew cooke  wrote:
> It's significant, depressing, and not at all surprising that every
> person who replied to this thread told me, in one way or another, that
> was I was asking was wrong or impossible or foolhardy.

People on this list are volunteers, who have no obligation to help.

If you want always friendly, enabling advice I'm sure there are good
support services out there who would be happy not to second-guess you
for a fee.

Otherwise, grow thicker skin.


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


ANN: Albow 2.1

2009-09-25 Thread Greg Ewing

ALBOW - A Little Bit of Widgetry for PyGame

Version 2.1 is now available.

  http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/

Highlights of this version:

  * OpenGL faciliites
  * Music facilities
  * Drop-down menus and menu bars

What is Albow?

Albow is a library for creating GUIs using PyGame that I have been
developing over the course of several PyWeek competitions. I am documenting
and releasing it as a separate package so that others may benefit from it,
and so that it will be permissible for use in future PyGame entries.

The download includes HTML documentation and some example programs
demonstrating most of the library's features. You can also see some
screenshots and browse the documentation on-line.

--
Gregory Ewing
[email protected]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Crypto and export laws

2009-09-25 Thread Piet van Oostrum
> Ben Finney  (BF) wrote:

>BF> Piet van Oostrum  writes:
>>> But Python is not in the public domain. Open source != public domain.

>BF> One always needs to be aware of what bizarro-world definitions these
>BF> legalese documents are using for terms we might normally understand.
>BF> However, in this case it seems fairly sane and :

>BF> GTN "In the public domain"

>BF> GSN This means "technology" or "software" which has been made
>BF> available

>BF> ML 22 without restrictions upon its further dissemination.

>BF> 
>http://74.125.153.132/search?q=cache:t8kUZpvsUncJ:www.wassenaar.org/controllists/2008/WA-LIST%2520(08)%25201/16%2520-%2520WA-LIST%2520(08)%25201%2520-%2520DEF.doc+%22definitions+of+terms+used+in+these+lists%22&cd=1&hl=en&ct=clnk&ie=UTF-8>

Yes, I found that a few minutes ago, in between my cooking preparations
:=)

>>> Public domain means there is no copyright and no license attached to
>>> it, AFAIK.

>BF> More accurately, it generally refers to a work with no copyright holder
>BF> and hence no license *needed* by anyone to perform acts normally
>BF> reserved to a copyright holder.

>BF> So free software still held under copyright is not “in the public
>BF> domain” by the above definition.


>BF> In any case, the part that seems to apply clearly to Python is this one:

>BF> GENERAL SOFTWARE NOTE 

>BF> The Lists do not control "software" which is either: 

>BF>   1. Generally available to the public by being: 

>BF>   a. Sold from stock at retail selling points without restriction,
>BF>   by means of:

>BF>  1. Over-the-counter transactions;

>BF>  2. Mail order transactions;

>BF>  3. Electronic transactions; or

>BF>  4. Telephone call transactions; and 

>BF>   b. Designed for installation by the user without further
>BF>   substantial support by the supplier;

>BF> 
>http://74.125.153.132/search?q=cache:oUPbVxp4coMJ:www.wassenaar.org/controllists/2008/WA-LIST%2520(08)%25201/02%2520-%2520WA-LIST%2520(08)%25201%2520-%2520GTN%2520and%2520GSN.doc+general+note+software&cd=1&hl=en&ct=clnk&ie=UTF-8>

>BF> Python is certainly generally available, by being sold as described
>BF> above (as well as other means), and with no further substantial support
>BF> from the supplier.

BUT: then it continues to state that the above does not apply to
cryptographic software. At least that's how I interpret the following
sentence:

Note Entry 1 of the General Software Note does not release
"software" controlled by Category 5 - Part 2 ("Information
Security").

except that Category 5 - Part 2 makes some exceptions.

>BF> So AFAICT, the Wassenaar Arrangement on export controls explicitly
>BF> excludes Python (and most widely-sold free software) by the “generally
>BF> available to the public by being sold from stock at retail” definition.

I had heard of the WA before (if only because I live in the same
country) but never looked into it. So does this mean that the export of
crypto software (with the exceptions above) is not allowed from European
countries either? I.e. that we in Europe have been infected with these
stupid USA export laws, maybe in a milder form?
-- 
Piet van Oostrum 
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: [email protected]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Crypto and export laws

2009-09-25 Thread Ben Finney
Piet van Oostrum  writes:

> But Python is not in the public domain. Open source != public domain.

One always needs to be aware of what bizarro-world definitions these
legalese documents are using for terms we might normally understand.
However, in this case it seems fairly sane and :

GTN "In the public domain"

GSN This means "technology" or "software" which has been made
available

ML 22 without restrictions upon its further dissemination.


http://74.125.153.132/search?q=cache:t8kUZpvsUncJ:www.wassenaar.org/controllists/2008/WA-LIST%2520(08)%25201/16%2520-%2520WA-LIST%2520(08)%25201%2520-%2520DEF.doc+%22definitions+of+terms+used+in+these+lists%22&cd=1&hl=en&ct=clnk&ie=UTF-8>

> Public domain means there is no copyright and no license attached to
> it, AFAIK.

More accurately, it generally refers to a work with no copyright holder
and hence no license *needed* by anyone to perform acts normally
reserved to a copyright holder.

So free software still held under copyright is not “in the public
domain” by the above definition.


In any case, the part that seems to apply clearly to Python is this one:

GENERAL SOFTWARE NOTE 

The Lists do not control "software" which is either: 

  1. Generally available to the public by being: 

  a. Sold from stock at retail selling points without restriction,
  by means of:

 1. Over-the-counter transactions;

 2. Mail order transactions;

 3. Electronic transactions; or

 4. Telephone call transactions; and 

  b. Designed for installation by the user without further
  substantial support by the supplier;


http://74.125.153.132/search?q=cache:oUPbVxp4coMJ:www.wassenaar.org/controllists/2008/WA-LIST%2520(08)%25201/02%2520-%2520WA-LIST%2520(08)%25201%2520-%2520GTN%2520and%2520GSN.doc+general+note+software&cd=1&hl=en&ct=clnk&ie=UTF-8>

Python is certainly generally available, by being sold as described
above (as well as other means), and with no further substantial support
from the supplier.

So AFAICT, the Wassenaar Arrangement on export controls explicitly
excludes Python (and most widely-sold free software) by the “generally
available to the public by being sold from stock at retail” definition.

-- 
 \ “What you have become is the price you paid to get what you |
  `\ used to want.” —Mignon McLaughlin |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Twisted PB: returning result as soon as ready

2009-09-25 Thread jacopo
In the following chunk of code the CLIENT receives both the results
from “compute” at the same time (i.e. when the second one has
finished). This way it cannot start “elaborateResult” on the first
result while the SERVER is still running the second “compute”.
How could I get the first result as soon as ready and therefore
parallelize things?
thanks, Jacopo

SERVER:

fibo=Fibonacci()
fact=pb.PBServerFactory(fibo)
reactor.listenTCP(port,  fact)
reactor.run()

CLIENT:

fact=pb.PBClientFactory()
reactor.connectTCP(host, port,   fact)
d=fact.getRootObject()
n1=1
d.addCallback(lambda obj: obj.callRemote("compute", n1))
d.addCallback(elaborateResult)

d2=fact.getRootObject()
n2=1
d2.addCallback(lambda obj: obj.callRemote("compute",  n2))
d2.addCallback(elaborateResult)

reactor.run()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most "active" coroutine library project?

2009-09-25 Thread Grant Edwards
On 2009-09-25, Hendrik van Rooyen  wrote:
> On Thursday, 24 September 2009 15:42:36 Antoine Pitrou wrote:
>> Grant Edwards  invalid.invalid> writes:
>> > Back when I worked on one of the first hand-held cellular
>> > mobile phones, it used co-routines where the number of
>> > coroutines was fixed at 2 (one for each register set in a Z80
>> > CPU).
>>
>> Gotta love the lightning-fast EXX instruction. :-)
>
> Using it in the above context is about equivalent to slipping
> a hand grenade in amongst the other eggs in a nest.

EXX accomplised much of the context switch operation.  I don't
remember how much RAM was available, but it wasn't much...

-- 
Grant Edwards   grante Yow! And furthermore,
  at   my bowling average is
   visi.comunimpeachable!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


is this whiff/wsgi claim true?

2009-09-25 Thread Aaron Watters
Hi folks.  I just modified the WHIFF concepts index page

http://aaron.oirt.rutgers.edu/myapp/docs/W1000.concepts

To include the following paragraph with a startling and arrogant
claim in the final sentence :)

"""
Developers build WHIFF applications much like they build
static web content, PHP applications, JSP pages, or ASP
pages among others -- the developer "drops" files into a
directory, and the files are automatically used to respond
to URLs related to the filename.
**This intuitive and ubiquitous approach to organizing
web components is not automatically supported by other
WSGI infrastructures.**
"""

[I go on to illustrate the concept with examples...]

Is the final sentence true?  Are there other WSGI approach
which make deploying a dynamic page as easy as putting
an HTML file in a static directory?  If I'm lying I'd like to
correct the statement and my knowledge of what else is out
there is faulty and incomplete, so please correct me.

Thanks,  -- Aaron Watters

===

less is more
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >