[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



[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: 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


Re: how do I search python mailing list archives?

2010-10-13 Thread Daniel Fetchinson
 What are the various ways to search the python mailing list archives?

If you are searching for 'foo' and 'bar' you can try this in google:

foo bar site:mail.python.org inurl:python-list

Cheers,
Daniel


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


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Daniel Fetchinson
 Raymond Hettinger pyt...@rcn.com writes:

 It doesn't seem to be common knowledge when and how a[x] gets
 translated to a[x+len(x)].  So, here's a short info post on how Python
 supports negative indices for sequences.

 Thanks for this. Could you post your messages using a channel that
 doesn't arbitrarily split your paragraphs into long-short-long-short
 lines?

It came across fine for me as well (gmail with basic html interface).

 It makes paragraphs burdensome to read, and I skipped most of the
 message because of that.

You might want to switch to a client where you do not have this problem.

 I encourage anyone whose messages are munged like that to seek
 correction from their mail service provider, and switch to a different
 one until it's fixed.

I encourage anyone who has problems with reading various emails,
newsgroup postings, forums and what not, to start using modern tools
that work with the vast majority of other tools.

Cheers,
Daniel


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


Re: fairly urgent request: paid python (or other) work required

2010-09-02 Thread Daniel Fetchinson
On 9/1/10, lkcl luke.leigh...@gmail.com wrote:
 i apologise for having to contact so many people but this is fairly
 urgent, and i'm running out of time and options.   i'm a free software
 programmer, and i need some paid work - preferably python - fairly
 urgently, so that i can pay for food and keep paying rent, and so that
 my family doesn't get deported or have to leave the country.

 i really would not be doing this unless it was absolutely, absolutely
 essential that i get money.

 so that both i and the list are not unnecessarily spammed, please
 don't reply with recommendations of where to get jobs, unless they
 are guaranteed to result in immediate work and money.

 if you have need of a highly skilled and experienced python-preferring
 free-software-preferring software engineer, please simply contact me,
 and tell me what you need doing: there's no need for you to read the
 rest of this message.

 so that people are not offended by me asking on such a high-volume
 list for work, here are some questions and answers:

 Q: who are you?
 A: luke leighton.  free sofware developer, free software project
 leader, and unusual cross-project mash-up-er (meaning: i spot the
 value of joining one or more bits of disparate stuff to make
 something that's more powerful than its components).

 Q: where's your CV?
 A: executive version of CV is at http://lkcl.net/exec_cv.txt - please
 don't ask for a proprietary microsoft word version, as a refusal and
 referral to the sylvester response often offends.

 Q: what can you do?
 A: python programming, c programming, web development, networking,
 cryptography, reverse-engineering, IT security, etc. etc. preferably
 involving free software.

 Q: what do you need?
 A: money to pay rent and food.  at the ABSOLUTE MINIMUM, i need as
 little as £1500 per month to pay everything, and have been earning
 approx £800 per month for the past year.   a £5000 inheritance last
 year which i was not expecting has delayed eviction and bankruptcy for
 me and my family, and deportation for my partner and 17 month old
 daughter (marie is here in the UK on a FLR/M visa)

 Q: why are you asking here?
 A: because it's urgent that i get money really really soon; my family
 members are refusing to assist, and the few friends that i have do not
 have any spare money to lend.

 Q: why here and not monster jobs or python-jobs list or the
 various recruitment agencies?
 A: those are full-time employment positions, which i have been
 frequently applying for and get rejected for various reasons, and i'm
 running out of time and money.  further interviews cost money, and do
 not result in guaranteed work.  i need work - and money - _now_.

 Q: why here and not peopleperhour.com?
 A: if you've ever bid on peopleperhour.com you will know that you are
 bidding against offshore contrators and even being undercut by 1st
 world country bidders who, insanely, appear to be happy to do work for
 as little as £2 / hour.

 Q: why are you getting rejected from interviews?
 A: that's complex.  a) i simply don't interview well.  people with the
 classic symptoms of asperger's just don't. b) my daughter is 17 months
 old.  when i go away for as little as 3 days, which i've done three
 times now, she is extremely upset both when i am away and when i
 return.  i think what would happen if i was doing some sort of full-
 time job, away from home, and... i can't do it.  subconsciously that
 affects how i react when speaking to interviewers.

 Q: why do you not go get a job at tesco's or drive a truck?
 A: tescos and HGV driving etc. pay around £12 per hour.  £12 per hour
 after tax comes down to about £8 to £9 per hour.  £9 per hour requires
 35 hours per week to earn as little as £1500.  35 hours per week is
 effectively full-time, and means that a) my programming and software
 engineering skills are utterly, utterly wasted b) my daughter gets
 extremely upset because i won't be at home.

 so you get the gist, and thank you for putting up with me needing to
 take this action.



For the sake of your family, I'd recommend taking the following
paragraphs off your cv:


If you require someone whom you do NOT want to take
the initiative to assess all aspects of the required
work and beyond; if you require someone who will
stay in the box, do NOT contact me.



The speed at which I acquire new knowledge and be
able to integrate and recommend new ideas tends to
make insecure people feel frightened and threatened.



Pet Hates:  - peer to peer networking [peer equals neanderthal...]
- microsoft marketing machine [FUD at its best...]
- restrictive anti-competitive business practices
- information-restricive laws [DMCA etc.]
- Unreliable systems that cannot be made to do the job
  you really needed done yesterday...



I'd also recommend updating the links on 

Re: looking for open source python project

2010-08-29 Thread Daniel Fetchinson
 looking for a python project (preferably something a bit small) that
 is looking for contributors. the small bit is because i've never
 worked in a team before and haven't really read source code that's
 1000s of lines long, so i'm not too sure i can keep up.

 my python fu is decent (i think), i recently wrote a small archive/
 grimoire program (command line only) that can store multiline text
 with title, tags, and basic search functionality (not using curses so
 the entry, once entered, can't be modified), entries are stored in a
 pickle file.

 anybody have any suggestions? i'm keen to work on something with
 others, both for learning and i'd like to do something a bit
 meaningful, plus i'm sure it's fun.

Have a look at http://wiki.python.org/moin/CodingProjectIdeas

Cheers,
Daniel



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


Re: pypy

2010-08-25 Thread Daniel Fetchinson
 Just curious if anyone had the chance to build pypy on a 64bit
 environment and to see if it really makes a huge difference in
 performance. Would like to hear some thoughts (or alternatives).

I'd recommend asking about this on the pypy mailing list or looking at
their documentation first; see
http://codespeak.net/pypy/dist/pypy/doc/

HTH,
Daniel

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


Re: Save/load like matlab?

2010-08-23 Thread Daniel Fetchinson
 I wonder if there is a way to save and load all python variables just like
 matlab does, so I can build a code step by step by loading previous states.

 I am handling a python processing code for very large files and multiple
 processing steps. Each time I find a bug, I have to run the whole thing
 again, which is time consuming.

Perhaps pickle is the thing you are looking for?

http://docs.python.org/library/pickle.html

HTH,
Daniel


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


path to data files

2010-08-19 Thread Daniel Fetchinson
If a python module requires a data file to run how would I reference
this data file in the source in a way that does not depend on whether
the module is installed system-wide, installed in $HOME/.local or is
just placed in a directory from where the interpreter is fired up? I'd
like to always keep the python source and the data file in the same
directory, be it /usr/lib/python2.6/site-packages,
$HOME/.local/lib/python2.6/site-packages or
/arbitrary/path/to/somewhere.

If the data file is called 'foo' and I simply do open('foo') in the
python source file this will not work if they are both installed
either system-wide or locally. More precisely if the module is called
'foo.py', data file called 'foo', they are both in
/usr/lib/python2.6/site-packages and if foo.py I have open('foo') I'll
get a file not found error.

Any ideas?

Cheers,
Daniel



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


Re: path to data files

2010-08-19 Thread Daniel Fetchinson
 If a python module requires a data file to run how would I reference
 this data file in the source in a way that does not depend on whether
 the module is installed system-wide, installed in $HOME/.local or is
 just placed in a directory from where the interpreter is fired up? I'd
 like to always keep the python source and the data file in the same
 directory, be it /usr/lib/python2.6/site-packages,
 $HOME/.local/lib/python2.6/site-packages or
 /arbitrary/path/to/somewhere.


 open(os.path.join(os.path.dirname(__file__), 'foo'))

Thanks a lot!

Cheers,
Daniel


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


Re: how to save a whole web page with something block

2010-08-10 Thread Daniel Fetchinson
 I want to save a web page. I use urllib to parse the web page. But I
 find the saved file, where some content  is missing. The missing part
 is block from the original web page, such as this part  div
 style=display: block; id=GeneInts.../div.I don't know how to
 parse a whole page without something block in it. Could you help me
 figure it out? Thank you!


 This is my program

 url = 'http://receptome.stanford.edu/hpmr/SearchDB/getGenePage.asp?
 Param=4502931ProtId=1ProtType=Receptor'
 f = urllib.urlretrieve(url,'test.html')

A web server may present different output depending on the client
used. When you use your browser to look at the source and then use
urllib's saved file you access the web server with different clients.
I'm not saying this is your problem, but potentially it is.

So you might want to make urllib appear as a browser by sending the
appropriate headers.

HTH,
Daniel



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


Re: Smith-Waterman Algorithm in Python

2010-08-09 Thread Daniel Fetchinson
 Every one of the first 20 entries is either the OP questions or your
 reply.

 And you think it was there before the OP sent his message?
 Oh wait, did you just invent a time machine? :)

 Daniel - you are no help at all, and no funny.

 Actually, I'm damn funny! :)

 I have noticed before that people who post without searching first end
 up polluting subsequent searches. Google obviously boosts the
 rank of recent pages.

This is one of the three major reasons stackoverflow and friends were developed.

Cheers,
Daniel


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


Re: Smith-Waterman Algorithm in Python

2010-08-07 Thread Daniel Fetchinson
 Does any one about any implementation of classical Smith Waterman
 local alignment algorithm and it's variants for aligning natural
 language text?


 Please see http://tinyurl.com/2wy43fh


 Every one of the first 20 entries is either the OP questions or your reply.

And you think it was there before the OP sent his message?
Oh wait, did you just invent a time machine? :)

 Daniel - you are no help at all, and no funny.

Actually, I'm damn funny! :)

Cheers,
Daniel


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


Re: Smith-Waterman Algorithm in Python

2010-08-06 Thread Daniel Fetchinson
 Does any one about any implementation of classical Smith Waterman
 local alignment algorithm and it's variants for aligning natural
 language text?


Please see http://tinyurl.com/2wy43fh

Cheers,
Daniel


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


Re: Why is there no platform independent way of clearing a terminal?

2010-07-28 Thread Daniel Fetchinson
 After getting the technicalities out of the way, maybe I should have
 asked:

 Is it only me or others would find a platform independent python API
 to clear the terminal useful?

 There are two kinds of programs:
 1. Those that process input to output. If one of those suddenly started by
 clearing my screen, I'd just dump it. Also, if output is redirected to a
 file or piped into another program, that is basically useless or even
 hurting, since you then end up with control sequences in the file.

 2. Those that provide a text-based interactive UI. Those typically not only
 clear the screen, but also control its whole layout and content, so there
 you don't only need ways to clear the screen but also to position the
 cursor or draw boxes etc. In that case you need a full curses library.

 Summary: No, I don't see the need for such an API.

Okay, that makes perfect sense, thanks for the exaplanation!
I'll just live with the platform.system( ) check for this particular
problem then.

Cheers,
Daniel

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


Re: Why is there no platform independent way of clearing a terminal?

2010-07-28 Thread Daniel Fetchinson
  After getting the technicalities out of the way, maybe I should have
  asked:

  Is it only me or others would find a platform independent python API
  to clear the terminal useful?

 I don't know much, but just in case the following is useful to anyone:

 There is a Windows program called 'ansicon', which when installed (run
 with '-i'), will modify all future Windows cmd shells to correctly
 intercept and interpret ANSI escape codes for colors, cursor movement,
 and:

   \e[#J ED: Erase Display

 which I presume is what is under discussion here. I understand there
 are other historical ANSI drivers which were responsible for achieving
 a similar thing under Windows, but this is the method I currently use
 (on XP) and am very happy with.

 Also, and probably less usefully, personally I do wish Python provided
 a cross platform mechanism for simple  terminal control like clearing
 and colored text. Since ANSI codes are used everywhere except Windows,
 it would make sense to base such a system on them. So I started a pure
 Python implementation of a crude ANSI driver, on PyPI as 'colorama'.
 It does nothing on non-windows systems, but on Windows it patches
 sys.stdout with a stream-like object, in order to filter out ANSI
 codes and convert them into Win32 terminal control calls. It currently
 only works with colors and brightness, but I would love to extend it
 to cover other ANSI codes such as 'clear screen'. It is doubtless
 riddled with errors and misunderstandings, and I would love any
 feedback helping me do a better job.

Thanks, I didn't know about 'colorama' before but it surely looks promising!
I'll look into it for future reference, once in a while I like having
pretty output without the hassle of 'curses' or other complicated
stuff.

Cheers,
Daniel


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


Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread Daniel Fetchinson
Hi folks,

If I'm only interested in linux and windows I know I can do


import os
import platform

if platform.system( ) == 'Linux':
clear = 'clear'
else:
clear = 'cls'

os.system( clear )


or something equivalent using os.name and friends, but was wondering
why there is no platform independent way (i.e. the platform dependence
is taken care of by the python stdlib) of clearing a terminal. Sure,
there are many different terminals and many different operating
systems but in many areas python managed to hide all these
complexities behind a well defined API.

Why was clearing a terminal left out?

Cheers,
Daniel


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


Re: Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread Daniel Fetchinson
 Hi folks,

 If I'm only interested in linux and windows I know I can do

 
 import os
 import platform

 if platform.system( ) == 'Linux':
 clear = 'clear'
 else:
 clear = 'cls'

 os.system( clear )
 

 or something equivalent using os.name and friends, but was wondering
 why there is no platform independent way (i.e. the platform dependence
 is taken care of by the python stdlib) of clearing a terminal. Sure,
 there are many different terminals and many different operating
 systems but in many areas python managed to hide all these
 complexities behind a well defined API.

 Why was clearing a terminal left out?


 What you're talking about is a shell, not a terminal (a terminal is a
 physical device). And the shell is not necessarily part of the OS itself

 (there's no shortage of shells for unices / linux systems), so it
 doesn't belong to the os or platform modules.

 FWIW, I can't tell for sure since I never used any other shell than
 bash, but I'm not sure your above code is garanteed to work on each and
 any possible unix shell.

 Sorry, but that is completely wrong - the shell is irrelevant.

 clear is just a normal command line program that queries the
 termcap/terminfo database (possibly via the curses library) for the
 terminal specific sequence of characters that will clear the screen. It
 then writes those characters to stdout. The terminal, or (more usually
 these days) terminal emulator, then interprets those characters and takes
 the appropriate action.

 I'm not sure what the POSIX status of the clear command is, but I'd be
 surprised if it wasn't present on a UNIX/Linux system of any vintage.


After getting the technicalities out of the way, maybe I should have asked:

Is it only me or others would find a platform independent python API
to clear the terminal useful?

Cheers,
Daniel


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


Re: detect endianness of a binary with python

2010-07-22 Thread Daniel Fetchinson
 Something like the file utility for linux would be very helpfull.

 Any help is appreciated.

You're going to have to describe in detail what's in the file before
anybody can help.

 We are creating inside our buildsystem for an embedded system  a cram
 filesystem
 image. Later on inside our build process we have to check the endianness,
 because it could be Little Endian or big endian (arm or ppc).

 The output of the file tool is for a little endian cramfs image:
 ourImage: Linux Compressed ROM File System data, little endian size
 1875968
 version #2 sorted_dirs CRC 0x8721dfc0, edition 0, 462 blocks, 10 files

 It would be possible to execute
 ret = os.system(file ourImage | grep little endian)
 and evaluate the return code.
 But I don't like to evaluate a piped system command. If there is an way
 without
 using the os.system command this would be great.


Please see http://pypi.python.org/pypi/python-magic

HTH,
Daniel


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


Re: source install of python2.7 and rpm install of cx_Oracle collision

2010-07-21 Thread Daniel Fetchinson
  I make installed python 2.7 from source, and also installed the RPM version
 of cx_Oracle for python 2.7.

  But  ldd tells me :
 #ldd cx_Oracle.so
   libpython2.7.so.1.0 = not found

 I find out that only libpython2.7.a generated when I install python2.7, who
 can tell me what I need to do ?  I want a libpython2.7.so.1.0 generated when


 I install python.

 I am not familiar with GCC and .so .a stuff.

In this case I'd recommend removing the source install of python 2.7,
install it from rpm, followed by installing cx_Oracle from rpm.

HTH,
Daniel



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


Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-16 Thread Daniel Fetchinson
 I'm pleased to announce the release of inflect.py v0.1.8, a module that
 correctly generates:

 * the plural of singular nouns and verbs
 * the singular of plural nouns
 * ordinals
 * indefinite articles
 * present participles
 * and converts numbers to words

 Which languages does it support? If the answer is what I expect it is,

 It is. Most of the time, when people forget to say what they are talking
 about, assuming that they are either US-Americans or Windows users will hit
 the nail on the head.

And most of the time, when people are bitching about US-Americans,
assuming that they are Europeans will hit the nail on the head :)

