Tuesday, January 26, 2010

comp.lang.python - 25 new messages in 11 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* pylint and the 'missing docstring' warning - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/dc667186a8854284?hl=en
* TypeError not caught by except statement - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e37098914031635d?hl=en
* list.pop(0) vs. collections.dequeue - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9221d87f93748b3f?hl=en
* Accessing the name of an actual parameter - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/8f475dd9c4d9b409?hl=en
* ctypes for AIX - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a93f969410d0d086?hl=en
* Authenticated encryption with PyCrypto - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/26ef2de83c5a0337?hl=en
* deriving from array.array - 5 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/a453c65be4e0f355?hl=en
* Sikuli: the coolest Python project I have yet seen... - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.python/t/766e5530f706ed52?hl=en
* Any Swisses here? - 3 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/474e4bb231d93e43?hl=en
* Py 3: Terminal script can't find relative path - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a89ac5bd497596cc?hl=en
* Python or Ant - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/d58ba6fc9a251f78?hl=en

==============================================================================
TOPIC: pylint and the 'missing docstring' warning
http://groups.google.com/group/comp.lang.python/t/dc667186a8854284?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Jan 26 2010 8:19 am
From: John Posner


On 1/26/2010 9:22 AM, Jean-Michel Pichavant wrote:
> John Posner wrote:
>> On 1/26/2010 8:43 AM, Jean-Michel Pichavant wrote:
>>> Hello,
>>>
>>> Does anyone using pylint knows a way to make pylint ignore these
>>> 'missing docstring' warnings when the base class version of the method
>>> actually defines the docstring ?
>>> 'Cause my doc builder (epydoc) handle it properly and propagate
>>> docstrings if asked to. Too bad pylint is complaining about it.
>>> I don't want to deactivate this warning.
>>>
>>
>> Look for this setting in the pylint configuration file:
>>
>> # not require a docstring
>> no-docstring-rgx=__.*__
>>
>> -John
>>
>>
> If I'm no wrong this just disables docstring checks for methods matching
> __.*__
> I'd like to disable it for any method which base class version already
> defines the docstring.
>

I'm a Pylint newbie myself. The only (half-baked) idea I can come up
with is to use a naming convention for such derived classes. For
example, if all such class names ended with "_d" (ugh!), you could
modify the configuration setting like this:

no-docstring-rgx=(__.*__|.*_d)

-John


== 2 of 2 ==
Date: Tues, Jan 26 2010 9:20 am
From: Jean-Michel Pichavant


John Posner wrote:
> On 1/26/2010 9:22 AM, Jean-Michel Pichavant wrote:
>> John Posner wrote:
>>> On 1/26/2010 8:43 AM, Jean-Michel Pichavant wrote:
>>>> Hello,
>>>>
>>>> Does anyone using pylint knows a way to make pylint ignore these
>>>> 'missing docstring' warnings when the base class version of the method
>>>> actually defines the docstring ?
>>>> 'Cause my doc builder (epydoc) handle it properly and propagate
>>>> docstrings if asked to. Too bad pylint is complaining about it.
>>>> I don't want to deactivate this warning.
>>>>
>>>
>>> Look for this setting in the pylint configuration file:
>>>
>>> # not require a docstring
>>> no-docstring-rgx=__.*__
>>>
>>> -John
>>>
>>>
>> If I'm no wrong this just disables docstring checks for methods matching
>> __.*__
>> I'd like to disable it for any method which base class version already
>> defines the docstring.
>>
>
> I'm a Pylint newbie myself. The only (half-baked) idea I can come up
> with is to use a naming convention for such derived classes. For
> example, if all such class names ended with "_d" (ugh!), you could
> modify the configuration setting like this:
>
> no-docstring-rgx=(__.*__|.*_d)
>
> -John
That would work but I definitely don't want to do that.

JM


==============================================================================
TOPIC: TypeError not caught by except statement
http://groups.google.com/group/comp.lang.python/t/e37098914031635d?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Jan 26 2010 8:54 am
From: Steve Holden


siddhartha veedaluru wrote:
> Hi,
>
> except not able to caught the TypeError exception occured in the below
> code
>
> log.info <http://log.info>("refer",ret) in the try block
>
> throws a TypeError which is not caught .

