Re: Guido sees the light: PEP 8 updated

2016-04-18 Thread Gregory Ewing
Marko Rauhamaa wrote: Steven D'Aprano : def Do_The_Thing(): def internal_subpart_start(): ... def internal_subpart_middle(): ... def internal_subpart_end(): ... ... That really should be done more. C weaned us from the routine Pascal mechanism, but there's no reason not to exploit

Re: Guido sees the light: PEP 8 updated

2016-04-18 Thread Gregory Ewing
Rustom Mody wrote: Come to think of it take an SQL DBMS browser. Should we say: Horizontal scrolls are BAD; just reformat the table after reaching 80 columns? I would say, yes, horizontal scrolling *is* bad in a table -- probably even worse than it is for text or code. The reason is that tabl

Re: QWERTY was not designed to intentionally slow typists down

2016-04-18 Thread Gregory Ewing
Steven D'Aprano wrote: Even on a modern keyboard, out of the ten most common digraphs: th he in er an re nd at on nt only er/re use consecutive keys, Also keep in mind that E and R being adjacent on the keyboard does *not* mean they're adjacent in the type basket -- they're actually separated

Re: Guido sees the light: PEP 8 updated

2016-04-18 Thread Gregory Ewing
Ian Kelly wrote: What happens when another programmer reviews the code using a different font and finds that there is only 3.5em worth of space? Do we descend into Calibri / Verdana line-length edit wars? That's easy, we just decree that all Python source code is to be displayed in this font:

Re: Convert input to upper case on screen as it is typed

2016-04-18 Thread Gregory Ewing
Ben Finney wrote: I am still looking for a solution (a Python-specific one would be fine). The only other way I can think of is to put the tty into raw mode and do your own line editing and echoing. You could wrap it all up in a file-like object for the rest of the code to use. -- Greg -- ht

Re: Guido sees the light: PEP 8 updated

2016-04-19 Thread Gregory Ewing
Rustom Mody wrote: On Wednesday, April 20, 2016 at 6:33:33 AM UTC+5:30, Steven D'Aprano wrote: Anyone who thinks that we're heading back to hieroglyphics simply isn't paying attention. Which are just text in the range 13000-1342F: http://unicode.org/charts/PDF/U13000.pdf Moreover, the Egyp

Re: Remove directory tree without following symlinks

2016-04-23 Thread Gregory Ewing
Steven D'Aprano wrote: But seriously, where is that documented? I've read the man page for rm, and it doesn't say anything about treatment of symlinks The Linux man page seems to be a bit deficient on this. The BSD version contains this sentence: The rm utility removes symbolic links, not

Re: Optimizing Memory Allocation in a Simple, but Long Function

2016-04-25 Thread Gregory Ewing
Derek Klinge wrote: Also, it seems to me if the goal is to use the smallest value of n to get a particular level of accuracy, changing your guess of N by doubling seems to have a high chance of overshoot. If you want to find the exact n required, once you overshoot you could use a binary search

Re: Python path and append

2016-04-25 Thread Gregory Ewing
Steven D'Aprano wrote: (Possible a few very old operating systems on supercomputers from the 1970s or 80s may have supported inserting... I seem to recall that VMS may have allowed that... but don't quote me.) I wouldn't be surprised if VMS provided some sort of indexed random-access file struc

Re: Python Madlibs.py code and error message

2016-04-27 Thread Gregory Ewing
Cai Gengyang wrote: adjective1 = raw_input("Enter an adjective: ") NameError: name 'Adjective1' is not defined Python is case-sensitive. You've spelled it "adjective1" in one place and "Adjective1" in another. You need to be consistent. -- Greg -- https://mail.python.org/mailman/listinfo/pyt

Re: Pythonic style

2016-04-28 Thread Gregory Ewing
MRAB wrote: Is it worthy of being in the Zen of Python? +1. Maybe something along the lines of: Dunder methods are for defining, not calling. Unless you're a dunderhead[1]. [1] Meant in the sense of an enthusiast, cf. gearhead. -- Greg -- https://mail.python.org/mailman/listinfo/pytho

