Re: right list for SIGABRT python binary question ?

2017-11-01 Thread dieter
Karsten Hilbert writes: > On Sat, Oct 21, 2017 at 09:31:54AM +0200, dieter wrote: >> It points to a memory corruption. > While running valgrind and friends is beyond my capabilitis I > have run the problem through gdb to at least obtain a stack > trace to see what gives: The i386/x64 architectur

Re: Objects with __name__ attribute

2017-11-01 Thread dieter
"ast" writes: > I know two Python's objects which have an intrinsic name, classes and > functions. > ... > Are there others objects with a __name__ attribute > and what is it used for ? Some Python objects naturally have a name: functions, classes, modules, ...; others don't: tuples, lists, integ

Re: Let's talk about debuggers!

2017-11-01 Thread dieter
Thomas Jollans writes: > I just wanted to know what tools everyone used for debugging Python > applications - scripts / backend / desktop apps / notebooks / whatever. > Apart from the usual dance with log files and strategically inserted > print() calls, that is. > > Of course we all know and mild

Re: Performance of map vs starmap.

2017-11-01 Thread Serhiy Storchaka
30.10.17 12:10, Kirill Balunov пише: Sometime ago I asked this question at SO [1], and among the responses received was paragraph: - `zip` re-uses the returned `tuple` if it has a reference count of 1 when the `__next__` call is made. - `map` build a new `tuple` that is passed to the mapped

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Karsten Hilbert
On Wed, Nov 01, 2017 at 09:21:46AM +0100, dieter wrote: > >> It points to a memory corruption. > > The i386/x64 architecture supports memory access breakpoints > and GDB, too, has support for this. You know the address which > gets corrupted. Thus, the following apporach could have a chance > to

Re: matplot plot hangs

2017-11-01 Thread Wolfgang Maier
On 01.11.2017 00:40, Andrew Z wrote: hello, learning python's plotting by using matplotlib with python35 on fedora 24 x86. Installed matplotlib into user's directory. tk, seemed to work - http://www.tkdocs.com/tutorial/install.html#installlinux - the window shows up just fine. but when trying

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Karsten Hilbert
On Wed, Nov 01, 2017 at 10:27:54AM +0100, Karsten Hilbert wrote: > > >> It points to a memory corruption. > > > > The i386/x64 architecture supports memory access breakpoints > > and GDB, too, has support for this. You know the address which > > gets corrupted. Thus, the following apporach could

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Karsten Hilbert
On Wed, Nov 01, 2017 at 11:14:08AM +0100, Karsten Hilbert wrote: > Or rather: I need to find out which "place" a given address > refers to, check whether the changing addresses always belong > to the same "place" between runs and _then_ map a "place" to > its address and breakpoint that address on

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Karsten Hilbert
> my assumption would be that something clobbers 0x6aab7c, > which seems to be in (?) _Py_ZeroStruct in this run. I'll > re-run a few times to make sure the corruption "reliably" > hits _Py_ZeroStruct. > > If so, I'll set a memory write breakpoint on _Py_ZeroStruct. Interestingly, on subsequent r

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Karsten Hilbert
On Wed, Nov 01, 2017 at 12:40:56PM +0100, Karsten Hilbert wrote: > Interestingly, on subsequent runs, it seems to hit the same > address, 0x6aab7c, belonging to the same symbol, _Py_ZeroStruct. > > This is what happens: > > (gdb) watch *0x6aab7c > Hardware watchpoint 1: *0x6aab7c >

Re: The syntax of replacement fields in format strings

2017-11-01 Thread Ned Batchelder
On 10/31/17 12:45 PM, John Smith wrote: If we keep the current implementation as is, perhaps the documentation should at least be altered ? John, it looks like you are responding to a Python-Dev message, but on this list, somehow... --Ned. -- https://mail.python.org/mailman/listinfo/python-l

Re: matplot plot hangs

2017-11-01 Thread Andrew Z
Wolfgang, I tried to ran from ide with no rwsults, so now im trying from a terminal in xwindow. The .plot is the last line in the script and it does hang trying to execute it. On Nov 1, 2017 05:44, "Wolfgang Maier" < wolfgang.ma...@biologie.uni-freiburg.de> wrote: On 01.11.2017 00:40, Andrew Z

Re: matplot plot hangs

