Re: Can global variable be passed into Python function?

2014-02-28 Thread Gregory Ewing
Mark H. Harris wrote: if (n**2 D(1)): a = __atan__(n) elif (n == D(1)): a = gpi/4 elif (n == D(-1)): a = -(gpi/4) elif (n D(-1)): a = __atan__Lt_neg1__(n) else: a = __atan__Gt_1__(n) That's not a candidate for a switch statement,

Re: posting code snippets

2014-03-01 Thread Gregory Ewing
Grant Edwards wrote: You drag out the lab scope, logic analyzer, spectrum analyzer, sweep generator, strip plotter, and the machine that goes ping. You start to get everything set up to nail that problem securely to the dissecting board. Long before you actually get to that point, the problem

Re: Functional programming

2014-03-03 Thread Gregory Ewing
Steven D'Aprano wrote: Given that x is an integer, and that you add 1 (also an integer) to it, is it really necessary to tell the compiler that add_one returns an integer? What else could the output type be? Just because the compiler *can* infer the return type doesn't necessarily mean it

Re: Working with the set of real numbers

2014-03-04 Thread Gregory Ewing
Chris Angelico wrote: In constant space, that will produce the sum of two infinite sequences of digits. It's not constant space, because the nines counter can grow infinitely large. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional programming

2014-03-04 Thread Gregory Ewing
Marko Rauhamaa wrote: Python doesn't have anonymous inner classes, but it has named inner classes, and that's quite sufficient. I would say it's Python's closures that make up for not having Java's inner classes. Or to put it another way, inner classes are Java's kludgy way of working around

Re: Proper conversion of timestamp

2014-03-04 Thread Gregory Ewing
Igor Korot wrote: What I have is a timestamp which reads: 1289410678L. Trying to convert this into the datetime object in Python using: import datetime datetime.datetime.fromtimestamp( stamp ) produces the error: timestamp out of range for platform localtime()/gmtime() function. Divide the

Re: Tuples and immutability

2014-03-07 Thread Gregory Ewing
Duncan Booth wrote: Is there any reason why tuples need to throw an exception on assigning to the element if the old value and new value are the same object? It would make introspection misleading, because tuples would have a __setitem__ method event though they don't actually support item

Re: Tuples and immutability

2014-03-08 Thread Gregory Ewing
Ian Kelly wrote: class LessThanFilter: def __init__(self, the_list): self._the_list = the_list def __getitem__(self, bound): return [x for x in self._the_list if x bound] filter = LessThanFilter([10, 20, 30, 40, 50]) filter[25] += [15, 17, 23] Should that last line

Re: Tuples and immutability

2014-03-08 Thread Gregory Ewing
Ian Kelly wrote: I already mentioned this earlier in the thread, but a balanced binary tree might implement += as node insertion and then return a different object if the balancing causes the root node to change. That would be a really bad way to design a binary tree implementation. What if

Re: Tuples and immutability

2014-03-09 Thread Gregory Ewing
Ian Kelly wrote: In my view the second one is wrong. a += b should be understood as being equivalent to a = a + b, but with the *possible* and by no means guaranteed optimization that the operation may be performed in-place. This interpretation is at odds with the Language Reference, section

Re: Tuples and immutability

2014-03-10 Thread Gregory Ewing
Ian Kelly wrote: It's technically possible for this augmented assignment to be performed in place: x = 12 x += 4 But it's not done in-place, because ints are meant to be immutable. Which means it's *not* possible, because doing so would violate the documented properties of the int type. In

Re: Tuples and immutability

2014-03-10 Thread Gregory Ewing
Ian Kelly wrote: If the in-place behavior of += is held to be part of the interface, then we must accept that += is not polymorphic across mutable and immutable types, That's quite correct, it's not. As I said, it's one notation doing double duty. Usually there isn't any confusion, because

Re: Tuples and immutability

2014-03-11 Thread Gregory Ewing
Steven D'Aprano wrote: On Tue, 11 Mar 2014 04:39:39 -0600, Ian Kelly wrote: On Mon, Mar 10, 2014 at 11:03 PM, Gregory Ewing What's the obvious way to spell in-place set intersection, for example? I would expect it to be =, That's my point -- once you know the binary operator

Re: which async framework?

2014-03-11 Thread Gregory Ewing
Sturla Molden wrote: Another thing is that co-routines and yield from statements just makes it hard to follow the logic of the program. I still have to convince myself that a library for transforming epoll function calls into co-routines is actually useful. It's not epoll function calls that

Re: Question about Source Control

2014-03-18 Thread Gregory Ewing
Frank Millman wrote: These are the kind of stumbling blocks that prevented me from succeeding in my previous attempt. I have a vague recollection that I set it up on machine A, but then hit a problem because machines B and C both accessed the same directory, but with different names For

Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Gregory Ewing
Haralanov, Mitko wrote: I am using Python to read from a binary device file which requires that all read sizes are in 8byte multiples and the user's buffer is 8byte aligned. Is there a way that I can get file.read() to use an 8byte aligned buffer? For control at that level you'd be better off

Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Gregory Ewing
Haralanov, Mitko wrote: The problem is not controlling the number of bytes read. That part seems to be working. The issue is that the buffer into which the data is placed needs to be of certain alignment (8byte-aligned). Python does not seem to have a way that allows me to control that. Hmmm,

Re: Question about Source Control

2014-03-20 Thread Gregory Ewing
Chris Angelico wrote: You can then offer a non-source-control means of downloading that specific revision. Just keep in mind the downside that you can't then push or pull your changes directly back into the main repository. You can generate a patch file for the project maintainer to apply,

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-21 Thread Gregory Ewing
Rustom Mody wrote: A 'for' introduces a scope: No, it doesn't! x = 42 for x in [1,2,3]: ... print x ... 1 2 3 No sign of the 42 --v ie the outer x -- inside because of scope You're right that there's no sign of the 42, but it's *not* because of scope, as you'll see if you do one

Re: Github down?

2014-03-22 Thread Gregory Ewing
Dan Sommers wrote: On Fri, 21 Mar 2014 14:51:54 +0100, Chris “Kwpolska” Warrick wrote: (though GitHub could qualify as social media for some…) +1 QOTW https://xkcd.com/624/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-25 Thread Gregory Ewing
Roy Smith wrote: Doors that open automatically as you approach them are now routine. Star Trek doors seem to be a bit smarter, though. Captain Kirk never had to stop in front of a door and wait for it to sluggishly slide open. Also the doors never open when you're just walking past and not

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-25 Thread Gregory Ewing
Rustom Mody wrote: ÷ for some reason seems inappropriate (some vague recollection that its an only English; Europeans dont use it??) To me it's something you learn in primary school and then grow out of when you start doing real mathematics. The / is actually a better approximation of what

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-25 Thread Gregory Ewing
Chris Angelico wrote: But you can't do the same for braces. You'd have to eschew *both* literal-ish notations and use explicit constructors everywhere. Not clean. This could have been dealt with by giving Python 2.7 a from __future__ import braces_mean_sets option or something like that. But

Re: Time we switched to unicode? (was Explanation of this Python language feature?)

2014-03-25 Thread Gregory Ewing
Chris Angelico wrote: Hey look, we have a rogue AI... CONSOLE!... Except that any rogue AI who's at all serious about the matter would take care of that little loophole at an early stage. Open the pod bay doors, HAL. I'm afraid I can't do that, Dave. CONSOLE! Sorry, Dave. Nice try, but

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Gregory Ewing
Chris Angelico wrote: By showing those last ones as 1̅.091... and 2̅.091..., you emphasize the floating-point nature of the data: everything after the decimal is the mantissa, and everything before the decimal is the exponent. The reason for writing them that way is so that you can look the

Re: unicode as valid naming symbols

2014-03-27 Thread Gregory Ewing
Mark H Harris wrote: Good ol infix -- x+y.. prefix (with paren) -- foo(x) prefix without -- ¬ x In case you thought alphanumerics had parens -- sin x Then theres postfix -- n! Inside fix -- nCr (Or if you prefer ⁿCᵣ ??) And outside fix -- mod -- |x| And mismatched delimiters: [5, 7)

