Re: Python is DOOMED! Again!

2015-02-01 Thread Gregory Ewing
Steven D'Aprano wrote: If I have an arbitrary pointer, and I want to check if it is safe to dereference, how do I do it? Surely I'm not expected to write something like: if type(ptr) == A: if ptr != Anil: ... if type(ptr) == B: if ptr != Bnil: ... etc. That would be insane. So how doe

Re: Python is DOOMED! Again!

2015-02-01 Thread Gregory Ewing
Devin Jeanpierre wrote: I answered my own question later, by accident: Java nulls are castable to each other if you do it explicitly (routing through Object -- e.g. (Something)((Object) ((SomeOtherThing) null. So in that sense, there is only one null, just with some arbitrary compiler distin

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: Both K.f and K.g are methods, even though only one meets the definition given in the glossary. The glossary is wrong. Or rather, it is not so much that it is *wrong*, but that it is incomplete and over-simplified. I agree with that; a more complete definition would be "a

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: In Python 2, they are methods. In Python 3, they are functions, and aren't converted into methods until you access them via the instance: They're methods in both cases. They don't have to be "converted into methods"; they already are, by virtue of their location and inte

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Marko Rauhamaa wrote: For (almost) all practical purposes, that is the Python way as well. If object instantiation (conceptually) copied the class's methods into the object's dict, you'd get the semantics I'm looking for. If things worked the way you want, it would be impossible to store a func

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: If some methods can be defined outside of the body of a class, then being defined inside the body of a class does not define a method. Nobody's disputing that. The business about super() is just a possible reason for the glossary to define the word 'method' in a more rest

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Marko Rauhamaa wrote: Right now Python generates the trampoline from the class prototype every time you call a method. If the semantics allowed, you could create the trampoline at instantiation time (for better or worse). That way, the problem you seem to be referring to wouldn't materialize. S

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: Gregory Ewing wrote: If things worked the way you want, it would be impossible to store a function in an instance attribute and get it out again *without* it being treated as a method > Not impossible, just inconvenient... the solution is to use a custom de

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: Er, perhaps "code injection" is not the best name for this, on account of it also being the name for a security vulnerability anti-pattern: I'm talking about a variety of dependency injection where you either add an entirely new method to an instance, or give the instan

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Gregory Ewing
Steven D'Aprano wrote: I'm arguing with those who insist that objects of type MethodType aren't methods, and objects of type FunctionType aren't functions but methods, except when they are, based on that simplified, incomplete glossary entry. I'm not arguing that based on the glossary entry. I

Re: pymongo and attribute dictionaries

2015-02-04 Thread Gregory Ewing
Travis Griggs wrote: for doc in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}}): pprint(doc) changes to for doc in ((Doc(d) for d in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}})): pprint(doc) Are there other approaches? Feel free to impress me with evil abuses in the interest of a

Re: meaning of: line, =

2015-02-05 Thread Gregory Ewing
Devin Jeanpierre wrote: On Wed, Feb 4, 2015 at 1:18 PM, Chris Angelico wrote: On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten <__pete...@web.de> wrote: [result] = f() result Huh, was not aware of that alternate syntax. Nor are most people. Nor is Python, in some places -- it seems like peop

Re: meaning of: line, =

2015-02-05 Thread Gregory Ewing
Chris Angelico wrote: [] = x # is equivalent to try: next(iter(x)) except StopIteration: pass else: raise ValueError("too many values to unpack (expected 0)") It's a way of asserting that an iterator is exhausted! But why disallow using () for the same thing? This is a blatant case of outright

Re: Incompatible idioms: relative imports, top-level program file

2015-02-07 Thread Gregory Ewing
Rustom Mody wrote: Wanted to try out sympy. apt-install promised ¼ GB download, ¾ GB space usage Just getting a src-tarball was: 6M download, 30M after opening the tar. Have you actually tried compiling and using that tarball, though? Sympy hooks into a lot of other libraries that are themsel

Re: How to extract a movie title out of a text file

2015-02-07 Thread Gregory Ewing
Seymore4Head wrote: What I would like to be able to do is download and save to a folder all the srr files in this Usenet group. alt.binaries.moovee The nntplib module in the standard library would be a good place to start. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Gregory Ewing
Mark Lawrence wrote: I still think it's a bug as the 'p' being referred to in the OP's original message is "The precision is a decimal number indicating how many digits should be displayed after the decimal point for a floating point value formatted with 'f' and 'F', or before and after the dec

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-18 Thread Gregory Ewing
Mario Figueiredo wrote: Parameterized queries is just a pet peeve of mine that I wish to include here. SQLite misses it How does sqlite3 miss parameterized queries? It supports DB-API parameter subsitution with '?' according to the docs. -- Greg -- https://mail.python.org/mailman/listinfo/pyth

