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

2016-05-16 Thread Random832
On Mon, May 16, 2016, at 13:57, sohcahto...@gmail.com wrote: > On Monday, May 16, 2016 at 10:35:28 AM UTC-7, Peter Otten wrote: > > I think HTTP/2 allows multiple requests over a single TCP connection. > > HTTP/1.1 already supports it, but most browsers have it disabled by > default. > > https://

Re: Extract the middle N chars of a string

2016-05-18 Thread Random832
On Wed, May 18, 2016, at 11:47, Steven D'Aprano wrote: > So after spending a ridiculous amount of time on what seemed like it > ought > to be a trivial function, and an embarrassingly large number of > off-by-one > and off-by-I-don't-even errors, I eventually came up with this: > > def mid(string,

Re: Image loading problem

2016-05-21 Thread Random832
On Sat, May 21, 2016, at 12:54, Peter Otten wrote: > It's not your fault, there's an odd quirk in the library: you have to > keep a reference of the PhotoImage instance around to prevent the > image from being garbage-collected. Just out of curiosity, why is this a "quirk" and not a bug? Why isn't

Re: for / while else doesn't make sense

2016-05-22 Thread Random832
On Sun, May 22, 2016, at 10:58, Marko Rauhamaa wrote: > Scheme has the best of both worlds: > >scheme@(guile-user)> 2/3 >$1 = 2/3 >scheme@(guile-user)> (exact->inexact $1) >$2 = 0. Why shouldn't Python do this? Imagine some future version of Python: >>> x = 2/3 >>

Re: for / while else doesn't make sense

2016-05-22 Thread Random832
On Sun, May 22, 2016, at 12:46, Jon Ribbens wrote: > Sorry, I have to stop you there as the entire premise of your post is > clearly wrong. "int" is not "an approximation of real numbers", it's > a model of the mathematical concept "integers", It is a representation of Z, a subset of R (as is floa

Re: for / while else doesn't make sense

2016-05-22 Thread Random832
On Sun, May 22, 2016, at 13:55, Jon Ribbens wrote: > No, in Python integers are closed under the standard arithmetic > operators (+ - * / % **) Z is not closed under standard division, as surely as N isn't closed under subtraction and R isn't closed under exponentiation. That is a mathematical fac

Re: for / while else doesn't make sense

2016-05-22 Thread Random832
On Sun, May 22, 2016, at 14:06, Jon Ribbens wrote: > This would be true if we had some Grand Unified Lossless Number Type. > Unfortunately, we don't, and we're not likely to any time soon. Scheme manages fine without one. It uses lossless types where it can, and lets you detect that an "inexact" n

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

2016-05-22 Thread Random832
On Wed, May 18, 2016, at 18:58, Gregory Ewing wrote: > 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 > >

Re: Image loading problem

2016-05-22 Thread Random832
On Sun, May 22, 2016, at 15:37, Michael Torrie wrote: > The reference is indeed held by the label but the problem is the label > is a Tcl/Tk object, thinly wrapped in Python. Okay but then in that case why doesn't the image get instantiated as a Tcl/Tk object which the label holds a reference t

Re: for / while else doesn't make sense

2016-05-23 Thread Random832
On Mon, May 23, 2016, at 13:33, Chris Angelico wrote: > and then you can use the special "tagged literal" syntax, like with > special forms of string literal: > > >>> f*22/7 + f*2/11 > Fraction(256, 77) I like the infix fraction literal syntax better: 22/f/7 + 2/f/11. -- https://mail.python.org/

Re: Handling exceptions with Py2 and Py3

2016-05-27 Thread Random832
On Fri, May 27, 2016, at 09:18, Ben Finney wrote: > try: > short_routine() > except ConnectionRefusedError as exc: > handle_connection_refused(exc) > except OSError as exc: > if exc.errno == errno.ECONNREFUSED: > handle_connection_refused(exc) But Co

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-27 Thread Random832
On Fri, May 27, 2016, at 05:56, Steven D'Aprano wrote: > On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote: > > > They are all ASCII derivatives. Those that aren't don't exist. > > *plonk* That's a bit harsh, considering that this argument started when you invented your own definition of "ASCII

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-27 Thread Random832
On Fri, May 27, 2016, at 11:53, Rustom Mody wrote: > And coding systems are VERY political. > Sure what characters are put in (and not) is political > But more invisible but equally political is the collating order. > > eg No one understands what jmf's gripes are... My guess is that a Euro > costs

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

2016-05-28 Thread Random832
On Sat, May 28, 2016, at 00:46, Rustom Mody wrote: > Which also means that if the Chinese were to have more say in the > design of Unicode/ UTF-8 they would likely not waste swathes of prime > real-estate for almost never used control characters just in the name > of ASCII compliance There are onl

Re: [spam] Re: look what I've found [ignore]

2016-05-29 Thread Random832
On Sun, May 29, 2016, at 14:14, Terry Reedy wrote: > Spam missed by the normally excellent spam filter. Ignore it. I didn't actually see the original message. Maybe it was sent directly to you (and perhaps other users, but not me) with a forged header implying it came from the list? -- https://m

Re: for / while else doesn't make sense

2016-05-29 Thread Random832
On Thu, May 26, 2016, at 05:05, Marko Rauhamaa wrote: >3124 16 8 0 >+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ >| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >+-+-+-+-+-+-+-+-+-+-+-+-+-+-

Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Random832
On Thu, Jun 2, 2016, at 13:36, Steven D'Aprano wrote: > On Thu, 2 Jun 2016 06:22 pm, Lawrence D’Oliveiro wrote: > > > On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote: > >> (Note that ‘__init__’ is not a constructor, because it operates on the > >> *already constructed* instance,

Re: Catch exception with message?

2016-06-03 Thread Random832
On Fri, Jun 3, 2016, at 19:14, Piyush Verma wrote: > Generally we catch exception using > except Exception as e: > > But sometimes, we see same type of exception is present with different > message.Is there a way to capture same exception with message > filtering? Please help me to do this. The m

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

2016-06-04 Thread Random832
On Fri, Jun 3, 2016, at 22:02, Steven D'Aprano wrote: > (I am surprised that it takes so little to grant end-user usage > rights, but IANAL and presumably the FSF's lawyers consider that > sufficient. Perhaps there are common law usage rights involved.) Technically, there are statutory usage right