2017-11-01 Thread Vlastimil Brom
2017-11-01 13:49 GMT+01:00 Andrew Z : > Wolfgang, > I tried to ran from ide with no rwsults, so now im trying from a terminal > in xwindow. > The .plot is the last line in the script and it does hang trying to execute > it. > > > On Nov 1, 2017 05:44, "Wolfgang Maier" < > wolfgang.ma...@biologie.u

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Karsten Hilbert
On Wed, Nov 01, 2017 at 11:58:53AM -0400, Dennis Lee Bieber wrote: > >I understand. Thank you for the explanation. This may seem > >like a dumb question: the actual address that gets corrupted > >varies from run to run (it may be the same "place" in the > > Since the process virtual memory

Re: right list for SIGABRT python binary question ?

2017-11-01 Thread Grant Edwards
On 2017-11-01, Dennis Lee Bieber wrote: > On Wed, 1 Nov 2017 10:27:54 +0100, Karsten Hilbert > declaimed the following: > > >> >>I understand. Thank you for the explanation. This may seem >>like a dumb question: the actual address that gets corrupted >>varies from run to run (it may be the same "p

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Israel Brewster
Let me rephrase the question, see if I can simplify it. I need to be able to access a defaultdict from two different threads - one thread that responds to user requests which will populate the dictionary in response to a user request, and a second thread that will keep the dictionary updated as

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Israel Brewster
On Nov 1, 2017, at 9:04 AM, Israel Brewster wrote: > > Let me rephrase the question, see if I can simplify it. I need to be able to > access a defaultdict from two different threads - one thread that responds to > user requests which will populate the dictionary in response to a user > request

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Ian Kelly
On Tue, Oct 31, 2017 at 11:38 AM, Israel Brewster wrote: > A question that has arisen before (for example, here: > https://mail.python.org/pipermail/python-list/2010-January/565497.html > ) is > the question of "is defaultd

Re: Code Snippets

2017-11-01 Thread Neil Cerutti
On 2017-11-01, Stefan Ram wrote: > I started to collect some code snippets: > > Sleep one second > > __import__( "time" ).sleep( 1 ) > > What I'm supposed to do instead, I guess, is: > > Sleep one second > > import time > ... > time.sleep( 1 ) > > Get current directory > > import os > ..

Re: Code Snippets

2017-11-01 Thread Ned Batchelder
On 11/1/17 1:25 PM, Stefan Ram wrote: I started to collect some code snippets: Sleep one second __import__( "time" ).sleep( 1 ) Get current directory __import__( "os" ).getcwd() Get a random number __import__( "random" ).random() And so on. You get the idea. However, rep

Re: Report on non-breaking spaces in posts

2017-11-01 Thread Ned Batchelder
On 10/31/17 1:23 PM, Stefan Ram wrote: 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 that is converting something, because there is no newsreader involved. You've worded this as if

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Israel Brewster
On Nov 1, 2017, at 9:58 AM, Ian Kelly wrote: > > On Tue, Oct 31, 2017 at 11:38 AM, Israel Brewster > wrote: >> A question that has arisen before (for example, here: >> https://mail.python.org/pipermail/python-list/2010-January/565497.html >>

String changing size on failure?

2017-11-01 Thread Ned Batchelder
From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): >>> a = 'n' >>> b = 'ñ' >>> sys.getsizeof(a) 50 >>> sys.getsizeof(b) 74 >>> float(b) Traceback (most recent call last):   File "", line 1, in ValueError: could not convert string to flo

Re: String changing size on failure?

2017-11-01 Thread Skip Montanaro
Leave it to DB to ask the tough questions other people won't. :-) Skip On Wed, Nov 1, 2017 at 2:26 PM, Ned Batchelder wrote: > From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): > > >>> a = 'n' > >>> b = 'ñ' > >>> sys.getsizeof(a) >50 > >>> sys.getsiz

Re: String changing size on failure?

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 6:26 AM, Ned Batchelder wrote: > From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): > > >>> a = 'n' > >>> b = 'ñ' > >>> sys.getsizeof(a) >50 > >>> sys.getsizeof(b) >74 > >>> float(b) >Traceback (most recent call last):

Re: Code Snippets

2017-11-01 Thread Wolfgang Maier
On 01.11.2017 18:25, Stefan Ram wrote: I started to collect some code snippets: Sleep one second __import__( "time" ).sleep( 1 ) Get current directory __import__( "os" ).getcwd() Get a random number __import__( "random" ).random() And so on. You get the idea. However, re

Re: String changing size on failure?

2017-11-01 Thread MRAB
On 2017-11-01 19:26, Ned Batchelder wrote: From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): >>> a = 'n' >>> b = 'ñ' >>> sys.getsizeof(a) 50 >>> sys.getsizeof(b) 74 >>> float(b) Traceback (most recent call last):   Fil

Re: Code Snippets

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 7:17 AM, Stefan Ram wrote: > 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« > al

Re: String changing size on failure?

2017-11-01 Thread Ned Batchelder
On 11/1/17 4:17 PM, MRAB wrote: On 2017-11-01 19:26, Ned Batchelder wrote:   From David Beazley (https://twitter.com/dabeaz/status/925787482515533830):   >>> a = 'n'   >>> b = 'ñ'   >>> sys.getsizeof(a) 50   >>> sys.getsizeof(b) 74   >>> float(b) Traceback (m

Re: String changing size on failure?

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 7:34 AM, Ned Batchelder wrote: > On 11/1/17 4:17 PM, MRAB wrote: >> >> On 2017-11-01 19:26, Ned Batchelder wrote: >>> >>> From David Beazley >>> (https://twitter.com/dabeaz/status/925787482515533830): >>> >>> >>> a = 'n' >>> >>> b = 'ñ' >>> >>> sys.getsiz

Re: Code Snippets

2017-11-01 Thread Irmen de Jong
On 11/01/2017 06:25 PM, Stefan Ram wrote: > import random > ... > random.random() > > Now, the user has to cut the import, paste it to the top > of his code, then go back to the list of snippets, find > the same snippet again, copy the expression, go to his code, > then find the point whe

Re: String changing size on failure?

2017-11-01 Thread Grant Edwards
On 2017-11-01, Ned Batchelder wrote: > On 11/1/17 4:17 PM, MRAB wrote: >> On 2017-11-01 19:26, Ned Batchelder wrote: >>>   From David Beazley >>> (https://twitter.com/dabeaz/status/925787482515533830): >>> >>>   >>> a = 'n' >>>   >>> b = 'ñ' >>>   >>> sys.getsizeof(a) >>> 50 >>>

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: Code Snippets

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 8:02 AM, Ben Bacarisse wrote: > 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,

Re: String changing size on failure?

2017-11-01 Thread David Beazley
Nah. I discuss this behavior (caching of UTF-8 conversions in the C API) in section 15.14 of the Python Cookbook. The tweet was a tutorial, not a question ;-). Admittedly, an evil tutorial... Cheers, Dave > On Nov 1, 2017, at 2:53 PM, Skip Montanaro wrote: > > Leave it to DB to ask the to

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

2017-11-01 Thread Alexey Muranov
Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for` and `try`? It seems clear that it should be rather "then" than "else." Compare also "try ... then ... finally" with "try ... else ... finally". Currently, with "else", it is almost impossib

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

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 8:12 AM, Alexey Muranov wrote: > Hello, > > what do you think about the idea of replacing "`else`" with "`then`" in the > contexts of `for` and `try`? > > It seems clear that it should be rather "then" than "else." Compare also > "try ... then ... finally" with "try ... els

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

2017-11-01 Thread Ned Batchelder
On 11/1/17 5:12 PM, Alexey Muranov wrote: Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for` and `try`? It seems clear that it should be rather "then" than "else." Compare also "try ... then ... finally" with "try ... else ... finally". Cur

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

2017-11-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 8:23 AM, Ned Batchelder wrote: > On 11/1/17 5:12 PM, Alexey Muranov wrote: >> >> Hello, >> >> what do you think about the idea of replacing "`else`" with "`then`" in >> the contexts of `for` and `try`? >> >> It seems clear that it should be rather "then" than "else." Compare

Re: matplot plot hangs

2017-11-01 Thread Andrew Z
nope. it doesnt: I added print-s after each line and that produced: [az@hp src]$ cat ./main1.py import matplotlib.pyplot as plt print("imported") plt.plot([1,2,4,1]) print("plot is done") plt.show() print("show is done") [az@hp src]$ python3.5 ./main1.py imported ^C^Z [1]+ Stopped

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

2017-11-01 Thread Ned Batchelder
On 11/1/17 5:29 PM, Chris Angelico wrote: On Thu, Nov 2, 2017 at 8:23 AM, Ned Batchelder wrote: On 11/1/17 5:12 PM, Alexey Muranov wrote: Hello, what do you think about the idea of replacing "`else`" with "`then`" in the contexts of `for` and `try`? It seems clear that it should be rather "t

what exactly does type.__call__ do?

2017-11-01 Thread Jason Maldonis
Hi everyone, I want to use a metaclass to override how class instantiation works. I've done something analogous to using the Singleton metaclass from the Python3 Cookbook example. However, I want to provide a classmethod that allows for "normal" class instantiation that prevents this metaclass fr

Re: what exactly does type.__call__ do?

2017-11-01 Thread Jason Maldonis
Thanks for the reply. And I think I wasn't clear enough. I was wondering what the metaclass `type`'s `type.__call__` does explicitly. I'm reasonably comfortable writing metaclasses when I need them, and I understand how `.__call__` works for non-metaclass objects. In my first email I gave three po

Re: Code Snippets

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 04:25 am, Stefan Ram wrote: > I started to collect some code snippets: [...] > __import__( "random" ).random() > > And so on. You get the idea. > > However, reportedly, all those snippets are anti-patterns > because they use »__import__«. Correct. Nearly all dunder fun

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 05:53 am, Israel Brewster wrote: [...] > So the end result is that the thread that "updates" the dictionary, and the > thread that initially *populates* the dictionary are actually running in > different processes. If they are in different processes, that would explain why the

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

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 08:12 am, Alexey Muranov wrote: > Hello, > > 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 for many years. The current

Re: Code Snippets

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 05:57 am, Stefan Ram wrote: > I also have heard that there was a module cache, so I > was hoping that a second import of the same module might > not be such an effort for the implementation. There is: sys.modules. Although `import spam` is cheap when spam is in the cache, its

Re: Code Snippets

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 08:02 am, Ben Bacarisse wrote: > 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, b

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

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 08:21 am, Chris Angelico wrote: > With the 'for' loop, > it's a bit more arguable, but I've never seen anything more than a > weak argument in favour of 'then' Thhpptpt! "else" is an completely inappropriate term that doesn't describe the semantics of the statement even a litt

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

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 08:23 am, Ned Batchelder wrote: > Apart from the questions of backward compatibility etc (Python is > unlikely to ever go through another shift like the 2/3 breakage), are > you sure "then" is what you mean?  This won't print "end": > > for i in range(10): > print(i) > e

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

2017-11-01 Thread bartc
On 02/11/2017 01:19, Steve D'Aprano wrote: On Thu, 2 Nov 2017 08:21 am, Chris Angelico wrote: With the 'for' loop, it's a bit more arguable, but I've never seen anything more than a weak argument in favour of 'then' Thhpptpt! "else" is an completely inappropriate term that doesn't describe t

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

2017-11-01 Thread bartc
On 02/11/2017 01:06, Steve D'Aprano wrote: On Thu, 2 Nov 2017 08:12 am, Alexey Muranov wrote: Hello, 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 a

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

2017-11-01 Thread Skip Montanaro
I don't know. The word "then" doesn't connote different ways of exiting a loop to me ("else" doesn't really either, I will grant you that, but it's what we have). Here's how I would read things: - *while* some condition holds, execute the loop, possibly breaking out, *then* do some finishing

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-01 Thread Chris Angelico
On Thu, Nov 2, 2017 at 12:19 PM, Steve D'Aprano wrote: > On Thu, 2 Nov 2017 08:21 am, Chris Angelico wrote: > >> With the 'for' loop, >> it's a bit more arguable, but I've never seen anything more than a >> weak argument in favour of 'then' > > Thhpptpt! > > "else" is an completely inappropriate t

Re: what exactly does type.__call__ do?

2017-11-01 Thread Jason Maldonis
Ok no worries then! Thanks for the tips. I might wait until tomorrow then until someone comes along who deals with metaclasses and alternate class constructors. In case you're curious, I'm doing two things that are relevant here, and I'll link the python3 cookbook examples that are super useful (I

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

2017-11-01 Thread Steve D'Aprano
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`" with "`then`" in >>> the contexts of `for` and `try`? [...] > Re-using finally would not need a new key

Re: what exactly does type.__call__ do?

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 10:13 am, Jason Maldonis wrote: > Hi everyone, > > I want to use a metaclass to override how class instantiation works. I've > done something analogous to using the Singleton metaclass from the Python3 > Cookbook example. In my opinion, nine times out of ten, using a metaclass