Re: Python handles globals badly.

2015-09-15 Thread Steven D'Aprano
On Mon, 14 Sep 2015 06:30 pm, Antoon Pardon wrote: > Op 12-09-15 om 05:48 schreef Steven D'Aprano: >> I believe I already acknowledged that assignment-as-expression was fine >> if it avoided the = versus == error, from the perspective of avoiding >> errors. But from the

Re: Python handles globals badly.

2015-09-15 Thread Steven D'Aprano
On Wed, 16 Sep 2015 11:13 am, Steven D'Aprano wrote: > Python is a remarkably clean and consistent language. There's only one > kind of value (the object -- everything is an object, even classes are > objects). The syntax isn't full of special cases. For example, the

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
spider in rat in cat in dog in old_woman: print("I don't know why she swallowed the fly") For a less whimsical example: if word in line in text: print("word in line and line in text") But I agree with Tim Chase: I wouldn't use it, even though it's legal.

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
or and have "1 instanceof int > instanceof type"? Having chaining apply to things that are not > semantically comparisons is just baffling. Somewhat ugly, I grant you, but if baffling? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
There's no other scenario, if the operators have natural meanings, that > it would actually be natural to write it that way. 0 <= x < y == z The main reason for supporting arbitrary chained operators is that they could be overloaded and have some meaning that makes sense: node = left <=

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
"is" [...] > I'm not all that sure A and B should be allowed. You can take `x == y == z` off me when you pry it from my cold, dead hands. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
On Thu, 17 Sep 2015 03:44 am, Grant Edwards wrote: > On 2015-09-16, Steven D'Aprano wrote: >> On Thu, 17 Sep 2015 03:27 am, Grant Edwards wrote: >> >>> On 2015-09-16, Sven R. Kunze wrote: >>>> On 16.09.2015 18:57, Random832 wrote: >>>>> I

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
On Thu, 17 Sep 2015 03:41 am, Sven R. Kunze wrote: > On 16.09.2015 19:33, Steven D'Aprano wrote: >> On Thu, 17 Sep 2015 01:40 am, Random832 wrote: >> >>> "in" suggests a relationship between objects of different types (X and >>> "something that

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
On Thu, 17 Sep 2015 03:47 am, Random832 wrote: > On Wed, Sep 16, 2015, at 13:33, Steven D'Aprano wrote: >> On Thu, 17 Sep 2015 01:40 am, Random832 wrote: >> >> > "in" suggests a relationship between objects of different types (X and >> > "some

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
t; Too colorful for a grammer? > > I'm not with you, sorry. Is "grammer" the US spelling of the UK > "grammar"? Mark, take a close look at Sven's name, and his email address. When your German is better than his English, then you can pick on his spelling. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: True == 1 weirdness

2015-09-16 Thread Steven D'Aprano
t; Too colorful for a grammer? > > I'm not with you, sorry. Is "grammer" the US spelling of the UK > "grammar"? Mark, take a close look at Sven's name, and his email address. When your German is better than his English, then you can pick on his spelling. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Context-aware return

2015-09-16 Thread Steven D'Aprano
On Sun, 13 Sep 2015 09:27 am, Ned Batchelder wrote: > On Thursday, September 10, 2015 at 8:44:01 PM UTC-4, Denis McMahon wrote: >> On Fri, 11 Sep 2015 03:54:14 +1000, Steven D'Aprano wrote: >> >> > If I did this thing, would people follow me down the street booing

Re: True == 1 weirdness

2015-09-17 Thread Steven D'Aprano
On Thu, 17 Sep 2015 02:10:44 -0400, Random832 wrote: > On Wed, Sep 16, 2015, at 21:25, Steven D'Aprano wrote: >> So what? The intended purpose of `is` and `==` is not to return True. >> It is >> to perform a comparison which may return False, or True. > > Yeah,

Re: .bat file trouble.

2015-09-18 Thread Steven D'Aprano
happens if you run this batch file instead? @echo off python -c "import sys; print(sys.version)" echo Press any key to exit. . . pause>nul Is the printed version the version you expect? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Einstein's Riddle

