[issue34823] libffi detection doesn’t work in my setup

2018-12-25 Thread Daniel Fetchinson


Daniel Fetchinson  added the comment:

It seems there is a way to fix this:

https://mail.python.org/pipermail/python-list/2018-December/738568.html

LDFLAGS=`pkg-config --libs-only-L libffi` ./configure

Would be nice to document this or make the build system find the libraries and 
headers in a simpler way.

--

___
Python tracker 
<https://bugs.python.org/issue34823>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: building 3.7.1 from source, _ctypes and libffi troubles

2018-12-25 Thread Fetchinson . via Python-list
>> And as far as I know pkg-config is used by python's configure script
>> so everything should be fine. I also set
>> LD_LIBRARY_PATH=/home/fetch/opt/lib:/home/fetch/opt/lib64 and also
>> C_INCLUDE_PATH=/home/fetch/opt/include
>
> I looked into this a little. I found that setting C_INCLUDE_PATH as you
> did disables finding libffi headers since pkg-config prints nothing with
> pkg-config --cflags libffi then and it seems the headers are found with
> pkg-config.

This didn't actually occur for me, I had C_INCLUDE_PATH set and your
second suggestion (see below) worked.

> As for the libraries, detect_modules() in setup.py wants to find extra
> library directories from the generated makefile so you need to make sure
> they actually go in there, like this for example:
>
> LDFLAGS=`pkg-config --libs-only-L libffi` ./configure
>
> Then you'll have CONFIGURE_LDFLAGS and PY_LDFLAGS set in the generated
> makefile and setup.py will pick up the directory from there.

Thanks a lot! This indeed worked, now _ctypes compiles no problemlo!

Cheers,
Daniel


> Anyways, hope it helps. This worked for me on Ubuntu 16.04.5 LTS.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34823] libffi detection doesn’t work in my setup

2018-12-22 Thread Daniel Fetchinson


Daniel Fetchinson  added the comment:

I have the exact same issue, trying to compile 3.7.1 with a custom libffi 
location. Note that I must build libffi from source and can't install binaries 
provided by my distro, I believe this is the origin of the problem. Probably 
the python build system checks for libffi in some "standard" locations and it 
doesn't seem possible to use libffi from a custom location.

This is where libffi gets installed after passing --prefix=$HOME/opt to 
./configure:


$HOME/opt/lib64/libffi.so.6.0.4
$HOME/opt/lib64/libffi.a
$HOME/opt/lib64/libffi.la
$HOME/opt/lib64/libffi.so.6
$HOME/opt/lib64/libffi.so
$HOME/opt/lib/pkgconfig/libffi.pc
$HOME/opt/lib/libffi-3.2.1/include/ffi.h
$HOME/opt/lib/libffi-3.2.1/include/ffitarget.h
$HOME/opt/share/info/libffi.info

In any case, just to be sure, I've copied the header files to

$HOME/opt/include/ffi.h
$HOME/opt/include/ffitarget.h

And pkg-config works:

[fetch@fetch opt]$ pkg-config --libs libffi
-L/home/fetch/opt/lib/../lib64 -lffi

[fetch@fetch opt]$ pkg-config --cflags libffi
-I/home/fetch/opt/lib/libffi-3.2.1/include

These environment variables are also set:

LD_LIBRARY_PATH=/home/fetch/opt/lib:/home/fetch/opt/lib64

C_INCLUDE_PATH=/home/fetch/opt/include

And still _ctypes fails to build (but python itself (minus _ctypes) compiles 
successful and works perfectly well).

--
nosy: +fetchinson

__
Python tracker 
<https://bugs.python.org/issue34823>
__
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34823] libffi detection doesn’t work in my setup

2018-12-22 Thread Daniel Fetchinson


Daniel Fetchinson  added the comment:

It would be really great if this could be sorted out because at the moment this 
bug prevents me from using numpy/scipy with python 3.7.1 (they need _ctypes).

--

__
Python tracker 
<https://bugs.python.org/issue34823>
__
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: building 3.7.1 from source, _ctypes and libffi troubles

2018-12-20 Thread Fetchinson . via Python-list
On 12/20/18, Fetchinson .  wrote:
> Hi all, I'm trying to build 3.7.1 from source and having trouble with
> libffi and _ctypes. I'm on linux and have installed libffi also from
> source to a custom location:
>
> $HOME/opt/lib64/libffi.so.6.0.4
> $HOME/opt/lib64/libffi.a
> $HOME/opt/lib64/libffi.la
> $HOME/opt/lib64/libffi.so.6
> $HOME/opt/lib64/libffi.so
> $HOME/opt/lib/pkgconfig/libffi.pc
> $HOME/opt/lib/libffi-3.2.1/include/ffi.h
> $HOME/opt/lib/libffi-3.2.1/include/ffitarget.h
> $HOME/opt/share/info/libffi.info
>
> I have no idea why the installation is somewhat scattered, these are
> the default locations that were created by
>
> ./configure --prefix=$HOME/opt
>
> of the source libffi.
>
> In any case, just to be sure, I've copied the header files to
>
> $HOME/opt/include/ffi.h
> $HOME/opt/include/ffitarget.h
>
> Looks like pkg-config works as intended:
>
> [fetch@fetch opt]$ pkg-config --libs libffi
> -L/home/fetch/opt/lib/../lib64 -lffi
>
> [fetch@fetch opt]$ pkg-config --cflags libffi
> -I/home/fetch/opt/lib/libffi-3.2.1/include
>
> And as far as I know pkg-config is used by python's configure script
> so everything should be fine. I also set
> LD_LIBRARY_PATH=/home/fetch/opt/lib:/home/fetch/opt/lib64 and also
> C_INCLUDE_PATH=/home/fetch/opt/include
>
> And still I get
>
> Failed to build these modules:
> _ctypes
>
> from make when I try to build python 3.7.1 Also tried adding
> --with-system-ffi to ./configure but that didn't help either.
>
> Does anyone have an idea what's wrong? I've seen some related bug reports,
> e.g.
>
> https://bugs.python.org/issue35170
>
> but these were typically solved by the OP installing libffi from the
> repository of his/her distro. Note that in my case I must compile
> libffi from source.
>
> Any ideas?
>
> Thanks a lot,
> Daniel

I just found a bug report from the end of September detailing the
exact same problem:

https://bugs.python.org/issue34823

It's still open with no comments at all :(

Is there a chance this will be fixed?

Summarizing: the problem is that python can't be build on linux from
source if libffi is installed to non-standard directories.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


building 3.7.1 from source, _ctypes and libffi troubles

2018-12-20 Thread Fetchinson . via Python-list
Hi all, I'm trying to build 3.7.1 from source and having trouble with
libffi and _ctypes. I'm on linux and have installed libffi also from
source to a custom location:

$HOME/opt/lib64/libffi.so.6.0.4
$HOME/opt/lib64/libffi.a
$HOME/opt/lib64/libffi.la
$HOME/opt/lib64/libffi.so.6
$HOME/opt/lib64/libffi.so
$HOME/opt/lib/pkgconfig/libffi.pc
$HOME/opt/lib/libffi-3.2.1/include/ffi.h
$HOME/opt/lib/libffi-3.2.1/include/ffitarget.h
$HOME/opt/share/info/libffi.info

I have no idea why the installation is somewhat scattered, these are
the default locations that were created by

./configure --prefix=$HOME/opt

of the source libffi.

In any case, just to be sure, I've copied the header files to

$HOME/opt/include/ffi.h
$HOME/opt/include/ffitarget.h

Looks like pkg-config works as intended:

[fetch@fetch opt]$ pkg-config --libs libffi
-L/home/fetch/opt/lib/../lib64 -lffi

[fetch@fetch opt]$ pkg-config --cflags libffi
-I/home/fetch/opt/lib/libffi-3.2.1/include

And as far as I know pkg-config is used by python's configure script
so everything should be fine. I also set
LD_LIBRARY_PATH=/home/fetch/opt/lib:/home/fetch/opt/lib64 and also
C_INCLUDE_PATH=/home/fetch/opt/include

And still I get

Failed to build these modules:
_ctypes

from make when I try to build python 3.7.1 Also tried adding
--with-system-ffi to ./configure but that didn't help either.

Does anyone have an idea what's wrong? I've seen some related bug reports, e.g.

https://bugs.python.org/issue35170

but these were typically solved by the OP installing libffi from the
repository of his/her distro. Note that in my case I must compile
libffi from source.

Any ideas?

Thanks a lot,
Daniel





-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: So apparently I've been banned from this list

2018-10-01 Thread Fetchinson . via Python-list
On 10/1/18, Roel Schroeven  wrote:
> jkn schreef op 1/10/2018 om 20:25:
>> On Monday, October 1, 2018 at 6:57:30 PM UTC+1, Ethan Furman wrote:
>>> On 09/30/2018 09:30 AM, Steven D'Aprano wrote:
>>>
 Notwithstanding Ethan's comment about having posted the suspension
 notice
 on the list, I see no sign that he actually did so.
>>>
>>> My apologies to you and the list.  I did indeed only send the notice to
>>> the other moderators.
>>>
>>> I have updated the filter that should be catching your posts, so
>>> hopefully the suspension is now working properly.  Since you did choose
>>> to ignore the ban, the two-month period restarts now.
>>>
>>
>> As a reader of /occasional contributor to, this newsgroup (via GG,
>> admittedly)
>> since around the year 2000, I for one am mightily unimpressed with this.
>> There's a lot of heavy-handedness going around.
>>
>> And then ... you make a mistake, and then restart the ban?? Sheesh, where
>> has
>> happened to the the grown-up behaviour that c.l.python has always had?
>> That has been one of its hallmarks for the past nearly twenty years.
>>
>> I'm not going to go as far as to agree with anything RR says on the matter
>> -
>> but c'mon guys, lighten up.
>
> Yeah I don't understand this neither.
>
> I'm not very active here, but I've been lurking for years. In my eyes
> Steven has always been active and helpful. Now he has *once* been a
> *tiny bit* rude, and he's banned for that?
>
> As far as I can see the moderators do a pretty good job overall, but
> this decision is ... weird.

+1

Steven has been around for a long time, after a quick search it seems
for at least 15 years, I mean on python-list. He has consistently been
helpful and has dedicated an amazing number of man hours to altruistic
help of fellow python users, beginners, experts, etc.

I'm totally amazed by this decision to ban him. The official
explanation has referenced 2 potentially mildly problematic posts.

I guess the moderators do have and should have the power to ban people
but we all have the right to criticise these bans on a case by case
basis. I'm not implying that Ethan and the moderators who were
involved in the ban are doing a bad job in general, but in this
particular case it does seem hyper excessive.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: compiling 3.7.0 from source with custom libffi path

2018-09-24 Thread Fetchinson . via Python-list
On 9/24/18, Thomas Jollans  wrote:
> On 2018-09-24 16:30, Fetchinson . via Python-list wrote:
>> [fetch@fetch]$ grep LIBFFI_INCLUDE Makefile
>> LIBFFI_INCLUDEDIR=  /opt/custom/lib/libffi-3.2.1/include
>>
>> So I'd say everything should work but it doesn't, I reran ./configure
>> and also make of course.
>
> I'm confused. ./configure succeeds? Then where's the error?

Yes, ./configure succeeds, also make succeeds in general, so it
produces a usable python executable but _ctypes is not compiled so
_ctypes is not usable and can not be imported, libffi is only needed
for _ctypes AFAIK. The error, or better said INFO message, comes from
make:

INFO: Could not locate ffi libs and/or headers

Failed to build these modules:
_ctypes

But nevertheless make install also succeeds, the only thing is that
_ctypes does not work.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: compiling 3.7.0 from source with custom libffi path

2018-09-24 Thread Fetchinson . via Python-list
On 9/24/18, Thomas Jollans  wrote:
> On 2018-09-24 14:14, Fetchinson . via Python-list wrote:
>>>> I'm trying to compile python 3.7.0 from source with a custom libffi
>>>> path and the compiler/linker doesn't seem to pick up the right
>>>> version. The system libffi doesn't have the development files so I've
>>>> installed the latest libffi (also from source) to /opt/custom but
>>>> still I get
>>>>
>>>> INFO: Could not locate ffi libs and/or headers
>>>
>>> Apparently the configure script uses pkg-config to locate libffi.[1] You
>>> should be able to get it to find your libffi by setting PKG_CONFIG_PATH
>>> appropriately (probably to "/opt/custom/lib/pkgconfig" ?)
>>>
>>> [1]: https://github.com/python/cpython/blob/v3.7.0/configure.ac#L2936
>>
>> Thanks, tried it, but still no luck, exact same error message.
>
> Is there a .pc file for libffi? Can you run pkg-config manually, to
> check if it works, and finds libffi in your environment?

Yes, there is a .pc for libffi and if I first

export PKG_CONFIG_PATH=/opt/custom

then pkg-config finds the necessary include path:

[fetch@fetch]$ pkg-config libffi --cflags-only-I
-I/opt/custom/lib/libffi-3.2.1/include

And of course this path is correct:

[fetch@fetch]$ ls /opt/custom/lib/libffi-3.2.1/include
ffi.h  ffitarget.h

And also the configure script correctly creates the Makefile:

[fetch@fetch]$ grep LIBFFI_INCLUDE Makefile
LIBFFI_INCLUDEDIR=  /opt/custom/lib/libffi-3.2.1/include

So I'd say everything should work but it doesn't, I reran ./configure
and also make of course.

Cheers,
Daniel











>>
>> Cheers,
>> Daniel
>>
>>
>>
>>>>
>>>> Failed to build these modules:
>>>> _ctypes
>>>>
>>>> Although I compile python with --prefix=/opt/custom because that's the
>>>> location I'd like to install it too. So how do I tell the build system
>>>> where to find my custom libffi?
>>>>
>>>> Cheers,
>>>> Daniel
>>>>
>>>>
>>>>
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: compiling 3.7.0 from source with custom libffi path

2018-09-24 Thread Fetchinson . via Python-list
>> I'm trying to compile python 3.7.0 from source with a custom libffi
>> path and the compiler/linker doesn't seem to pick up the right
>> version. The system libffi doesn't have the development files so I've
>> installed the latest libffi (also from source) to /opt/custom but
>> still I get
>>
>> INFO: Could not locate ffi libs and/or headers
>
> Apparently the configure script uses pkg-config to locate libffi.[1] You
> should be able to get it to find your libffi by setting PKG_CONFIG_PATH
> appropriately (probably to "/opt/custom/lib/pkgconfig" ?)
>
> [1]: https://github.com/python/cpython/blob/v3.7.0/configure.ac#L2936

