Re: Python... feeding an instance as an argument into a new instance.

2017-09-02 Thread Steve D'Aprano
On Sun, 3 Sep 2017 08:34 am, Chris Roberts wrote: > Perhaps someone here could help me to get this into perspective. > Somehow when we start to feed an instance as the argument in a new instance. > my head explodes.. in this case... > a = Foo() > b = Bar(a) > So... > a is a 'Foo instance' with pr

Re: Battle of the garbage collectors, or ARGGHHHHHH!!!!

2017-09-02 Thread CFK
On Wed, Apr 26, 2017 at 10:38 PM, Cem Karan wrote: > > On Apr 24, 2017, at 8:54 PM, Jon Ribbens > wrote: > > > On 2017-04-24, CFK wrote: > >> Long version: I'm trying to write bindings for python via ctypes to > control > >> a library written in C that uses the bdwgc garbage collector ( > >> ht

Re: Delay a computation in another thread

2017-09-02 Thread Terry Reedy
On 9/2/2017 6:53 AM, Steve D'Aprano wrote: I want to delay a computation and then print it, in the REPL (interactive interpreter). I have something like this: import time from threading import Timer def do_work(): x = 2 + 2 print("It is", time.asctime(), "and 2+2 is", x) def schedul

Re: Python... feeding an instance as an argument into a new instance.

2017-09-02 Thread Irv Kalb
> On Sep 2, 2017, at 3:34 PM, Chris Roberts wrote: > > Perhaps someone here could help me to get this into perspective. > Somehow when we start to feed an instance as the argument in a new instance. > my head explodes.. > in this case... > a = Foo() > b = Bar(a) > So... > a is a 'Foo instance

Python... feeding an instance as an argument into a new instance.

2017-09-02 Thread Chris Roberts
Perhaps someone here could help me to get this into perspective. Somehow when we start to feed an instance as the argument in a new instance. my head explodes.. in this case... a = Foo() b = Bar(a) So... a is a 'Foo instance' with properties and methods. b is a 'Bar instance' Since b is using

Re: possible bug in while loop test

2017-09-02 Thread MRAB
On 2017-09-02 18:53, Charles Hixson wrote: python3 --version Python 3.5.3 Running on Debian stretch In this code s is a string parameter while (j < k and \ (s[j].isalnum()) or \ (s[j] in seps and s[j+1].isalnum()) ): j = j + 1 print ("i = {0}, j =

Re: possible bug in while loop test

2017-09-02 Thread Peter Otten
Charles Hixson wrote: > python3 --version > Python 3.5.3 > > Running on Debian stretch > > In this code s is a string parameter > > while (j < k and \ > (s[j].isalnum()) or \ >(s[j] in seps and s[j+1].isalnum()) ): > j = j + 1 > print ("i = {0}, j = {1

possible bug in while loop test

2017-09-02 Thread Charles Hixson
python3 --version Python 3.5.3 Running on Debian stretch In this code s is a string parameter while (j < k and \ (s[j].isalnum()) or \ (s[j] in seps and s[j+1].isalnum()) ): j = j + 1 print ("i = {0}, j = {1}, k = {2}, len[s] = {3}". \ format(i,

Re: Delay a computation in another thread

2017-09-02 Thread eryk sun
On Sat, Sep 2, 2017 at 5:53 AM, Steve D'Aprano wrote: > > The problem is that after the message is printed, the REPL's prompt is > disrupted. This is especially annoying when I'm in the middle of typing a > line. > This is just a cosmetic flaw, but it would be nice if I could tell Python to > red

Re: Delay a computation in another thread

2017-09-02 Thread MRAB
On 2017-09-02 11:59, Steve D'Aprano wrote: On Sat, 2 Sep 2017 08:53 pm, Steve D'Aprano wrote: I want to delay a computation and then print it, in the REPL (interactive interpreter). I have something like this: [...] The other problem is that if I exit the REPL while a Timer is still active, i

Re: Delay a computation in another thread

2017-09-02 Thread Chris Angelico
On Sat, Sep 2, 2017 at 8:53 PM, Steve D'Aprano wrote: > The problem is that after the message is printed, the REPL's prompt is > disrupted. This is especially annoying when I'm in the middle of typing a > line. > This is just a cosmetic flaw, but it would be nice if I could tell Python to > redra

Re: Delay a computation in another thread

2017-09-02 Thread Steve D'Aprano
On Sat, 2 Sep 2017 08:53 pm, Steve D'Aprano wrote: > I want to delay a computation and then print it, in the REPL (interactive > interpreter). I have something like this: [...] > The other problem is that if I exit the REPL while a Timer is still active, it > freezes until the time has run before

Delay a computation in another thread

2017-09-02 Thread Steve D'Aprano
I want to delay a computation and then print it, in the REPL (interactive interpreter). I have something like this: import time from threading import Timer def do_work(): x = 2 + 2 print("It is", time.asctime(), "and 2+2 is", x) def schedule_work(): Timer(60, do_work, ()).start() #

Re: Case-insensitive string equality

2017-09-02 Thread Pavol Lisy
On 9/2/17 at 4:21, Steve D'Aprano wrote: > If regular case-sensitive string comparisons don't support the locale, why > should case-insensitive comparisons be required to? I think that Chris answered very good before: On 9/2/17 at 2:53 AM, Chris Angelico wrote: > On Sat, Sep 2, 2017 at 10:31 AM

Re: If you are running 32-bit 3.6 on Windows, please test this

2017-09-02 Thread Pavol Lisy
On 9/2/17, eryk sun wrote: > On Fri, Sep 1, 2017 at 3:23 AM, Peter Otten <__pete...@web.de> wrote: >> >> I think you have to specify the types yourself: >> > import ctypes > libm = ctypes.cdll.LoadLibrary("libm.so") > libm.sqrt(42) >> 0 > libm.sqrt.argtypes = [ctypes.c_double]

Re: Python string replace the values

2017-09-02 Thread Peter Otten
Steve D'Aprano wrote: > On Sat, 2 Sep 2017 03:13 am, Ganesh Pal wrote: > >> Example : >> >> "a" and "1" => a0001 >> >> "a" and "aa" => c00aa > > Why does the leading 'a' change to a 'c'? Is that a mistake? I'll assume > its a typo. > > You want string slicing. > > base = 'a'

Re: Python string replace the values

2017-09-02 Thread Ganesh Pal
MRAB , Thanks for your solution it looks neat and best ! On Fri, Sep 1, 2017 at 11:14 PM, MRAB wrote: > On 2017-09-01 18:13, Ganesh Pal wrote: > >> In the fixed length string i.e "a",last 4 bits i.e "" should be >> replaced by the user provided value ( the value is between 0001 + f f f