2015-09-18 Thread Steven D'Aprano
to the speed of light, and for him it is only a few minutes after the original post was sent. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: True == 1 weirdness

2015-09-18 Thread Steven D'Aprano
* > sane, it's better to be explicit about what you are doing. Why? The results are perfectly well-defined however you write them. Transitivity or not, "Rock beats Scissors beats Paper beats Rock" means the same thing as "Rock beats Scissors, and Scissors beats Paper, and Paper beats Rock" except it's much shorter. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: True == 1 weirdness

2015-09-18 Thread Steven D'Aprano
On Fri, 18 Sep 2015 10:47 pm, Random832 wrote: > On Fri, Sep 18, 2015, at 08:30, Steven D'Aprano wrote: >> On Fri, 18 Sep 2015 07:26 am, Random832 wrote: >> >> > I don't even think chaining should >> > work for all *actual* comparison operations. &

Idiosyncratic python

2015-09-23 Thread Steven D'Aprano
I was looking at an in-house code base today, and the author seems to have a rather idiosyncratic approach to Python. For example: for k, v in mydict.items(): del(k) ... instead of the more obvious for v in mydict.values(): ... What are your favorite not-wrong-just-weird Pyth

Re: Idiosyncratic python

2015-09-23 Thread Steven D'Aprano
On Thursday 24 September 2015 16:16, Paul Rubin wrote: > Steven D'Aprano writes: >> for k, v in mydict.items(): >> del(k) > > That looks wrong: it's deleting k from what? The local namespace. py> k = 23 py> print k 23 py> del k py> print

Re: Idiosyncratic python

2015-09-24 Thread Steven D'Aprano
andard idiom, before the ternary if was added to the language. So I don't consider it "weird", especially as a lot of my code still supports Python 2.4 which doesn't include the ternary if. Sometimes, instead of a list, I'll use a dict: {True: value1, False: va

Re: Idiosyncratic python

2015-09-24 Thread Steven D'Aprano
On Fri, 25 Sep 2015 06:46 am, Ned Batchelder wrote: > On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano > wrote: >> What are your favorite not-wrong-just-weird Python moments? > > I've seen this a number of times: > > dict_of_values.up

Re: Idiosyncratic python

2015-09-24 Thread Steven D'Aprano
On Thu, 24 Sep 2015 04:54 pm, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thursday 24 September 2015 16:16, Paul Rubin wrote: >> >> > Steven D'Aprano writes: >> >> for k, v in mydict.items(): >> >> del(k) >&g

Re: PY3.5 and nnumpy and scipy installation problem

2015-09-25 Thread Steven D'Aprano
ed (Windows crash, computer caught fire...) please describe it. It may help if you explain the exact commands you used to install. Did you use a text-based installer from the command line, or a GUI? The more information you can give, the better the chances we can help. Regards, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python program on induction heating

2015-09-26 Thread Steven D'Aprano
nfortunately that second link is broken and I don't understand enough French to find it from the home page. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with Debugging

2015-09-27 Thread Steven D'Aprano
" to the error message at the end, and send it to us. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question re class variable

2015-09-29 Thread Steven D'Aprano
an item within the existing self.__instance_registry. So the registry object (a dict?) gets modified in place, not re-bound or shadowed by an instance attribute of the same name. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-09-29 Thread Steven D'Aprano
still compares -1 against each value. Testing a numeric value within a certain range of values should be constant time and constant memory. It should be *fast*. Using range in Python 2 is none of those things. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-09-29 Thread Steven D'Aprano
On Wed, 30 Sep 2015 01:08 pm, Random832 wrote: > Steven D'Aprano writes: >> It's not fine. In Python 2, >>... >> Testing a numeric value within a certain range of values should be >> constant time and constant memory. It should be *fast*. Using range i

Re: Linux Mint installation of Python 3.5

2015-09-29 Thread Steven D'Aprano
thon, even if they use the same version. That way, even if you accidentally break your development Python, the system Python will continue to work. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-10-01 Thread Steven D'Aprano
e certainly a senile old git if you think we're falling for that one :-) P.S. in case you missed it, you don't actually need the params, since the precedence of not is lower than the other operators. Did-I-include-sufficient-smileys-ly y'rs, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-10-01 Thread Steven D'Aprano
se your right hand? I could be wrong, but I seem to recall reading that this is *exactly* what happens -- the muscles used to raise the right arm trigger ever-so-slightly. You don't even notice it, but sensitive electrodes can detect the change in electrical potential in the muscles. [1] Except when there isn't. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Create a .lua fle from Python

2015-10-01 Thread Steven D'Aprano
a professional[1] duty of care to warn an *obvious beginner* that he may be introducing a serious security vulnerability into his code. [1] In the sense of a job well done, not in the sense of "I got paid money to write this shit". Think master craftsman, not interchangeable code monke

Re: Check if a given value is out of certain range

2015-10-01 Thread Steven D'Aprano
On Fri, 2 Oct 2015 04:20 am, John Gordon wrote: > In <[email protected]> Steven D'Aprano > writes: > >> > I have to parse those damn brackets and then figure out the inverted >> > logic. Give me x < 0 or x > 10 a

Re: Check if a given value is out of certain range

2015-10-03 Thread Steven D'Aprano
second less time to chew each mouthful of burger compared to kebab") is unnecessary. But we do love the argument from efficiency. Frankly, as a profession, we programmers are lousy at prioritising. We write pages and pages of convoluted, inconsistent, hard to understand code that can somet

Re: Instance method for converting int to str - str() and __str__()

2015-10-03 Thread Steven D'Aprano
ll perform pre-processing or post-processing, catch exceptions, or error-check the result. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Footnotes in ReST

2015-10-03 Thread Steven D'Aprano
between [2] and [3], but I don't want to have to renumber the following 997 footnotes by hand. Is there something I can do, within the syntax of ReST itself, to help? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-10-03 Thread Steven D'Aprano
On Sat, 3 Oct 2015 10:12 pm, Laura Creighton wrote: > People think logically LOL :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Footnotes in ReST

2015-10-03 Thread Steven D'Aprano
On Sat, 3 Oct 2015 10:21 pm, Laura Creighton wrote: > In a message of Sat, 03 Oct 2015 21:39:26 +1000, "Steven D'Aprano" writes: >>I have a document written in Restructured Text format, and I use lots of >>footnotes: [...] > You shouldn't have numbered t

Re: function code snippet that has function calls I have never seen before. How does it work.

2015-10-04 Thread Steven D'Aprano
funA(4, -1, 1) => which returns (4 + -1)*1, which gives 3 and finally pass that value to print: * print(3) which prints 3. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Check if a given value is out of certain range

2015-10-04 Thread Steven D'Aprano
ve load than typing, for > the people studied, thus they reported that keyboard was faster, > when it wasn't for them. Thanks for the anecdote, it was fascinating. My point was not so much about the advantage (if any) of mouse over keyboard, which I'm sure will depend on a multi

Re: Recover data over the network

2015-10-09 Thread Steven D'Aprano
n to do 1st task. Depends on what you mean by data recovery. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread Steven D'Aprano
hing against functional programming, but mixing it > so closely with OO would, I think, result in a confusing, > schizophrenic interface. Do you find len(alist) to be confusing and schizophrenic? > Last possibly relevant fact: the library I want to extend is > `xml.dom.minidom`. By `Node` I mean `Element`, and the specific > methods I want to add will modify attributes used for CSS/JavaScript. It may be relevant. Try it and see. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Strong typing implementation for Python

2015-10-11 Thread Steven D'Aprano
#x27;s nothing innovative about Swift to include that as a feature. Type inference is *old*. The theory behind type inference goes back to 1958, and languages such as ML and OCaml have included it for decades, and yet here we are in 2015 and people think that it's something cool and new :-( -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Strong typing implementation for Python

2015-10-12 Thread Steven D'Aprano
fine and useful tool. But if you are crippled as a programmer without it, well, then you can hardly claim to understand the language or framework you are programming in if you cannot use it without an IDE doing half the work for you. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Strong typing implementation for Python

2015-10-12 Thread Steven D'Aprano
gly typed language with no numeric promotion, the compiler can infer that x must be an int. In a language with numeric promotion, it can infer that x must be an int or float. Where is the "vast amounts of noise" added to the code? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Strong typing implementation for Python

