Re: Looking for tips and gotchas for working with Python 3.5 zipapp feature

2019-07-01 Thread Simon
> The other main limitation (not so much a gotcha as a consequence of
> how the OS works) is that you can't load C extensions (pyd or so
> files) from a zipfile. If you need to do that, you'll have to bundle
> the C extensions to work around that limitation, but that's pretty
> advanced usage.
> 

Very interesting post (and one of the only ones on the internet about that... 
that is why I am posting here even though the thread is quite old).

I am exactly in the "pretty advanced usage": I want to create a zip that embed 
numpy. In this case, I have to bundle the C extension. How can I do that?

Thx,
Simon 
-- 
https://mail.python.org/mailman/listinfo/python-list


__getitem__ on new-style classes

2005-03-10 Thread simon
What i'm trying to do is tie special methods of a "proxy" instance
to another instance:

def test1():
  class Container:
def __init__( self, data ):
  self.data = data
  self.__getitem__ = self.data.__getitem__

  data = range(10)
  c = Container(data)
  print "test1"
  print c[3]

This works OK. But when I try the same thing on
new style classes:

def test2():
  print "test2"
  class Container(object):
def __init__( self, data ):
  self.data = data
#  self.__dict__["__getitem__"] = self.data.__getitem__
  self.__setattr__( "__getitem__", self.data.__getitem__ )
  data = range(10)
  c = Container(data)
  print
  print c.__getitem__(3) # works OK
  print c[3] # fails

I get a "TypeError: unindexable object". It
seems that c[] does not call __getitem__ in this case.

The plot thickens, however, when one tries the following:

def test3():
  data = range(10)
  c = type( "Container", (), { "__getitem__":data.__getitem__ } )()
  print "test3"
  print c[3]

Which works fine. However, if I need to resort to
such trickery, no-one here where i work will have any idea
what it does :)

Would anyone like to shed some light on what is going on here ?

bye,

Simon.

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


Re: Set literals

2005-03-21 Thread simon
+1 from me.

The other possible meaning for {1,2,3} would be {1:None,2:None,3:None},
but that is usually meant to be a set anyway (done with a dict).

So what is this: {1:2, 3, 4 } (apart from "nearly useless") ?

hmmm, thinking a bit more about this, it seems
you can build a set from a dict's keys, but not the other
way around. Is this odd, or what ?

>>> a = set({1:0,2:0,3:0})
>>> a
set([1, 2, 3])
>>>
>>> dict(a)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: cannot convert dictionary update sequence element #0 to a
sequence

Simon.

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


how to create an external string when binding C to Python?

2014-05-08 Thread Simon
I'd like to make a C memory buffer available inside Python via the Python C/API 
without copying that memory into Python. How to do this? I've read [1] but it's 
not clear that this functionality exists. In javascript it's possible using 
String::NewExternal() [2].

"Creates a new external string using the ASCII data defined in the given 
resource.

When the external string is no longer live on V8's heap the resource will be 
disposed by calling its Dispose method. The caller of this function should not 
otherwise delete or modify the resource. Neither should the underlying buffer 
be deallocated or modified except through the destructor of the external string 
resource."

[1] https://docs.python.org/2/c-api/buffer.html
[2] 
http://izs.me/v8-docs/classv8_1_1String.html#a07c47bf675b802c550984fa24511a589
-- 
https://mail.python.org/mailman/listinfo/python-list


how to create a zero copy external string when binding C to Python?

2014-05-08 Thread Simon
I'd like to make a C memory buffer available inside Python via the Python C/API 
without copying that memory into Python. How to do this? I've read [1] but it's 
not clear that this functionality exists. In javascript it's possible using 
String::NewExternal() [2].

"Creates a new external string using the ASCII data defined in the given 
resource.

When the external string is no longer live on V8's heap the resource will be 
disposed by calling its Dispose method. The caller of this function should not 
otherwise delete or modify the resource. Neither should the underlying buffer 
be deallocated or modified except through the destructor of the external string 
resource."

[1] https://docs.python.org/2/c-api/buffer.html
[2] 
http://izs.me/v8-docs/classv8_1_1String.html#a07c47bf675b802c550984fa24511a589
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: per instance descriptors

2006-12-07 Thread simon

George Sakkis wrote:
> Simon Bunker wrote:
>
> > Hi I have code similar to this:
> >
> > class Input(object):
> >
> >  def __init__(self, val):
> >  self.value = val
> >
> >  def __get__(self, obj, objtype):
> >  return self.value
> >
> >  def __set__(self, obj, val):
> >  # do some checking... only accept floats etc
> >  self.value = val
> >
> > class Node(object):
> >
> > a = Input(1)
> > b = Input(2)
> >
> > I realise that a and b are now class attributes - however I want to do this:
> >
> > node1 = Node()
> > node2 = Node()
> >
> > node1.a = 3
> > node.b = 4
> >
> > And have them keep these values per instance. However now node1.a is 4
> > when it should be 3.
> >
> > Basically I want to have the Input class as a gateway that does lots of
> > checking when the attibute is assigned or read.
> >
> > I have had a look at __getattribute__(), but this gets very ugly as I
> > have to check if the attribute is an Input class or not.
> >
> > Also I don't think property() is appropriate is it? All of the
> > attributes will essentially be doing the same thing - they should not
> > have individual set/get commands.
> >
> > Is there any way of doing this nicely in Python?
>
> What about __setattr__ ? At least from your example, checking happens
> only when you set an attribute. If not, post a more representative
> sample of what you're trying to do.
>
> George

Yes, but I am setting it in the Node class aren't I? Wouldn't I need to
define __setattr__() in class Node rather than class Input? I don't
want to do this. Or am I getting confused here?

thanks

Simon

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


epydoc and latex math

2005-05-01 Thread simon
Hi,

We have a requirement for latex math (eg. $\sum_i x_i$) in our
documentation,
and i'm looking at patching epydoc to handle this. We have been using
the python doc system
(also used by numarray), with a script to rip docstrings into the
required latex.
However, this method is getting out of hand, and epydoc looks like a
great replacement tool.

I see nltk and twisted use epydoc, but the project itself seems to be
quiet at the moment.

Also, I have been subscribed to doc-sig for a while now, but I am
utterly confused
as to what they are up to.

bye,

Simon.


--
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com

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


python unix install, sqlite3

2007-05-29 Thread Simon
I installed the source code on unix for python 2.5.1. The install went
mainly okay, except for some failures regarding:
_ssl, _hashlib, _curses, _curses_panel.

No errors regarding sqlite3.
However, when I start python and do an import sqlite3 I get:

/ptmp/bin/> python
Python 2.5.1 (r251:54863, May 29 2007, 05:19:30)
[GCC 3.3.2] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "", line 1, in 
  File "/ptmp/Python-2.5.1/lib/python2.5/sqlite3/__init__.py", line
24, in 
from dbapi2 import *
  File "/ptmp/Python-2.5.1/lib/python2.5/sqlite3/dbapi2.py", line 27,
in 
from _sqlite3 import *
ImportError: No module named _sqlite3

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


Re: python unix install, sqlite3

2007-05-29 Thread Simon
On May 29, 7:05 am, vasudevram <[EMAIL PROTECTED]> wrote:
> On May 29, 5:52 pm, Simon <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > I installed the source code on unix for python 2.5.1. The install went
> > mainly okay, except for some failures regarding:
> > _ssl, _hashlib, _curses, _curses_panel.
>
> > No errors regarding sqlite3.
> > However, when I start python and do an import sqlite3 I get:
>
> > /ptmp/bin/> python
> > Python 2.5.1 (r251:54863, May 29 2007, 05:19:30)
> > [GCC 3.3.2] on sunos5
> > Type "help", "copyright", "credits" or "license" for more information.>>> 
> > import sqlite3
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/ptmp/Python-2.5.1/lib/python2.5/sqlite3/__init__.py", line
> > 24, in 
> > from dbapi2 import *
> >   File "/ptmp/Python-2.5.1/lib/python2.5/sqlite3/dbapi2.py", line 27,
> > in 
> > from _sqlite3 import *
> > ImportError: No module named _sqlite3
>
> Some ideas:
>
> I don't know if sqlite3 comes bundled with the standard Python source
> bundle. My guess is not. If not, that's the cause of the error - you
> need to install sqlite3 (and probably pysqlite3 (not sure of the name
> (whether it has a trailing 3) which, if I remember, is the Python
> binding/wrapper for sqlite3 (which is a C library, I think). Other
> possible cause of the error (if sqlite3 _is_ bundled with Python and
> no Python binding/wrapper is needed, is that sqlite3 depends on one of
> those other libraries you mention (such as _hashlib) for which you got
> errors while installing Python from source.
>
> HTH
> Vasudev Ram
> Dancing Bison Enterpriseswww.dancingbison.com- Hide quoted text -
>
> - Show quoted text -

Vasudev,
  Thanks so much for the reply. I went to their website and your guess
was correct. Python 2.5 has included support for sqlite but it only
includes the PySqlite interface module (now called sqlite3). It does
not include sqlite3 with the source distribution.

Simon

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


Re: HIRING: PHP Developer

2006-03-27 Thread Simon
>I apologize.  Google groups has restricted our contact email.  To reach
> us, please send your quote to hiringdivision @ gmail.com.
>
> Thank you.

Apologize to whom?  Who/What are you replying to?

Please note that we don't all use Google groups format your replies 
properly.

Simon

-- 
http://urlkick.com/
Free URL redirection service. Turns a long URL into a much shorter one. 


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


Re: HIRING: PHP Developer

2006-04-05 Thread Simon


-- 
http://urlkick.com/
Free URL redirection service. Turns a long URL into a much shorter one.
"Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> In article <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED] wrote:
>
>>We are hiring a PHP developer!
>
> <http://groups.google.com/[EMAIL PROTECTED]
> .co.nz>

Or http://urlkick.com/51 :)

Simon 


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


Wrapping paper, anyone ?

2009-12-15 Thread simon
#!/usr/bin/env python

from math import *

from random import *

import cairo
from cairo import Context

Black = (0, 0, 0)
White = (1, 1, 1)

def rand():
return random()*2 - 1

def rotate(theta, x, y):
x, y = x*cos(theta)-y*sin(theta), x*sin(theta)+y*cos(theta)
return x, y

def star(ctx, n=5, r0=0.4):

for c in range(2):
ctx.set_source_rgba(*(White, Black)[c])
x, y = 0, 1
ctx.move_to(x, y)
theta = 2*pi / n
for i in range(n):
x1, y1 = rotate(theta/2, x, y)
ctx.line_to(r0*x1, r0*y1)
x, y = rotate(theta/2, x1, y1)
ctx.line_to(x, y)
ctx.close_path()
(ctx.fill, ctx.stroke)[c]()


class ScribeCall(object):
def __init__(self, scribe, name):
self.scribe = scribe
self.name = name

def __call__(self, *args, **kw):
self.args = args
self.kw = kw
self.scribe.calls.append(self)


class Scribe(object):
def __init__(self):
self.calls = []

__getattr__ = ScribeCall
def run(self, ctx):
for call in self.calls:
#print "ctx.%s(%s)" % (call.name, ', '.join(str(x) for x
in call.args))
getattr(ctx, call.name)(*call.args, **call.kw)


def orbit(dx, dy, w, h):
x = -2*w
while x < 2*w:
y = -2*h
while y < 2*h:
yield x, y
y += dy
x += dx


def main_stars(w=800, h=1000):

seed(0)

surface = cairo.PSSurface('stars.ps', w, h)
ctx = Context(surface)

ctx.set_source_rgba(*White)
ctx.rectangle(0, 0, w, h)
ctx.fill()

ctx.set_line_width(1./30)

scribe = Scribe()

for i in range(10):
scribe.save()

scribe.translate(w*random(), h*random())
scribe.scale(20, 20)
scribe.rotate(random() * 2 * pi)

r = exp(random())
scribe.scale(r, r)
star(scribe, 5)
scribe.scale(1./r, 1./r)

scribe.translate(rand(), rand())
scribe.restore()

for x, y in orbit(120, 240, w, h):
ctx.save()
ctx.translate(x, y)
scribe.run(ctx)
ctx.restore()


if __name__=="__main__":
main_stars()

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


Re: Wrapping paper, anyone ?

2009-12-16 Thread simon
On Dec 16, 9:00 pm, Peter Otten <__pete...@web.de> wrote:
> simon wrote:
>
> Nice :)
>
> --- stars.py    2009-12-16 10:52:49.553505036 +0100
> +++ stars_fixed.py      2009-12-16 10:53:32.545786454 +0100
> @@ -48,7 +48,9 @@
>      def __init__(self):
>          self.calls = []
>
> -    __getattr__ = ScribeCall
> +    def __getattr__(self, name):
> +        return ScribeCall(self, name)
> +
>      def run(self, ctx):
>          for call in self.calls:
>              #print "ctx.%s(%s)" % (call.name, ', '.join(str(x) for x in
> call.args))
>
> Peter

Oh.. I'm on py2.5.. does this not work for you ?

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


Re: Wrapping paper, anyone ?

2009-12-16 Thread simon
On Dec 17, 12:36 am, r0g  wrote:
> Peter Otten wrote:
> > simon wrote:
>
> > Nice :)
>
> > --- stars.py    2009-12-16 10:52:49.553505036 +0100
> > +++ stars_fixed.py      2009-12-16 10:53:32.545786454 +0100
> > @@ -48,7 +48,9 @@
> >      def __init__(self):
> >          self.calls = []
>
> > -    __getattr__ = ScribeCall
> > +    def __getattr__(self, name):
> > +        return ScribeCall(self, name)
> > +
> >      def run(self, ctx):
> >          for call in self.calls:
> >              #print "ctx.%s(%s)" % (call.name, ', '.join(str(x) for x in
> > call.args))
>
> > Peter
>
> Nice :) Now all I need is an A0 printer, maybe Santa will bring me one!
>
> Roger.

I found I could wrap a CD in A4 paper... for bigger things, i might
stick some A4 paper together.

Wow. Who is getting the A0 gift ?


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


Re: Wrapping paper, anyone ?