Thanks, tried it, but still no luck, exact same error message.

Cheers,
Daniel



>>
>> Failed to build these modules:
>> _ctypes
>>
>> Although I compile python with --prefix=/opt/custom because that's the
>> location I'd like to install it too. So how do I tell the build system
>> where to find my custom libffi?
>>
>> Cheers,
>> Daniel
>>
>>
>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


compiling 3.7.0 from source with custom libffi path

2018-09-24 Thread Fetchinson . via Python-list
I'm trying to compile python 3.7.0 from source with a custom libffi
path and the compiler/linker doesn't seem to pick up the right
version. The system libffi doesn't have the development files so I've
installed the latest libffi (also from source) to /opt/custom but
still I get

INFO: Could not locate ffi libs and/or headers

Failed to build these modules:
_ctypes

Although I compile python with --prefix=/opt/custom because that's the
location I'd like to install it too. So how do I tell the build system
where to find my custom libffi?

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make python pick up my new-and-shiny openssl shared object

2018-08-08 Thread Fetchinson . via Python-list
On 8/8/18, Christian Heimes  wrote:
> On 2018-08-08 00:07, Fetchinson . via Python-list wrote:
>> The highest version of openssl available on my system is 1.0.0 which
>> is not good enough for pip these days (or github for that matter). So
>> I've installed 1.1.0 to a custom location /home/fetch/opt. But if I do
>>
>> import ssl
>> ssl.OPENSSL_VERSION
>>
>> it still shows me that it is using the system default 1.0.0. How do I
>> tell python to use /home/fetch/opt for the ssl module? Note that I
>> have /home/fetch/opt as the first entry in LD_LIBRARY_PATH. Also, I
>> know for a fact that I don't need to recompile python for this so
>> please don't suggest "just recompile python with the new openssl
>> library" as the solution :)
>
> Hi,
>
> first of all, you need to use the library directory for LD_LIBRARY_PATH.
> It's the directory that contains libssl*.so, probably
> /home/fetch/opt/lib or /home/fetch/opt/lib64.

Yes, you are right, thanks. But it still doesn't work, most probably
because of the reason you mention below.


> You may also have to recompile Python yourself. OpenSSL 1.0.2 is not
> ABI-compatible with OpenSSL 1.0.0. In case you want to use OpenSSL
> 1.1.0, you must update to a more recent version of Python, too. OpenSSL
> 1.1.0 support was added in 2.7.13.

Ach, you are right again! I thought openssl was fully backward
compatible, if not, then indeed I need to recompile, which I'll do
now.

Thanks a lot,
Daniel


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


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


How to make python pick up my new-and-shiny openssl shared object

2018-08-07 Thread Fetchinson . via Python-list
The highest version of openssl available on my system is 1.0.0 which
is not good enough for pip these days (or github for that matter). So
I've installed 1.1.0 to a custom location /home/fetch/opt. But if I do

import ssl
ssl.OPENSSL_VERSION

it still shows me that it is using the system default 1.0.0. How do I
tell python to use /home/fetch/opt for the ssl module? Note that I
have /home/fetch/opt as the first entry in LD_LIBRARY_PATH. Also, I
know for a fact that I don't need to recompile python for this so
please don't suggest "just recompile python with the new openssl
library" as the solution :)

By the way my python is 2.7.3.

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why does memory consumption keep growing?

2017-10-05 Thread Fetchinson . via Python-list
On 10/5/17, Chris Angelico <ros...@gmail.com> wrote:
> On Fri, Oct 6, 2017 at 8:06 AM, Fetchinson . via Python-list
> <python-list@python.org> wrote:
>> Hi folks,
>>
>> I have a rather simple program which cycles through a bunch of files,
>> does some operation on them, and then quits. There are 500 files
>> involved and each operation takes about 5-10 MB of memory. As you'll
>> see I tried to make every attempt at removing everything at the end of
>> each cycle so that memory consumption doesn't grow as the for loop
>> progresses, but it still does.
>>
>> import os
>>
>> for f in os.listdir( '.' ):
>>
>> x = [ ]
>>
>> for ( i, line ) in enumerate( open( f ) ):
>>
>> import mystuff
>> x.append( mystuff.expensive_stuff( line ) )
>> del mystuff
>>
>> import mystuff
>> mystuff.some_more_expensive_stuff( x )
>> del mystuff
>> del x
>>
>>
>> What can be the reason? I understand that mystuff might be leaky, but
>> if I delete it, doesn't that mean that whatever memory was allocated
>> is freed? Similary x is deleted so that can't possibly make the memory
>> consumption go up.
>
> You're not actually deleting anything. When you say "del x", all
> you're doing is removing the *name* x. Especially, deleting an
> imported module basically does nothing; it's a complete waste of time.
> Modules are kept in their own special cache.

Meaning that if mystuff has some leaky stuff in it, there is no way
for me to recover?

Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


why does memory consumption keep growing?

2017-10-05 Thread Fetchinson . via Python-list
Hi folks,

I have a rather simple program which cycles through a bunch of files,
does some operation on them, and then quits. There are 500 files
involved and each operation takes about 5-10 MB of memory. As you'll
see I tried to make every attempt at removing everything at the end of
each cycle so that memory consumption doesn't grow as the for loop
progresses, but it still does.

import os

for f in os.listdir( '.' ):

x = [ ]

for ( i, line ) in enumerate( open( f ) ):

import mystuff
x.append( mystuff.expensive_stuff( line ) )
del mystuff

import mystuff
mystuff.some_more_expensive_stuff( x )
del mystuff
del x


What can be the reason? I understand that mystuff might be leaky, but
if I delete it, doesn't that mean that whatever memory was allocated
is freed? Similary x is deleted so that can't possibly make the memory
consumption go up.

Any hint would be much appreciated,
Daniel




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: web facing static text db

2016-04-30 Thread Fetchinson . via Python-list
On 4/30/16, Gordon Levi <gordon@address.invalid> wrote:
> "Fetchinson ." <fetchin...@googlemail.com> wrote:
>
>>Hi folks,
>>
>>I have a very specific set of requirements for a task and was
>>wondering if anyone had good suggestions for the best set of tools:
>>
>>* store text documents (about 10 pages)
>>* the data set is static (i.e. only lookups are performed, no delete,
>>no edit, no addition)
>>* only one operation required: lookup of pages by matching words in them
>>* very simple web frontend for querying the words to be matched
>>* no authentication or authorization, frontend completely public
>>* deployment at webfaction
>>* deadline: yesterday :)
>>
>>Which web framework and db engine would you recommend?
>>
>>So far I'm familiar with turbogears but would be willing to learn
>>anything if sufficiently basic since my needs are pretty basic (I
>>think).
>>
>
> What do need that storing the documents in HTML format and Google
> Custom Search does not provide
> <https://support.google.com/customsearch/answer/2630969?hl=en>?

Wow! Thanks, I was not aware of that, sounds exactly what I need.

Thanks for all the other ideas too.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


web facing static text db

2016-04-29 Thread Fetchinson . via Python-list
Hi folks,

I have a very specific set of requirements for a task and was
wondering if anyone had good suggestions for the best set of tools:

* store text documents (about 10 pages)
* the data set is static (i.e. only lookups are performed, no delete,
no edit, no addition)
* only one operation required: lookup of pages by matching words in them
* very simple web frontend for querying the words to be matched
* no authentication or authorization, frontend completely public
* deployment at webfaction
* deadline: yesterday :)

Which web framework and db engine would you recommend?

So far I'm familiar with turbogears but would be willing to learn
anything if sufficiently basic since my needs are pretty basic (I
think).

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


smart scheduling for webapp tester

2015-05-12 Thread Fetchinson .
I'm looking into a robust solution for web application testing. While
selenium is great for the actual testing, I'm thinking of a scheduler
as the final piece in the pipeline. Let's say I have 4 websites that I
need to test periodically, A, B, C, D. I'd like to be able to define
things like run the tests for site A once a day or run the tests
for site B twice a day indefinitely or run the tests for site C
twice a week between now and 2 months from now or run the tests for
site C once a week between May 25 and June 21.

What would be the right scheduling tool for this? I know about the
standard tools like cron, sched, etc, and first even wrote one myself
(which became of course unmanagable after a short while :)) but was
hoping a more sophisticated tool is available.

Any ideas?
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: smart scheduling for webapp tester

2015-05-12 Thread Fetchinson .
On 5/12/15, Chris Angelico ros...@gmail.com wrote:
 On Tue, May 12, 2015 at 6:31 AM, Fetchinson . fetchin...@googlemail.com
 wrote:
 I'm looking into a robust solution for web application testing. While
 selenium is great for the actual testing, I'm thinking of a scheduler
 as the final piece in the pipeline. Let's say I have 4 websites that I
 need to test periodically, A, B, C, D. I'd like to be able to define
 things like run the tests for site A once a day or run the tests
 for site B twice a day indefinitely or run the tests for site C
 twice a week between now and 2 months from now or run the tests for
 site C once a week between May 25 and June 21.

 What would be the right scheduling tool for this? I know about the
 standard tools like cron, sched, etc, and first even wrote one myself
 (which became of course unmanagable after a short while :)) but was
 hoping a more sophisticated tool is available.

 I'm not sure what you're testing here, so I can't advise on specifics.
 If you're testing your application code, it shouldn't need any
 periodic testing at all, but if you're verifying an active database,
 it may not be necessary to involve your application. Actually, I tend
 never to verify database structures; anything that I would consider
 testing can get coded as a constraint, so it's enforced by the
 database before anything gets committed.

I'd like to test the application code. I do frequent live updates
which are mostly tested, but sometimes things go through which are
buggy and I don't detect them before pushing the change. I know, this
is bad practice, I should do my thorough testing first before going
live, but in my setup occasional bugs are not a big deal. So I find it
convenient to just push changes live fast before complicated and time
consuming testing (I do some tests of course but quick and dirty ones
only) and I'd like to catch all remaining bugs in an automated way by
periodically testing the live web application. Again, generally I
agree that this is bad practice, but my setup is an outlier and
certainly not generic (non-critical in house app with  10 users).

 But if you really do need things on a scheduler, I would advise using
 your OS's facilities (cron, or equivalent). No need to reinvent the
 wheel, unless you want it to do something different. I've written
 several simple task schedulers, but always because they do something
 fundamentally different from a basic one (like my Let Me Know, which
 checks my calendar and shows me a tick-down until the next significant
 event - 27 hours until I host Office Hours, at the moment). To simply
 invoke a program every 4:00 UTC, use cron and save yourself the
 trouble.

I might do this in the end and use cron indeed.

Cheers,
Daniel


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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Great Math Mystery

2015-04-17 Thread Fetchinson .
 In an altercation with the police, complying with their orders greatly
 increases your chances of survival.

 Ah, the definition of a police state: where ordinary people, whether
 breaking the law or not, are forced by fear of death to obey the police at
 all times, whether the police are acting legally or not.

I think you are grossly mischaracterizing that sentence of the OP. He
simply makes an observation: in an altercation with the police,
complying with their orders greatly increases your chances of
survival. Is this observation/statement true or false? Based on
empirical data from the past 50 years (in the US and elsewhere) I'd
say it's true by a huge margin.

The OP didn't make any value judgements on this statement whether he
advocates for compliance or not, whether he encourages the
establishment of a police state or not, whether he thinks compliance
is a good thing or not.

For all we know he might be a flaming anarchist with a keen sense of
observing empirical facts.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 conversion - embrace the pain

2015-03-15 Thread Fetchinson .
On 3/15/15, Mark Lawrence breamore...@yahoo.co.uk wrote:
 On 15/03/2015 19:05, John Nagle wrote:
 On 3/14/2015 1:00 AM, Marko Rauhamaa wrote:
 John Nagle na...@animats.com:
I'm approaching the end of converting a large system from Python 2
 to Python 3. Here's why you don't want to do this.

 A nice report, thanks. Shows that the slowness of Python 3 adoption is
 not only social inertia.
 Marko

  Thanks.

  Some of the bugs I listed are so easy to hit that I suspect those
 packages aren't used much.  Those bugs should have been found years
 ago.  Fixed, even.  I shouldn't be discovering them in 2015.

  I appreciate all the effort put in by developers in fixing these
 problems.  Python 3 is still a long way from being ready for prime
 time, though.

  John Nagle


 This https://python3wos.appspot.com/ says differently.

A package supporting python 3 is not equivalent to a package not
introducing new bugs in its python 3 version relative to python 2 and
is also not equivalent to a package working without issues on python
3.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


python on mobile mailing list

2015-01-28 Thread Fetchinson .
Hi all, the mobile-sig mailing list is alive:

https://mail.python.org/pipermail/mobile-sig/2015-January/thread.html

If you are interested in python on smart phones that's the place to go!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Sanity Proposal: Type Hinting Solution

2015-01-24 Thread Fetchinson .
On 1/24/15, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 Fetchinson . wrote:

 On 1/23/15, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 [...]
 Cobra is especially close to Python-like syntax, and supports unit tests
 as well:


 def sqroot(i as int) as float
 require
i  0
 ensure
result  0
 tests
assert sqroot(25) == 5.0
 body
 ...

 It would be nice to be able to include at least *some* tests right there
 in the code rather than in a separate file.

 I completely agree. A cobra-style type hinting implementation would
 satisfy everyone who doesn't want to make function signatures noisy
 (including me) and would also satisfy those who advocate for the
 actual feature (type hinting) without worrying much about the
 implementation detail. These two groups are overlapping by the way :)

 I don't understand this. Cobra's type-hints are right there in the function
 signature, just like Python annotations.


 # Cobra
 def sqroot(i as int) as float

 # Python
 def sqroot(i:int)-float:

You are right. This aspect is pretty close, what I had in mind, but
expressed myself poorly is this idiom in cobra:

def myfunc( a, b )
require
something_about( a, b )
ensure
something_about_the_return_value

Yes, type hinting and arbitrary constraints on the function arguments
and return types are different things, but closely related. I'd say it
makes sense to combine the two.


 Cobra's use of as clashes with Python. In Python, as is used for
 name-binding:

 import module as name
 with open('file') as f
 except Exception as e

 but apart from that minor difference, they're virtually identical.


 In any case, I'm pretty sure it was said before, but I can't really
 find it anywhere, can someone tell me what the rationale is for
 *function signature* type hinting?

 The basic principle is that things which are related should be found
 together. The further away they are, the worse.

 Bad:
 - the parameter name and the type are in different files

 Better:
 - the parameter name and the type are only a few lines apart

 Best:
 - the parameter name and type are right next to each other


 The closer they are, the easier it is to keep them in sync, and the easier
 it is to see the relevant information at a glance. Putting them together
 also means that you don't have to repeat the argument name:

 int n
 def spam(n): ...

 versus

 def spam(n:int): ...


 Those reasons are why decorators have the syntax which they do:

 @decorator
 def spam(n):
 do_this()
 do_that()
 do_something_else()


 is better than the old way of using decorators:

 def spam(n):
 do_this()
 do_that()
 do_something_else()

 spam = decorator(spam)


 The decorator is only a single line away from the signature, and you don't
 have to repeat the name.


 We can see this at work in Pascal. Pascal functions have type declarations
 in the signature, and variable declarations between the signature and the
 body:


 function sqroot(arg: Integer): Real;
   var
 x: Integer;
 y: Real;
 z: Something_Else;
   begin
 do_this(1, 2);
 do_that(3, 4);
 do_something_else(5, 6);
 x := some expression;  { what's the type of x again? }
   end;


 The declarations in the signature work very well and are easy to use, but
 the var section, not so much. Especially in large functions, the place
 where you declare the variable and its type, and the place where you first
 use it, can be separated by many lines. This makes maintenance and reading
 of the code more difficult.

 Newer languages like Java let you declare the variable the first time you
 use it:

 int x = some expression;

 and you don't have to search very far to find out what sort of thing x is,
 it is right there.



 --
 Steven

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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Sanity Proposal: Type Hinting Solution

2015-01-23 Thread Fetchinson .
On 1/23/15, Chris Angelico ros...@gmail.com wrote:
 On Sat, Jan 24, 2015 at 12:23 AM, Fetchinson .
 fetchin...@googlemail.com wrote:
 In any case, I'm pretty sure it was said before, but I can't really
 find it anywhere, can someone tell me what the rationale is for
 *function signature* type hinting?

 I totally get type hinting in general, but why does it have to be in
 the function signature? Any reason for that specifically?

 Is there any particular reason for the number of arguments to be part
 of the function signature?

I guess this is a rhetorical question :)

 I totally get the notion of declaring how
 many arguments a function takes, but why does it have to be in the
 function signature?

Ditto :)

 Data types are just as much a part of that signature as argument count
 is.

I guess this would be true if there weren't about 5 other alternative
proposals which solve the exact same problem (type hinting) by other
means. Luckily, these will be listed in the PEP soon and the reason
for rejecting them will be there as well, and so my question will
pretty much be answered there.

https://github.com/ambv/typehinting/issues/55


 You could argue that the function's return type isn't part of
 that, but that's about it.

 If there is a pep for it, people will use it, so the fact that
 it is optional is irrelevant...

 Function annotations were introduced in 2006 (Python 3.0) with PEP 3107:

 https://www.python.org/dev/peps/pep-3107/

 They were optional then, they are still optional now. Have you been
 overrun with them for the past decade? If not, why do you expect now
 to be?

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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Sanity Proposal: Type Hinting Solution

2015-01-23 Thread Fetchinson .
On 1/23/15, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 Terry Reedy wrote:

 On 1/22/2015 10:59 PM, Chris Angelico wrote:
 On Fri, Jan 23, 2015 at 2:22 PM, Terry Reedy tjre...@udel.edu wrote:
 This idea is so brilliant that it is already an option in mypy and is
 part
 of the new type-hint proposal.  The separate type-hint files are called
 'stub files'.

 It's worth pointing out, too, that the idea isn't panaceaic - it's
 just another tool in the box. Any time you break related things into
 separate places, especially separate files, the tendency for them to
 get out of sync grows dramatically.

 The same could be said of putting tests in a separate file.

 I agree!

 Python has doctests, which live right there with the function. It also has
 assertions, which can be considered a form of continuous testing.

 Eiffel has syntax for design-by-contract (testing pre-conditions,
 post-conditions and invariants) there in the body of the function or
 method:

 https://docs.eiffel.com/book/method/et-design-contract-tm-assertions-and-exceptions#Expressing_assertions


 Contracts are a form of testing, since they are designed to be disabled in
 production. Other languages with syntactic support for Design By Contract
 include Clojure, Cobra, D, Mercury, Perl6 and Racket.

 Cobra is especially close to Python-like syntax, and supports unit tests as
 well:


 def sqroot(i as int) as float
 require
i  0
 ensure
result  0
 tests
assert sqroot(25) == 5.0
 body
 ...

 It would be nice to be able to include at least *some* tests right there in
 the code rather than in a separate file.

I completely agree. A cobra-style type hinting implementation would
satisfy everyone who doesn't want to make function signatures noisy
(including me) and would also satisfy those who advocate for the
actual feature (type hinting) without worrying much about the
implementation detail. These two groups are overlapping by the way :)

In any case, I'm pretty sure it was said before, but I can't really
find it anywhere, can someone tell me what the rationale is for
*function signature* type hinting?

I totally get type hinting in general, but why does it have to be in
the function signature? Any reason for that specifically?

Are there lots of folks who actually insist on the type hints being in
the function signature and definitely want to see it there and not
somewhere else?

I'd say cobra-style type hinting would be great, but also something
which is property looking:

@official_type_hinting_by_the_psf( arg1: str, arg2: int, returns: bool )
def myfunction( arg1, arg2 ):
return True

I really like the idea that in python I don't have lots of choices in
many areas, certain things are dictated. The big advantage is that
when I read other people's code I know what to expect so me being
restricted is a small price to pay that is totally worth it. So I'd
come down on the side of the complainers in this case, the type
hinting pep introduces noisy and not so readable features (I
understand these are optional) which if used will make readability
suffer. If there is a pep for it, people will use it, so the fact that
it is optional is irrelevant, it will be used, so people will be faced
with it when reading other people's code, whether they like it or not.

Cheers,
Daniel




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-26 Thread Fetchinson .
On 12/26/14, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 Fetchinson . wrote:

 Guido is still working at google, right?


 No. Google is still using Python for lots of things, but Guido is now
 working for Dropbox.

 https://www.python.org/~guido/

Thanks, I missed the transition. The best would of course be if the
core developer team of python would bless an android distribution and
keep it up to date just as with the linux/windows/macos python
distribution. I don't know if that will happen though. It would make
sense because the number of android installations is growing rapidly.
By the way, is there a mobile strategy on the part of the core dev
team? Maybe not android, perhaps tizen is a better target but I'd say
it would make sense if some mobile platform would officially be
targeted.

Cheers,
Daniel



 --
 Steven

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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-26 Thread Fetchinson .
On 12/26/14, iMath redstone-c...@163.com wrote:
 在 2014年12月25日星期四UTC+8下午11时31分24秒,Fetchinson .写道:
 Hi all,

 I was using sl4a for quite some time on android and it basically
 worked very well although some features are missing. It looks like
 sl4a is dead, although I could be wrong. Does anyone knowledgeable
 have any further info on the future of sl4a? For instance it doesn't
 work with android 5 and there doesn't seem to be any activity around
 it for the past couple of years.

 If sl4a is out, what's the preferred way of running python on android?
 Guido is still working at google, right? This makes me suspect that
 python is ought to be part of the android ecosystem but can't find
 anything else beyond sl4a.

 So what's the future proof way of writing/deploying/installing python
 programs on android?

 Cheers,
 Daniel


 --
 Psss, psss, put it down! - http://www.cafepress.com/putitdown

 According this post here,
 http://plashless.wordpress.com/2014/08/19/using-pyqtdeploy0-5-on-linux-to-cross-compile-a-pyqt-app-for-android/

 you can use PyQt5 for Android app development !

Nice, haven't heard about it, thanks for the pointer!

Daniel


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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: If One Line

2014-12-25 Thread Fetchinson .
 Is it possible in python:

 if ((x = a(b,c)) == 'TRUE'):
   print x

Nope. Assignment is not allowed in a conditional.

Cheers,
Daniel


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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Future of python on android

2014-12-25 Thread Fetchinson .
Hi all,

I was using sl4a for quite some time on android and it basically
worked very well although some features are missing. It looks like
sl4a is dead, although I could be wrong. Does anyone knowledgeable
have any further info on the future of sl4a? For instance it doesn't
work with android 5 and there doesn't seem to be any activity around
it for the past couple of years.

If sl4a is out, what's the preferred way of running python on android?
Guido is still working at google, right? This makes me suspect that
python is ought to be part of the android ecosystem but can't find
anything else beyond sl4a.

So what's the future proof way of writing/deploying/installing python
programs on android?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of python on android

2014-12-25 Thread Fetchinson .
On 12/25/14, Billy Earney billy.ear...@gmail.com wrote:
 try kivy, instead of sl4a http://kivy.org/

 I believe in the past year or two, the python foundation gave a grant to
 kivy to add further functionality..

Thanks, I didn't know about kivy but it looks quite nice, will give it a try!
Hopefully it will be around for a while and won't evaporate like sl4a :)

Cheers,
Daniel


 According to wikipedia http://en.wikipedia.org/wiki/Guido_van_Rossum  Guido
 works for dropbox.

 Billy

 On Thu, Dec 25, 2014 at 9:31 AM, Fetchinson . fetchin...@googlemail.com
 wrote:

 Hi all,

 I was using sl4a for quite some time on android and it basically
 worked very well although some features are missing. It looks like
 sl4a is dead, although I could be wrong. Does anyone knowledgeable
 have any further info on the future of sl4a? For instance it doesn't
 work with android 5 and there doesn't seem to be any activity around
 it for the past couple of years.

 If sl4a is out, what's the preferred way of running python on android?
 Guido is still working at google, right? This makes me suspect that
 python is ought to be part of the android ecosystem but can't find
 anything else beyond sl4a.

 So what's the future proof way of writing/deploying/installing python
 programs on android?

 Cheers,
 Daniel


 --
 Psss, psss, put it down! - http://www.cafepress.com/putitdown
 --
 https://mail.python.org/mailman/listinfo/python-list




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Fetchinson .
 Lest it seem like I am agreeing with these complaints, I'd like to say:
 Either python goes this way or the way of Fortran and Cobol.

 You mean if Cobol had a shiny but disfunctional website we'd be using that
 instead of Python?

Why would he mean that?

If !A implies !B, it does *not* follow that A implies B.

Here A = shiny website and B = success.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Fetchinson .
  Many links are broken. When you click on the broken link, it says that
 it
  has been reported and will be fixed, but weeks later it remains broken,
  e.g.:
 
  https://www.python.org/doc/essays/metaclasses/Eiffel.py

 What makes you think that this page is ought to return actual content?

 The page at https://www.python.org/doc/essays/metaclasses/ links to it. The
 fact that something on the same site links to it is a good indication that
 there ought to be something at the other end of the link.

I see, thanks, this was the missing piece of information, I didn't
know there are links to that page.

Cheers,
Daniel


 The content that is expected to be found there can still be found at the
 legacy site: http://legacy.python.org/doc/essays/metaclasses/Eiffel.py



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-09 Thread Fetchinson .
On 12/9/14, Ethan Furman et...@stoneleaf.us wrote:
 On 12/05/2014 03:30 AM, Fetchinson responded to
 Steven D'Aprano's rant of:

 Many links are broken. When you click on the broken link, it says that
 it
 has been reported and will be fixed, but weeks later it remains broken,
 e.g.:

 https://www.python.org/doc/essays/metaclasses/Eiffel.py

 What makes you think that this page is ought to return actual content?

 Could you rephrase that question?  The way it's worded at the moment is like
 going to a restaurant, ordering some food,
 having the plate of food put in front of you, trying to eat the food and
 getting nothing but air, and then having the
 waiter say, What makes you think there would be actual substance?

As Ian pointed out in another message in this thread there is a link
on python.org that points to the above page. I did not know this. So
when I read that a link is broken, to me it sounded like, hey, there
isn't any content at https://python.org/some/bla/bla/bla/random/stuff
which made me ask why does the OP think there should be anything. If
there are no links to it, it's fine, if there is one (or more) then of
course it's not fine. Apparently the case is the latter.

Cheers,
Daniel



 And what would you estimate, how many standard deviations are you away
 from the average viewer of python.org in terms of these metrics (where
 the metrics are like/dislike of menus, like/dislike of mouse moving,
 like/dislike of unexpected browser behavior, like/dislike of links,
 like/dislike of slide shows, etc.)?

 I am reminded of the quote by Edsger W. Dijkstra:

   Simplicity and elegance are unpopular because they require
   hard work and discipline to achieve and education to be
   appreciated.

 --
 ~Ethan~




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you like the current design of python.org?

2014-12-05 Thread Fetchinson .
 Did you ever hit the Socialize button?

No, but it doesn't bother me.

 Are you eager to see the latest
 tweets when you are reading a PEP?

No, but it doesn't bother me either. You can easily block twitter
related things by a number of ways, firewalls, /etc/hosts, etc.

 Do you run away screaming from a page
 where nothing moves without you hitting a button? Do you appreciate the
 choice between ten or so links to the documentation?

No, but it doesn't bother me at all.

 I dislike the new design of python.org.

I actually love it a lot! Big improvement over the previous site I think.

 The formatting of long text essays get completely mangled towards the
 bottom
 of the page, e.g.:

 https://www.python.org/download/releases/2.2/descrintro

It doesn't look mangled to me (firefox 22).

 Many links are broken. When you click on the broken link, it says that it
 has been reported and will be fixed, but weeks later it remains broken,
 e.g.:

 https://www.python.org/doc/essays/metaclasses/Eiffel.py

What makes you think that this page is ought to return actual content?

 It requires Javascript or else basic functionality fails. With Javascript,
 basic functionality fails too, but in a much more entertaining and exciting
 way, as in I'm trying to click a button on that menu, why does the screen
 keep refreshing and hiding the menu before I can click?.

I never encountered screen refreshings that I did not trigger myself.

 I'm not terribly impressed by the design or the colour scheme, it's way
 too web 2.0, i.e. simultaneously pretentious and dumbed down.