The traceback you provide does not show the line in question, so I am
confused as to why you would think it was causing the problem. The
purpose of the traceback is to show you where the exception occurred,
and I question whether that is happening here.

Anyway, I suspect your error might go away if you turned the first
argument of hte log.info() call into a format string such as

log.info("refer: %s", ret)

regards
Steve

> Also sometimes process is getting hanged.
>
> ------------------------------------------------------------------------------------------------------------------------------------------------
> import logging
> log = logging.getLogger()
> fileName = strftime("%d-%b-%Y-", gmtime()) + str(int(time.time())) + "-
> Log.log"
> log = logging.getLogger()
> log.setLevel(logging.NOTSET)
> fh = logging.FileHandler(logFile)
> logFileLevel = logging.DEBUG
> fh.setLevel(logFileLevel)
> format_string = '%(process)d %(thread)d %(asctime)-15s %(levelname)-5s
> at %(filename)-15s in %(funcName)-10s at line %(lineno)-3d "%(message)
> s"'
> fh.setFormatter(logging.Formatter(format_string))
> log.addHandler(fh)
>
> try:
> log.info <http://log.info>("start")
> log.info <http://log.info>("refer",ret)
> log.info <http://log.info>("end")
> except TypeError:
> log.exception("Exception raised")
>
> ----------------------------------------------------------------------------------------------------------------------------------------------
> OUTPUT message:
>
> Traceback (most recent call last):
> File "C:\Python26\lib\logging\__init__.py", line 768, in emit
> msg = self.format(record)
> File "C:\Python26\lib\logging\__init__.py", line 648, in format
> return fmt.format(record)
> File "C:\Python26\lib\logging\__init__.py", line 436, in format
> record.message = record.getMessage()
> File "C:\Python26\lib\logging\__init__.py", line 306, in getMessage
> msg = msg % self.args
> TypeError: not all arguments converted during string formatting
>


--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


== 2 of 2 ==
Date: Tues, Jan 26 2010 8:54 am
From: Steve Holden


siddhartha veedaluru wrote:
> Hi,
>
> except not able to caught the TypeError exception occured in the below
> code
>
> log.info <http://log.info>("refer",ret) in the try block
>
> throws a TypeError which is not caught .

The traceback you provide does not show the line in question, so I am
confused as to why you would think it was causing the problem. The
purpose of the traceback is to show you where the exception occurred,
and I question whether that is happening here.

Anyway, I suspect your error might go away if you turned the first
argument of hte log.info() call into a format string such as

log.info("refer: %s", ret)

regards
Steve

> Also sometimes process is getting hanged.
>
> ------------------------------------------------------------------------------------------------------------------------------------------------
> import logging
> log = logging.getLogger()
> fileName = strftime("%d-%b-%Y-", gmtime()) + str(int(time.time())) + "-
> Log.log"
> log = logging.getLogger()
> log.setLevel(logging.NOTSET)
> fh = logging.FileHandler(logFile)
> logFileLevel = logging.DEBUG
> fh.setLevel(logFileLevel)
> format_string = '%(process)d %(thread)d %(asctime)-15s %(levelname)-5s
> at %(filename)-15s in %(funcName)-10s at line %(lineno)-3d "%(message)
> s"'
> fh.setFormatter(logging.Formatter(format_string))
> log.addHandler(fh)
>
> try:
> log.info <http://log.info>("start")
> log.info <http://log.info>("refer",ret)
> log.info <http://log.info>("end")
> except TypeError:
> log.exception("Exception raised")
>
> ----------------------------------------------------------------------------------------------------------------------------------------------
> OUTPUT message:
>
> Traceback (most recent call last):
> File "C:\Python26\lib\logging\__init__.py", line 768, in emit
> msg = self.format(record)
> File "C:\Python26\lib\logging\__init__.py", line 648, in format
> return fmt.format(record)
> File "C:\Python26\lib\logging\__init__.py", line 436, in format
> record.message = record.getMessage()
> File "C:\Python26\lib\logging\__init__.py", line 306, in getMessage
> msg = msg % self.args
> TypeError: not all arguments converted during string formatting
>


