Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Gregory Ewing
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

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread breamoreboy
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

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Erik
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

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Erik
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__.

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread breamoreboy
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__, > > __

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Ben Finney
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

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Gregory Ewing
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

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Erik
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

Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Ned Batchelder
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

Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread Erik
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

Re: inconsistency in converting from/to hex

2013-11-17 Thread Serhiy Storchaka
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')

Re: inconsistency in converting from/to hex

2013-11-17 Thread Mark Lawrence
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

Re: inconsistency in converting from/to hex

2013-11-16 Thread Steven D'Aprano
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

Re: inconsistency in converting from/to hex

2013-11-16 Thread Ned Batchelder
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

inconsistency in converting from/to hex

2013-11-16 Thread Laszlo Nagy
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()

Re: Inconsistency on getting arguments

2013-06-25 Thread Chris Angelico
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

Re: Inconsistency on getting arguments

2013-06-25 Thread Dave Angel
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

Re: Inconsistency on getting arguments

2013-06-25 Thread Peter Otten
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

Inconsistency on getting arguments

2013-06-25 Thread Marco Perniciaro
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

concurrent.futures inconsistency?

2012-08-24 Thread Mark Summerfield
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

Re: Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-26 Thread jeff
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. > > >

Re: Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-25 Thread Ben Finney
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

Re: Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-25 Thread jeff
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

Re: Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-25 Thread Heiko Wundram
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

Inconsistency between os.getgroups and os.system('groups') after os.setgroups()

2012-03-25 Thread jeff
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

Re: List comprehension/genexp inconsistency.

2012-03-21 Thread J. Cliff Dyer
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

Re: List comprehension/genexp inconsistency.

2012-03-20 Thread Steve Howell
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

Re: List comprehension/genexp inconsistency.

2012-03-20 Thread Ian Kelly
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

List comprehension/genexp inconsistency.

2012-03-20 Thread J. Cliff Dyer
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Steven D'Aprano
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,

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Terry Reedy
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Alex Willmer
(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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ian Kelly
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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) >>

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread MRAB
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Steven D'Aprano
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):

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ethan Furman
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

Re: Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread Ian Kelly
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

Inconsistency with split() - Script, OS, or Package Problem?

2011-05-09 Thread James Wright
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

Re: My stupidity / strange inconsistency overriding class methods

2011-04-20 Thread andrew cooke
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

Re: My stupidity / strange inconsistency overriding class methods

2011-04-20 Thread andrew cooke
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

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread Chris Rebert
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

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
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

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
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

My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
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

Re: Perceived inconsistency in py3k documentation

2010-12-08 Thread Steven D'Aprano
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

Re: Perceived inconsistency in py3k documentation

2010-12-07 Thread Steve Holden
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: >>

Re: Perceived inconsistency in py3k documentation

2010-12-06 Thread Antoine Pitrou
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

Re: Perceived inconsistency in py3k documentation

2010-12-05 Thread Terry Reedy
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

Re: Perceived inconsistency in py3k documentation

2010-12-05 Thread Peter Otten
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

Perceived inconsistency in py3k documentation

2010-12-05 Thread Greg
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

Re: Function closure inconsistency

2010-07-23 Thread Terry Reedy
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

Re: Function closure inconsistency

2010-07-23 Thread Dave Angel
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

Re: Function closure inconsistency

2010-07-23 Thread Benjamin Kaplan
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 >  

Function closure inconsistency

2010-07-23 Thread SeanMon
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()

Re: Inconsistency in the format docstring (2.7).

2010-07-21 Thread Terry Reedy
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('{}'.

Inconsistency in the format docstring (2.7).

2010-07-21 Thread jmfauth
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('{}'

Re: MySQLdb - weird formatting inconsistency

2010-04-24 Thread Anthra Norell
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

Re: MySQLdb - weird formatting inconsistency

2010-04-24 Thread John Nagle
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

Re: MySQLdb - weird formatting inconsistency

2010-04-24 Thread Sebastian Bassi
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/

MySQLdb - weird formatting inconsistency

2010-04-24 Thread Anthra Norell
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

Re: MRO inconsistency: why?

2008-10-08 Thread Michele Simionato
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

Re: MRO inconsistency: why?

2008-10-08 Thread Terry Reedy
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

Re: MRO inconsistency: why?

2008-10-08 Thread Christian Heimes
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

MRO inconsistency: why?

2008-10-08 Thread Ravi
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(

Re: Inconsistency in retrieving exceptions via sys module

2008-05-12 Thread Gabriel Genellina
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

Inconsistency in retrieving exceptions via sys module

2008-05-12 Thread Raj Bandyopadhyay
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

Re: Tokenizer inconsistency wrt to new lines in comments

2008-04-04 Thread George Sakkis
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

Re: Tokenizer inconsistency wrt to new lines in comments

2008-04-04 Thread Fredrik Lundh
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

Re: Tokenizer inconsistency wrt to new lines in comments

2008-04-04 Thread George Sakkis
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

Re: Tokenizer inconsistency wrt to new lines in comments

2008-04-04 Thread Kay Schluehr
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

Tokenizer inconsistency wrt to new lines in comments

2008-04-04 Thread George Sakkis
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

Re: argv[0] and __file__ inconsistency

2007-12-31 Thread Benjamin M. A'Lee
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

Re: argv[0] and __file__ inconsistency

2007-12-31 Thread Hai Vu
> use os.path.abspath Bingo! This is just what the doctor ordered. Thank you. Hai -- http://mail.python.org/mailman/listinfo/python-list

Re: argv[0] and __file__ inconsistency

2007-12-31 Thread John Machin
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

argv[0] and __file__ inconsistency

2007-12-31 Thread Hai Vu
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.

Re: Inconsistency in dictionary behaviour: dict(dict) not calling__setitem__

2006-12-14 Thread Terry Reedy
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

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-14 Thread Almad
Thanks to everybody for replies, I'm now satisfied ^_^ Almad -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Raymond Hettinger
[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]

Re: Inconsistency in dictionary behaviour: dict(dict) not calling__setitem__

2006-12-12 Thread Terry Reedy
"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__

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Andrea Griffini
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

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Fredrik Lundh
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

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Mitja Trampus
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

Re: Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Fredrik Lundh
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

Inconsistency in dictionary behaviour: dict(dict) not calling __setitem__

2006-12-12 Thread Almad
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

Re: Inconsistency producing constant for float "infinity"

2006-08-12 Thread Alex Martelli
Tim Peters <[EMAIL PROTECTED]> wrote: [snip] thanks for an exhaustively satisfying explanation! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistency producing constant for float "infinity"

2006-08-12 Thread Tim Peters
[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

Re: Inconsistency producing constant for float "infinity"

2006-08-12 Thread Alex Martelli
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

Re: Inconsistency producing constant for float "infinity"

2006-08-11 Thread Tim Peters
[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.

Re: Inconsistency producing constant for float "infinity"

2006-08-11 Thread Peter Hansen
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

Inconsistency producing constant for float "infinity"

2006-08-11 Thread 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...) The issue appears possibly to point to a bug in the Python compiler, with it producing

Re: Inconsistency of special class method lookup?

2006-03-11 Thread anne . nospam01
Thanks. -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >