Re: List of integers & L.I.S. (SPOILER)

2005-09-11 Thread Tim Peters
[Tim Peters, on the problem at http://spoj.sphere.pl/problems/SUPPER/ ] >> ... [EMAIL PROTECTED] > INCREDIBLE~ > 241433 2005-09-11 04:23:40 Tim Peters accepted 3.44 7096 PYTH > BRAVO! It's different now ;-) I added the two lines import psyco psyco.full() and

Re: List of integers & L.I.S. (SPOILER)

2005-09-11 Thread Tim Peters
[Tim Peters, on the problem at http://spoj.sphere.pl/problems/SUPPER/ ] >> Oh, it's not that bad . I took a stab at a Python program for >> this, and it passed (3.44 seconds). >> ... >> I didn't make any effort to speed this, beyond picking a reasonable &

Re: Builtin classes list, set, dict reimplemented via B-trees

2005-09-14 Thread Tim Peters
[EMAIL PROTECTED] > ... > I've gotten bored and went back to one of my other projects: > reimplementing the Python builtin classes list(), set(), dict(), > and frozenset() with balanced trees (specifically, counted B-trees > stored in memory). > > In short, this allows list lookup, insertion, delet

Re: Britney Spears nude

2005-09-15 Thread Tim Peters
[john basha] > send me the britney nude photos Because they're a new feature, you'll have to wait for Python 2.5 to be released. -- http://mail.python.org/mailman/listinfo/python-list

Re: Insane import behaviour and regrtest.py: heeelp

2005-02-06 Thread Tim Peters
[John J. Lee] > ... > I tried it, and I get the same results as before (the test modules from my > installed copy of Python are picked up instead of the local copies in > my CVS checkout's Lib/test, apparently entirely contrary to sys.path). Try running Python with -vv (that's two letter "v", not

Re: Insane import behaviour and regrtest.py: heeelp

2005-02-06 Thread Tim Peters
[John J. Lee] > I'm still puzzled, though. Reading the -vv output, I see that when > importing test_cookielib (which is currently the only line in my > regrtest.py -f file), Python doesn't appear to look in Lib/test to > find module "test.test_cookielib" (the actual string passed by > regrtest.py

Re: Hack with os.walk()

2005-02-12 Thread Tim Peters
[Frans Englich] ... > My problem, AFAICT, with using os.walk() the usual way, is that in order to > construct the /hierarchial/ XML document, I need to be aware of the directory > depth, and a recursive function handles that nicely; os.walk() simply > concentrates on figuring out paths to all files

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Tim Peters
[Ilias Lazaridis] ... > Let's see: > > The process would be: > > a) A Python Foundation official states: "of course we accept diversity > and of course we are intrested that our source-code-base compiles > directly with MinGW (and other compilers)". Well, I'm a Director of the Python Software Foun

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Tim Peters
[Tim Peters] >> Well, I'm a Director of the Python Software Foundation, and my view is >> "the more platforms the merrier". [Ilias Lazaridis] > I extract: "you are intrested, that the source-code-base compiles > directly with MinGW (and other compilers)"

Re: Whither datetime.date ?

2005-02-26 Thread Tim Peters
[Harald Hanche-Olsen] > I'm confused. I was going to try linkchecker, and it dies with a > traceback ending in > > File "/usr/local/lib/python2.4/calendar.py", line 32, in _localized_month >_months = [datetime.date(2001, i+1, 1).strftime for i in range(12)] > AttributeError: 'module' object h

Re: Regular Expressions: large amount of or's

2005-03-01 Thread Tim Peters
[André Søreng] > Given a string, I want to find all ocurrences of > certain predefined words in that string. Problem is, the list of > words that should be detected can be in the order of thousands. > > With the re module, this can be solved something like this: > > import re > > r = re.compile("wo

Re: Python 2.4 removes None data type?

2005-03-04 Thread Tim Peters
[EMAIL PROTECTED] > I just read in the 'What's New in Python 2.4' document that the None > data type was converted to a constant: > http://python.org/doc/2.4/whatsnew/node15.html > > """ > # None is now a constant; code that binds a new value to the name > "None" is now a syntax error. > """ > > S

Re: Licensing Python code under the Python license

2005-03-11 Thread Tim Peters
[Daniel Keep] > I'm currently working on a Python program, and was wondering if it's > possible to license the program, some associated tools, and a few other > libraries I've written under the Python license. > > I had a look at the new PSF Python license on the list of OSI-approved > licenses, bu

Re: date diff calc

2004-11-29 Thread Tim Peters
[Skip Montanaro] > ... > The datetime.date object already exposes a strftime method for > generating a formatted string output and will create date objects > from both time.time() output (fromtimestamp) and "proleptic > Gregorian ordinal"s (fromordinal). Looking at the datetime module > docs, it's

Re: Struggling with struct.unpack() and "p" format specifier

2004-11-30 Thread Tim Peters
[Geoffrey <[EMAIL PROTECTED]>] > I am trying to read data from a file binary file and then unpack the > data into python variables. Some of the data is store like this; > > xbuffer: '\x00\x00\xb9\x02\x13EXCLUDE_CREDIT_CARD' > # the above was printed using repr(xbuffer). > # Note that int(0x13) =

Re: date diff calc

2004-11-30 Thread Tim Peters
[Skip Montanaro] >>> I think inputs from strings would be much more common. [Tim Peters] >> Me too, although it's a bottomless pit. >> >> guess-6-intended-meanings-for-1/2/3-before-breakfast-ly y'rs [Peter Hansen] > I think Skip was intending that the for

Re: Python 3000 and "Python Regrets"

2004-12-01 Thread Tim Peters
[EMAIL PROTECTED] > I just came across the slides for Guido van Rossum's "Python > Regrets" talk, given in 2002. It worries me that much of my Python > code would be broken if all of his ideas were implemented. Actually, none of it would break, provided you don't change the Python implementation y

Re: access to generator state

2004-12-02 Thread Tim Peters
[Neal D. Becker] > ... > Only one problem. Is there any way to access the state of a > generator externally? In other words, the generator saves all it's > local variables. Can an unrelated object then query the values of > those variables? (In this case, to get at intermediate results) It's

Re: assymetry between a == b and a.__eq__(b)

2004-12-04 Thread Tim Peters
[Mel Wilson] > :) Seems to: > > > Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> class Eq(object): > ... def __eq__(self, other): > ... return True > ... > >>> class Neq(Eq

Re: [BUG] IMO, but no opinions? Uncle Tim? was: int(float(sys.maxint)) buglet ?

2004-12-06 Thread Tim Peters
[Bengt Richter] > Peculiar boundary cases: > > >>> 2.0**31-1.0 > 2147483647.0 > >>> int(2147483647.0) > 2147483647L > >>> int(2147483647L ) > 2147483647 > >>> > >>> -2.0**31 > -2147483648.0 > >>> int(-2147483648.0) > -2147483648L > >>> int(-2147483648L ) > -2147483648 > > some kind of one-off err

Re: Ptyon 2.3.5 probably coming in January; get your bugs/patches reported!

2004-12-06 Thread Tim Peters
[Brett C] >> Anthony Baxter, our ever-diligent release manager, mentioned this past week >> that Python 2.3.5 will most likely come to fruition some time in January >> (this is not guaranteed date). [Roy Smith] > Interesting. Does that mean that 2.3 and 2.4 will be maintained in > parallel for a

Re: [BUG] IMO, but no opinions? Uncle Tim? was: int(float(sys.maxint)) buglet ?

2004-12-07 Thread Tim Peters
[Tim Peters] >> ... there's no promise anywhere, e.g., that Python will return an int >> whenever it's physically possible to do so. [Bengt Richter] > Ok, I understand the expediency of that policy, but what is now the meaning > of int, in that case? Is it now just a v

Re: Python 2.3.5 ?

2004-12-07 Thread Tim Peters
[Luis M. Gonzalez] > I'm confussed... > Python 2.4 (final) hs been released a few days ago, but now I > see that Python 2.3.5 is being worked on. > Why? What does it mean? Just that enough volunteers exist interested in producing another bugfix release for the 2.3 line. It will probably be the la

Re: memoize factorial example (was Re: decorators ?)

2004-12-07 Thread Tim Peters
[Daniel 'Dang' Griffith] >> But the factorial example on the wiki has a defect. It incorrectly >> calculates factorial(0) as 0, when it should be 1. [Terry Reedy] > This is a matter of definition, and definitions apparently differ. > fact(0) == 0 is a backward projection from the definition f(1)

Re: results of division

2004-12-09 Thread Tim Peters
[Paul McGuire] ... > >>> print "%.2f" % 1.775 > 1.77 > > Hmmm, if we rounded, I would have expected 1.775 to round up > to 1.78. Platform-dependent. 1.775 isn't exactly representable regardless, but whether exactly-half-way numbers that are exactly representable round up or truncate varies across

Re: thread/queue bug

2004-12-11 Thread Tim Peters
[Peter Otten] > What I believe to be a minimal example: > > > import Queue > import threading > import time > > q = Queue.Queue(4) > > def proc(): >while True: >q.get(1) >Queue.Queue() >print "YADDA" > > threading.Thread(target=proc).start() > > while True: >pri

Re: thread/queue bug

2004-12-13 Thread Tim Peters
[Antoon Pardon] > I don't see why starting a thread as a side effect of importing is > bad thread practice. Sure python doesn't cater for it, but IMO > that seems to be python failing. Obviously, it's bad practice in Python because it can lead to deadlocks in Python. It's nearly tautological. Im

Re: Efficient grep using Python?

2004-12-15 Thread Tim Peters
["sf" <[EMAIL PROTECTED]>] >> I have files A, and B each containing say 100,000 lines (each >> line=one string without any space) >> >> I want to do >> >> " A - (A intersection B) " >> >> Essentially, want to do efficient grep, i..e from A remove those >> lines which are also present in file B.

Re: Efficient grep using Python?

2004-12-15 Thread Tim Peters
[Fredrik Lundh] >>> bdict = dict.fromkeys(open(bfile).readlines()) >>> >>> for line in open(afile): >>>if line not in bdict: >>>print line, >>> >>> [Tim Peters] >> Note that an open file is an iterable object, yi

Re: Efficient grep using Python?

2004-12-15 Thread Tim Peters
[Jane Austine] > fromkeys(open(f).readlines()) and fromkeys(open(f)) seem to be > equivalent. Semantically, yes; pragmatically, no, in the way explained before. > When I pass an iterator instance(or a generator iterator) to the > dict.fromkeys, it is expanded at that moment, I don't know what "e

Re: os.walk bug?

2004-12-16 Thread Tim Peters
[Gabriel Cosentino de Barros] ... > for root, dirs, files in os.walk('t:\'): > # -- do stuff > print "working on", root > # -- stuff done > > print 'DEBUG: dirs =', dirs > for d in dirs: > # -- remove archive >

Re: os.walk bug?

2004-12-16 Thread Tim Peters
[Adam DePrince] > Each iteration of os.walk returns three parameters; one of those, > dirs, is a list of directories within the current directory pointed at > by root. Right. > Am I correct to assume that you beleve that by changing the > contents of dir you will affect how os.walk traverses the

Re: expression form of one-to-many dict?

2004-12-17 Thread Tim Peters
[Steven Bethard] > So I end up writing code like this a fair bit: > > map = {} > for key, value in sequence: > map.setdefault(key, []).append(value) > > This code basically constructs a one-to-many mapping -- each > value that a key occurs with is stored in the list for that key. > > This code'

Re: A rational proposal

2004-12-18 Thread Tim Peters
[Jp Calderone] ... > The Decimal type seems to define min and max so that NaNs > can be treated specially, but I glean this understanding from only > a moment of reading decimal.py. Perhaps someone more well > informed can declare definitively the purpose of these methods. To conform to the sema

Re: Boo who? (was Re: newbie question)

2004-12-20 Thread Tim Peters
[Doug Holton] ... > But I will not be intimidated by the likes of Fredrik Lundh. Trollers > will be held accountable. Doug, Doug, Doug. Fredrik isn't a troll. He's a Swede. Trolls are Norwegian. Lighten up, please. Fredrik is usually terse, and sometimes curt (although Americans seem to have

Re: Should I always call PyErr_Clear() when an exception occurs?

2004-12-20 Thread Tim Peters
[Jaime Wyant] > I've found that the code below will crash if I don't have the > PyErr_Clear() function call. Should I always call PyErr_Clear()? That's not the right approach. Nearly all Python C API calls can fail. They return a special value if they do, primarily NULL for a call that returns

Re: trouble building python2.4

2004-12-22 Thread Tim Peters
[Matthew Thorley] >> I have got to be the stupidest person on the face of the planet. [Steve Holden] > I'll have you know I don't welcome newcomers to this newsgroup > trying to steal my hard-won reputation, if you don't mind. In all fairness, Matthew did present evidence to support his claim. F

Re: test

2004-12-23 Thread Tim Peters
[Per Erik Stendahl <[EMAIL PROTECTED]>] > sdfdsafasd Generally speaking, yes, but not if you're concerned about Pythons before 1.5.2 too. If you are, a reasonable workaround is: try: sdfdsafasd except NameError: pass else: True = None is None and 1 != 2 False = None is not None o

Re: Bug in threading.Thread.join() ?

2005-03-25 Thread Tim Peters
[Peter Hansen] > I'm still trying to understand the behaviour that I'm > seeing but I'm already pretty sure that it's either > a bug, or something that would be considered a bug if > it didn't perhaps avoid even worse behaviour. > > Inside the join() method of threading.Thread objects, > a Conditio

Re: math - need divisors algorithm

2005-03-30 Thread Tim Peters
[Philp Smith] > Does anyone have suggested code for a compact, efficient, elegant, most of > all pythonic routine to produce a list of all the proper divisors of an > integer (given a list of prime factors/powers) If the canonical factorization of N is the product of p_i**e_i, the number of diviso

Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Tim Peters
[Aahz] >> "The joy of coding Python should be in seeing short, concise, readable >> classes that express a lot of action in a small amount of clear code -- >> not in reams of trivial code that bores the reader to death." --GvR [Sunnan] > Can anyone please point me to the text that quote was taken

Re: Simple thread-safe counter?

2005-04-01 Thread Tim Peters
[Paul Rubin] > I'd like to have a function (or other callable object) that returns > 0, 1, 2, etc. on repeated calls. That is: > >print f() # prints 0 >print f() # prints 1 >print f() # prints 2 ># etc. > > There should never be any possibility of any number getting returned

Re: Simple thread-safe counter?

2005-04-02 Thread Tim Peters
[Paul Rubin] > I'm starting to believe the GIL covers up an awful lot of sloppiness > in Python. The GIL is highly exploitable, and much of CPython does exploit it. If you don't want to exploit it, that's fine: there was always an obvious approach using an explicit mutex here, and the only thing

Re: IronPython 0.7 released!

2005-04-05 Thread Tim Peters
[Thomas Gagne] > Does the Python community think Microsoft's embrace is a good or bad thing? All things in this world unfold exactly according to Guido's secret Master Plan. So it depends on whether you think Guido is good or bad. Members of the Python community are required to think Guido is go

Re: sorting a list and counting interchanges

2005-04-06 Thread Tim Peters
[RickMuller] > I have to sort a list, but in addition to the sorting, I need to > compute a phase factor that is +1 if there is an even number of > interchanges in the sort, and -1 if there is an odd number of > interchanges. So you want the parity ("sign") of the associated permutation. > I coul

Re: sorting a list and counting interchanges

2005-04-07 Thread Tim Peters
[Paul Rubin] > Writing a sorting function from scratch for this purpose seems like > reinventing the wheel. Yup! list.sort() is going to be mounds faster. > Tim's answer of simply counting the cycles (without having to pay > attention to their length) is really clever. I didn't realize you coul

Re: struct enhancements?

2005-04-07 Thread Tim Peters
[EMAIL PROTECTED] > I would like to be able to pack/unpack 8-byte longs, ... Have you tried struct's 'q' or 'Q' format codes? -- http://mail.python.org/mailman/listinfo/python-list

Re: Positions of regexp groups

2005-04-08 Thread Tim Peters
[Magnus Lie Hetland] > Just a quick question: Does anyone have a simple way of finding the > positions (start, end) of the groups in a regexp match? AFAICS, the re > API can only return the contents...? Read the docs for match objects, esp. the start(), end(), and span() methods. -- http://mail.p

Re: Python 2.4 killing commercial Windows Python development ?

2005-04-11 Thread Tim Peters
[Michael Kearns] > ... > Also, I don't believe that just 'owning' MSVC 7.1 is enough. From > cursory glances at the various redist files, I would also have to ship > the EULA, and as an end-user (of python) I can't just redistribute the > files - perhaps I could write a place holder application in

Re: Proposal: an unchanging URL for Python documentation

2005-04-18 Thread Tim Peters
[Steve] > I have a suggestion/request that will, I think, improve the Python > documentation. > > Currently, the Python documentation in HTML format is stored at URLs > that change with each new release of Python. That is, for example, the > documentation for the os module is at > http://python.or

Re: How to run Python in Windows w/o popping a DOS box?

2005-04-19 Thread Tim Peters
[Paul Rubin] > Dumb question from a Windows ignoramus: > > I find myself needing to write a Python app (call it myapp.py) that > uses tkinter, which as it happens has to be used under (ugh) Windows. > That's Windows XP if it makes any difference. Nope, the Windows flavor doesn't matter. > I put a

Re: time.strftime in 2.4.1 claims data out of range when not

2005-04-22 Thread Tim Peters
[Sheila King] > I have a web app that has been running just fine for several months under > Python 2.2.2. > > We are preparing to upgrade the server to run Python 2.4.1. > > However, part of my web app is throwing an error on this code (that has > previously worked without exception): > > >>> time.

Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Tim Peters
[Mike Rovner] > 3 IS wrong because if you use any not BIG letter after bodyguard on both > sides, you get extra 'eCQQmSXK\n' which slow me down for 5 minutes. Get rid of the newlines first. On level 7, I'm not sure whether there's something more to do, or whether I'm looking at a bug in how IE di

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Tim Peters
> I was trying to find out how arithmetic on aware datetimes is "supposed > to" work, and tested with pytz. When I posted asking why it behaves this > way I was told that pytz doesn't behave correctly according to the way > the API was designed. You were told (by me) that its implementation of tzi

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Tim Peters
[] > My context is that I am working on an idea to include utc offsets in > datetime objects (or on a similar object in a new module), as an > alternative to something like a "fold" attribute. and since "classic > arithmetic" is apparently so important, Love it or hate it, it's flatly impossible t

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Tim Peters
>>> If there are not, maybe the intended semantics should go >> > by the wayside and be replaced by what pytz does. >> Changing anything about default arithmetic behavior is not a >> possibility. This has been beaten to death multiple times on this >> mailing list already, and I'm not volunteerin

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Tim Peters
[Guido] >> Those pytz methods work for any (pytz) timezone -- astimezone() with a >> default argument only works for the local time zone. {Alex] > That's what os.environ['TZ'] = zonename is for. The astimezone() method > works for every timezone installed on your system. Try it - you won't even

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Tim Peters
[Tim] >> Me too - except I think acceptance of 495 should be contingent upon >> someone first completing a fully functional (if not releasable) >> fold-aware zoneinfo wrapping. [Alex] > Good idea. How far are you from completing that? In my head, it was done last week ;-) In real life, I'm runn

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Tim Peters
[Alex] >>> I will try to create a zoneinfo wrapping prototype as well, but I will >>> probably "cheat" and build it on top of pytz. [Tim] >> It would be crazy not to ;-) Note that Stuart got to punt on "the >> hard part": .utcoffset(), since pytz only uses fixed-offset classes. >> For a prototy

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread Tim Peters
[Alex] >>I will try to create a zoneinfo wrapping prototype as well, but I will >>probably "cheat" and build it on top of pytz. [Laura Creighton] > My question, is whether it will handle Creighton, Saskatchewan, Canada? > Creighton is an odd little place. Like all of Saskatchewan, it is > in the

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread Tim Peters
[Tim] >> Hi, Laura! By "zoneinfo" here, we mean the IANA (aka "Olson") time >> zone database, which is ubiquitous on (at least) Linux: >> >>https://www.iana.org/time-zones >> >>So "will a wrapping of zoneinfo handle XYZ?" isn't so much a question >>about the wrapping as about what's in the IAN

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread Tim Peters
[Laura] >>> But I am not sure how it is that a poor soul who just wants to print a >>> railway schedule 'in local time' is supposed to know that Creighton is >>> using Winnipeg time. [Tim] >> I'm not sure how that poor soul would get a railway schedule >> manipulable in Python to begin with ;-) [

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread Tim Peters
[Tim] >> Whatever time zone the traveler's railroad schedule uses, so long as >> it sticks to just one [Laura] > This is what does not happen. Which is why I have written a python > app to perform conversions for my parents, in the past. So how did they get the right time zone rules for Creighto

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread Tim Peters
[Guido] > Wouldn't it be sufficient for people in Creighton to set their timezone to > US/Central? IIUC the Canadian DST rules are the same as the US ones. Now, > the question may remain how do people know what to set their timezone to. > But neither pytz nor datetime can help with that -- it is up

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Tim] >> pytz solves it by _never_ creating a hybrid tzinfo. It only uses >> eternally-fixed-offset tzinfos. For example, for a conceptual zone >> with two possible total UTC offsets (one for "daylight", one for >> "standard"), there two distinct eternally-fixed-offset tzinfo objects >> in pytz.

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Guido] >> Wouldn't it be sufficient for people in Creighton to set their timezone to >> US/Central? IIUC the Canadian DST rules are the same as the US ones. Now, >> the question may remain how do people know what to set their timezone to. >> But neither pytz nor datetime can help with that -- it i

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Tim] >> So, on your own machine, whenever daylight time starts or ends, you >> manually change your TZ environment variable to specify the newly >> appropriate eternally-fixed-offset zone? Of course not. [Random832 ] > No, but the hybrid zone isn't what gets attached to the individual > struct t

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Tim] >> It would be nice to have! .utcoffset() is an expensive operation >> as-is, and being able to rely on tm_gmtoff would make that dirt-cheap >> instead. [Alex] > If it is just a question of optimization, Yes. If it's more than just that, then 495 doesn't actually solve the problem of get

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Random832 ] Whether or not datetimes stored tm_gmtoff and tm_zone workalikes has no effect on semantics I can see. If, in your view, they're purely an optimization, they're just a distraction for now. If you're proposing to add them _instead_ of adding `fold`, no, that can't work, for the pick

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Tim] >> It depends on how expensive .utcoffset() >> is, which in turn depends on how the tzinfo author implements it. [Alex] > No, it does not. In most time zones, UTC offset in seconds can be computed > by C code as a 4-byte integer Which is a specific implementation of .utcoffset(). Which li

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Random832 ] > A) I'm still not sure why, but I was talking about adding an int, not a > timedelta and a string. > > B) Older python versions can't make use of either utcoffset or fold, but > can ignore either of them. I don't even see why they couldn't ignore a > timedelta and a string if we felt

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Tim] >> Because all versions of Python expect a very specific pickle layout >> for _every_ kind of pickled object (including datetimes).. Make any >> change to the pickle format of any object, and older Pythons will >> simply blow up (raise an exception) when trying to load the new pickle >> - or

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Random832 ] > Would allowing a 16-byte string in the future have increased the storage > occupied by a 10-byte string today? Would allowing a third argument in > the future have increased the storage occupied by two arguments today? > As far as I can tell the pickle format for non-primitive types

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Tim Peters
[Tim] >> Sorry, I'm not arguing about this any more. Pickle doesn't work at >> all at the level of "count of bytes followed by a string". [Random832 ] > The SHORT_BINBYTES opcode consists of the byte b'C', followed by *yes > indeed* "count of bytes followed by a string". Yes, some individual opc