--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


==============================================================================
TOPIC: list.pop(0) vs. collections.dequeue
http://groups.google.com/group/comp.lang.python/t/9221d87f93748b3f?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Jan 26 2010 8:57 am
From: Steve Holden


Steve Howell wrote:
> On Jan 24, 11:28 am, a...@pythoncraft.com (Aahz) wrote:
>> In article <b4440231-f33f-49e1-9d6f-5fbce0a63...@b2g2000yqi.googlegroups.com>,
>> Steve Howell <showel...@yahoo.com> wrote:
>>
>>
>>
>>> Even with realloc()'s brokenness, you could improve pop(0) in a way
>>> that does not impact list access at all, and the patch would not change
>>> the time complexity of any operation; it would just add negligible
>>> extract bookkeeping within list_resize() and a few other places.
>> Again, your responsibility is to provide a patch and a spectrum of
>> benchmarking tests to prove it. Then you would still have to deal with
>> the objection that extensions use the list internals -- that might be an
>> okay sell given the effort otherwise required to port extensions to
>> Python 3, but that's not the way to bet.
>>
>
> Ok, I just submitted a patch to python-dev that illustrates a 100x
> speedup on an admittedly artificial program. It still has a long way
> to go, but it demonstrates proof of concept. I'm done for the day,
> but tomorrow I will try to polish it up and improve it, even if its
> doomed for rejection. Apologies to all I have offended in this
> thread. I frankly found some of the pushback to be a bit hasty and
> disrespectful, but I certainly overreacted to some of the criticism.
> And now I'm in the awkward position of asking the people I offended to
> help me with the patch. If anybody can offer me a hand in
> understanding some of CPython's internals, particularly with regard to
> memory management, it would be greatly appreciated.
>
> (Sorry I don't have a link to the python-dev posting; it is not
> showing up in the archives yet for some reason.)
>
>
Fortunately for you this is a very welcoming group, and particularly
responsive to individuals who have seen the error of their ways ;-)

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


== 2 of 2 ==
Date: Tues, Jan 26 2010 8:57 am
From: Steve Holden


Steve Howell wrote:
> On Jan 24, 11:28 am, a...@pythoncraft.com (Aahz) wrote:
>> In article <b4440231-f33f-49e1-9d6f-5fbce0a63...@b2g2000yqi.googlegroups.com>,
>> Steve Howell <showel...@yahoo.com> wrote:
>>
>>
>>
>>> Even with realloc()'s brokenness, you could improve pop(0) in a way
>>> that does not impact list access at all, and the patch would not change
>>> the time complexity of any operation; it would just add negligible
>>> extract bookkeeping within list_resize() and a few other places.
>> Again, your responsibility is to provide a patch and a spectrum of
>> benchmarking tests to prove it. Then you would still have to deal with
>> the objection that extensions use the list internals -- that might be an
>> okay sell given the effort otherwise required to port extensions to
>> Python 3, but that's not the way to bet.
>>
>
> Ok, I just submitted a patch to python-dev that illustrates a 100x
> speedup on an admittedly artificial program. It still has a long way
> to go, but it demonstrates proof of concept. I'm done for the day,
> but tomorrow I will try to polish it up and improve it, even if its
> doomed for rejection. Apologies to all I have offended in this
> thread. I frankly found some of the pushback to be a bit hasty and
> disrespectful, but I certainly overreacted to some of the criticism.
> And now I'm in the awkward position of asking the people I offended to
> help me with the patch. If anybody can offer me a hand in
> understanding some of CPython's internals, particularly with regard to
> memory management, it would be greatly appreciated.
>
> (Sorry I don't have a link to the python-dev posting; it is not
> showing up in the archives yet for some reason.)
>
>
Fortunately for you this is a very welcoming group, and particularly
responsive to individuals who have seen the error of their ways ;-)

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


==============================================================================
TOPIC: Accessing the name of an actual parameter
http://groups.google.com/group/comp.lang.python/t/8f475dd9c4d9b409?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Jan 26 2010 9:12 am
From: Jean-Michel Pichavant