Re: unicode as valid naming symbols

2014-03-30 Thread Gregory Ewing
Chris Angelico wrote: a 5x8 bitmap has forty pixels, any of which can be either on or off - that gives roughly twice as much data space as the 21-bit Unicode spec. We don't need a font, then -- just map the pixels straight onto bits in the character code! Might require some user re-education,

Re: checking if two things do not equal None

2014-03-30 Thread Gregory Ewing
Roy Smith wrote: But, if you show me a != None != b: my brain just goes into overload. Chained comparisons get weird with not-equal operators. If you see a == b == c then it implies that a == c, but a != b != c does *not* imply that a != c. At least it doesn't in Python; I've never

Re: checking if two things do not equal None

2014-03-30 Thread Gregory Ewing
Roy Smith wrote: Adding to the confusion, many designs would use active low logic, which means a 1 was represented by a low voltage, and a 0 by a high voltage. So, you quickly end up with gibberish like, not active low clear nand not active low enable clock. There are ways of dealing with

Re: Keeping track of things with dictionaries

2014-04-08 Thread Gregory Ewing
Chris Angelico wrote: in the dictionary I have here (Debian Wheezy, using an American English dictionary - it's a symlink to (ultimately) /usr/share/dict/american-english), there are five entries in that list. Mine's bigger than yours! On MacOSX 10.6 I get 41 words. (I think someone must have

Re: threading

2014-04-09 Thread Gregory Ewing
Roy Smith wrote: In the old days, all Unix system calls were divided up into two groups, based on whether they were fast or slow. Processes executing a fast system call would block, and could not be interrupted; That doesn't really have anything to do with blocking vs. non-blocking, though.

Re: threading

2014-04-09 Thread Gregory Ewing
On 2014-04-09 16:51, Rick Johnson wrote: Again we have the pronoun it declared as the very first word of the sentence, however, the referent is missing, and instead must be intuited! Pronoun referents *always* need to be intuited. There are no mechanical rules for finding the referent of a

Re: MemoryError in data conversion

2014-04-14 Thread Gregory Ewing
Mok-Kong Shen wrote: I have yet a question out of curiosity: Why is my 2nd list structure, that apparently is too complex for handling by eval and json, seemingly not a problem for pickle? Pickle is intended for arbitrary data structures, so it is designed to be able to handle deeply-nested

Re: MemoryError in data conversion

2014-04-15 Thread Gregory Ewing
Mok-Kong Shen wrote: (It means that I have to pickle out the list to a file and read in the content of the file in order to have it as a bytearray etc. etc.) No, you don't -- pickle.dumps() returns the pickled data as a bytes object instead of writing it to a file. -- Greg --

Re: Why Python 3?

2014-04-19 Thread Gregory Ewing
Chris Angelico wrote: I'd rather have to explicitly request floating-point division; When you write / in Python 3, you *are* explicitly requesting floating-point division. Similarly, when you write // you're explicitly requesting integer division. I don't see the problem. You write whatever

Re: Why Python 3?

2014-04-19 Thread Gregory Ewing
Chris Angelico wrote: Is your function so generic that it has to be able to handle float, Decimal, or complex, and not care about the difference, and yet has to ensure that int divided by int doesn't yield int? It doesn't have to be that generic to cause pain. Even if you're only dealing with

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Chris Angelico wrote: Truncating vs true is not the same as int vs float. If you mean to explicitly request float division, you call float() on one or both arguments. You're being explicit about something different. If you know you're dealing with either ints or floats, which is true in the

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Terry Reedy wrote: On 4/19/2014 9:06 PM, Gregory Ewing wrote: Similarly, when you write // you're explicitly requesting integer division. One is requesting 'floor division' 3.0//2.0 1.0 In general that's true, but I'm talking about a context in which you have some expectations

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Gregory Ewing
On Sat, 19 Apr 2014 19:37:31 +1000, Chris Angelico wrote: In Python 3, you have to say Oh but I want my integer division to result in an integer: I don't see why that's such a big hardship. There are clear advantages to having an explicit way to request non-floor division. Whatever way is

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Ian Kelly wrote: def average(values): return sum(values) / len(values) This works for decimals, it works for fractions, it works for complex numbers, it works for numpy types, and in Python 3 it works for ints. That depends on what you mean by works. I would actually find it rather

Re: Why Python 3?

2014-04-20 Thread Gregory Ewing
Richard Damon wrote: If you thing of the Standard Deviation being the Root Mean Norm2 of the deviations, it has a very similar meaning as to over the reals, a measure of the spread of the values. NumPy appears to handle this: http://docs.scipy.org/doc/numpy/reference/generated/numpy.std.html

Re: Why Python 3?

2014-04-21 Thread Gregory Ewing
Chris Angelico wrote: Earlier it was said that having both / and // lets you explicitly choose whether you want a float result or an int by picking an operator. I'm saying that's not so; the operator and the type aren't quite orthogonal, but close to. I don't think I said that, or if I did I

Re: Why Python 3?

2014-04-21 Thread Gregory Ewing
Chris Angelico wrote: All other basic arithmetic operations on two numbers of the same type results in another number of that type. ... There's just one special case: dividing an integer by an integer yields a float, if and only if you use truediv. It sticks out as an exception. I take your

Re: Why Python 3?

2014-04-22 Thread Gregory Ewing
Chris Angelico wrote: As it is, we have the case that most lowish integers have equivalent floats (all integers within the range that most people use them), and beyond that, you have problems. No, I don't. I'm not talking about representing ints using floats, I'm talking about representing

Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Gregory Ewing
tim.thel...@gmail.com wrote: I think this would be better solved by moving fully to an OOP model. That is, I would have a SubuserProgram class which had methods such as install, describe, isInstalled... This wouldn't necessarily be better. Don't be taken in by the everything is better as a

Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Gregory Ewing
Ian Kelly wrote: How about adding one abstract class per file, and then letting SubuserProgram inherit from each of those individual classes? I'd recommend against that kind of thing, because it makes the code hard to follow. With module-level functions, you can tell where any given function

Re: retrieve source code from code object as returned by compile()

2014-04-23 Thread Gregory Ewing
Justin Ezequiel wrote: Using Easy Python Decompiler I am able to get the source for the imported modules. Using Resources Viewer from PlexData and some code I am able to retrieve the code object. I am however stumped as to how to retrieve the source from this code object. Easy Python

Re: Installing PyGame?

2014-04-24 Thread Gregory Ewing
rohit782...@gmail.com wrote: On Saturday, June 8, 2013 9:37:44 PM UTC+5:30, Eam onn wrote: Now I have a bigger problem: HOW THE HECK DO I INSTALL PYGAME!?!?! System Details: I've tried using MacPorts, Fink, the Mac DMG, source installing, installing NumPY, just about every way possible. My

Re: Installing PyGame?

2014-04-24 Thread Gregory Ewing
Terry Reedy wrote: Idle depends on tkinter. Tkinter depends on having a tcl/tk that works, at least for tkinter. The following page has essential info about getting the right tcl/tk installed. https://www.python.org/download/mac/tcltk Also keep in mind that you don't *have* to use IDLE at

Re: Installing PyGame?

2014-04-25 Thread Gregory Ewing
Ned Deily wrote: I disagree that installing a bunch of disparate software from various sources via binary installers and/or source is to be preferred to a modern third-party package manager on OS X like MacPorts or Homebrew. That's just setting yourself up for a long-term maintenance

Re: Installing PyGame?

2014-04-25 Thread Gregory Ewing
Ryan Hiebert wrote: I've chosen to use MacPorts because it keeps things separate, because when things get hosed using the system libraries, I don't have to erase my whole system to get back to a vanilla OS X install. I don't know what you're doing to hose your system that badly. I've never

Re: retrieve source code from code object as returned by compile()

2014-04-25 Thread Gregory Ewing
Amirouche Boubekki wrote: in python3, I do inspect.getsource(object) [doc https://docs.python.org/3/library/inspect.html#inspect.getsource], I don't know the limitations. The limitation relevant here is that it requires the original source file to be present. :-) -- Greg --

Re: Inconsistent viewkeys behaviour

2014-04-28 Thread Gregory Ewing
Terry Reedy wrote: The left operand determines the result. The manual specifies that and do not have to be consistent. But I suspect that when 3.x dict.keys() was backported to 2.7.0, no one thought to update set, whereas the backported key view code already had the comparison. The

Re: Significant digits in a float?

2014-04-29 Thread Gregory Ewing
Ned Batchelder wrote: Reminds me of the story that the first survey of Mt. Everest resulted in a height of exactly 29,000 feet, but to avoid the appearance of an estimate, they reported it as 29,002: http://www.jstor.org/stable/2684102 They could have said it was 29.000 kilofeet. -- Greg --

Re: Bug in Decimal??

2014-04-30 Thread Gregory Ewing
pleasedonts...@isp.com wrote: I compared the results with wolfram Alpha, and also with an open source arbitrary precision calculator, which matches Alpha results. Decimal is *not* an arbitrary precision data type, so you can't expect exact results from it. You can set the precision to be very

Re: Significant digits in a float?

2014-04-30 Thread Gregory Ewing
Chris Angelico wrote: Any point where the mile east takes you an exact number of times around the globe. So, anywhere exactly one mile north of that, which is a number of circles not far from the south pole. True, but there are no bears in Antarctica, so that rules out all the south-pole

Re: Off-topic circumnavigating the earth in a mile or less [was Re: Significant digits in a float?]

2014-05-01 Thread Gregory Ewing
Terry Reedy wrote: For the most part, there are no bears within a mile of the North Pole either. they are rare north of 88° (ie, 140 miles from pole). https://en.wikipedia.org/wiki/Polar_bears They mostly hunt in or near open water, near the coastlines. The way things are going, the coastline

Re: Why has __new__ been implemented as a static method?

2014-05-03 Thread Gregory Ewing
Steven D'Aprano wrote: I'm not entirely sure what he means by upcalls, but I believe it means to call the method further up (that is, closer to the base) of the inheritance tree. I think it means this: def __new__(cls): MyBaseClass.__new__(cls) which wouldn't work with a class

Re: Why has __new__ been implemented as a static method?

2014-05-04 Thread Gregory Ewing
Steven D'Aprano wrote: If it were a class method, you would call it by MyBaseClass.__new__() rather than explicitly providing the cls argument. But that wouldn't be any good, because the base __new__ needs to receive the actual class being instantiated, not the class that the __new__ method

Re: The � debate

2014-05-08 Thread Gregory Ewing
Steven D'Aprano wrote: Today we routinely call horseless carriages cars, and nobody would blink if I pointed at a Prius or a Ford Explorer and said that's not a carriage, it's a car except to wonder why on earth I thought something so obvious needed to be said. That's only because the term

Re: The � debate

2014-05-10 Thread Gregory Ewing
Steven D'Aprano wrote: some_function(x, y+1)[key].attribute[num](arg)[spam or eggs] = 42 I'm pretty sure that it isn't common to call the LHS of that assignment a variable. A better way of putting it might be something in the data model that can be assigned to. -- Greg --

Re: PEP 8 : Maximum line Length :

2014-05-13 Thread Gregory Ewing
Ben Finney wrote: The 80 character line limit is *not* driven by a limitation of computer technology; it is driven by a limitation of human cognition. For that reason, it remains relevant until human cognition in the general reading population improves. Another thing: Just because I may have

Re: confused about the different built-in functions in Python

2014-05-26 Thread Gregory Ewing
Marko Rauhamaa wrote: IOW, you can override a method with setattr() but you cannot delete a method with delattr(). Actually, you can -- but you need to delete it from the class, not the instance: delattr(X, 'f') x.f() Traceback (most recent call last): File stdin, line 1, in module

Re: Python 3.2 has some deadly infection

2014-06-02 Thread Gregory Ewing
Terry Reedy wrote: The issue Armin ran into is this. He write a library module that makes sure the streams are binary. Seems to me he made a mistake right there. A library should *not* be making global changes like that. It can obtain binary streams from stdin and stdout for its own use, but

Re: Obfuscated Python hack

2014-06-02 Thread Gregory Ewing
Tim Chase wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But you have to do that in *another* Python session, because the first one is broken in interesing ways, e.g. (lambda *fs:

Re: Unicode and Python - how often do you index strings?

2014-06-04 Thread Gregory Ewing
Chris Angelico wrote: On Wed, Jun 4, 2014 at 11:18 AM, Roy Smith r...@panix.com wrote: sarcasm style=regex-pedantUm, you mean cent(er|re), don't you? The pattern you wrote also matches centee and centrr./sarcasm Maybe there's someone who spells it that way! Come visit Pirate Island, the

Re: Python 3.2 has some deadly infection

2014-06-04 Thread Gregory Ewing
Steven D'Aprano wrote: The whole concept of stdin and stdout is based on the idea of having a console to read from and write to. Not really; stdin and stdout are frequently connected to files, or pipes to other processes. The console, if it exists, just happens to be a convenient default value

Re: OT: This Swift thing

2014-06-07 Thread Gregory Ewing
Michael Torrie wrote: Technically C doesn't either, except via subroutines in libc, though C does have pointers which would be used to access memory. The Pascal that Apple used had a way of casting an int to a pointer, so you could do all the tricks you can do with pointers in C. -- Greg --

Re: OT: This Swift thing

2014-06-07 Thread Gregory Ewing
Dennis Lee Bieber wrote: Not standard Pascal... It had pointer types, but no means to stuff an integer into the pointer variable in order to dereference it as a memory address... Although most implementations would let you get the same effect by abusing variant records (the equivalent

Re: Uniform Function Call Syntax (UFCS)

2014-06-07 Thread Gregory Ewing
Ian Kelly wrote: It's a nice feature in a statically typed language, but I'm not sure how well it would work in a language as dynamic as Python. Also it doesn't sit well with Python's one obvious way to do it guideline, because it means there are *two* equally obvious ways to call a function.

Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing
Rustom Mody wrote: JFTR: Information processing and (physics) energy are about as convertible as say: Is a kilogram smaller/greater than a mile? Actually, that's not true. There is a fundamental thermodynamic limit on the minimum energy needed to flip a bit from one state to the other, so in

Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing
Steven D'Aprano wrote: Everything *eventually* gets converted to heat, but not immediately. There's a big difference between a car that gets 100 miles to the gallon, and one that gets 1 mile to the gallon. With a car, the engine converts some of its energy to kinetic energy, which is

Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing
Chris Angelico wrote: So, let me get this straight. A CPU has to have a fan, but a car engine doesn't, because the car's moving at a hundred kays an hour. I have a suspicion the CPU fan moves air a bit slower than that. If the car were *always* moving at 100km/h, it probably wouldn't need a

Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing
Steven D'Aprano wrote: Automotive cooling fluid in modern sealed radiators is typically a mixture of 50% anti-freeze and 50% water. Sometimes it's even more than 50%, at which point you really have an antifreeze-cooled engine. :-) -- Greg --

Re: OT: This Swift thing

2014-06-12 Thread Gregory Ewing
Steven D'Aprano wrote: It is my contention that, had Intel and AMD spent the last few decades optimizing for power consumption rather than speed, we probably could run a server off, well, perhaps not a watch battery, Current draw of CMOS circuitry is pretty much zero when nothing is changing,

Re: Lines on a tkinter.Canvas

2014-06-12 Thread Gregory Ewing
Pedro Izecksohn wrote: The Canvas' method create_line turns on at least 2 pixels. But I want to turn on many single pixels on a Canvas. You could try using a 1x1 rectangle instead. However, be aware that either of these will use quite a lot of memory per pixel. If you are drawing a very large

Re: Lines on a tkinter.Canvas

2014-06-12 Thread Gregory Ewing
Pedro Izecksohn wrote: Thank you Greg. Your second approach works and the script became: That's not really what I meant; doing it that way, you're still incurring the overhead of a tk canvas object for each point that you draw. However, if there are only 250 points or so, it might not

Re: Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Gregory Ewing
Robert Lehmann wrote: I have noticed there is a slight asymmetry in the way the interpreter (v3.3.5, reproduced also in v3.5.x) loads and stores globals. While loading globals from a custom mapping triggers __getitem__ just fine, writing seems to silently ignore __setitem__. I didn't think

Re: OT: This Swift thing

2014-06-16 Thread Gregory Ewing
Anssi Saari wrote: That was before 90 nm when leakage current started dominating over switching current. Well, if you don't care about speed, you probably don't need to make it that small. There's plenty of time for signals to propagate, so you can afford to spread the circuitry out more. The

Re: python 3.44 float addition bug?

2014-06-23 Thread Gregory Ewing
buck wrote: What's the recommended way to do this now? format(.01 + .01 + .01 + .01 + .01 + .01, 'g') == format(.06, 'g') There's no recommended way. What you're asking for can't be done. Whatever trick you come up with, there will be cases where it doesn't work. Why do you think you want

Re: Off-Topic: The Machine

2014-06-25 Thread Gregory Ewing
Steven D'Aprano wrote: Heh, yes, it's a puff-piece, based on HP's publicity, not an in-depth review. Considering that The Machine isn't publicly available yet, that's hardly surprising. There's a talk here that goes into a bit more detail, although still not much:

Re: How to get Timezone from latitude/longitude ?

2014-06-25 Thread Gregory Ewing
Ethan Furman wrote: On 06/25/2014 07:24 AM, Grant Edwards wrote: On 2014-06-25, Marko Rauhamaa wrote: Some years back my employer switched ISPs in Southern California. The following morning Google displayed everything in Hebrew. It took a week or two to be corrected. Learning Hebrew in a

Re: Python While loop Takes too much time.

2014-06-30 Thread Gregory Ewing
marco.naw...@colosso.nl wrote: In the past I even dumped an EXCEL sheet as a CSV file That's probably the only way you'll speed things up significantly. In my experience, accessing Excel via COM is abysmally slow no matter how you go about it. -- Greg --

Re: 1-0.95

2014-07-02 Thread Gregory Ewing
Rustom Mody wrote: Just as there are even some esteemed members of this list who think that c - a is a meaningful operation where c is speed of light a is speed of an automobile Indeed, it should be (c - a) / (1 - (c*a)/c**2). Although loss of precision might give you the right

Re: Using the Python Interpreter as a Reference

2011-11-28 Thread Gregory Ewing
Travis Parks wrote: I thinking tabs are out-of-date. Even the MAKE community wishes that the need for tabs would go away The situation with make is a bit different, because it *requires* tabs in certain places -- spaces won't do. Python lets you choose which to use as long as you don't mix

Re: Using the Python Interpreter as a Reference

2011-11-28 Thread Gregory Ewing
Neil Cerutti wrote: I've always held with the anti-functional style conspiracy interpretation of Python's lambda expressions. They were added but grudgingingly, made weak on purpose to discourage their use. Seems to me that Python's lambdas are about as powerful as they can be given the

Re: tp_new, tp_alloc, tp_init

2011-12-08 Thread Gregory Ewing
Michael Hennebry wrote: I've been reading about writing extension types in C and am rather fuzzy about the relationship between tp_new, tp_alloc and tp_init. Most especially, why tp_new? It seems to me that tp_alloc and tp_init would be sufficient. tp_new and tp_init correspond to the Python

Re: How to get a correct entry in the menu for a Python application on Mac OS X

2011-12-08 Thread Gregory Ewing
Detlev Offenbach wrote: I am fairly new to Mac OS X and would like to know, what I have to do to make my Python application show the correct name in the menu bar. What did I do so far. I created an application package containing the .plist file with correct entries and a shell script, that

Re: Verbose and flexible args and kwargs syntax

2011-12-12 Thread Gregory Ewing
Steven D'Aprano wrote: Modulo is hardly an obscure operation. What's the remainder...? is a simple question that people learn about in primary school. Well, sort of. The way I remember it, the remainder was just something that fell out as a side effect of division -- the annoying bit left

Re: Verbose and flexible args and kwargs syntax

2011-12-12 Thread Gregory Ewing
For what it's worth, googling for python asterisk gives this as the very first result: http://www.technovelty.org/code/python/asterisk.html which tells you exactly what you're probably wanting to know if you ask that. To check that this phenomemon isn't restricted to asterisks in particular,

Re: AttributeError in with statement (3.2.2)

2011-12-15 Thread Gregory Ewing
MRAB wrote: To give an analogy, it is like defining mammals as hairy animals which give birth to live young, which is correct for all mammals except for monotremes, which are mammals which lay eggs. Or the naked mole-rat. Or cetaceans (whales). The way I understand it, the main

Re: ERP with Supply chain management (incl. POS) and Customer relationship management — What's available?

2011-12-15 Thread Gregory Ewing
On Thu, Dec 15, 2011 at 5:54 AM, Anurag Chourasia anurag.choura...@gmail.com wrote: I am building a POS/CRM (Loyalty Management) system as well. Is it just me, or does the phrase Loyalty Management have a faintly ominous ring to it? -- Greg --

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Gregory Ewing
Eelco wrote: the actual english usage of the phrase, which omits the negation completely :). (I could care less) No, that's the American usage. The English usage is I couldn't care less, which has the advantage of actually making sense. -- Greg --

Re: expression in an if statement

2010-08-22 Thread Gregory Ewing
Thomas Jollans wrote: What if set has side effects? A compiler could only exclude this possibility if it knew exactly what set will be at run time, And also that 'a' remains bound to the same object, and that object or anything reachable from it is not mutated in any way that could affect the

Re: palindrome iteration

2010-08-29 Thread Gregory Ewing
Steven D'Aprano wrote: I'm not entirely sure what the use-case for swapcase is. Obviously it's for correcting things that were typed in with tHE cAPS lOCK kEY oN bY mISTAKE. :-) -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue cleanup

2010-08-30 Thread Gregory Ewing
Paul Rubin wrote: These days I think the GC pause issue is overrated except for real-time control applications. Also for games, which are a fairly common application these days. Even a few milliseconds can be too long when you're trying to achieve smooth animation. I'd be disappointed if

Re: String substitution VS proper mysql escaping

2010-08-30 Thread Gregory Ewing
Nik the Greek wrote: Yes i will i just asked to know if i were to substitute what might be the problem so to understand why i need the quoting. Because if you use % to build a query string, the result must be syntactically valid SQL. The values that you substitute into the placeholders must

Re: Passing variable to SQL statement when using psycopg2

2010-08-30 Thread Gregory Ewing
Chris Rebert wrote: On Sun, Aug 29, 2010 at 11:29 PM, Julia Jacobson Where does the E in front of 'xyz' come from? It's probably the reason, why my query doesn't work. Quite doubtful, considering the example in the psycopg2 docs also has the E:

Re: Queue cleanup

2010-09-07 Thread Gregory Ewing
Paul Rubin wrote: Now extrapolate that error rate from 30 lines to a program the size of Firefox (something like 5 MLOC), and you should see how fraught with danger that style of programming is. But you don't write 5 MLOC of code using that programming style. You use it to write a small core

Re: what should __iter__ return?

2010-09-07 Thread Gregory Ewing
Thomas Jollans wrote: Hmm. Modifying an object while iterating over it isn't a great idea, ever: I wouldn't say never. Algorithms that calculate some kind of transitive closure can be expressed rather neatly by appending items to a list being iterated over. You can accommodate that kind of

<    1   2   3   4   5   6   7   8   9   10   >