Re: What behavior would you expect?

2015-02-20 Thread Gregory Ewing
Jason Friedman wrote: It's a shame that glob.glob does not take an arbitrary directory as an optional argument if one does not want to scan the current directory. It doesn't have to -- you can give it an absolute path: >>> from glob import glob >>> glob("/usr/include/std*.h") ['/usr/include/st

Re: Design thought for callbacks

2015-02-22 Thread Gregory Ewing
Frank Millman wrote: "In order to inform users that certain bits of state have changed, I require them to register a callback with my code." This sounds to me like a pub/sub scenario. When a 'listener' object comes into existence it is passed a reference to a 'controller' object that holds st

Re: Design thought for callbacks

2015-02-23 Thread Gregory Ewing
Cem Karan wrote: I tend to structure my code as a tree or DAG of objects. The owner refers to the owned object, but the owned object has no reference to its owner. With callbacks, you get cycles, where the owned owns the owner. This is why I suggested registering a listener object plus a meth

Re: Design thought for callbacks

2015-02-24 Thread Gregory Ewing
random...@fastmail.us wrote: On Tue, Feb 24, 2015, at 00:20, Gregory Ewing wrote: This is why I suggested registering a listener object plus a method name instead of a callback. It avoids that reference cycle, because there is no long-lived callback object keeping a reference to the listener

Re: Design thought for callbacks

2015-02-25 Thread Gregory Ewing
Cem Karan wrote: I think I see what you're talking about now. Does WeakMethod (https://docs.python.org/3/library/weakref.html#weakref.WeakMethod) solve this problem? Yes, that looks like it would work. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: singleton ... again

2014-02-12 Thread Gregory Ewing
Roy Smith wrote: It looks to me like he's trying to implement a classic Gang of Four singleton pattern. Which I've never really seen the point of in Python, or any other language for that matter. Just create one instance of the class during initialisation, put it in a global somewhere, and use

Re: singleton ... again

2014-02-12 Thread Gregory Ewing
Asaf Las wrote: There is another one. Once object passes through singletonizator there wont be any other object than first one. Then object constructor can freely be used in every place of code. You're still making things far more complicated than they need to be. *Why* do you want to be a

Re: Working with the set of real numbers

2014-02-12 Thread Gregory Ewing
Ben Finney wrote: That's why I think you need to be clear that your point isn't “computers don't work with real numbers”, but rather “computers work only with a limited subset of real numbers”. They actually work with a subset of *rational* numbers. All floats representable by a computer are ra

Re: Working with the set of real numbers

2014-02-12 Thread Gregory Ewing
Chris Angelico wrote: Sure, but nobody said the text file had to be _stored_ anywhere :) Computers are quite capable of working with streams of incoming data that are potentially infinite in size. However, they *can't* work with arbitrary real numbers in an exact way, even if they are represent

Re: Working with the set of real numbers

2014-02-12 Thread Gregory Ewing
Chris Angelico wrote: Of course a computer can work with _some_ real numbers; but only some. (An awful lot of them, of course. A ridiculously huge number of numbers. More numbers than you could read in a lifetime! While the number is extremely large, it still falls pitifully short of infinity.[1]

Re: Top down Python

2014-02-12 Thread Gregory Ewing
John Allsup wrote: I'm still minimalist, so I guess we want xmlrpc and a python server, with a bit of javascript in the browser to sort out the drawing end. This now seems way simpler than trying to play with Gtk or Qt. Depends on what you mean by "simpler". You've just mentioned about 3 addi

Re: singleton ... again

2014-02-13 Thread Gregory Ewing
Steven D'Aprano wrote: On Wed, 12 Feb 2014 23:04:32 +1300, Gregory Ewing wrote: If you really want to make sure nobody creates another instance by accident, delete the class out of the namespace after instantiating it. That does not work. It is trivial to get the type from an instance

Re: singleton ... again

2014-02-13 Thread Gregory Ewing
Steven D'Aprano wrote: Of course it can happen by accident. It's happened to me, where I've accidentally called NoneType() (which raises, rather than returning a new instance). Well, "unlikely to happen by accident", then. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: singleton ... again

2014-02-13 Thread Gregory Ewing
Ethan Furman wrote: Say you have a class that represents serial ports or your computer. You should get the same object every time you ask for SerialPort(2). No, you shouldn't ask for SerialPort(2) at all, you should call get_serial_port(2). Then you won't be fooled into thinking that you're cr

Re: Working with the set of real numbers

2014-02-13 Thread Gregory Ewing
Dave Angel wrote: Actually, the particular example you use can be done. When printing the infinite sum of two infinite decimal streams, you can simply hold back whenever you get one or more nines. But you only have a finite amount of space for keeping track of how many nines you've seen, so

Re: Working with the set of real numbers

2014-02-13 Thread Gregory Ewing
Chris Angelico wrote: Even adding to your requirements that it have an ℵ₁ Hz bus (which, by the way, I *totally* want - the uses are endless), it would take a finite amount of time to assign to x the "next number", ergo your algorithm can't guarantee to finish in finite time. If it's a quantum

Re: Working with the set of real numbers

2014-02-14 Thread Gregory Ewing
Devin Jeanpierre wrote: There is no way to iterate over all the reals one at a time, no matter how fast you execute instructions. If you could, it would be trivial to show that the reals have the same cardinality as the positive integers: correspond n with the whatever is returned by the nth call

Re: Explanation of list reference

2014-02-15 Thread Gregory Ewing
Steven D'Aprano wrote: (1) General relativity tells us that not all observers will agree on the space-time coordinates of two objects, since not all observers agree on a single frame of reference. But that doesn't mean they won't agree about whether objects are identical or not! The coordinate

Re: Explanation of list reference

2014-02-15 Thread Gregory Ewing
Steven D'Aprano wrote: IDs are a proxy for distinct objects. If you live in a country with an ID card of some sort, then the IDs acts as an identifier for each unique individual. But countries without ID cards don't lack unique individual people. "You are Number Six." "I am not an id()! I am

Re: Explanation of list reference

2014-02-15 Thread Gregory Ewing
Jussi Piitulainen wrote: Would it help to say that in case 1 the relevant statement acts on the variable while in case 2 it acts on the value of the variable? I would try to avoid using words like "value" and "variable", because they don't have well-defined meanings in Python. The way I would

Re: Explanation of list reference

2014-02-15 Thread Gregory Ewing
Chris Angelico wrote: But yes, this is an expression, and it evaluates to a reference. Well, *all* expressions in Python evaluate to references, so that's not really saying much. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-16 Thread Gregory Ewing
Steven D'Aprano wrote: And indeed numpy arrays do share state. Why? No idea. Somebody thought that it was a good idea. (Not me though...) Probably because they're often large and people don't want to incur the overhead of copying them any more than necessary. So slices are defined to return vie

Re: Explanation of list reference

2014-02-16 Thread Gregory Ewing
Chris Angelico wrote: Because everything in Python is an object, and objects always are handled by their references. So, we have objects... and we have references to objects... but everything is an object... so does that mean references are objects too? This is the kind of trouble you get in

Re: Can global variable be passed into Python function?

2014-02-24 Thread Gregory Ewing
Steven D'Aprano wrote: Yes, Pascal has pointers as a first-class data type. Syntax is similar to C, ^x is a pointer to x, p^ dereferences the pointer p. Actually, the prefix ^ is only used for declaring pointer *types*. Standard Pascal has no way of getting a pointer to an arbitrary variable; t

Re: Can global variable be passed into Python function?

2014-02-26 Thread Gregory Ewing
Steven D'Aprano wrote: Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-) Mac Pascal used @ for getting a pointer to a variable, if I remember rightly. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: exec and locals

2014-02-26 Thread Gregory Ewing
Steven D'Aprano wrote: except SyntaxError: def inner(): # manually operate the context manager call context manager __enter__ try: try: return something except: # Yes, a bare except. Catch EVERYTH

Re: exec and locals

2014-02-27 Thread Gregory Ewing
Steven D'Aprano wrote: On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote: Why not just use this version all the time? It should work in both 2.x and 3.x. Because that's yucky. It's an aesthetic thing: when supported, I want the Python interpreter to manage the context

Re: References, and avoiding use of ???variable???

2014-02-28 Thread Gregory Ewing
Ben Finney wrote: That whole chapter of the tutorial talks about “variable” and “variable assignment”, when IMO it should avoid those terms and use the clearer terminology of “reference”, “name”, and “binding a name to a value”. What about all the other things that can be assigned to but aren't

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 proble

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 *sho

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 a

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 assi

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 th

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 6

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. I

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 you

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

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" tha

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 deali

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, howe

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 more

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 inte

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,

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 las

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-29 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-29 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 s

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 wi

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 f

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, tho

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 pr

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 and

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 -- https://mail.pyth

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 y

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 f

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 va

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 whic

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 dis

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 wa

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 poi

Re: Why Python 3?

2014-04-21 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 floa

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 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 Decomp

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 a

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 all

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 headache

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 neve

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 ], I don't know the limitations. The limitation relevant here is that it requires the original source file to be present. :-) -- Greg -- https://mail.pyt

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 quest

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 -- h

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 l

<    5   6   7   8   9   10   11   12   13   14   >