Re: What should Python apps do when asked to show help?

2016-04-28 Thread Gregory Ewing
Irmen de Jong : if sys.stdout.isatty(): #use a pager to display help text else: #print all help text normally I think nowadays it's an anti-pattern for programs to do their own pagination. Very often the "terminal" is a GUI application with its own facilities for scrolling and se

Re: Pythonic style

2016-04-28 Thread Gregory Ewing
Chris Angelico wrote: I thought the twentieth zen would never be found? Yes. This will have to be numbered the 21st zen to maintain that invariant. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Not x.islower() has different output than x.isupper() in list output...

2016-04-29 Thread Gregory Ewing
Christopher Reimer wrote: str.islower(): "Return true if all cased characters [4] in the string are lowercase and there is at least one cased character, false otherwise." str.isupper(): "Return true if all cased characters [4] in the string are uppercase and there is at least one cased charac

Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-04 Thread Gregory Ewing
Jussi Piitulainen wrote: Ceterum censeo, the only suggested use for .swapcase I've ever heard of is encryption. Yep, all the smart terrorists these days are using a combination of swapcase and rot13. Totally bamboozles the FBI. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: After a year using Node.js, the prodigal son returns

2016-05-06 Thread Gregory Ewing
Chris Angelico wrote: https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript This video seems to be broken. It stops about 1/3 of the way through for me and says "No video with supported format and MIME type found". -- Greg -- https://mail.python.org/mailman/listinfo/pytho

Re: A fun python CLI program for all to enjoy!