2009-12-16 Thread simon
On Dec 17, 2:18 am, Peter Otten <__pete...@web.de> wrote:
> simon wrote:
> > On Dec 16, 9:00 pm, Peter Otten <__pete...@web.de> wrote:
> >> simon wrote:
>
> >> Nice :)
>
> >> --- stars.py    2009-12-16 10:52:49.553505036 +0100
> >> +++ stars_fixed.py      2009-12-16 10:53:32.545786454 +0100
> >> @@ -48,7 +48,9 @@
> >> def __init__(self):
> >> self.calls = []
>
> >> -    __getattr__ = ScribeCall
> >> +    def __getattr__(self, name):
> >> +        return ScribeCall(self, name)
> >> +
> >> def run(self, ctx):
> >> for call in self.calls:
> >> #print "ctx.%s(%s)" % (call.name, ', '.join(str(x) for x in
> >> call.args))
>
> >> Peter
>
> > Oh.. I'm on py2.5.. does this not work for you ?
>
> You mean 2.4? Here's a little demo:
>
> $ cat scribecall.py
> class ScribeCall(object):
>     def __init__(self, scribe, name):
>         print "init", scribe, name
>     def __call__(self, *args, **kw):
>         print "call", args, kw
>
> class Scribe(object):
>     __getattr__ = ScribeCall
>
> if __name__ == "__main__":
>     scribe = Scribe()
>     scribe.yadda(42)
>
> $ python2.4 scribecall.py
> init <__main__.Scribe object at 0x7fc87b9a1450> yadda
> call (42,) {}
>
> $ python2.5 scribecall.py
> Traceback (most recent call last):
>   File "scribecall.py", line 12, in 
>     scribe.yadda(42)
> TypeError: __init__() takes exactly 3 arguments (2 given)
>
> $ python2.5 -V
> Python 2.5.4
>
> $ python2.6 scribecall.py
> Traceback (most recent call last):
>   File "scribecall.py", line 12, in 
>     scribe.yadda(42)
> TypeError: __init__() takes exactly 3 arguments (2 given)
>
> Peter

Oh wow, it works on python 2.5.2 !

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


Re: ftp and python

2010-04-08 Thread Simon
You could user FTP.voidcmd()
E.G.
ftp.voidcmd('RNFT filename.txt')ftp.voidcmd('RNTO newdir/filename.txt')
>From the rfc:

RENAME FROM (RNFR)

   This command specifies the old pathname of the file which is
   to be renamed.  This command must be immediately followed by
   a "rename to" command specifying the new file pathname.

RENAME TO (RNTO)

   This command specifies the new pathname of the file
   specified in the immediately preceding "rename from"
   command.  Together the two commands cause a file to be
   renamed.

P.S. Sorry about emailing that direct to you John :(


On 8 April 2010 07:24, John Nagle  wrote:

> Tim Chase wrote:
>
>> Matjaz Pfefferer wrote:
>>
>>> What would be the easiest way to copy files from one ftp
>>> folder to another without downloading them to local system?
>>>
>>
>> As best I can tell, this isn't well-supported by FTP[1] which doesn't seem
>> to have a native "copy this file from server-location to server-location
>> bypassing the client". There's a pair of RNFR/RNTO commands that allow you
>> to rename (or perhaps move as well) a file which ftplib.FTP.rename()
>> supports but it sounds like you want too copies.
>>
>
>   In theory, the FTP spec supports "three-way transfers", where the
> source, destination, and control can all be on different machines.
> But no modern implementation supports that.
>
>John Nagle
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Simon
Hay I got a better idea. If you put two dots (..) on a line by itself it
means
execute the previous line again!

On 1 May 2010 07:08, Patrick Maupin  wrote:

> On Apr 30, 11:04 am, Jabapyth  wrote:
> > At least a few times a day I wish python had the following shortcut
> > syntax:
> >
> > vbl.=func(args)
> >
> > this would be equivalent to
> >
> > vbl = vbl.func(args)
> >
> > example:
> >
> > foo = "Hello world"
> > foo.=split(" ")
> > print foo
> > # ['Hello', 'world']
> >
> > and I guess you could generalize this to
> >
> > vbl.=[some text]
> > #
> > vbl = vbl.[some text]
> >
> > e.g.
> >
> > temp.=children[0]
> > # temp = temp.children[0]
> >
> > thoughts?
>
> First thought:  good luck getting something like this through.
> Probably not going to happen, although I do find the idea very
> intriguing.
>
> Second thought:  I don't like the proposed syntax at all.
>
> +=, -=, /=, *=, etc.  conceptually (and, if lhs object supports in-
> place operator methods, actually) *modify* the lhs object.
>
> Your proposed .= syntax conceptually *replaces* the lhs object
> (actually, rebinds the lhs symbol to the new object).
>
> If this were to be deemed worthy of the language, I would think a
> better syntax would be something like:
>
>  mystring = .upper()
>  mystring = .replace('a', 'b')
>
> etc.
>
> The '=' shows clearly that mystring is being rebound to a new object.
>
> As Steven has shown, '.' functions as an operator, so if this change
> were accepted, in reality you would probably be able to write:
>
> mystring = . upper()
> mystring=.upper()
>
> or whatever.  But the canonical form would probably be with a space
> before the period but not after.
>
> Regards,
> Pat
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


install Python-2.4.4 from source (parallel to existing Python-2.6)

2009-06-12 Thread Simon

edexter wrote:

simon wrote:

Hi everybody,

The situation:
I wrote a GUI, based on Python, TkInter and Pmw.
It runs perfectly fine with Python 2.4 (providing, TkInter and Pmw are
installed). But it crashes with Python 2.6. I tried this on MacOSX11.4
and various Linux Distributions.
Crashes occurs when I activate a Pmw.Diaog (I guess this is due to a bug
in the installed blt package), also when I use setitems on
Pmw.OptionMenu (I guess this is due to another package, associated with
tcl/tk).

The target:
I have to get my GUI work under openSUSE 11.1 (x86_64).

My plan:
On my openSUSE 11.1 (x86_64), Python 2.6 is installed by default.
I would like to know, how to install Python 2.4 along with TkInter and
Pmw (and packages that are required by them), parallel to the existing
Python 2.6. So that I do not break other software that depends on Python
2.6.

If you can think of another plan, I would be also glad to discuss it.

Cheers,
Simon


I suspect you want to install python 2.4 and then reinstall 2.6  I did
that in windows and I don't understand why it wouldn't work in linux


I'm afraid, installation is quit different under UNIX based systems and 
Windows.


I installed Python-2.4.4.tar.bz2 from python.org, using gcc-4.3 (within 
openSUSE 11.1 x86_64) via 'make altinstall'.


First, I tried to configure with the following flags: 
--prefix=/opt/python-24 --enable-framework --with-pydebug
This provoked an error during compilation via make (sorry, the list was 
so long, but I will post it, if it helps).


Second, configured again without any flags. The installation by 'make 
altinstall' to /usr/local was a success. Python2.6 seams unaffected, 
too. So, I got my parallel installation.


However, I cannot import modules like Tkinter or readline within python2.4.

For example, Tkinter.py is located in /usr/local/lib/python2.4/lib-tk

sys.path says: ['', '/usr/local/lib/python24.zip', 
'/usr/local/lib/python2.4', '/usr/local/lib/python2.4/plat-linux2', 
'/usr/local/lib/python2.4/lib-tk', 
'/usr/local/lib/python2.4/lib-dynload', 
'/usr/local/lib/python2.4/site-packages']


sys.prefix and sys.exec_prefix say: '/usr/local'

my bash's PATH variable says: 
/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin


Which configuration step did I miss after my Python2.4 installation? 
What did I do wrong?


Cheers,
Simon
--
http://mail.python.org/mailman/listinfo/python-list


Re: install Python-2.4.4 from source (parallel to existing Python-2.6)

2009-06-12 Thread Simon

Simon wrote:

edexter wrote:

simon wrote:

Hi everybody,

The situation:
I wrote a GUI, based on Python, TkInter and Pmw.
It runs perfectly fine with Python 2.4 (providing, TkInter and Pmw are
installed). But it crashes with Python 2.6. I tried this on MacOSX11.4
and various Linux Distributions.
Crashes occurs when I activate a Pmw.Diaog (I guess this is due to a bug
in the installed blt package), also when I use setitems on
Pmw.OptionMenu (I guess this is due to another package, associated with
tcl/tk).

The target:
I have to get my GUI work under openSUSE 11.1 (x86_64).

My plan:
On my openSUSE 11.1 (x86_64), Python 2.6 is installed by default.
I would like to know, how to install Python 2.4 along with TkInter and
Pmw (and packages that are required by them), parallel to the existing
Python 2.6. So that I do not break other software that depends on Python
2.6.

If you can think of another plan, I would be also glad to discuss it.

Cheers,
Simon


I suspect you want to install python 2.4 and then reinstall 2.6  I did
that in windows and I don't understand why it wouldn't work in linux


I'm afraid, installation is quit different under UNIX based systems and 
Windows.


I installed Python-2.4.4.tar.bz2 from python.org, using gcc-4.3 (within 
openSUSE 11.1 x86_64) via 'make altinstall'.


First, I tried to configure with the following flags: 
--prefix=/opt/python-24 --enable-framework --with-pydebug
This provoked an error during compilation via make (sorry, the list was 
so long, but I will post it, if it helps).


Second, configured again without any flags. The installation by 'make 
altinstall' to /usr/local was a success. Python2.6 seams unaffected, 
too. So, I got my parallel installation.


However, I cannot import modules like Tkinter or readline within python2.4.

For example, Tkinter.py is located in /usr/local/lib/python2.4/lib-tk

sys.path says: ['', '/usr/local/lib/python24.zip', 
'/usr/local/lib/python2.4', '/usr/local/lib/python2.4/plat-linux2', 
'/usr/local/lib/python2.4/lib-tk', 
'/usr/local/lib/python2.4/lib-dynload', 
'/usr/local/lib/python2.4/site-packages']


sys.prefix and sys.exec_prefix say: '/usr/local'

my bash's PATH variable says: 
/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin 



Which configuration step did I miss after my Python2.4 installation? 
What did I do wrong?


Cheers,
Simon


OK, I found an 'Ansatzpunkt' where I can start from:
_tkinter.so is missing in /usr/local/lib/python2.4/lib-dynload
so I guess my python is not configured for using Tcl?

I found the following from 
http://mail.python.org/pipermail/python-list/2001-December/117984.html


Install Tcl, Tk and Python as peers of each other ...
1. run configure in Python
2. make and make install Tcl  (unless you're using binary dist)make and
3. make install Tk   (unless you're using binary dist)
4. edit Setup
5. make and make install Python

I guess, I will try that next. Maybe somebody knows a more detailed 
instruction. My problems:


a)
I don't know if I have to set special flags to make the three packages 
aware of each other during 'configure', 'make', and 'make altinstall'.


b)
Also, I don't know, which setup do I have to edit during step 4.

c)
Which Tcl and Tk versions do I need, don't I need tcl-devel in addition?

Sorry for so many questions, but this stuff is new for me,
Simon
--
http://mail.python.org/mailman/listinfo/python-list


Re: install Python-2.4.4 from source (parallel to existing Python-2.6)

2009-06-12 Thread Simon

Benjamin Kaplan wrote:



On Fri, Jun 12, 2009 at 9:31 AM, Simon <mailto:simon...@gmx.de>> wrote:


edexter wrote:

simon wrote:

Hi everybody,

The situation:
I wrote a GUI, based on Python, TkInter and Pmw.
It runs perfectly fine with Python 2.4 (providing, TkInter
and Pmw are
installed). But it crashes with Python 2.6. I tried this on
MacOSX11.4
and various Linux Distributions.
Crashes occurs when I activate a Pmw.Diaog (I guess this is
due to a bug
in the installed blt package), also when I use setitems on
Pmw.OptionMenu (I guess this is due to another package,
associated with
tcl/tk).

The target:
I have to get my GUI work under openSUSE 11.1 (x86_64).

My plan:
On my openSUSE 11.1 (x86_64), Python 2.6 is installed by
default.
I would like to know, how to install Python 2.4 along with
TkInter and
Pmw (and packages that are required by them), parallel to
the existing
Python 2.6. So that I do not break other software that
depends on Python
2.6.

If you can think of another plan, I would be also glad to
discuss it.

Cheers,
    Simon


I suspect you want to install python 2.4 and then reinstall 2.6
 I did
that in windows and I don't understand why it wouldn't work in linux


I'm afraid, installation is quit different under UNIX based systems
and Windows.

I installed Python-2.4.4.tar.bz2 from python.org
<http://python.org>, using gcc-4.3 (within openSUSE 11.1 x86_64) via
'make altinstall'.

First, I tried to configure with the following flags:
--prefix=/opt/python-24 --enable-framework --with-pydebug
This provoked an error during compilation via make (sorry, the list
was so long, but I will post it, if it helps).


The --enable-framework option is for creating Framework builds on OS X. 
It won't work on Linux.
 



Second, configured again without any flags. The installation by
'make altinstall' to /usr/local was a success. Python2.6 seams
unaffected, too. So, I got my parallel installation.

However, I cannot import modules like Tkinter or readline within
python2.4.

For example, Tkinter.py is located in /usr/local/lib/python2.4/lib-tk

sys.path says: ['', '/usr/local/lib/python24.zip',
'/usr/local/lib/python2.4', '/usr/local/lib/python2.4/plat-linux2',
'/usr/local/lib/python2.4/lib-tk',
'/usr/local/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages']

sys.prefix and sys.exec_prefix say: '/usr/local'

my bash's PATH variable says:

/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin

Which configuration step did I miss after my Python2.4 installation?
What did I do wrong?



Again, give us the error message. We can't help if we don't know exactly 
what's going on.
 





Sorry, here it comes:


Python 2.4.4 (#1, Jun 12 2009, 14:11:55)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/etc/pythonstart", line 7, in ?
import readline
ImportError: No module named readline

>>> import Tkinter
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 38, in ?
import _tkinter # If this fails your Python may not be configured 
for Tk

ImportError: No module named _tkinter



Right know, I'm following Christian's hint, to "install the development 
library of tk, readline, zlib and libbz2 prior to configure && make", 
because the following essential packages were not installed on my system:


autoconf automake libbz2-devel libopenssl-devel libtool ncurses-devel 
readline-devel sqlite2-devel tack tcl-devel tk-devel zlib-devel


I will let you know about the result, soon.

Cheers,
Simon
--
http://mail.python.org/mailman/listinfo/python-list


Re: install Python-2.4.4 from source (parallel to existing Python-2.6)

2009-06-13 Thread Simon

Christian Heimes wrote:

Simon schrieb:

Christian Heimes wrote:

Simon wrote:

I installed Python-2.4.4.tar.bz2 from python.org, using gcc-4.3 (within
openSUSE 11.1 x86_64) via 'make altinstall'.

First, I tried to configure with the following flags:
--prefix=/opt/python-24 --enable-framework --with-pydebug
This provoked an error during compilation via make (sorry, the list was
so long, but I will post it, if it helps).

--enable-framework is for Mac OS X only.


Second, configured again without any flags. The installation by 'make
altinstall' to /usr/local was a success. Python2.6 seams unaffected,
too. So, I got my parallel installation.

You have chosen the correct and canonical way to install a parallel
installation of Python.


However, I cannot import modules like Tkinter or readline within
python2.4.

You must install the development library of tk, readline, zlib and
libbz2 prior to configure && make.

Try this on your box:

zypper install gcc make autoconf automake libtool zlib-devel
readline-devel tk-devel tcl-devel sqlite2-devel libbz2-devel
libopenssl-devel



Unfortunately, I got the following errors, while compiling via make.
Please, see attached text file for details about everything I did from
installing the missing packages via zypper until make.


zypper should have installed all necessary dependencies, including a
whole bunch of X11 headers. Something seems to be wrong on your system
or SuSE's package dependencies.
I know why I dislike SuSE. :) Although I started my Linux career 12
years ago with SuSE I prefer Debian based systems since Woody came out
in 2002. :)


X11 says:
Program 'X11' is present in package 'xorg-x11', which is installed on
your system.


zypper search X11 | grep devel
...
zypper install xorg-x11-devel

That should (hopefully) do the trick. On a Debian based systems it's
much easier to install all Python dependencies with "apt-get build-dep
python2.5"

To quote SuSE: "Have a lot of fun ..."

Und viel Glück!

Christian



Danke :)

On Monday, I will be able to tell if it worked out, or if I have to try 
a new strategy, e.g. to convince the admin about (K)ubuntu.

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


Newbie Question regarding __init__()

2009-07-31 Thread Simon
Hi

I want to create an instance of dcCursor which inherits from
dcObject.  When I run the following code it gives the error shown.
Can some explain to me what is wrong? I have included the dcObject.py
and dcCursor.py below.

>>>import dcObject
>>> import dcCursor
>>> x = dcCursor.dcCursor()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: __init__() takes no arguments (1 given)

# -*- coding: utf-8 -*-
# dcCursor.py - The base Cursor Class

from dcObject import dcObject

class dcCursor(dcObject):
"""The base Cursor Class"""
def OpenCursor(tcTemp,tcTable):
"""Opens the specified cursor
Parameters: tcTemp,tcTable"""
pass

def CreateCursor(tcTable):
"""Creates the specified cursor
Parameters: tcTable"""
pass

def init_Exec():
print("init_Exec called")



# -*- coding: utf-8 -*-
# dcObject.py - Base Object
class dcObject(object):
"""Base Object"""
def __init__():
"""default init method has the form
of init_Pre() and init_Exec
init_Post()"""
self.init_Pre() and self.init_Exec()
self.init_Post()

def init_Pre():
"""Always called before init_Exec()
if it returns false init_Exec is
not executed"""
return True

def init_Exec():
"""Base __init__ code goes here and this is
only executed if init_Pre() returns true"""
return True

def init_Post():
"""Always called after the init_Pre() and
init_Exec()"""
return True

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


Re: Newbie Question regarding __init__()

2009-07-31 Thread Simon
Hi

So should the dcObject class include the "self" as well since I have
not defined an __init__ method in dcCursor?

Simon

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


Re: Newbie Question regarding __init__()

2009-08-01 Thread Simon
Okay I will fix my code and include "self" and see what happens.  I
know I tried that before and got another error which I suspect was
another newbie error.

The idea behind the init_Pre is that I can put custom code here to
customize the __init__ instead of creating a new subclass.  This kind
of hook pattern allows you to flatten your inheritance hierarchy.  I
can choose in the init_Pre method to execute code before the init_exec
(which contains the default __init__ code) and still execute the
init_Exec method or I can completely customize the entire __init__ by
returning False from init_Pre and prevent the init_Exec from being
called.  I use this type of pattern with almost all my methods.  In
this way I can create a less complicated inheritance chain but still
have have custom code when needed without sub-classing.

I am use to Visual FoxPro which where you can do

=This.init_Pre().And.This.init_Exec() and the result is discarded so
that is why it looks the way it does.  In this form init_Exec has to
return a value.  However, If self.init_Pre(): self.init_Exec() would
work the same and then I could avoid returning a value.

Thanks,
Simon


On Aug 1, 5:52 am, Dave Angel  wrote:
> Nat Williams wrote:
> > As MRAB described, ALL instance methods need to accept 'self' as a first
> > parameter, as that will be passed to them implicitly when they are called.
> > This includes __init__.  The name 'self' is just a commonly accepted
> > convention for the name of the instance object passed to methods.  You don't
> > have to call it that, but you really should.
>
> > Take a look athttp://docs.python.org/tutorial/classes.html#class-objects
> > It might help shed some light on how methods and instances work.
>
> > One other thing.  I'm a little confused by the first line of
> > dcObject.__init__:
>
> > self.init_Pre() and self.init_Exec()
>
> > I suspect this does not do what you think it does.  init_Pre and init_Exec
> > will both be called by this expression (unless init_Pre throws an exception,
> > of course).  You're not getting anything here that you wouldn't by just
> > calling each method on a separate line, except just making it harder to
> > read.
>
> Read the doc-string for init_Pre() and for init_Exec().  The final
> version of init_Pre() will return False in some circumstances, and in
> those circumstances Simon doesn't want init_Exec() to be called.  He's
> deliberately using the short-circuit evaluation of  'and'  to accomplish
> that.
>
>
>
>
>
>
>
> > On Fri, Jul 31, 2009 at 8:53 PM, Simon  wrote:
>
> >> Hi
>
> >> So should the dcObject class include the "self" as well since I have
> >> not defined an __init__ method in dcCursor?
>
> >> Simon
>
> >> --
> >>http://mail.python.org/mailman/listinfo/python-list
>
> Every one of those methods in both of those classes need a "self" first
> argument.  As others have said, all instance methods need a 'self.'

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


Re: Newbie Question regarding __init__()

2009-08-03 Thread Simon
On Aug 2, 5:51 am, Dave Angel  wrote:
> Simon wrote:
> > Okay I will fix my code and include "self" and see what happens.  I
> > know I tried that before and got another error which I suspect was
> > another newbie error.
>
> > The idea behind the init_Pre is that I can put custom code here to
> > customize the __init__ instead of creating a new subclass.  This kind
> > of hook pattern allows you to flatten your inheritance hierarchy.  I
> > can choose in the init_Pre method to execute code before the init_exec
> > (which contains the default __init__ code) and still execute the
> > init_Exec method or I can completely customize the entire __init__ by
> > returning False from init_Pre and prevent the init_Exec from being
> > called.  I use this type of pattern with almost all my methods.  In
> > this way I can create a less complicated inheritance chain but still
> > have have custom code when needed without sub-classing.
>
> > I am use to Visual FoxPro which where you can do
>
> > =is.init_Pre().And.This.init_Exec() and the result is discarded so
> > that is why it looks the way it does.  In this form init_Exec has to
> > return a value.  However, If self.init_Pre(): self.init_Exec() would
> > work the same and then I could avoid returning a value.
>
> > Thanks,
> > Simon
>
> > On Aug 1, 5:52 am, Dave Angel  wrote:
>
> >> Nat Williams wrote:
>
> >>> As MRAB described, ALL instance methods need to accept 'self' as a first
> >>> parameter, as that will be passed to them implicitly when they are called.
> >>> This includes __init__.  The name 'self' is just a commonly accepted
> >>> convention for the name of the instance object passed to methods.  You 
> >>> don't
> >>> have to call it that, but you really should.
>
> >>> Take a look athttp://docs.python.org/tutorial/classes.html#class-objects
> >>> It might help shed some light on how methods and instances work.
>
> >>> One other thing.  I'm a little confused by the first line of
> >>> dcObject.__init__:
>
> >>> self.init_Pre() and self.init_Exec()
>
> >>> I suspect this does not do what you think it does.  init_Pre and init_Exec
> >>> will both be called by this expression (unless init_Pre throws an 
> >>> exception,
> >>> of course).  You're not getting anything here that you wouldn't by just
> >>> calling each method on a separate line, except just making it harder to
> >>> read.
>
> >> Read the doc-string for init_Pre() and for init_Exec().  The final
> >> version of init_Pre() will return False in some circumstances, and in
> >> those circumstances Simon doesn't want init_Exec() to be called.  He's
> >> deliberately using the short-circuit evaluation of  'and'  to accomplish
> >> that.
>
> >>> On Fri, Jul 31, 2009 at 8:53 PM, Simon  wrote:
>
> >>>> Hi
>
> >>>> So should the dcObject class include the "self" as well since I have
> >>>> not defined an __init__ method in dcCursor?
>
> >>>> Simon
>
> >>>> --
> >>>>http://mail.python.org/mailman/listinfo/python-list
>
> >> Every one of those methods in both of those classes need a "self" first
> >> argument.  As others have said, all instance methods need a 'self.'
>
> (Please don't top-post.  You should put new responses at the end of
> quoted text, or sometimes inline if that's clearer.)
>
> I don't understand your comparison to Foxpro.  read on.
>
> As your code was last posted, you don't need a return value from
> init_Exec()  Every function that doesn't have an explicit return will
> return None.  And None is interpreted as False in an "and" expression.  
> If you had an "if" around the whole thing, then you'd care.
>
> DaveA

All I meant by the FoxPro comment was the idea of using the equal sign
without a variable to throw away the result.  Also in FoxPro there is
no such thing as automatically returning None.  If there is no
explicit return then True is returned.

Thanks I did not know that None is interpreted as False.

Simon

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


Re: Newbie Question regarding __init__()

2009-08-04 Thread Simon
On Aug 3, 11:00 pm, Dave Angel  wrote:
> Simon wrote:
> > On Aug 2, 5:51 am, Dave Angel  wrote:
>
> >> 
> >> I don't understand your comparison to Foxpro.  read on.
>
> >> As your code was last posted, you don't need a return value from
> >> init_Exec()  Every function that doesn't have an explicit return will
> >> return None.  And None is interpreted as False in an "and" expression.  
> >> If you had an "if" around the whole thing, then you'd care.
>
> >> DaveA
>
> > All I meant by the FoxPro comment was the idea of using the equal sign
> > without a variable to throw away the result.  Also in FoxPro there is
> > no such thing as automatically returning None.  If there is no
> > explicit return then True is returned.
>
> > Thanks I did not know that None is interpreted as False.
>
> > Simon
>
> To throw away the result of an expression in Python is even easier.  
> Just don't use it.
>        func1() and func2()
> is a valid expression whose result is not used.  And func2()'s result is
> therefore irrelevant.  But shortcircuiting means that func2() is only
> called if func1() returned False (or something equivalent to it, like 0
> or an empty list)

Thanks for telling me how Python throws away the result.  Secondly my
code works perfectly now that I am properly defining my methods using
"self".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: eGenix PyRun - One file Python Runtime 1.0.0

2012-07-02 Thread Simon Cropper

On 02/07/12 23:52, eGenix Team: M.-A. Lemburg wrote:


ANNOUNCING

  eGenix PyRun - One file Python Runtime

  Version 1.0.0


   An easy-to-use single file relocatable Python run-time -
 available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-PyRun-1.0.0.html


INTRODUCTION

Our new eGenix PyRun combines a Python interpreter with an almost
complete Python standard library into a single easy-to-use
executable, that does not require a system wide installation and
is fully relocatable.

eGenix PyRun's executable only needs 12MB, but still supports
most Python application and scripts - and it can be further
compressed to 3-4MB using gzexe or upx.

Compared to a regular Python installation of typically 100MB on
disk, this makes eGenix PyRun ideal for applications and scripts
that need to be distributed to many target machines, client
installations or customers.

It makes "installing" Python on a Unix based system as simple as
copying a single file.

 http://www.egenix.com/products/python/PyRun/


NEWS

This is the first public release of eGenix PyRun. We have been
using the product internally in our mxODBC Connect Server since
2008 with great success and have now extracted it into a
stand-alone open-source product.

We provide both the source archive to build your own eGenix
PyRun, as well as provide pre-compiled binaries for Linux,
FreeBSD and Mac OS X, for the resp. 32- and 64-bit platforms.

Presentation at EuroPython 2012
---

Marc-André, CEO of eGenix, will be giving a presentation about
eGenix PyRun at EuroPython 2012 in Florence, Italy on Wednesday,
July 4th in the Room Tagliatelle.

He will also be available during the conference to answer
questions.


DOWNLOADS

The download archives and instructions for installing the product
can be found at:

 http://www.egenix.com/products/python/PyRun/

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

 http://www.egenix.com/services/support/

for details about our support offerings.


MORE INFORMATION

For more information about eGenix PyRun, licensing and download
instructions, please visit our web-site or write to
sa...@egenix.com.

Enjoy,



Hello,

Are you able to indicate what size the installation would be WITH ALL 
the mentioned dependencies on various typical systems (MS Windows 32/64, 
Ubuntu, etc)?


Saying something is only 12-13 MB in size is one thing but noting that 
you need 283MB+* of other packages means that in order to get this 
package to work on another machine you would need to install more than a 
12-13MB executable, particularly on a Windows machine.



OpenSSL on Windows 20MB -- http://slproweb.com/products

zlib binary on Windows 0.012MB-- /Win32OpenSSL.html -- 
http://gnuwin32.sourceforge.net/packages/zlib.htm


SQLite binary for Windows 262.59 MB -- http://www.sqlite.org/download.html/

BZip tarball 0.75 MB -- http://www.bzip.org/downloads.html

Also, do you have a page that indicates what standard libraries have 
been included? How can someone tell whether they would need to 
distribute or include any additional modules to get a script to work?


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting


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


Re: code review

2012-07-03 Thread Simon Cropper

On 04/07/12 13:53, Chris Angelico wrote:

On Wed, Jul 4, 2012 at 12:57 PM,   wrote:

Well, if you waited until you had the password (however long) in a variable 
before you applied your maximum limits, the DoS ship has probably sailed 
already.


Only because data transfer is usually more expensive than hashing. But
I'd say that'll always be true.

ChrisA



Some questions to Tyler Littlefield, who started this thread.

Q1 -- Did you get any constructive feedback on your code?

Q2 -- Did you feel that the process of submitting your code for review 
met your expectation?


Q3 -- Would you recommend others doing this either on this forum or 
other fora?


It appears to me - third party watching the ongoing dialog - that the 
tread has gone right off topic (some time ago) and someone should really 
start a new thread under a new title/subject. Most of what I have read 
does not appear to be discussing your code or how you could improve your 
code.


Following the last few posts, I was wondering whether some other 
off-list dialog is going on or whether I am missing something.


--
Cheers Simon



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


Re: Apology for OT posts

2012-07-05 Thread Simon Cropper

On 06/07/12 12:06, John O'Hagan wrote:

On Tue, 03 Jul 2012 23:39:20 -0600
"Littlefield, Tyler"  wrote:


On 7/3/2012 10:55 PM, Simon Cropper wrote:

Some questions to Tyler Littlefield, who started this thread.

Q1 -- Did you get any constructive feedback on your code?


I did get some, which I appreciated. someone mentioned using PyLint.
  From reading, I found it was really really pedantic, so I used PyFlakes
instead.


Q2 -- Did you feel that the process of submitting your code for review
met your expectation?


There wasn't much more to review, so yes. The info I got was helpful and
farther than it was before I started.


Q3 -- Would you recommend others doing this either on this forum or
other fora?

It appears to me - third party watching the ongoing dialog - that the
tread has gone right off topic (some time ago) and someone should
really start a new thread under a new title/subject. Most of what I
have read does not appear to be discussing your code or how you could
improve your code.


I basically just stopped after a while. It got into a my language is
better than your language, so I didn't see much constructive info. I've
started reading from the bottom though, where it looks like it's back,
and I do appreciate the rest of the info given, as well. Thanks again
for the feedback.



As one of the perpetrators, I did apologise for being OT within the body of my
replies to OT posts, but I see the irony. I guess I just thought somebody else
would do it eventually. I hereby apologise for not taking the correct action,
and vow to do so in future: to change the subject line regardless of who
initially went OT, starting now.

Regards,
--
John



thanks :)

