Re: What is a mechanism equivalent to "trace variable w ..." in Tcl for Python?

2016-09-30 Thread Random832
On Fri, Sep 30, 2016, at 14:42, Ned Batchelder wrote: > On Friday, September 30, 2016 at 2:16:10 PM UTC-4, Les Cargill wrote: > > What is an equivalent mechanism in Python? > > There's no way* to hook into "x = 2", but you could hook into "x.a = 2" > if you wanted do, by defining __setattr__ on x'

Re: Expression can be simplified on list

2016-09-29 Thread Random832
On Thu, Sep 29, 2016, at 02:47, Rustom Mody wrote: > Your example is exactly what I am saying; if a type has a behavior in > which all values are always True (true-ish) its a rather strange kind > of bool-nature. For a given type T, if all objects of type T are true (true-ish, truthy, whatever), i

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Random832
On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote: > What "allows side effects" in languages like Haskell is the fact that the > runtime behaviour of the language is not defined as "calculating the > value of the main function" but rather as "making the process that the > main functon defines as an

Re: Can this be easily done in Python?

2016-09-27 Thread Random832
On Tue, Sep 27, 2016, at 15:58, TUA wrote: > Is the following possible in Python? > > Given how the line below works > > TransactionTerms = 'TransactionTerms' > > > have something like > > TransactionTerms = > > that sets the variable TransactionTerms to its own name as string > representati

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Random832
On Thu, Sep 22, 2016, at 09:45, eryk sun wrote: > On Thu, Sep 22, 2016 at 12:40 PM, Gregory Ewing > wrote: > > eryk sun wrote: > >> > >> Actually in a Unix terminal the cursor can also be at > >> the end of a line, but a bug in Python requires pressing Ctrl+D twice > >> in that case. > > > > I wou

Re: Linear Time Tree Traversal Generator

2016-09-21 Thread Random832
On Wed, Sep 21, 2016, at 10:39, ROGER GRAYDON CHRISTMAN wrote: > Which only highlights my disappointment that my tree > traversal itself was O(n log n), unless I gave up on yield. Or you can give up on recursion. Recursive tree traversal is generally associated with passing in a callback in rather

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 23:34, Steve D'Aprano wrote: > One of us is badly missing something. The problem is the number of times next is called. Here, it'll be more clear if we wrap the iterator in the original example to print each time next is called. class WrappedIterator(): def __init__(s

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 22:34, Steve D'Aprano wrote: > I'm afraid I don't understand this. This is a standard binary tree > inorder traversal. Each node is visited once, and there are N nodes, > so I make that out to be O(N) not O(N log N). I'm afraid I can't parse > your final clause: > > "si

Re: What does this zip() code mean?

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 09:19, 38016226...@gmail.com wrote: > >>> x = [1, 2, 3] > >>> y = [4, 5, 6] > >>> zipped = zip(x, y) > >>> list(zipped) > [(1, 4), (2, 5), (3, 6)] > >>> x2, y2 = zip(*zip(x, y)) > >>> x == list(x2) and y == list(y2) > True > > My problem is >>> x2, y2 = zip(*zip(x, y)). >

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Random832
On Thu, Sep 15, 2016, at 15:31, Steve D'Aprano wrote: > Light follows geodesics, not straight lines. What is a straight line on a curved space if not a geodesic? That was actually what I was getting at. -- https://mail.python.org/mailman/listinfo/python-list

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-15 Thread Random832
On Thu, Sep 15, 2016, at 15:06, Steve D'Aprano wrote: > No, the horizon would still be horizontal. It merely wouldn't *look* > horizontal, an optical illusion. I guess that depends on your definition of what a horizon is - and what a straight line is, if not the path followed by a beam of light. -

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread Random832
On Wed, Sep 14, 2016, at 23:12, Steve D'Aprano wrote: > Yes it does. Even an infinitely large flat plane has a horizon almost > identical to the actual horizon. Your link actually doesn't support the latter claim, it goes into some detail on why it wouldn't if it were infinitely large due to gravi

Re: How to extend a tuple of tuples?

2016-09-13 Thread Random832
On Mon, Sep 12, 2016, at 17:29, Chris Angelico wrote: > old_id = id(a) > a += something > if id(a) == old_id: > print("We may have an optimization, folks!") > > But that can have false positives. If two objects do not concurrently > exist, they're allowed to have the same ID number. But the t

Re: What you can do about legalese nonsense on email (was: How to split value where is comma ?)

2016-09-08 Thread Random832
On Thu, Sep 8, 2016, at 18:13, Grant Edwards wrote: > After all, that boilerplate just makes the corporation look stupid and > incompetent. Any email that leaves the corporate network must be > assumed to be visible to world+dog. Anybody who thinks differently is > deluded and should not be allow

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread Random832
On Fri, Sep 2, 2016, at 15:12, Christian Gollwitzer wrote: > Tradition? All languages I know of treat a number with an exponent as > floating point. Scheme does allow you to give integers (and rationals) in decimal and/or exponential notation with the "#e" prefix. -- https://mail.python.org/mail

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread Random832
On Fri, Sep 2, 2016, at 13:02, Marco Sulla wrote: > On Fri, Sep 2, 2016 at 6:17 PM, Random832 wrote: > > Trying to add 1 gets it rounded off again, and the value is simply > > printed as 1e+26 by default because this is the shortest representation > > that gives the

Re: Strange behaviour with numbers in exponential notation

2016-09-02 Thread Random832
On Fri, Sep 2, 2016, at 11:51, Marco Sulla wrote: > >>> 10**26 - 1 > 99 > >>> 1e26 - 1 > 1e+26 > > > Why? Exponential notation creates floating point numbers, which have a limited amount of precision in binary. Specifically (on my system which, as most modern computer

Re: Python slang

2016-09-02 Thread Random832
On Wed, Aug 10, 2016, at 12:19, Random832 wrote: > On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: > > The use of = also has a long history... FORTRAN (where the > > comparison was .EQ.), BASIC (granted, K&K required assignment to > > start with the k

Re: Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Random832
On Mon, Aug 29, 2016, at 11:14, Chris Angelico wrote: > Please don't. :) This is something that belongs in the application; > it's somewhat hacky, and I don't see any benefit to it going into the > language. For one thing, I could well imagine making the fallback > encoding configurable (it isn't c

Magic UTF-8/Windows-1252 encodings

2016-08-29 Thread Random832
Directing this to python-list because it's really not on the topic of the idea being discussed. On Mon, Aug 29, 2016, at 05:37, Chris Angelico wrote: > Suppose I come to python-ideas and say "Hey, the MUD community would > really benefit from a magic decoder that would use UTF-8 where > possible,

Re: integer's methods

2016-08-27 Thread Random832
On Sat, Aug 27, 2016, at 13:24, Grant Edwards wrote: > Becuase the parser thinks you've entered a floating point number with > a fractional part of "bit_length". 123.+456 doesn't think that the fractional part is "+456". (Of course, the real reason is "because it would be even more annoying to ge

Re: The order of iterable de-referencing in assignment?

2016-08-24 Thread Random832
On Wed, Aug 24, 2016, at 07:17, Chris Angelico wrote: > Objects/listobject.c:795 > > /* Special cases: >1) lists and tuples which can use PySequence_Fast ops >2) extending self to self requires making a copy first > */ And, of course, it is a special case - a.extend(iter(a

Re: degrees and radians.

2016-08-23 Thread Random832
On Wed, Aug 24, 2016, at 00:26, Gary Herron wrote: > Perhaps I'm not understanding what you mean by "clunky", but this seems > pretty clean and simple to me. The original post is from 2002, I don't know why it got a reply just now. -- https://mail.python.org/mailman/listinfo/python-list

Re: Dynamically import specific names from a module vs importing full module

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 16:21, Malcolm Greene wrote: > Python 3.5: Is there a way to dynamically import specific names from a > module vs importing the full module? > > By dynamic I mean via some form of importlib machinery, eg. I'm looking > for the dynamic "from import " equivalent of "import

Re: The dangerous, exquisite art of safely handing user-uploaded files: Tom Eastman (was: Does This Scare You?)

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 11:40, Chris Angelico wrote: > Windows has some other issues, including that arbitrary files can > become executable very easily (eg if %PATHEXT% includes its file > extension), and since the current directory is always at the beginning > of your path, this can easily turn

Re: The dangerous, exquisite art of safely handing user-uploaded files: Tom Eastman (was: Does This Scare You?)

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 10:21, Ben Finney wrote: > So yes, filenames from arbitrary sources should be *completely* > untrusted, and never used to access any file on the system. Throw the > entire filename away and make a filename locally, without using any part > of the original name. To be fair,

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 09:21, Steve D'Aprano wrote: > Rather, you just use the features you rely on, document the minimum > supported version, and if somebody is silly enough to try running your > code > under Python 1.4, they'll get a SyntaxError or an exception when you try > to > do something

Re: Does This Scare You?

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 08:39, Chris Angelico wrote: > Nope. On Windows, you would try/except it. No, you can't, because the failure mode often isn't "file refuses to open" but "data is written to a serial port". There are myriad other ways > something could fail, and the only correct action is

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-22 Thread Random832
On Mon, Aug 22, 2016, at 08:44, Chris Angelico wrote: > However, I don't think it's particularly necessary. Explicit version > number checks should be very rare, and shouldn't be encouraged. > Instead, encourage feature checks, as Steve gave some examples of. The problem is when you want to write

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Random832
On Mon, Aug 22, 2016, at 02:03, Stefan Behnel wrote: > Steven D'Aprano schrieb am 22.08.2016 um 07:35: > > if sys.version < '3': > > import mymodule2 as mymodule > > else: > > import mymodule3 as mymodule > > This condition is going to fail when Python 30.0 comes out. Er, won't it rather

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Random832
On Mon, Aug 22, 2016, at 01:35, Steven D'Aprano wrote: > Could somebody (the OP?) please explain what is the purpose of this > proposal, what it does, how it works, and when would people use it? I think what he wants is a way for a module which uses features (syntactic or otherwise, but I suppose

Re: saving octet-stream png file

2016-08-20 Thread Random832
On Sat, Aug 20, 2016, at 03:50, Marko Rauhamaa wrote: > 2'scomplement arithmetics is quite often taken advantage of in C > programming. Unfortunately, with the castration of signed integers with > the most recent C standards, 2's-complement has been dangerously broken. No part of any version of th

Re: saving octet-stream png file

2016-08-19 Thread Random832
On Fri, Aug 19, 2016, at 21:09, Steve D'Aprano wrote: > Depends what you mean by "byte", but the short answer is "Yes". > > In the C/C++ standard, bytes must be at least eight bytes. As the below > FAQ > explains, that means that on machines like the PDP-10 a C++ compiler will > define bytes to be

Re: saving octet-stream png file

2016-08-19 Thread Random832
On Fri, Aug 19, 2016, at 16:51, Lawrence D’Oliveiro wrote: > On Saturday, August 20, 2016 at 6:03:53 AM UTC+12, Terry Reedy wrote: > > > > An 'octet' is a byte of 8 bits. > > Is there any other size of byte? Not very often anymore. Used to be some systems had 9-bit bytes, and of course a lot of c

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread Random832
On Wed, Aug 17, 2016, at 14:27, Terry Reedy wrote: > That particular syntax was not really considered. At least 10 versions > using 'if', 'then', 'else', and other tokens were. > > They all had the problem of requiring a new keyword such as 'then' or > some other innovation. Why not just if(co

Re: Python slang

2016-08-14 Thread Random832
On Wed, Aug 10, 2016, at 19:57, Michael Torrie wrote: > But the grammar must still be a bit complex as sometimes the LHS of the > = is an expression, as well as the RHS. The only place that an *arbitrary* expression (including e.g. = as equality) can appear in the LHS is inside parentheses, otherw

Re: Python slang

2016-08-10 Thread Random832
On Wed, Aug 10, 2016, at 07:59, Dennis Lee Bieber wrote: > The use of = also has a long history... FORTRAN (where the comparison > was .EQ.), BASIC (granted, K&K required assignment to start with the > keyword LET, so the use of = was mainly a delimiter between target and > expression being a

Re: cmd prompt does not recognizes python command on Windows 7

2016-08-10 Thread Random832
On Wed, Aug 10, 2016, at 06:34, eryk sun wrote: > On Wed, Aug 10, 2016 at 4:46 AM, wrote: > > > > i have installed python 3.5 , but the python command is not recognized > > > > C:\Users\sharmaaj>python > > 'python' is not recognized as an internal or external command, > > operable program or batc

Re: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Random832
On Tue, Aug 9, 2016, at 16:51, Juan Pablo Romero Méndez wrote: > So as the writer of the function you expect the user to read the function > body to determine what is safe to pass or not? How about expecting them to read the docstring? -- https://mail.python.org/mailman/listinfo/python-list

Re: Running Python from the source repo

2016-08-08 Thread Random832
On Mon, Aug 8, 2016, at 15:25, Terry Reedy wrote: > Last January, I wrote a batch file to build all three versions with the > 'optional' extensions. I started rebuilding more often after this. > > 36\pcbuild\build.bat -e -d > 35\pcbuild\build.bat -e -d > 27\pcbuild\build.bat -e -d > > Thanks fo

Re: Python slang

2016-08-05 Thread Random832
On Fri, Aug 5, 2016, at 20:14, Dennis Lee Bieber wrote: > .push() tends to make this one think "stack" and not general purpose > list. It's a bit unusual to have .pop() without a matching .push(). -- https://mail.python.org/mailman/listinfo/python-list

Re: Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-04 Thread Random832
On Thu, Aug 4, 2016, at 15:22, Malcolm Greene wrote: > Hi Chris, > > Thanks for your suggestions. I would like to capture the specific bad > codes *before* they get replaced. So if a line of text has 10 bad codes > (each one raising UnicodeError), I would like to track each exception's > bad code

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Random832
On Wed, Aug 3, 2016, at 11:09, Peter Otten wrote: > I'm unsure about this myself -- wouldn't it be better to detach the > underlying raw stream? Like Well, "better" depends on your point of view. > The ValueError raised if you try to write to the original stdout > looks like a feature to me. Ma

Re: print() function with encoding= and errors= parameters?

2016-08-03 Thread Random832
On Wed, Aug 3, 2016, at 08:29, Malcolm Greene wrote: > Looking for a way to use the Python 3 print() function with encoding and > errors parameters. > > Are there any concerns with closing and re-opening sys.stdout so > sys.stdout has a specific encoding and errors behavior? Would this break > oth

Re: Procedures and functions [was Re: Why not allow empty code blocks?]

2016-07-30 Thread Random832
On Sun, Jul 31, 2016, at 00:01, D'Arcy J.M. Cain wrote: > On Sun, 31 Jul 2016 13:32:16 +1000 > Steven D'Aprano wrote: > > Many beginners make the mistake of writing: > > > > mylist = mylist.sort() > > > > or try to write: > > > > mylist.sort().reverse() > > > > If we had procedures, that would

Re: Why not allow empty code blocks?

2016-07-30 Thread Random832
On Sat, Jul 30, 2016, at 22:17, Chris Angelico wrote: > Yeah. The distinction means you have a fundamental API difference > between the procedures (which don't return anything) and the functions > (whose return values you mightn't care about). Not really any more than between functions returning d

Re: Why not allow empty code blocks?

2016-07-30 Thread Random832
On Sat, Jul 30, 2016, at 22:10, Steven D'Aprano wrote: > "while True" doesn't merely emulate an infinite loop, it implements an > infinite loop without needing dedicated syntax, byte-code or > implementation. Er, it's not like it would need dedicated byte code anyway. The bytecode of an infinite

Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2.

2016-07-28 Thread Random832
On Thu, Jul 28, 2016, at 11:47, Enjoys Math wrote: > So what's the proper way to get the return value of an exec call when > there is one? Exec calls do not have return values. If you need to pass an object out of the exec call to the surrounding context, you can wrap it in an exception and throw

Re: Can Python learn from Perl? Perl 5 can now run Perl 6 code

2016-07-28 Thread Random832
On Thu, Jul 28, 2016, at 03:21, Steven D'Aprano wrote: > Well, kinda sorta. I'm not really pulling your leg. But Perl has a > feature that if you tell it to run a file with a hashbang line, it > will call the given executable to run that file. That's now been > improved to recognise Perl6 as an ext

Re: Why not allow empty code blocks?

2016-07-25 Thread Random832
On Sun, Jul 24, 2016, at 18:13, 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? int (*a)[]; === int x[]; where x is (*a). To

Re: learning python. learning defining functions . need help

2016-07-22 Thread Random832
On Fri, Jul 22, 2016, at 11:21, justin walters wrote: > Try opening the interactive terminal on your command line and type the > following: > > type({}) == dict() > > That should illustrate why. That doesn't illustrate anything relevant at all. The reason this is false is because dict() is

Re: Just starting to learn Python, and encounter a problem

2016-07-22 Thread Random832
On Fri, Jul 22, 2016, at 09:59, Zagyen Leo wrote: > yeah, it may be quite simple to you experts, but hard to me. > > In one of exercises from the Tutorial it said: "Write a program that asks > the user their name, if they enter your name say "That is a nice name", > if they enter "John Cleese" o

Re: reversed(enumerate(x))

2016-07-20 Thread Random832
On Wed, Jul 20, 2016, at 13:42, Ian Kelly wrote: > I had occasion to write something like this: > > for i, n in reversed(enumerate(x)): pass > > How would you write this? I'd write my own version of enumerate with a step argument, and call enumerate(reversed(x), start=len(x), step=-1) -- ht

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

2016-07-20 Thread Random832
On Wed, Jul 20, 2016, at 03:16, Marko Rauhamaa wrote: > Random832 : > > Typically their capacity is labeled in amp-hours. > > Did you really see that labeled on the (nonrechargeable AA) battery? Sorry, I must have imagined that. Anyway, my point was that the reality is too compli

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

2016-07-19 Thread Random832
On Tue, Jul 19, 2016, at 18:17, Marko Rauhamaa wrote: > I'd love it if batteries were priced per joule, or even per > kilowatt-hour. Typically their capacity is labeled in amp-hours. You have to know your devices to know if the voltage difference between different battery types (Which ranges from

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

2016-07-18 Thread Random832
On Mon, Jul 18, 2016, at 01:37, Rustom Mody wrote: > The INTENTION is that in addition to capturing the usual number tower > ℕ ⊂ ℤ ⊂ ℝ (or parts therefore) Well, ℚ. You hardly ever see representations of numbers that are in ℝ-ℚ. > scheme also captures ORTHOGONALLY (word in the docs) the (in)exact

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

2016-07-18 Thread Random832
On Mon, Jul 18, 2016, at 00:46, Ben Finney wrote: > What is “those”? The measurement is imprecise, the observations are > inexact. > > It makes no sense to say that a number is inexact. Exactness is not a > property of a number. There's no reason it shouldn't be a property of an object of a numer

Re: Clean Singleton Docstrings

2016-07-17 Thread Random832
On Sun, Jul 17, 2016, at 03:51, Chris Angelico wrote: > Currently yes, you can choose to use fractions.Fraction and pay the > price. How, if you have a single type with different representations, > can you make that choice? Sorry, I forgot to answer your question. Though, your implicit claim that

Re: Clean Singleton Docstrings

2016-07-17 Thread Random832
On Sun, Jul 17, 2016, at 03:51, Chris Angelico wrote: > > True, although the programmer has control over the feature. If you > > *want* the luxury of exact fractions, you pay the price. If you don't, > > you make the numbers inexact. > > Not if you have a single "Number" type: Saying that exact a

Re: Clean Singleton Docstrings

2016-07-16 Thread Random832
On Sat, Jul 16, 2016, at 03:27, Chris Angelico wrote: > Will an "Exact" non-integer be stored as Decimal or > Fraction? How do you know? They have vastly different semantics, and > you should be able to choose. Er, the point is for them to _not_ have different semantics. A decimal storage format w

Re: Clean Singleton Docstrings

2016-07-16 Thread Random832
On Sat, Jul 16, 2016, at 02:29, Chris Angelico wrote: > The difference between ints and floats can lead to bugs, too. Which > one should we eliminate? Eliminate both of them. Move to a single abstract numeric type* a la Scheme, with an "inexact" attribute (inexact numbers may or may not be represe

Re: math.frexp

2016-07-15 Thread Random832
On Fri, Jul 15, 2016, at 12:32, Steven D'Aprano wrote: > I can take the geometric mean of: > > [2.0**900, 2.0**920, 2.0**960, 2.0**980, 2.0**990] > > and get to within a relative error of 1e-14 of the correct answer, > 2**950: > > py> geometric_mean([2.0**900, 2.0**920, 2.0**960, 2.0**980, 2.0*

Re: Curious Omission In New-Style Formats

2016-07-15 Thread Random832
On Fri, Jul 15, 2016, at 07:44, Antoon Pardon wrote: > No, that is what people come up with afterwards. If you just start a > conversation about how people learn and how long it would take to get > some mastery and how we could present progress in a graph, virtually > everyone uses the conventio

Re: subprocess: xterm -c cat, need to send data to cat and have it displayed in the xterm window

2016-07-12 Thread Random832
On Tue, Jul 12, 2016, at 02:27, Steven D'Aprano wrote: > On Tuesday 12 July 2016 13:20, Veek. M wrote: > > I then need to get it translated which also works and then display in > > XTerm using cat. > > Why not just print it? Why do you have to use cat? Well, displaying something in a new xterm (i

Re: What is precision of a number representation?

2016-07-12 Thread Random832
On Tue, Jul 12, 2016, at 02:21, Steven D'Aprano wrote: > If not, then what are the alternatives? Using str.format, how would > you get the same output as this? > > > py> "%8.4d" % 25 > '0025' "%04d" % 25 "%8s" % ("%04d" % 25) The latter (well, generally, "format it how you want and the

Re: Curious Omission In New-Style Formats

2016-07-11 Thread Random832
On Mon, Jul 11, 2016, at 16:06, Michael Torrie wrote: > I'm not sure I've ever seen a negative hex number in the wild. Usually > when I view a number in hex I am wanting the raw representation. -0x123 > with a width of 7 would be 0xFFEDD There's nothing "raw" about python int objects. To get what

Re: Quick poll: gmean or geometric_mean

2016-07-10 Thread Random832
On Sun, Jul 10, 2016, at 10:55, Ian Kelly wrote: > force_N = -G * mass1_kg * mass2_kg / distance_m ** 2 > > I'm fine with "G" as is because it's the standard name for the value > in physics contexts, and it's presumably defined in the code as a > constant. It's every bit as clear as "pi". Shouldn

Re: Quick poll: gmean or geometric_mean

2016-07-08 Thread Random832
On Sat, Jul 9, 2016, at 01:26, Steven D'Aprano wrote: > hmean and gmean > > harmonic_mean and geometric_mean The latter, definitely. > Remember that the arithmetic mean is just called "mean". so? (also maybe it shouldn't be?) -- https://mail.python.org/mailman/listinfo/python-list

Re: Two curious errors when function globals are manipulated

2016-07-05 Thread Random832
On Tue, Jul 5, 2016, at 11:50, Steven D'Aprano wrote: > If PyDict_SetItem expects an actual dict (accept no substitutes or > subclasses), why is there no error? I would have expected a segfault at > worst or at least an exception. Subclasses are fine. Sort of. In general if you pass a *subclass* o

Re: Well, I finally ran into a Python Unicode problem, sort of

2016-07-03 Thread Random832
On Sun, Jul 3, 2016, at 21:15, Lawrence D’Oliveiro wrote: > On Monday, July 4, 2016 at 12:40:14 PM UTC+12, BartC wrote: > > The structure of such a parser doesn't need to exactly match the grammar > > with a dedicated block of code for each operator precedence. It can be > > table-driven so that

Re: Well, I finally ran into a Python Unicode problem, sort of

2016-07-03 Thread Random832
On Sun, Jul 3, 2016, at 20:00, Lawrence D’Oliveiro wrote: > That would be neat. But remember, you would have to define the operator > precedence as well. So you could no longer use a recursive-descent > parser. You could use a recursive-descent parser if you monkey-patch the parser when adding a n

Re: Well, I finally ran into a Python Unicode problem, sort of

2016-07-03 Thread Random832
On Sun, Jul 3, 2016, at 07:22, Marko Rauhamaa wrote: > Christian Gollwitzer : > > Am 03.07.16 um 13:01 schrieb Marko Rauhamaa: > >> Scheme allows *any* characters whatsoever in identifiers. > > > > Parentheses? > > Yes. > > Hint: Python allows *any* characters whatsoever in strings. Being able t

Re: Namespaces are one honking great idea

2016-07-01 Thread Random832
On Fri, Jul 1, 2016, at 21:50, Kevin Conway wrote: > I believe the namespace object you are referring to is exactly a > class. IIRC, classes came about as a "module in a module". No, because classes have instances. And conceptually they seem like they *should* have instances. Just using the term "

Re: Namespaces are one honking great idea

2016-07-01 Thread Random832
On Fri, Jul 1, 2016, at 10:13, Steven D'Aprano wrote: > The biggest limitation is that I have to abuse the class statement to do > this. In an ideal world, there would be syntactic support and a keyword: > > namespace Example: > x = 0 > y = [] > def test(n): ... > > al

Re: Were is a great place to Share your finished projects?

2016-06-30 Thread Random832
On Thu, Jun 30, 2016, at 19:06, Lawrence D’Oliveiro wrote: > On Friday, July 1, 2016 at 1:09:31 AM UTC+12, Christian Gollwitzer wrote: > > Github makes that extremely easy, just create an account, create a repo, > > "git pull" and start working. Your incremental changes will be updated > > with e

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Random832
On Thu, Jun 30, 2016, at 00:12, Steven D'Aprano wrote: > I tried to find the actual implementation of os.abort(), but I > couldn't work out where it was or what it does. Can somebody > enlighten me? It's in posixmodule.c, it calls abort(), which is a standard C function, equivalent to killing the

Re: "for/while ... break(by any means) ... else" make sense?

2016-06-29 Thread Random832
On Wed, Jun 29, 2016, at 22:26, Rustom Mody wrote: > > os.kill(os.getpid(), 9) > > > > Now THAT is the hardest way to abort. You ain't comin' back from > > this one! > > Is it? > > | On Windows, signal() can only be called with SIGABRT, SIGFPE, > | SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError

Re: Can math.atan2 return INF?

2016-06-29 Thread Random832
On Wed, Jun 29, 2016, at 05:35, Steven D'Aprano wrote: > Although their perspectives are very different, neither is "more > right" than the other. I think usually the idea that there are "no privileged frames of reference" doesn't go so far as to include ones from which it is impossible to send in

Re: Assignment Versus Equality

2016-06-28 Thread Random832
On Tue, Jun 28, 2016, at 22:27, Steven D'Aprano wrote: > Are you suggesting that email clients and newsreaders should silently > mangle the text of your message behind your back? Because that's what > it sounds like you're saying. That was how I was characterizing Rustom Mody's position; he seemed

Re: Assignment Versus Equality

2016-06-28 Thread Random832
On Tue, Jun 28, 2016, at 12:39, Marko Rauhamaa wrote: > A physicist once clarified to me that an almost-black-hole is > practically identical with a black hole because all information about > anything falling in is very quickly red-shifted to oblivion. Subject to some definition of "quickly" and "

Re: Processing text data with different encodings

2016-06-28 Thread Random832
On Tue, Jun 28, 2016, at 06:25, Chris Angelico wrote: > For the OP's situation, frankly, I doubt there'll be anything other > than UTF-8, Latin-1, and CP-1252. The chances that someone casually > mixes CP-1252 with (say) CP-1254 would be vanishingly small. So the > simple decode of "UTF-8, or faili

Re: Processing text data with different encodings

2016-06-28 Thread Random832
On Tue, Jun 28, 2016, at 10:52, Steven D'Aprano wrote: > "you will find THREE OR FOUR different encodings in one email. > I think at the sending side they just glue different text > fragments from different sources together without thinking > about the encoding" > > But I'm not

Re: Assignment Versus Equality

2016-06-28 Thread Random832
On Tue, Jun 28, 2016, at 00:31, Rustom Mody wrote: > GG downgrades posts containing unicode if it can, thereby increasing > reach to recipients with unicode-broken clients That'd be entirely reasonable, except for the excessively broad application of "if it can". Certainly it _can_ do it all the

Re: Can math.atan2 return INF?

2016-06-28 Thread Random832
On Sun, Jun 26, 2016, at 22:59, Steven D'Aprano wrote: > We have no way of seeing what goes on past the black hole's event > horizon, since light cannot escape. But we can still see *some* > properties of black holes, even through their event horizon: their > mass, any electric charge they may hold

Re: __all__ attribute: bug and proposal

2016-06-27 Thread Random832
On Mon, Jun 27, 2016, at 20:32, Chris Angelico wrote: > If you're primarily worried about classes and functions, here's a neat > trick you can use: How about just __all__ = [list of stuff including classes and functions] __all__ = [x if isinstance(x, str) else x.__name__ for x in __all__] -- htt

Re: __all__ attribute: bug and proposal

2016-06-27 Thread Random832
On Mon, Jun 27, 2016, at 16:56, Pavel S wrote: > Porposal: allow putting objects into __all__ directly, so possible > problems will be found earlier: Question: What happens if the object in __all__ isn't the same object that's in the module? -- https://mail.python.org/mailman/listinfo/python-list

Re: Question on compiling on linux

2016-06-27 Thread Random832
On Mon, Jun 27, 2016, at 00:26, Zachary Ware wrote: > A: Because you have to read things in reverse order. > Q: Why? > A: Top-posting. > Q: What's one of the most annoying common email practices? Which is witty, but doesn't *actually* explain why it's bad. 1. The intent, as I understand it, with

Re: Which one is the best XML-parser?

2016-06-24 Thread Random832
On Fri, Jun 24, 2016, at 02:39, dieter wrote: > You want an incremental parser if the XML documents are so huge that > you must process them incrementally rather than have a data structure > representing the whole document (in memory). Incremental parsers > for XML are usually called "SAX" parsers.

Re: Operator Precedence/Boolean Logic

2016-06-23 Thread Random832
On Thu, Jun 23, 2016, at 08:37, Steven D'Aprano wrote: > You keep saying that, but I've never seen it happen. I've seen cases > where people have been surprised by the unexpected truthiness of an > object ("I expected an exhausted iterator to be false, but it was > true"), but that's not what you s

Re: Operator Precedence/Boolean Logic

2016-06-23 Thread Random832
On Thu, Jun 23, 2016, at 02:34, Andreas Röhler wrote: > Indeed, why should the result of 4 - 4 have a different truth-value > than 4 - 3 ? This implementation seems to be a legacy from languages > without boolean types. A set which included Python until version 2.3. -- https://mail.python.org/mai

Re: Can math.atan2 return INF?

2016-06-22 Thread Random832
On Wed, Jun 22, 2016, at 11:34, Ben Bacarisse wrote: > Steven D'Aprano writes: > > I think that the only way it will return a NAN is if passed a NAN. > > That seems to be the case but I was a little surprised to find that > > >>> math.atan2(INF, INF) > 0.7853981633974483 > > I would have ex

Re: Is signed zero always available?

2016-06-22 Thread Random832
On Wed, Jun 22, 2016, at 10:19, Grant Edwards wrote: > Is that guaranteed by Python, or just a side-effect of the > implementation? Back in the days when Python used native C integers I > think the latter. AIUI, native C integers have never reliably supported signed zero even with representations

Re: Operator Precedence/Boolean Logic

2016-06-22 Thread Random832
On Tue, Jun 21, 2016, at 23:40, Elizabeth Weiss wrote: > Hi There, > > I am a little confused as to how this is False: > > False==(False or True) > > I would think it is True because False==False is true. "False or True" is True, and then it reduces to "False == True" which is false. There's

Re: the global keyword:

2016-06-21 Thread Random832
On Tue, Jun 21, 2016, at 13:04, Rick Johnson wrote: > On Sunday, June 12, 2016 at 2:08:01 PM UTC-5, BartC wrote: > > Anyway, it shows Python doesn't have true cross-module globals. > > BS! You can inject symbols into sys.modules and achieve a > true global. You can put a function or constant th

Re: the global keyword:

2016-06-20 Thread Random832
On Mon, Jun 20, 2016, at 08:15, Steven D'Aprano wrote: > Bart didn't say anyone had defended it. He made an observation: > > "that's a good illustration of why 'y' isn't a name reference to 'x'" > > which is factually correct. And this does refer to the "ducks limp" > thread. Except it doesn't.

Re: best text editor for programming Python on a Mac

2016-06-20 Thread Random832
On Sun, Jun 19, 2016, at 18:44, Gregory Ewing wrote: > 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 betwe

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Random832
On Mon, Jun 20, 2016, at 01:03, Rustom Mody wrote: > > Ctrl-K, =, ! (last two steps interchangeable). Done. Result: ≠ > > Are these 'shortcuts' parameterizable? They originate from RFC 1345, with the extension that they can be reversed if the reverse doesn't itself exist as a RFC 1345 combinat

Re: (repost) Advisory: HTTP Header Injection in Python urllib

2016-06-18 Thread Random832
On Sat, Jun 18, 2016, at 12:02, Steven D'Aprano wrote: > Er, you may have missed that I'm talking about a single user setup. > Are you suggesting that I can't trust myself not to forge a request > that goes to a hostile site? > > It's all well and good to say that the application is vulnerable to >

Re: (repost) Advisory: HTTP Header Injection in Python urllib

2016-06-17 Thread Random832
On Fri, Jun 17, 2016, at 21:00, Steven D'Aprano wrote: > The author doesn't go into details of what sort of attacks against > localhost they're talking about. An unauthenticated service running on > localhost implies, to me, a single-user setup, where presumably the > single-user has admin access t

Re: value of pi and 22/7

2016-06-17 Thread Random832
On Fri, Jun 17, 2016, at 19:12, Lawrence D’Oliveiro wrote: > I’m not sure how you can write “30” with one digit... One *significant* digit. Though, as it happens, some ancient number systems, including Hebrew and Greek, have one set of digits for 1-9, one for 10-90, and one for 100-900. -- https:

<    1   2   3   4   5   6   7   8   >