Duncan Booth wrote:
> Gary Herron <gherron@islandtraining.com> wrote:
>
>
>> It's naive to think this question even makes sense. There are many ways
>> f can be called which don't involve a parameter:
>>
>> f(42)
>> f(time())
>> f(a+123)
>> f(sin(a))
>> f(f(1))
>>
>> and so on.
>>
>
> So long as the OP doesn't care if they get no names or several name that
> might not matter. However, explicitly passing in the name you want to use
> is likely to be more useful.
>
>
>>>> def getcallersnames(obj):
>>>>
> f = inspect.currentframe().f_back.f_back
> return [name for name in f.f_locals if f.f_locals[name] is obj]
>
>
>>>> def bip(x):
>>>>
> print getcallersnames(x)
>
>
>
>>>> def foo(bar):
>>>>
> baz = bar
> bip(baz)
> bip(baz+1)
>
>
>
>>>> foo(3)
>>>>
> ['bar', 'baz']
> []
>
How do you know which between baz and bar has been used ? Here you get
all names (in locals()) referencing the object passed in argument, you
don't get the one actually used for the call.

Another issue:

class Foo:
test = 'test'

def foo(bar):
bip(bar.test)

f = Foo()

foo(f)
[]


That restricts pretty much the use of getcallersnames.
As said before, there is hardly any legit design which would require to
know the actual refrence used to pass a parameter.

JM

==============================================================================
TOPIC: ctypes for AIX
http://groups.google.com/group/comp.lang.python/t/a93f969410d0d086?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Jan 26 2010 9:21 am
From: "M.-A. Lemburg"


Waddle, Jim wrote:
> I need to use ctypes with python running on AIX. It appears that python is being developed mostly for windows. Is there a policy concerning getting functions like ctypes working on AIX.

If you can provide patches to get ctypes working on AIX, we'd
consider adding those to the core.

Please file patch or bug describing the problems you are having
on AIX with the tracker:

http://bugs.python.org/

Thanks,
--
Marc-Andre Lemburg
eGenix.com

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

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


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

==============================================================================
TOPIC: Authenticated encryption with PyCrypto
http://groups.google.com/group/comp.lang.python/t/26ef2de83c5a0337?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Jan 26 2010 9:37 am
From: "M.-A. Lemburg"


Daniel wrote:
> Just got done reading this thread:
>
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/b31a5b5f58084f12/0e09f5f5542812c3
>
> and I'd appreciate feedback on this recipe:
>
> http://code.activestate.com/recipes/576980/
>
> Of course, it does not meet all of the requirements set forth by the
> OP in the referenced thread (the pycrypto dependency is a problem),
> but it is an attempt to provide a simple interface for performing
> strong, password-based encryption. Are there already modules out there
> that provide such a simple interface? If there are, they seem to be
> hiding somewhere out of Google's view.
>
> I looked at ezPyCrypto, but it seemed to require public and private
> keys, which was not convenient in my situation... maybe password-based
> encryption is trivial to do with ezPyCrypto as well? In addition to
> ezPyCrypto, I looked at Google's keyczar, but despite the claims of
> the documentation, the API seemed overly complicated. Is it possible
> to have a simple API for an industry-strength encryption module? If
> not, is it possible to document that complicated API such that a non-
> cryptographer could use it and feel confident that he hadn't made a
> critical mistake?

Yes, it is possible, but whatever you come up with will usually
be bound to just one (or a few) different use cases, e.g. just
look at the different cipher modes there are, the different key
sizes, block sizes (for block ciphers), IV strings, padding, etc.
etc.

Note that your code has a padding bug: the decoder doesn't
undo the padding. You're lucky though, since pickle will only
read as much data as it needs and not complain about the extra
data it finds.