bet this kills the conservation though...

Simon

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


Re: ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-11 Thread Simon Cropper

On 12/07/12 00:06, Chris Gonnerman wrote:

I've held off announcing this until I was sure it was really stable;
it's been 19 days since I made the last change to it, so here goes.
PollyReports is my Python module for report generation. It is designed
to be, quite literally, the "simplest thing that can possibly work" in
the field of PDF generation from a database record set.  There is a
somewhat vague resemblance to GeraldoReports; I had problems with
Geraldo's pagination which led me to develop PollyReports in a brief
flurry of intense activity.

It's on PyPI: http://pypi.python.org/pypi/PollyReports
and on Github: https://github.com/Solomoriah/PollyReports
and I have a blog where I talk about it (like anyone cares):
http://opensource.gonnerman.org/?cat=4


"I've noticed that acceptance of a new software module or package for 
developers in the Open Source/Free Software world is greatly affected by 
the availability of a good tutorial. I mean, it seems obvious, doesn't 
it? But I've also noticed that the original author of a project rarely 
writes a good tutorial." 
http://packages.python.org/PollyReports/tutorial.html


Well I thought it was a good tutorial. It certainly empowers me with 
enough confidence to give it a try.


That said... with more than a passing interest in software and content 
licensing I looked at how the work was licensed. A none-standard license 
like this makes most people stop and think "will this be a problem if I 
use this in my work?" How compatible is your license with the main 
software licenses currently available?


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting


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


Re: my email

2012-07-17 Thread Simon Cropper

On 18/07/12 11:44, Maria Hanna Carmela Dionisio wrote:

mmdionisio1...@yahoo.com.ph

Just a newbhie here :>


[snip]


You must know your password to change your options (including changing
the password, itself) or to unsubscribe.  It is:

   sweet103093



I suggest you change you password now that you have told the world what 
it is.


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting


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


Re: Finding duplicate file names and modifying them based on elements of the path

2012-07-18 Thread Simon Cropper

On 19/07/12 08:20, larry.mart...@gmail.com wrote:

I have an interesting problem I'm trying to solve. I have a solution
almost working, but it's super ugly, and know there has to be a
better, cleaner way to do it.

I have a list of path names that have this form:

/dir0/dir1/dir2/dir3/dir4/dir5/dir6/file

I need to find all the file names (basenames) in the list that are
duplicates, and for each one that is a dup, prepend dir4 to the
filename as long as the dir4/file pair is unique. If there are
multiple dir4/files in the list, then I also need to add a sequence
number based on the sorted value of dir5 (which is a date in ddMONyy
format).

For example, if my list contains:

/dir0/dir1/dir2/dir3/qwer/09Jan12/dir6/file3
/dir0/dir1/dir2/dir3/abcd/08Jan12/dir6/file1
/dir0/dir1/dir2/dir3/abcd/08Jan12/dir6/file2
/dir0/dir1/dir2/dir3/xyz/08Jan12/dir6/file1
/dir0/dir1/dir2/dir3/qwer/07Jan12/dir6/file3

Then I want to end up with:

/dir0/dir1/dir2/dir3/qwer/09Jan12/dir6/qwer_01_file3
/dir0/dir1/dir2/dir3/abcd/08Jan12/dir6/abcd_file1
/dir0/dir1/dir2/dir3/abcd/08Jan12/dir6/file2
/dir0/dir1/dir2/dir3/xyz/08Jan12/dir6/xyz_file1
/dir0/dir1/dir2/dir3/qwer/07Jan12/dir6/qwer_00_file3

My solution involves multiple maps and multiple iterations through the
data. How would you folks do this?



Hi Larry,

I am making the assumption that you intend to collapse the directory 
tree and store each file in the same directory, otherwise I can't think 
of why you need to do this.


If this is the case, then I would...

1. import all the files into an array
2. parse path to extract forth level directory name and base name.
3. reiterate through the array
   3.1 check if base filename exists in recipient directory
   3.2 if not, copy to recipient directory
   3.3 if present, append the directory path then save
   3.4 create log of success or failure

Personally, I would not have some files with abcd_file1 and others as 
file2 because if it is important enough to store a file in a separate 
directory you should also note where file2 came from as well. When 
looking at your results at a later date you are going to have to open 
file2 (which I presume must record where it relates to) to figure out 
where it came from. If it is in the name it is easier to review.


In short, consistency is the name of the game; if you are going to do it 
for some then do it for all; and finally it will be easier for others 
later to work out what you have done.


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting


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


Re: ANN: dbf.py 0.94

2012-07-20 Thread Simon Cropper

On 21/07/12 09:59, Ethan Furman wrote:

Getting closer to a stable release.

Latest version has a simpler, cleaner API, and works on PyPy (and
hopefully the other implementations as well ;), as well as CPython.

Get your copy at http://python.org/pypi/dbf.

Bug reports, comments, and kudos welcome!  ;)

~Ethan~


Question 1 - What version of VFP will dbf work with? Is VFP9 OK?

Question 2 - You statement of compatibility is unclear.

Works with PyPy, OK.

Hopefully works with other implementations, Hm, what does this mean?

Works or hopefully works with CPython -- which is it?

--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


PyPy, is it a 1:1 replacement for CPython?

2012-07-20 Thread Simon Cropper

Hi,

Can you use PyPy as a direct replacement for the normal python or is it 
a specialized compiler that can only work with libraries that are 
manipulated to operate within its constraints (if it has any).


Are there any issues with using PyPy? For example, if programs are 
created under PyPy are they subtle different from normal code that would 
make the program incompatible with the normal compiler?


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


append in IMAP4 from imaplib very slow

2012-07-25 Thread Simon Pirschel

Hi,

I'm currently experimenting with IMAP using Python 2.7.3 and IMAP4 from 
imaplib. I noticed the performance to be very bad. I read 5000 files 
from a directory and append them to an IMAP INBOX. The hole procedure of 
reading and appending is taking about 210 seconds.


I set up the exact same code in Perl to check if there is a general IMAP 
server configuration issue, since CPU and I/O isn't the problem. The 
same amount of data on the same IMAP server is done after 7.9 seconds 
using Perl.


The difference is huge and I tried to narrow the issue down by profiling 
the Python code.

The profile results are, 206 seconds are spent in calling socket.recv.

Python Code: <http://pastebin.com/EWnfpsZB>http://pastebin.com/d2c9d4Dx
Profile Result: http://pastebin.com/rWCS8tAz
Perl Code: http://pastebin.com/ZV3Yv74d

Maybe someone can explain what's the problem, or help me debugging the 
issue.


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


Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Simon Pirschel

On 07/26/2012 05:21 AM, Tim Chase wrote:

On 07/25/12 12:47, Simon Pirschel wrote:

I'm currently experimenting with IMAP using Python 2.7.3 and
IMAP4 from imaplib. I noticed the performance to be very bad. I
read 5000 files from a directory and append them to an IMAP
INBOX. The hole procedure of reading and appending is taking
about 210 seconds.

I set up the exact same code in Perl to check if there is a
general IMAP server configuration issue, since CPU and I/O isn't
the problem. The same amount of data on the same IMAP server is
done after 7.9 seconds using Perl.

The difference is huge and I tried to narrow the issue down by
profiling the Python code. The profile results are, 206 seconds
are spent in calling socket.recv.

While I don't know the ins and outs of the Perl code, it looks like
the Python imaplib.py is doing some pretty straight-forward
send/receive work.  However, IMAP4 does support both pipelining and
multi-append extensions, so if the Perl code takes advantage of the
features if the server offers them, it might be reaping significant
gains over the naïve Python code.

Can you get a debugging dump of the commands being sent each way?
(particularly if you see a bunch of APPEND commands before the reply
acknowledgement, as detailed at [1])

-tkc

[1]
http://www.ietf.org/rfc/rfc3502.txt on page 4

I took a strace of all network related sys calls from Python and Perl. 
It seems both don't do multi appends and waiting for the OK after 
appending one mail. But the Python version is getting a completely 
different response.


Python: "* 204 EXISTS\r\n* 1 RECENT\r\nNBGC3 OK [APPENDUID 1343283946 
204] Append completed.\r\n"

Perl: "2 OK [APPENDUID 1343283946 255] Append completed.\r\n"

The Python lib seems to trigger a EXISTS and RECENT lookup on every 
append, which could be the performance difference. I couldn't figure out 
why, yet!


Python strace: http://aboutsimon.com/py.strace
Perl strace: http://aboutsimon.com/pl.strace

Strings are shortened to 40 chars.


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


Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Simon Pirschel

On 07/26/2012 09:49 AM, Simon Pirschel wrote:

On 07/26/2012 05:21 AM, Tim Chase wrote:

On 07/25/12 12:47, Simon Pirschel wrote:

I'm currently experimenting with IMAP using Python 2.7.3 and
IMAP4 from imaplib. I noticed the performance to be very bad. I
read 5000 files from a directory and append them to an IMAP
INBOX. The hole procedure of reading and appending is taking
about 210 seconds.

I set up the exact same code in Perl to check if there is a
general IMAP server configuration issue, since CPU and I/O isn't
the problem. The same amount of data on the same IMAP server is
done after 7.9 seconds using Perl.

The difference is huge and I tried to narrow the issue down by
profiling the Python code. The profile results are, 206 seconds
are spent in calling socket.recv.

While I don't know the ins and outs of the Perl code, it looks like
the Python imaplib.py is doing some pretty straight-forward
send/receive work.  However, IMAP4 does support both pipelining and
multi-append extensions, so if the Perl code takes advantage of the
features if the server offers them, it might be reaping significant
gains over the naïve Python code.

Can you get a debugging dump of the commands being sent each way?
(particularly if you see a bunch of APPEND commands before the reply
acknowledgement, as detailed at [1])

-tkc

[1]
http://www.ietf.org/rfc/rfc3502.txt  on page 4

I took a strace of all network related sys calls from Python and Perl. 
It seems both don't do multi appends and waiting for the OK after 
appending one mail. But the Python version is getting a completely 
different response.


Python: "* 204 EXISTS\r\n* 1 RECENT\r\nNBGC3 OK [APPENDUID 1343283946 
204] Append completed.\r\n"

Perl: "2 OK [APPENDUID 1343283946 255] Append completed.\r\n"

The Python lib seems to trigger a EXISTS and RECENT lookup on every 
append, which could be the performance difference. I couldn't figure 
out why, yet!


Python strace: http://aboutsimon.com/py.strace
Perl strace: http://aboutsimon.com/pl.strace

Strings are shortened to 40 chars.


Simon
Ok, forget about the EXISTS and RECENT response. The server will 
response this way if you selected a mailbox, which I did in the Python 
code but not in the Perl code. I disabled selecting the mailbox in 
Python and there is no difference in the runtime. So, this isn't the issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Simon Pirschel

On 07/26/2012 11:25 AM, Simon Pirschel wrote:
Ok, forget about the EXISTS and RECENT response. The server will 
response this way if you selected a mailbox, which I did in the Python 
code but not in the Perl code. I disabled selecting the mailbox in 
Python and there is no difference in the runtime. So, this isn't the 
issue.


I solved the issue. The bad performance is caused by the socketopt 
socket.TCP_NODELAY set to 0 by default.


Request timing with socket.TCP_NODELAY=0: 0.0501310825348 seconds
Request timing with socket.TCP_NODELAY=1: 0.0027711391449 seconds

This is a huge difference. Setting TCP_NODELAY=1 will bring the runtime 
from 3:30 minutes down to 14 seconds! Not Perl speed, but close.


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


Re: ANN: dbf.py 0.94.003

2012-07-26 Thread Simon Cropper

On 27/07/12 05:31, Ethan Furman wrote:

A few more bug fixes, and I actually included the documentation this
time.  :)  It can be found at http://python.org/pypi/dbf, and has been
tested on CPythons 2.4 - 2.7, and PyPy 1.8.


[snip]

Ethan,

That's great.

Can you comment on the ultimate aim of the project?

Is this package primarily a "universal dbf translator" that allows the 
data stored in DBFs (which I might add I have many in legacy VFP 
applications and GIS Shapefiles) to be accessed and extracted or is the 
module being designed to be used interactively to extract data from and 
update tables?


I remember on the last thread that someone mentioned that indexes are 
not supported. I presume then that moving around a table with a couple 
of million records might be a tad slow. Have you tested the package on 
large datasets, both DBFs with a large number of records as well as a 
large number of fields?


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] New paper published (Volume 7 of The Python Papers) - High-Speed Data Shredding using Python

2012-07-30 Thread Simon Cropper

On 31/07/12 07:36, mauricel...@acm.org wrote:

Link: http://ojs.pythonpapers.org/index.php/tpp/article/view/243

Abstract

In recent years, backup and restore is a common topic in data storage. However, 
there’s hardly anybody mention about safe data deletion. Common data 
destruction methodology requires the wipe operation to fill the disk with 
zeros, then with random data, and then with zeros again. Three passes are 
normally sufficient for ordinary home users. On the down side, such algorithms 
will take many hours to delete a 2TB hard disk. Although current Linux utility 
tools gives most users more than enough security and data protections, we had 
developed a cross-platform standalone application that could expunge all 
confidential data stored in flash drive or hard disk. The data shredding 
software is written in Python, and it could overwrite existing data using 
user-defined wipe algorithm. This software project also explores the technical 
approaches to digital data destruction using various methodologies defined in 
different standards, which includes a selection of military-grade procedures 
proposed

by information security specialists. The application operates with no 
limitations to the capacity of the storage media connected to the computer 
system, it can rapidly and securely erase any magnetic mediums, optical disks 
or solid-state memories found in the computer or embedded system. Not only does 
the software comply with the IEEE T10/T13 specifications, it also binds to the 
number of connectivity limited by the SAS/SATA buses.




The paper is very interesting.

Funny though  I found it very hard to find a name of the application 
developed -- I presume it is the successor of CBL Data Shredder -- or if 
it is foss or proprietary package?


Does the application have a project page?

--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Geneology Packages -- WAS: Looking for a good introduction to object oriented programming with Python

2012-08-08 Thread Simon Cropper

On 09/08/12 12:59, Dennis Lee Bieber wrote:

On Wed, 08 Aug 2012 20:31:57 +0100, lipska the kat
 declaimed the following in
gmane.comp.python.general:


A Tree consists of Node(s) and Leaf(s), relationships are modelled by
following the Line(s) in the Tree diagram and that is it. Line may be a
class as in 'the patriarchal line' I'm not sure, it would come out in
the iterative wash.

We can infer whatever we want from this simple model. A Leaf is a child,
until it becomes a parent when it becomes a Node. To anthropomorphize a
bit more (I love that word) and introduce non species specific words and
concepts, a Node can be a father or mother (simple to implement by


If a "node" is a father or mother, and it takes one of each to
produce a "leaf", your "tree" has just collapsed.

In genealogy, a "tree" is merely the representation -- in one
direction -- of relationships from a single Person to either all
ancestors, or to all descendents.

"Father", "mother", "son", "daughter" (or to simplify, "parent",
"child") are merely roles taken on by a person in relationship to
another person. A Person can exist even if we do not know who the
parents were, nor if there are any children.


But what of all the ephemeral data that goes with a sentient existance
on this planet such as birth certificates, newspaper articles,
christenings, death certificates, photographs etc etc, what about
pegigree certificates, innoculation records and any other trivia,
information and flotsam that goes with a pedigree Dog or Horse or indeed
Parrot.


Those documents are the /evidence/ used to prove the linkages of the
Person.

Granted, the most popular genealogy program tends to be the least
capable -- it won't let one add a person without creating a "family"
first; and most all evidence is recorded as just a text memo.

In contrast, TMG, provides for "Sources" (the documents),
"Citations" (references to sources, used in the events in the person's
life), "Repositories" (where the source can be found). Events cover
things like "Birth", "Marriage", "Death", "Graduation", etc. [one can
create custom events too]. Events have a date, a location, and can have
multiple citations to the source the provides evidence that the event
took place and involved the person to which it is linked. In TMG, there
is no "family" as such -- only the linkages from relationship events (a
"birth" event does not link a child to its parents; that is done via a
pair of parent-child relationships [father-relationship,
mother-relationship] and TMG supports having multiples -- only the pair
marked a "primary" is used to produce "tree-like" reports, but the
system supports having birth-parents and adoptive-parents at the same
time in the data). It even supports having multiple "Birth" events too,
if one finds conflicting evidence and can not determine if some is
invalid.

I'm not going to go into depth, but the TMG (v8) database consists
of 29 tables, and the user interface centers on displaying a list of
events for a person. Oh, and the person can have more than one name too,
though only one can be listed as primary (shows at the top of the page)
-- the others appear as name events.

The absolute minimum to define a person in TMG is an ID number (the
internal primary key) and preferably a "primary" name (and the name
could be all blanks -- though having multiple people with no names, just
ID numbers, makes for difficulty when later adding relationships: does
this person connect to "(---unknown---)(---unknown---)" #2718 or to
"(---unknown---)(---unknown---)" #3145 )



Since we have graduated to a completely different topic I have renamed 
the thread.


If people are interested in a totally python-based open source FREE (as 
in no $$) package that can do all the above try gramps...


http://gramps-project.org/

I have used this package for a few years now and it is fantastic. Check 
out the features page to see what I mean.


http://gramps-project.org/features/

--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread Simon Cropper

On 14/08/12 15:12, mullaper...@gmail.com wrote:

Hi,

I wanna call perl script in HTML form n store that data in DB using Python.

How can i do this...??

Please help me

Thank you
Pervez



Google you question.

Many solutions already exist on the Internet.

--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread Simon Cropper

On 14/08/12 15:31, mullaper...@gmail.com wrote:

On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, mulla...@gmail.com wrote:

Hi,



I wanna call perl script in HTML form n store that data in DB using Python.



How can i do this...??



Please help me



Thank you

Pervez


Hey Simon,

Thank You for your mail and time,

Yest I spent entire day for this , But I didn't get any solution for this 
problem .I google it but am not able to get any solution for this



Then you should outline what you have tried and what the problems you 
encountered that way people can help.


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


pylagiarism -- Need help now! Please provide code...

2012-08-13 Thread Simon Cropper

Hi Everyone,

I just had a great idea for a new python module. I haven't bothered 
googling it or doing any research.


I need help putting together some code; today preferably, my boss is on 
my back. Can someone please contribute a functioning module showing me 
how to do it?


Once I have all your submissions, I will compile a functioning  package, 
which I hope to sell. Don't worry, no one will be at risk of being sued, 
I don't intend to credit you with the code and you will not know 
anything about what I have done because I don't intend to post and 
feedback to the list. Licenses are not a problem either, I don't believe 
in them and even if you find out I have plagiarized your stuff you have 
bub-kiss chance of suing me as I am in another jurisdiction.


So, now you know where I am coming from, I would like to thank you for 
all your help. Remember though, I need help now, so please stop what you 
are doing and submit something quickly. I'm waiting...


Still waiting...

Hey, stop reading and get on with writing some code, I don't have all day!

--
Simon

Disclaimer  :) Please don't flame me, I have written this with my tongue 
in my cheek and a light hearted take on some people request for 
assistance on a range of mail lists. It was not meant to target anyone 
in particular only to exaggerate how some people's requests appear to 
lurkers and contributors on many fora I frequent.

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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Simon Cropper

On 14/08/12 18:19, Peter Otten wrote:

Simon Cropper wrote:


Hi Everyone,

I just had a great idea for a new python module. I haven't bothered
googling it or doing any research.

I need help putting together some code; today preferably, my boss is on
my back. Can someone please contribute a functioning module showing me
how to do it?

Once I have all your submissions, I will compile a functioning  package,
which I hope to sell. Don't worry, no one will be at risk of being sued,
I don't intend to credit you with the code and you will not know
anything about what I have done because I don't intend to post and
feedback to the list. Licenses are not a problem either, I don't believe
in them and even if you find out I have plagiarized your stuff you have
bub-kiss chance of suing me as I am in another jurisdiction.

So, now you know where I am coming from, I would like to thank you for
all your help. Remember though, I need help now, so please stop what you
are doing and submit something quickly. I'm waiting...

Still waiting...

Hey, stop reading and get on with writing some code, I don't have all day!


You're close, but I prefer to help out the guy with the brilliant idea (I
know it's brilliant because he says so) who is offering me a fraction of the
fortune he is going to make once I've done all the work...



Peter,

You are right. Quite remiss of me.

Anyone willing to contribute money to help with the compilation of the 
code will get a portion of the profits. Just send me your account 
details, name and address; and I will ensure, once I have been paid, 
that I will send you your cut! :)


--
Simon


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


Re: Haskell -> Python

2012-11-02 Thread Simon Foster

On 02/11/12 19:56, Dave Angel wrote:

On 11/02/2012 03:19 PM, foste...@gmail.com wrote:

Hi All,

As part of a Nim solver I'm playing around with I'm trying to code this Haskell 
snippet:

   options [x] = zero : [ [y] | y <- [1..x - 1] ]
   options (x:xs) = map (++ xs) (options [x]) ++ map (x:) (options xs)

in Python.  So far I have this, which works OK, but somehow doesn't feel right:

def options( heaps ):

 if heaps == []: return []

 head, tail = heaps[:1], heaps[1:]

 # Calculate all possible moves which is the sum of
 # prepending all possible head "moves" to the tail
 # and appending all possible tail "moves" to the head

 return [ [h] + tail for h in range( head[0] ) ] \
  + [ head + t   for t in options( tail )  ]

Is there anything anyone could recommend to make it more "Pythonic" or more 
functional.  It looks clumsy next to the Haskell.

Regards

etc.


You'd save people a lot of time if you'd specify that the parameter
heaps is a list of ints, perhaps initially [1,3,5,7]   or [3, 4, 5]
depending on which variation of Nim you're trying to.  There are many.
One variant is that some versions of Nim say the winner is the player
who does NOT take the last piece.  I'll assume that the goal is to end
up with [0,0,0,0]

My main problem with studying your code is that brute force is totally
unnecessary;  there's a fairly simple strategy for winning at Nim.
Certainly it's simple enough to have perfect strategy without any computer.

A "good" move is any one where the xor of all the items in the list ends
up as zero.  There is always at least one move for an "ungood" position
that results in a "good" one.  Thus the strategy is to go from good to
good, with the opponent always stuck on an ungood one.




Hi Dave,

Thanks for the comments.  Yes, I should have specified that the input is 
a list of ints giving the size of each heap, and the return value should 
be a list of all game positions reachable from the input position.


At the moment I'm not concentrating on any particular Nim flavour, just 
trying to enumerate all possible moves from a given position.


I know that there's an easier way to determine winning-losing positions, 
but my question was more about programming style than Nim strategy.


My code to calculate the "nim-value" looks like this:

def nim_val( heaps ):
return functools.reduce( operator.xor, heaps, 0 )

Assuming that we're playing "non-misere" Nim then a zero nim-value is a 
lose for the player *about* to play.


Regards

Simon


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


Re: Numpy outlier removal

2013-01-06 Thread Paul Simon

"Steven D'Aprano"  wrote in message 
news:50ea28e7$0$30003$c3e8da3$54964...@news.astraweb.com...
> On Sun, 06 Jan 2013 19:44:08 +, Joseph L. Casale wrote:
>
>> I have a dataset that consists of a dict with text descriptions and
>> values that are integers. If required, I collect the values into a list
>> and create a numpy array running it through a simple routine:
>>
>> data[abs(data - mean(data)) < m * std(data)]
>>
>> where m is the number of std deviations to include.
>
> I'm not sure that this approach is statistically robust. No, let me be
> even more assertive: I'm sure that this approach is NOT statistically
> robust, and may be scientifically dubious.
>
> The above assumes your data is normally distributed. How sure are you
> that this is actually the case?
>
> For normally distributed data:
>
> Since both the mean and std calculations as effected by the presence of
> outliers, your test for what counts as an outlier will miss outliers for
> data from a normal distribution. For small N (sample size), it may be
> mathematically impossible for any data point to be greater than m*SD from
> the mean. For example, with N=5, no data point can be more than 1.789*SD
> from the mean. So for N=5, m=1 may throw away good data, and m=2 will
> fail to find any outliers no matter how outrageous they are.
>
> For large N, you will expect to find significant numbers of data points
> more than m*SD from the mean. With N=10, and m=3, you will expect to
> throw away 270 perfectly good data points simply because they are out on
> the tails of the distribution.
>
> Worse, if the data is not in fact from a normal distribution, all bets
> are off. You may be keeping obvious outliers; or more often, your test
> will be throwing away perfectly good data that it misidentifies as
> outliers.
>
> In other words: this approach for detecting outliers is nothing more than
> a very rough, and very bad, heuristic, and should be avoided.
>
> Identifying outliers is fraught with problems even for experts. For
> example, the ozone hole over the Antarctic was ignored for many years
> because the software being used to analyse it misidentified the data as
> outliers.
>
> The best general advice I have seen is:
>
> Never automatically remove outliers except for values that are physically
> impossible (e.g. "baby's weight is 95kg", "test score of 31 out of 20"),
> unless you have good, solid, physical reasons for justifying removal of
> outliers. Other than that, manually remove outliers with care, or not at
> all, and if you do so, always report your results twice, once with all
> the data, and once with supposed outliers removed.
>
> You can read up more about outlier detection, and the difficulties
> thereof, here:
>
> http://www.medcalc.org/manual/outliers.php
>
> https://secure.graphpad.com/guides/prism/6/statistics/index.htm
>
> http://www.webapps.cee.vt.edu/ewr/environmental/teach/smprimer/outlier/outlier.html
>
> http://stats.stackexchange.com/questions/38001/detecting-outliers-using-standard-deviations
>
>
>
> -- 
> Steven
If you suspect that the data may not be normal you might look at exploratory 
data analysis, see Tukey.  It's descriptive rather than analytic, treats 
outliers respectfully, uses median rather than mean, and is very visual. 
Wherever I analyzed data both gaussian and with EDA, EDA always won.

Paul 


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


Re: Fetching data from a HTML file

2012-03-23 Thread Simon Yan
On Fri, Mar 23, 2012 at 9:52 PM, Sangeet  wrote:

> Hi,
>
> I've got to fetch data from the snippet below and have been trying to
> match the digits in this to specifically to specific groups. But I can't
> seem to figure how to go about stripping the tags! :(
>
> Sum class="green">24511 align='center'>02561.496
> [min]
> 
>
> Actually, I'm working on ROBOT Framework, and haven't been able to figure
> out how to read data from HTML tables. Reading from the source, is the best
> (read rudimentary) way I could come up with. Any suggestions are welcome!
>

Sangeet,

I think Python comes with its own HTML parser. Can you have a look at this
http://docs.python.org/library/htmlparser.html and see if it helps?


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



-- 
Regards,
YeeYaa (Simon Yan)

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


Re: inquery

2012-04-18 Thread Simon Cropper

On 19/04/12 08:32, Lovda, Kathryn wrote:

Hello,

I'm having trouble trying to script for a fellow graduate student who is
doing research on frogs and their homeranges. He asked me to help him by
using python to manipulate his data on ArcMap 10. Here is a summary of
the situation:

"A fellow graduate student working in the Boone Herpetology lab in the
Zoology Department has asked you to help him with his research project.
Specifically he needs to know what land use land cover types the frogs
he has been studying had within their "homerange" in the early 1990s. He
has field measurements for current data but he wants historical data on
what this same area was like in terms of land use land cover (LULC). The
output you provide to him should be a table that lists the total area of
each land cover type within ALL frog homeranges in each county. Use the
data provided to you to write a script that has the desired output that
your friend needs."

I know that I have to use the JoinField command and the Statistics
command, but not sure how to formulate the script. Is there anyway you
can send me a script to work off of? Thanks for your help.

--

Kathryn Lovda
Miami University IES Graduate Student
Botany & Environmental Science B.A. Major
lov...@muohio.edu <mailto:lov...@muohio.edu>





Kathryn,

This type of work is basic GIS work that should be able to be achieved 
without resorting to scripting. That is, achieved through a simple GUI 
interface using preconfigured tools. The issue is whether you actually 
have land use and land cover data for the 1990s.


Present the same inquiry to an ESRI forum - you would probably have more 
chance of a response. If your University does not have the entire ESRI 
suite you can download any number of free and open source tools that can 
do this work -- e.g. GRASS, gvSIG, QGIS. All you need to do is convert 
the ArcMap file to something that can be used by ArcView or by one of 
these tools (e.g. shapefile).


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newby Python Programming Question

2012-05-14 Thread Simon Cropper

On 15/05/12 12:18, Chris Angelico wrote:

On Sat, May 12, 2012 at 8:25 AM, Coyote  wrote:

I've been playing around with a couple of IDEs because I liked the one I used 
with IDL and I wanted to use something similar for Python. The IDLDE was an 
Eclipse variant, but I've tried installing Eclipse before for something else 
and I'm pretty sure I don't need *that* kind of headache on a Friday afternoon. 
Unless, of course, I need a good excuse to head over to the Rio for the 
margaritas. :-)


When it comes to IDEs, I've never really gone for any. My current
setup at work (which I convinced my boss to deploy to all our
developers, himself included) is all open-source: SciTE
(Scintilla-based Text Editor) with a few in-house configurations, a
good makefile, and m4 (plus git for source control). SciTE has syntax
highlighting for all the languages we use, and is set to save and
'make' on press of F7, and the makefile handles everything else.
There's a couple of in-house scripts such as a cache-control script
(looks through our HTML and PHP pages for references to .js files and
adds ?tag to them where tag comes from git) and a rapid deployment
handler, but the upshot is that I edit a file, hit F7, and everything
happens for me. That's about as good as any IDE would give, but
without the overhead of most IDEs.

ChrisA


Sorry for responding to you post Chris but I missed Davids post.

David,

I really like SPE IDE - Stani's Python Editor 
(http://pythonide.stani.be/). It and the bundled packages work really 
well. I note it works on Windows, Mac and Linux.


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: Where is the most recent Tkinter information

2012-05-16 Thread Simon Cropper

On 17/05/12 13:02, Mark R Rivet wrote:

It seems like all the info on tkinter is around the 2000 time frame.
Is tkinter still being developed/supported?


The main page of the python 3.2.3 documentation for tkinter can be found 
here... 
http://docs.python.org/py3k/library/tkinter.html?highlight=tkinter#tkinter 
it is dated 2012.


This seems to be duplicated from the ActiveState site here...
http://docs.activestate.com/activepython/3.1/python/library/tkinter.html 
also dated 2012.


Here are some other resources I have stumbled on...

http://www.tutorialspoint.com/python/python_gui_programming.htm

http://infohost.nmt.edu/tcc/help/pubs/tkinter/

http://www.tkdocs.com/tutorial/index.html

http://www.ibm.com/developerworks/linux/library/l-tkprg/

--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for Python script for Vector Map simplification, preserving shape and topology

2012-05-17 Thread Simon Cropper

On 18/05/12 03:46, David Shi wrote:

Dear All,

I am looking for Python script for Vector Map simplification, preserving
shape and topology.

Please get in touch with davidg...@yahoo.co.uk

Regards.

David




David,

You really need to provide more information to get a specific answer; 
what sort of vector file? What do you mean by simplify? etc.


Of course, most likely most people python-gis bent would say check out 
the GDAL libraries -- http://pypi.python.org/pypi/GDAL/


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


GUI toolkits and dynamic table browser widget

2012-05-17 Thread Simon Cropper

Hi,

There has been some discussion on this list regarding GUI toolkits and 
it reinvigorated my search for one to meet my needs.


I would like to create windows with grids (AKA rows and column of a
table like excel). Do any of the GUI interfaces have these types of 
widgets? i have looked but can't find any and I have not stumbled on 
program that presents data in this way so I can see how they do it.


Specifically I would like to run a SQL command and have the returned 
list passed to a widget with little or no manipulation and that widget
present the data, allow the user to scroll through that data and 
preferably allow edits to occur. These edits could then be passed back 
via a string to the program for inclusion in a sql-update command.


Any ideas?

--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUI toolkits and dynamic table browser widget

2012-05-17 Thread Simon Cropper

On 18/05/12 14:00, Vincent Vande Vyvre wrote:

On 18/05/12 02:52, Simon Cropper wrote:

Hi,

There has been some discussion on this list regarding GUI toolkits and
it reinvigorated my search for one to meet my needs.

I would like to create windows with grids (AKA rows and column of a
table like excel). Do any of the GUI interfaces have these types of
widgets? i have looked but can't find any and I have not stumbled on
program that presents data in this way so I can see how they do it.

Specifically I would like to run a SQL command and have the returned
list passed to a widget with little or no manipulation and that widget
present the data, allow the user to scroll through that data and
preferably allow edits to occur. These edits could then be passed back
via a string to the program for inclusion in a sql-update command.

Any ideas?


Have a look at PyQt [1], specially QTableView [2] and QtSql [3]

[1] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/index.html
[2]
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtableview.html
[3] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qsql.html



Vincent,

That looks very promising... do you understand the licensing though?

GPL to GPL is obvious but would development of an in-house system be 
commercial or GPL licensing?


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: serial module

2012-05-18 Thread Paul Simon
Sounds like you may be using this on a Windows machine.   the code is 
functional, it is best practice to close the port first before openiing it. 
If due to an error, usually not syntax, the port will stay stuck open until 
the program is closed and reopened.  I have used the Python serial port 
(serial.py?) with good results.

Paul Simon

"Ron Eggler"  wrote in message 
news:jp6gcj$1rij$1...@adenine.netfront.net...
> Hoi,
>
> I'm trying to connect to a serial port and always get the error
> "serial.serialutil.SerialException: Port is already open." whcih is 
> untrue.
> I have no serial port open yet, my code looks like this:
> #!/usr/bin/python
> import time
> import serial
>
> # configure the serial connections (the parameters differs on the device
> # you are connecting to)
> ser = serial.Serial(
>port='/dev/ttyUSB0',
>baudrate=19200,
>parity=serial.PARITY_ODD,
>stopbits=serial.STOPBITS_TWO,
>bytesize=serial.SEVENBITS
> )
>
> ser.open()
>
> Why do I get this error?
>
> Thank you,
> Ron
>
> --- Posted via news://freenews.netfront.net/ - Complaints to 
> n...@netfront.net --- 


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


Re: GUI toolkits and dynamic table browser widget

2012-05-18 Thread Simon Cropper

On 19/05/12 01:09, Dennis Lee Bieber wrote:

On Fri, 18 May 2012 10:52:07 +1000, Simon Cropper
  declaimed the following in
gmane.comp.python.general:


Hi,

There has been some discussion on this list regarding GUI toolkits and
it reinvigorated my search for one to meet my needs.

I would like to create windows with grids (AKA rows and column of a
table like excel). Do any of the GUI interfaces have these types of
widgets? i have looked but can't find any and I have not stumbled on
program that presents data in this way so I can see how they do it.


Page 426 of "wxPython in Action" starts a chapter on using a grid
view (and a "gridtable" which uses a linked data structure for
populating the grid)..


Specifically I would like to run a SQL command and have the returned
list passed to a widget with little or no manipulation and that widget
present the data, allow the user to scroll through that data and
preferably allow edits to occur. These edits could then be passed back
via a string to the program for inclusion in a sql-update command.


Don't know if it has a direct link to SQL data sources; however, the
"gridtable" is probably closest.


Dennis,

Thanks for you feedback. Sometimes it just knowing the name of what you 
are looking for you to be able to find the data.


Googling gridtable allowed me to find my way to the wxGrid Manual which 
seems to be what I was asking for...


http://wiki.wxpython.org/wxGrid%20Manual

wxPyGridTableBase, a particular class associated with wxGrid appears to 
be what I need. The blurb states "The wxPyGridTableBase class is the 
interface between the wxGrid and your application-specific data sources"


http://wiki.wxpython.org/wxPyGridTableBase

--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUI toolkits and dynamic table browser widget

2012-05-21 Thread Simon Cropper

On 22/05/12 05:35, Sibylle Koczian wrote:

So I suppose you're using Python 2 or that's acceptable for you at
least. In this case I'd take a long look at Dabo: http://www.dabodev.com/
That's based on wxPython but easier to use and explicitly made for
database applications. Developers and mailing list are especially
helpful and friendly.


I have investigated Dabo.

Dabo is OK but is like a big wizard.

You fix you underlying data structure then it creates basic menus,
data entry screens, etc. The basic stuff is OK but you need change the 
underlying code to customize the screens and you are bound to use the 
classes created by the developers (you can create you own but all sorts 
of interactions can happen apparently, and although it can be done, care 
needs to be taken to avoid conflicts -- the recommendation by the 
developers to is use the existing classes whenever possible).


On top of this the project is not being developed any more. What is 
there, is what is there. The developers occasionally jump on the forums 
to propose a solution to an interesting problem but state that no 
further development will be happening. The community is still active 
however and there are a number of devotees.


Personally, when I reviewed it, I wanted to develop a different dialog 
screen and database model than what Dabo is designed to address, which 
meant that I required to butcher their code and classes to achieve what 
I wanted. In my mind you are better starting from scratch using a 
maintained library/toolkit, rather than creating a hybrid system with a 
unmaintained project (that is unless you want to fork the project).


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


wxpython using variable with wx.statictext ignores \n

2012-06-01 Thread Simon Cropper

Hi,

I have some wxPython code created with wxGlade that I am customizing.

I have a label created under the def __init__() section of the Frame 
Class. It states...


self.Question = wx.StaticText(self, -1, "My question...")

if I insert a new line character in this string like this then the 
output is placed on two lines as expected.


self.Question = wx.StaticText(self, -1, "My \nquestion...")

Output   My
 question

I am getting the question as an argument using sys.argv[] and putting
it in a variable called "question_text". The code is as follows...


question_text = "My \nquestion..."
self.Question = wx.StaticText(self, -1, question_text)

Output   My \nquestion

How do I get the line text \n recognized so the break is inserted using 
the variable technique like what happened when I actually used a string?


...in bash you would do "$question_text". Is there comparable macro
substitution in python.

--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: testing if a list contains a sublist

2011-08-20 Thread Simon Forman
On Mon, Aug 15, 2011 at 4:26 PM, Johannes  wrote:
> hi list,
> what is the best way to check if a given list (lets call it l1) is
> totally contained in a second list (l2)?
>
> for example:
> l1 = [1,2], l2 = [1,2,3,4,5] -> l1 is contained in l2
> l1 = [1,2,2,], l2 = [1,2,3,4,5] -> l1 is not contained in l2
> l1 = [1,2,3], l2 = [1,3,5,7] -> l1 is not contained in l2
>
> my problem is the second example, which makes it impossible to work with
> sets insteads of lists. But something like set.issubset for lists would
> be nice.
>
> greatz Johannes
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Probably not the most efficient way, but I wanted to mention it:


from difflib import SequenceMatcher


def list_in(a, b):
'''Is a completely contained in b?'''
matcher = SequenceMatcher(a=a, b=b)
m = matcher.find_longest_match(0, len(a), 0, len(b))
return m.size == len(a)


Cheers,
~Simon
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello, and request for help with 'dynamic grids'

2011-09-04 Thread Simon Cropper

Hi,

I am a applications developer - originally from Windows using primarily 
Visual Foxpro, although I am familiar with a variety of other xbase 
derivatives. I now use Linux / Ubuntu, and have been actively teaching 
myself Python with the view to migrate most of my applications to 
sqlite-based database.


I am looking for the ability to create dynamic grids in a window but 
can't for the life of me find how to do this.


Here is the functionality that I desire...
1. Have a dialog appear that allows me to select a database, e.g. 
sqlite3 database.
2. Select table in the database and have all the records appear in a 
grid. Fields represented as column, width and order adjustable, rows 
representing records. Each cell can be edited directly.
3. I would like to create filters on this grid based on attributes in 
the table. So if the table is a list of names, filter and show only 
those people with a particular first name. For people familiar with 
xbase languages it equivalent to browsing a table and applying a filter.
4. Once the record is identified I would like to select the record or 
hit enter to have the data sent to the keyboard buffer or put into the 
clipboard.


I have found most of these elements available. I can create dialogs, I 
can connect to a database, I can extract data from the tables using SQL 
but I can't find how to easily get these lists into a grid -- it appears 
to me you need to allocate list record 1 to grid row 1, list record 2 to 
grid row 2, etc and manage how many rows are displayed and 'page' 
through the table.


Am I missing something? I presume that you could just supply a list or 
array selected using SQL from a table and just pass this data to a grid 
and have it manage all the basics like if the window is resized the 
number of rows and columns are adjusted accordingly, buffering records, etc.


My investigations have generally found that windows/forms/data entry 
screen can be created for a specific table or view, but these are 
hard-wired during development. Is there anyway of rapidly defining the 
grid during runtime so any table can be viewed?


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://gis.fossworkflowguides.com
   bash / Pythonhttp://scripting.fossworkflowguides.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hello, and request for help with 'dynamic grids'

2011-09-05 Thread Simon Cropper

On 05/09/11 17:19, Steven D'Aprano wrote:

On Mon, 5 Sep 2011 03:18 pm Simon Cropper wrote:


I am looking for the ability to create dynamic grids in a window but
can't for the life of me find how to do this.


What GUI toolkit are you using?




I have looked at wxGlade, Boa Constructor, wxFormBuilder, tkinder, I 
have also looked through the Python website many times looking for 
commands that would allow me to create a GUI from scratch.


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://gis.fossworkflowguides.com
   bash / Pythonhttp://scripting.fossworkflowguides.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hello, and request for help with 'dynamic grids'

2011-09-05 Thread Simon Cropper

On 05/09/11 20:40, Thomas Jollans wrote:

It depends on which windowing toolkit you're planning to use. If you use
PyGTK, you'd want a TreeView widget to display the list. Fill a
ListStore instance with your data and give that to the TreeView. You can
implement filtering and sorting on top of that using TreeModelFilter and
TreeModelSort.


I have look at most. I have no preference.

Are you able to point me to some resource material explaining how this 
can be done - e.g. a tutorial or manual?



LibreOffice and OpenOffice have database management components (I
haven't used them, I assume they're somewhat similar to MS Access) - and
they can be scripted using Python. Depending on what you're doing, and
what you're planning to do in the future (re learning investment), that
might be worth looking into.


'Base' is of no value in this regard. It is not really designed for this 
and there is a raging debate at the moment whether it will be maintained 
in the future. It also fails in that it requires predefined connections 
and forms to be established. It would not be possible to dynamically 
link to a table in a database (I have established ODBC links to a SQLite 
database, but the driver is an un-maintained draft). I also believe that 
the 'base' component in libreoffice/openoffice is a java implementation 
not python.


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://gis.fossworkflowguides.com
   bash / Pythonhttp://scripting.fossworkflowguides.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hello, and request for help with 'dynamic grids'

2011-09-05 Thread Simon Cropper

On 05/09/11 23:23, pyt...@bdurham.com wrote:

Check out dabodev.com. Dabo is a Python framework created by former VFP
developers.



Dabo is a great product. Spoke extensively with Ed Leafe and Paul 
McNett. Unfortunately the framework is not 'dynamic'. If you have an 
fixed database and tables it can quite quickly create a basic data entry 
setup and menu. Looks great when it runs. The problem is creating the 
window and grid on the fly.


I want a program that can be used to open any database and 'data mine' 
and extract table content. Dabo allows RAD for an established relational 
databases not unknown ones.


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://gis.fossworkflowguides.com
   bash / Pythonhttp://scripting.fossworkflowguides.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hello, and request for help with 'dynamic grids'

2011-09-05 Thread Simon Cropper

On 06/09/11 00:40, alex23 wrote:

On Sep 5, 3:18 pm, Simon Cropper
wrote:

My investigations have generally found that windows/forms/data entry
screen can be created for a specific table or view, but these are
hard-wired during development. Is there anyway of rapidly defining the
grid during runtime so any table can be viewed?


The commercial product Resolver One provides a grid/spreadsheet style
interface with Python scripting capabilities. I'm not sure of its
current licensing status but I believe it used to be free if used on
open source projects.

http://www.resolversystems.com/products/resolver-one/

Each spreadsheet itself is Python code; I think it should be quite do-
able to take something with introspective SQL capabilities like
SQLAlchemy and have it title columns and fill them with the correct
fields accordingly.

Hope this helps.




Alex,

The Resolver Package looks good. Not exactly open source though. I 
equate it to a proprietary package that can at times be used for free by 
select groups.


The product creates spreadsheets with python code in the background 
(instead of say VBA in Excel or Basic in Calc).


Access to a database still needs to be hard-wired, so it does not act as 
a 'dynamic' viewer. The product works pretty much like Excel and Calc in 
this manner.


Sheets can be shared, although the Resolver Exchange website does not 
clarify the licence under which samples are released (GPL, CC, etc), so 
it is debatable how any of this could reliably be used in creation of 
derivatives.


From what I can glean from this page...

 http://www.resolversystems.com/opensource/

 ... Resolver will allow you to use the package if you are an open 
source project to create spreadsheets that can be redistributed. For 
people to use these sheets they need to download the viewer or purchase 
the package.


--
Cheers Simon

   Simon Cropper - Open Content Creator / Website Administrator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://gis.fossworkflowguides.com
   bash / Pythonhttp://scripting.fossworkflowguides.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing numeric ranges

2011-02-25 Thread Simon Brunning
On 25 February 2011 09:27, Seldon  wrote:
> Hi all,
> I have to convert integer ranges expressed in a popular "compact" notation
> (e.g. 2, 5-7, 20-22, 41) to a the actual set of numbers (i.e.
> 2,5,7,20,21,22,41).
>
> Is there any library for doing such kind of things or I have to write it
> from scratch ?

I dredged this out:



def _revision_list_with_ranges_to_list_without_ranges(revision_list):
'''Convert a revision list with ranges (e.g. '1,3,5-7') to a
simple list without ranges (1,3,5,6,7)'''
for revision in revision_list:
if '-' in revision:
from_revision, _, to_revision = revision.partition('-')
for revision_in_range in range(int(from_revision),
int(to_revision)+1):
    yield revision_in_range
else:
yield int(revision)

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python benefits over Cobra

2011-04-05 Thread Brendan Simon



>  On 05-Apr-11 06:22 AM, Brendan Simon (eTRIX) wrote:
>>
>>  Any other arguments where Python has benefits over Cobra ??
>>
>>  Cheers, Brendan.
>>
>  Two questions:
> 1. Is Cobra Open Source?
> 2. The blog ended on October, did he run out of steam?
>
>  I liked the '.', in place of '.self', but that's been rejected for Python.


"Cobra is an open source project under the MIT license." according to 
the web site.


It seems that it mostly, if not all, the work of one person.  All code 
commits seem to be from Charles Esterbrook.


It seems the latest release is Oct 2010, but I can see posts in the 
forum for April 2011, March, Feb, .


I too like the '.' in place of self :)  However, I don't like _ as line 
continuation :(   Life is tough, eh ??


It also looks like there is work to have it run in a JVM.  I presume 
that means that no .NET/Mono framework is required ??


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


Re: Python 3.10 Fizzbuzz

2023-03-01 Thread Simon Ward

On Tue, Feb 28, 2023 at 04:05:19PM -0500, avi.e.gr...@gmail.com wrote:
Is it rude to name something "black" to make it hard for some of us to 
remind them of the rules or claim that our personal style is so often 
the opposite that it should be called "white" or at least shade of 
gray?


The usual kidding aside, I have no idea what it was called black but in 
all seriousness this is not a black and white issue. Opinions may 
differ when a language provides many valid options on how to write 
code. If someone wants to standardize and impose some decisions, fine. 
But other may choose their own variant and take their chances.


https://pypi.org/project/grey/
https://pypi.org/project/white/
https://pypi.org/project/blue/
https://pypi.org/project/oitnb/

:o

It amuses me that opinionated formatter, with very little 
configurability by design, in the face of differing opinions just 
results in forks or wrappers that modify the behaviours that might 
otherwise have been configuration options.


Simon
--
https://mail.python.org/mailman/listinfo/python-list


Re: Baffled by readline module

2023-03-10 Thread Simon Ward

On Fri, Mar 10, 2023 at 06:37:56AM -0800, Grant Edwards wrote:

On 2023-03-10, Weatherby,Gerard  wrote:
I'll have to remember that one. It doesn't really fit my current use
case, but there are others where it would work nicely.

However, cmd.Cmd does not provide command recall and
editing. According to the page above, that's provided by the readline
module


There is also prompt_toolkit[1] for even more fancy command‐line 
handling. The documentation even states it “can be a very advanced pure 
Python replacement for GNU readline, but it can also be used for 
building full screen applications.” (It doesn’t depend on readline or 
libedit.) It’s used by IPython for its history, editing, and completion 
features. If cmd with readline is overkill for your use case then this 
is even more so, but I thought it worth a mention.


Simon
--
https://mail.python.org/mailman/listinfo/python-list


Re: Distributing program for Linux

2023-03-14 Thread Simon Ward

On Tue, Mar 14, 2023 at 04:43:14PM +0100, Loris Bennett wrote:

If I write a system program which has Python >= 3.y as a dependency,
what are the options for someone whose Linux distribution provides
Python 3.x, where x < y?


The docs suggest creating your own package or building and installing 
from source:

https://docs.python.org/3/using/unix.html

To install from source, use ‘make altinstall’ (instead of ‘make 
install’) to avoid shadowing your system Python version. The alternative 
interpreter should be qualified with . version, e.g. 
python3.11


Depending on the package manager used by the distribution, 
‘checkinstall’ could be used to build from source and install as a 
package without rolling your own.

https://wiki.debian.org/CheckInstall

On Ubuntu check out the deadsnakes PPA:
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa

Or use python-build from pyenv to install to a custom location:
https://github.com/pyenv/pyenv/wiki/Common-build-problems#installing-a-system-wide-python

Simon
--
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing a plug-in mechanism

2023-03-16 Thread Simon Ward

On Thu, Mar 16, 2023 at 07:45:18AM +1300, dn via Python-list wrote:
There is a PyPi library called pluggy (not used it). I've used informal 
approaches using an ABC as a framework/reminder (see @George's 
response).


typing.Protocol is also useful here as the plugin interface can be 
defined separately not requiring inheriting from an ABC.


Simon
--
A complex system that works is invariably found to have evolved from a
simple system that works.—John Gall
--
https://mail.python.org/mailman/listinfo/python-list


Re: Friday finking: IDE 'macro expansions'

2023-03-17 Thread Simon Ward

On Fri, Mar 17, 2023 at 11:55:38AM +1300, dn via Python-list wrote:
Do you make use of your IDE's expansionist tendencies, and if-so, which 
ones?


Unix (well, GNU/Linux) is my IDE ;)