2016-05-06 Thread Gregory Ewing
DFS wrote: Maybe it worked because the last time the file was written to was in a for loop, so I got lucky and the files weren't truncated? Don't know. It "works" because CPython disposes of objects as soon as they are not referenced anywhere. Other implementations of Python (e.g. Jython, PyPy

Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread Gregory Ewing
Steven D'Aprano wrote: Who is setting and enforcing this quota, and given that only about 1 in 20 Python programmers is a woman, do you think men are seriously missing out on any opportunities? Suppose there are 100 people wanting to ask questions, and there is only time to answer 10 questions.

Re: Python is an Equal Opportunity Programming Language

2016-05-07 Thread Gregory Ewing
Stephen Hansen wrote: On Fri, May 6, 2016, at 11:43 PM, Gregory Ewing wrote: Whether you think this is a good strategy or not, beliavsky is right that it's not "equal". This is a pedantically and nonsensical definition of "equal", that ignores the many, many reas

Re: pylint woes

2016-05-08 Thread Gregory Ewing
Stephen Hansen wrote: The point is, you don't usually commit after an error happens. You rollback. He might want to commit the ones that *did* go in. That's not necessarily wrong. It all depends on the surrounding requirements and workflow. -- Greg -- https://mail.python.org/mailman/listinfo/p

Re: Design: Idiom for classes and methods that are customizable by the user?

2016-05-12 Thread Gregory Ewing
Dirk Bächle wrote: What happens now and then is, that users are unhappy with the way this Taskmaster proceeds. One peculiar detail is, that our "default" Taskmaster always deletes the old target file before re-building it...and in special situations this may be seen as unwanted. I'm not conv

Re: Distinction between “class” and “type”

2016-05-13 Thread Gregory Ewing
Paul Rubin wrote: You can't instantiate T by saying x = T() and expecting to get back some value that is (indeterminately) an int or a string. Unless it's Python 6000 running on a quantum computer... -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Gregory Ewing
Is there some way you can get more stuff into a single html page? For example, use inline css and image data instead of delivering them as separate files. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Quote of the day

2016-05-18 Thread Gregory Ewing
Ned Batchelder wrote: I'm not sure how the test runner could determine that it was empty. I guess it could introspect the test function to see if it had any real code in it, Then people would just get clever at putting dummy code in the test that fools the test runner but doesn't really test a

Re: OT: limit number of connections from browser to my server?

2016-05-18 Thread Gregory Ewing
Grant Edwards wrote: Product spec explicitly states HTTPS only. I'm told that is not open for discussion. The customer is a large, somewhat bureaucratic German corporation, and they generally mean it when they say something is non-negotiable. They're probably being sensible. The way the Inter

Re: setrecursionlimit

2016-05-19 Thread Gregory Ewing
Steven D'Aprano wrote: I don't really understand why the system can't track the current top of the stack and bottom of the heap, and if they're going to collide, halt the process. That effectively *is* what it does. The reason it manifests as a segfault is because of the way it goes about dete

Re: setrecursionlimit

2016-05-19 Thread Gregory Ewing
Rustom Mody wrote: Both the mess in catching numeric overflow as well as stackoverflow looks like its C's fault. I consider it as the fault of currently fashionable stock hardware The sad thing about C is that it doesn't even help you detect integer overflow in *software*. Every machine I've

Re: Resources/pointers for writing maintable, testable Python

2016-05-19 Thread Gregory Ewing
Chris Angelico wrote: [1] Some people's names can't be represented in Unicode. Like this fellow's, for instance: https://www.youtube.com/watch?v=hNoS2BU6bbQ -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-19 Thread Gregory Ewing
Herkermer Sherwood wrote: But there is already a reserved keyword that would work great here. "finally". Unfortunately, it wouldn't follow the semantics of try/except/else/finally. Is it better to follow the semantics used elsewhere in the language, or have the language itself make sense semant

Re: for / while else doesn't make sense

2016-05-23 Thread Gregory Ewing
Pete Forman wrote: However I am coming from scientific measurements where 1.0 is the stored value for observations between 0.95 and 1.05. You only know that because you're keeping some extra information in your head about what the 1.0 stored in your computer represents. It's not inherent in the

Re: for / while else doesn't make sense

2016-05-24 Thread Gregory Ewing
Pete Forman wrote: Gregory Ewing writes: Pete Forman wrote: However I am coming from scientific measurements where 1.0 is the stored value for observations between 0.95 and 1.05. You only know that because you're keeping some extra information in your head about what the 1.0 stor

Re: for / while else doesn't make sense

2016-05-24 Thread Gregory Ewing
Christopher Reimer wrote: Nope. I meant 8-bit ASCII (0-255). http://www.ascii-code.com That page is talking about latin-1, which is just one of many possible 8-bit extensions of ascii. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Coding systems are political (was Exended ASCII and code pages)

2016-05-29 Thread Gregory Ewing
Steven D'Aprano wrote: And I thought that the Turing model was based on binary: It's not based on any particular encoding. When you define a Turing machine, you can pick any set of symbols you want for your alphabet. The model doesn't specify how they're represented. -- Greg -- https://mail.py

Re: Recommendation for Object-Oriented systems to study

2016-05-29 Thread Gregory Ewing
Alan Evangelista wrote: if the interest is learning OOP concepts (and not OOP in Python), IMHO Java is better. The problem with this is that if you're not careful you'll end up learning a lot of cruft that is irrelevant to Python. There's no clear distinction in Java between things that are es

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Gregory Ewing
jlada...@itu.edu wrote: So, how can I take the byte sequence <0x01 0x02 0x03 0x04 0x05 0x06 \n> that Serial.readline() returns to me, Using readline() to read binary data doesn't sound like a good idea -- what happens if one of the data bytes happens to be 0x0a? If you're going binary, it woul

Re: Don't put your software in the public domain

2016-06-01 Thread Gregory Ewing
Steven D'Aprano wrote: http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html From that: It might be ruled to create a global licence for unrestricted use. That > licence might or might not then be adjudicated to be revocable by subsequent > copyright owners (heirs, divorcing spouses

Re: Efficient handling of fast, real-time hex data

2016-06-01 Thread Gregory Ewing
jlada...@itu.edu wrote: One common data transmission error I've seen in other systems is added/dropped bytes. I may add a CRC-8 error-checking byte in place of the newline. Also maybe add a start byte with a known value at the beginning of each packet to help resynchronise if you get out of ste

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Gregory Ewing
Nagy László Zsolt wrote: I do not use diamond shapes in my hierarchy, I guess that does not affect me. I may be wrong. If there are no diamonds, there is no need to use super. Explicit inherited method calls, done correctly, will work fine. The only downside is that if your inheritance hierarc

Re: Multiple inheritance, super() and changing signature

2016-06-03 Thread Gregory Ewing
Ben Finney wrote: With classes all inheriting ultimately from ‘object’ (as all Python 3 classes do, and as all current Python 2 classes should), mutliple inheritance inevitably places your classes in a diamond inheritance pattern. That's usually harmless, though, because object provides very li

Re: Multiple inheritance, super() and changing signature

2016-06-04 Thread Gregory Ewing
Ian Kelly wrote: It can't belong to a subclass; the MRI guarantees that. But it's not necessarily a superclass either. Er, yes, what I really meant to say was that it could be a class that got introduced into the MRO as a result of someone else subclassing your class. So when you make a super

Re: Multiple inheritance, super() and changing signature

2016-06-04 Thread Gregory Ewing
Steven D'Aprano wrote: On Sat, 4 Jun 2016 11:06 am, Gregory Ewing wrote: there is no need to use super. Except then you are precluding others from integrating your classes into their class hierarchies. And if you *do* use super, you're precluding integrating them into other h

Re: I'm wrong or Will we fix the ducks limp?

2016-06-05 Thread Gregory Ewing
Random832 wrote: There *is* a variable called None [getattr(__builtins__, 'None')] which holds a leash tied to that puppy ... But nothing's special about the object itself, no more than any other object. The only special-ish thing about it is that it's unique -- there will never be another one

Re: I'm wrong or Will we fix the ducks limp?

2016-06-05 Thread Gregory Ewing
Steven D'Aprano wrote: The *name* "x" is an entity which is bound to (i.e. a reference to) the object 99, in some specific namespace, at some specific time. The name itself is an English word consisting of a single letter, "x". This is one reason why the term "name" is not good subsitute for th

Re: Operator precedence problem

2016-06-06 Thread Gregory Ewing
Peter Pearson wrote: c b a**(b**c) = a Also, in mathematical texts it's usually written with the c smaller than the b, and the b smaller than the a, which helps to make the precedence clear. We can't do that in Python, unforunately. Unless we allow writing the

Re: Operator precedence problem

2016-06-06 Thread Gregory Ewing
MRAB wrote: In Pascal, "and" has the same precedence as "*" and "or" has the same precedence as "+". Which was annoying, because it gave them higher precedence than the comparison operators, so instead of a = b and c > d you had to write (a = b) and (c > d) -- Greg -- https://mail.py

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Gregory Ewing
Steven D'Aprano wrote: Even if you were right that objects must exist at a single well-defined location, that is strictly irrelevant. That's implementation, not interface. We're talking about mental models. Sure, you could come up with some kind of Tardis-like mental model where objects exist i

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Gregory Ewing
Steven D'Aprano wrote: I never said that the string "x" is the same thing as the variable x. Maybe you didn't, but some people insist we shouldn't use the term "variable" when talking about python, but use "name" instead. I was pointing out that those two words don't have the same connotations

Re: I'm wrong or Will we fix the ducks limp?

2016-06-06 Thread Gregory Ewing
Steven D'Aprano wrote: I think I'm on fairly solid ground to say that a language that is just like C except that it allocates variables in a hash table at runtime, using runtime lookups for variable access, would not satisfy the C89 or C99 standards. I wouldn't be so sure about that. Modern C s

Re: I'm wrong or Will we fix the ducks limp?

2016-06-07 Thread Gregory Ewing
Marko Rauhamaa wrote: > [concerning leashed puppies] Note: no boxes! However, there are strings attached. Now you can truly *bind* objects to variables. If you wanted to really bind them good and proper, you'd use duct tape (or "duck tape" as some people call it -- arguably more appropriate in

Re: I'm wrong or Will we fix the ducks limp?

2016-06-07 Thread Gregory Ewing
Random832 wrote: Er, how would that make them not first class? They wouldn't be as transparent as references in C++, which you just assign to like any other variable. That works because C++ makes a distinction between initialisation and assignment. It's not so easy to separate those in Python.

Re: Want to play with or learn a parser system including a grammar for Python? See spark_parser on pypy

2016-06-08 Thread Gregory Ewing
Robin Becker wrote: "Python was conceived in the late 1980s[1] and its implementation was started in December 1989[2] by Guido van Rossum at CWI in the Netherlands" so that Aycocks's paper must have been at the -1st Python Conference When the time machine was invented, Guido thought it would

Re: for / while else doesn't make sense

2016-06-10 Thread Gregory Ewing
Steven D'Aprano wrote: I have a 2000 inch monitor, and by using a narrow proportional font set to 5pt, I can display the entire Python standard library including tests on screen at once. Then it's just a matter of using my trusty 4" reflecting telescope to zoom in on any part of the screen I like

Re: Overriding methods inherited from a superclass with methods from a mixin

2016-06-13 Thread Gregory Ewing
alanquei...@gmail.com wrote: I see that in most cases the order doesn't matter, but still I would think that since the correct order is from right to left, that should be the common practice. This order is only "correct" if overriding is what you want. That's not always going to be the case. Th

Re: base64.b64encode(data)

2016-06-13 Thread Gregory Ewing
Michael Torrie wrote: On 06/12/2016 11:16 PM, Steven D'Aprano wrote: Squirt it down a wire as bytes? Almost certainly. Sometimes yes. But not always. And even when the ultimate destination is a wire, a Python programmer is more likely to be accessing the wire through some high-level interf

Re: base64.b64encode(data)

2016-06-13 Thread Gregory Ewing
Chris Angelico wrote: Maybe what Python needs is an "ascii" type that's a subclass of both str and bytes, and requires that the contents be <0x80. It is text, so it can be combined with text strings; but it is also bytes, so when you combine it with bytes strings, it'll behave as most people expe

Re: value of pi and 22/7

2016-06-19 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: I feel a new phrase coming on: “good enough for Bible work”! I understand there's a passage in the Bible somewhere that uses a 1 significant digit approximation to pi... -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: value of pi and 22/7

2016-06-19 Thread Gregory Ewing
Ian Kelly wrote: Remember, the cubit was based on the length of the forearm, so it's not like it was a terribly precise measurement to begin with; Let's not sell them short. Just because it was based on a forearm doesn't mean they didn't have a precise standard for it, any more than people who

Re: best text editor for programming Python on a Mac

2016-06-19 Thread Gregory Ewing
Michael Vilain wrote: BBEdit has been around a long time and for it's price ($130) it does a lot but it's falling behind the times. New versions aren't really adding much in terms of new features. There's a free version of BBEdit called TextWrangler that's pretty good. I'm currently using it f

Re: best text editor for programming Python on a Mac

2016-06-19 Thread Gregory Ewing
Lawrence D’Oliveiro wrote: But not vi/vim. It only lets you place your cursor *on* a character, not *in-between* characters. That's because the terminals it was designed to work on didn't have any way of displaying a cursor between two characters. Emacs is the same (except it doesn't go as far

Re: value of pi and 22/7

2016-06-21 Thread Gregory Ewing
Marko Rauhamaa wrote: And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and a line of thirty cubits did compass it round about. [1 Kings 7:23] I think I know how that came about. It was actually filled with molt

Re: Operator Precedence/Boolean Logic

2016-06-25 Thread Gregory Ewing
Marko Rauhamaa wrote: The pile originally had -4 coconuts. The first sailor threw one to the monkey, leaving -5 coconuts in the pile. He took his share (-1 coconut) out and put the remaining -4 coconuts back in the big pile. Sounds a bit like Hawking radiation. A coconut-anticoconut p

Re: Can math.atan2 return INF?

2016-06-25 Thread Gregory Ewing
Steven D'Aprano wrote: China has just announced a new supercomputer that is so fast it can run an infinite loop in 3.7 seconds. They're lying. It has to be NaN seconds. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Can math.atan2 return INF?

2016-06-25 Thread Gregory Ewing
Marko Rauhamaa wrote: pdora...@pas-de-pub-merci.mac.com (Pierre-Alain Dorange): Near a black hole 3.7 seconds can last an infinite time... Which phenomenon prevents a black hole from ever forming. Yet astronomers keep telling us they are all over the place. Astronomers have observed objects

Re: Can math.atan2 return INF?

2016-06-25 Thread Gregory Ewing
Marko Rauhamaa wrote: pdora...@pas-de-pub-merci.mac.com (Pierre-Alain Dorange): For a scientific point of view, right. But tell this to the one that will be close to a blackhole ;-) Then, you'd better consult a priest than a scientist. But don't worry, you'll have an infinitely long time to

Re: Can math.atan2 return INF?

2016-06-26 Thread Gregory Ewing
Marko Rauhamaa wrote: The singularity being talked about there is an artifact of a particular coordinate system; the theory predicts that there is no *physical* singularity at the event horizon. That theory can't be tested even in principle, can it? Therefore, it is not scientific. It can in

Re: Assignment Versus Equality

2016-06-26 Thread Gregory Ewing
BartC wrote: On 26/06/2016 08:36, Lawrence D’Oliveiro wrote: One of Python’s few mistakes was that it copied the C convention of using “=” for assignment and “==” for equality comparison. One of C's many mistakes. Unfortunately C has been very influential. I'm not sure it's fair to call it

Re: Assignment Versus Equality

2016-06-26 Thread Gregory Ewing
BartC wrote: I did a year of it in the 1970s. Looks funny in lower case though. It's interesting how our perceptions of such things change. Up until my second year of university, my only experiences of computing had all been in upper case. Then we got a lecturer who wrote all his Pascal on the

Re: Assignment Versus Equality

2016-06-26 Thread Gregory Ewing
Christopher Reimer wrote: How can you not use chained assignments? I thought Python was the art of the clever one-liners. :) No, Python is the art of writing clever one-liners using more than one line. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Can math.atan2 return INF?