Re: Operator precedence problem

2016-06-05 Thread Random832
On Sun, Jun 5, 2016, at 02:53, ICT Ezy wrote: > >>> 2 ** 3 ** 2 > Answer is 512 > Why not 64? > Order is right-left or left-right? You're mixing up order of evaluation with operator associativity. The ** operator is right-to-left associative, this means x ** y ** z == x ** (y ** z). Evaluation is

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

2016-06-05 Thread Random832
On Sun, Jun 5, 2016, at 02:37, Steven D'Aprano wrote: > No they don't. You are confusing the implementation with the programming > model. > > Following the assignment: > > x = 99 > > if you print(x), do you see something like "reference 0x12345"? No. > > Do you have to dereference that referenc

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

2016-06-05 Thread Random832
On Sun, Jun 5, 2016, at 04:01, Marko Rauhamaa wrote: > You could also think of variables as pegs, references as leashes, and > objects as cute puppies. One puppy could be held with multiple leashes > hung on separate pegs. Some puppies hold leashes in their mouths. Every > leash is tied to a puppy

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

2016-06-05 Thread Random832
On Sun, Jun 5, 2016, at 15:20, Marko Rauhamaa wrote: > I say None is a wooden post, you say None is a puppy. > > What piece of Python code could put our dispute to rest? isinstance(None, object) Anyway, I read the "wooden post" claim as suggesting that a reference to None is somehow different fr

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

2016-06-05 Thread Random832
On Sun, Jun 5, 2016, at 23:52, Steven D'Aprano wrote: > Certainly not. x = y = 999 is required to bind the same object to x and > y. My statement was that if two variables can be bound to the same object, then variables *cannot* contain objects. The object has to exist somewhere, and this requirem

Re: Operator precedence problem

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 01:46, Lawrence D’Oliveiro wrote: > On Monday, June 6, 2016 at 4:06:20 AM UTC+12, Uri Even-Chen wrote: > > Never write expressions, such as 2 ** 3 ** 2 or even 2 * 4 > > + 5, without parentheses. > > That leads to the code equivalent of >