2015-10-13 Thread Steven D'Aprano
On Tue, 13 Oct 2015 06:55 pm, Todd wrote: > On Oct 13, 2015 2:11 AM, "Steven D'Aprano" wrote: >> Consider the following piece of code: >> >> def addone(x): >> return x + 1 >> >> >> The human programmer reading that can trivially i

Strict comparisons in Python 2

2015-10-13 Thread Steven D'Aprano
some implementation-dependent rule. Is there some way to force the Python 3 rules into Python 2? Something like a __future__ import? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: pip problem

2015-10-16 Thread Steven D'Aprano
l, which tells me you need to try turning the computer off and on again. Sorry I can't be of more help. I-knew-I-should-have-paid-more-than-$2.95-for-a-magic-crystal-ball-ly y'rs, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Cryptographically strong random numbers

2015-10-16 Thread Steven D'Aprano
. This discussion is purely about what will be offered in the "secrets" module. https://www.python.org/dev/peps/pep-0506/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Defamation

2015-10-20 Thread Steven D'Aprano
obeying laws that don't apply, even if well-meaning, opens us to a dangerous precedent that we shouldn't go near. There's another reason to try very, very hard to avoid deleting archived posts: until such time as python.org moves to Mailman3, deleting a single posts breaks the

Re: Defamation

2015-10-20 Thread Steven D'Aprano
On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote: > In a message of Wed, 21 Oct 2015 00:09:18 +1100, "Steven D'Aprano" writes: >>On Tue, 20 Oct 2015 03:28 am, Laura Creighton wrote: >> >>> Actually, this one was part of a huge set of defaming articles s

select.poll and ppoll

2015-10-21 Thread Steven D'Aprano
Using Python 2.6, don't hate me. I have select.poll, but I'm looking for something like ppoll instead. From the Linux man page: ppoll() The relationship between poll() and ppoll() is analogous to the relationship between select(2) and pselect(2): like pselect(2),

Re: Defamation

2015-10-22 Thread Steven D'Aprano
On Thu, 22 Oct 2015 11:45 am, John O'Hagan wrote: > On Wed, 21 Oct 2015 00:09:18 +1100 > Steven D'Aprano wrote: > > >> I don't believe that the Python mailing list archives are hosted in a >> country under the jurisdiction of European Law. If I'm ri

Re: [ANN] Python 3 Cheat Sheet v2.0

2015-10-30 Thread Steven D'Aprano
not correct. You can open binary files too, and read/write raw bytes: https://docs.python.org/3/library/functions.html#open https://docs.python.org/3/glossary.html#term-binary-file -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Unittests and serial workflows

2015-10-30 Thread Steven D'Aprano
each test alone (in > PyCharm a mouse click alone starts a single test). > > My question(s): is Unittest the "right" framework for my needs? Should I > move to Nosetests? Any hint to a useful, not too long document about > testing framework and good practices? http://thedai

Re: UNABLE TO GET IDLE TO RUN

2015-11-01 Thread Steven D'Aprano
) What an overkill... If that is true, that's really sad. Were we really unable to tell this teacher to delete the shadowing file? Or was there more to the problem than that? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: UNABLE TO GET IDLE TO RUN

2015-11-01 Thread Steven D'Aprano
http://ux.stackexchange.com/questions/4518/should-alert-boxes-be-avoided-at-any-cost Good to see that IDLE is going to continue that fine old tradition of degrading usability for the sake of a quick and easy non-solution to a problem. :-( -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: UNABLE TO GET IDLE TO RUN

2015-11-01 Thread Steven D'Aprano
On Mon, 2 Nov 2015 03:17 am, Laura Creighton wrote: > I managed to delete the real mail I would like to reply to. > This is, at least in the same thread > > In a message of Mon, 02 Nov 2015 01:27:23 +1100, "Steven D'Aprano" writes > a reply to Michael Overt

Re: UNABLE TO GET IDLE TO RUN