I think it looks great! We agree to disagree I guess; see more below.

 But most of all, I despise the menus that pop up covering what I am trying
 to read the page just because I happened to move the mouse over a button. I
 loathe the practice of stuffing content into menus instead of using links
 to individual web pages. And I hold nothing but scorn for the fact that the
 main page has a slideshow.

And what would you estimate, how many standard deviations are you away
from the average viewer of python.org in terms of these metrics (where
the metrics are like/dislike of menus, like/dislike of mouse moving,
like/dislike of unexpected browser behavior, like/dislike of links,
like/dislike of slide shows, etc.)?

 But none of that even gets close to the spitting fury I feel when I see
 the Socialise links. With the possible exception of the link to
 http://irc.freenode.net/ which at least has the vague excuse that there is
 a #python channel, not that a visitor to the python.org website has any way
 to learn this.

And what would you estimate, how many standard deviations are you away
from the average viewer of python.org in terms of these metrics (where
now the metrics are like/dislike of social links, social websites,
etc.)?

 Oh, I've just discovered that when you click in the search box, a perfectly
 serviceable search box, it automatically expands by about 20%, just
 because.

And that is a problem because?

 Urge to kill rising...

I didn't see the disclaimer No living thing was harmed while typing
this email. below your message so I'm kinda worried!

Cheers,
Daniel


 You can probably guess my opinion -- konqueror just crashed on the PEP
 index and for some reason I'm more annoyed about the page than about the
 browser.


 PS: Is there a twitter.com something that I can block to trade black
 friday and cyber monkey sales for a box with a good old error message?

 I love konquorer as a file manager, but I've come to the conclusion that
 Firefox is the absolute worst web browser available, except for all the
 rest. Firefox has a wonderful plugin, No Script, which lets you block
 Javascript and other nonsense on a per-site basis.

 I love me my No Script. Browsing the web is so painful without it.




 --
 Steven

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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Iterate over text file, discarding some lines via context manager

2014-11-28 Thread fetchinson .
Hi all,

I have a feeling that I should solve this by a context manager but
since I've never used them I'm not sure what the optimal (in the
python sense) solution is. So basically what I do all the time is
this:

for line in open( 'myfile' ):
if not line:
# discard empty lines
continue
if line.startswith( '#' ):
# discard lines starting with #
continue
items = line.split( )
if not items:
# discard lines with only spaces, tabs, etc
continue

process( items )

You see I'd like to ignore lines which are empty, start with a #, or
are only white space. How would I write a context manager so that the
above simply becomes

with some_tricky_stuff( 'myfile' ) as items:
process( items )

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Iterate over text file, discarding some lines via context manager

2014-11-28 Thread fetchinson .
On 11/28/14, Dave Angel da...@davea.name wrote:
 On 11/28/2014 10:04 AM, fetchinson . wrote:
 Hi all,

 I have a feeling that I should solve this by a context manager but
 since I've never used them I'm not sure what the optimal (in the
 python sense) solution is. So basically what I do all the time is
 this:

 for line in open( 'myfile' ):
  if not line:
  # discard empty lines
  continue
  if line.startswith( '#' ):
  # discard lines starting with #
  continue
  items = line.split( )
  if not items:
  # discard lines with only spaces, tabs, etc
  continue

  process( items )

 You see I'd like to ignore lines which are empty, start with a #, or
 are only white space. How would I write a context manager so that the
 above simply becomes

 with some_tricky_stuff( 'myfile' ) as items:
  process( items )


 I see what you're getting at, but a context manager is the wrong
 paradigm.  What you want is a generator.   (untested)

 def mygenerator(filename):
  with open(filename) as f:
  for line in f:
  if not line: continue
  if line.startswith('#'): continue
  items = line.split()
  if not items: continue
  yield items

 Now your caller simply does:

 for items in mygenerator(filename):
process(items)

Great, thanks a lot!

Cheers,
Daniel



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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-27 Thread Daniel Fetchinson
 I'm new to python, got 10-20 years perl and C experience, all gained on unix
 alike machines hacking happily in vi, and later on in vim.

 Now it's python, and currently mainly on my kubuntu desktop.

Welcome to the club!

 Do I really need a real IDE, as the windows guys around me say I do, or will
 vim, git, make and other standalone tools make it the next 20 years too for
 me?

Sure they will!

 Oh, by the way, after 7 days I'm completely in love with this python thing.

Again, welcome to the club!

 I should have made the switch much earlier!

Indeed..

BTW, I also use vim only,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Daniel Fetchinson
Hi folks, I realize this is slightly off topic and maybe belongs to a
gnome email list but it's nevertheless python:

I use an old python program that was written for gnome 2 and gtk 2 and
uses the function get_local_path_from_uri. More specifically it uses
gnomevfs.get_local_path_from_uri.

Now with gnome 3 the module pygnomevfs does not exist anymore and
after checking the source for pygnomevfs it turns out it's written in
C using all the header files and stuff from gnome 2. So I can't just
lift it from the source. I was hoping it's pure python in which case I
could have simply lifted it.

Does anyone know what a good replacement for get_local_path_from_uri
is? Is there a gtk/gnome/etc related python package that contains it
which would work with gnome 3? Or a totally gnome-independent python
implementation?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Daniel Fetchinson
 Hi folks, I realize this is slightly off topic and maybe belongs to a
 gnome email list but it's nevertheless python:

 I use an old python program that was written for gnome 2 and gtk 2 and
 uses the function get_local_path_from_uri. More specifically it uses
 gnomevfs.get_local_path_from_uri.

 Now with gnome 3 the module pygnomevfs does not exist anymore and
 after checking the source for pygnomevfs it turns out it's written in
 C using all the header files and stuff from gnome 2. So I can't just
 lift it from the source. I was hoping it's pure python in which case I
 could have simply lifted it.

 Does anyone know what a good replacement for get_local_path_from_uri
 is? Is there a gtk/gnome/etc related python package that contains it
 which would work with gnome 3? Or a totally gnome-independent python
 implementation?

 The commit
 https://mail.gnome.org/archives/commits-list/2009-May/msg05733.html
 suggests that get_local_path_from_uri() might have been defined as
 (taking slight liberties):
 gnome_vfs_unescape_string(remove_host_from_uri(uri))
 Assuming these functions do the obvious things implied by their
 names (you can probably chase down the Gnome VFS source or docs to
 check; I don't care enough to bother), given a general URI
 protocol://host/path, it presumably returns either
 protocol:///path (`protocol:` likely being file: in this case) or
 /path, in either case with `path` having been un-percent-escaped.
 The latter transform can be done using
 http://docs.python.org/2/library/urllib.html#urllib.unquote

 Alternately, you might call the Gnome VFS C API directly via
 http://docs.python.org/2/library/ctypes.html

Thanks, ctypes is actually a great idea, I should have thought about that.
In the meantime I use the simple function

def get_local_path_from_uri( uri ):

return uri.split( '//' )[1]


and it seems to work. In the program the function is always called in
a try: except: block so if anything is not okay it will get caught, I
don't have to catch exceptions inside the function.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


unpacking first few items of iterable

2012-12-13 Thread Daniel Fetchinson
Hi folks, I swear I used to know this but can't find it anywhere:

What's the standard idiom for unpacking the first few items of an
iterable whose total length is unknown?

Something like

a, b, c, _ = myiterable

where _ could eat up a variable number of items, in case I'm only
interested in the first 3 items?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unpacking first few items of iterable

2012-12-13 Thread Daniel Fetchinson
Hi folks, I swear I used to know this but can't find it anywhere:

What's the standard idiom for unpacking the first few items of an
iterable whose total length is unknown?

Something like

a, b, c, _ = myiterable

where _ could eat up a variable number of items, in case I'm only
interested in the first 3 items?

 If you're using python3, you can simply do:

 a, b, c, *rest = myiterable

Thanks, sounds great, how about python2?

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unpacking first few items of iterable

2012-12-13 Thread Daniel Fetchinson
 Hi folks, I swear I used to know this but can't find it anywhere:

 What's the standard idiom for unpacking the first few items of an
 iterable whose total length is unknown?

 Something like

 a, b, c, _ = myiterable

 where _ could eat up a variable number of items, in case I'm only
 interested in the first 3 items?
 If you're using python3, you can simply do:

 a, b, c, *rest = myiterable
 Thanks, sounds great, how about python2?


 If you know the sequence has at least n items, you
 can do a, b, c = seq[:3]

Yeah, that's probably the simplest, without all the fancy stuff :)

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


assign only first few items of a tuple/list

2012-12-04 Thread Daniel Fetchinson
Hi folks, I swear I used to know this but can't find it anywhere.
Say I have a list x = [ 1,2,3,4,5 ] and only care about the first two items.
I'd like to assign the first two items to two variables, something like,

a, b, _ = x

but the above will not work, of course, but what is the common idiom
for this that does?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can we append a list with another list in Python ?

2012-10-23 Thread Daniel Fetchinson
 can we append a list with another list in Python ? using the normal routine
 syntax but with a for loop ??

x = [1,2,3]
y = [10,20,30]
x.extend( y )
print x

this will give you [1,2,3,10,20,30] which I guess is what you want.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: system tray or notification area in python

2012-10-17 Thread Daniel Fetchinson
 Hi folks,
 So I thought I would write a brand new stand alone system tray or
 notification area in python. I guess I need to use gtk bindings or
 some such but don't really know what my options are.

 Where would I start something like this?
 Any pointers would be greatly appreciated!

 Why not look at the source code of the current app your using to get
 an idea how that application accomplishes said task?

 I actually did that already it's using the C bindings of gtk.

 I think you are mistaken - if its this one:
   http://stalonetray.sourceforge.net/

Yes, that's it.

 I had a quick look into the sources, it does not use gtk at all, it uses
 low level X11 calls. Programming in this way is very tedious.

Sorry, you are right. I was mixing things up, I just remembered it was
gtk, apparently it's not.

 But I have zero experience with gui programming in python. So any
 pointers would be much appreciated how to implement a system tray in
 python. Gtk is I guess just one option, one could use other stuff from
 python but I wouldn't know what the simplest approach is.

 I'm not sure it is even possible. Usual GUI applications just need to
 request certain features from their window manager such as the setting
 the program icon or requesting a certain position on the screen. That is
 what is implemented in the usual toolits like Tk, QT, and gtk.

That is my impression as well, tk, qt, etc, won't be good for this
task but I thought there are some sort of X bindings in python that
will make writing low level X applications in python possible. For
instance a system tray :)

 A window manager, on the other hand, must be able to recieve and
 interpret these messages. For a system tray, they are described here:

 http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.3.html

 I have not studied the whole interface of the aforementioned toolkits,
 but I suspect that there is no way around writing low level Xlib code in
 order to recieve these messages.

Right, but nobody wrote Xlib bindings for python?

 Don't take it wrong, but when you write that you have no experience with
 GUI programming, I'd start another projet first - I think you will have
 a tough way to succeed with this project.

I certainly wouldn't start with Xlib in C, but if python bindings
would be available that would make life much easier.

Cheers,
Daniel


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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: system tray or notification area in python

2012-10-17 Thread Daniel Fetchinson
 So I thought I would write a brand new stand alone system tray or
 notification area in python. I guess I need to use gtk bindings or
 some such but don't really know what my options are.

 Where would I start something like this?
 Any pointers would be greatly appreciated!

 Why not look at the source code of the current app your using to get
 an idea how that application accomplishes said task?

 I actually did that already it's using the C bindings of gtk.

 I think you are mistaken - if its this one:
 http://stalonetray.sourceforge.net/

 Yes, that's it.

 I had a quick look into the sources, it does not use gtk at all, it uses
 low level X11 calls. Programming in this way is very tedious.

 Right, but nobody wrote Xlib bindings for python?

 Erm, Google is your friend: python xlib turns up

   http://python-xlib.sourceforge.net/

 as well as

   http://plwm.sourceforge.net/

 which is pretty close to what you are trying to do.

Great, thanks a lot!

 Don't take it wrong, but when you write that you have no experience with
 GUI programming, I'd start another projet first - I think you will have
 a tough way to succeed with this project.

 I certainly wouldn't start with Xlib in C, but if python bindings
 would be available that would make life much easier.


 Everything is easier in python:) because usually python libs are
 designed with OO and ease of use in mind. Beware that this will be much
 tougher than using gtkfriends.

I guess so :) But it's a good excuse to get familiar with X :)

Cheers,
Daniel


   Christian


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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


system tray or notification area in python

2012-10-16 Thread Daniel Fetchinson
Hi folks,

I'm using a stand alone window manager without gnome or kde or any
other de. But I still would like to have a system tray or notification
area and so far used stalonetray for this. Stalonetray is written in C
and is a GTK application, works all right but sometimes it doesn't.
For instance if it is killed and restarted icons don't come back, etc,
etc, there are some quirks.

So I thought I would write a brand new stand alone system tray or
notification area in python. I guess I need to use gtk bindings or
some such but don't really know what my options are.

Where would I start something like this?
Any pointers would be greatly appreciated!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: system tray or notification area in python

2012-10-16 Thread Daniel Fetchinson
 Hi folks,

 I'm using a stand alone window manager without gnome or kde or any
 other de. But I still would like to have a system tray or notification
 area and so far used stalonetray for this. Stalonetray is written in C
 and is a GTK application, works all right but sometimes it doesn't.
 For instance if it is killed and restarted icons don't come back, etc,
 etc, there are some quirks.

 So I thought I would write a brand new stand alone system tray or
 notification area in python. I guess I need to use gtk bindings or
 some such but don't really know what my options are.

 Where would I start something like this?
 Any pointers would be greatly appreciated!

 Why not look at the source code of the current app your using to get
 an idea how that application accomplishes said task?

I actually did that already it's using the C bindings of gtk.
You might ask you I'm not modifying the code in order to achieve what
I want, well, the answer is that I'd much rather prototype something
like this in python than work immediately with gtk from C.

But I have zero experience with gui programming in python. So any
pointers would be much appreciated how to implement a system tray in
python. Gtk is I guess just one option, one could use other stuff from
python but I wouldn't know what the simplest approach is.

Cheers,
Daniel


 You could always use raw X11 libs but leveraging something like Gtk or
 Qt/KDE would probably be much easier.



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