Duck-and-run-ly yours,
Daniel


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


Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-16 Thread Daniel Fetchinson
 I'm pleased to announce the release of inflect.py v0.1.8, a module that
 correctly generates:

 * the plural of singular nouns and verbs
 * the singular of plural nouns
 * ordinals
 * indefinite articles
 * present participles
 * and converts numbers to words

 Which languages does it support? If the answer is what I expect it is,

 It is. Most of the time, when people forget to say what they are talking
 about, assuming that they are either US-Americans or Windows users will
 hit
 the nail on the head.

 And most of the time, when people are bitching about US-Americans,
 assuming that they are Europeans will hit the nail on the head :)

In this case, I actually should modify the above to: when people are
bitching about an English speaker they don't like for some reason and
they automatically think that said person must be US-American when in
fact he/she is Australian (or British or South African or something
else), assuming that they are Europeans will hit the nail on the head
:)

Duck-and-run-even-faster-ly yours,
Daniel



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


Re: how to install all python plugins

2010-07-15 Thread Daniel Fetchinson
 I`m using ubuntu 10.04 I want to install all the python plugins at once
 or the python plugins list.
 thank you in advance

What is a python plugin?

If you mean all published packages on the python website, then you
probably don't really want to install all of them, only those that you
need.

If you mean all python packages that are available through the package
manager of ubuntu, then you'll need to search the entire list of
available packages using ubuntu's package manager, pick out the ones
that have 'python' in their names (presumably, this is how it works on
fedora) and install them using the above mentioned package manager
software. If you don't know how to use it, please see

https://help.ubuntu.com/community/SynapticHowto
https://help.ubuntu.com/community/InstallingSoftware

HTH,
Daniel


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


Re: [ANN] inflect.py: generate plurals, ordinals, numbers to words...

2010-07-15 Thread Daniel Fetchinson
 I'm pleased to announce the release of inflect.py v0.1.8, a module that
 correctly generates:

 * the plural of singular nouns and verbs
 * the singular of plural nouns
 * ordinals
 * indefinite articles
 * present participles
 * and converts numbers to words

Wow!

Tons of kudos, this must have been hell of a work to put together with
all the irregular nouns/verbs/etc, and I really needed something like
this for a long time.

Thanks a lot,
Daniel


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


Re: eGenix at EuroPython 2010

2010-07-14 Thread Daniel Fetchinson
 EuroPython 2009 - Making 50 Mio. EUR per year using Python
 http://www.egenix.com/go23/

This link returns a 404.

Cheers,
Daniel



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


Re: Python script to install python

2010-07-08 Thread Daniel Fetchinson
 I would like to have a python script that would download the most
 recent svn of python, configure, make, install and cleanup after
 itself. I am not replacing the python version I would be using to run
 the script.
 I was struggling to get this to work and I assume someone else has
 done it better.  Any pointers?

Assuming you are on linux I recommend not using a python script for
this but rather a shell script. From a python script you would most of
the time be calling shell commands anyway. In a shell script you would
do something like this:


#!/bin/bash

svn checkout 
cd whatever
./configure --whatever-options-you-like
make
# you probably want to run this as root
make install
# you probably don't want to be root anymore
cd ..
rm -rf whatever



If you are on windows I assume a similar strategy is best.

Cheers,
Daniel



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


Re: Python 3 - Is PIL/wxPython/PyWin32 supported?

2010-07-07 Thread Daniel Fetchinson
 I don't know that PIL or wxPython supports Python 3 or not. May with
 some trick these packages are working.

 Does anybody know about it?
 Can I replace my Py2.6 without lost PIL/wxPython?

PIL currently does not support python 3 but release 1.1.7 will in the
future. Don't ask me when, I don't know.

I have no idea about the rest.

Cheers,
Daniel



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


Re: Twisted 10.1.0 released

2010-07-05 Thread Daniel Fetchinson
 On behalf of Twisted Matrix Laboratories, I am honored to announce the
 release of Twisted 10.1.0.

 Highlights include:

  * Deferreds now support cancellation

  * A new endpoint interface which can abstractly describe stream
 transport endpoints such as TCP and SSL

  * inotify support for Linux, which allows monitoring of file system events.

  * AMP supports transferring timestamps

 Note also that this is the *last* supported release of Twisted for
 Python 2.4 on Windows.

 For more information, see the NEWS file.

 It's stable, backwards compatible, well tested and in every way an
 improvement. Download it now from:

  http://tmrc.mit.edu/mirror/twisted/Twisted/10.1/Twisted-10.1.0.tar.bz2
 http://tmrc.mit.edu/mirror/twisted/Twisted/10.1/Twisted-10.1.0.winxp32-py2.5.msi
 http://tmrc.mit.edu/mirror/twisted/Twisted/10.1/Twisted-10.1.0.winxp32-py2.6.msi

 Many thanks to Glyph Lefkowitz, who helped do the release preparation,
 and the PyCon 2010 sprinters, who did so much of the work for this
 release.


The twisted website at http://twistedmatrix.com/ seems to be having
issues (trac can not connect to its database?).

Cheers,
Daniel

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


Re: Build unordered list in HTML from a python list

2010-06-30 Thread Daniel Fetchinson
 I have this python list that represets a sitemap:

 tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False},
  {'indent': 1, 'title':'Item 2', 'hassubfolder':False},
  {'indent': 1, 'title':'Folder 1', 'hassubfolder':True},
  {'indent': 2, 'title':'Sub Item 1.1', 'hassubfolder':False},
  {'indent': 2, 'title':'Sub Item 1.2', 'hassubfolder':False},
  {'indent': 1, 'title':'Item 3', 'hassubfolder':False},
  {'indent': 1, 'title':'Folder 2', 'hassubfolder':True},
  {'indent': 2, 'title':'Sub Item 2.1', 'hassubfolder':False},
  {'indent': 2, 'title':'Folder 2.1', 'hassubfolder':True},
  {'indent': 3, 'title':'Sub Item 2.1.1', 'hassubfolder':False},
  {'indent': 3, 'title':'Sub Item 2.1.2', 'hassubfolder':False},
 ]

  From that list I want to create the following HTML code:

 ul id=tree
liItem 1/li
liItem 2/li
liFolder 1
  ul
liSub Item 1.1/li
liSub Item 1.2/li
  /ul
/li
liItem 3/li
liFolder 2
  ul
liSub Item 2.1/li
liFolder 2.1
  ul
liSub Item 2.1.1/li
liSub Item 2.1.2/li
  /ul
/li
  /ul
/li
 /ul

 If an item of the list has 'True' for the 'hassubfolder' key than a new
 ulli must be created instead of /li after its title. (See
 Folder 2 node in the HTML code above.

 My problem is: How do I keep track of the closing tags while iterating
 over the python list?

Elementtree has already been mentioned as a solution, but if you need
something more lightweight, give markup.py a try:
http://markup.sourceforge.net/ it's a single module and very easy to
use for the sort of things you are after.

Cheers,
Daniel

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


Re: Using Python for web applications

2010-06-30 Thread Daniel Fetchinson
 Sorry for asking such a simple (or possibly complicated) question, as
 I am new to Python programming. Anyways, I have read online that many
 popular websites use Python for some of their web-based applications
 (for example, Reddit), and that lead me to wonder how is this done?

There are various options, the simplest is using a full blown web
framework which simplifies about 90% of the work and you only need to
code the logic related to your app. Two of the most popular frameworks
are django [1] and turbogears [2].

You can also go more low level by designing your own framework from
scratch which is something the bigger shops are doing like youtube.

In any case there is a wiki page that you might find useful [3].

HTH,
Daniel

[1] http://www.djangoproject.com/
[2] http://www.turbogears.org/
[3] http://wiki.python.org/moin/WebProgramming


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


Re: web application in django

2010-06-25 Thread Daniel Fetchinson
 I'm doing web application in django in which I have to make search option
 that will find on other web page some product(for example) and that product
 will have to been seen on my page.. now I don't know where to start with
 programming.. I know I must parse that other page but I don't have idea how
 to do that.. can someone help me with understanding what I have to do
 exactly?!

First fetch the page using urllib2 [1] then parse it with elementtree
[2] or beautiful soup [3] or something else [4]. Once you filtered out
the data you want you can insert it where ever you need to insert it.

Be sure to read this also [5].

HTH,
Daniel

[1] http://docs.python.org/library/urllib2.html
[2] http://docs.python.org/library/xml.etree.elementtree.html
[3] http://www.crummy.com/software/BeautifulSoup/
[4] http://wiki.python.org/moin/PythonXml
[5] http://catb.org/esr/faqs/smart-questions.html


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


Re: [Python-Dev] adding new function

2010-06-22 Thread Daniel Fetchinson
 how can i simply add new functions to module after its initialization
 (Py_InitModule())?  I'm missing something like
 PyModule_AddCFunction().

This type of question really belongs to python-list aka
comp.lang.python which I CC-d now. Please keep the discussion on that
list.

Cheers,
Daniel


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


Re: Vote to Add Python Package pubsub to the Python Standard Library

2010-06-01 Thread Daniel Fetchinson
 I vote for adding the Python package pubsub to the Python standard
 library.  It has recently been added to wxpython (replacing the old
 wx.lib.pubsub package), but it has application to non-gui programs as
 well.

 For more information see: http://pubsub.sourceforge.net/.

If you are really interested in this the minimum would be following these steps:

1. discuss various publish-subscribe API variants on python-list (aka c.l.p)
2. when you got tons of feedback summarize the discussion on python-dev
3. tons of feedback will follow and try to converge on a consensus
concerning the API
4. write a PEP
5. produce an implementation (or get someone to do it)
6. add the implementation to the PEP
7. lobby for acceptance of the PEP

A good example for the first couple of stages of this process is PEP
3143 concerning adding a daemon package to the stdlib:
http://www.python.org/dev/peps/pep-3143/

I haven't found the beginning of the thread discussing this but you
can start for example here:

http://mail.python.org/pipermail/python-list/2009-March/1197808.html

Good luck,
Daniel


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


Re: What's the largest python/django powered website in the world?

2010-05-30 Thread Daniel Fetchinson
 just curious, what's the largest python powered website in the world?

I'm afraid you'll need to define what you mean by python powered. If
the server side of a web application is written in 3 or more languages
and one of them is python, does that count? If yes, then probably
google and youtube are the largest python powered websites.

Daniel


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


Re: Does pickled objects work fine between different OS?

2010-05-26 Thread Daniel Fetchinson
 If I dump a Python dictionary into a file named data.pkl using
 Pickle module on a Linux operating system, will the data contained in
 data.pkl load fine in a Windows OS?

Yes.

 I mean will I be able to load the dictionary data contained in data.pkl
 just fine on Windows XP?

Yes.

Cheers,
Daniel


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


  1   2   3   4   5   >