2015-11-01 Thread Steven D'Aprano
On Mon, 2 Nov 2015 11:07 am, Terry Reedy wrote: > On 11/1/2015 11:17 AM, Laura Creighton wrote: > >> In a message of Mon, 02 Nov 2015 01:27:23 +1100, "Steven D'Aprano" writes >> a reply to Michael Overtoon: > > He was actually responding to my proposal t

Re: installer user interface glitch ?

2015-11-01 Thread Steven D'Aprano
the website shouldn't do that then. Seriously, if the browser announces Windows XP, it's probably not a good idea to download a version which is known not to work with XP... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Unbuffered stderr in Python 3

2015-11-02 Thread Steven D'Aprano
In Python 2, stderr is unbuffered. In most other environments (the shell, C...) stderr is unbuffered. It is usually considered a bad, bad thing for stderr to be buffered. What happens if your application is killed before the buffer fills up? The errors in the buffer will be lost. So how come P

Re: Modern recommended exception handling practices?

2015-11-02 Thread Steven D'Aprano
raise OSError ... py> X() + 2 Traceback (most recent call last): File "", line 1, in File "", line 3, in __add__ OSError Does this mean you should *catch* everything? No. See Rule (2) above. Unless you are expecting an X instance in your code, the presence of one is probably a bug. The *unexpected* OSError will be the exception that reveals this bug, and allows you to fix it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-02 Thread Steven D'Aprano
eir syntax is harmful, and he has recreated them for Perl 6: http://www.perl.com/pub/2002/06/04/apo5.html Oh, and the icing on the cake, regexes can be a security vulnerability too: https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Modern recommended exception handling practices?

2015-11-02 Thread Steven D'Aprano
27;t mean you have read permission to it.) A lot can happen in the few microseconds between checking for the existence of the file and actually opening it -- the file could be renamed or deleted. https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use -- Steven -- https://mail.python.org/

Re: Unbuffered stderr in Python 3

2015-11-03 Thread Steven D'Aprano
On Wednesday 04 November 2015 09:25, Terry Reedy wrote: > On 11/3/2015 10:42 AM, Chris Angelico wrote: >> On Wed, Nov 4, 2015 at 2:00 AM, Random832 wrote: >>> Nobody writes: >>> It's probably related to the fact that std{in,out,err} are Unicode streams. >>> >>> There's no fundamental r

Re: Regular expressions

2015-11-03 Thread Steven D'Aprano
ult mode most certainly is regular > expressions. I don't even know what grep stands for. But I think what Michael may mean is that if you "grep foo", no regex magic takes place since "foo" contains no metacharacters. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-03 Thread Steven D'Aprano
On Wednesday 04 November 2015 03:20, Chris Angelico wrote: > On Wed, Nov 4, 2015 at 3:10 AM, Seymore4Head > wrote: >> Yes I knew that -1 represents the end character. It is not a question >> of trying to accomplish anything. I was just practicing with regex >> and wasn't sure how to express a *

Re: Irregular last line in a text file, was Re: Regular expressions

2015-11-03 Thread Steven D'Aprano
On Wednesday 04 November 2015 03:56, Tim Chase wrote: > Or even more valuable to me: > > with open(..., newline="strip") as f: > assert all(not line.endswith(("\n", "\r")) for line in f) # Works only on Windows text files. def chomp(lines): for line in lines: yield line.rstrip(

Re: Regular expressions

2015-11-03 Thread Steven D'Aprano
On Wednesday 04 November 2015 11:33, [email protected] wrote: >> Not quite. Core language concepts like ifs, loops, functions, >> variables, slicing, etc are the socket wrenches of the programmer's >> toolbox. Regexs are like an electric impact socket wrench. You can do >> the same work without i

Re: Regular expressions

2015-11-04 Thread Steven D'Aprano
On Wednesday 04 November 2015 18:21, Christian Gollwitzer wrote: > What rurpy meant, was that regexes can surface to a computer user > earlier than variables and branches; a user who does not go into the > depth to actually program the machine, might still encounter them in a > text editor or data

Re: Unbuffered stderr in Python 3