Re: Operator precedence problem

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 10:22, Marko Rauhamaa wrote: > You *can* assume other people have read the spec. Even more importantly, > you can assume the Python interpreter complies with the spec. I can assume the python interpreter will accept tabs as indents too, that doesn't make it good style. Req

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

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 12:19, Steven D'Aprano wrote: > (2) The "variables are like boxes" metaphor applies to static languages > like > C and Pascal, where the compiler has knowledge of what variables will > exist. Such languages allocate space for the variables at compile time, > usually using fi

Re: Operator precedence problem

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 13:07, Steven D'Aprano wrote: > Blimey, you're right. I always thought `and` and `or` had the same > precedence. And now that I know better, I have no doubt that I will > forget > it again. A good way to remember it is that "and" is analogous to multiplication, and "or" is

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

2016-06-06 Thread Random832
On Mon, Jun 6, 2016, at 14:59, Steven D'Aprano wrote: > "Variables as boxes" is a long-standing, well-known metaphor for the C > and > Pascal variable model, one where the value is copied into the box > (metaphorically), or to be more precise, where variables have fixed > locations and on assignmen

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

2016-06-07 Thread Random832
On Tue, Jun 7, 2016, at 03:03, Gregory Ewing wrote: > a = 42 > b = 17 > c = &a > c = &b > > does 'c' now hold a reference to the variable 'b', or > does it still hold a reference to 'a' and 'a' now > holds a reference to 'b'? It'd have to be spelled *c = &b, or c.value = &b or c.setvalue(&b), or

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

2016-06-07 Thread Random832
On Tue, Jun 7, 2016, at 08:32, Antoon Pardon wrote: > > Here's a thought experiment for you. Suppose in Python 3.6, Guido announces > > that Python will support a form of high-level pointer (not the scary, > > dangerous > > low-level pointer of C) called "reference". There will be a dereference

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

2016-06-09 Thread Random832
On Thu, Jun 9, 2016, at 03:30, Antoon Pardon wrote: > Then you think wrong. Python has no pointers, that is an implementation > detail. Nonsense. A binary number referring to a memory address is an implementation detail. A pointer/reference/arrow-thingy-on-a-diagram is the thing it is an implement

Re: fast dictionary initialization

2016-06-10 Thread Random832
pOn Fri, Jun 10, 2016, at 17:07, maurice wrote: > Hi. If I have already a list of values, let's call it valuesList and the > keysList, both same sized lists, what is the easiest/quickest way to > initialize a dictionary with those keys and list, in terms of number of > lines perhaps? > > example:

Re: the global keyword:

2016-06-11 Thread Random832
On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > So my question is, how the heck is it possible that I get 5 as the last > value printed? the global test_var (global to Test.py) I set to 44 when I > ran some_function()??? does anyone have a clue they could throw my way? Importing a variable fr

Re: the global keyword:

2016-06-11 Thread Random832
On Sat, Jun 11, 2016, at 20:09, MRAB wrote: > Not true. Importing doesn't copy the value. > > Importing a name creates a new name in the local scope that refers to > the same object that the imported name referred to. Yes, the value of a variable is a reference to an object. Can we not have anot

Re: the global keyword:

2016-06-11 Thread Random832
On Sat, Jun 11, 2016, at 20:12, Marcin Rak wrote: > What about variables that are user defined classes? Are they referenced > or copied? It will reference the same object, but if the variable is reassigned in the original module it will still not update the imported variable. -- https://mail.pyt

Re: Altering sys.argv on startup in Python 2

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 08:56, Adam Bartoš wrote: > Hello, > > I'm trying to employ code like > https://code.activestate.com/recipes/572200/ > at Python 2 startup. The problem is that sys.argv isn't polulated yet > when > sitecustomize is executed. Is there any way around? I was thinking about >

Re: how to handle surrogate encoding: read from fs write to database

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 12:50, Steven D'Aprano wrote: > I think Windows also gets it almost write: NTFS uses UTF-16, and (I > think) only allow valid Unicode file names. Nope. Windows allows any sequence of 16-bit units (except for a dozen or so ASCII characters) in filenames. Of course, you're

Re: Altering sys.argv on startup in Python 2

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 13:51, Random832 wrote: > if edit_done: > return this should of course be raise ImportError - an artifact of some refactoring I did on the example. -- https://mail.python.org/mailman/listinfo/python-list

Re: Altering sys.argv on startup in Python 2

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 13:51, Random832 wrote: > if edit_done: > return this should of course be raise ImportError - an artifact of some refactoring I did on the example. -- https://mail.python.org/mailman/listinfo/python-list

