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

2012-10-25 Thread Ben Bacarisse
Rivka Miller rivkaumil...@gmail.com writes: On Oct 25, 2:27 pm, Danny dann90...@gmail.com 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

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

2012-10-26 Thread Ben Bacarisse
Rivka Miller rivkaumil...@gmail.com 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. snip -- Ben. -- http://mail.python.org/mailman/listinfo/python-list

Re: Program Translation - Nov. 14, 2013

2013-11-17 Thread Ben Bacarisse
E.D.G. edgrs...@ix.netcom.com writes: E.D.G. edgrs...@ix.netcom.com wrote in message news:jckdnqiu1zxguxvpnz2dnuvz_qmdn...@earthlink.com... E.D.G. edgrs...@ix.netcom.com wrote in message news:ro-dnch2dptbrhnpnz2dnuvz_rsdn...@earthlink.com... Etgtab FORTRAN project Perl speed comparison

Re: May I drop list bracket from list?

2015-04-23 Thread Ben Bacarisse
subhabrata.bane...@gmail.com writes: I am trying to read a list of files as list_of_files = glob.glob('C:\Python27\*.*') Now I am trying to read each one of them, convert into list of words, and append to a list as. list1=[] for file in list_of_files: print file

Re: code blocks

2015-05-03 Thread Ben Bacarisse
Dr. John Q. Hacker zonderv...@gmail.com writes: I'm thinking how interesting it would be to add code blocks to Python, so that arbitrary strings of code can be passed around. It would open up some interesting possibilities for self-modifying code and generic programming. Since Python has

Re: Best way to use globally format

2015-05-03 Thread Ben Bacarisse
Cecil Westerhof ce...@decebal.nl writes: I have a file where I used a lot of {0}, {1} and {2}. Most but not all are changed to {0:.3E}, {1:.3E} and {2:.3E}. But when I want to change the format I come in dependency hell. I could do something like: format = ':.3E' fmt0 = '{0' +

Re: Great Math Mystery

2015-04-16 Thread Ben Bacarisse
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Fri, 17 Apr 2015 07:15 am, Seymore4Head wrote: I am guessing that a few here might find this program interesting. http://video.pbs.org/video/2365464997/ For the sake of those of us with limited access to the Internet at the

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Ben Bacarisse
Ian Kelly ian.g.ke...@gmail.com writes: On Tue, Apr 7, 2015 at 12:55 PM, Terry Reedy tjre...@udel.edu wrote: On 4/7/2015 1:44 PM, Ian Kelly wrote: def to_base(number, base): ... digits = [] ... while number 0: ... digits.append(number % base) ... number //= base

Re: Concatenating Strings

2015-04-09 Thread Ben Bacarisse
Chris Angelico ros...@gmail.com writes: On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Travis Griggs travisgri...@gmail.com writes: Here’s 3 examples: if k + ‘_@‘ in documents: timeKey = k + ‘_@‘ historyKey = thingID + ‘_’ + k In addition

Re: What is considered an advanced topic in Python?

2015-06-01 Thread Ben Bacarisse
Laura Creighton l...@openend.se writes: In a message of Mon, 01 Jun 2015 19:45:31 +1000, Chris Angelico writes: On Mon, Jun 1, 2015 at 5:58 PM, Laura Creighton l...@openend.se wrote: If you are giving a talk about Decimal -- and trying to stamp out the inappropriate use of floats you have to

Re: regex recursive matching (regex 2015.07.19)

2015-08-19 Thread Ben Bacarisse
MRAB pyt...@mrabarnett.plus.com writes: On 2015-08-18 22:55, Ben Bacarisse wrote: Neal Becker ndbeck...@gmail.com writes: Trying regex 2015.07.19 I'd like to match recursive parenthesized expressions, with groups such that '(a(b)c)' would give group(0) - '(a(b)c)' group(1) - '(b

Re: regex recursive matching (regex 2015.07.19)

2015-08-18 Thread Ben Bacarisse
Neal Becker ndbeck...@gmail.com writes: Trying regex 2015.07.19 I'd like to match recursive parenthesized expressions, with groups such that '(a(b)c)' would give group(0) - '(a(b)c)' group(1) - '(b)' but that's not what I get import regex #r = r'\((?[^()]|(?R))*\)' r =

Re: Linear time baseconversion

2015-06-29 Thread Ben Bacarisse
Ian Kelly ian.g.ke...@gmail.com writes: On Mon, Jun 29, 2015 at 4:56 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Jun 29, 2015 at 4:39 PM, jonas.thornv...@gmail.com wrote: http://jt.node365.se/baseconversion8.html snip By the way, I think you have a bug. I did my time testing by

Re: Can I copy/paste Python code?

2015-07-21 Thread Ben Bacarisse
Christian Gollwitzer aurio...@gmx.de writes: On 21.07.2015 04:55, Chris Angelico wrote: On Tue, Jul 21, 2015 at 12:49 PM, ryguy7272 ryanshu...@gmail.com wrote: [...] Every time I paste in any kind of code, it seems like everything is immediately left-justified, and then nothing works. snip

Re: What use of 'sum' in this line code?

2016-01-03 Thread Ben Bacarisse
Robert writes: > I find below code snippet on line: > > // > m = 10 > theta_A = 0.8 > theta_B = 0.3 > theta_0 = [theta_A, theta_B] > > coin_A = bernoulli(theta_A) > coin_B = bernoulli(theta_B) > > xs = map(sum, [coin_A.rvs(m), coin_A.rvs(m), coin_B.rvs(m), >

Re: Operator precedence problem

2016-06-06 Thread Ben Bacarisse
Rustom Mody writes: > Kernghan/Thomson/Ritchie (dont remember which) actually admitted to the > fact that these precedences are wrong > The mistake that C creators made was to treat bitwise operators as > *logical* rather than as *arithmetic* It was more that they did

Re: reduction

2016-05-31 Thread Ben Bacarisse
Ian Kelly writes: > On Tue, May 31, 2016 at 8:22 AM, Fillmore wrote: >> >> My problem. I have lists of substrings associated to values: >> >> ['a','b','c','g'] => 1 >> ['a','b','c','h'] => 1 >> ['a','b','c','i'] => 1 >> ['a','b','c','j'] => 1

Re: Can math.atan2 return INF?

2016-06-22 Thread Ben Bacarisse
Steven D'Aprano writes: > On Wed, 22 Jun 2016 04:01 am, Pierre-Alain Dorange wrote: >> I do not know under what circumstance atan2 can return NAN, atan2 taks 2 >> argument (y and x) and return the angle corresponding to y/x. >> If x is 0.0, atan2 return 0.0 (do not try to

Re: Can math.atan2 return INF?

2016-06-23 Thread Ben Bacarisse
Steven D'Aprano <st...@pearwood.info> writes: > On Thu, 23 Jun 2016 05:17 am, Ben Bacarisse wrote: > >> pdora...@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes: >> >>> Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >>> >>>> >

Re: Can math.atan2 return INF?

2016-06-23 Thread Ben Bacarisse
Steven D'Aprano writes: > On Thursday 23 June 2016 14:40, Dan Sommers wrote: > >>> Since x == y, the answer should be the same as for any other pair of x == y. >> >> When x == y == 0, then atan2(y, x) is 0. I see just added noise by making the same comment

Re: Can math.atan2 return INF?

2016-06-22 Thread Ben Bacarisse
pdora...@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes: > Ben Bacarisse <ben.use...@bsb.me.uk> wrote: > >> >>> math.atan2(INF, INF) >> 0.7853981633974483 >> >> I would have expected NaN since atan2(INF, INF) could be thought of as >>

Re: Can math.atan2 return INF?

2016-06-23 Thread Ben Bacarisse
alister <alister.w...@ntlworld.com> writes: > On Thu, 23 Jun 2016 15:39:43 +0100, Ben Bacarisse wrote: > >> Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: >> >>> On Thursday 23 June 2016 14:40, Dan Sommers wrote: >>> >>>

Re: Text input with keyboard, via input methods

2016-03-10 Thread Ben Bacarisse
Marko Rauhamaa writes: > Ben Finney : > >> As for how solved it is, that depends on what you're hoping for as a >> solution. >> >> [...] >> >> Hopefully your operating system has a good input method system, with >> many input methods available to

Re: sobering observation, python vs. perl

2016-03-19 Thread Ben Bacarisse
Marko Rauhamaa writes: > "Charles T. Smith" : > >> Actually, I saw a study some years ago that concluded that python >> could be both slower and faster than perl, but that perl had much less >> deviation than python. I took that and accepted it, but

Re: Unicode normalisation [was Re: [beginner] What's wrong?]

2016-04-09 Thread Ben Bacarisse
alister writes: > > the design of qwerty was not to "Slow" the typist bu to ensure that the > hammers for letters commonly used together are spaced widely apart, > reducing the portion of trier travel arc were the could jam. > I and E are actually such a pair which

Re: Unicode normalisation [was Re: [beginner] What's wrong?]

2016-04-09 Thread Ben Bacarisse
Ben Bacarisse <ben.use...@bsb.me.uk> writes: > alister <alister.w...@ntlworld.com> writes: > >> >> the design of qwerty was not to "Slow" the typist bu to ensure that the >> hammers for letters commonly used together are spaced widely apart, &g

Re: Unicode normalisation [was Re: [beginner] What's wrong?]

2016-04-09 Thread Ben Bacarisse
Rustom Mody <rustompm...@gmail.com> writes: > On Saturday, April 9, 2016 at 7:14:05 PM UTC+5:30, Ben Bacarisse wrote: >> The problem with that theory is that 'er/re' (this is e and r in either >> order) is the 3rd most common pair in English but have been placed >> toge

Re: Convert list to another form but providing same information

2016-03-21 Thread Ben Bacarisse
Ian Kelly <ian.g.ke...@gmail.com> writes: > On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> For experts here: why can't I write a lambda that has a statement in it >> (actually I wanted two: lambda l, i: l[i] += 1; return l)? > &

Re: How to waste computer memory?

2016-03-20 Thread Ben Bacarisse
Rustom Mody writes: > On Sunday, March 20, 2016 at 10:32:07 AM UTC+5:30, Steven D'Aprano wrote: >> Unicode (the character set part of it) is a set of abstract 23-bit numbers, > > 23? Or 21? It's 21. The reason being (or at least part of the reason being) that 21 bits

Re: Convert list to another form but providing same information

2016-03-21 Thread Ben Bacarisse
Maurice writes: > Hello, hope everything is okay. I think someone might have dealt with > a similar issue I'm having. > > Basically I wanna do the following: > > I have a list such [6,19,19,21,21,21] (FYI this is the item of a >certain key in the dictionary) > >

Re: [OT'ish] Is there a list as good as this for Javascript

2016-03-25 Thread Ben Bacarisse
Cousin Stanley writes: > >> Occasionally I have to make forays into Javascript, >> can anyone recommend a place similar to this list >> where Javascript questions can be asked ? > > > Several years back I found > the newsgroup comp.lang.javascript > to

Re: Undefined behaviour in C [was Re: The Cost of Dynamism]

2016-03-27 Thread Ben Bacarisse
Steven D'Aprano writes: > On Sun, 27 Mar 2016 05:13 pm, Paul Rubin wrote: > >> Steven D'Aprano writes: >>> For example, would you consider that this isolated C code is >>> "meaningless"? >>> int i = n + 1; >> >> It's meaningful as long as n is in a

Re: List of Functions

2016-03-27 Thread Ben Bacarisse
Richard Riehle writes: > Several months ago, I posted a question regarding how to create a list > of functions. > I realize that this seems trivial to many experience Pythonistas. But > it might prove useful for those who are relative newcomers to the > language. In any case,

Re: List of Functions

2016-03-28 Thread Ben Bacarisse
Steven D'Aprano <st...@pearwood.info> writes: > On Mon, 28 Mar 2016 06:51 pm, Jussi Piitulainen wrote: > >> Ben Bacarisse writes: >> >>> It's shame that anonymous functions (for that's what's being returned >>> here -- a function with no name) were born

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-30 Thread Ben Bacarisse
Dennis Lee Bieber writes: > On Tue, 29 Mar 2016 20:14:02 -0700 (PDT), Rustom Mody > declaimed the following: > > >>Pascal ? C ? Python is a slide down because >>Pascal had the clear distinction of procedure and function > > That goes back to

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-28 Thread Ben Bacarisse
BartC writes: > On 28/03/2016 01:54, Steven D'Aprano wrote: >> What should be the return value of this statement? >> >> while True: >> x += 1 >> if condition: break > > Many statements such as loops just returned 'void' in A68. The > interesting statements were if,

Re: for / while else doesn't make sense

2016-05-23 Thread Ben Bacarisse
Ian Kelly writes: > On Mon, May 23, 2016 at 2:09 AM, Steven D'Aprano > wrote: >> Are you saying that the Egyptians, Babylonians and Greeks didn't know how to >> work with fractions? >> >>

Re: for / while else doesn't make sense

2016-05-23 Thread Ben Bacarisse
Chris Angelico <ros...@gmail.com> writes: > On Tue, May 24, 2016 at 12:29 AM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Right, but this is to miss the point. Let's say that 4000 years have >> defined 1/3 to be one third, but Python 3 (as do many programmin

Re: for / while else doesn't make sense

2016-05-23 Thread Ben Bacarisse
Mark Dickinson <mdickin...@enthought.com> writes: > Ben Bacarisse bsb.me.uk> writes: >> [1] Not being a Python expert I don't know how you show that actual >> value of a float. What is the Pythonic way to do that? > > I don't know about Pythonic, but here ar

Re: for / while else doesn't make sense

2016-05-23 Thread Ben Bacarisse
Steven D'Aprano <st...@pearwood.info> writes: > On Tue, 24 May 2016 12:29 am, Ben Bacarisse wrote: > >> Ian Kelly <ian.g.ke...@gmail.com> writes: >> >>> On Mon, May 23, 2016 at 2:09 AM, Steven D'Aprano >>> <steve+comp.lang.pyt...@pearwood.

Re: for / while else doesn't make sense

2016-05-23 Thread Ben Bacarisse
Chris Angelico <ros...@gmail.com> writes: > On Tue, May 24, 2016 at 2:51 AM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Chris Angelico <ros...@gmail.com> writes: >> >>> On Tue, May 24, 2016 at 12:29 AM, Ben Bacarisse <ben.use...@bsb.me.uk> >

Re: for / while else doesn't make sense

2016-05-22 Thread Ben Bacarisse
Jon Ribbens writes: > No, in Python integers are closed under the standard arithmetic > operators (+ - * / % **) - except, since Python 3, for "/", which > is now a special case. 2 ** -1 is 0.5 even in Python 2[*]. I agree with your general point (that floats

Re: A tough one: split on word length?

2016-05-16 Thread Ben Bacarisse
DFS writes: > Have: > '584323 Fri 13 May 2016 17:37:01 - (UTC) 584324 Fri 13 May 2016 > 13:44:40 -0400 584325 13 May 2016 17:45:25 GMT 584326 Fri 13 May 2016 > 13:47:28 -0400' > > Want: > [('584323', 'Fri 13 May 2016 17:37:01 - (UTC)'), > ('584324', 'Fri 13 May 2016

Re: Conditionals And Control Flows

2016-05-04 Thread Ben Bacarisse
Jussi Piitulainen writes: > Cai Gengyang writes: > >> I am trying to understand the boolean operator "and" in Python. It is >> supposed to return "True" when the expression on both sides of "and" >> are true >> >> For instance, >> >> 1 < 3 and 10 < 20 is True ---

Re: json.loads(...) ValueError: Expecting value: line 1 column 1 (char 0)

2016-05-09 Thread Ben Bacarisse
zljubi...@gmail.com writes: > in python3 my variable looks like this: > > a = b'{"uuid":"5730e8666ffa02.34177329","error":""}' > str(a) = 'b\'{"uuid":"5730e8666ffa02.34177329","error":""}\'' > > If I execute the following command I get the error: > json.loads(str(a)) > Traceback (most recent

Re: sum accuracy

2016-04-15 Thread Ben Bacarisse
Oscar Benjamin <oscar.j.benja...@gmail.com> writes: > On 15 April 2016 at 11:10, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Oscar Benjamin <oscar.j.benja...@gmail.com> writes: >> >>> On 15 April 2016 at 10:24, Robin Becker <ro...@reportlab.com&

Re: Guido sees the light: PEP 8 updated

2016-04-16 Thread Ben Bacarisse
Dennis Lee Bieber writes: > I still miss the Amiga -- in which one could /push/ a window to the > back of the stack while still retaining input focus! Made it nice for > transcribing stuff from a visible window to a text input region while it > was obscured. That

Re: Guido sees the light: PEP 8 updated

2016-04-16 Thread Ben Bacarisse
Chris Angelico <ros...@gmail.com> writes: > On Sun, Apr 17, 2016 at 9:25 AM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Dennis Lee Bieber <wlfr...@ix.netcom.com> writes: >> >>> I still miss the Amiga -- in which one could /push/ a windo

Re: sum accuracy

2016-04-15 Thread Ben Bacarisse
Oscar Benjamin writes: > On 15 April 2016 at 10:24, Robin Becker wrote: >> yes indeed summation is hard :( > > Not with Fraction it isn't: > > from fractions import Fraction > > def exact_sum(nums): > return sum(map(Fraction, nums)) > > This

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-22 Thread Ben Bacarisse
Chris Kaynor <ckay...@zindagigames.com> writes: > On Thu, Jul 21, 2016 at 4:54 PM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: > >> Steven D'Aprano <st...@pearwood.info> writes: >> >> > Or you might be using a language like Javascript, which intention

Re: Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

2016-07-21 Thread Ben Bacarisse
Steven D'Aprano writes: > Or you might be using a language like Javascript, which intentionally has > only floats for numbers. That's okay, you can still perform exact integer > arithmetic, so long as you stay within the bounds of ±2**16. Small point: it's 2**52. -- Ben.

Re: Detecting the trivial can be non-trivial (was Why not allow empty code blocks?)

2016-07-24 Thread Ben Bacarisse
Rustom Mody writes: > For a long time the re → dfa transformation went and was taught the laborious > route: > re → nfa-with-ε-transitions → nfa-without-ε-transitions → dfa > > https://en.wikipedia.org/wiki/Thompson's_construction >

Re: JSON result parsing

2016-07-30 Thread Ben Bacarisse
TUA writes: > Calls to my REST api may either return a dict (for single results) or > a list of dicts (for multiple results). I think John's answer missed this part. > I receive these results using the requests library. > > I want to retrieve the value for a key 'ID' but

Re: What is precision of a number representation?

2016-07-11 Thread Ben Bacarisse
Ben Finney writes: > Ethan Furman writes: > >> I will readily admit to not having a maths degree, and so of course to >> me saying the integer 123 has a precision of 5, 10, or 99 digits seems >> like hogwash to me. > > Precision is not a property

Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions

2016-07-01 Thread Ben Bacarisse
dieter writes: >> Lawrence D’Oliveiro wrote: >>> I don’t know why this fear and suspicion of lambdas is so widespread among >>> Python users ... former Java/C# programmers, perhaps? By replying I'm not accepting the premise -- I have no idea if there is widespread fear and

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

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

Re: How coding in Python is bad for you

2017-01-24 Thread Ben Bacarisse
Chris Angelico writes: > ... I teach JavaScript as well as Python, and I've seen some > pretty horrendous indentation flaws (examples available if people ask > privately, but I will anonymize them because I'm not here to shame > students) - but there have been nearly as many

Re: How coding in Python is bad for you

2017-01-24 Thread Ben Bacarisse
Chris Angelico <ros...@gmail.com> writes: > On Wed, Jan 25, 2017 at 2:51 AM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Chris Angelico <ros...@gmail.com> writes: >> >>> ... I teach JavaScript as well as Python, and I've seen some >>> pret

Re: How coding in Python is bad for you

2017-01-24 Thread Ben Bacarisse
Chris Angelico <ros...@gmail.com> writes: > On Wed, Jan 25, 2017 at 3:21 AM, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> Chris Angelico <ros...@gmail.com> writes: >> >>> On Wed, Jan 25, 2017 at 2:51 AM, Ben Bacarisse <ben.use...@bsb.me.uk> wrot

Re: How coding in Python is bad for you

2017-01-24 Thread Ben Bacarisse
BartC <b...@freeuk.com> writes: > On 24/01/2017 15:51, Ben Bacarisse wrote: >> Chris Angelico <ros...@gmail.com> writes: >> >>> ... I teach JavaScript as well as Python, and I've seen some >>> pretty horrendous indentation flaws (examples

Re: How coding in Python is bad for you

2017-01-24 Thread Ben Bacarisse
Steve D'Aprano <steve+pyt...@pearwood.info> writes: > On Wed, 25 Jan 2017 03:21 am, Ben Bacarisse wrote: > >> Chris Angelico <ros...@gmail.com> writes: >> >>> On Wed, Jan 25, 2017 at 2:51 AM, Ben Bacarisse <ben.use...@bsb.me.uk> >>> wrote: &g

Re: Namedtuples problem

2017-02-23 Thread Ben Bacarisse
"Deborah Swanson" writes: >> -Original Message- >> From: Erik [mailto:pyt...@lucidity.plus.com] >> Sent: Thursday, February 23, 2017 2:09 AM >> To: pyt...@deborahswanson.net; python-list@python.org >> Subject: Re: Namedtuples problem >> >> >> Hi, >> >> On

Re: Create ordering of points

2017-02-15 Thread Ben Bacarisse
spiess.benja...@googlemail.com writes: > I've got a problem which I would really like to solve. > I got a cloud of points (in the simplest example its a 2-dimensional > cloud of points). > First, I want to set one of the points as the initial (or middle) > point. Starting from there, the next

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

Re: Assignment versus binding

2016-10-05 Thread Ben Bacarisse
Gregory Ewing writes: > Steve D'Aprano wrote: > >> And (shamelessly using Python syntax) if I have a function: >> >> def spam(x): >> print(x) >> print(x+1) >> >> spam(time.sleep(60) or 1) > > You can't write that in Haskell, because Haskell's > equivalent of

Re: Assignment versus binding

2016-10-05 Thread Ben Bacarisse
BartC <b...@freeuk.com> writes: > On 05/10/2016 11:03, Ben Bacarisse wrote: >> Gregory Ewing <greg.ew...@canterbury.ac.nz> writes: >> >>> Steve D'Aprano wrote: >>> >>>> And (shamelessly using Python syntax) if I have a function: &g

Re: Assignment versus binding

2016-10-04 Thread Ben Bacarisse
Steve D'Aprano <steve+pyt...@pearwood.info> 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) p

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 >>

Re: Function to take the minimum of 3 numbers

2016-10-09 Thread Ben Bacarisse
Cai Gengyang writes: > I'm moving on to chapter 9 > (http://programarcadegames.com/index.php?lang=en=lab_functions) > of programarcadegames for the time being and going back to chapter 8 > later (its just fucking frustrating and doesn't seem to work for the > time being

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)

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-05 Thread Ben Bacarisse
Steve D'Aprano writes: > On Sun, 6 Nov 2016 04:10 am, Mr. Wrobel wrote: > >> Hi, >> >> Some skeptics asked my why there is a reason to use Python against of >> any other "not interpreted" languages, like objective-C. > > Here's the "Hello World" program in Python: >

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-05 Thread Ben Bacarisse
Steve D'Aprano <steve+pyt...@pearwood.info> writes: > On Sun, 6 Nov 2016 08:17 am, Ben Bacarisse wrote: > >> Steve D'Aprano <steve+pyt...@pearwood.info> writes: > >>> Here's the same program in Objective C: >>> >>> --- cut --- >>

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-05 Thread Ben Bacarisse
"Mr. Wrobel" writes: > ... However the most important is second part of my question. > > What do you think about using GPU processing or pypy? Sorry, I don't have enough experience of them to offer any useful advice. -- Ben. --

Re: how to print variable few time?

2016-11-12 Thread Ben Bacarisse
guy asor writes: > this is my code: > > word=raw_input() > print word*3 > > > with this code im getting - wordwordword. > what changes i need to make to get - word word word - instead? Two hints: What does ['a']*3 give you? What about '/'.join(['a', 'b', 'c'])? Can you

Re: Deviding N(1, 2, 3, .., N) part from numeric list as summation of each values(don't sorted) has highest possible.

2016-10-10 Thread Ben Bacarisse
Nune9 writes: > I have a list is > > land = [10,20,30,40,110,50,18,32,5] > > and I want to find each values of summation (don't sorted values in > list) as It has highest possible > > example. > > I want to dividing N=3 part from list as above and divieded each part > has

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-07 Thread Ben Bacarisse
BartC writes: > [...] But remember: > > cp *.c > > There might be some irate users out there if it can't detect a simple > user error like that. There might be. They are ill-served by current Unix shells. But, oddly, the flow has gone the other way. People have wanted Unix

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-07 Thread Ben Bacarisse
BartC <b...@freeuk.com> writes: > On 07/12/2016 15:25, Ben Bacarisse wrote: >> BartC <b...@freeuk.com> writes: >> >>> [...] But remember: >>> >>> cp *.c >>> >>> There might be some irate users out there if it can't detec

Re: Temporary variables in list comprehensions

2017-01-09 Thread Ben Bacarisse
Steven D'Aprano writes: > Suppose you have an expensive calculation that gets used two or more times in > a > loop. The obvious way to avoid calculating it twice in an ordinary loop is > with > a temporary variable: > > result = [] > for x in data: >

Re: python list index - an easy question

2016-12-18 Thread Ben Bacarisse
BartC writes: > On 18/12/2016 10:59, Paul Götze wrote: >> there is a nice short article by E. W. Dijkstra about why it makes sense >> to start numbering at zero (and exclude the upper given bound) while >> slicing a list. Might give a bit of additional understanding. >> >>

Re: python list index - an easy question

2016-12-19 Thread Ben Bacarisse
Jussi Piitulainen <jussi.piitulai...@helsinki.fi> writes: > Ben Bacarisse writes: > >> BartC writes: >> >>> You need to take your C hat off, I think. >> >> It's a computing hat. Indexes are best seen as offsets (i.e. as a >> measured distances

Re: Another security question

2016-12-23 Thread Ben Bacarisse
"Frank Millman" writes: > ... Here are my thoughts on improving this. > > 1. Generate a 'salt' for each password. There seem to be two ways in > the standard library to do this - >import os >salt = os.urandom(16) > >import secrets >salt =

Re: python list index - an easy question

2016-12-19 Thread Ben Bacarisse
BartC <b...@freeuk.com> writes: > On 19/12/2016 01:10, Ben Bacarisse wrote: >> BartC <b...@freeuk.com> writes: >> >>> On 18/12/2016 10:59, Paul Götze wrote: >>>> there is a nice short article by E. W. Dijkstra about why it makes sense >>>

Re: Python and the need for speed

2017-04-12 Thread Ben Bacarisse
Steve D'Aprano writes: > On Wed, 12 Apr 2017 03:39 am, Paul Rubin wrote: > >> I still do my everyday stuff in Python and I'd like to get more >> conversant with stuff like numpy, but it feels like an old-fashioned >> language these days. > > "Old fashioned"? With

Re: Check multiple file parms in single os.access?

2017-04-13 Thread Ben Bacarisse
James McMahon writes: > Hello. Am a Python newbie. I have researched and found examples how we can > check existence, readability, and write-ability on a given fully-qualified > filename for the current python script user. Evidently os.access is the way > to go, wrapped in

Re: Python and the need for speed

2017-04-15 Thread Ben Bacarisse
bartc writes: > 'do', in the original Algol 68 syntax, was part of its 'for' > statement, where you could leave out the parts you don't need. The > full syntax is something like: > > for var := a to b by c while d do body od FOR name FROM e1 BY e2 TO e3 WHILE cond DO body

Re: Looping [was Re: Python and the need for speed]

2017-04-16 Thread Ben Bacarisse
Steve D'Aprano writes: > I don't remember the language, but I remember seeing one generalisation of > the repeat/do loop that puts the test in the middle, rather than at the > start or end of the loop. If I remember it was something like: > > DO > setup code #

Re: Looping [was Re: Python and the need for speed]

2017-04-17 Thread Ben Bacarisse
Marko Rauhamaa writes: > Terry Reedy : > >> On 4/17/2017 3:11 AM, Marko Rauhamaa wrote: >>> Here's statistics from a medium-sized project of mine: >>> >>>while True:34 >>>while : 39 >>>for ... in ...: 158 >> >> As I posted

Re: Looping [was Re: Python and the need for speed]

2017-04-17 Thread Ben Bacarisse
Marko Rauhamaa <ma...@pacujo.net> writes: > Ben Bacarisse <ben.use...@bsb.me.uk>: > >> Marko Rauhamaa <ma...@pacujo.net> writes: >>> What I notice in my numbers is that about one half of my while loops >>> are "while True", and

Re: Looping [was Re: Python and the need for speed]

2017-04-17 Thread Ben Bacarisse
Paul Rubin <no.email@nospam.invalid> writes: > Ben Bacarisse <ben.use...@bsb.me.uk> writes: >> c = sys.stdin.read(1) >> while c == ' ': >> c = sys.stdin.read(1) (for the record: I was not suggesting this was how you'd do it but how you'd be forced

Re: A small quiz question

2017-08-16 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > >

Re: Proposed new syntax

2017-08-11 Thread Ben Bacarisse
Steve D'Aprano writes: > Every few years, the following syntax comes up for discussion, with some > people > saying it isn't obvious what it would do, and others disagreeing and saying > that it is obvious. So I thought I'd do an informal survey. > > What would you

Re: A small quiz question

2017-08-16 Thread Ben Bacarisse
Steve D'Aprano <steve+pyt...@pearwood.info> writes: > On Wed, 16 Aug 2017 11:38 pm, Ben Bacarisse wrote: > >> r...@zedat.fu-berlin.de (Stefan Ram) writes: >> >>> I wrote my first Python quiz question! >>> >>> It goes like this: >

Re: python script is slowly after use multiprocessing

2017-07-03 Thread Ben Bacarisse
Xristos Xristoou writes: > i have create an image processing python function. > > my system have 4 cores + 4 threads. > > i want to use multiprocessing to speed up my function,but anytime to > use multiprocessing packages my function is not faster and is 1 minute > slowly. any

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

2017-08-18 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Ben Bacarisse <ben.use...@bsb.me.uk> writes: >>Steve D'Aprano <steve+pyt...@pearwood.info> writes: >>>"Java is call by value, dammit!" >>I don't think this is a fair point. You will run out of ideas i

Re: What extended ASCII character set uses 0x9D?

2017-08-17 Thread Ben Bacarisse
John Nagle writes: > I'm cleaning up some data which has text description fields from > multiple sources. Some are are in UTF-8. Some are in WINDOWS-1252. > And some are in some other character set. So I have to examine and > sanity check each field in a database dump,

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

2017-08-17 Thread Ben Bacarisse
Steve D'Aprano writes: > On Thu, 17 Aug 2017 10:14 am, Ned Batchelder wrote: >> For some reason, students have been taught that things can be either >> call-by-reference or call-by-value. But those are not the only two >> possibilities, and neither completely

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

2017-08-18 Thread Ben Bacarisse
Steve D'Aprano <steve+pyt...@pearwood.info> writes: > On Thu, 17 Aug 2017 11:37 pm, Ben Bacarisse wrote: > >> What goes wrong when someone thinks of Python as passing by value but >> the value of an expression is an object reference? This seems to be a hot-button topic so

Re: New to python and programming

2017-05-17 Thread Ben Bacarisse
BT writes: > I am fairly new to programming. I was just trying to understand how > this group works. Am i allowed to ask any questions that I may have > when i get stuck? I mean is this group for new programmers as well..? Welcome. Yes, it's for pretty much any questions

Re: Converting sentences to vector form

2017-06-27 Thread Ben Bacarisse
Bhaskar Dhariyal writes: > I am doing a project on data science. I need to convert sentences to > vectorial form. That's not a term I am familiar with. If it's standard, that's my fault, but you can still help people like me by explaining what you mean. And if it is

  1   2   3   >