2016-06-27 Thread Gregory Ewing
Rustom Mody wrote: I said that for the Haskell list [0..] [0..] ++ [-1] == [0..] He said (in effect) yes that -1 would not be detectable but its still there! The code to generate it is there, but it will never be executed, so the compiler is entitled to optimise it away. :-) He may have a po

Re: Can math.atan2 return INF?

2016-06-27 Thread Gregory Ewing
Marko Rauhamaa wrote: We cannot get any information on black holes proper because black holes cannot come into existence according to the very theory that predicts black holes. It will take infinitely long for an event horizon to form. Only in some frames of reference. By your reasoning, Zeno'

Re: Assignment Versus Equality

2016-06-27 Thread Gregory Ewing
BartC wrote: You mean the rationale was based on saving keystrokes? Maybe disk space as well -- bytes were expensive in those days! -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Assignment Versus Equality

2016-06-27 Thread Gregory Ewing
Dennis Lee Bieber wrote: Or my favorite example of a parser headache: which is the loop instruction and which is the assignment DO10I=3,14 DO 10 I = 3.14 And if the programmer and/or compiler gets it wrong, your spacecraft crashes into the planet. -- Greg -- https://ma

Re: Assignment Versus Equality

2016-06-28 Thread Gregory Ewing
BartC wrote: On 27/06/2016 23:45, Lawrence D’Oliveiro wrote: FORMAT(...complex expression with lots of nested parentheses...) = You just design the compiler to do the same processing in each case, ie. parse a followed (), then mark the result AST fragment as either an Array term, or Fo