You are also using CBC mode, even though you are really after
ECB mode (your code doesn't use chaining). With ECB mode, you
don't need the IV string.

> Also, slightly related, is there an easy way to get the sha/md5
> deprecation warnings emitted by PyCrypto in Python 2.6 to go away?

Yes: you silence them via the warnings module. I suppose that the
latest version of PyCrypto fixes these warnings.

--
Marc-Andre Lemburg
eGenix.com

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

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


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


== 2 of 3 ==
Date: Tues, Jan 26 2010 11:40 am
From: geremy condra


On Tue, Jan 26, 2010 at 12:37 PM, M.-A. Lemburg <mal@egenix.com> wrote:

<snip>

> You are also using CBC mode, even though you are really after
> ECB mode (your code doesn't use chaining). With ECB mode, you
> don't need the IV string.

However, ECB mode is not as secure- the IV is the right way to go
here.

I'd also note that you aren't supposed to use RandomPool anymore,
and that AES-192 is frequently recommended over AES-256 for
new applications due to a number of recent developments in
the cryptanalysis of its key schedule.

Geremy Condra


== 3 of 3 ==
Date: Tues, Jan 26 2010 11:45 am
From: Paul Rubin


Daniel <millerdev@gmail.com> writes:
> Of course, it does not meet all of the requirements set forth by the
> OP in the referenced thread (the pycrypto dependency is a problem),
> but it is an attempt to provide a simple interface for performing
> strong, password-based encryption. Are there already modules out there
> that provide such a simple interface? If there are, they seem to be
> hiding somewhere out of Google's view.

http://www.nightsong.com/phr/crypto/p3.py

I need to update it to handle 64-bit OS's and use Python 3.x-style print
statements, but that is pretty trivial.

==============================================================================
TOPIC: deriving from array.array
http://groups.google.com/group/comp.lang.python/t/a453c65be4e0f355?hl=en
==============================================================================

== 1 of 5 ==
Date: Tues, Jan 26 2010 9:41 am
From: Torsten Mohr


Hello,

i try to derive a class from array.array:


import array

class Abc(array.array):
def __init__(self, a, b):
array.array.__init__(self, 'B')
self.a = a
self.b = b


a = Abc(4, 5)
print a
print a.a


I get an error for "a = Abc(4, 5)", seems the parameters are
forwarded to array's __init__ as they are. Though i explicitly
call __init__() for array.

I'd like to use array and make sure it's type is always 'B'.
I'd like to derive because i don't want to rewrite all the methods like
__getiem__ for my class and then call array's __getitem__.

How do i best derive from array.array?


Thanks for any hints,
Torsten.

== 2 of 5 ==
Date: Tues, Jan 26 2010 10:24 am
From: "Alf P. Steinbach"


* Torsten Mohr:
> Hello,
>
> i try to derive a class from array.array:
>
>
> import array
>
> class Abc(array.array):
> def __init__(self, a, b):
> array.array.__init__(self, 'B')
> self.a = a
> self.b = b
>
>
> a = Abc(4, 5)
> print a
> print a.a
>
>
> I get an error for "a = Abc(4, 5)", seems the parameters are
> forwarded to array's __init__ as they are.

No, with CPython they're forwarded to __new__.


> Though i explicitly
> call __init__() for array.

That's the constructor inherited from 'object', it takes no args (except the
self arg).


> I'd like to use array and make sure it's type is always 'B'.
> I'd like to derive because i don't want to rewrite all the methods like
> __getiem__ for my class and then call array's __getitem__.
>
> How do i best derive from array.array?

<code>
import array

class ByteArray( array.array ):
def __new__( self, *args ):
return array.array.__new__( self, "B" )

def __init__( self, a, b ):
array.array.__init__( self )
self.a = a
self.b = b

a = ByteArray( 4, 5 )
print( a )
print( a.a )
</code>


Disclaimer: I'm not a Python programmer. :-)


Cheers & hth.,

- Alf


== 3 of 5 ==
Date: Tues, Jan 26 2010 11:23 am
From: "Alf P. Steinbach"


* Alf P. Steinbach:
> * Torsten Mohr:
>> Hello,
>>
>> i try to derive a class from array.array:
>>
>>
>> import array
>>
>> class Abc(array.array):
>> def __init__(self, a, b):
>> array.array.__init__(self, 'B')
>> self.a = a
>> self.b = b
>>
>>
>> a = Abc(4, 5)
>> print a
>> print a.a
>>
>>
>> I get an error for "a = Abc(4, 5)", seems the parameters are
>> forwarded to array's __init__ as they are.
>
> No, with CPython they're forwarded to __new__.
>
>
>> Though i explicitly
>> call __init__() for array.
>
> That's the constructor inherited from 'object', it takes no args (except
> the self arg).
>
>
>> I'd like to use array and make sure it's type is always 'B'.
>> I'd like to derive because i don't want to rewrite all the methods
>> like __getiem__ for my class and then call array's __getitem__.
>>
>> How do i best derive from array.array?
>
> <code>
> import array
>
> class ByteArray( array.array ):
> def __new__( self, *args ):
> return array.array.__new__( self, "B" )
>
> def __init__( self, a, b ):
> array.array.__init__( self )
> self.a = a
> self.b = b
>
> a = ByteArray( 4, 5 )
> print( a )
> print( a.a )
> </code>
>
>
> Disclaimer: I'm not a Python programmer. :-)

