Erik wrote:
Is there not a class that is somewhere between "dict" and "OrderedDict"
that provides what I need?
Such a class could exist, but the stdlib doesn't happen to provide
one as far as I know.
Note, though, that you're relying on implementation details of
OrderedDict when you use it to
On Sunday, April 30, 2017 at 2:30:25 AM UTC+1, Erik wrote:
> On 30/04/17 01:17, breamoreboy wrote:
> > On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> >> The other is that the documentation of collections.OrderedDict seems to
> >> be lacking (it is talking in terms of being a "dict" s
On 30/04/17 01:17, breamore...@gmail.com wrote:
On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
The other is that the documentation of collections.OrderedDict seems to
be lacking (it is talking in terms of being a "dict" subclass, but it
actually isn't one).
E.
Could have fooled m
On 30/04/17 01:31, Ben Finney wrote:
Erik writes:
On 29/04/17 23:40, Ned Batchelder wrote:
For creating your own class that acts like a dict, you should derive
from collections.abc.MutableMapping, which only requires
implementing __getitem__, __setitem__, __delitem__, __iter__, and
__len__.
On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> On 29/04/17 23:40, Ned Batchelder wrote:
> > For creating your own class that acts like
> > a dict, you should derive from collections.abc.MutableMapping, which
> > only requires implementing __getitem__, __setitem__, __delitem__,
> > __
Erik writes:
> On 29/04/17 23:40, Ned Batchelder wrote:
> > For creating your own class that acts like a dict, you should derive
> > from collections.abc.MutableMapping, which only requires
> > implementing __getitem__, __setitem__, __delitem__, __iter__, and
> > __len__.
>
> Or, I could derive f
Erik wrote:
That's one of the points I'm trying to make - why is it harder than it
needs to be to do something this simple?
The built-in dict class is used internally to implement
various namespaces (module, class, instance, etc.), so it
needs to be extremely efficient. Funnelling all updates
t
On 29/04/17 23:40, Ned Batchelder wrote:
For creating your own class that acts like
a dict, you should derive from collections.abc.MutableMapping, which
only requires implementing __getitem__, __setitem__, __delitem__,
__iter__, and __len__.
Or, I could derive from collections.OrderedDict and j
On Saturday, April 29, 2017 at 4:20:06 PM UTC-4, Erik wrote:
> It seems a little onerous that I have to put the key checks in several
> places and implement each of those APIs manually again (and keep on top
> of that if dict() grows some new methods that involve setting items). Is
> there a co
I have a subclass of dict that enforces which keys are allowed to be set
and only allows each key to be set at most once:
class StrictDict(dict):
def __init__(self, validkeys, *args, **kwargs):
self.validkeys = validkeys
super(StrictDict, self).__init__(*args, **kwargs)
def __setite
17.11.13 08:31, Steven D'Aprano написав(ла):
There's already at least two ways to do it in Python 2:
py> import binascii
py> binascii.hexlify('Python')
'507974686f6e'
py> import codecs
py> codecs.encode('Python', 'hex')
'507974686f6e'
Third:
>>> import base64
>>> base64.b16encode(b'Python')
On 17/11/2013 06:31, Steven D'Aprano wrote:
I agree that its a bit of a mess. But only a little bit, and it will be
less messy by 3.5 when the codecs solution is re-introduced. Then the
codecs.encode and decode functions will be the one obvious way.
For anyone who's interested in the codecs i
On Sat, 16 Nov 2013 23:16:58 +0100, Laszlo Nagy wrote:
> Questions:
>
> * if we have bytes.fromhex() then why don't we have
> bytes_instance.tohex() ?
The Python core developers are quite conservative about adding new
methods, particularly when there is already a solution to the given
problem
On Saturday, November 16, 2013 5:16:58 PM UTC-5, Laszlo Nagy wrote:
> We can convert from hex str to bytes with bytes.fromhex class method:
>
> >>> b = bytes.fromhex("ff")
>
> But we cannot convert from hex binary:
>
> >>> b = bytes.fromhex(b"ff")
> Traceback (most recent call last):
>File
We can convert from hex str to bytes with bytes.fromhex class method:
>>> b = bytes.fromhex("ff")
But we cannot convert from hex binary:
>>> b = bytes.fromhex(b"ff")
Traceback (most recent call last):
File "", line 1, in
TypeError: must be str, not bytes
We don't have bytes_instance.tohex()
On Wed, Jun 26, 2013 at 12:17 AM, Dave Angel wrote:
> On 06/25/2013 09:55 AM, Peter Otten wrote:
>>
>> Marco Perniciaro wrote:
>>
>>> Hi,
>>> I've been working with Python for a long time.
>>> Yet, I came across an issue which I cannot explain.
>>>
>>> Recently I have a new PC (Windows 7).
>>> Pre
On 06/25/2013 09:55 AM, Peter Otten wrote:
Marco Perniciaro wrote:
Hi,
I've been working with Python for a long time.
Yet, I came across an issue which I cannot explain.
Recently I have a new PC (Windows 7).
Previously I could call a Python script with or without the "python" word
at the begin
Marco Perniciaro wrote:
> Hi,
> I've been working with Python for a long time.
> Yet, I came across an issue which I cannot explain.
>
> Recently I have a new PC (Windows 7).
> Previously I could call a Python script with or without the "python" word
> at the beginning. Now the behavior is differ
Hi,
I've been working with Python for a long time.
Yet, I came across an issue which I cannot explain.
Recently I have a new PC (Windows 7).
Previously I could call a Python script with or without the "python" word at
the beginning.
Now the behavior is different if I use or not use the "python" p
Hi,
It seems that in concurrent.futures, ProcessPoolExecutor() can be used
with no args and default to max_workers=multiprocessing.cpu_count();
but for ThreadPoolExecutor() the max_workers arg is required. Is this
intentional? (I'm using Python 3.2.)
--
http://mail.python.org/mailman/listinfo/pyt
On Sunday, March 25, 2012 6:22:10 PM UTC-6, Ben Finney wrote:
> jeff writes:
>
> > On Sunday, March 25, 2012 4:04:55 PM UTC-6, Heiko Wundram wrote:
> > > Am 25.03.2012 23:32, schrieb jeff:
> > > > but I have to be able to get back to root privilege so I can't use
> > > > setgid and setuid.
> > >
jeff <3bee...@gmail.com> writes:
> On Sunday, March 25, 2012 4:04:55 PM UTC-6, Heiko Wundram wrote:
> > Am 25.03.2012 23:32, schrieb jeff:
> > > but I have to be able to get back to root privilege so I can't use
> > > setgid and setuid.
> >
> > Simply not possible (i.e., you can't drop root privi
On Sunday, March 25, 2012 4:04:55 PM UTC-6, Heiko Wundram wrote:
> Am 25.03.2012 23:32, schrieb jeff:
> > After the os.setgroups, os.getgroups says that the process is not in
> > any groups, just as you would expect... I can suppress
> > membership in the root group only by doing os.setgid and os.s
Am 25.03.2012 23:32, schrieb jeff:
After the os.setgroups, os.getgroups says that the process is not in
any groups, just as you would expect... I can suppress
membership in the root group only by doing os.setgid and os.setuid
before the os.system call (in which case I wind up in the group of
the
Run this test program as root:
import os
print "before:", os.getgroups()
os.system("groups")
os.setgroups([])
print "after:", os.getgroups()
os.system("groups")
After the os.setgroups, os.getgroups says that the process is not in any
groups, just as you would expect. However the groups command
Thanks, Ian.
That does seem to explain it. The inner loop doesn't have access to the
class's name space, and of course you can't fix it by referencing Foo.y
explicitly, because the class isn't fully defined yet.
Ultimately, we realized that the dict should be created in the __init__
method, so t
On Mar 20, 3:50 pm, Ian Kelly wrote:
> On Tue, Mar 20, 2012 at 3:16 PM, Dennis Lee Bieber
>
> wrote:
> > On Tue, 20 Mar 2012 16:23:22 -0400, "J. Cliff Dyer"
> > declaimed the following in
> > gmane.comp.python.general:
>
> >> When trying to create a class with a dual-loop generator expression in
On Tue, Mar 20, 2012 at 3:16 PM, Dennis Lee Bieber
wrote:
> On Tue, 20 Mar 2012 16:23:22 -0400, "J. Cliff Dyer"
> declaimed the following in
> gmane.comp.python.general:
>
>>
>> When trying to create a class with a dual-loop generator expression in a
>> class definition, there is a strange scopin
One of my coworkers just stumbled across an interesting issue. I'm
hoping someone here can explain why it's happening.
When trying to create a class with a dual-loop generator expression in a
class definition, there is a strange scoping issue where the inner
variable is not found, (but the outer
On Mon, 09 May 2011 15:09:32 -0400, James Wright wrote:
> Thank you Steven,
>
> I will take your advice :) In this particular case though, I do not
> think a lack of underscore is the issue, at least as far as I can
> understand the issue. Please see my reply to Ethan.
In your reply to Ethan,
7;s are various OpenSuse installs from 10.3 to 11.4. It works on
all the existing ones, which leads me to believe that I have a package
or configuration inconsistency. It should be noted though that I am
quite new to python programming and very well could have coded in a
non-portable manner and was just
James Wright wrote:
On Mon, May 9, 2011 at 4:04 PM, Ethan Furman wrote:
James Wright wrote:
On Mon, May 9, 2011 at 3:36 PM, Ethan Furman wrote:
Change your print line to:
print("D4[%s] = %s" % (report, each_value))
After that, you'll have to track down how D4 is being created to see
Sorry Alex, and thank you.
On Mon, May 9, 2011 at 4:02 PM, Alex Willmer wrote:
> (Direct reply to me, reposted on Jame's behalf)
>
>
>
> Hi Alex,
>
> On Mon, May 9, 2011 at 3:21 PM, Alex Willmer
> wrote:
>> On May 9, 8:10 pm, James Wright wrote:
>>> Hello Ian,
>>>
>>> It does indeed to seem tha
Hello Ethan,
On Mon, May 9, 2011 at 4:04 PM, Ethan Furman wrote:
> James Wright wrote:
>>
>> On Mon, May 9, 2011 at 3:36 PM, Ethan Furman wrote:
>>>
>>> Change your print line to:
>>>
>>> print("D4[%s] = %s" % (report, each_value))
>>>
>>> After that, you'll have to track down how D4 is being
(Direct reply to me, reposted on Jame's behalf)
Hi Alex,
On Mon, May 9, 2011 at 3:21 PM, Alex Willmer
wrote:
> On May 9, 8:10 pm, James Wright wrote:
>> Hello Ian,
>>
>> It does indeed to seem that way. However the script works just fine
>> on other machines, with the same input file.
>
> Ho
James Wright wrote:
On Mon, May 9, 2011 at 3:36 PM, Ethan Furman wrote:
Change your print line to:
print("D4[%s] = %s" % (report, each_value))
After that, you'll have to track down how D4 is being created to see where
'vsr' is coming from.
It does not appear to show a key:
D4[] = vsr
On Mon, May 9, 2011 at 1:29 PM, James Wright wrote:
> It does not appear to show a key:
>
> D4[] = vsr
> Traceback (most recent call last):
> File "render4.py", line 115, in
> create_report_index(each_item)
> File "render4.py", line 26, in create_report_index
> [clean_name, _] = each_valu
On Mon, May 9, 2011 at 3:36 PM, Ethan Furman wrote:
> James Wright wrote:
>>
>> Thank you Ethan,
>>
>> This is what I see now:
>>
>> # python render4.py
>> current each_value is: vsr
>> Traceback (most recent call last):
>> File "render4.py", line 115, in
>> create_report_index(each_item)
>>
On 09/05/2011 20:10, James Wright wrote:
On Mon, May 9, 2011 at 2:41 PM, Ian Kelly wrote:
On Mon, May 9, 2011 at 12:10 PM, James Wright wrote:
Hello,
I have been using a script on several boxes that have been around for
a while, and everything works just fine. I am finding though, that on
s
James Wright wrote:
Thank you Ethan,
This is what I see now:
# python render4.py
current each_value is: vsr
Traceback (most recent call last):
File "render4.py", line 115, in
create_report_index(each_item)
File "render4.py", line 26, in create_report_index
[clean_name, _] = each_va
Hello Ian,
It does indeed to seem that way. However the script works just fine
on other machines, with the same input file.
Thanks,
James
On Mon, May 9, 2011 at 2:41 PM, Ian Kelly wrote:
> On Mon, May 9, 2011 at 12:10 PM, James Wright wrote:
>> Hello,
>>
>> I have been using a script on sev
Thank you Steven,
I will take your advice :) In this particular case though, I do not
think a lack of underscore is the issue, at least as far as I can
understand the issue. Please see my reply to Ethan.
Thanks,
James
On Mon, May 9, 2011 at 2:43 PM, Steven D'Aprano
wrote:
> On Mon, 09 May 2
Thank you Ethan,
This is what I see now:
# python render4.py
current each_value is: vsr
Traceback (most recent call last):
File "render4.py", line 115, in
create_report_index(each_item)
File "render4.py", line 26, in create_report_index
[clean_name, _] = each_value.split('_', 1)
Valu
On Mon, 09 May 2011 14:10:21 -0400, James Wright wrote:
> Hello,
>
> I have been using a script on several boxes that have been around for a
> while, and everything works just fine. I am finding though, that on
> some new OS installs the script fails with:
>
> Traceback (most recent call last):
James Wright wrote:
Hello,
Howdy!
def create_report_index(report): #Here we are creating a simple
index.html file from data in a text file
newfile = open(report + '.html', 'w') #Create the index file using
report name
for each_value in D4[report]:
[clean_name, _] = each_value
On Mon, May 9, 2011 at 12:10 PM, James Wright wrote:
> Hello,
>
> I have been using a script on several boxes that have been around for
> a while, and everything works just fine. I am finding though, that on
> some new OS installs the script fails with:
>
> Traceback (most recent call last):
> F
to believe that I have a package
or configuration inconsistency. It should be noted though that I am
quite new to python programming and very well could have coded in a
non-portable manner and was just lucky to get it working in the first
place :)
Here is the code snippet that generates the failure ( wh
I didn't phrase that very well. I do see the point about this being "an
instance lookup on a class"...
--
http://mail.python.org/mailman/listinfo/python-list
Thanks for finding that reference in the data model docs! I was about to post
a bug report because in PEP 3119 it says otherwise:
> The primary mechanism proposed here is to allow overloading the built-in
> functions isinstance() and issubclass(). The overloading works as follows:
> The call i
On Tue, Apr 19, 2011 at 4:52 PM, andrew cooke wrote:
> Hi,
>
> I've been staring at this problem, in various forms, all day. Am I missing
> something obvious, or is there some strange hardwiring of isinstance? This
> is with Python 3.2.
>
> class A(metaclass=ABCMeta):
> @clas
OK, sorry, I see the mistake. I'm confusing __class__ on the instance and on
te class (the latter being the metaclass). Sorry again, Andrew
--
http://mail.python.org/mailman/listinfo/python-list
Also, there's something strange about the number of arguments (they're not
consistent between the two examples - the "A" to __instancecheck__ should not
be needed). Yet it compiles and runs like that. Very confused :o(
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I've been staring at this problem, in various forms, all day. Am I missing
something obvious, or is there some strange hardwiring of isinstance? This is
with Python 3.2.
class A(metaclass=ABCMeta):
@classmethod
def __instancecheck__(cls, instance): return F
On Wed, 08 Dec 2010 00:47:37 +0100, Steve Holden wrote:
> On 12/6/2010 8:00 PM, Antoine Pitrou wrote:
>> On Sun, 05 Dec 2010 14:47:38 -0500
>> Terry Reedy wrote:
>>> On 12/5/2010 3:31 AM, Greg wrote:
>>>
>>> For future reference,
>>>
1) At http://docs.python.org/py3k/reference/datamodel.html
On 12/6/2010 8:00 PM, Antoine Pitrou wrote:
> On Sun, 05 Dec 2010 14:47:38 -0500
> Terry Reedy wrote:
>> On 12/5/2010 3:31 AM, Greg wrote:
>>
>> For future reference,
>>
>>> 1) At http://docs.python.org/py3k/reference/datamodel.html:
>>> 2) At http://docs.python.org/py3k/library/stdtypes.html:
>>
On Sun, 05 Dec 2010 14:47:38 -0500
Terry Reedy wrote:
> On 12/5/2010 3:31 AM, Greg wrote:
>
> For future reference,
>
> > 1) At http://docs.python.org/py3k/reference/datamodel.html:
> > 2) At http://docs.python.org/py3k/library/stdtypes.html:
>
> do not work because of the trailing :s, at least
On 12/5/2010 3:31 AM, Greg wrote:
For future reference,
1) At http://docs.python.org/py3k/reference/datamodel.html:
2) At http://docs.python.org/py3k/library/stdtypes.html:
do not work because of the trailing :s, at least not with FireFox.
> 1) At http://docs.python.org/py3k/reference/datamo
Greg wrote:
> This is my first post here, so if this is not the correct place to ask
> this, please direct me to the best place.
This is a good place to get general advice and to discuss potential bugs
when you are unsure whether they actually are bugs.
If you are sure that you ran into a bug in
Hello,
This is my first post here, so if this is not the correct place to ask
this, please direct me to the best place.
In looking at the py3k documentation for comparing two classes, two
different view points are expressed (at least it seems so to me).
1) At http://docs.python.org/py3k/reference
On 7/23/2010 2:30 PM, SeanMon wrote:
I was playing around with Python functions returning functions and the
scope rules for variables, and encountered this weird behavior that I
can't figure out.
Why does f1() leave x unbound, but f2() does not?
def f1():
x = 0
def g():
In 3.x, add
SeanMon wrote:
I was playing around with Python functions returning functions and the
scope rules for variables, and encountered this weird behavior that I
can't figure out.
Why does f1() leave x unbound, but f2() does not?
def f1():
x = 0
def g():
x += 1
return x
re
On Fri, Jul 23, 2010 at 11:30 AM, SeanMon wrote:
>
> I was playing around with Python functions returning functions and the
> scope rules for variables, and encountered this weird behavior that I
> can't figure out.
>
> Why does f1() leave x unbound, but f2() does not?
>
> def f1():
> x = 0
>
I was playing around with Python functions returning functions and the
scope rules for variables, and encountered this weird behavior that I
can't figure out.
Why does f1() leave x unbound, but f2() does not?
def f1():
x = 0
def g():
x += 1
return x
return g1
def f2()
On 7/21/2010 2:13 PM, jmfauth wrote:
Small inconsistency in the format.__doc__
sys.version
2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)]
''.format.__doc__
S.format(*args, **kwargs) -> unicode
type('{}'.format(999))
type('{}'.
Small inconsistency in the format.__doc__
>>> sys.version
2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)]
>>> ''.format.__doc__
S.format(*args, **kwargs) -> unicode
>>> type('{}'.format(999))
>>> type('{}'
Anthra Norell wrote:
Sebastian Bassi wrote:
Hi,
Could you post a minimal version of the DB (a DB dump) to test it?
Just remove most information and leave on the ones needed to reproduce
the error. Also remove any personal/confidential information. Then
dump the DB so I can test it here.
Best,
S
Anthra Norell wrote:
Hi all,
Can anyone explain this? Three commands with three different cutoff
dates (12/30, 12/31 and 1/1) produce a formatting inconsistency. Examine
the third field. The first and last run represents it correctly. The
second run strips it. The field happens to be a
Hi,
Could you post a minimal version of the DB (a DB dump) to test it?
Just remove most information and leave on the ones needed to reproduce
the error. Also remove any personal/confidential information. Then
dump the DB so I can test it here.
Best,
SB.
--
http://mail.python.org/mailman/listinfo/
Hi all,
Can anyone explain this? Three commands with three different cutoff
dates (12/30, 12/31 and 1/1) produce a formatting inconsistency. Examine
the third field. The first and last run represents it correctly. The
second run strips it. The field happens to be a record ID and getting it
On Oct 8, 9:09 pm, Ravi <[EMAIL PROTECTED]> wrote:
> Why the following code gives inconsistent method resolution order
> error:
>
If you want to know all the nitty-gritty details about
the MRO (including the reason for the error you get)
you should read this:
http://www.python.org/download/releas
Ravi wrote:
Why the following code gives inconsistent method resolution order
error:
class X(object): x = 4 def f(self): print 'f in X' print dir(X)
X.g(self) def g(self): print 'g in X'
class Y(object, X): def g(self): print 'g in Y'
o = Y() o.f()
Calculating a linear MRO from a non-tree
Ravi wrote:
Why the following code gives inconsistent method resolution order
error:
[...]
Your problem can be reduced to:
>>> class A(object):
... pass
...
>>> A.__mro__
(, )
>>> class B(object, A):
... pass
...
Traceback (most recent call last):
File "", line 1, in
TypeError: Erro
Why the following code gives inconsistent method resolution order
error:
class X(object):
x = 4
def f(self):
print 'f in X'
print dir(X)
X.g(self)
def g(self):
print 'g in X'
class Y(object, X):
def g(
I get two
different results and am very puzzled by this apparent inconsistency.
Could anyone please clarify what I'm missing? I need both to work
consistently for my application.
The sys.exc_* variables are just for backwards compatibility, don't use
them; use sys.exc_info() in
Hi
I am writing some C code which sets and retrieves a Python exception. I
set the exception using PyErr_SetString(), and retrieve it in 2 ways: 1)
using PyErr_Occurred() and 2) Using sys.exc_type. However, I get two
different results and am very puzzled by this apparent inconsistency.
Could
On Apr 4, 4:38 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
> >> If it was a bug it has to violate a functional requirement. I can't
> >> see which one.
>
> > Perhaps it's not a functional requirement but it came up as a real
> > problem on a source colorizer I use. I count o
George Sakkis wrote:
>> If it was a bug it has to violate a functional requirement. I can't
>> see which one.
>
> Perhaps it's not a functional requirement but it came up as a real
> problem on a source colorizer I use. I count on newlines generating
> token.NEWLINE or tokenize.NL tokens in order
On Apr 4, 3:18 pm, Kay Schluehr <[EMAIL PROTECTED]> wrote:
> I guess it's just an artifact of handling line continuations within
> expressions where a different rule is applied. For compilation
> purposes both the newlines within expressions as well as the comments
> are irrelevant. There are even
On 4 Apr., 18:22, George Sakkis <[EMAIL PROTECTED]> wrote:
> The tokenize.generate_tokens function seems to handle in a context-
> sensitive manner the new line after a comment:
>
> >>> from StringIO import StringIO
> >>> from tokenize import generate_tokens
>
> >>> text = '''
>
> ... # hello world
The tokenize.generate_tokens function seems to handle in a context-
sensitive manner the new line after a comment:
>>> from StringIO import StringIO
>>> from tokenize import generate_tokens
>>>
>>> text = '''
... # hello world
... x = (
... # hello world
... )
... '''
>>>
>>> for t in generate_tok
On Mon, Dec 31, 2007 at 02:31:39PM -0800, Hai Vu wrote:
> I currently use ActivePython 2.5.1. Consider the following code which
> I saved as cmdline.py:
> import sys
> print sys.argv[0]
> If I invoke this code as 'python cmdline.py', then the output is:
> cmdline.py
> If I invoke it as
> use os.path.abspath
Bingo! This is just what the doctor ordered. Thank you.
Hai
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 1, 9:31 am, Hai Vu <[EMAIL PROTECTED]> wrote:
> I currently use ActivePython 2.5.1. Consider the following code which
> I saved as cmdline.py:
> import sys
> print sys.argv[0]
> If I invoke this code as 'python cmdline.py', then the output is:
> cmdline.py
> If I invoke it as 'cm
I currently use ActivePython 2.5.1. Consider the following code which
I saved as cmdline.py:
import sys
print sys.argv[0]
If I invoke this code as 'python cmdline.py', then the output is:
cmdline.py
If I invoke it as 'cmdline.py', then the output is:
C:\Users\hai\src\python\cmdline.
Final note: one of the developers ran into a similar issue with dict and
has opened a discussion on pydev about how the C implementation might be
changed to have derived classes act more consistently without imposing a
time penalty on the normal use of dict. There might possibly be a change
by
Thanks to everybody for replies, I'm now satisfied ^_^
Almad
--
http://mail.python.org/mailman/listinfo/python-list
[Almad]
> I discovered this behaviour in dictionary which I find confusing. In
> SneakyLang, I've tried to extend dictionary so it visits another class
> after something is added:
>
> class RegisterMap(dict):
> def __setitem__(self, k, v):
> dict.__setitem__(self, k,v)
> self[k]
"Almad" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> I discovered this behaviour in dictionary which I find confusing
...
> However, when constructing dictionary with dictionary in constructor
> like d = RegisterMap({'k':'v'}), __setitem__ is not called,
d.__setitem__
Mitja Trampus wrote:
...
> At least, I know it surprised me when I first met this behavior. Or is
> my reasoning incorrect?
Why len() doesn't call iteritems() ? :-)
Kidding apart for example it would be ok for __setitem__
to call either an internal "insert_new_item" or
"update_existing_item" de
Mitja Trampus wrote:
> I think what was unexpected for the OP is that dict.__init__
> does not use __setitem__ to create its internal structures.
you can implement most methods on core objects in terms of other
methods. picking one by random, and then complaining that other
methods don't use
Fredrik Lundh wrote:
> Almad wrote:
>
>> However, when constructing dictionary with dictionary in constructor
>> like d = RegisterMap({'k':'v'}), __setitem__ is not called
>
> why should it do that? dict() is a concrete implementation, not a
> template class for the creation of dict-like object
Almad wrote:
> However, when constructing dictionary with dictionary in constructor
> like d = RegisterMap({'k':'v'}), __setitem__ is not called
why should it do that? dict() is a concrete implementation, not a
template class for the creation of dict-like objects.
> Or should this be consider
Hello,
I discovered this behaviour in dictionary which I find confusing. In
SneakyLang, I've tried to extend dictionary so it visits another class
after something is added:
class RegisterMap(dict):
def __setitem__(self, k, v):
dict.__setitem__(self, k,v)
self[k].visit_register
Tim Peters <[EMAIL PROTECTED]> wrote:
[snip]
thanks for an exhaustively satisfying explanation!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
[Tim Peters]
>...
>> It has a much better chance of working from .pyc in Python 2.5.
>> Michael Hudson put considerable effort into figuring out whether the
>> platform uses a recognizable IEEE double storage format, and, if so,
>> marshal and pickle take different paths that preserve infinitie
Tim Peters <[EMAIL PROTECTED]> wrote:
...
> It has a much better chance of working from .pyc in Python 2.5.
> Michael Hudson put considerable effort into figuring out whether the
> platform uses a recognizable IEEE double storage format, and, if so,
> marshal and pickle take different paths that
[Peter Hansen]
>> I'm investigating a puzzling problem involving an attempt to
>> generate a constant containing an (IEEE 754) "infinity" value. (I
>> understand that special float values are a "platform-dependent
>> accident" etc...)
[also Peter]
> ...
> My guess about marshal was correct.
Yup.
Sybren Stuvel wrote:
> Peter Hansen enlightened us with:
>
>>I'm investigating a puzzling problem involving an attempt to
>>generate a constant containing an (IEEE 754) "infinity" value. (I
>>understand that special float values are a "platform-dependent
>>accident" etc...)
>
> Why aren't you si
I'm investigating a puzzling problem involving an attempt to generate a
constant containing an (IEEE 754) "infinity" value. (I understand that
special float values are a "platform-dependent accident" etc...)
The issue appears possibly to point to a bug in the Python compiler,
with it producing
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 127 matches
Mail list logo