2015-11-04 Thread Steven D'Aprano
On Wed, 4 Nov 2015 07:19 pm, Wolfgang Maier wrote: > On 04.11.2015 04:18, Steven D'Aprano wrote: >> On Wednesday 04 November 2015 09:25, Terry Reedy wrote: >> >>> On 11/3/2015 10:42 AM, Chris Angelico wrote: >>>> On Wed, Nov 4, 2015 at 2:00 AM, Ra

Re: raw_input and break

2015-11-04 Thread Steven D'Aprano
omething else, neither can we. Help us to help you. We cannot help you unless you show us the code you are running. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-04 Thread Steven D'Aprano
t once you've already found it. So they are complementary, not alternatives. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-04 Thread Steven D'Aprano
NOBOL pattern matching, or lowly globbing patterns. Or even alternative idioms, like Hypercard's "chunking" idioms. When all you have is a hammer, everything looks like a nail. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-04 Thread Steven D'Aprano
sic regular expressions": > > """ > Basic vs Extended Regular Expressions >In basic regular expressions the meta-characters ?, +, {, |, (, >and ) lose their special meaning; instead use the backslashed > versions \?, \+, \{, \|,

Re: Regular expressions

2015-11-04 Thread Steven D'Aprano
tainly we should accept questions from people who are simply trying to learn how to use regexes without bombarding them with admonitions to do something different. Yes yes, I know that regexes aren't the only tool in my tool box, but *right now* I want to learn how to use regexes. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regular expressions

2015-11-05 Thread Steven D'Aprano
On Thu, 5 Nov 2015 07:33 pm, Peter Otten wrote: > Steven D'Aprano wrote: > >> On Wed, 4 Nov 2015 07:57 pm, Peter Otten wrote: >> >>> I tried Tim's example >>> >>> $ seq 5 | grep '1*' >>> 1 >>> 2 >>> 3 &

Re: Question about math.pi is mutable

2015-11-06 Thread Steven D'Aprano
g themselves "PointedEars". Please stop trying to enforce non-existent rules about internet identities on others. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-06 Thread Steven D'Aprano
st time. Not to prevent determined coders from changing things, but to avoid *accidental* changes done in error. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-07 Thread Steven D'Aprano
he compiler or interpreter performs that checking for you. Besides, the Python convention is honoured more in theory than in practice. We have math.pi, not math.PI. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-07 Thread Steven D'Aprano
27;s design decisions, I would be rich beyond the dreams of avarice. Fortunately, C is not the only other computer language, and we are by no means limited to the two choices of the status quo (no constants in Python) and what C does. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-07 Thread Steven D'Aprano
wed you to swap out the radio, the doors, the tyres, even the engine, while the car was moving. You could unplug the engine while driving down the road, and plug in a new one, and the car would just keep going. As a consequence, the car is significantly bigger and slower than most other cars, and occasionally it is useful (when you get a flat tyre, you don't have to stop, you just swap into place a new tyre and keep going) but generally it's not used much (who swaps out the seat that they are sitting on?). Ford call this car "Python". > I wouldn't like Python to turn into such a contraption. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-08 Thread Steven D'Aprano
On Sun, 8 Nov 2015 08:44 pm, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 8 Nov 2015 01:23 am, Marko Rauhamaa wrote: >>> Correct. That's not Python's fault, however. Python should not try to >>> placate the performance computing people. (Al

Re: Question about math.pi is mutable

2015-11-08 Thread Steven D'Aprano
On Sun, 8 Nov 2015 09:40 pm, Bartc wrote: > On 08/11/2015 02:59, Steven D'Aprano wrote: >> On Sun, 8 Nov 2015 02:01 am, Bartc wrote: >> >>> Neither have the simplicity of concept of Pascal's 'const', which is >>> just a named value. Not a v

Re: Question about math.pi is mutable

2015-11-08 Thread Steven D'Aprano
ct and slots; - search the class dict; - search the dict for each additional superclass; where searching involves more than just a hash table lookup. It also involves checking the classes for __getattribute__ and __getattr__ methods, checking for descriptors, and more. The whole lookup process is

Re: Question about math.pi is mutable

2015-11-08 Thread Steven D'Aprano
ignificant assumptions about correctness; - avoiding actually checking those assumptions; - and in the case of C, by outright *ignoring the code you write* if you inadvertently violate those assumptions. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-08 Thread Steven D'Aprano
izations like this. (The aim of Nuitka is to be a static optimizing compiler.) PyPy may do things like this too, using a JIT optimizing compiler. PyPy is capable of far more than such simple optimizations. As I have argued all along, it is certainly not true that Python's dynamicism prevents all such optimizations. It just makes them harder. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-09 Thread Steven D'Aprano
r-php-move-fast/280583813919 HipHop is perhaps not the best example, as it does give up some of the most dynamic features of PHP, such as eval. The post above isn't clear whether using such features is prohibited, or merely falls back on the slow, regular PHP interpreter when you use them. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-09 Thread Steven D'Aprano
On Tue, 10 Nov 2015 06:45 am, Ben Finney wrote: > Steven D'Aprano writes: > >> The compiler doesn't need to decide in advance whether or not the >> module attributes have been changed. It can decide that at runtime, >> just before actually looking up the attri

Re: Question about math.pi is mutable

2015-11-10 Thread Steven D'Aprano
On Tue, 10 Nov 2015 05:10 pm, Ben Finney wrote: > Steven D'Aprano writes: > >> Ben, I fear that you are not paying attention to me :-) > > Possibly, though I also think there's miscommunication in this thread. > > You speak of “compile time” and “run

Re: Question about math.pi is mutable

2015-11-10 Thread Steven D'Aprano
denying the possibility of technologies which *already exist* I think that things have got a bit out of hand. It's a bit like somebody getting on Twitter to tweet "A globally interconnected communication network allowing computers all over the world to communicate? Impossible! And even if it were possible, nobody would use it." ;-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Keeping context-manager object alive through function calls

2015-11-10 Thread Steven D'Aprano
On Wednesday 11 November 2015 09:36, Pablo Lucena wrote: > I am running into a bit of an issue with keeping a context manager open > through function calls. Here is what I mean: [...] > In order to keep the SSH session open and not have to re-establish it > across function calls, I would like to d

Re: Question about math.pi is mutable

2015-11-10 Thread Steven D'Aprano
ping. And it probably never will do that, because Guido likes the fact that CPython is simple enough for him to understand. He's happy for PyPy and other third-party implementations to do the clever stuff. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-11 Thread Steven D'Aprano
On Wed, 11 Nov 2015 07:30 pm, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Since compile, eval and exec are Python built-ins, if it doesn't >> include a byte-code compiler, it isn't Python. It's just a subset of >> Python. > > compile() can be

Re: new to python, help please !!

2015-11-11 Thread Steven D'Aprano
On Thursday 12 November 2015 04:48, Quivis wrote: > On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote: > >> md5 > > If those are md5 values stored inside files, wouldn't it be easier to > just hash them? > > import hashlib > > m1 = hashlib.sha224(open('f1').read()).hexdigest() > m2 = has

Re: Question about math.pi is mutable

2015-11-12 Thread Steven D'Aprano
Engelbert Humperdinck", "Cher", "Thomas Lahn" or "Bartholomew Roberts" how would you decide whether it was "real" or "fake"? Petty bigotry over "real" names is no better than any other sort of bigotry. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Jython standalone

2015-11-13 Thread Steven D'Aprano
u have Java installed? Are .jar files associated with the correct Java executable? > What does it need to give me a prompt? What sort of prompt to you expect? A Python prompt, DOS prompt, something else? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-13 Thread Steven D'Aprano
y # oops, meant x -= y If anything, this is an argument against the augmented assignment short-cuts, rather than the operators. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-13 Thread Steven D'Aprano
On Sat, 14 Nov 2015 02:01 pm, Chris Angelico wrote: > On Sat, Nov 14, 2015 at 1:40 PM, Steven D'Aprano > wrote: >> On Sat, 14 Nov 2015 09:42 am, Chris Angelico wrote: >> >>> However, this is a reasonable call for the abolition of unary plus... >> >>

Re: find which Python libraries are most influential in scientific research

2015-11-13 Thread Steven D'Aprano
ect, but they're not doing themselves (or us) any favours with the design of the webpage. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    76   77   78   79   80   81   82   83   84   85   >