Hm, good that I included a disclaimer. The above code is technically OK but it
is misleading. The first argument to '__new__' is not a self argument but a type
argument, better called 'cls' or some such.

From the docs, "__new__() is a static method (special-cased so you need not
declare it as such) that takes the class of which an instance was requested as
its first argument"


Cheers,

- Alf (self-correcting)


== 4 of 5 ==
Date: Tues, Jan 26 2010 11:28 am
From: Torsten Mohr


Hello,

thanks a lot for your hint, it works fine.

>> I get an error for "a = Abc(4, 5)", seems the parameters are
>> forwarded to array's __init__ as they are.
>
> No, with CPython they're forwarded to __new__.

Not sure if i understand this correctly, if i derive from other
classes (like wxpython widgets) i always call the bases __init__ .

>> Though i explicitly
>> call __init__() for array.
>
> That's the constructor inherited from 'object', it takes no args (except
> the self arg).

Is there a way to find out what i need to call? I haven't found much in
the documentation. From writing C extensions i knew about the "new" entry
in the PyTypeObject struct but it seems there's more behind it.
In docs.python.org i did not find much, is there an URL where i can read
more?


Best regards,
Torsten.


== 5 of 5 ==
Date: Tues, Jan 26 2010 11:51 am
From: "Alf P. Steinbach"


* Torsten Mohr:
>
> thanks a lot for your hint, it works fine.
>
>>> I get an error for "a = Abc(4, 5)", seems the parameters are
>>> forwarded to array's __init__ as they are.
>> No, with CPython they're forwarded to __new__.
>
> Not sure if i understand this correctly, if i derive from other
> classes (like wxpython widgets) i always call the bases __init__ .

Well, creation of an object happens in two phases: allocation and initialization.

Allocation reserves memory for the object and creates a sort of default object
in that memory. This is the job of __new__. The object doesn't exist at all
before __new__ is called.

Initialization then outfits the object with all that's required for a proper
object of class T. This is the job of __init__. __init__ as passed as argument
the default object created by __new__.

CPython's array.array does both in __new__. It does not override the __init__ it
inherits from 'object'. To wit:

>>> import array
>>> id( array.array.__init__ )
10965560
>>> id( object.__init__ )
10965560
>>> array.array.__init__ is object.__init__
True
>>> _

So overriding __init__ doesn't override any of array.array's functionality.

But you'd have to override __new__ anyway, because with array.array the first
argument has to be a type code specifying the element type of the array object
the __new__ should create. An alternative design instead of those type codes
could have had one subclass for each element type, essentially what you're
doing, except you're only doing one of those subclasses. Then there would be no
issue with __new__.


>>> Though i explicitly
>>> call __init__() for array.
>> That's the constructor inherited from 'object', it takes no args (except
>> the self arg).
>
> Is there a way to find out what i need to call?

Testing. :-)


> I haven't found much in
> the documentation. From writing C extensions i knew about the "new" entry
> in the PyTypeObject struct but it seems there's more behind it.
> In docs.python.org i did not find much, is there an URL where i can read
> more?

Don't know, sorry. Google?


Cheers,

- Alf

==============================================================================
TOPIC: Sikuli: the coolest Python project I have yet seen...
http://groups.google.com/group/comp.lang.python/t/766e5530f706ed52?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Jan 26 2010 10:59 am
From: CM