terminate called after throwing an instance of 'CABRTException'

2012-10-02 Thread Daniel Fetchinson
I've noticed a strange thing with python lately:



Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type help, copyright, credits or license for more information.
 def f(): print x
...
 f()
terminate called after throwing an instance of 'CABRTException'
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 1, in f
NameError: global name 'x' is not defined




Clearly there is a NameError because x is not defined, but what the
hell is the terminate . 'CABRTException' business?

I guess it has to do with abrt but abrt is not running on my system at
all. Also, if I run python2.7 with the above code I don't get the
CABRTException stuff. What is really strange is that I have all sorts
of recent files in /var/cache/abrt/pyhook-* indicating that somehow
abrt is doing things even though it is not running, for instance
chkconfig --list | grep abrt shows it off in all run levels.

What's going on?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: terminate called after throwing an instance of 'CABRTException'

2012-10-02 Thread Daniel Fetchinson
 I've noticed a strange thing with python lately:



 Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
 [GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
 Type help, copyright, credits or license for more information.
 def f(): print x
 ...
 f()
 terminate called after throwing an instance of 'CABRTException'
 Traceback (most recent call last):
   File stdin, line 1, in module
   File stdin, line 1, in f
 NameError: global name 'x' is not defined




 Clearly there is a NameError because x is not defined, but what the
 hell is the terminate . 'CABRTException' business?

 I guess it has to do with abrt but abrt is not running on my system at
 all. Also, if I run python2.7 with the above code I don't get the
 CABRTException stuff. What is really strange is that I have all sorts
 of recent files in /var/cache/abrt/pyhook-* indicating that somehow
 abrt is doing things even though it is not running, for instance
 chkconfig --list | grep abrt shows it off in all run levels.

 What's going on?

 No idea, but I'd have a look at sys.modules, and if

 import sys
 [name for name in sys.modules if abrt in name.lower()]
 []

 gives a non-empty result I'd investigate where the culprit is imported --
 /usr/lib/python2.6/sitecustomize.py would be the obvious candidate.

Indeed! Thanks a lot,
/usr/lib/python2.6/site-packages/sitecustomize.py was created by the
package abrt-addon-python (at least this is the fedora name) and so it
was activated by python itself completely independently from abrt
(which was not running).

Now I removed all packages called abrt-* and the problem is gone.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


lambda in list comprehension acting funny

2012-07-11 Thread Daniel Fetchinson
funcs = [ lambda x: x**i for i in range( 5 ) ]
print funcs[0]( 2 )
print funcs[1]( 2 )
print funcs[2]( 2 )

This gives me

16
16
16

When I was excepting

1
2
4

Does anyone know why?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda in list comprehension acting funny

2012-07-11 Thread Daniel Fetchinson
 funcs = [ lambda x: x**i for i in range( 5 ) ]
 print funcs[0]( 2 )
 print funcs[1]( 2 )
 print funcs[2]( 2 )

 This gives me

 16
 16
 16

 When I was excepting

 1
 2
 4

 Does anyone know why?

And more importantly, what's the simplest way to achieve the latter? :)


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda in list comprehension acting funny

2012-07-11 Thread Daniel Fetchinson
 funcs = [ lambda x: x**i for i in range( 5 ) ]
 print funcs[0]( 2 )

 This gives me
 16

 When I was excepting
 1

 Does anyone know why?

Just the way Python lambda expressions bind their variable
 references. Inner 'i' references the outer scope's 'i' variable and not
 its value 'at the time the lambda got defined'.


 And more importantly, what's the simplest way to achieve the latter? :)

Try giving the lambda a default parameter (they get calculated and
 have their value stored at the time the lambda is defined) like this:
funcs = [ lambda x, i=i: x**i for i in range( 5 ) ]

Thanks a lot!
I worked around it by

def p(i):
return lambda x: x**i
funcs = [ p(i) for i in range(5) ]

But your variant is nicer (matter of taste of course).

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda in list comprehension acting funny

2012-07-11 Thread Daniel Fetchinson
 You should not be using lambda in this case
 .for x in [2, 3]:
 .funcs = [x**ctr for ctr in range( 5 )]
 .for p in range(5):
 .print x, funcs[p]
 .print

 If you change the requirements, it's always easy to solve problems. But
 it is the wrong problem that you have solved.

 The problem we have been asked to solve is to create a sequence of
 function objects, so that they can be called later, when needed, *not* to
 pre-calculate the results.

 In this case, the most obvious solution is to store a local variable in
 each function object with the value you want.

 funcs = [(lambda x, i=i: x**i) for i in range(5)]

 creates a list of five functions:

 lambda x, i=0: x**i
 lambda x, i=1: x**i
 lambda x, i=2: x**i
 and so on.

 In this case, each function has two local variables, x and i, with i
 having a default value. The function parameter i is bound to the value of
 i when the function was created.

 Because parameter defaults are calculated once, when the function is
 created, this causes the value of i to stick to the newly created
 function, and we get the result we need.

 What happens if you don't use a parameter with a default value?

 funcs = [(lambda x: x**i) for i in range(5)]

 In this case, each function body contains one local variable, x, and one
 non-local or global variable, i.

 Because i is a non-local, the function doesn't store a value for it.
 Instead, the function stores a lump of data pointing to just enough of
 the environment to fetch the current value of the non-local i when
 needed. Since all five functions are in the same environment, they all
 see the same value of i when you call them, regardless of what the value
 of i was when they were created.

 This is little different from doing this:

 i = 1
 def f1(x): return x**i

 i = 2
 def f2(x): return x**i

 i = 3
 def f3(x): return x**i

 Is there any surprise that all three functions return the same value?
 They all point to the same global variable i. I'm not sure what it is
 about lambda that fools people into thinking that it is different (I've
 even been fooled myself!) but it is not.

Thank you Steve!
Precise and clear, as always!

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Namespace hack

2012-06-05 Thread Daniel Fetchinson
 Funny, you got to the last line of import this but apparently
 skipped the second line:

 Explicit is better than implicit.

 And you didn't even post your message on April 1 so no, I can't laugh
 even though I'd like to.

 Can you be less condescending?

Of course! :)

Anyway, the point I was trying to make is that Steve's example is
kinda cool but only as a funny exercise and not something for real
life. Let's toy with python kinda thing, which is always welcome but
with a big fat asterisk saying don't try this at home kids.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Namespace hack

2012-05-24 Thread Daniel Fetchinson
 From the Zen of Python (import this):

 Namespaces are one honking great idea -- let's do more of those!


 Inspired by this, I have a decorator that abuses function closures to
 create a namespace type with the following properties:

 - all methods are static methods that do not take a self parameter;

 - methods can see class variables;

 - external callers can see selected methods and attributes.


 An example may make this clearer.

 In a regular class:

 class C:
 x = 42
 def spam(self, y):
 return self.x + y
 def ham(self, z):
 return self.spam(z+1)


 Notice that the class attribute x is visible to the outside caller, but
 methods spam and ham cannot see it except by prefixing it with a
 reference to self.

 Here's an example using my namespace hack example:

 @namespace
 def C():  # Abuse nested functions to make this work.
 x = 42
 def spam(y):
 return x + y
 def ham(z):
 return spam(z+1)
 return (spam, ham)  # Need an explicit return to make methods visible.

 However, class attribute x is not exposed. You may consider this a
 feature, rather than a bug. To expose a class attribute, define it in the
 outer function argument list:

 @namespace
 def C(x=42):
 def spam(y):
 return x + y
 def ham(z):
 return spam(z+1)
 return (spam, ham)



 And in use:

 C.x
 42
 C.spam(100)
 142
 C.ham(999)
 1042



 Here's the namespace decorator:

 import inspect

 def namespace(func):
   spec = inspect.getargspec(func)
   ns = {'__doc__': func.__doc__}
   for name, value in zip(spec.args, spec.defaults or ()):
   ns[name] = value
   function = type(lambda: None)
   exported = func() or ()
   try:
   len(exported)
   except TypeError:
   exported = (exported,)
   for obj in exported:
   if isinstance(obj, function):
   ns[obj.__name__] = staticmethod(obj)
   else:
   raise TypeError('bad export')
   Namespace = type(func.__name__, (), ns)
   return Namespace()


 Have fun!

Funny, you got to the last line of import this but apparently
skipped the second line:

Explicit is better than implicit.

And you didn't even post your message on April 1 so no, I can't laugh
even though I'd like to.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-15 Thread Daniel Fetchinson
 Blatantly the pyjs ownership  change turned out to be an awkward
 operation (as reactions on that ML show it), but a fork could also have
 very harmfully split pyjs-interested people, so all in all I don't
 think there was a perfect solution - dictatorships never fall harmlessly.

You say fork could also have very harmfully split, what harms are
you referring to?
In the open source world there were tons of forks of projects and it
proved to be a useful mechanism for resolving serious management
issues.  On the other hand the kind of hostile takeover that happened
with pyjs is virtually unparalleled in the open source world. What
made you think such a unique operation will be less harmful than the
other which has already been tried many times?

 
 | Please get this absolutely clear in your head: that  |
 | you do not understand my reasoning is completely and utterly   |
 | irrelevant.  i understand *your* reasoning; i'm the one making the   |
 | decisions, that's my role to understand the pros and cons.  i make a |
 | decision: that's the end of it.  |
 | You present reasoning to me: i weight it up, against the other   |
 | reasoning, and i make a decision.  you don't have to understand that |
 | decision, you do not have to like that decision, you do not have to  |
 | accept that decision.|
 

Again, if you don't like the lead developer just fork the project,
come up with a new name, new website and new infrastructure and start
building a new community. Why didn't the rebels do that?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Daniel Fetchinson
It's also quite ironic that the initial complaining started from how
the domain name www.pyjs.org is not available only pyjs.org is. At the
same time the Rebel Chief's listed domain name on github, see
https://github.com/xtfxme, gives you a server not found:
http://the.xtfx.me/ :)