Re: Comparing dictionaries, is this valid Python?

2005-12-13 Thread Tim Peters
[François Pinard] ... > Would someone know where I could find a confirmation that comparing > dictionaries with `==' has the meaning one would expect (even this is > debatable!), that is, same set of keys, and for each key, same values? Yes, look here : it has the meaning you expect, provided tha

Re: Why and how "there is only one way to do something"?

2005-12-15 Thread Tim Peters
[Steve Holden, to bonono] > ... > I believe I have also suggested that the phrases of the Zen aren't to be > taken too literally. Heretic. > You seem to distinguish between "obvious" meaning "obvious to Steve > but not necessarily to me" and "really obvious" meaning "obvious to both > Steve and m

Re: Next floating point number

2005-12-17 Thread Tim Peters
[Steven D'Aprano] > I'm looking for some way to get the next floating point number after any > particular float. ... > According to the IEEE standard, there should be a routine like next(x,y) > which returns the next float starting from x in the direction of y. > > Unless I have missed something, P

Re: doctest fails to NORMALIZE_WHITESPACE ?

2005-12-17 Thread Tim Peters
[David MacKay] > Hello, I'm a python-list newbie. I've got a question about doctest; perhaps > a bug report. As things will turn out, it's just a question. That's common for newbies :-) > I really like doctest, but sometimes doctest gives a failure when the output > looks absolutely fine to me -

Re: doctest fails to NORMALIZE_WHITESPACE ?

2005-12-17 Thread Tim Peters
[David MacKay, having fun with doctest] ... > I've got a follow-up question motivated by my ugly backslash continuations. [Tim] >> When Python doesn't "look clean", it's not Python -- and backslash >> continuation & semicolons often look like dirt to the experienced >> Python's eye. > The reason

Re: Next floating point number

2005-12-18 Thread Tim Peters
[Bengt Richter] > I wonder if frexp is always available, Yes, `frexp` is a standard C89 libm function. Python's `math` doesn't contain any platform-specific functions. ... > The math module could also expose an efficient multiply by a power > of two using FSCALE if the pentium FPU is there. `l