Re: the global keyword:

2016-06-12 Thread Random832
On Sat, Jun 11, 2016, at 23:15, Lawrence D’Oliveiro wrote: > On Sunday, June 12, 2016 at 11:51:11 AM UTC+12, Random832 wrote: > > Importing a variable from a module copies its value into your own > > module's variable. > > Every name in Python is a variable, and can be

Re: the global keyword:

2016-06-12 Thread Random832
On Sat, Jun 11, 2016, at 23:15, Lawrence D’Oliveiro wrote: > On Sunday, June 12, 2016 at 11:51:11 AM UTC+12, Random832 wrote: > > Importing a variable from a module copies its value into your own > > module's variable. > > Every name in Python is a variable, and can be

Re: base64.b64encode(data)

2016-06-12 Thread Random832
On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: > That's because base64 is a bytes-to-bytes transformation. It has > nothing to do with unicode encodings. Nonsense. base64 is a binary-to-text encoding scheme. The output range is specifically chosen to be safe to transmit in text protocols.

Re: base64.b64encode(data)

2016-06-12 Thread Random832
On Mon, Jun 13, 2016, at 01:16, Steven D'Aprano wrote: > Suppose instead it returned the Unicode string 'AUERFg=='. That's all > well and good, but what are you going to do with it? You can't > transmit it over a serial cable, because that almost surely is going > to expect bytes, so you have to en

Re: base64.b64encode(data)

2016-06-13 Thread Random832
On Mon, Jun 13, 2016, at 06:35, Steven D'Aprano wrote: > But this is a Python forum, and Python 3 is a language that tries > very, very hard to keep a clean separation between bytes and text, Yes, but that doesn't mean that you're right about which side of that divide base64 output belongs on. >

Re: base64.b64encode(data)

2016-06-13 Thread Random832
On Mon, Jun 13, 2016, at 19:12, Gregory Ewing wrote: > They could maybe be made a bit cheaper still by arranging > some way for a bytes object and an ascii-only str object > to share underlying storage. While we're at it, why not allow bytes to share storage with FSR latin-1 strings and the cached

Re: for / while else doesn't make sense

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 07:19, Rustom Mody wrote: > I thought there'd be many examples for showing that break is just goto in > disguise... Evidently not > > So here is an example in more detail for why/how break=goto: > > http://blog.languager.org/2016/06/break-is-goto-in-disguise.html So? S

Re: for / while else doesn't make sense

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 10:20, Rustom Mody wrote: > Claim is that the damaging propensities of goto are replicable with > break. The "damaging propensity" in this particular case simply comes from the fact that it's a statement that can appear in the body of an if statement (the real flaw that ca

Re: for / while else doesn't make sense

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 13:18, Michael Selik wrote: > On Wed, Jun 15, 2016, 10:28 AM Rustom Mody wrote: > > > Where did the question of "break can be written as goto" come from? > > > > Stephen said the "else" in for-else was "unconditional". He argued that > neither the presence nor absence of

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 13:37, Rob Gaddi wrote: > I've got a whole lot of methods I want to add to my Channel class, all > of which following nearly the same form. The below code works, but > having to do the for loop outside of the main class definition feels > kludgey. Am I missing some cleane

Re: PEP8 needs revision

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 15:18, Kyle Thomas wrote: > To Whom It May Concern, > Knuth's quote refers to the output of TeX, the programming language he > authored. The quote cannot be interpreted to speak about formatting of > source-code. It speaks about what is more readable, and is mentioned in

Re: pip vs pip2 vs pip2.7?

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 16:34, Chupo via Python-list wrote: > I am assuming multiple copies of the same file with different names are > because of some compatibility issues but couldn't find any explanations > so I hope someone can point me to some docs explaining the issue. The idea is, if you

Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Random832
On Wed, Jun 15, 2016, at 15:03, Ethan Furman wrote: > [1] https://docs.python.org/3/library/functions.html#locals > Yes, returning the class namespace is a language gaurantee. How do you get a guarantee from that text? I don't see any definition asserting that the "current local symbol table"

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:

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: (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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: __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: __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: 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: 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: 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: 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: 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: 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: 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: "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: "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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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-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: 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: 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-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-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

<    1   2   3   4   5   6   7   8   >