On 5/9/12, anth...@xtfx.me anth...@xtfx.me wrote:
 On Tuesday, May 8, 2012 4:10:13 AM UTC-5, james hedley wrote:
 Agreed with pretty much all of that. It's third-world politics, lurching
 from one dictator to another. Risinger seems to have banned all discussion
 of the subject from the list too, I'm not posting anymore because I don't
 want to give him an excuse to wield his newly found banhammer.

 hello James,

 i'm not really sure what you're referring too ... you appear to be making
 these things up.  i have not banned anything, or even alluded to it,
 whatsoever.  i asked that one specific mail not be commented upon, as a
 request; perhaps this is the dreaded bannhammer you speak of?

 reading your accounts strewn about is interesting, what exactly are *your*
 motives?  a simple curiosity, nothing more.

 your comparison to gov'ts is pretty skewed i would say, you know this as
 well as i. regardless of what you think or know of me, i have a permanent
 track record of being pretty fair and receptive to virtually anything, and
 am involved in a wide range of projects.  Luke is a talented developer,
 there is no doubt of this, but he is one of the most socially inept persons
 i have ever encountered.  leading your users to statements such as this:

 https://groups.google.com/forum/?fromgroups#!searchin/pyjamas-dev/credo/pyjamas-dev/xzp4CCWhJN4/nQ3-emtYFVgJ

 ... dozens of times on several occasions, is truly incredible.  other such
 behavior, eg. being the only person in the history of the webkit project to
 ever be *ejected* from contributing or communicating *at all*, is further
 testament to the deficiencies provoking this maneuver.

 however, i have no interest in comparing or being compared.  go read my
 notes again; i have a high level of respect for Luke in many capacities, and
 this has not changed.

 lets make one thing perfectly clear; you are not the only one who cares of
 this project or wishes it to succeed.  mistakes were made.  problems were
 had.  the decisions however, stands.

 But yeah, a lot of the commentary from the pro-rebel side ( not that any
 of them admit they had anything to do with it ) really does come across as
 being ill-informed and childish.

 indeed, you have witnessed little chatter.  however, barring your belief of
 such, i had received dozens of notes thanking me and attesting to a renewed
 impetus for action.  the original goal was to purchase a domain and fork --
 i made this very clear in my notes -- `uxpy.net`.  however, the most
 respectable member of the commit IMO convinced me otherwise.  names names,
 yes you want names?  sorry :-(.  alas, he, myself, and numerous others are
 still active and moving forward.  the list is actually approaching 100 ...
 not the 4-5 you so graciously quoted.  i am simply the point man willing
 to stand the flurry.

 likewise, i did not convince the domain holder to give me the domain.  not
 only was he already aware prior to me approaching him -- list member,
 passive -- he was more that willing to assist in reinstating the projects
 foundations and direction.  he *was* the person who left Luke in charge
 ... why do you think he was the owner? as far as im concerned, the domain
 was already hijacked; this was, in good faith, intended as remedy.

 this was not a easy or light decision, the dissonance exists to this day.
 the idea was to retain Luke, but he decided to play legal threats as the
 first card (which i'm afraid can only backfire), before he even knew of the
 domain changes.  hge is not a victim here, nor is anyone else.  so please,
 show some cognitive capacity by realizing this is not as black-and-white as
 you's like it to be.

 when you decide to include yourself -- sooner, or later -- you are more than
 welcome.

 @alex23 ... try reading a bit further.  as a human i am subject to annoyance
 and frustration.  i probably shouldn't have started the message in that
 manner, but the absurdity and absolute inaccurate statements being made were
 rather upsetting.  you will note that i make it perfectly clear that Luke is
 a fantastic developer, and a great part of the team.  this of course has
 neither waned nor faltered.

 i encourage anyone willing to take the time to consult the archives,
 pyjamas' and elsewhere, as they are the only path to proper answers.  this
 will impact the project in both known and untold ways, but we have a great
 number of minds willing to push beyond.

 --

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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Daniel Fetchinson
 the original goal was to purchase a domain and fork --
 i made this very clear in my notes -- `uxpy.net`.  however, the most
 respectable member of the commit IMO convinced me otherwise.

(I'm a total outsider, never used pyjs.)

Anthony, you never explained what the reasoning behind the advice of
the most respectable member of the commit was. Why didn't you
finally buy the new domain name, pick a new name, and fork the
project?

As it stands now the obvious answer for most people is because it
looked easier to just take over than to build a new community, new
infrastructure, new fame, etc, and I sure as hell like to take the
easy road as opposed to the hard road.

Until you clearly explain your reasoning for taking over as opposed to
forking, the default answer is the above one.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fetching data from a HTML file

2012-03-23 Thread Daniel Fetchinson
On 3/23/12, Sangeet mrsang...@gmail.com 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! :(

 trtd align=centerbSum/b/tdtd/tdtd align='center'
 class=green245/tdtd align='center' class=red11/tdtd
 align='center'0/tdtd align='center' 256/tdtd align='center' 1.496
 [min]/td/tr
 /table

Try beautiful soup: http://www.crummy.com/software/BeautifulSoup/

 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!

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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in scientific way

2012-02-17 Thread Daniel Fetchinson
 Thanks, it's simpler indeed, but gives me an error for value=1.267,
 error=0.08:

 Traceback (most recent call last):
  File /home/fetchinson/bin/format_error, line 26, in module
print format_error( sys.argv[1], sys.argv[2] )
  File /home/fetchinson/bin/format_error, line 9, in format_error
error_scale += error.scaleb( -error_scale ).to_integral(  ).adjusted(
  )
  File /usr/lib64/python2.6/decimal.py, line 3398, in scaleb
ans = self._check_nans(other, context)
  File /usr/lib64/python2.6/decimal.py, line 699, in _check_nans
other_is_nan = other._isnan()
 AttributeError: 'int' object has no attribute '_isnan'

 Which version of python are you using?

 2.7.1.  At a guess, it's failing because scaleb() (which was new in
 2.6) is buggily expecting a decimal argument, but adjusted() returns an int.
 Convert the results of the two adjusted() calls to decimals, and I
 think it should be fine.

Great, with python 2.7 it works indeed!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in scientific way

2012-02-17 Thread Daniel Fetchinson
 Hi folks, often times in science one expresses a value (say
 1.03789291) and its error (say 0.00089) in a short way by parentheses
 like so: 1.0379(9)

 Before swallowing any Python solution, you should
 realize, the values (value, error) you are using are
 a non sense :

 1.03789291 +/- 0.00089

 You express more precision in the value than
 in the error.

My impression is that you didn't understand the original problem:
given an arbitrary value to arbitrary digits and an arbitrary error,
find the relevant number of digits for the value that makes sense for
the given error. So what you call non sense is part of the problem
to be solved.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in scientific way

2012-02-16 Thread Daniel Fetchinson
 Hi folks, often times in science one expresses a value (say
 1.03789291) and its error (say 0.00089) in a short way by parentheses
 like so: 1.0379(9)

 One can vary things a bit, but let's take the simplest case when we
 only keep 1 digit of the error (and round it of course) and round the
 value correspondingly. I've been searching around for a simple
 function that would take 2 float arguments and would return a string
 but didn't find anything although something tells me it's been done a
 gazillion times.

 What would be the simplest such function?

 Well, this basically works:

 def format_error(value, error):
 ... precision = int(math.floor(math.log(error, 10)))
 ... format = %%.%df(%%d) % max(-precision, 0)
 ... return format % (round(value, -precision),
 ...  int(round(error / 10 ** precision)))
 ...
 format_error(1.03789291, 0.00089)
 '1.0379(9)'

 Note that math.floor(math.log(error, 10)) may return the wrong
 decimal precision due to binary floating point rounding error, which
 could produce some strange results:

 format_error(10378929, 1000)
 '10378900(10)'

 So you'll probably want to use decimals instead:

 def format_error(value, error):
 value = decimal.Decimal(value)
 error = decimal.Decimal(error)
 value_scale = value.log10().to_integral(decimal.ROUND_FLOOR)
 error_scale = error.log10().to_integral(decimal.ROUND_FLOOR)
 precision = value_scale - error_scale
 if error_scale  0:
 format = %%.%dE % max(precision, 0)
 else:
 format = %%.%dG % (max(precision, 0) + 1)
 value_str = format % value.quantize(decimal.Decimal(10) **
 error_scale)
 error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
 if 'E' in value_str:
 index = value_str.index('E')
 return value_str[:index] + error_str + value_str[index:]
 else:
 return value_str + error_str

 format_error(1.03789291, 0.00089)
 '1.0379(9)'
 format_error(103789291, 1000)
 '1.03789(1)E+08'

 I haven't tested this thoroughly, so use at your own risk. :-)

Thanks a lot, this indeed mostly works, except for cases when the
error needs to be rounded up and becomes two digits:

 format_error( '1.34883', '0.0098' )
'1.349(10)'

But in this case I'd like to see 1.35(1)

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format a measurement result and its error in scientific way

2012-02-16 Thread Daniel Fetchinson
On 2/16/12, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Feb 16, 2012 at 1:36 AM, Daniel Fetchinson
 fetchin...@googlemail.com wrote:
 Hi folks, often times in science one expresses a value (say
 1.03789291) and its error (say 0.00089) in a short way by parentheses
 like so: 1.0379(9)

 One can vary things a bit, but let's take the simplest case when we
 only keep 1 digit of the error (and round it of course) and round the
 value correspondingly. I've been searching around for a simple
 function that would take 2 float arguments and would return a string
 but didn't find anything although something tells me it's been done a
 gazillion times.

 What would be the simplest such function?

 Well, this basically works:

 def format_error(value, error):
 ... precision = int(math.floor(math.log(error, 10)))
 ... format = %%.%df(%%d) % max(-precision, 0)
 ... return format % (round(value, -precision),
 ...  int(round(error / 10 ** precision)))
 ...
 format_error(1.03789291, 0.00089)
 '1.0379(9)'

 Note that math.floor(math.log(error, 10)) may return the wrong
 decimal precision due to binary floating point rounding error, which
 could produce some strange results:

 format_error(10378929, 1000)
 '10378900(10)'

 So you'll probably want to use decimals instead:

 def format_error(value, error):
 value = decimal.Decimal(value)
 error = decimal.Decimal(error)
 value_scale = value.log10().to_integral(decimal.ROUND_FLOOR)
 error_scale = error.log10().to_integral(decimal.ROUND_FLOOR)
 precision = value_scale - error_scale
 if error_scale  0:
 format = %%.%dE % max(precision, 0)
 else:
 format = %%.%dG % (max(precision, 0) + 1)
 value_str = format % value.quantize(decimal.Decimal(10) **
 error_scale)
 error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
 if 'E' in value_str:
 index = value_str.index('E')
 return value_str[:index] + error_str + value_str[index:]
 else:
 return value_str + error_str

 format_error(1.03789291, 0.00089)
 '1.0379(9)'
 format_error(103789291, 1000)
 '1.03789(1)E+08'

 I haven't tested this thoroughly, so use at your own risk. :-)

 Thanks a lot, this indeed mostly works, except for cases when the
 error needs to be rounded up and becomes two digits:

 format_error( '1.34883', '0.0098' )
 '1.349(10)'

 But in this case I'd like to see 1.35(1)

 A small adjustment to the scale fixes that.  Also tidied up the string
 formatting part:

 import decimal

 def format_error(value, error):
 value = decimal.Decimal(value)
 error = decimal.Decimal(error)
 error_scale = error.adjusted()
 error_scale += error.scaleb(-error_scale).to_integral().adjusted()
 value_str = str(value.quantize(decimal.Decimal(1E%d % error_scale)))
 error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
 if 'E' in value_str:
 index = value_str.index('E')
 return value_str[:index] + error_str + value_str[index:]
 else:
 return value_str + error_str

 Cheers,
 Ian

Thanks, it's simpler indeed, but gives me an error for value=1.267, error=0.08:

Traceback (most recent call last):
  File /home/fetchinson/bin/format_error, line 26, in module
print format_error( sys.argv[1], sys.argv[2] )
  File /home/fetchinson/bin/format_error, line 9, in format_error
error_scale += error.scaleb( -error_scale ).to_integral(  ).adjusted(  )
  File /usr/lib64/python2.6/decimal.py, line 3398, in scaleb
ans = self._check_nans(other, context)
  File /usr/lib64/python2.6/decimal.py, line 699, in _check_nans
other_is_nan = other._isnan()
AttributeError: 'int' object has no attribute '_isnan'

Which version of python are you using?

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


format a measurement result and its error in scientific way

2012-02-15 Thread Daniel Fetchinson
Hi folks, often times in science one expresses a value (say
1.03789291) and its error (say 0.00089) in a short way by parentheses
like so: 1.0379(9)

One can vary things a bit, but let's take the simplest case when we
only keep 1 digit of the error (and round it of course) and round the
value correspondingly. I've been searching around for a simple
function that would take 2 float arguments and would return a string
but didn't find anything although something tells me it's been done a
gazillion times.

What would be the simplest such function?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLObject 1.2.0

2011-11-21 Thread Daniel Fetchinson
Thanks a million Oleg!

Cheers,
Daniel


On 11/20/11, Oleg Broytman p...@phdru.name wrote:
 Hello!

 I'm pleased to announce version 1.2.0, the first stable release of branch
 1.2 of SQLObject.


 What is SQLObject
 =

 SQLObject is an object-relational mapper.  Your database tables are
 described
 as classes, and rows are instances of those classes.  SQLObject is meant to
 be
 easy to use and quick to get started with.

 SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
 Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


 Where is SQLObject
 ==

 Site:
 http://sqlobject.org

 Development:
 http://sqlobject.org/devel/

 Mailing list:
 https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

 Archives:
 http://news.gmane.org/gmane.comp.python.sqlobject

 Download:
 http://pypi.python.org/pypi/SQLObject/1.2.0

 News and changes:
 http://sqlobject.org/News.html


 What's New
 ==

 Features  Interface
 

 * Strings are treated specially in Select to allow
   Select(['id, 'name'], where='value = 42'). Update allows a string in
   WHERE.

 * ForeignKey('Table', refColumn='refcol_id') to allow ForeignKey to
   point to a non-id column; the referred column must be a unique integer
   column.

 * delColumn now accepts a ForeignKey's name without 'ID'.

 * Support for PostgreSQL 7.* is dropped. The minimal supported version of
   PostgreSQL is 8.1 now.

 * Quoting rules changed for PostgreSQL: SQLObject uses E'' escape string
   if the string contains characters escaped with backslash.

 * A bug caused by psycopg2 recently added a new boolean not callable
   autocommit attribute was fixed.

 * sqlobject.__doc__ and main.__doc__ no longer contain version number.
   Use sqlobject.version or version_info.

 For a more complete list, please see the news:
 http://sqlobject.org/News.html

 Oleg.
 --
  Oleg Broytmanhttp://phdru.name/p...@phdru.name
Programmers don't die, they just GOSUB without RETURN.
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


OT

2011-08-19 Thread Daniel Fetchinson
I'll be 59 in a couple of months.

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: web hosting, first hand experiences?

2011-07-04 Thread Daniel Fetchinson
 Hi folks, I know this comes up regularly but the thing is that the
 quality of service changes also quite regularly with many of the
 hosting companies. What's currently the best option for shared hosting
 of a turbogears application? I'm thinking of dreamhost and webfaction
 does anyone have any recent experiences with these two? Or others?

 Cheers,
 Daniel


 Hi Daniel,

 I can wholeheartedly recommend WebFaction.  I currently have an account
 running 3 different CherryPy applications (so TurboGears shouldn't pose
 any problems), and apart from initial teething problems, they have been
 running for months without interruption.  As well as an excellent
 control panel, they give you full Linux command-line access to your
 site(s).  The level of support is as good as you will get anywhere
 (short of having experts with you in the office!), and they know a huge
 amount about Python web applications.  Nothing seems to be too much
 trouble for them.  They also provide a 60-day money-back guarantee, so
 you can try-before-you-buy.

 Best wishes,
 Alan Harris-Reid

Thanks for all the responses, based on the feedback I'll go with
webfaction I guess.
They were my first choice anyway but wanted to double check with
people in the know about their current situation.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


web hosting, first hand experiences?

2011-07-03 Thread Daniel Fetchinson
Hi folks, I know this comes up regularly but the thing is that the
quality of service changes also quite regularly with many of the
hosting companies. What's currently the best option for shared hosting
of a turbogears application? I'm thinking of dreamhost and webfaction
does anyone have any recent experiences with these two? Or others?

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


Re: New member intro and question

2011-06-18 Thread Daniel Fetchinson
 gush
 I'm a new list member from the United States. Long time programmer,
 fairly new to Python and absolutely loving it so far! I'm 36, live in
 Oklahoma, and own a small Linux software development and consulting
 firm. Python has made my life a *lot* easier and, the more I learn,
 the easier it gets. Simply blown away.
 /gush

 Now, for my question: I'm taking on a project that will run on plug
 computers and I'm thinking about using Python to do it. It seems like
 a really attractive option over C/C++ and I think it would cut down
 the dev time immensely. I know a scaled down version of Debian can run
 on the computer but I'm wondering about Python.

 Has anyone ever used Python to develop for extremely limited resource
 computers like this? Specifically, I'm going to be using the DreamPlug
 (http://www.geek.com/articles/gadgets/dreamplug-puts-a-1-2ghz-arm-pc-in-a-power-outlet-2011022/)
 which isn't too shabby but I wonder if it will work.

The netbook I use with fedora linux and basically every major python
release from 2.4 to 3.2 has more limited resources :)

So yes, python would run on your gadget no problem.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Postmortem on Unladen Swallow

2011-04-14 Thread Daniel Fetchinson
 There's a postmortem on the failure of Unladen Swallow by one of the
 developers at:

 http://qinsb.blogspot.com/2011/03/unladen-swallow-retrospective.html

This outcome of things is really a testament to the hard work of the pypy folks.
They, a volunteer bunch, beat google!
And that's something to be proud of, I'd think.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Common practice for multiple python versions sharing 3rd party modules

2011-04-09 Thread Daniel Fetchinson
Hi folks,

In order to test my own modules with various python versions I've
installed python 2.4, 2.5, 2.6, 2.7, 3.1, 3.2. The original
installation on my fedora box was 2.6 and all 3rd party modules so far
were installed under /usr/lib/python2.6/site-packages. Since now the
executable 'python' points to python 2.7 and lot of programs have
#!/usr/bin/env python at the top, these programs try to use 2.7. But
there are no 3rd party modules installed for 2.7 so programs that need
these do not run. Of course I can just replace #!/usr/bin/env python
with #!/usr/bin/env python2.6 but doing so for all programs would be a
pain.

Also, once I have a 3rd party module installed in
/usr/lib/python2.6/site-packages I wouldn't want to copy all of these
to /usr/lib/pythonX.Y/site-packages (assuming they are compatible with
pythonX.Y).

What would be the most common practice for having a single location
for 3rd party modules and all python versions could have access to
them?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
 what is the character limit on a one liner :P.

 For PEP 8 compliance, 80 characters. :-)

Yeah, but we don't live in the 80's or 90's anymore and our screens
can support xterms (or let alone IDE widows) much wider than 80
characters. I'm using 140 for python these days. Seriously, who would
want to limit him/herself to 80 characters in 2011?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
 what is the character limit on a one liner :P.

 For PEP 8 compliance, 80 characters. :-)

 Yeah, but we don't live in the 80's or 90's anymore and our screens can
 support xterms (or let alone IDE widows) much wider than 80 characters.
 I'm using 140 for python these days. Seriously, who would want to limit
 him/herself to 80 characters in 2011?

 Seriously, or is that a rhetorical question?

Rhetorical :)

What it intended to demonstrate is that it is possible to rationalize
ancient habits which have their origins in particular circumstances of
those ancient times but actually nothing necessitates them today other
than the momentum built around them during their lifetime (which is a
pretty strong argument for them by the way).

Cheers,
Daniel


 People who like to have two source files side-by-side on a standard
 sized monitor, or three on a wide-screen monitor.

 People who need to read or edit source code on a virtual terminal rather
 than in a GUI console app.

 People who print out source code to read later.

 People with poor vision who need to use a significantly larger sized
 characters, and therefore can't fit as many on a line.

 People who might want to email code snippets without having them
 inconveniently wrapped by the mail client.

 People who don't like reading really long, overly complex, lines, and
 prefer to keep lines short for readability.

 And most importantly... people who want to have their code accepted into
 the Python standard library.


 Personally, I find that the discipline of keeping to 80 characters is
 good for me. It reduces the temptation of writing obfuscated Python one-
 liners when two lines would be better. The *only* time it is a burden is
 when I write doc strings, and even then, only a small one.



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



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestion Reqd for Designing a Website in Python

2011-02-25 Thread Daniel Fetchinson
 I have developed one big Machine Learning software a Machine
 Translation system in Python.
 Now, I am thinking to make a User Interface of it and upload it in a
 web site.

 Do you mean you want people to download this from a web site as an
 executable, and then run it locally on their computers?  Or do you mean
 you
 want people to use this as a web site, using their web browsers?  The
 answers are very different.

 My questions are:
 (i) For Designing an interface I am choosing Tkinter. Is it fine?
 (ii) How to connect this interface with my Tkinter based interface -
 should I have to recode the whole system?
 (iii) After designing I want to upload now how to do the server side
 scripting?

 Question (i) implies that you want the first option (download an
 executable
 and run it).  Question (iii) implies the second (that you want your app to
 run on a web server so people use it through your browser).  Please
 clarify.
 --
 Tim Roberts, t...@probo.com
 Providenza  Boekelheide, Inc.

 Thank you for your kind reply.
 I want to design an interface like Google Translate. So that users can
 paste text (of any length)-or may browse files which can be uploaded,
 and one user interface for filling up form, so that attached files
 after translation may be sent back to the given e-mail id as an
 attached file(.pdf/.txt).
 Best Regards,
 Subhabrata.

In this case you are looking for a web application framework. There
are many written in python, a good place to start would be:

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

My personal opinion is that the 3 top frameworks to consider are: (1)
django (2) turbogears (3) web2py. You need to decide for yourself
which one use choose, you may even choose something other than these
3, there are tons more.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use the Source Luke

2011-02-05 Thread Daniel Fetchinson
 For the Python world though, there does seem
 to have been a change.  A decade ago in this newsgroup, there were
 frequent references to standard library source.  I don't see that
 much anymore.

Popularity has a price. A decade ago only hackers were exposed to
python who are happy to chat about the source code but these days
average computer users (my grandma) frequently come across python and
ask questions from a user perspective.

So I'd think your observation is correct that the ratio of source
related posts to non-source related posts on this list went down but
the reason is not because the total number of source related questions
decreased but because the total number of non-source related questions
increased.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting bug

2011-01-01 Thread Daniel Fetchinson
 Dear Group,

 Hope all of you are fine and spending nice new year evenings.

 I get a bug in Python over the last 4 years or so, since I am using
 it. The language is superb, no doubt about it. It helped me finish
 many a projects, with extraordinary accuracy. But long since, I was
 getting an interesting bug. In the initial days, I thought it may be
 my learning error or usability error. It comes every now and then. The
 bug is suppose I am calling a library or using some logical operator,
 it works fine initially but if I want to copy the code to some other
 modules, same line of codes do not run at all.

 The remedy I do is,
 (a) I take the code from file and test it in GUI, more astonishingly
 in 99% of the cases I found the code llines, are correct.
 Then I apply a brute force technique I rewrite the whole code again.
 For small codes this technique is okay, but if I write mammoth code,
 and all on a sudden some interesting behavior came out, well it really
 feels bad. I keep now a days some time out that I have to do this, but
 is there any definite solution? I believe there is some, as I do not
 know them, as it happens, unnecessarily get upset.

 I use Python on WinXP service pack2, I started to use Python2.5.1, and
 now I am using Python2.6.5, IDLE as GUI.

 Best Regards,
 Subhabrata

An AI bot is playing a trick on us.
Focus and don't let your guards down!

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Daniel Fetchinson
 I'm trying to solve a computational problem and of course speed and size is
 important there. Apart from picking the right algorithm, I came across an
 idea that could help speed up things and keep memory requirements down. What
 I have is regions described by min and max coordinates. At first, I just
 modeled these as a simple class containing two values for each axis.

 In a second step, I derived this class from tuple instead of object. Some
 code then moved from __init__ to __new__ and some code that modified these
 objects had to be changed to replace them instead. The upside to this is
 that they can be used as keys in sets and dicts, which isn't the case for
 mutable types[1].

 What I'm now considering is to only allow a single instance of these objects
 for each set of values, similar to interned strings. What I would gain is
 that I could safely compare objects for identity instead of equality. What
 I'm not yet sure is how much overhead that would give me and/or how to keep
 it low. The idea is to store each instance in a set and after creating a new
 object I would first look up an equal object in the global set and return
 that instead, otherwise add the new one.

 The problem I foresee is that if I define equality as identity, this lookup
 when creating will never eliminate duplicates. If I only fall back to
 equality comparison for non-identical objects, I would probably sacrifice
 most of the gain. If I build a dict mapping between the values and the
 actual objects, I would have doubled the required memory and uselessly store
 the same values twice there.

 Am I looking in the wrong direction? Is there some better approach? Please
 don't tell me to use C, as I'm specifically interested in learning Python,
 I'm pretty sure I could have solved the problem quickly in C++ otherwise.
 Other suggestions?

 Cheers!

 Uli


 [1] Somebody correct me if I'm wrong, but I believe I could have defined a
 hashing function for the type and thus allowed its use in a set or dict,
 right? However, goofing up because you accidentally modified an object and
 changed its hash value is something I don't want to risk anyway.

I believe what you are looking for is (some variant of) the singleton pattern:

http://en.wikipedia.org/wiki/Singleton_pattern

How it's done in python see http://www.google.com/search?q=python+singleton

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interning own classes like strings for speed and size?

2010-12-27 Thread Daniel Fetchinson
 I believe what you are looking for is (some variant of) the singleton
 pattern:

 http://en.wikipedia.org/wiki/Singleton_pattern

 Actually, no. What I want is the flyweight pattern instead:

 http://en.wikipedia.org/wiki/Flyweight_pattern

Oh I see. I did not know about this pattern, but in my defense it
looks like a variant of the singleton pattern :)

Thanks! One always learns something new on python-list.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Web App

2010-12-23 Thread Daniel Fetchinson
 Anybody know where I can find a Python Development Environment in the
 form of a web app for use with Chrome OS. I have been looking for a
 few days and all i have been able to find is some old discussions with
 python developers talking about they will want one for the OS to be a
 success with them.

 Personally, I think a web app based IDE would be ghastly; but, you might
 have a look at Mozilla Skywriter (formerly Bespin):

 Why grashtly?

 I don't personally think the web makes a good framework for highly
 interactive applications as they must work within the constraints of the
 browser and IDEs are highly interactive applications by their very nature.
 Perhaps HTML5/CSS3 will change things; but, standard DOM manipulation,
 as I am accustomed to seeing it, cannot generate the kind of rendering
 that is available from native applications.  Attempts to do so end up being
 kludgy.

 It also cannot handle the kinds of desktop integrations that are common
 for native applications without opening up serious security trust issues.
 (Can everybody say ActiveX fiasco?)

So, in essence, you are predicting that google's chrome OS will be a
failure, right?

 Finally, there are difficulties in handling keystrokes without conflicting
 with the browser's native key bindings.  I seldom ever touch a mouse
 and I am a huge fan of vi, mutt, slrn, screen, ratpoison, etc. where
 the primary interface is totally accessable through the keyboard without
 having to tab through many options.

Well, implementing vi or other text based tools in the browser is
trivial. I mean it will function in exactly the same way as a native
vi.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Added Python, WSGI to XAMPP

2010-12-17 Thread Daniel Fetchinson
 How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
 http://www.apachefriends.org/f/viewtopic.php?f=17t=42981

 Maybe, if there's no Zope.  Or we'll run away screaming...

 That is rather pathetically true...

 Ah well, each to their own...

 Chris

 What I really don't like right off is that Pyramid is contorting the MVC
 model just as Django did with their MTV model.  They are both making the
 controller be the view and this confuses the hell out of people who come
 from true MVC based projects.

 The VIEW is the bits that stream out of the webserver back to the users
 browser.  The CONTROLLER is the code that gathers all the pieces from
 the model and constructs the python code that is then fed to the engine
 that then creates the view.  And just because the controller navigates
 the logic to dynamically contruct/render a view, that does not make 'it'
 the view.

In turbogears that is exactly what happens.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inverse of a matrix with Fraction entries

2010-11-25 Thread Daniel Fetchinson
  I wouldn't do it that way.  Let M be your matrix.  Work out the LCM l of
  the denominators, and multiply the matrix by that to make it an integer
  matrix N = l M.  Then work out the determinant d of that integer matrix.
  Next, the big step: use Gaussian elimination to find a matrix A (the
  `adjugate matrix') such that A N = d I.  This should be doable entirely
  using integer arithmetic, and I think without needing any divisions.
  Finally, we have l A M = d I, so (l/d A) M = I and l/d A is the inverse
  you seek.
 
  Does that make sense?

 Absolutely! But there is nothing wrong with working out the inverse
 directly using fractions.Fraction arithmetic, I'd think.

 It'll work, certainly; but the Fraction implementation will have to do a
 buttload of GCD computations that it wouldn't need to do if you worked
 with plain integers.  And GCDs are relatively hard, as arithmetical
 computations go: the usual algorithms require either a number of
 divisions (which are themselves rather costly) or a bitwise traversal of
 one of the operands.

 A million entries seems nontrivial for a matrix, and Gaussian
 elimination has cubic running time if I remember rightly; I suspect that
 the transformations I describe would reduce the running time by a fair
 amount.  Of course, I might be drastically underestimating the
 performance of modern hardware -- I often do -- so this may not be
 especially relevant.  Anyway, the possibility's there.

Okay, I see your point and I completely agree.
Surely it will be faster to do it with integers, will give it a shot.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
I guess this is a question to folks with some numpy background (but
not necessarily).

I'm using fractions.Fraction as entries in a matrix because I need to
have very high precision and fractions.Fraction provides infinite
precision (as I've learned from advice from this list). Now I need to
calculate its inverse. Can numpy help in this regard? Can I tell numpy
that the inverse matrix should also have entries in
fractions.Fraction? Or numpy can only do floating point calculations?

Probably it doesn't matter but the matrix has all components non-zero
and is about a thousand by thousand in size.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
 I guess this is a question to folks with some numpy background (but
 not necessarily).

 I'm using fractions.Fraction as entries in a matrix because I need to
 have very high precision and fractions.Fraction provides infinite
 precision (as I've learned from advice from this list).

 Infinite precision only for values that can be expressed as a fraction:

 Fraction(2)**Fraction(1, 2)
 1.4142135623730951
 type(_)
 type 'float'

True, but I only need to add, multiply and divide my fractions in
order to end up with the entries in the matrix.

 Now I need to
 calculate its inverse. Can numpy help in this regard? Can I tell numpy
 that the inverse matrix should also have entries in
 fractions.Fraction? Or numpy can only do floating point calculations?

 I tried it, and numpy.linalg.inv() converted the Fraction values to float.
 If you aren't concerned about efficiency it should be easy to do it
 yourself, in pure python.

If there is no other way, that's what I'll try to do.

 You could also ask on the numpy mailing list.

 Probably it doesn't matter but the matrix has all components non-zero
 and is about a thousand by thousand in size.

 Hmm, where did you get that million of exact fractions from?

The million of exact fractions are coming from a recursion relation.
This recursion relation only adds, multiplies and divides numbers so
the end result is always a rational number.

 If some real
 world data is involved the error introduced by the floating point
 calculation may be negligable in comparison with the initial measurement
 uncertainty.

It's a mathematical problem so no uncertainty is present in the
initial values. And even if there was, if there are many orders of
magnitude differences between the entries in the matrix floating point
does not suffice for various things like eigenvalue calculation and
stuff like that.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
 I guess this is a question to folks with some numpy background (but
 not necessarily).

 I'm using fractions.Fraction as entries in a matrix because I need to
 have very high precision and fractions.Fraction provides infinite
 precision (as I've learned from advice from this list).

 Infinite precision only for values that can be expressed as a fraction:

 Fraction(2)**Fraction(1, 2)
 1.4142135623730951
 type(_)
 type 'float'

 True, but I only need to add, multiply and divide my fractions in
 order to end up with the entries in the matrix.

 Now I need to
 calculate its inverse. Can numpy help in this regard? Can I tell numpy
 that the inverse matrix should also have entries in
 fractions.Fraction? Or numpy can only do floating point calculations?

 I tried it, and numpy.linalg.inv() converted the Fraction values to
 float. If you aren't concerned about efficiency it should be easy to do
 it yourself, in pure python.

 If there is no other way, that's what I'll try to do.

 You could also ask on the numpy mailing list.

 Probably it doesn't matter but the matrix has all components non-zero
 and is about a thousand by thousand in size.

 Hmm, where did you get that million of exact fractions from?

 The million of exact fractions are coming from a recursion relation.
 This recursion relation only adds, multiplies and divides numbers so
 the end result is always a rational number.

 If some real
 world data is involved the error introduced by the floating point
 calculation may be negligable in comparison with the initial measurement
 uncertainty.

 It's a mathematical problem so no uncertainty is present in the
 initial values. And even if there was, if there are many orders of
 magnitude differences between the entries in the matrix floating point
 does not suffice for various things like eigenvalue calculation and
 stuff like that.

 It may be worthwhile to have a look at http://www.sagemath.org/

 sage: Matrix([[1,2],[3,4]])**-1

 [  -21]
 [ 3/2 -1/2]
 sage: a = Matrix([[1,2],[3,4]])
 sage: b = Matrix([[1,2],[3,4]])**-1
 sage: a*b

 [1 0]
 [0 1]
 sage: type(b[1,1])
 type 'sage.rings.rational.Rational'

This sounds like a good idea!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
 I'm using fractions.Fraction as entries in a matrix because I need to
 have very high precision and fractions.Fraction provides infinite
 precision . . .

 Probably it doesn't matter but the matrix has all components non-zero
 and is about a thousand by thousand in size.

 I wonder how big the numerators and denominators in those
 fractions are going to get during the matrix inversion.  Would
 it be surprising if the elements of the inverse matrix had
 numerators and denominators a million times longer than the
 original matrix?

I've checked this with Maple for matrix size 150 x 150 and the
numerators and denominators do get pretty long. But that's okay as
long as it is kept exact.

The whole story is that I have a matrix A and matrix B both of which
have rational entries and they both have pretty crazy entries too.
Their magnitude spans many orders of magnitude, but inverse(A)*B is an
okay matrix and I can deal with it using floating point numbers. I
only need this exact fraction business for inverse(A)*B (yes, a
preconditioner would be useful :))

And I wouldn't want to write the whole matrix into a file, call Maple
on it, parse the result, etc.

So after all I might just code the inversion via Gauss elimination
myself in a way that can deal with fractions, shouldn't be that hard.

Cheers,
Daniel




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
 It's a mathematical problem so no uncertainty is present in the
 initial values. And even if there was, if there are many orders of
 magnitude differences between the entries in the matrix floating point
 does not suffice for various things like eigenvalue calculation and
 stuff like that.

 Well, if you want to do eigenvalue calculations, you are going to have to
 start
 doing numerical approximations anyways. There is no analytical solution for
 matrices larger than 4x4.

Sure! (I didn't explain the whole thing yet, see the other reply where
I actually do.)

 Sympy will do inverses of matrices over rationals for you, though:

 |4 from sympy import *

 |6 m = Matrix([[S(1)/2, S(1)/3], [S(1)/4, S(1)/5]])

 |7 m
 [1/2, 1/3]
 [1/4, 1/5]

 |8 m.inv()
 [ 12, -20]
 [-15,  30]

Thanks a lot! This sounds like the simplest solution so far.
I don't need to call Maple after all :)

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
 So after all I might just code the inversion via Gauss elimination
 myself in a way that can deal with fractions, shouldn't be that hard.

 I wouldn't do it that way.  Let M be your matrix.  Work out the LCM l of
 the denominators, and multiply the matrix by that to make it an integer
 matrix N = l M.  Then work out the determinant d of that integer matrix.
 Next, the big step: use Gaussian elimination to find a matrix A (the
 `adjugate matrix') such that A N = d I.  This should be doable entirely
 using integer arithmetic, and I think without needing any divisions.
 Finally, we have l A M = d I, so (l/d A) M = I and l/d A is the inverse
 you seek.

 Does that make sense?

Absolutely! But there is nothing wrong with working out the inverse
directly using fractions.Fraction arithmetic, I'd think.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


what's the precision of fractions.Fraction?

2010-11-18 Thread Daniel Fetchinson
I do a recursive evaluation of an expression involving fractions and
unsurprisingly the numerator and denominator grows pretty quickly.
After 10-20 iterations the number of digits in the numerator and
denominator (as integers) reaches 80-100. And I'm wondering until what
point I can trust the result since I'm using fractions.Fraction for
the whole procedure. Are Fraction's infinite precision? Or will I get
some sort of an exception if python is not able to represent the
numerator and/or denominator as integers?

http://www.python.org/dev/peps/pep-3141/ was not very helpful in this
regard nor was http://docs.python.org/library/fractions.html

Any ideas?

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what's the precision of fractions.Fraction?

2010-11-18 Thread Daniel Fetchinson
 I do a recursive evaluation of an expression involving fractions and
 unsurprisingly the numerator and denominator grows pretty quickly.
 After 10-20 iterations the number of digits in the numerator and
 denominator (as integers) reaches 80-100. And I'm wondering until what
 point I can trust the result since I'm using fractions.Fraction for
 the whole procedure. Are Fraction's infinite precision? Or will I get
 some sort of an exception if python is not able to represent the
 numerator and/or denominator as integers?

 Since fractions are represented as a pair of integers, and since python
 integers have unlimited precision, I would guess that fractions also have
 unlimited precision.  You could check the code if you want to be absolutely
 sure.

Sounds reasonable, thanks a lot,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I The Only One Who Keeps Reading “Numpy” as “Numpty”?

2010-11-12 Thread Daniel Fetchinson
As in Numpty Dumpty?

 Sorry...




-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 2.3

2010-11-11 Thread Daniel Fetchinson
 The problem is that some part of the application gets installed to

 /home/fetchinson/.local/lib/python2.6/site-packages/GUI

 and some other parts get installed to

 /home/fetchinson/.local/lib/python/site-packages/GUI

 Which parts get installed in which places, exactly?

This gets installed to /home/fetchinson/.local/lib/python/GUI :

Generic
Gtk
__init__.py
__init__.pyc
Version.py
Version.pyc
_where.py
_where.pyc

And this gets installed to
/home/fetchinson/.local/lib/python2.6/site-packages/GUI :

Resources


 I'm puzzled, because I can't see anything in the setup.py
 that could result in things getting split up like this.
 I'm wondering whether there is some breakage in distutils.

I honestly have no idea :)

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cms 4 static pages?

2010-11-04 Thread Daniel Fetchinson
 m looking 4 a framework, that allows to build static community software
 (similar to facebook) without having to start scripts, database
 connects, admin cookies, e.t.c.

 means - should be dynamic without really being dynamic, delivering just
 static pages. (yes, i know e.g. nginx does that by caching, thats not
 what i want!)

 features wanted:

 a not database driven

 b password access ist done by just renaming users home directory. User
 at logout will receive new secret subdirectory name 4 new login.

 c no clientside scripting. changing layout will be done by rebuilding
 all relevant static pages in user directory once by serverside script.

 d new entries e.g. mail, discussions will be queued, user just sees: tnx
 4 your new article, page will be rebuilt in ... estimated 3 seconds ...
 or estimated 10 seconds ... depending on load and todo queue length.

 e load balancing is done by just replicating static pages between
 servers after new rebuild of static pages.

 f simulation of received mail directory through just rebuilding relevant
 static html tree. attachments not allowed.

 g intelligent todo queue 4 resorting mail sent, received, discussions,
 look and feel before rebuilding static user pages. (herein lies the
 intelligence of the whole system)

 h notifications 4 new mail, messages, e.t.c. are just updates in static
 html fields. if user gets offline (measured by time since last update of
 static pages) user will be informed once a day by mail.

 i simulation of locking can easily be done by dotfiles.

 j according 2 my calculations such system should be able 2 satisfy any
 bandwidth without causing significant load of cpu, due 2 low protocol
 overhead and no server side scripting, no database load. overload of
 server should not possible by design.

 k modules, addon 4 twitter e.g., nice 2 have


 (and no, no java!) any pointers?

Yeah, rethink your design!

Seriously, you listed a number of features which are not really
features but implementation details and you haven't told us what your
original goals are which you think are fulfilled by these
implementation details. If you would clearly state what your goals are
(regardless of how it is implemented) I'm 100% certain a better
implementation can be found than the one you enumerated.

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: playful coding problems for 10 year olds

2010-11-02 Thread Daniel Fetchinson
 Hi folks,

 My niece is interested in programming and python looks like a good
 choice (she already wrote a couple of lines :)) She is 10 and I
 thought it would be good to have a bunch of playful coding problems
 for her, stuff that she could code herself maybe after some initial
 help.

 Do you guys know problems like these? Or a good resource where to look
 them up?

 Cheers,
 Daniel


 There's a great book valled 'Invent your own computer games using
 Python', aimed at kids, which teaches programming from tne ground up,
 in the context of writing games, starting with terminal word games,
 ending with Pygame fullscreen 2D vector graphic  bitmaps affairs.
 http://inventwithpython.com/

 The website says aimed at kids 'ages 10 to 12 and upwards', so it
 sounds like she's on the minimum cusp.

 (now I come to look at the website, one of the quotes he features is
 from an Amazon review I wrote months ago! :-)


Thanks a lot for everyone for the suggestions,
I think I'll be able to cook things up from all
the references you sent!

Cheers,
Daniel

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


playful coding problems for 10 year olds

2010-11-01 Thread Daniel Fetchinson
Hi folks,

My niece is interested in programming and python looks like a good
choice (she already wrote a couple of lines :)) She is 10 and I
thought it would be good to have a bunch of playful coding problems
for her, stuff that she could code herself maybe after some initial
help.

Do you guys know problems like these? Or a good resource where to look them up?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 2.3

2010-10-27 Thread Daniel Fetchinson
 PyGUI 2.3 is available:

http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/

 This version works on Snow Leopard with PyObjC 2.3.


 What is PyGUI?
 --

 PyGUI is a cross-platform GUI toolkit designed to be lightweight
 and have a highly Pythonic API.

Installation to a custom location with

python setup.py install --home=/home/fetchinson/.local

makes GUI un-importable:

[fetchin...@fetch ~]$ python
Python 2.6.2 (r262:71600, Aug 21 2009, 12:23:57)
[GCC 4.4.1 20090818 (Red Hat 4.4.1-6)] on linux2
Type help, copyright, credits or license for more information.
 import GUI
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named GUI


The problem is that some part of the application gets installed to

/home/fetchinson/.local/lib/python2.6/site-packages/GUI

and some other parts get installed to

/home/fetchinson/.local/lib/python/site-packages/GUI

which makes the install broken. If I move everything from the latter
location to the former, it all works though.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 2.3

2010-10-26 Thread Daniel Fetchinson
 PyGUI 2.3 is available:

http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/

 This version works on Snow Leopard with PyObjC 2.3.

Any reason your project is not easy_installable?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


[OFF] sed equivalent of something easy in python

2010-10-25 Thread Daniel Fetchinson
This question is really about sed not python, hence it's totally off.
But since lots of unix heads are frequenting this list I thought I'd
try my luck nevertheless.

If I have a file with content

1
2
3
4
5
6
7
8
...

i.e. each line contains simply its line number, then it's quite easy
to convert it into

2
3
7
8
12
13
...

using python. The pattern is that the first line is deleted, then 2
lines are kept, 3 lines are deleted, 2 lines are kept, 3 lines are
deleted, etc, etc.

But I couldn't find a way to do this with sed and since the whole
operation is currently done with a bash script I'd hate to move to
python just to do this simple task.

What would be the sed equivalent?

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OFF] sed equivalent of something easy in python

2010-10-25 Thread Daniel Fetchinson
 using python. The pattern is that the first line is deleted,
 then 2 lines are kept, 3 lines are deleted, 2 lines are kept,
 3 lines are deleted, etc, etc.

 If you have GNU sed, you can use

sed -n '2~5{N;p}'

 which makes use of the GNU ~ extension. If you need a more
 portable version:

   sed -n '1d;N;p;N;N;N;d'

 Both have the side-effect that the expect the printed lines to
 come in pairs, so if you have

   seq 17 | sed -n '...'

 it won't print the 17, but if you take it to 18, it will print 17
 and 18.  To address that (so to speak), you can use

   sed -n '1d;p;n;p;N;N;N;d'

Thanks a lot, Tim!

 But I couldn't find a way to do this with sed and since the
 whole operation is currently done with a bash script I'd hate
 to move to python just to do this simple task.

 I'm not sure this is a great reason to avoid Python, but whatever
 floats your boat :)

Well, the reason I wanted to avoid python in this particular case is
that I have a large bash script that does its job perfectly and I
needed to insert this additional task into it. I had 3 choices: (1)
rewrite the whole thing in python (2) add this one task in python (3)
add this one task in sed. I chose (3) because (1) looked like a waste
of time and (2) made me take care of 2 files instead of 1 from now on.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Does everyone keep getting recruiting emails from google?

2010-10-14 Thread Daniel Fetchinson
I keep getting recruiting emails from charlesngu...@google.com about
working for google as an engineer. The messages are pretty much the
same and go like this:


I am part of the Google Staffing team and was wondering if you would
be open to exploring engineering opportunities with Google. I am
impressed with your background and thought your skills could be a fit
for our team.

I am currently looking for Engineers with hybrid Unix/Linux Systems
Administrators who possess experience in coding in C/C++ or Java
and/or scripting skills (Perl, Python, or Shell).

The Google.com Engineering Team is one of the most visible and
respected teams within Google, and the most mission critical. The team
is responsible for keeping the Google site and infrastructure up and
running 24/7, 365 days/year. They are dedicated to the scalability and
availability for the performance of Google applications. In short,
they maintain, monitor, and improve all Google services. Locations
primarily concentrated in Mt. View, Dublin, Zurich, with distributed
teams in San Francisco, Santa Monica, Boston, Kirkland, Seattle, New
York, London, and Sydney.

If you are interested, please email me an updated resume. If the
timing isn’t right for you to make a move, I would love to connect on
LinkedIn, and hopefully, we can keep in touch. Any referrals would be
appreciated!
-

I'm guessing I'm not the only one on this list to get these emails and
suspect that pretty much everyone gets them. Is that the case? If yes,
what's the point of spamming a more-or-less random set of people who
although are probably interested in IT-related stuff but who can
otherwise also be a set of dogs. Aren't enough people applying without
this?

Just wondering,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   >