Re: Next floating point number

2005-12-18 Thread Tim Peters
[Steven D'Aprano] > ... > Will Python always use 64-bit floats? A CPython "float" is whatever the platform C compiler means by "double". The C standard doesn't define the size of a double, so neither does Python define the size of a float. That said, I don't know of any Python platform to date w

Re: Guido at Google

2005-12-22 Thread Tim Peters
[EMAIL PROTECTED] > ... > What about the copyright in CPython ? Can I someone take the codebase > and make modifications then call it Sneak ? Of course they _could_ do that, and even without making modifications beyond the name change. If you want to know whether it's legal, that's a different q

Re: Guido at Google

2005-12-22 Thread Tim Peters
[Greg Stein] >>> Guido would acknowledge a query, but never announce it. That's not his >>> style. He's been very low-key about it, but did make an informal announcement on the PSF-Members mailing list. >>> This should have a positive impact on Python. His job description has a >>> *very* signifi

Re: How to get started in GUI Programming?

2005-12-23 Thread Tim Peters
[D H] > ... > Doesn't the python community already have enough assholes as it is? The Python Software Foundation may well wish to fund a study on that. Write a proposal! My wild-ass guess is that, same as most other Open Source communities, we average about one asshole per member. I'd love to p

Re: sorting with expensive compares?

2005-12-23 Thread Tim Peters
[Steven D'Aprano] > ... > As others have pointed out, Python's sort never compares the same objects > more than once. Others have pointed it out, and it's getting repeated now, but it's not true. Since I wrote Python's sorting implementation, it's conceivable that I'm not just making this up ;-)

Re: How to signal "not implemented yet"?

2005-12-25 Thread Tim Peters
[Roy Smith] > Is there some standard way to signal "not implemented yet" in > unfinished code? raise NotImplementedError That's a builtin exception. ... -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-25 Thread Tim Peters
Over at http://spoj.sphere.pl/problems/SIZECON/ the task is to come up with the shortest program that solves a different problem. There's a twist in this one: Score equals to size of source code of your program except symbols with ASCII code <= 32. So blanks, newlines and tabs aren

Re: build curiosities of svn head (on WinXP)

2005-12-26 Thread Tim Peters
[David Murmann] ... >> second, the build order in "pcbuild.sln" for elementtree seems to be >> wrong, nant tried to build elementtree before pythoncore (which failed). >> i fixed this by building elementtree separately. [Steve Holden] > Yes, the elementtree module is a new arrival for 3.5, so the

Re: python coding contest

2005-12-28 Thread Tim Peters
[Bengt Richter] > ... > [23:28] C:\pywk\clp\seven\pycontest_01>wc -lc seven_seg.py > 2136 seven_seg.py > > 2 lines, 136 chars including unix-style lineseps (is that cheating on > windows?) Na. Most native Windows apps (including native Windows Python) don't care whether \n or

Re: using NamedTemporaryFile on windows

2005-12-29 Thread Tim Peters
[Peter Hansen] >>> What I don't understand is why you _can't_ reopen the NamedTemporaryFile >>> under Windows when you can reopen the file created by mkstemp (and the >>> files created by TemporaryFile are created by mkstemp in the first place). [Lee Harr] >> Are you saying you tried it and you ac

Re: csrss.exe & Numeric

2005-12-30 Thread Tim Peters
[jelle] > I have a function that uses the Numeric module. When I launch the > function csrss.exe consumes 60 / 70 % cpu power rather than having > python / Numeric run at full speed. Has anyone encountered this problem > before? It seriously messes up my Numeric performance. > > I'm running 2.4.2 o

Re: Occasional OSError: [Errno 13] Permission denied on Windows

2006-01-05 Thread Tim Peters
[Alec Wysoker] > Using Python 2.3.5 on Windows XP, I occasionally get OSError: [Errno > 13] Permission denied when calling os.remove(). This can occur with a > file that is not used by any other process on the machine, How do you know that? > and is created by the python.exe invocation that is t

Re: Does Python allow access to some of the implementation details?

2006-01-06 Thread Tim Peters
[Claudio Grondi] > Let's consider a test source code given at the very end of this posting. > > The question is if Python allows somehow access to the bytes of the > representation of a long integer or integer in computers memory? CPython does not expose its internal representation of longs at the

Re: Newline at EOF Removal

2006-01-09 Thread Tim Peters
[Bengt Richter] > ... > [1] BTW, I didn't see the 't' mode in > http://docs.python.org/lib/built-in-funcs.html > description of open/file, but I have a nagging doubt about saying it's not > valid. > Where did you see it? 't' is a Windows-specific extension to standard C's file modes. Python pas

Re: testing units in a specific order?

2006-01-09 Thread Tim Peters
[Antoon Pardon] > I have used unit tests now for a number of project. One thing > that I dislike is it that the order in which the tests are done > bears no relationship to the order they appear in the source. > > This makes using unit tests somewhat cumbersome. Is there some > way to forc

Re: Do you have real-world use cases for map's None fill-in feature?

2006-01-10 Thread Tim Peters
[Raymond Hettinger] > ... > I scanned the docs for Haskell, SML, and Perl and found that the norm > for map() and zip() is to truncate to the shortest input or raise an > exception for unequal input lengths. > ... > Also, I'm curious as to whether someone has seen a zip fill-in feature > employed t

Re: testing units in a specific order?

2006-01-10 Thread Tim Peters
[Antoon Pardon] > Well maybe unit tests shouldn't care (Thats what I think you meant), Yup! > I care. Some methods are vital for the functionality of other methods. > So it the test for the first method fails it is very likely a number of > other methods will fail too. However I'm not interrested

Re: atexit + threads = bug?

2006-01-12 Thread Tim Peters
[David Rushby] > Consider the following program (underscores are used to force > indentation): > > import atexit, threading, time > > def atExitFunc(): > print 'atExitFunc called.' > > atexit.register(atExitFunc) > > class T(threading.Thread): >

Re: atexit + threads = bug?

2006-01-12 Thread Tim Peters
[David Rushby] > ... > I understand your explanation and can live with the consequences, but > the atexit docs sure don't prepare the reader for this. In fact, they don't mention threading.py at all. > They say, "Functions thus registered are automatically executed upon > normal interpreter termi

Re: Why is there no post-pre increment operator in python

2006-01-12 Thread Tim Peters
[EMAIL PROTECTED] > Anyone has any idea on why is there no post/pre increment operators in > python ? Maybe because Python doesn't aim at being a cryptic portable assembly language? That's my guess ;-) > Although the statement: > ++j > works but does nothing That depends on the type of j, and h

<    1   2   3   4   >