On Jan 24, 10:18 pm, Ron <ursusmaxi...@gmail.com> wrote:
> Sikuli is the coolest Python project I have ever seen in my ten year
> hobbyist career. An MIT oepn source project, Sikuli uses Python to
> automate GUI tasks (in any GUI or GUI baed app that runs the JVM) by
> simply drag and dropping GUI elements into Python scripts as function
> arguments. Download athttp://sikuli.csail.mit.edu/I also did this
> podcast about Sikulihttp://media.libsyn.com/media/awaretek/Python411_20100124_Sikuli.mp3

How is this preferable to a macro recorder?


== 2 of 2 ==
Date: Tues, Jan 26 2010 12:24 pm
From: Ron


On Jan 26, 10:59 am, CM <cmpyt...@gmail.com> wrote:
> On Jan 24, 10:18 pm, Ron <ursusmaxi...@gmail.com> wrote:
>
> > Sikuli is the coolest Python project I have ever seen in my ten year
> > hobbyist career. An MIT open source project, Sikuli uses Python to
> > automate GUI tasks (in any GUI or GUI based app that runs the JVM) by
> > simply drag and dropping GUI elements into Python scripts as function
> > Arguments. Download athttp://sikuli.csail.mit.edu/Ialso did this
> > podcast about Sikulihttp://media.libsyn.com/media/awaretek/Python411_20100124_Sikuli.mp3
>
> How is this preferable to a macro recorder?