Simon
--
https://mail.python.org/mailman/listinfo/python-list


Re: Friday finking: IDE 'macro expansions'

2023-03-17 Thread Simon Ward

On Fri, Mar 17, 2023 at 02:05:50PM +0100, Roel Schroeven wrote:
Even better than simply highlighting is (IMO) a thing called "Rainbow 
Braces" or "Bracket Pair Colorization" I recently learned about: both 
braces of a matching pair get the same color, while other pairs get 
other colors. I have to say I like it quite a lot. It's in VS Code 
these days; possible there are implementations or extensions for other 
editors and IDEs as well.


VS Code also supports ‘semantic highlighting’: Instead of simply 
highlighting syntax, highlight the same identifiers in the same colours, 
with the aim of helping you see them through the flow of the code.


Simon
--
A complex system that works is invariably found to have evolved from a
simple system that works.—John Gall
--
https://mail.python.org/mailman/listinfo/python-list


ipaddress (was: Re: for a 'good python')

2023-04-21 Thread Simon Ward

On Thu, Apr 13, 2023 at 04:00:59PM +0100, Barry wrote:
Ipaddress was developed outside of the std lib and later added i 
recall.


I used it prior to it being in the standard library:
https://pypi.org/project/ipaddr/

Simon

--
A complex system that works is invariably found to have evolved from a
simple system that works.—John Gall
--
https://mail.python.org/mailman/listinfo/python-list


need help with a ctypes project for PyPI

2021-02-03 Thread Simon Zhang
Hi,

I have created a ctypes project as in the following link's first answer:
https://stackoverflow.com/questions/42585210/extending-setuptools-extension-to-use-cmake-in-setup-py

Since my machine's gcc is too high version or something, I used the docker
image located here:
https://quay.io/repository/pypa/manylinux2014_x86_64
to compile the copied .whl file. I ran auditwheel repair on my whl file
then copied it back to my local machine without complaints.

I'm not sure I understand the subsequent process I need to do with PyPI.

If I copy the manylinux2014 wheel back to my local machine  (into the dist
folder) and run the command:

python3 -m twine upload --repository testpypi dist/*

following the instructions from:
https://packaging.python.org/tutorials/packaging-projects/

when I pip3 install spamplusplus (this is the name I gave my test project)
https://test.pypi.org/project/spamplusplus/

I get that the CMakeLists.txt file is not existent. I used the same
setup.py file given in the link:
https://stackoverflow.com/questions/42585210/extending-setuptools-extension-to-use-cmake-in-setup-py

However I get the error that CMakeLists.txt file is not being uploaded?

 cmake /tmp/pip-build-6ff9ifuu/spamplusplus
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-build-6ff9ifuu/spamplusplus/build/lib.linux-x86_64-3.6/spamplusplus
-DCMAKE_BUILD_TYPE=Release
  CMake Error: The source directory
"/tmp/pip-build-6ff9ifuu/spamplusplus" does not appear to contain
CMakeLists.txt.

I think this is something basic involving paths but could be more involved.

Can anyone help!!

Thanks,

Simon Zhang
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python installer hangs in Windows 7

2018-03-15 Thread simon . wonng
On Monday, December 4, 2017 at 12:44:48 PM UTC-8, christian...@gmail.com wrote:
> Same with me, except that I tried to install Python 3.6.3. Unchecking 
> "Install launcher for all users" helped, however.

This worked for me, thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Pyscripter Issues

2016-03-31 Thread Simon Martin
Hi

I have been having issues trying to run python 3.5.1 and pyscripter 2.6. Giving 
the error message that it cannot initialize python.

I have tried to re-install multiple versions of both python and pyscripter to 
no avail. Any advice?

Thanks

Simon

Sent from Mail for Windows 10

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


Rate limiting a web crawler

2018-12-26 Thread Simon Connah

Hi,

I want to build a simple web crawler. I know how I am going to do it but 
I have one problem.


Obviously I don't want to negatively impact any of the websites that I 
am crawling so I want to implement some form of rate limiting of HTTP 
requests to specific domain names.


What I'd like is some form of timer which calls a piece of code say 
every 5 seconds or something and that code is what goes off and crawls 
the website.


I'm just not sure on the best way to call code based on a timer.

Could anyone offer some advice on the best way to do this? It will be 
running on Linux and using the python-daemon library to run it as a 
service and will be using at least Python 3.6.


Thanks for any help.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Rate limiting a web crawler

2018-12-26 Thread Simon Connah

On 26/12/2018 18:30, Richard Damon wrote:

On 12/26/18 10:35 AM, Simon Connah wrote:

Hi,

I want to build a simple web crawler. I know how I am going to do it
but I have one problem.

Obviously I don't want to negatively impact any of the websites that I
am crawling so I want to implement some form of rate limiting of HTTP
requests to specific domain names.

What I'd like is some form of timer which calls a piece of code say
every 5 seconds or something and that code is what goes off and crawls
the website.

I'm just not sure on the best way to call code based on a timer.

Could anyone offer some advice on the best way to do this? It will be
running on Linux and using the python-daemon library to run it as a
service and will be using at least Python 3.6.

Thanks for any help.


One big piece of information that would help in replies would be an
indication of scale. Is you application crawling just a few sites, so
that you need to pause between accesses to keep the hit rate down, or
are you calling a number of sites, so that if you are going to delay
crawling a page from one site, you can go off and crawl another in the
mean time?



Sorry. I should have stated that.

This is for a minimum viable product so crawling say two or three domain 
names would be enough to start with but I'd want to grow in the future.


I'm building this on AWS and my idea was to have each web crawler 
instance query a database (DynamoDB) and get say 10 URLs and if they 
hadn't be crawled in the previous say 12 to 24 hours then recrawl them. 
If they have been crawled in the last 12 to 24 hours then skip that URL. 
Once a URL has been crawled I would then save the crawl date and time in 
the database.


Doing it that way I could skip the whole timing thing on the daemon end 
and just use database queries to control whether a URL is crawled or 
not. Of course that would mean that one web crawler would have to "lock" 
a domain name so that multiple instances do not query the same domain 
name in parallel which would be bad.

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


Re: Rate limiting a web crawler

2018-12-26 Thread Simon Connah

On 26/12/2018 19:04, Terry Reedy wrote:

On 12/26/2018 10:35 AM, Simon Connah wrote:

Hi,

I want to build a simple web crawler. I know how I am going to do it 
but I have one problem.


Obviously I don't want to negatively impact any of the websites that I 
am crawling so I want to implement some form of rate limiting of HTTP 
requests to specific domain names.


What I'd like is some form of timer which calls a piece of code say 
every 5 seconds or something and that code is what goes off and crawls 
the website.


I'm just not sure on the best way to call code based on a timer.

Could anyone offer some advice on the best way to do this? It will be 
running on Linux and using the python-daemon library to run it as a 
service and will be using at least Python 3.6.


You can use asyncio to make repeated non-blocking requests to a web site 
at timed intervals and to work with multiple websites at once.  You can 
do the same with tkinter except that requests would block until a 
response unless you implemented your own polling.




Thank you. I'll look into asynio.
--
https://mail.python.org/mailman/listinfo/python-list


asyncio Question

2019-03-14 Thread Simon Connah

Hi,

Hopefully this isn't a stupid question. For the record I am using Python 
3.7 on Ubuntu Linux.


I've decided to use asyncio to write a TCP network server using Streams 
and asyncio.start_server(). I can handle that part of it without many 
problems as the documentation is pretty good. I have one problem though 
that I am not sure how to solve. Each request to the server will be a 
JSON string and one of the components of the JSON string will be the 
latitude and longitude. What I want to do is associate a latitude and 
longitude with the client connection. Every time the latitude and 
longitude changes then the two values will be updated. There will only 
ever be one latitude and longitude for each client connection (since a 
device can only ever be in one place). I'm just not sure what the best 
method to achieve this would be when using asyncio.start_server().


Any help would be greatly appreciated.

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


Python WebApp where Python runs on the client's machine using Pyodide

2019-05-21 Thread Simon Biggs
It's still a massive work in progress, but I though people here might be
interested in the progress made thus far:
https://app.pymedphys.com/

It is a file processing application. It has input files and output files.
Users select input files from their computer, select a script to run (or
edit a script to create their own) and then it produces the output files
which can be downloaded.
At the moment when Python is running the user interface freezes but to fix
that I am told I just need to get my head around web workers (
https://github.com/iodide-project/pyodide/issues/435#issuecomment-493928297
).

It's been quite fun!

Also, adding new scripts to the web app should be as simple as following
the steps laid out over here:
https://github.com/pymedphys/pymedphys/issues/312

I'm keen for feedback, please let me know what you think!

I'll likely post this again in the near future once I fix up the freezing
and I have also provided a few more example scripts.

Cheers,
Simon
-- 
https://mail.python.org/mailman/listinfo/python-list


Would you be interested in this Python open source project?

2019-10-08 Thread Simon Connah
I'm posting this message as a way to gauge interest in the project and 
to see if it is worth moving forward with. There are probably hundreds 
of CI/CD tools out there and many more general devops tools but what I 
want to build is a CI/CD tool that ONLY supports Python 3.6 or greater 
and only runs on one Linux distribution (my preference is Ubuntu). This 
way configuration would be much more simple than the vast majority of 
devops tools which try to support every programming language that is 
popular (or so it seems) on many different Linux distributions and even 
Windows and macOS.


My theory is that if you limit the devops tool to a very limited 
subsection of the available options the system will be easier to 
configure for users, more stable, easier to patch bugs in and generally 
just be a better all around things for Python developers.


I'd love to hear some feedback on the idea.

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


Re: Would you be interested in this Python open source project?

2019-10-09 Thread Simon Connah


On 08/10/2019 13:17, Rhodri James wrote:

On 08/10/2019 11:22, Simon Connah wrote:
I'm posting this message as a way to gauge interest in the project 
and to see if it is worth moving forward with. There are probably 
hundreds of CI/CD tools out there and many more general devops tools 
but what I want to build is a CI/CD tool that ONLY supports Python 
3.6 or greater and only runs on one Linux distribution (my preference 
is Ubuntu). This way configuration would be much more simple than the 
vast majority of devops tools which try to support every programming 
language that is popular (or so it seems) on many different Linux 
distributions and even Windows and macOS.


My theory is that if you limit the devops tool to a very limited 
subsection of the available options the system will be easier to 
configure for users, more stable, easier to patch bugs in and 
generally just be a better all around things for Python developers.


I'd love to hear some feedback on the idea.



I think your reasoning is sound.  I probably wouldn't make a lot of 
use of it, but I live in Embedded Systems land where it's notoriously 
hard to do CI off the target silicon.  Other people living in more 
tractable problem spaces will probably be more enthusiastic.


Thank you for your reply. I'll keep working on this project and see how 
it turns out. I'm quite excited about it actually as I find that most 
CI/CD systems are so complicated when it comes to simple tasks. I want 
to build something where the developer spends 10 minutes reading the 
documentation and then can do 90% of what he needs with no more hand 
holding or Googling.


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


Re: Would you be interested in this Python open source project?

2019-10-09 Thread Simon Connah



On 08/10/2019 15:05, Bill Deegan wrote:

You might just consider working with the BuildBot project to add support
for lighter weight build workers.
Re-Re-Re-inventing the wheel is almost always wasted effort.


Buildbot looks good. I'll check to make sure its open source license is 
compatible with the Affero General Public License version 3. On the 
other hand I do have a desire to build something similar myself just to 
get the hang of things like this. Thank you for your reply.



On Tue, Oct 8, 2019 at 8:33 AM Rhodri James  wrote:


On 08/10/2019 11:22, Simon Connah wrote:

I'm posting this message as a way to gauge interest in the project and
to see if it is worth moving forward with. There are probably hundreds
of CI/CD tools out there and many more general devops tools but what I
want to build is a CI/CD tool that ONLY supports Python 3.6 or greater
and only runs on one Linux distribution (my preference is Ubuntu). This
way configuration would be much more simple than the vast majority of
devops tools which try to support every programming language that is
popular (or so it seems) on many different Linux distributions and even
Windows and macOS.

My theory is that if you limit the devops tool to a very limited
subsection of the available options the system will be easier to
configure for users, more stable, easier to patch bugs in and generally
just be a better all around things for Python developers.

I'd love to hear some feedback on the idea.


I think your reasoning is sound.  I probably wouldn't make a lot of use
of it, but I live in Embedded Systems land where it's notoriously hard
to do CI off the target silicon.  Other people living in more tractable
problem spaces will probably be more enthusiastic.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


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


Re: Accessing class variable at class creation time

2005-09-23 Thread Simon Percivall
It might be that I'm complicating something easy here, but I
immediately thought of

import sys

class A:
X = 2
def F():
f = sys._getframe().f_back
print f.f_locals["X"]
F()

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


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, could ildg <[EMAIL PROTECTED]> wrote:
> Python is wonderful except that it has no real private and protected
> properties and methods.
> Every py object has dict so that you can easily find what fields and methods
> an obj has,
> this is very convenient, but because of this, py is very hard to support
> real private and
> protected?

My convention, attributes with names prefixed with a single underscore
are private. There's nothing to stop anyone using these, but, well, if
you take the back off the radio, the warranty is void.

> If private and protected is supported, python will be perfect.

If *real* private and protected are *enforced*, Python will be the
poorer for it. See
<http://groups.google.com/group/comp.lang.python/msg/b977ed1312e10b21>.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Simon Brunning <[EMAIL PROTECTED]> wrote:
> My convention, attributes with names prefixed with a single underscore
> are private. There's nothing to stop anyone using these, but, well, if
> you take the back off the radio, the warranty is void.

*By* convention, not *my* convention!

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Tony Meyer <[EMAIL PROTECTED]> wrote:
> I'm not sure why I haven't seen this mentioned yet, but a leading
> double-underscore does really make a member private:

I thought about it, but I didn't mention it in the end because this
feature ("name mangling") isn't intended as a mechanism for making
things private - it's intended to prevent namespace clashes when doing
multiple inheritance. It can be used to make things private, true, but
that's abusing the feature, just as using __slots__ as a way of
"declaring variables" is an abuse - (__slots__ is a memory
optimisation feature).

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 28 Sep 2005 05:06:50 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > Do you know any language that has real private and protected attributes?
>
> Java?

Oh, there are ways around private and protected, even in Java. CGLIB
spings to mind. But you'd be wise to follow the rules, especially if
you work in a team.

When writing Java, I write Java. When writing Python, I write Python.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> > If *real* private and protected are *enforced*, Python will be the
> > poorer for it. See
> > <http://groups.google.com/group/comp.lang.python/msg/b977ed1312e10b21>.
>
> That's a wonderful, if long, essay.

That's the Martellibot for you. Never use a word where a paragraph
with explanatory footnotes will do.

Sigh. I miss him on c.l.py.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 28 Sep 2005 05:35:25 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> I don't see anything on the CGLIB web page (in about 1 minute of
> looking) that says it can get around private and protected.  It looks
> like something that disassembles class files and reassembles them into
> new classes from them with additional interfaces.  That's a lot
> different than being able to reach into an already-existing class
> instance and get at its private variables.

I've never directly used CGLIB myself, but I do use JMock and
Hibernate, and AFAIK both use CGLIB to modify private and protected
members. I could certainly be wrong, though. Anyway, this is getting a
bit OT...

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Simon Brunning
On 9/28/05, Tony Meyer <[EMAIL PROTECTED]> wrote:
> That's not what the documentation says:

So, either the docs are wrong, or I am. You be the judge. 

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-29 Thread Simon Brunning
On 9/29/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> What if the access to that variable was forbidden for reasons you never
> foresaw? What if the class author decide to remove the variable in the next
> version of the class, because it's not an interface, but only a part of the
> class implementation?

Then your code breaks. You can't say you weren't warned.

But if too much is made private, chances are you could never get your
code working in the first place. This has happened to me several times
when using 3rd party Java components. Serves us right for using closed
source libraries, I suppose, but that wasn't my decision.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A rather unpythonic way of doing things

2005-09-29 Thread Simon Brunning
On 9/29/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> "fraca7" wrote:
>
> > print ''.join(map(lambda x: chrord(x) - ord('a')) + 13) % 26) + 
> > ord('a')), 'yvfc'))
>
> that's spelled
>
> print "yvfc".decode("rot-13")
>
> or, if you prefer,
>
> print "yvfc".encode("rot-13")
>
> , in contemporary python.

I'm not sure that being more comprehensible is considered a virtue in
this thread, /F. ;-)

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Will python never intend to support private, protected and public?

2005-09-29 Thread Simon Brunning
On 9/29/05, could ildg <[EMAIL PROTECTED]> wrote:
> **Encapsulation** is one of the 3 basic characteristics of OOP.

Pyhton has encapsulation. On objetcts members are encapsulated in a
namespace all of its own. You can't change these by accident.

> Every programmer is  just a human being, but not God. Our life is limited,
> our time is limited, so we need to use convenient tools to save time.
> Private variables guarantee that we will never make stupid mistakes

Private variables prevent the developer of the *client* of a class
from making a small subset of all possible stupid mistakes. But if the
developer of the classitself is mistaken in marking a variable as
private, and if the language enforces this, then there is nothing at
all that the client can do to fix it. Why should the developer of the
class be more likely to be god-like than the user of the class? This
has happened to me more than once.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python <=> Excel question

2005-09-30 Thread Simon Brunning
On 9/30/05, Gerry Blais <[EMAIL PROTECTED]> wrote:
> Finally, how can I, in Python, make a .txt version of a Word document?

http://www.brunningonline.net/simon/blog/archives/001299.html

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bug or feature?

2005-10-05 Thread Simon Percivall
Python.org General FAQ 1.4.21: Why are default values shared between
objects?
(http://www.python.org/doc/faq/general.html#why-are-default-values-shared-between-objects)

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


Re: updating local()

2005-10-06 Thread Simon Brunning
On 6 Oct 2005 05:55:14 -0700, Flavio <[EMAIL PROTECTED]> wrote:
> Now what would you do if you wanted to pass a lot of variables (like a
> thousand) to a function and did not wanted the declare them in the
> function header?

I'd think twice. If on reflection I decided I really wanted to do it,
I'd pass them all in a dictionary.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: updating local()

2005-10-06 Thread Simon Brunning
On 6 Oct 2005 07:04:08 -0700, Flavio <[EMAIL PROTECTED]> wrote:
> I know I could pass these variables around as:
>
> def some_function(**variables):
> ...
>
> some_function(**variables)
>
> but its a pain in the neck to have to refer to them as
> variables['whatever']...
>
> dont you think?

Err, no, not really. ;-)

If you'd prfefer to access them like this:

variables.whatever

Check out the Bunch class here -
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308>.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python interpreter bug

2005-10-07 Thread Simon Percivall
Why would it be a bug? You've made it so that every instance of OBJ is
equal to every other instance of OBJ. The behaviour is as expected.

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


  1   2   3   4   5   6   7   8   9   10   >