Re: Fibonacci series recursion error

2011-04-29 Thread Chris Angelico
On Sat, Apr 30, 2011 at 4:32 PM, Peter Otten <__pete...@web.de> wrote:
>> ...  because each recursion level 'return' calls fib() twice, and each
>> of those calls fib() twice, and you get the point...
>
> I don't understand what you are trying to say -- but it's wrong ;)

Fortunately, most Python interpreters will not implement
double-tail-recursion as forking.

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


Re: Fibonacci series recursion error

2011-04-29 Thread Peter Otten
harrismh777 wrote:

> Ian Kelly wrote:
>> since the fact is that if
>> the function were properly coded, the call stack for fib(20) would
>> never be more than 20 entries deep at any one time.
>>
> 
> Not so much... and much more !
> 
> 
> ...  because each recursion level 'return' calls fib() twice, and each
> of those calls fib() twice, and you get the point...

I don't understand what you are trying to say -- but it's wrong ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-04-29 Thread Peter Otten
harrismh777 wrote:

> def fib(i=1):
>  a=1;n=1;l=[]
>  for j in range(0,i):
>  l.append(a)
>  p=a;a=n;n=p+a

Hm, did you run out of newlines?

>  return l
> 
> list=fib(7)
> 
> 
> 
> ... and the above, is how I would actually code it
> 
> 
> 
> 

Nah, that can't be it ;)

For the record, the one true way to implement the Fibonacci series in Python 
is

>>> def fib():
... a = b = 1
... while True:
... yield a
... a, b = b, a+b # look ma, no temporary variable
...
>>> from itertools import islice
>>> list(islice(fib(), 20))
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 
4181, 6765]


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


Re: Fibonacci series recursion error

2011-04-29 Thread Paul Rudin
harrismh777  writes:

> lalit wrote:
>> The above function return the
>> return (fib(n-1)+fib(n-2))
>>
>> RuntimeError: maximum recursion depth exceeded in comparison
>> [36355 refs]
>
> There is much debate about this generally, but general wisdom is that
> recursion is to be avoided when possible. Another way to say this is,
> "Only use recursion when there is no other obvious way to handle the
> problem".
> Recursion is very tempting to young artists because its a ~cool trick,
> and because sometimes it requires very little coding (although huge
> amounts of memory!),  


Writing recurive code is acceptable and is a nice clear way of
expressing things when you have naturally recursive data structures, and
can lead to perfectly good compiled code. The problem in CPython is the
lack of tail optimization, so it's not a good idea for python . Some
language standards guarantee tail optimization...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-04-29 Thread Hans Georg Schaathun
On Fri, 29 Apr 2011 23:45:30 -0500, harrismh777
   wrote:
:  There is much debate about this generally, but general wisdom is that 
:  recursion is to be avoided when possible.

That is context dependent at best.  You have given reasons to avoid
recursion in /executable code/, but that's a compiler issue.  You
have only given reason /for/ recursion in source code.  It generally
gives little and very reaadble code.  In almost every non-trivial
software project, the programmers will be more overworked than the
computer, and therefore they are the once to consider when optimising.

:  Recursion is very tempting to young artists because its a ~cool trick, 
:  and because sometimes it requires very little coding (although huge 
:  amounts of memory!),  or as in your case, recursion depth errors.

Waste of memory happens only with some types of recursion, and even
then it is usually negligible.  The recursion depth issue is the
result of a flawed base case, and nothing to do with a weakness of
recursion.

:  Anyway, the better way to build a Fibonacci sequence generator is the 
:  following... I have expanded things a bit so that someone not knowing 
:  what the sequence is can see what is happening... you will notice simple 
:  'for' iterations, and no recursion:

And surprisingly difficult to read for such a well-known operation as
Fibonacci numbers.  If you want to promote iteration, you had better
at least try to make it legible.

Your code is obviously more efficient in being O(n) whereas OP had
(I think) O(2^n), but that's not a property of iteration.  You can
make a recursive implementation which is O(n).  Any undergraduate 
textbook teaching recursion in any depth is likely to give it as an 
example; see e.g. Simon Thompson's Haskell book.

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


Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777

Ian Kelly wrote:

since the fact is that if
the function were properly coded, the call stack for fib(20) would
never be more than 20 entries deep at any one time.



Not so much... and much more !


...  because each recursion level 'return' calls fib() twice, and each 
of those calls fib() twice, and you get the point...



(not to mention, its not properly coded)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777

def fib(i=1):
a=1;n=1;l=[]
for j in range(0,i):
l.append(a)
p=a;a=n;n=p+a
return l

list=fib(7)



... and the above, is how I would actually code it




kind regards,
m harris
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 9:57 PM, Jason Friedman  wrote:
> The first call to fib() recursively calls fib() twice.  Each of those
> will call fib() twice.  Each of those will call fib() twice.  Pretty
> soon, you've got a lot of calls.

Which is hell for the running time, but doesn't answer the question of
why the maximum recursion depth is exceeded, since the fact is that if
the function were properly coded, the call stack for fib(20) would
never be more than 20 entries deep at any one time.

The actual problem, as Gary pointed out, is that the base case is incomplete.
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing programs that depend on, or are, python extensions.

2011-04-29 Thread James A. Donald
I have noticed that installing python programs tends to be hell,
particularly under windows, and installing python programs that rely
on, or in large part are, python extensions written in C++ tends to be
hell on wheels with large spiky knobs and scythes on the wheels.

Is this because such install are inherently hard to do and hard to
write, or is it because Install tends to be done last, and therefore
not done at all?

Can anyone suggest any examples of such a program with a clean windows
install that shows how it was done?

By windows install, I mean you run setup.exe, and get a program group,
file types registered, and an entry in the add/remove programs list, I
do not mean fourteen pages of direly incomplete notes which do not
actually work for versions later than 1.01, and do not work for
version 1.01 unless one has already installed the complete developer
environment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (beginner) logging config not working

2011-04-29 Thread Peter Otten
Unknown Moss wrote:

> Hi
> 
> This is a beginner question. Thanks for the hand.
> 
> I've been asked to maintain some poorly constructed python code.
> Logging is weak. Getting it to work with python logging
> programmatically was easy.
> 
> However, I'd like to refactor all the logging code into configuration
> since I see the need for other handlers in the future (syslog and
> possibly email).
> 
> For now I just want to get console and log file working, but I'm
> having problems with the log file. I'm trying some test code. Here's
> my test script (logging_example.py):
> 
> import logging
> import logging.config
> 
> def main():
> logging.config.fileConfig("logging.conf")
> logging.debug("debug check")

The above is a shortcut for

root = logging.getLogger("")
root.debug("debug check")

i. e. you are logging to the root logger. According to your config file 
messages sent to the root logger are only handled by the console handler:

> [logger_root]
> level=NOTSET
> handlers=console

You can either change that by adding the file handler to the list of 
handlers for the root logger

handlers=console,file
 
in the config file or by directing your logging messages to "mylogger" with

mylogger = logging.getLogger("mylogger")
mylogger.debug("debug check")

Note that loggers are organized in a tree; messages sent to mylogger will be 
propagated upwords to the root logger by default.

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


Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777

===begin==
def fib(i=1):
l=[]
p=0
a=1
n=p+a
for j in range(1,i+1):
l.append(a)
p=a
a=n
n=p+a
return l

list=fib(7)
===end==


... the above, if you want to return the list, not print...

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


Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777

lalit wrote:

The above function return the
return (fib(n-1)+fib(n-2))

RuntimeError: maximum recursion depth exceeded in comparison
[36355 refs]


There is much debate about this generally, but general wisdom is that 
recursion is to be avoided when possible. Another way to say this is, 
"Only use recursion when there is no other obvious way to handle the 
problem".
Recursion is very tempting to young artists because its a ~cool trick, 
and because sometimes it requires very little coding (although huge 
amounts of memory!),  or as in your case, recursion depth errors.
Anyway, the better way to build a Fibonacci sequence generator is the 
following... I have expanded things a bit so that someone not knowing 
what the sequence is can see what is happening... you will notice simple 
'for' iterations, and no recursion:

===begin==
def fib(i=1):
l=[]
p=0
a=1
n=p+a
for j in range(1,i+1):
l.append(a)
p=a
a=n
n=p+a
for j in l:
print(j, end=' ')

fib(7)
===end==


kind regards,

m harris

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


Re: Fibonacci series recursion error

2011-04-29 Thread Jason Friedman
> import os
> def fib(n):
>        if n == 1:
>          return(n)
>        else:
>          return (fib(n-1)+fib(n-2))
>
> list=fib(20)
> print(list)
>
> The above function return the
> return (fib(n-1)+fib(n-2))
>
>
> RuntimeError: maximum recursion depth exceeded in comparison
> [36355 refs]
>
> can any one help

The first call to fib() recursively calls fib() twice.  Each of those
will call fib() twice.  Each of those will call fib() twice.  Pretty
soon, you've got a lot of calls.

Have a look at:  http://en.literateprograms.org/Fibonacci_numbers_(Python).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-04-29 Thread Roy Smith
In article 
,
 CM  wrote:

> While we're on the topic, when should a lone developer bother to start
> using a VCS?

No need to use VCS at the very beginning of a project.  You can easily 
wait until you've written 10 or 20 lines of code :-)

> Should I bother to try a VCS?

Absolutely.  Even if you don't need it for a small one-person project, 
it's a good habit to get into.

If you haven't used any, my recommendation would be hg.  Partly because 
it's powerful, and partly because it's relatively easy to use.  The 
other popular choice these days would be git.  Hg and git are pretty 
similar, and between the two of them probably cover 90% of current 
usage.  Unless you've got a specific reason to try something else (i.e. 
a project you're interested in uses something else), those seem like the 
only two reasonable choices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-04-29 Thread Gary Herron

On 04/29/2011 08:22 PM, lalit wrote:

import os
def fib(n):
if n == 1:
   return(n)
else:
   return (fib(n-1)+fib(n-2))

list=fib(20)
print(list)

The above function return the
return (fib(n-1)+fib(n-2))


RuntimeError: maximum recursion depth exceeded in comparison
[36355 refs]

can any one help


You correctly test for n==1, but what about when n==2?When the 
recursion works its way down to fib(2), you call both fib(1) and fib(0), 
but the latter starts an infinite sequence of calls to fib(-1), fib(-2) 
and so on without end.


Gary Herron

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


Re: Development tools and practices for Pythonistas

2011-04-29 Thread Shawn Milochik
Depends on the project, but I'd start with git the time I created the 
first file in my project. If you're in the habit of committing then you 
can easily rollback missteps. If you're in the habit of making branches 
you can experiment without breaking the currently-working code.



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


Fibonacci series recursion error

2011-04-29 Thread lalit
import os
def fib(n):
if n == 1:
  return(n)
else:
  return (fib(n-1)+fib(n-2))

list=fib(20)
print(list)

The above function return the
return (fib(n-1)+fib(n-2))


RuntimeError: maximum recursion depth exceeded in comparison
[36355 refs]

can any one help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-04-29 Thread CM

> A lone developer using such a VCS reaps the benefits of this by getting
> good merging support.

While we're on the topic, when should a lone developer bother to start
using
a VCS?  At what point in the complexity of a project (say a hobby
project, but
a somewhat seriousish one, around ~5-9k LOC) is the added complexity
of
bringing a VCS into it worth it?

I've been making changes to code and saving changes to the same
files,
but backing up on Dropbox, which keeps 30 days of previous saves.
I've rarely had to resort to undoing code by calling up a previous
save.
I test each new change as it is made to see if it breaks anything
(not
automatic testing, though), and I don't collaborate with anyone else
as
yet.

Should I bother to try a VCS?


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


Re: Composition instead of inheritance

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 5:54 PM, Carl Banks  wrote:
>> Really, *any* class that uses super().__init__ should take its
>> arguments and pass them along in this manner.
>
> If you are programming defensively for any possible scenario, you might try 
> this (and you'd still fail).
>
> In the real world, certain classes might have more or less probability to be 
> used in a multiple inheritance situations, and programmer needs to weigh the 
> probability of that versus the loss of readability.  For me, except when I'm 
> designing a class specifically to participate in MI (such as a mixin), 
> readability wins.

Agreed.  Actually, my preferred solution is to not use super at all.
It's so rarely needed (i.e. diamond inheritance situations) that it's
usually not worth it to jump through the hoops it creates, so I prefer
to call the base class methods explicitly.

For pure base-class + mixin design, you should not have any diamond
inheritance situations, so super should not really be necessary.

> If you merely mean DRY, then I'd say this doesn't necessarily add to it.  The 
> derived class has a responsibility one way or another to get the mixin 
> whatever initializers it needs.

I mean the difference in terms of maintenance between this:

class Derived1(Mixin1, Base):
def __init__(self, mixin_arg1, mixin_arg2, *args, **kwargs):
self.mixin_arg1 = mixin_arg1
self.mixin_arg2 = mixin_arg2
super(Derived, self).__init__(*args, **kwargs)

and simply doing this:

class Derived2(Mixin2, Base):
def __init__(self, *args, **kwargs):
super(Derived, self).__init__(*args, **kwargs)

In both cases we are passing the arguments in to the mixin.  In the
former case, if we later decide to add mixin_arg3, then we have to
also add it to the Derived1.__init__ signature and then add a line to
set the attribute.  In the latter case, adding mixin_arg3 has no
effect on the Derived2 initializer at all, because it passes through
transparently in the kwargs.

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


(beginner) logging config not working

2011-04-29 Thread Unknown Moss
Hi

This is a beginner question. Thanks for the hand.

I've been asked to maintain some poorly constructed python code.
Logging is weak. Getting it to work with python logging
programmatically was easy.

However, I'd like to refactor all the logging code into configuration
since I see the need for other handlers in the future (syslog and
possibly email).

For now I just want to get console and log file working, but I'm
having problems with the log file. I'm trying some test code. Here's
my test script (logging_example.py):

import logging
import logging.config

def main():
logging.config.fileConfig("logging.conf")
logging.debug("debug check")
logging.info("info check")
logging.warn("warn check")
logging.error("err check")
logging.critical("crit check")

if __name__ == "__main__":
  main()

Here's my config (logging.conf):

[loggers]
keys=root,file

[handlers]
keys=console,file

[formatters]
keys=simple,detailed

[logger_root]
level=NOTSET
handlers=console

[logger_file]
level=DEBUG
handlers=file
qualname=mylogger

[formatter_simple]
class=logging.Formatter
format=%(asctime)s - %(name)s [%(levelname)s] - %(message)s

[formatter_detailed]
class=logging.Formatter
format=%(asctime)s - %(name)s [%(levelname)s] - %(message)s

[handler_console]
class=logging.StreamHandler
formatter=simple
args=(sys.stdout,)

[handler_file]
class=FileHandler
level=DEBUG
formatter=detailed
args=('logging_example.log', 'w')


Output:

$ python logging_example.py
2011-04-29 17:07:01,923 - root [DEBUG] - debug check
2011-04-29 17:07:01,986 - root [INFO] - info check
2011-04-29 17:07:01,986 - root [WARNING] - warn check
2011-04-29 17:07:01,986 - root [ERROR] - err check
2011-04-29 17:07:02,000 - root [CRITICAL] - crit check

The logging_example.log is created, but no entries are written to it.
Based on this configuration I'd expect all the logging entries to be
written to the file as well.

Any ideas where I'm going awry?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Friday, April 29, 2011 2:44:56 PM UTC-7, Ian wrote:
> On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks 
>  wrote:
> > Here is my advice on mixins:
> >
> > Mixins should almost always be listed first in the bases.  (The only 
> > exception is to work around a technicality.  Otherwise mixins go first.)
> >
> > If a mixin defines __init__, it should always accept self, *args and 
> > **kwargs (and no other arguments), and pass those on to super().__init__.  
> > Same deal with any other function that different sister classes might 
> > define in varied ways (such as __call__).
> 
> Really, *any* class that uses super().__init__ should take its
> arguments and pass them along in this manner.

If you are programming defensively for any possible scenario, you might try 
this (and you'd still fail).

In the real world, certain classes might have more or less probability to be 
used in a multiple inheritance situations, and programmer needs to weigh the 
probability of that versus the loss of readability.  For me, except when I'm 
designing a class specifically to participate in MI (such as a mixin), 
readability wins.

[snip]
> > A mixin should not accept arguments in __init__.  Instead, it should burden 
> > the derived class to accept arguments on its behalf, and set attributes 
> > before calling super().__init__, which the mixin can access.
> 
> Ugh.  This breaks encapsulation, since if I ever need to add an
> optional argument, I have to add handling for that argument to every
> derived class that uses that mixin.  The mixin should be able to
> accept new optional arguments without the derived classes needing to
> know about them.

Well, encapsulation means nothing to me; if it did I'd be using Java.

If you merely mean DRY, then I'd say this doesn't necessarily add to it.  The 
derived class has a responsibility one way or another to get the mixin whatever 
initializers it needs.  Whether it does that with __init__ args or through 
attributes it still has to do it.  Since attributes are more versatile than 
arguments, and since it's messy to use arguments in MI situations, using 
attributes is the superior method. 


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


Re: Development tools and practices for Pythonistas

2011-04-29 Thread Ben Finney
Hans Georg Schaathun  writes:

> Exactly, and with svn that can be a true nightmare when directories 
> are involved.  The rumour is that git handles this much better.

Any of the top-tier distributed VCS (Bazaar, Git, Mercurial) handle
branching and merging very well. They have to, because branching and
merging is much more frequent and casual in a distributed VCS.

A lone developer using such a VCS reaps the benefits of this by getting
good merging support.

-- 
 \   “If consumers even know there's a DRM, what it is, and how it |
  `\ works, we've already failed.” —Peter Lee, Disney corporation, |
_o__) 2005 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cx_Freeze 4.2.3

2011-04-29 Thread PuffTheMagic
I get this error too using Apple's system python.

On Mar 31, 7:49 pm, James Mills  wrote:
> On Sun, Mar 20, 2011 at 9:52 AM, Anthony Tuininga
>
>  wrote:
> > Where do I get it?
>
> >http://cx-freeze.sourceforge.net
>
> Just as a matter of interest, I tried to install cx_Freeze with
> pip/distribute (Python 2.7.1)
> but it fails with:
>
> error: option --single-version-externally-managed not recognized
>
> cheers
> James
>
> --
> -- James Mills
> --
> -- "Problems are solved by method"

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


Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman

Ian Kelly wrote:

On Thu, Apr 28, 2011 at 11:15 AM, Ethan Furman  wrote:

For anybody interested in composition instead of multiple inheritance, I
have posted this recipe on ActiveState (for python 2.6/7, not 3.x):

http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/

Comments welcome!


On line 14, is it intentional that attributes whose values happen to
be false are not considered as conflicts?


Nope, not intentional at all!  I'll fix that...



On line 31, this code:

thing = getattr(thing, '__func__', None) or thing

could be simplified to this:

thing = getattr(thing, '__func__', thing)


I'll fix that, too.


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


Re: Composition instead of inheritance

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks  wrote:
> Here is my advice on mixins:
>
> Mixins should almost always be listed first in the bases.  (The only 
> exception is to work around a technicality.  Otherwise mixins go first.)
>
> If a mixin defines __init__, it should always accept self, *args and **kwargs 
> (and no other arguments), and pass those on to super().__init__.  Same deal 
> with any other function that different sister classes might define in varied 
> ways (such as __call__).

Really, *any* class that uses super().__init__ should take its
arguments and pass them along in this manner.  This applies to your
base classes as well as your mixins.  It's okay to take keyword
arguments as well, but you have to be careful to pass them on exactly
as you received them.  Reason being that you can't pragmatically
predict which __init__ method will be invoked next by the super call,
which means that you can't predict which arguments will be needed for
that call, so you just have to pass all of them along.

> A mixin should not accept arguments in __init__.  Instead, it should burden 
> the derived class to accept arguments on its behalf, and set attributes 
> before calling super().__init__, which the mixin can access.

Ugh.  This breaks encapsulation, since if I ever need to add an
optional argument, I have to add handling for that argument to every
derived class that uses that mixin.  The mixin should be able to
accept new optional arguments without the derived classes needing to
know about them.

> If you insist on a mixin that accepts arguments in __init__, then it should 
> should pop them off kwargs.  Avoid using positional arguments, and never use 
> named arguments.  Always go through args and kwargs.

Theoretically this would break if you had two mixins accepting the
same argument, but I can't think of an actual case where that might
happen.

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


Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman

Carl Banks wrote:

Here is my advice on mixins:


[snip]

Cool.  Thanks!

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


Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Thursday, April 28, 2011 6:43:35 PM UTC-7, Ethan Furman wrote:
> Carl Banks wrote:
> > The sorts of class that this decorator will work for are probably not
>  > the ones that are going to have problems cooperating in the first place.
>  > So you might as well just use inheritance; that way people trying to read
>  > the code will have a common, well-known Python construct rather than a
>  > custom decorator to understand.
> 
>  From thread 'python and super' on Python-Dev:
> Ricardo Kirkner wrote:
>  > I'll give you the example I came upon:
>  >
>  > I have a TestCase class, which inherits from both Django's TestCase
>  > and from some custom TestCases that act as mixin classes. So I have
>  > something like
>  >
>  > class MyTestCase(TestCase, Mixin1, Mixin2):
>  >...
>  >
>  > now django's TestCase class inherits from unittest2.TestCase, which we
>  > found was not calling super.
> 
> This is the type of situation the decorator was written for (although 
> it's too simplistic to handle that exact case, as Ricardo goes on to say 
> he has a setUp in each mixin that needs to be called -- it works fine 
> though if you are not adding duplicate names).

The problem is that he was doing mixins wrong.  Way wrong.

Here is my advice on mixins:

Mixins should almost always be listed first in the bases.  (The only exception 
is to work around a technicality.  Otherwise mixins go first.)

If a mixin defines __init__, it should always accept self, *args and **kwargs 
(and no other arguments), and pass those on to super().__init__.  Same deal 
with any other function that different sister classes might define in varied 
ways (such as __call__).

A mixin should not accept arguments in __init__.  Instead, it should burden the 
derived class to accept arguments on its behalf, and set attributes before 
calling super().__init__, which the mixin can access.

If you insist on a mixin that accepts arguments in __init__, then it should 
should pop them off kwargs.  Avoid using positional arguments, and never use 
named arguments.  Always go through args and kwargs.

If mixins follow these rules, they'll be reasonably safe to use on a variety of 
classes.  (Maybe even safe enough to use in Django classes.)


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


Re: Deditor

2011-04-29 Thread Kruptein
On 29 apr, 20:25, jmfauth  wrote:
> On 28 avr, 22:16, Kruptein  wrote:
>
>
>
>
>
> > On 28 apr, 07:46, jmfauth  wrote:
>
> > > On 27 avr, 19:22, Alec Taylor  wrote:
>
> > > > Thanks, any plans for a Windows version?
>
> > > - Download the deb
> > > - Unpack it with a utility like 7zip
> > > - Throw away the unnecessary stuff, (keep the "deditorpart")
> > > - Depending on your libs, adatpt the "import"
> > > - Launchdeditor.py
> > > - Then ...
>
> > > [5 minutes]
>
> > > In fact, this kind of app can be simply packed in a zip file.
>
> > > jmf
>
> > It isn't that easy as you might have hoped ;)  I'm using wxpython for
> > rendering the GUI  somehow some things that work in the linux version
> > break in the windows version  so I need to do some small
> > modifications  and as I'm a hardcore linux fan I ony use windows for
> > gaming it usually takes a little longer for a windows release,  I'm
> > releasing a tarball now btw :D
>
> Sure, it is doable. I have done it (I only tweak the
> import in such a way, that it does not import modules
> not installed in my machine, like not importing paramiko).
>
> Your application is just a normal application which uses
> a Python environment, independently from the platform.
>
> wxPython does not play something special. Exemple, the
> wxPython demo can be installed in any dir, even on external
> drive.
>
> PS I have no special interest indeditor, except I like
> to see what is done with wxPython.
>
> jmf

The problem had to do with the configuration panel which displayed
wrong in windows but right in linux.  I fixed it and it should now
actually work on both :p
(and the paramiko import error was because I had forgooten to do a try/
except block somewhere in my plugin management..)

the windows source zip file is online,   Alec can make an installer if
he wants :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman

James Mills wrote:

On Fri, Apr 29, 2011 at 11:43 AM, Ethan Furman  wrote:

Hmmm. Okay -- any ideas for a better term?  Something that describes taking
different source classes and fusing them into a new whole, possibly using
single-inheritance... Frankenstein, maybe?  ;)


I'd have to say that this is typical of MixIns


Yes, but it's designed to be used when Mixins fail because of MI issues 
(see my reply to Carl for an example).


Maybe Integrate?

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


Re: windows 7 x64 shutdown

2011-04-29 Thread Brian Curtin
On Mon, Apr 25, 2011 at 16:15, rjmccorkle  wrote:

> does anyone know a solution to shutting down windows 7 x64 via python
> script?  the win32 obviously doesn't work... something similar?
>
> "the win32 obviously doesn't work" -- It does.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python wide-python-build unicode for Windows

2011-04-29 Thread Terry Reedy

On 4/29/2011 7:52 AM, sathe...@e-ndicus.com wrote:


How could i increase the unicode range beyond 1 ?


Use Python3, which, after renaming unichar to chr, changed it to always 
accept the full range of codepoints, even when that means returning a 
two-char string on narrow builds, like windows.

>>> chr(0x10)
'\U0010'
>>> len(chr(0x10))
2

If OpenERP does not have a 3.x version, encourage them to make one to 
take advantage of the unicode improvements. Tell them the use case, that 
you want to use the full range, even on windows.


Or file a bug report requesting a workaround in the 2.x version.

--
Terry Jan Reedy

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


Re: Python wide-python-build unicode for Windows

2011-04-29 Thread Martin v. Loewis
> But how could i do this in Windows.

It's not supported. Hopefully, it will be supported in Python 3.3,
due to PEP 393.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-04-29 Thread Hans Georg Schaathun
On Wed, 27 Apr 2011 14:24:30 +0200, Jean-Michel Pichavant
   wrote:
:  I was talking about merge *issue* i.e merge resulting in conflicts that 
:  are not easy to solve. With a single user most of the merge will be 
:  solved automatically by any decent VCS.

Exactly, and with svn that can be a true nightmare when directories 
are involved.  The rumour is that git handles this much better.


I call it a rumour not because I doubt it (I don't), but because 
I have not seen for myself.

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


Re: [OT] VCS tools

2011-04-29 Thread Martin Schöön
On 2011-04-28, Ben Finney  wrote:
> Martin Schöön  writes:
>
>> This has been a pretty informative thread so far. Please keep it coming.
>> I am a hardware development guy and do very little software development.
>> I have been vaguely aware of tools for version control but inspired by
>> this thread I have started looking at Mercurial.
>
> After my passionate Bazaar evangelism? :-)
>
Before I think as I remember I was quick out of the blocks.

> I seriously recommend anyone looking for a modern VCS to give Bazaar a
> decent trial. It's the one I've found newcomers learn most easily, and
> it's astoundingly flexible as one's needs with it grow.
>
I'll take look but so far I have found Mercurial pretty easy to get to 
grips with. But then I have only done fairly trivial stuff.

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


Re: Deditor

2011-04-29 Thread jmfauth
On 28 avr, 22:16, Kruptein  wrote:
> On 28 apr, 07:46, jmfauth  wrote:
>
>
>
> > On 27 avr, 19:22, Alec Taylor  wrote:
>
> > > Thanks, any plans for a Windows version?
>
> > - Download the deb
> > - Unpack it with a utility like 7zip
> > - Throw away the unnecessary stuff, (keep the "deditor part")
> > - Depending on your libs, adatpt the "import"
> > - Launch deditor.py
> > - Then ...
>
> > [5 minutes]
>
> > In fact, this kind of app can be simply packed in a zip file.
>
> > jmf
>
> It isn't that easy as you might have hoped ;)  I'm using wxpython for
> rendering the GUI  somehow some things that work in the linux version
> break in the windows version  so I need to do some small
> modifications  and as I'm a hardcore linux fan I ony use windows for
> gaming it usually takes a little longer for a windows release,  I'm
> releasing a tarball now btw :D


Sure, it is doable. I have done it (I only tweak the
import in such a way, that it does not import modules
not installed in my machine, like not importing paramiko).

Your application is just a normal application which uses
a Python environment, independently from the platform.

wxPython does not play something special. Exemple, the
wxPython demo can be installed in any dir, even on external
drive.

PS I have no special interest in deditor, except I like
to see what is done with wxPython.

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


Re: [OT] From svn to something else?

2011-04-29 Thread Tim Chase

On 04/29/2011 12:01 PM, Hans Georg Schaathun wrote:

 wrote:
:  I'd say that one of the things SVN has going for it is that it's
:  the lingua-franca of VCSes, so just about everything (especially
:  the 3 big names mentioned in this thread: hg, bzr, git) can talk
:  to svn pretty uneventfully.  As a matter of fact, last I checked,
:  Django is hosted in SVN, but most of the developers use DVCS
:  tools to check in/out from the main repository to their own local
:  hg/bzr/git repos, do their work locally (with the option to work
:  offline, branch/merge easily, etc), and then push changesets back
:  up when they have a patch they're happy with.

I am not sure I get the implications right.  Are you suggesting that
I could keep my svn server, switch to a DVCS client, and reap the
benefits?


Yep...some are plugins while others are stock/native, but you can 
read your fill at


Git:
http://www.kernel.org/pub/software/scm/git/docs/git-svn.html

Mercurial:
http://mercurial.selenic.com/wiki/WorkingWithSubversion

Bazaar:
http://doc.bazaar.canonical.com/plugins/en/svn-plugin.html


-tkc



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


Re: [OT] Comparing VCS tools (was ""Development tools and practices for Pythonistas")

2011-04-29 Thread Daniel Kluev
We were looking for some simple integrated SCM, issue tracker and wiki
in our university for software design and software testing courses,
and fossil seems to be perfect match, thanks for sharing.

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Thank You Re: use of index (beginner's question)

2011-04-29 Thread Rusty Scalf


An overdue Thank You to everyone who responded.  I got well more than I 
bargained for, including needed reinforcement (beyond the beginner's 
guides) of how Python actually works and some good programming habits. I 
am grateful.


I liked Steven D'Aprano comment:

  Define "does not work".
  What do you expect to happen, and what happens instead?

A good dose of humility. Getting a result that surprises me isn't the 
same as the language not working!


In the end I followed Thomas Lahn's suggestion and used the structure

 data = {
  'pig':   '62327',
  'horse': '49123',
  'moose': '79115'
  }
  print data.get('horse')

I am using the Python extension written for ArcGIS software.

The happy result is a set of 54 maps, each with three frames, which 
display gridded tuna harvest data for 3 tuna species from 1950 through 
2004 as well as total tonnages. And the beauty is, if I modify the basic 
map template I need only execute the program again, go have coffee, and 
come back to 54 new pdf files!  The boss can say 'change the title font' 
and it's no big deal.


Thanks again,
 Rusty Scalf


On 4/27/2011 5:42 PM, Rusty Scalf wrote:

Greetings,
I am just now learning python and am trying to use the index function 
with variables.


list1 = ['pig', 'horse', 'moose']
list2 =  ['62327', '49123', '79115']
a = list2[list1.index('horse')]
print a
>49123

   -works fine. But

list1 = ['pig', 'horse', 'moose']
list2 =  ['62327', '49123', '79115']
n = 2
s2 = "list" + `n`
a = s2[list1.index('horse')]
print a

  -does not work

I'd like to use the index function in a loop updating the file names 
by adding a number to that name with each cycle. But can't get to 
first base.


Thank you,

   Rusty Scalf



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


Re: Deditor

2011-04-29 Thread Alec Taylor
I'll create an installer or two (an NSIS or InnoSetup .exe and an MSI)
if you like, once you've released the windows version.

On Fri, Apr 29, 2011 at 6:16 AM, Kruptein  wrote:
> On 28 apr, 07:46, jmfauth  wrote:
>> On 27 avr, 19:22, Alec Taylor  wrote:
>>
>> > Thanks, any plans for a Windows version?
>>
>> - Download the deb
>> - Unpack it with a utility like 7zip
>> - Throw away the unnecessary stuff, (keep the "deditor part")
>> - Depending on your libs, adatpt the "import"
>> - Launch deditor.py
>> - Then ...
>>
>> [5 minutes]
>>
>> In fact, this kind of app can be simply packed in a zip file.
>>
>> jmf
>
> It isn't that easy as you might have hoped ;)  I'm using wxpython for
> rendering the GUI  somehow some things that work in the linux version
> break in the windows version  so I need to do some small
> modifications  and as I'm a hardcore linux fan I ony use windows for
> gaming it usually takes a little longer for a windows release,  I'm
> releasing a tarball now btw :D
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] From svn to something else?

2011-04-29 Thread Hans Georg Schaathun
On Fri, 29 Apr 2011 06:50:52 -0500, Tim Chase
   wrote:
:  I'd say that one of the things SVN has going for it is that it's 
:  the lingua-franca of VCSes, so just about everything (especially 
:  the 3 big names mentioned in this thread: hg, bzr, git) can talk 
:  to svn pretty uneventfully.  As a matter of fact, last I checked, 
:  Django is hosted in SVN, but most of the developers use DVCS 
:  tools to check in/out from the main repository to their own local 
:  hg/bzr/git repos, do their work locally (with the option to work 
:  offline, branch/merge easily, etc), and then push changesets back 
:  up when they have a patch they're happy with.

I am not sure I get the implications right.  Are you suggesting that
I could keep my svn server, switch to a DVCS client, and reap the
benefits?

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


Re: Read-write lock for Python

2011-04-29 Thread Geoff Bache
On Fri, Apr 29, 2011 at 12:38 AM, Ryan Kelly  wrote:
> On Thu, 2011-04-28 at 07:02 -0700, Geoff Bache wrote:
>> Hi all,
>>
>> I currently find myself needing a Python read-write lock. I note that
>> there is none in the standard library, but googling "python read-write
>> lock" quickly produced 6 different competing examples, including two
>> languishing patch proposals for the standard library.
>>
>> I can always pick a random one and hope for the best, but I was hoping
>> someone here might have a tip for one that has been used and debugged
>> and is likely to work.
>
> I wrote and have used the "SHLock" class in threading2 which should do
> what you need.  Don't know about "likely to work" but if it doesn't, I'd
> like to hear about it so I can fix it :-)

That's good enough for me :) Thanks, I'll give it a try.

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


Re: [OT] Comparing VCS tools (was ""Development tools and practices for Pythonistas")

2011-04-29 Thread Kevin Walzer

Fossil is another SCM to consider: http://www.fossil-scm.org/

It's written by the author of SQLite, D. Richard Hipp. It's not as 
well-known as some of the other DCVS's, but the Tcl/Tk language projects 
have moved their core development to it (http://core.tcl.tk). This is 
relevant to Python because Tkinter is part of the stlib.


There aren't any huge sites like Github providing Fossil hosting, but 
here is one site: http://chiselapp.com/


--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] From svn to something else?

2011-04-29 Thread D'Arcy J.M. Cain
On Fri, 29 Apr 2011 22:53:47 +1000
Ben Finney  wrote:
> Bazaar's support for Subversion repositories is great (it requires the
> ‘bzr-svn’ plug-in, of course). Use the ‘svn-import’ subcommand to import
> an entire Subversion repository to a Bazaar repository with all branches
> and history intact.

Anyone know how to go the other way?  I recently converted all my
projects over to svn from cvs and then took over another project that
uses bzr. I would prefer everything to be in the same system.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] From svn to something else?

2011-04-29 Thread Ben Finney
Hans Georg Schaathun  writes:

> How easy and reliable is it to import my svn version history into
> one of the three big DVCS-s mentioned here?

Bazaar's support for Subversion repositories is great (it requires the
‘bzr-svn’ plug-in, of course). Use the ‘svn-import’ subcommand to import
an entire Subversion repository to a Bazaar repository with all branches
and history intact.

-- 
 \“Your [government] representative owes you, not his industry |
  `\   only, but his judgment; and he betrays, instead of serving you, |
_o__)if he sacrifices it to your opinion.” —Edmund Burke, 1774 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Active Directory user creation with python-ldap

2011-04-29 Thread Michael Ströder
Nello wrote:
> I need to create an Active Directory user using python-ldap library. So, I
> authenticate with an admin account and I use "add_s" to create the user.

This is possible. Which version of AD are you working with.

> Anyway, by default users are disabled on creation,

That's the correct way of doing this.

> and I can not set
> userAccountControl to swith off the flag ACCOUNTDISABLE, i.e. setting
> userAccountControl with 512 (NORMAL_ACCOUNT) value. 

This should be possible. Make sure you really bind as the admin and you have
sufficient access rights.

Check your code. I'd suggest to set trace_level when calling ldap.initialize()
to observe what gets passed to python-ldap in which order.

http://www.python-ldap.org/doc/html/ldap.html#ldap.initialize

> Same thing if - as someone suggests - I create the user without a
> password and try to set userAccountCreation later.

Passwords are different anyway since you have to set the unicodePwd attribute.
I never tried to do this with a single write operation though.

You can try my web2ldap which does all this also with MS AD. It has a special
plugin class for attribute userAccountControl which lets you set values
bit-wise when modifying an user entry. And setting password automagically
switches to setting unicodePwd when working with MS AD.

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Adam Tauno Williams
On Fri, 2011-04-29 at 13:24 +0200, Paul Kölle wrote:
> Am 29.04.2011 12:01, schrieb Adam Tauno Williams:
> >> 3. The web based application will be used internally in the network to
> >> moniter servers in that network only.
> > You mean like OpenNMS or ZenOSS?
> >> 4. Web based application will be a real time application with a
> >> Database.
> > Like OpenNMS or ZenOSS?
> How can they be realtime if they generate static images?

All images are static regardless of how much they pretend not to be.
You can refresh as much as you like.  But a graph shows a progression
over time so there is always an interval.

> >> 5. Technology I am thingking for web based application is Django and
> >> Python as this web application can also be installed on Windows or
> >> Linux based OS.
> > If you want real-time monitoring you *must* build a service; a 'web app'
> > can *not* do that.
> Do you mean an agent?

No, just use WMI over the wire.  Agents are terrible, hard to develop,
unreliable, and everyone hates agents.  The systems already provide you
access to the information you are talking about.

> >> 6. Also please suggest which third party tool for chatrs and graphs I
> >> should use with Django (open source + paid)
> > ZenOSS and OpenNMS do graphs using RRD.
> I know this is the "standard" but IMO it's totally backward these days. 
> Correlating or selecting/deselecting certain values is painful
>(you have to write a graph def)

How is it painful?  Of course you have to create a graph definition - in
your case you are creating a graph definition BY WRITING CODE!  There
couldn't be a more painful way to just create a graph.

Have you used recent versions of ZenOSS?  Graph definitions can be
created right in the UI.

> . With  and modern JS libs like raphael 
> there are better ways to do this. Just look at google analytics.

I've seen it.  I don't see how it is "better".  It's a graph.

> It looks like PCP (http://oss.sgi.com/projects/pcp/features.html) will 
> gain a JSON interface shortly. That would be awesome because PCP is 
> developed by real engineers and has a proper architecture and is NOT a 
> CPU sucking monstrosity of PERL-line-noise + a few hacked-together PHP 
> frontends.

I have no idea where the "PERL-line-noise + a few hacked-together PHP
frontend" comment comes from.  RRD is written in C.  OpenNMS is Java and
ZenOSS is Python/ZOPE.

And as for "CPU sucking monstrosity" that is what everyone says... until
they try to build a monitoring application... and thus create their own
"CPU sucking monstrosity".  This is a case of
those-who-refuse-to-use-are-doomed-to-reinvent.

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


Python wide-python-build unicode for Windows

2011-04-29 Thread satheesh
Hi All,

How could i increase the unicode range beyond 1 ?

In python 2.5.4 by default the unicode range is 0x1, but in some cases
i have unicode char beyond the limit. For those conditions it th an error.

"""File "E:\OpenERP\OpenERP
AllInOne\Server\library.zip\reportlab\pdfbase\ttfonts.py", line 1197, in
splitString
ValueError: unichr() arg not in range(0x1) (narrow Python build)"""

In Linux we can convert the "Narrow Python Build" to "Wide Python Build"
using the command "--enable-unicode=ucs4 configures a wide Py_UNICODE"

But how could i do this in Windows.

Note:
I used OpenERP All in one installer to install python 2.5.


Thank you,
--
SatheeshKumar. P
+91 99446 38595
+91 87544 15303
sathe...@e-ndicus.com
pskuma...@gmail.com

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


Re: [OT] From svn to something else?

2011-04-29 Thread Tim Chase

On 04/29/2011 05:07 AM, Hans Georg Schaathun wrote:

How easy and reliable is it to import my svn version history
into one of the three big DVCS-s mentioned here?


I'd say that one of the things SVN has going for it is that it's 
the lingua-franca of VCSes, so just about everything (especially 
the 3 big names mentioned in this thread: hg, bzr, git) can talk 
to svn pretty uneventfully.  As a matter of fact, last I checked, 
Django is hosted in SVN, but most of the developers use DVCS 
tools to check in/out from the main repository to their own local 
hg/bzr/git repos, do their work locally (with the option to work 
offline, branch/merge easily, etc), and then push changesets back 
up when they have a patch they're happy with.


-tkc


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


Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Paul Kölle

Hi,

Am 29.04.2011 12:01, schrieb Adam Tauno Williams:

On Thu, 2011-04-28 at 23:47 -0700, Anurag (anu) Agarwal wrote:

Hi All,
I want to build an application for one of my client which has
following features
1. Client has some driver software which can be installed on Windows
and Linux based systems. This driver software is fetching some
operating system details using kernel level programming.
This is commonly called an "agent". You might not want do write your own 
because it is hard to do correctly and takes a lot of time. I'd suggest 
you search for something like sigar (library) or collectd and check out 
what they can offer in terms of output formats.



2. Now a new web based application is required to moniter these
servers remotly. This application will talk to these servers and get
the data (not sure how data will be fetched from driver software) then
show it on UI.


Perhaps via WMI?
Yes, best option. Modern windows versions have WinRM which is basically 
WMI over http (wmi being an implementation of CIM over DCOM, but I 
digress...)





3. The web based application will be used internally in the network to
moniter servers in that network only.


You mean like OpenNMS or ZenOSS?


4. Web based application will be a real time application with a
Database.


Like OpenNMS or ZenOSS?

How can they be realtime if they generate static images?




5. Technology I am thingking for web based application is Django and
Python as this web application can also be installed on Windows or
Linux based OS.


If you want real-time monitoring you *must* build a service; a 'web app'
can *not* do that.

Do you mean an agent?




6. Also please suggest which third party tool for chatrs and graphs I
should use with Django (open source + paid)


ZenOSS and OpenNMS do graphs using RRD.
I know this is the "standard" but IMO it's totally backward these days. 
Correlating or selecting/deselecting certain values is painful (you have 
to write a graph def). With  and modern JS libs like raphael 
there are better ways to do this. Just look at google analytics. On the 
other hand, RRD (the database) is great, I just never got the python 
bindings for rrd_fetch to reliably fetch the values I needed (you can't 
tell it to stop normalizing )


It looks like PCP (http://oss.sgi.com/projects/pcp/features.html) will 
gain a JSON interface shortly. That would be awesome because PCP is 
developed by real engineers and has a proper architecture and is NOT a 
CPU sucking monstrosity of PERL-line-noise + a few hacked-together PHP 
frontends.


just my 2cents
 Paul


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


Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Adam Tauno Williams
On Thu, 2011-04-28 at 23:47 -0700, Anurag (anu) Agarwal wrote:
> Hi All,
> I want to build an application for one of my client which has
> following features
> 1. Client has some driver software which can be installed on Windows
> and Linux based systems. This driver software is fetching some
> operating system details using kernel level programming.
> 2. Now a new web based application is required to moniter these
> servers remotly. This application will talk to these servers and get
> the data (not sure how data will be fetched from driver software) then
> show it on UI.

Perhaps via WMI?

> 3. The web based application will be used internally in the network to
> moniter servers in that network only.

You mean like OpenNMS or ZenOSS?

> 4. Web based application will be a real time application with a
> Database.

Like OpenNMS or ZenOSS?

> 5. Technology I am thingking for web based application is Django and
> Python as this web application can also be installed on Windows or
> Linux based OS.

If you want real-time monitoring you *must* build a service; a 'web app'
can *not* do that.

> 6. Also please suggest which third party tool for chatrs and graphs I
> should use with Django (open source + paid)

ZenOSS and OpenNMS do graphs using RRD.

> If you guys can help me in desiging a very high level Architecture of
> this application.

Take a look at ZenOSS; copy what they did.

> Thanks for reading so long. Please help me in this. If I am not clear
> on something then please write back.


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


Re: [OT] From svn to something else? (was: VCS tools)

2011-04-29 Thread Hans Georg Schaathun
Hmmm.  I am still using svn.

How easy and reliable is it to import my svn version history into
one of the three big DVCS-s mentioned here?  

I am fairly happy with svn, but then I use it more as a backup system
and a means to synchronise multiple systems.  Something better would 
not hurt, but loosing the version history would ...

I am particularly interested in git, not because of any qualities it 
may have but because that's what my colleague pushes, and he seems 
to be pushing our students into it, so it would be useful for me to be
familiar with it.

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


Re: Composition instead of inheritance

2011-04-29 Thread Jean-Michel Pichavant

Ben Finney wrote:

Ethan Furman  writes:

  

Carl Banks wrote:


That's not what we mean by composition. Composition is when one
object calls upon another object that it owns to implement some of
its behavior. Often used to model a part/whole relationship, hence
the name.
  

Hmmm. Okay -- any ideas for a better term? Something that describes
taking different source classes and fusing them into a new whole,
possibly using single-inheritance... Frankenstein, maybe? ;)



(Remember that Frankenstein was not the monster, but the scientist.)

“Hybrid”?

  

Actualy this story is about the villagers being the monsters :o)

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


Re: unpickling derived LogRecord in python 2.7 from python2.6

2011-04-29 Thread ivdn...@gmail.com
On Apr 28, 9:22 am, Peter Otten <__pete...@web.de> wrote:
> Vinay Sajip wrote:
> > On Apr 27, 5:41 pm, Peter Otten <__pete...@web.de> wrote:
>
> >> The Problem is that as of Python 2.7logging.LogRecord has become a
> >> newstyle class which is pickled/unpickled differently. I don't know if
> >> there is an official way to do the conversion, but here's what I've
> >> hacked up. The script can read pickles written with 2.6 in 2.7, but not
> >> the other way round.
> >> [code snipped]
>
> > I don't know about "official", but another way of doing this is to
> > pickle just the LogRecord's __dict__ and send that over the wire. The
> > logging package contains a function makeLogRecord(d) where d is a
> > dict.
>
> You are right, my approach is too complicated and only needed when the OP
> cannot modify the sending script -- which is unlikely.
>
> > This is the approach used by the examples in the library documentation
> > which pickle events for sending across a network:
>
> >http://docs.python.org/howto/logging-cookbook.html#sending-and-receiv...
>
> logging-events-across-a-network
>
>
>
> > The built-in SocketHandler pickles the LogRecord's __dict__ rather
> > than the LogRecord itself, precisely because of the improved
> > interoperability over pickling the instance directly.
>
> As a minimal change ensuring that the logging.LogRecord subclass used by the
> OP is a newstyle class in 2.6 with
>
> class LogRecord(logging.LogRecord, object):
>     #...
>
> should work, too.

I tried this, but it didn't work. Pickling the __dict__ and then use
makeLogRecord does the trick.

Thank you very much for the excellent help,

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