Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Ben Bacarisse
Rivka Miller writes: > On Oct 25, 2:27 pm, Danny wrote: >> Why you just don't give us the string/input, say a line or two, and >> what you want off of it, so we can tell better what to suggest > > no one has really helped yet. Really? I was going to reply but then I saw Janis had given you the

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Ben Bacarisse
Rivka Miller writes: > Thanks everyone, esp this gentleman. Kind of you to single me out, but it was Janis Papanagnou who first posted the solution that you say "works best" for you. -- Ben. -- http://mail.python.org/mailman/listinfo/python-list

Re: meaning of [ ]

2017-09-04 Thread Ben Bacarisse
Rustom Mody writes: > On Sunday, September 3, 2017 at 5:10:13 PM UTC+5:30, Rick Johnson wrote: >> Andrej Viktorovich wrote: >> > I suppose p becomes array of strings but what [] means in this statement? >> >> Generally, it's an inline form of writing a loop that returns a >> list. There are othe

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-04 Thread Ben Bacarisse
Rustom Mody writes: > Here is some code I (tried) to write in class the other day > > The basic problem is of generating combinations > Now thats neat as far as it goes but combinations are fundamentally sets > not lists > > So I thought python would do a better job > I tried translating it to p

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-05 Thread Ben Bacarisse
Rustom Mody writes: > On Tuesday, September 5, 2017 at 1:44:24 AM UTC+5:30, Ben Bacarisse wrote: >> Rustom Mody writes: >> >> > Here is some code I (tried) to write in class the other day >> > >> > The basic problem is of generating combinations >

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-06 Thread Ben Bacarisse
Gregory Ewing writes: > Seems to me you're making life difficult for yourself (and > very inefficient) by insisting on doing the whole computation > with sets. If you want a set as a result, it's easy enough > to construct one from the list at the end. Yes, but my intent was to show that the pat

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-06 Thread Ben Bacarisse
Rustom Mody writes: > I posted it because I genuinely thought I had missed some obvious way > of splitting a set into an (arbitrary) element and a rest without > jumping through hoops. Evidently not Curious, because I posted because I thought you had. Anyway, for speed you probably just want

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-07 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, Sep 7, 2017 at 5:59 PM, Marko Rauhamaa wrote: >> Dennis Lee Bieber : >> >>> On Wed, 06 Sep 2017 10:37:42 +0300, Marko Rauhamaa >>> declaimed the following: >>> Which reminds me of this puzzle I saw a couple of days ago: 1 + 4 = 5 2 +

Re: A question on modification of a list via a function invocation

2017-09-08 Thread Ben Bacarisse
Steve D'Aprano writes: > On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote: > >> languages without mutable objects don't >> really care whether they're pass-by-X or pass-by-Y. > > Only if you don't care about efficiency. > > Believe me, the first time you pass a five gigabyte array to a function

Re: tictactoe script - commented - may have pedagogical value

2017-09-13 Thread Ben Bacarisse
Ian Kelly writes: > On Thu, Sep 7, 2017 at 2:05 AM, Chris Angelico wrote: >> On Thu, Sep 7, 2017 at 5:11 PM, Steven D'Aprano >>> I don't know why it places *two* pairs of crosses and naughts instead of >>> one. Maybe the page is broken. >> >> I think it is, as part of being on the Internet Archi

Re: Old Man Yells At Cloud

2017-09-18 Thread Ben Bacarisse
Steve D'Aprano writes: > [...] try something more common: > > 1/2 > > Most people aren't expecting integer division, but true division, and silently > returning the wrong result (0 instead of 0.5) is a silent source of > bugs. I'm the sure that expectation depends on their background and previou

Re: Old Man Yells At Cloud

2017-09-18 Thread Ben Bacarisse
Steve D'Aprano writes: > To answer your question, what do I mean by int/int being undefined, I'd have > to > dig into areas of maths that either weren't taught in the undergrad courses I > did, or that I've long since forgotten about. Something > about... fields? > This is a pretty specialised

Re: Old Man Yells At Cloud

2017-09-18 Thread Ben Bacarisse
bartc writes: > On 18/09/2017 15:04, Gregory Ewing wrote: >> Dennis Lee Bieber wrote: >>> Pascal >>> provides print()/println() [okay, not /statements/ but /procedures/] >> >> Actually write/writeln, and although they used parens like >> procedures, they had special syntax for output formatting >

Re: Old Man Yells At Cloud

2017-09-20 Thread Ben Bacarisse
bartc writes: > Value-Added-Tax in the UK increased from 17.5% to 20%, ... When it was 17.5% you could shock people not in the know by working it out in your head since it's much simpler than it sounds: take a tenth, halve it, halve it again, and add all three. -- Ben. -- https://mail.python.

Re: Even Older Man Yells At Whippersnappers

2017-09-20 Thread Ben Bacarisse
Larry Martell writes: > On Tue, Sep 19, 2017 at 12:12 PM, Rhodri James wrote: >> >> Eh, my school never 'ad an electronics class, nor a computer neither. Made >> programming a bit tricky; we 'ad to write programs on a form and send 'em >> off to next county. None of this new-fangled VHDL neith

Re: Printing a Chunk Of Words

2017-09-25 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Cai Gengyang writes: >> Boolean Operators >> >>True and True is True >>True and False is False >>False and True is False >>False and False is False >>True or True is True >>True or False is True >>False or True is Tr

Re: on a very slow function

2017-10-01 Thread Ben Bacarisse
Daniel Bastos writes: > def make_sequence_non_recursive(N, x0 = 2, c = -1): > "What's wrong with this function? It's very slow." > last = x0 > def sequence(): > nonlocal last > next = last > last = last**2 + c > return next % N > return sequence > > It crawls pretty soon.

Re: on a very slow function

2017-10-01 Thread Ben Bacarisse
Steve D'Aprano writes: > On Mon, 2 Oct 2017 09:49 am, Ben Bacarisse wrote: > >> Daniel Bastos writes: >> >>> def make_sequence_non_recursive(N, x0 = 2, c = -1): >>> "What's wrong with this function? It's very slow." >>>

Re: on a very slow function

2017-10-02 Thread Ben Bacarisse
Steve D'Aprano writes: > On Mon, 2 Oct 2017 12:00 pm, Ben Bacarisse wrote: > > >>> Better: >>> >>> last = (pow(last, 2, N) + (2 % N)) % N >> >> You meant c rather than 2, I think. > > Oops, yes, that was a typo. > > >>

Re: The "loop and a half"

2017-10-04 Thread Ben Bacarisse
Steve D'Aprano writes: > On Wed, 4 Oct 2017 04:45 am, Rhodri James wrote: > >> On 03/10/17 18:29, Stefan Ram wrote: >>>Is this the best way to write a "loop and a half" in Python? >> >> Define "best". > > I'd start with "define loop and a half". What it means to me is this pattern: while

Re: The "loop and a half"

2017-10-04 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Steve D'Aprano writes: >>For-each loops are MUCH easier to understand, and should be taught first. > > I prefer a bottom-up approach. > > For loops are based on iterators. > > So, "bottom-up" in this case means: iterators should be > taught b

Re: The "loop and a half"

2017-10-04 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > bartc writes: >>Note that your reverse-indentation style is confusing! > > In Python, indentation can be significant. > > Sometimes, some lines in Python must be indented by 0. > > This dictates that Python code cannot be indented > in posts

Re: Easier way to do this?

2017-10-04 Thread Ben Bacarisse
20/20 Lab writes: > Looking for advice for what looks to me like clumsy code. > > I have a large csv (effectively garbage) dump.  I have to pull out > sales information per employee and count them by price range. I've got > my code working, but I'm thinking there must be a more refined way of > d

Re: Pedagogical style [was Re: The "loop and a half"]

2017-10-05 Thread Ben Bacarisse
Steve D'Aprano writes: > There's no link to the original paper, only to secondary sources that discuss > it, e.g.: > > http://phys.org/pdf128266927.pdf > [1] Anecdotes are not data, but for what it is worth, just in the last two > days I came across two examples of this. Teaching a boy in Year

Re: The "loop and a half"

2017-10-05 Thread Ben Bacarisse
Steve D'Aprano writes: > On Fri, 6 Oct 2017 09:57 am, Marko Rauhamaa wrote: > > [quoting Bart] Yes, I tried typing 'sort' in Linux, where it apparently hangs (same on Windows actually). The reason: because it might have killed someone to have added a message saying what you are exp

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Ben Bacarisse
Chris Angelico writes: > On Fri, Oct 6, 2017 at 7:09 PM, Steve D'Aprano > wrote: >> What are the right ways for a Python script to detect these sorts of >> situations? >> >> (1) Standard input is coming from a pipe; >> >> (2) Stdin is being read from a file; >> >> (3) Stdin is coming from a huma

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Ben Bacarisse
Steve D'Aprano writes: > On Fri, 6 Oct 2017 09:33 pm, Ben Bacarisse wrote: > >> A general solution to the (rather odd) complaint about silent waiting >> should really check any input fileno to see if a prompt is needed.  You >> could argue, though, that anyone who&#x

Re: The "loop and a half"

2017-10-06 Thread Ben Bacarisse
bartc writes: > On 06/10/2017 14:35, Paul Moore wrote: >> On 6 October 2017 at 13:56, bartc wrote: >>> If you don't like the word 'crude', try 'lazy'. Take this example of the gcc >>> C compiler: >>> >>> > gcc -E program.c >>> >>> This preprocesses the code and shows the result. Typical progra

Re: The "loop and a half"

2017-10-06 Thread Ben Bacarisse
bartc writes: > It is anyway not really acceptable these days for a long list of data > to simply be typed in like that without any feedback at all. And 100% > dependent on your typing Ctrl-D at the end and not Ctrl-C by > mistake. This is not still the 1970s. It was not acceptable in the 1970s

Re: The "loop and a half"

2017-10-06 Thread Ben Bacarisse
bartc writes: > On 07/10/2017 01:14, Ben Bacarisse wrote: >> bartc writes: >> >>> On 06/10/2017 14:35, Paul Moore wrote: >>>> On 6 October 2017 at 13:56, bartc wrote: >>>>> If you don't like the word 'crude'

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
Bill writes: > Mikhail V wrote: > [...] I'm not here to "cast stones", I like Python. I just think > that you shouldn't cast stones at C/C++. Not while PHP exists. There aren't enough stones in the world... >>> PHP seems (seemed?) popular for laying out web pages. Are their va

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, Oct 12, 2017 at 7:42 AM, Ben Bacarisse wrote: >> Bill writes: >> >>> Mikhail V wrote: >>>>>>> [...] I'm not here to "cast stones", I like Python. I just think >>>>>>> that you

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
Gregory Ewing writes: > bartc wrote: > >> tokenrec * (*)[] >> >> the original source and that type is written like this: >> >> ref [] ref tokenrec > > The idiomatic way to write that type in C would be > >tokenrec ** That's a different type. I think you mean that a human writing C (

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Ben Bacarisse writes: >>That's a different type. I think you mean that a human writing C >>(rather than bartc's code generator) would probably design the code to >>use tokenrec ** then I agree, but the latter is not

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, Oct 12, 2017 at 9:44 AM, Ben Bacarisse wrote: >> Chris Angelico writes: >>> Check out Django and Flask, the two most popular ways. I quite like >>> Flask. >> >> I see. Both appear to be frameworks (I'd heard of Djang

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, Oct 12, 2017 at 11:55 AM, Ben Bacarisse wrote: >> Chris Angelico writes: >>> it binds your URLs to >>> the concrete file system. That may not seem like too much of a >>> problem, but it's a pretty big limita

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Ben Bacarisse
Steve D'Aprano writes: > On Thu, 12 Oct 2017 02:43 am, Marko Rauhamaa wrote: > >> Chris Angelico : >> >>> The places where C++ is not a superset of C are mostly things you >>> wouldn't want to be doing anyway. You can generally take C code and >>> compile it with a C++ compiler, and it'll have t

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, Oct 12, 2017 at 12:19 PM, Ben Bacarisse wrote: >> Chris Angelico writes: >> >>> On Thu, Oct 12, 2017 at 11:55 AM, Ben Bacarisse >>> wrote: >>>> Chris Angelico writes: >>>>> it binds your URLs to >

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Ben Bacarisse
Gregory Ewing writes: > Ben Bacarisse wrote: >> That's a different type. I think you mean that a human writing C >> (rather than bartc's code generator) would probably design the code to >> use tokenrec ** then I agree, but the latter is not just a different way

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, Oct 12, 2017 at 7:32 PM, Thomas Jollans wrote: >> On 2017-10-12 07:31, Chris Angelico wrote: >>> On Thu, Oct 12, 2017 at 12:19 PM, Ben Bacarisse >>> wrote: >>>> Provided some early part of the URL is handled by PHP, the r

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Ben Bacarisse
Jon Ribbens writes: > On 2017-10-12, Ben Bacarisse wrote: >> Chris Angelico writes: >>> Normally, with a Python-based framework, you don't need _any_ web >>> server configuration. You simply define your URL routing within the >>> Python code. The o

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Ben Bacarisse
Thomas Jollans writes: > On 2017-10-12 15:16, Ben Bacarisse wrote: >> Gregory Ewing writes: >> >>> Ben Bacarisse wrote: >>>> That's a different type. I think you mean that a human writing C >>>> (rather than bartc's code generator) wou

Re: Lies in education [was Re: The "loop and a half"]

2017-10-12 Thread Ben Bacarisse
Jon Ribbens writes: > On 2017-10-12, Ben Bacarisse wrote: >> I see. If I'm reading this right, the app requests are passed through >> to another server -- uWSGI. > > Yes. It doesn't have to be uWSGI; it could be gunicorn, or you could > probably use Apache

Re: Heroku (was Re: Lies in education [was Re: The "loop and a half"])

2017-10-12 Thread Ben Bacarisse
Chris Angelico writes: > On Fri, Oct 13, 2017 at 1:09 AM, Ben Bacarisse wrote: >> Chris Angelico writes: >> >>> On Thu, Oct 12, 2017 at 7:32 PM, Thomas Jollans wrote: >>>> On 2017-10-12 07:31, Chris Angelico wrote: >>>>> On Thu, Oc

Re: Heroku (was Re: Lies in education [was Re: The "loop and a half"])

2017-10-13 Thread Ben Bacarisse
Chris Angelico writes: > On Fri, Oct 13, 2017 at 10:14 AM, Ben Bacarisse wrote: >> Chris Angelico writes: >>> I abbreviated that down to nothing, but since you ask, here's a really >>> REALLY simple run-down of how to use Heroku: >> >> I

Re: Heroku (was Re: Lies in education [was Re: The "loop and a half"])

2017-10-13 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Oct 14, 2017 at 8:42 AM, Ben Bacarisse wrote: >> Chris Angelico writes: >> >>> On Fri, Oct 13, 2017 at 10:14 AM, Ben Bacarisse >>> wrote: >>>> Chris Angelico writes: >>>>> I abbreviated that down

Re: Heroku (was Re: Lies in education [was Re: The "loop and a half"])

2017-10-14 Thread Ben Bacarisse
"Peter J. Holzer" writes: > On 2017-10-13 21:42, Ben Bacarisse wrote: >> That's one way to put it. Another is that to use Python I need to buy a >> new service that is already configured. > > That's exactly the same for PHP. You can't use that ei

Re: Python 2 -> 3, urllib.urlopen (corrected the case)

2017-10-14 Thread Ben Bacarisse
Irv Kalb writes: Lots of detail snipped. I hope it won't matter... > (_ssl.c:749)> > > Huh??? > > I've read a bunch of documentation, and it looks like I'm doing > everything right, but I cannot get this to work. Any other > suggestions to get this 3 line program to work correctly? Just a da

Re: Python 2 -> 3, urllib.urlopen (corrected the case)

2017-10-14 Thread Ben Bacarisse
Irv Kalb writes: > Thank you! You're welcome. >> Just a data point... It works here: >> >> $ python3 t.py >> Response is: b'156.99\n' >> $ cat t.py >> import urllib.request >> fullURLWithParameters = 'http://finance.yahoo.com/d/quotes.csv?s=aapl&f=l1' >> # read all the data >> response = ur

Re: Python 2 -> 3, urllib.urlopen (corrected the case)

2017-10-15 Thread Ben Bacarisse
Irv Kalb writes: >> On Oct 14, 2017, at 6:46 PM, Ben Bacarisse wrote: >>>> Finally, wget -S shows that the resource has moved. It is now at >>>> >>>> Location: http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1 >>>> >>

Re: Compression of random binary data

2017-10-23 Thread Ben Bacarisse
danceswithnumb...@gmail.com writes: > ... First let me clarify before you lump this in with > perpetual motion, or cold fusion. It is a mapping solution to compress > ANY i repeat ANY random file with numbers of only 0 - 9 such as are in > the million rand numbers page. Entirely possible. Of cour

Re: Compression of random binary data

2017-10-24 Thread Ben Bacarisse
danceswithnumb...@gmail.com writes: > Finally figured out how to turn this into a random binary compression > program. Since my transform can compress more than dec to binary. Then > i took a random binary stream, Forget random data. For one thing it's hard to define, but more importantly no one

Re: Compression of random binary data

2017-10-24 Thread Ben Bacarisse
Paul Moore writes: > On 24 October 2017 at 11:23, Ben Bacarisse wrote: >> For example, run the complete works of Shakespeare through your program. >> The result is very much not random data, but that's the sort of data >> people want to compress. If you can c

Re: Compression of random binary data

2017-10-24 Thread Ben Bacarisse
Steve D'Aprano writes: > On Tue, 24 Oct 2017 09:23 pm, Ben Bacarisse wrote: > >> Forget random data. For one thing it's hard to define, > > That bit is true. > >> but more importantly no one cares about it. > > But that's wrong. All generalisa

Re: Compression of random binary data

2017-10-24 Thread Ben Bacarisse
Steve D'Aprano writes: > On Tue, 24 Oct 2017 06:46 pm, danceswithnumb...@gmail.com wrote: > >> Greg, you're very smart, but you are missing a big key. I'm not padding, >> you are still thinking inside the box, and will never solve this by doing >> so. Yes! At least you see my accomplishment, thi

Re: Compression of random binary data

2017-10-26 Thread Ben Bacarisse
Gregory Ewing writes: > Ben Bacarisse wrote: >> The trouble is a pedagogic one. Saying "you can't compress random data" >> inevitably leads (though, again, this is just my experience) to endless >> attempts to define random data. > > It's more

Re: Compression of random binary data

2017-10-27 Thread Ben Bacarisse
Marko Rauhamaa writes: > Ben Bacarisse : > >>> In this context, "random data" really means "uniformly distributed >>> data", i.e. any bit sequence is equally likely to be presented as >>> input. *That's* what information theory says can&#

Re: Compression of random binary data

2017-10-28 Thread Ben Bacarisse
Steve D'Aprano writes: > On Fri, 27 Oct 2017 09:53 am, Ben Bacarisse wrote: > >> A source of random can be defined but "random data" is much more >> illusive. > > Random data = any set of data generated by "a source of random". (I had an edit

Re: Compression of random binary data

2017-10-29 Thread Ben Bacarisse
Gregory Ewing writes: > Ben Bacarisse wrote: >> But that has to be about the process that gives rise to the data, not >> the data themselves. > >> If I say: "here is some random data..." you can't tell if it is or is >> not from a random sou

Re: Report on non-breaking spaces in posts

2017-10-31 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: >>|od -c tmp.txt >>|... >>|0012620 s u l a t e i t : \n \n     >>|0012640      d e f w r a p p e d _ >>|... >>| >>|od -x tmp.txt >>|.

Re: Report on non-breaking spaces in posts

2017-10-31 Thread Ben Bacarisse
Rhodri James writes: > On 31/10/17 17:23, Stefan Ram wrote: >> Ned Batchelder writes: >>>     def wrapped_join(values, sep): >> >>Ok, here's a report on me seing non-breaking spaces in >>posts in this NG. I have written this report so that you >>can see that it's not my newsreader

Re: Code Snippets

2017-11-01 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Wolfgang Maier writes: >>If you're worried bout having things on separate lines, you could write: >>import os; os.getcwd() >>,etc., which is actually saving a few characters :) > > Yes, but there still is the risk of the identifier »os« > already

Re: replacing `else` with `then` in `for` and `try`

2017-11-01 Thread Ben Bacarisse
Steve D'Aprano writes: > On Thu, 2 Nov 2017 08:12 am, Alexey Muranov wrote: > >> what do you think about the idea of replacing "`else`" with "`then`" in >> the contexts of `for` and `try`? > > Yes, this, exactly!!! > > (For while and for loops, but not try -- see below.) > > I have argued this fo

Re: replacing `else` with `then` in `for` and `try`

2017-11-02 Thread Ben Bacarisse
Steve D'Aprano writes: > On Thu, 2 Nov 2017 12:50 pm, Ben Bacarisse wrote: > >> Steve D'Aprano writes: >> >>> On Thu, 2 Nov 2017 08:12 am, Alexey Muranov wrote: >>> >>>> what do you think about the idea of replacing "`else`"

Re: replacing `else` with `then` in `for` and `try`

2017-11-02 Thread Ben Bacarisse
Steve D'Aprano writes: > On Thu, 2 Nov 2017 10:09 pm, Ben Bacarisse wrote: > >> Sure, but your argument seemed to that else has entirely the wrong >> meaning (I certainly to a double take when I have to remember what it >> means) and, in that context, finally has

Re: Goto (Posting On Python-List Prohibited)

2017-12-30 Thread Ben Bacarisse
bartc writes: > On 30/12/2017 16:53, mm0fmf wrote: >> On 30/12/2017 14:41, bartc wrote: >>> it looks a bit naff >> >> Understatement of 2017. > > I'm honest about my own ideas, but my remarks were about the use of > special symbols such as "::" and "@". > > Before completely dismissing it however

Re: Goto (Posting On Python-List Prohibited)

2017-12-30 Thread Ben Bacarisse
bartc writes: > On 30/12/2017 20:36, Ben Bacarisse wrote: >> bartc writes: >> >>> On 30/12/2017 16:53, mm0fmf wrote: >>>> On 30/12/2017 14:41, bartc wrote: >>>>> it looks a bit naff >>>> >>>> Understatement of 2017.

Re: Goto (Posting On Python-List Prohibited)

2017-12-31 Thread Ben Bacarisse
bartc writes: > On 31/12/2017 12:41, Chris Angelico wrote: >> On Sun, Dec 31, 2017 at 11:33 PM, bartc wrote: >>> On 30/12/2017 23:54, Chris Angelico wrote: > I've written code that uses dirty tricks like that to avoid duplication. It's at least as much of a problem as actual duplicatio

Re: Goto (Posting On Python-List Prohibited)

2017-12-31 Thread Ben Bacarisse
bartc writes: > On 31/12/2017 15:02, Ben Bacarisse wrote: >> bartc writes: > >> I think there's a problem with that. Standard C does not have them, you >> said your language does not implement them properly > > (The real problem is I don't remember lo

Re: Goto (Posting On Python-List Prohibited)

2017-12-31 Thread Ben Bacarisse
bartc writes: > On 31/12/2017 22:09, Ben Bacarisse wrote: > >> No, you missed the point and did not address the question. You said (now >> cut) >> >> | If I thought introducing functions, whether local or not, as a way of >> | avoiding goto was worth doing, I

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Ben Bacarisse
Marko Rauhamaa writes: > Many people think static typing is key to high quality. I tend to think > the reverse is true: the boilerplate of static typing hampers > expressivity so much that, on the net, quality suffers. I don't find that with Haskell. It's statically typed but the types are almo

Re: could use some help with this problem! I've been working on it for days but cant seem to get it right !

2018-02-20 Thread Ben Bacarisse
Marc Cohen writes: > USING PYTHON 2: Why is that? > Write a program to play this game. This may seem tricky, so break it > down into parts. Like many programs, we have to use nested loops (one > loop inside another). In the outermost loop, we want to keep playing > until we are out of stones.

Re: could use some help with this problem! (Posting On Python-List Prohibited)

2018-02-20 Thread Ben Bacarisse
Lawrence D’Oliveiro writes: > On Wednesday, February 21, 2018 at 3:10:25 AM UTC+13, Ben Bacarisse wrote: >> You almost never /have/ to use nested loops. Has the course got this >> far without introducing the idea of a function? > > If you are using a function to avoid a

Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread Ben Bacarisse
Steven D'Aprano writes: > On Fri, 23 Feb 2018 00:26:33 +, bartc wrote: > >> The point of the article was Julia vs. Python. You can't make Python >> faster by switching to a faster algorithm; you have to use the same one >> on both. > > No, the point of the article was to write Python code tha

Re: How to make Python run as fast (or faster) than Julia

2018-02-26 Thread Ben Bacarisse
bartc writes: > A C version is given below. (One I may have messed around with, which > I'm not sure works properly. For an original, google for Marsaglia and > KISS64 or SUPRKISS64.) The version I know uses unsigned integers. Did you change then to signed? For a Python version, go back to the

Re: How to make Python run as fast (or faster) than Julia

2018-02-27 Thread Ben Bacarisse
Christian Gollwitzer writes: > George Marsaglia is a researcher who invented a couple of PRNGs which > are both simple (one of the first was called KISS) yet surprisingly > good. s/is/was/ Sadly, he died a few years ago (2011). -- Ben. -- https://mail.python.org/mailman/listinfo/python-list

Re: Local variable definition in Python list comprehension

2022-09-01 Thread Ben Bacarisse
James Tsai writes: > I find it very useful if I am allowed to define new local variables in > a list comprehension. For example, I wish to have something like > [(x, y) for x in range(10) for y := x ** 2 if x + y < 80], or > [(x, y) for x in range(10) with y := x ** 2 if x + y < 80]. > > For now

Re: bool and int

2023-01-26 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, 26 Jan 2023 at 08:19, Dino wrote: >> >> On 1/23/2023 11:22 PM, Dino wrote: >> > >>> b = True >> > >>> isinstance(b,bool) >> > True >> > >>> isinstance(b,int) >> > True >> > >>> >> >> ok, I read everything you guys wrote. Everyone's got their reasons >> obviou

Re: evaluation question

2023-01-27 Thread Ben Bacarisse
mutt...@dastardlyhq.com writes: > Hi It looks like you posted this question via Usenet. comp.lang.python is essentially dead as a Usenet group. It exists, and gets NNTP versions of mail sent to the mailing list, but nothing posted to the group via NNTP get send on the mailing list. I prefer Us

Re: Usenet vs. Mailing-list

2023-01-28 Thread Ben Bacarisse
"Peter J. Holzer" writes: > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >> mutt...@dastardlyhq.com writes: >> >> > Hi >> >> It looks like you posted this question via Usenet. comp.lang.python is >> essentially dead as a Usenet group

Re: Usenet vs. Mailing-list

2023-01-28 Thread Ben Bacarisse
Jon Ribbens writes: > On 2023-01-29, Ben Bacarisse wrote: >> "Peter J. Holzer" writes: >> >>> On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >>>> mutt...@dastardlyhq.com writes: >>>> >>>> > Hi >>&

Re: Usenet vs. Mailing-list

2023-01-29 Thread Ben Bacarisse
Igor Berger writes: > On Saturday, January 28, 2023 at 10:02:57 PM UTC-5, Ben Bacarisse wrote: >> Jon Ribbens writes: >> >> > On 2023-01-29, Ben Bacarisse wrote: >> >> "Peter J. Holzer" writes: >> >> >> >

Re: sqlite3 cannot detect the version of compiled sqlite version at some point in runtime.

2021-01-20 Thread Ben Bacarisse
panfei writes: > 4. Test sqlite3 > Python 3.9.1 (default, Jan 20 2021, 14:32:50) > [GCC 10.2.0] on linux > Type "help", "copyright", "credits" or "license" for more information. import sqlite3 conn = sqlite3.connect(':memory:') conn.create_function('f', 2, lambda *args: None, deter

Re: Mr. Flibble

2021-02-15 Thread Ben Bacarisse
Mr Flibble writes: > On 15/02/2021 18:09, Ethan Furman wrote: >> Thank you to those who pointed out this individual to the >> moderators. As Mr. Flibble accurately noted, he is not on the mailing >> list -- so his posts won't be here either. > > ORLY? You said you used Usenet (and your reply her

Re: Mr. Flibble

2021-02-15 Thread Ben Bacarisse
Ethan Furman writes: > On 2/15/21 2:02 PM, Grant Edwards wrote: >> On 2021-02-15, Ben Bacarisse wrote: >> >>> You said you used Usenet (and your reply here was via Usenet). >>> Usenet posts to comp.lang.python don't go to the mailing list (the >>>

Re: New Python implementation

2021-02-16 Thread Ben Bacarisse
"Avi Gross" writes: > Thanks for sharing. I took a look and he does have a few schemas for Ada and > C from TWO YEARS ago. Nothing about the infinite number of other languages > he plans on supporting, let alone Python. And what he has is likely not > enough to do what he claims he can do easily

Re: neonumeric - C++ arbitrary precision arithmetic library

2021-03-06 Thread Ben Bacarisse
Mr Flibble writes: >> Someone who says that he is capable of writing a compiler that >> translates every language has megalomania. No one can do this. > > Just because you can't make one it doesn't follow that nobody else > can. True, but lots of very knowledgeable people have tried and failed.

Re: Help with gaussian filter from scipy

2021-07-07 Thread Ben Bacarisse
Arak Rachael writes: > this time I am stuck on gaussian_filter scipy returns none instead of some > valid gaussian filtered image, can someone help me please. > > Here is the full code: > https://www.dropbox.com/s/18ylpiwmhlu5n62/test_filter_xdog.ipynb?dl=0 It might help to link to the code its

Re: Help with gaussian filter from scipy

2021-07-07 Thread Ben Bacarisse
Arak Rachael writes: > On Wednesday, 7 July 2021 at 12:47:40 UTC+2, Arak Rachael wrote: >> On Wednesday, 7 July 2021 at 12:41:44 UTC+2, Ben Bacarisse wrote: >> > Arak Rachael writes: >> > >> > > this time I am stuck on gaussian_filter scipy returns none

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 5:08 AM ast wrote: >> >>> 0.3 + 0.3 + 0.3 == 0.9 >> False > > That's because 0.3 is not 3/10. It's not because floats are > "unreliable" or "inaccurate". It's because the ones you're entering > are not what you think they are. > > When will peop

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse wrote: >> >> Chris Angelico writes: >> >> > On Sat, Nov 20, 2021 at 5:08 AM ast wrote: >> >> >> >>> 0.3 + 0.3 + 0.3 == 0.9 >> >> False >> > >

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-19 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse wrote: >> >> Chris Angelico writes: >> >> > On Sat, Nov 20, 2021 at 9:07 AM Ben Bacarisse wrote: >> >> >> >> Chris Angelico writes: >> >> >> >&g

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Ben Bacarisse
Chris Angelico writes: > On Sat, Nov 20, 2021 at 3:41 PM Ben Bacarisse wrote: >> >> Chris Angelico writes: >> >> > On Sat, Nov 20, 2021 at 12:43 PM Ben Bacarisse >> > wrote: >> >> >> >> Chris Angelico writes: >> >

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

2021-11-20 Thread Ben Bacarisse
Grant Edwards writes: > On 2021-11-20, Ben Bacarisse wrote: > >> You seem to be agreeing with me. It's the floating point part that is >> the issue, not the base itself. > > No, it's the base. Floating point can't represent 3/10 _because_ it's > b

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

2016-08-17 Thread Ben Bacarisse
MRAB writes: > On 2016-08-17 18:19, Jussi Piitulainen wrote: >> MRAB writes: >> >>> On 2016-08-17 12:24, Jussi Piitulainen wrote: BartC writes: > On 17/08/2016 07:39, Steven D'Aprano wrote: >> Rather than ask why Python uses `trueval if cond else falseval`, you >> should ask

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

2016-08-17 Thread Ben Bacarisse
Jussi Piitulainen writes: > BartC writes: > >> On 17/08/2016 07:39, Steven D'Aprano wrote: >>> Rather than ask why Python uses `trueval if cond else falseval`, you >>> should ask why C uses `cond ? trueval : falseval`. Is that documented >>> anywhere? >> >> I'm not fond of C's a ? b : c but the p

Re: The Joys Of Data-Driven Programming

2016-08-21 Thread Ben Bacarisse
Tim Chase writes: > On 2016-08-21 04:53, Rustom Mody wrote: >> 2. Basic computing theory shows that re-s and dfas are equivalent. >> Which would one prefer to write/debug? [Thats not a rhetorical >> question] > > I'm curious where REs and DFAs are shown to be equivalent (serious, > not trying to

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

2016-08-29 Thread Ben Bacarisse
Steve D'Aprano writes: > On Mon, 29 Aug 2016 10:31 pm, Chris Angelico wrote: > >> On Mon, Aug 29, 2016 at 10:13 PM, BartC wrote: >>> In C, you can write this: >>> >>> int x; >>> >>> x = 5; >>> x = "hello"; >>> >>> With certain compilers (eg. gcc) you only get a warning. (And since I >>> don't

Re: Assignment versus binding

2016-10-04 Thread Ben Bacarisse
Marko Rauhamaa writes: > dieter : >> The concept "assignment" comes from an operational semantics based on >> some form of "RAM" machine. Such a machine has storage cells where you >> can assign values to which remain there until overridden with a new >> value. >> >> The concept "binding" comes f

Re: Assignment versus binding

2016-10-04 Thread Ben Bacarisse
Steve D'Aprano writes: > On Tue, 4 Oct 2016 11:27 pm, Ben Bacarisse wrote: > >> Haskell defines let (it's version of multiple mutually recursive >> bindings) in terms of the least fix point of a lambda function whose >> (pattern) parameter binds the expression

  1   2   3   >