Re: write to file

2018-05-05 Thread Chris Angelico
On Sun, May 6, 2018 at 3:10 PM, Sharan Basappa wrote: > On Saturday, 5 May 2018 21:47:33 UTC+5:30, Steven D'Aprano wrote: >> On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: >> >> > Thanks a lot. I have actually tried print with file handle as a >> > parameter (the last option). I see th

Re: write to file

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 21:47:33 UTC+5:30, Steven D'Aprano wrote: > On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: > > > Thanks a lot. I have actually tried print with file handle as a > > parameter (the last option). I see that the file is created but nothing > > is logged. > > That

Re: write to file

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 22:05:53 UTC+5:30, Mark Lawrence wrote: > On 05/05/18 12:25, Sharan Basappa wrote: > > In my program, I have print statements for debugging. > > However, these are cluttering the display. So, I am trying to save > > these to a file but somehow I cant seem to get it correct.

Re: Why is calling eval so slow?

2018-05-05 Thread Serhiy Storchaka
06.05.18 05:29, Steven D'Aprano пише: On Sat, 05 May 2018 20:11:28 +0300, Serhiy Storchaka wrote: Why so slow? 1. Add an overhead of calling eval(), not just looking up its name. It is comparable with a time of calling a simple lambda. 2. Add an overhead of getting the globals dict and creati

Re: ImportError: cannot import name _remove_dead_weakref

2018-05-05 Thread INADA Naoki
On Sun, May 6, 2018 at 1:22 AM joseph pareti wrote: > thanks for the hint, virtualenv looks like an interesting option, however > in my case I need to rely on several components that are already installed > in the VM in Azure, including tensorflow, etc. > If I use virtualenv, do I need to start

Re: Why is calling eval so slow?

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 20:11:28 +0300, Serhiy Storchaka wrote: >> Why so slow? > > 1. Add an overhead of calling eval(), not just looking up its name. It > is comparable with a time of calling a simple lambda. 2. Add an overhead > of getting the globals dict and creating a locals dict. [...] Ah, th

Re: Meaning of abbreviated terms

2018-05-05 Thread MRAB
On 2018-05-05 17:57, T Berger wrote: What does the "p" in "plist" stand for? Is there a python glossary that spells out the meanings of abbreviated terms? "plist" is "property list". It's listed in the Python documentation. -- https://mail.python.org/mailman/listinfo/python-list

Meaning of abbreviated terms

2018-05-05 Thread T Berger
What does the "p" in "plist" stand for? Is there a python glossary that spells out the meanings of abbreviated terms? -- https://mail.python.org/mailman/listinfo/python-list

Re: ipython install

2018-05-05 Thread Terry Reedy
On 5/5/2018 6:09 AM, Sharan Basappa wrote: On Saturday, 5 May 2018 15:02:33 UTC+5:30, Steven D'Aprano wrote: On Sat, 05 May 2018 00:20:26 -0700, Sharan Basappa wrote: After this, when I type ipython on command prompt, I don't get anything on my windows. You don't get *anything*? Not even an

Re: Why is calling eval so slow?

2018-05-05 Thread Serhiy Storchaka
05.05.18 19:10, Steven D'Aprano пише: # calling a regular function python3.5 -m timeit -s "f = lambda: 99" "f()" # evaluating a function code object python3.5 -m timeit -s "f = (lambda: 99).__code__" "eval(f)" # estimate the overhead of the eval name lookup python3.5 -m timeit "eval" # evaluating

Re: write to file

2018-05-05 Thread Mark Lawrence
On 05/05/18 12:25, Sharan Basappa wrote: In my program, I have print statements for debugging. However, these are cluttering the display. So, I am trying to save these to a file but somehow I cant seem to get it correct. Use the logging module https://docs.python.org/3/library/logging.html for

Re: ImportError: cannot import name _remove_dead_weakref

2018-05-05 Thread joseph pareti
thanks for the hint, virtualenv looks like an interesting option, however in my case I need to rely on several components that are already installed in the VM in Azure, including tensorflow, etc. If I use virtualenv, do I need to start from scratch? In addition, I am not sure this will solve my p

Re: write to file

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 08:45:39 -0700, Sharan Basappa wrote: > Thanks a lot. I have actually tried print with file handle as a > parameter (the last option). I see that the file is created but nothing > is logged. That could be a file buffer issue. Nothing will actually be written to the disk until

Why is calling eval so slow?

2018-05-05 Thread Steven D'Aprano
I understand that calling eval() on a string is going to be slow, since the string has to be parsed, compiled, and then executed. But why is it so slow when called on function __code__ objects and pre- compiled byte-code? Here are the tests I ran: # calling a regular function python3.5 -m time

Re: write to file

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 19:00:12 UTC+5:30, Steven D'Aprano wrote: > On Sat, 05 May 2018 04:25:50 -0700, Sharan Basappa wrote: > > > In my program, I have print statements for debugging. However, these are > > cluttering the display. So, I am trying to save these to a file but > > somehow I cant s

Re: itemgetter with default arguments

2018-05-05 Thread Ian Kelly
On Fri, May 4, 2018 at 5:34 PM, Thomas Jollans wrote: > On 04/05/18 22:38, Ian Kelly wrote: >> The real thing is written in C. >> > > Is it though? > > https://github.com/python/cpython/blob/a1fc949b5ab8911a803eee691e6eea55cec43eeb/Lib/operator.py#L265 It is. First, notice the docstring of that m

Re: write to file

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 04:25:50 -0700, Sharan Basappa wrote: > In my program, I have print statements for debugging. However, these are > cluttering the display. So, I am trying to save these to a file but > somehow I cant seem to get it correct. There are lots of way to solve this problem. The bes

Re: itemgetter with default arguments

2018-05-05 Thread Serhiy Storchaka
05.05.18 12:59, Steven D'Aprano пише: On Sat, 05 May 2018 10:31:17 +0300, Serhiy Storchaka wrote: Consider a concrete example. You need to sort a list of 2- or 3- element tuples by the first and third items (third items are strings if presented). itemgetter(0, 2) doesn't work because some tuples

write to file

2018-05-05 Thread Sharan Basappa
In my program, I have print statements for debugging. However, these are cluttering the display. So, I am trying to save these to a file but somehow I cant seem to get it correct. For example, the following are the print statement in my program: print("target_names\n",target_names) To print to a

Re: ipython install

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 15:39:32 UTC+5:30, Sharan Basappa wrote: > On Saturday, 5 May 2018 15:02:33 UTC+5:30, Steven D'Aprano wrote: > > On Sat, 05 May 2018 00:20:26 -0700, Sharan Basappa wrote: > > > > > After this, when I type ipython on command prompt, I don't get anything > > > on my windows

Re: ipython install

2018-05-05 Thread Sharan Basappa
On Saturday, 5 May 2018 15:02:33 UTC+5:30, Steven D'Aprano wrote: > On Sat, 05 May 2018 00:20:26 -0700, Sharan Basappa wrote: > > > After this, when I type ipython on command prompt, I don't get anything > > on my windows. > > You don't get *anything*? Not even an error? > > > > -- > Steve

Re: itemgetter with default arguments

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 10:31:17 +0300, Serhiy Storchaka wrote: > Consider a concrete example. You need to sort a list of 2- or 3- element > tuples by the first and third items (third items are strings if > presented). itemgetter(0, 2) doesn't work because some tuples has only 2 > items. But you can u

Re: ipython install

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 00:20:26 -0700, Sharan Basappa wrote: > After this, when I type ipython on command prompt, I don't get anything > on my windows. You don't get *anything*? Not even an error? -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: itemgetter with default arguments

2018-05-05 Thread Steven D'Aprano
On Sat, 05 May 2018 09:33:37 +0200, Peter Otten wrote: > I think you have established that there is no straight-forward way to > write this as a lambda. What I *mostly* established was that I was having a "cannot brain, I have the dumb" day, because the solution with ternary if was obvious in h

Re: itemgetter with default arguments

2018-05-05 Thread Peter Otten
Steven D'Aprano wrote: > A re-occurring feature request is to add a default to itemgetter and > attrgetter. For example, we might say: > > from operator import itemgetter > f = itemgetter(1, 6, default="spam") # proposed feature > f("Hello World!") # returns ('e', 'W') > f("Hello") # re

Re: itemgetter with default arguments

2018-05-05 Thread Serhiy Storchaka
04.05.18 20:04, Steven D'Aprano пише: On Fri, 04 May 2018 09:17:14 -0600, Ian Kelly wrote: On Fri, May 4, 2018 at 7:01 AM, Steven D'Aprano wrote: Here are the specifications: * you must use lambda, not def; Why? This seems like an arbitrary constraint. You'll have to ask the two core devs

ipython install

2018-05-05 Thread Sharan Basappa
I am trying to install ipython. I already have python installed. When I type "pip install ipython" I get the following messages: Requirement already satisfied: setuptools>=18.5 in d:\users\sharanb\appdata\local\programs\python\python36-32\lib\site-packages (from ipython) Requirement already sat

Re: ImportError: cannot import name _remove_dead_weakref

2018-05-05 Thread dieter
joseph pareti writes: > thank you for the advice: depending on the value of PYTHONPATH (version > 2.7, 3.5, or unset), tensorflow stops with 3 different error traps "PYTHONPATH" usually is used when you have private Python modules not installed at the standard place. Nowadays, you can use a so ca

Re: Tk covering the entire screen

2018-05-05 Thread Serhiy Storchaka
04.05.18 23:15, Skip Montanaro пише: I forgot to mention that when running on Linux (displaying back on Windows), the Python 3 version (3.6.4, Tk 8.6) does cover all three screens. The Windows Python 2.7.14 version with Tk 8.5 has problems. Try to upgrade to 2.7.15. It should be shipped with Tk

Re: Tk covering the entire screen

2018-05-05 Thread Serhiy Storchaka
04.05.18 22:54, Skip Montanaro пише: I suspect this is a Tk issue as much as anything, but this is the only place I know to ask Tk questions. Any ideas? There is more specific place for Tkinter questions: https://mail.python.org/mailman/listinfo/tkinter-discuss -- https://mail.python.org/mail