Well, the pattern recognition engine allows you to recognize partial
matches to any image, to any desired degree of accuracy. In other
words, you can specify to take action only when an exact match is
found, or else when a 50% match is found. This allows applications
like the baby monitor (to tell you when your sleeping baby wakes up,
and the imminent bus arrival monitor (to tell you when your bus is
within one mile or any distance you want), and the route mapper from
one city to another on a digital map.

Another thing, Sikuli works with web pages. In other words, you can
automate interaction with web sites as well as with desktop
applications.

You can also automate the entry of text.

And it works (theoretically) on any graphical platform (Mac, Linux,
Window, smartphones, etc).

Probably other advantages. Those are just the ones I see off the top
of my head.

Good question.

Ron

==============================================================================
TOPIC: Any Swisses here?
http://groups.google.com/group/comp.lang.python/t/474e4bb231d93e43?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Jan 26 2010 11:25 am
From: n00m


And this ones want only to smoke hookahs, to dance, to get welfare
payments.
And to do nothing, of course.
In France for them were built hundreds of schools, colleges etc.
They had spit into French people *soul* while crushing cars, shops and
the schools.
They expose themselves as "victims" of Western civilization. Very
smart.

Sorry guys. I'm really a very kind and tolerant person but
and me too don't want "new mosques" in Swiss.
Hope (surely) you understand me right what I mean.
I'm not a troll, just currently in such a mood.


== 2 of 3 ==
Date: Tues, Jan 26 2010 11:53 am
From: n00m


For me Swiss is a country of Otto Frisch, Hesse
(I know hi's a Scwabian)
and many many other charming things
But really maybe maybe in some of my next lives
I visit this wonderful country:
I don't want to see there Muslim mosques


== 3 of 3 ==
Date: Tues, Jan 26 2010 12:10 pm
From: n00m


PS

> I don't want to see there Muslim mosques

Along with Orthodox churches.
Though I'm a baptized Orthodox, since my birth.
I admire Orthodox church cupolas, but near to me,
in my own country.

What I'm against is when someones try to hide
their laziness, stupidity, impudence etc under
sauce of "merging of cultures".


==============================================================================
TOPIC: Py 3: Terminal script can't find relative path
http://groups.google.com/group/comp.lang.python/t/a89ac5bd497596cc?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Jan 26 2010 11:35 am
From: aahz@pythoncraft.com (Aahz)


In article <98c70d6f-5872-436b-b160-01b39d17d270@a32g2000yqm.googlegroups.com>,
Gnarlodious <gnarlodious@gmail.com> wrote:
>
>OK I guess that is normal, I fixed it with this:
>path=os.path.dirname(__file__)+"/Data/"

Use os.path.join() instead -- just in case you ever port to Windows
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/

import antigravity

==============================================================================
TOPIC: Python or Ant
http://groups.google.com/group/comp.lang.python/t/d58ba6fc9a251f78?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Jan 26 2010 11:46 am
From: Steve Holden


gslindstrom@gmail.com wrote:
> My company is looking at creating a tool to allow us to define and
> manage a process for each job we run (a typical job may be look on a
> customers ftp site for a file, download it, decrypt it and load it into
> our database). We would like something which would allow us to glue
> together various existing processes we currently use into a single unit
> with multiple steps. Along the way, this new routine would need to log
> its progress and be able to report and even handle errors. A coworker
> has suggested we look at Ant ("Another Neat Tool") and, though it looks
> promising, I have reservations. If I recall correctly, it was intended
> as a replacement for "Make" and I worry that we may be trying to force
> Ant to be something it is not. Also, most of our code base is in Python
> and I'd really like to stay that way, of possible.
>
> Are there any systems out there that will allow me to run multiple
> programs as one process? We could write our own, of course, and the
> Twisted package looks like it would be fun to use. Or, is Ant a viable
> solution to our problem?
>
> Your constructive comments would be appreciated
>
> Greg Lindstrom
> Novasys Health
> Little Rock, Arkansas
>
Take a look at fabric. It was designed for installation, but it might do
what you want.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/


== 2 of 3 ==
Date: Tues, Jan 26 2010 11:46 am
From: Steve Holden


gslindstrom@gmail.com wrote:
> My company is looking at creating a tool to allow us to define and
> manage a process for each job we run (a typical job may be look on a
> customers ftp site for a file, download it, decrypt it and load it into
> our database). We would like something which would allow us to glue
> together various existing processes we currently use into a single unit
> with multiple steps. Along the way, this new routine would need to log
> its progress and be able to report and even handle errors. A coworker
> has suggested we look at Ant ("Another Neat Tool") and, though it looks
> promising, I have reservations. If I recall correctly, it was intended
> as a replacement for "Make" and I worry that we may be trying to force
> Ant to be something it is not. Also, most of our code base is in Python
> and I'd really like to stay that way, of possible.
>
> Are there any systems out there that will allow me to run multiple
> programs as one process? We could write our own, of course, and the
> Twisted package looks like it would be fun to use. Or, is Ant a viable
> solution to our problem?
>
> Your constructive comments would be appreciated
>
> Greg Lindstrom
> Novasys Health
> Little Rock, Arkansas
>
Take a look at fabric. It was designed for installation, but it might do
what you want.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/

== 3 of 3 ==
Date: Tues, Jan 26 2010 12:21 pm
From: John Bokma


Steve Holden <steve@holdenweb.com> writes:

Apologies for the piggy back, my Usenet provider can't get the OP's
message.

> gslindstrom@gmail.com wrote:
>> My company is looking at creating a tool to allow us to define and
>> manage a process for each job we run (a typical job may be look on a
>> customers ftp site for a file, download it, decrypt it and load it into
>> our database). We would like something which would allow us to glue
>> together various existing processes we currently use into a single unit
>> with multiple steps. Along the way, this new routine would need to log
>> its progress and be able to report and even handle errors. A coworker
>> has suggested we look at Ant ("Another Neat Tool") and, though it looks
>> promising, I have reservations. If I recall correctly, it was intended
>> as a replacement for "Make" and I worry that we may be trying to force
>> Ant to be something it is not.

It was intended as a replacement. But you can use it for many other
things, without making it feel out of place in my opinion. I do use it
exactly the way you describe for various tasks: calling external
programs, uploading a file, etc. My personal site, see sig, is generated
by a Perl program, and uploaded by another, and some other programs have
to run as well, and all is glued together using ant. If I modify an XML
file (my site is defined using XML), I do:

ant local

to update a local version.

If I am happy with how it looks, I do

ant upload

Ant makes several things really easy. The things I do with it would take
me more lines in either Perl or Python. So I use Perl (or Python) when
it makes things easier, and ant to glue everything together if that's
easier.

--
John Bokma j3b

Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate