Re: how to replace line on particular line in file[no need to write it back whole file again]

2018-10-12 Thread Peter J. Holzer
On 2018-10-12 22:28:44 -0400, Dennis Lee Bieber wrote: > On Fri, 12 Oct 2018 21:00:45 +0200, "Peter J. Holzer" > declaimed the following: > >I don't know if there was a C implementation for CP-V, but there is > >certainly nothing in the C standard which would prevent a standard > >conforming imple

Re: ESR "Waning of Python" post

2018-10-12 Thread dieter
Marko Rauhamaa writes: > dieter : > ... >> I work in the domain of web applications. And I made there a nasty >> experience with garbage collection: occasionally, the web application >> stopped to respond for about a minute. A (quite difficult) analysis >> revealed that some (stupid) component cre

Re: ESR "Waning of Python" post

2018-10-12 Thread Gregory Ewing
Paul Rubin wrote: I even wonder what happens if you turn Py_INCREF etc. into no-ops, install the Boehm garbage collector in a stop-the-world mode, and disable the GIL. I suspect you would run into problems with things that need mutual exclusion but don't do any locking of their own, because the

Re: Quickest way to concatenate strings

2018-10-12 Thread Alan Bawden
"Frank Millman" writes: > I have often read that the quickest way to concatenate a number of strings > is to place them in a list and 'join' them - > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" > ''.join([x, y, z]) ... > > I seem to have found a quicker method,

Re: ESR "Waning of Python" post

2018-10-12 Thread Neil Cerutti
On 2018-10-12, Peter J. Holzer wrote: > Neil Cerutti said: >> I imagine that if I stuck with Go long enough I'd develop a >> new coding style that didn't inolve creating useful data >> types. > > I haven't used Go for any real project yet (that may change > next year - we'll see whether I love it

Re: ESR "Waning of Python" post

2018-10-12 Thread Chris Angelico
On Sat, Oct 13, 2018 at 7:25 AM Vito De Tullio wrote: > > Chris Angelico wrote: > > >> Reference counting was likely a bad idea to begin with. > > > > Then prove CPython wrong by making a fantastically better > > implementation that uses some other form of garbage collection. > > I'm not talking a

Re: ESR "Waning of Python" post

2018-10-12 Thread Vito De Tullio
Chris Angelico wrote: >> Reference counting was likely a bad idea to begin with. > > Then prove CPython wrong by making a fantastically better > implementation that uses some other form of garbage collection. I'm not talking about the "goodness" of the implemetations, but AFAIK jython and ironp

Re: ESR "Waning of Python" post

2018-10-12 Thread Tim Daneliuk
On 10/12/2018 11:43 AM, Skip Montanaro wrote: > I sort of skimmed ESR's post, and sort of skimmed this thread, so > obviously I'm totally qualified to offer my observations on the post > and follow ups. :-) Skip - In the 15-ish years I've been reading this group, this has NEVER been an obstacle f

Re: ESR "Waning of Python" post

2018-10-12 Thread Tim Daneliuk
On 10/11/2018 12:15 AM, Gregory Ewing wrote: > Paul Rubin wrote [concerning GIL removal]: >> It's weird that Python's designers were willing to mess up the user >> language in the 2-to-3 transition but felt that the C API had to be kept >> sarcosanct.  Huge opportunities were blown at multiple leve

Re: how to replace line on particular line in file[no need to write it back whole file again]

2018-10-12 Thread Peter J. Holzer
On 2018-10-11 09:01:55 -0400, Dennis Lee Bieber wrote: > On Thu, 11 Oct 2018 15:14:49 +0530, Iranna Mathapati > declaimed the following: > >How to replace particular line text with new text on a file > >i have below code but its writing whole code. > > > For C-style streams (which seem to h

Re: how to replace line on particular line in file[no need to write it back whole file again]

2018-10-12 Thread Peter J. Holzer
On 2018-10-11 13:57:57 +0200, Thomas Jollans wrote: > There's no easy way to write to the middle of a file (though I think it > can be done by mmap'ing a file) #!/usr/bin/python3 import os with open("foo.bin", "wb") as f: f.write(b'abcdefghijklmnopqrstuvwxyz') with open("foo.bin", "rb") as f

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Terry Reedy
On 10/12/2018 1:06 PM, Chris Angelico wrote: There are many many different ways to write code, and you can approach your coding challenges from all sorts of directions. My recommendation is: Pseudo-code first, then implement in actual Python. https://en.wikipedia.org/wiki/Pseudocode Note how,

Re: ESR "Waning of Python" post

2018-10-12 Thread Peter J. Holzer
On 2018-10-11 17:56:43 +, Neil Cerutti wrote: > On 2018-10-10, Paul Rubin wrote: > > Neil Cerutti writes: > >> > >>> the GIL (15/16th of his CPUs are unused..) > >> Channels are a big selling point of Go, no argument there. > > > > The unused CPUs are not about channels (Python has Queue whic

RE: Single DB connection during class's lifetime. Metaclass,singleton and __new__() examples and references.

2018-10-12 Thread Ryan Johnson
Thanks for the clarification. If I am creating a class variable, are you suggesting I perform the “if it exists, great, otherwise make it” logic in the __init__ block or in the class definition block? Will that even run in a class definition? I never see examples do anything besides assignment

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Neil Cerutti
On 2018-10-12, Kaan Taze wrote: > How do I get used to this? Is this just another "practice, > practice, practice" situation? Anything you can recommend? You will become comfortable with Python with time and practice. Be patient with yourself. I don't care for my early Python code, but it still w

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Spencer Graves
On 2018-10-12 11:44, Rhodri James wrote: On 12/10/18 17:12, Rob Gaddi wrote: On 10/11/2018 11:29 PM, Kaan Taze wrote: Hi everyone, Since this is my first post to mail-list I'm kind of hesitant to ask this question here but as many of you spend years working with Python maybe some of you c

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Chris Angelico
On Sat, Oct 13, 2018 at 3:07 AM Kaan Taze wrote: > > Hi everyone, > > Since this is my first post to mail-list I'm kind of hesitant to ask this > question here but as many of you spend years working with Python maybe some > of you can guide me. Hey there, welcome! :) > I do what I need to do wit

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Rhodri James
On 12/10/18 17:12, Rob Gaddi wrote: On 10/11/2018 11:29 PM, Kaan Taze wrote: Hi everyone, Since this is my first post to mail-list I'm kind of hesitant to ask this question here but as many of you spend years working with Python maybe some of you can guide me. What I trouble with is not a lo

Re: ESR "Waning of Python" post

2018-10-12 Thread Skip Montanaro
I sort of skimmed ESR's post, and sort of skimmed this thread, so obviously I'm totally qualified to offer my observations on the post and follow ups. :-) Eric makes a mistake, in my opinion, confusing his particular application with the mainstream, when in fact it seems pretty specialized to me.

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Rob Gaddi
On 10/11/2018 11:29 PM, Kaan Taze wrote: Hi everyone, Since this is my first post to mail-list I'm kind of hesitant to ask this question here but as many of you spend years working with Python maybe some of you can guide me. What I trouble with is not a logical error that exist on a program I w

Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Kaan Taze
Hi everyone, Since this is my first post to mail-list I'm kind of hesitant to ask this question here but as many of you spend years working with Python maybe some of you can guide me. What I trouble with is not a logical error that exist on a program I wrote. It's the Python itself. Well, I'm 22

Re: How to run/debug a script file its name has characters such as space, (, etc.

2018-10-12 Thread Chris Angelico
On Fri, Oct 12, 2018 at 9:16 PM wrote: > > Chris Angelico於 2018年10月12日星期五 UTC+8下午4時39分37秒寫道: > > On Fri, Oct 12, 2018 at 6:26 PM wrote: > > > > > > I saw a directory where all its filenames are something like this: > > > ... > > > 1a PSG (Entry and PopUp).py > > > 1b PSG (Format).py > > > 1c PSG

Re: Quickest way to concatenate strings

2018-10-12 Thread Frank Millman
"Dennis Lee Bieber" wrote in message news:cnk0sdl5a7p17framc5er811p1230mp...@4ax.com... On Fri, 12 Oct 2018 07:55:58 +0200, "Frank Millman" declaimed the following: >I have often read that the quickest way to concatenate a number of >strings >is to place them in a list and 'join' them - >

Re: Observations on the List - "Be More Kind"

2018-10-12 Thread Dan Purgert
Chris Angelico wrote: > On Fri, Oct 12, 2018 at 5:07 AM Ian Kelly wrote: >> >> On Thu, Oct 11, 2018 at 9:28 AM Dan Purgert wrote: >> > >> > Larry Martell wrote: >> > > On Fri, Oct 5, 2018 at 6:54 AM Bruce Coram >> > > wrote: >> > > [...] >> > > We don't like you. We don't want you here. We neve

Re: How to run/debug a script file its name has characters such as space, (, etc.

2018-10-12 Thread jfong
Chris Angelico於 2018年10月12日星期五 UTC+8下午4時39分37秒寫道: > On Fri, Oct 12, 2018 at 6:26 PM wrote: > > > > I saw a directory where all its filenames are something like this: > > ... > > 1a PSG (Entry and PopUp).py > > 1b PSG (Format).py > > 1c PSG (persistent form and bind key).py > > ... > > > > Just won

Re: Quickest way to concatenate strings

2018-10-12 Thread Frank Millman
On 12/10/2018 08:36, Thomas Jollans wrote: > On 12/10/2018 07:55, Frank Millman wrote: > Hi all > > > I have often read that the quickest way to concatenate a number of > > strings is to place them in a list and 'join' them - > > > > > > C:\Users\User>python -m timeit -s "x='a'*500; y='b'*

Re: Quickest way to concatenate strings

2018-10-12 Thread Thomas Jollans
On 12/10/2018 07:55, Frank Millman wrote: Hi all I have often read that the quickest way to concatenate a number of strings is to place them in a list and 'join' them -    C:\Users\User>python -m timeit -s "x='a'*500; y='b'*500; z='c'*500" ''.join([x, y, z])    50 loops, best of 5: 30

Re: How to run/debug a script file its name has characters such as space, (, etc.

2018-10-12 Thread Chris Angelico
On Fri, Oct 12, 2018 at 6:26 PM wrote: > > I saw a directory where all its filenames are something like this: > ... > 1a PSG (Entry and PopUp).py > 1b PSG (Format).py > 1c PSG (persistent form and bind key).py > ... > > Just wondering how these file can run and debugged under Windows? > Put the f

How to run/debug a script file its name has characters such as space, (, etc.

2018-10-12 Thread jfong
I saw a directory where all its filenames are something like this: ... 1a PSG (Entry and PopUp).py 1b PSG (Format).py 1c PSG (persistent form and bind key).py ... Just wondering how these file can run and debugged under Windows? --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: Single DB connection during class's lifetime. Metaclass, singleton and __new__() examples and references.

2018-10-12 Thread Thomas Jollans
On 12/10/2018 01:19, Ryan Johnson wrote: I am working on using mysql.connector in a class and have found an example of how to create a single connection that spans the lifetime of all instances of the class: https://softwareengineering.stackexchange.com/a/358061/317228 however, I do not under

Re: Single DB connection during class's lifetime. Metaclass, singleton and __new__() examples and references.

2018-10-12 Thread dieter
Ryan Johnson writes: > I am working on using mysql.connector in a class and have found an example of > how to create a single connection that spans the lifetime of all instances of > the class: > > https://softwareengineering.stackexchange.com/a/358061/317228 > > however, I do not understand a