Re: Assignment Versus Equality

2016-06-29 Thread Gregory Ewing
Marko Rauhamaa wrote: -- / \ / (almost) \ N |black || | hole |S \/ \ / -- / / compass needle / The compass needle shows that the probe is "frozen" and won'

Re: Can math.atan2 return INF?

2016-06-29 Thread Gregory Ewing
Marko Rauhamaa wrote: By the time the event horizon hits Tim at the speed of light, Tim will have received all of our Universe's signals at an ever accelerating frequency and increasing power. He will have seen the End of the World before leaving it. I don't think that's right. From the point o

A nestedmodule decorator (Re: Namespaces are one honking great idea)

2016-07-05 Thread Gregory Ewing
Steven D'Aprano wrote: There's only so far I can go without support from the compiler. It turns out one can go surprisingly far. Here's something I cooked up that seems to meet almost all the requirements. The only shortcoming I can think of is that a nestedmodule inside another nestedmodule wo

Improved nestedmodule decorator implementation

2016-07-05 Thread Gregory Ewing
I wrote: The only shortcoming I can think of is that a nestedmodule inside another nestedmodule won't be able to see the names in the outer nestedmodule Actually, that's not correct -- the version I posted before actually crashes if you try to refer to a name in an outer nestedmodule from an in

Re: Curious Omission In New-Style Formats

2016-07-11 Thread Gregory Ewing
I seem to remember Guido stating once that a design principle of the new formatting system was for the part after the colon to be the same as what you would put in an equivalent %-format, to make it easy for people to switch between them. If that principle still stands, then this would seem to be

Re: Curious Omission In New-Style Formats

2016-07-11 Thread Gregory Ewing
Ethan Furman wrote: I will readily admit to not having a maths degree, and so of course to me saying the integer 123 has a precision of 5, 10, or 99 digits seems like hogwash to me. Seems to me insisting that the number after the dot be called "precision" in all cases is imposing a foolish con

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-19 Thread Gregory Ewing
Gene Heskett wrote: The theory of relativity says that the faster you are going, the more massive you become. It doesn't, really. The equations only seem to say that if you insist on keeping the Newtonian definitions of momentum and kinetic energy in the context of relativity, which is a silly

Re: What exactly is "exact" (was Clean Singleton Docstrings)

2016-07-20 Thread Gregory Ewing
Random832 wrote: Well, your amp hours will be shittier with a lower voltage. Define "shittier". An incandescent flashlight (which consumes less power at lower voltage) will last longer, but won't be as bright. If it's still acceptably bright, that's not worse. I think the point is that the ce

Re: Why not allow empty code blocks?

2016-07-24 Thread Gregory Ewing
BartC wrote: On 24/07/2016 14:24, Chris Angelico wrote: No, it's an example of how *mixing tabs and spaces* can go wrong. And in fact will always go wrong unless you legislate the width of a tab. That's easy to say. How do you actually ensure that they aren't mixed? The software may not high

Re: Why not allow empty code blocks?

2016-07-24 Thread Gregory Ewing
BartC wrote: (They don't need to be elaborate to start being confusing. Take 'int *a[]' and 'int (*a)[]'; one of these is an array of pointers, the other a pointer to an array. Quite different! But which is which? Where have you seen 'int (*a)[]' used? I don't think I've ever seen any real-lif

Re: Why not allow empty code blocks?

2016-07-26 Thread Gregory Ewing
BartC wrote: (Yes everyone uses T*a (pointer to T) instead of T(*a)[] (pointer to array of T), because, thanks to how C mixes up deferencing and indexing, the former can be accessed as a[i] instead of (*a)[i]. But it's wrong, and leads to errors that the language can't detect. Such as when a

Re: Why not allow empty code blocks?

2016-07-26 Thread Gregory Ewing
BartC wrote: But otherwise free-flowing English text is not a good comparison with a programming language syntax. I think Python is more like poetry. -- roses are red violets are blue is this the end of the poem no-one can tell because there is no end marker thus spake the bdfl -- https://mail

Re: Why not allow empty code blocks?

2016-07-26 Thread Gregory Ewing
Marko Rauhamaa wrote: int a[3]; > a produces a pointer to the array's first element. Yes, and that makes using true pointer-to-array types in C really awkward. You're fighting against the way the language was designed to be used. If you use a language in an un-idiomatic way, you can't

Re: Why not allow empty code blocks?

2016-07-30 Thread Gregory Ewing
Michael Torrie wrote: Python would have been alright to teach "programming," but to teach the actual theory of programming languages (lambda calculus, lists as a foundation unit for all other data structures) I wouldn't say that "lists as a foundation unit for all other data structures" is (or

Re: Why not allow empty code blocks?

2016-07-30 Thread Gregory Ewing
Chris Angelico wrote: So do I need to be able to "call a function as if it were a procedure", or is there a stark difference between the two types of callable? Well, Pascal makes a stark distinction between them -- it's a compile-time error to call a procedure as though it were a function or vi

Re: Why not allow empty code blocks?

2016-07-30 Thread Gregory Ewing
Chris Angelico wrote: I mean, "for i in 3.5" should start half way down the loop body, complete that loop, and then do three complete loops. +1, this is the best idea for a "loop-and-a-half" construct I've ever seen. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Why not allow empty code blocks?

2016-07-30 Thread Gregory Ewing
Steven D'Aprano wrote: In English, we can talk about having a quick meal of fast food, but not a fast meal of quick food. If you interpret "quick" in its original sense of "alive" then it's theoretically possible, although not practised much in civilised society these days. Yoghurt might qualif

Re: Why not allow empty code blocks?

2016-07-31 Thread Gregory Ewing
Steven D'Aprano wrote: It has always perplexed me that Lisp's prefix notation is held up as the /sine qua non/ of elegance and power, while Forth is ignored if not ridiculed. The reason Lisp is easier to program in than Forth is not because of prefix vs. postfix. It's because in Lisp a function

Re: Python slang

2016-08-06 Thread Gregory Ewing
Ian Kelly wrote: (not grammar, since "myself" is grammatically correct) Not sure about that. "Myself" is a reflexive pronoun, used when the subject and object of a verb are the same. So "I did this research by myself" is correct. But if Bob is involved, the subject and object are different, so

Re: zeroed out

2018-12-12 Thread Gregory Ewing
MRAB wrote: Later processors have a DAS instruction, which is used after BCD subtraction. The humble 6502 doesn't have DAA/DAS, but instead has a decimal mode flag. The 68000 also had a Decimal Add instruction, but disappointingly it only worked a byte at a time. I guess running COBOL at high

Re: sampling from frequency distribution / histogram without replacement

2019-01-14 Thread Gregory Ewing
duncan smith wrote: Hello, Just checking to see if anyone has attacked this problem before for cases where the population size is unfeasibly large. The fastest way I know of is to create a list of cumulative frequencies, then generate uniformly distributed numbers and use a binary search

Re: the python name

2019-01-16 Thread Gregory Ewing
Avi Gross wrote: The question that seems to come up too often about the python name is a distraction. In particular, it is answered fairly prominently in many places as just being a nonsensical name because a founder once liked a comedic entity that chose an oddball name, so they did too. That

Re: the python name

2019-01-16 Thread Gregory Ewing
Dennis Lee Bieber wrote: Getting too close to REXX (which was something like Restructured EXtended eXecutor). And if we continue the theme of dinosaur evolution, we end up with Tyrannosaurus REXX. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: the python name

2019-01-18 Thread Gregory Ewing
DL Neil wrote: (not that New Zealanders need to know much about snakes!) Probably recommended when we visit Australia, though. Also we seem to have imported some of their spiders in recent years, so it's only a matter of time before their snakes follow. I wonder if we could get Australia to p

Re: Convert a list with wrong encoding to utf8

2019-02-14 Thread Gregory Ewing
vergos.niko...@gmail.com wrote: I just tried: names = tuple( [s.encode('latin1').decode('utf8') for s in names] ) but i get UnicodeEncodeError('latin-1', 'Άκης Τσιάμης', 0, 4, 'ordinal not in range(256)') This suggests that the string you're getting from the database *has* already been correc

Re: Convert a list with wrong encoding to utf8

2019-02-15 Thread Gregory Ewing
vergos.niko...@gmail.com wrote: [python] con = pymysql.connect( db = 'clientele', user = 'vergos', passwd = '**', charset = 'utf8' ) cur = con.cursor() [/python] From that i understand that the names being fetched from the db to pyhton script are being fetced as utf8, right? No, I don't th

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-15 Thread Gregory Ewing
Avi Gross wrote: I can see why you may be wondering. You see the nan concept as having a specific spelling using all lowercase and to an extent you are right. No, he's talking about this particular line from the transcript you posted: >>>float(" nan") > Nan This suggests that the interpreter

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