[issue16372] Initialization strange behavior

2012-10-31 Thread Wojciech Danilo

New submission from Wojciech Danilo:

Hi!
I'm using Python for several years and now I'm writing in Python 3 for the 
first time. I think I found a strange bug in it. Lets concider the code in the 
attachement.
In the 33 line there is construction of new instance of class Result:
print('!!!',Result().value)
what is strange, the class is defined as:
class Result:
def __init__(self, value=[], start=0, end=0):
self.value = value
...

and what I get as a result is:
"!!! ['a', 'b']"

Where the array was somehow magically stored from previous initialization (take 
a look at the code for full listing).

--
components: Interpreter Core
files: test.py
messages: 174280
nosy: wdanilo
priority: normal
severity: normal
status: open
title: Initialization strange behavior
versions: Python 3.3
Added file: http://bugs.python.org/file27809/test.py

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



[issue16372] Initialization strange behavior

2012-10-31 Thread Wojciech Danilo

Wojciech Danilo added the comment:

Wow, I was using Python so long and I didn't know about it. Is there any paper 
discussing why this feature is better than storing "cache" as global variable / 
as class "private" parameter?

--

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



[issue16372] Initialization strange behavior

2012-10-31 Thread Wojciech Danilo

Wojciech Danilo added the comment:

Thank you!

--

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



[issue16851] ismethod and isfunction methods error

2013-01-03 Thread Wojciech Danilo

New submission from Wojciech Danilo:

Hi! I think this behaviour is bug. Lets concider the following code:

import inspect
class X(object):
def a(self):pass
def b(self):pass
def c(self):pass

print(inspect.getmembers(X, predicate=inspect.ismethod))
print(inspect.getmembers(X, predicate=inspect.isfunction))

In python 2.7, the results are:
[('a', ), ('b', ), ('c', )]
[]

and in Python 3.2:
[]
[('a', ), ('b', ), ('c', 
)]

I think, the results from python 2.7 are correct.

--
components: Library (Lib)
messages: 178964
nosy: wdanilo
priority: normal
severity: normal
status: open
title: ismethod and isfunction methods error
type: behavior
versions: Python 2.7, Python 3.2

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