Re: Windows, IDLE, __doc_, other
On 12/30/2009 6:21 AM, W. eWatson wrote: Lie Ryan wrote: On 12/29/2009 5:10 AM, W. eWatson wrote: Lie Ryan wrote: If you're on Windows, don't use the Edit with IDLE right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start menu. When I go to Start and select IDLE, Saves or Opens want to go into C:/Python25. I have to motor over to my folder where I keep the source code. The code is in a folder about 4 levels below the top. That's a bit awkward. Is there a way to go directly to the folder I normally work in? These are the various workarounds, I've used or heard: 1. Open using Edit in IDLE, close it; then open IDLE properly from Start Menu and open your file from the list of Recent files 2. Shift-RightClick on the folder, get to Open Command Window Here. Use python interpreter from there to execute python -m idlelib.idle myfile.py. 3. create a .bat or shortcut file in your working directory to start IDLE 4. [GENERIC WARNING: Editing registry may damage your system] [SPECIFIC WARNING: There must be a reason the IDLE devs put the -n flag on the context menu, I'm not fully aware of the complications, and I disclaim myself from any damage that may be caused] Open Registry Editor, browse to these: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command HKEY_CLASSES_ROOT\Python.NoConFile\shell\Edit with IDLE\command and remove the -n flag from the commands -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Lie Ryan wrote: On 12/29/2009 5:10 AM, W. eWatson wrote: Lie Ryan wrote: If you're on Windows, don't use the Edit with IDLE right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start menu. When I go to Start and select IDLE, Saves or Opens want to go into C:/Python25. I have to motor over to my folder where I keep the source code. The code is in a folder about 4 levels below the top. That's a bit awkward. Is there a way to go directly to the folder I normally work in? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? I suggest you download a programmers' editor (like Notepad++ or PsPad) for programming work and use the basic Python interpreter for interactive work. The basic interpreter lives in a standard Window console window where you can use up and down arrow keys, F8 completion, F7 for list of earlier commands, etc (as documented by the doskey command in the Windows command interpreter). Just forget IDLE in windows: while Windows console windows are something from the middle ages, IDLE seems to stem from a period before that! g Cheers hth., - Alf PS: Shameless plug: take a look at url: http://tinyurl.com/programmingbookP3, it's for Windows. I just downloaded the three files. It looks useful. I take it you are the author? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Lie Ryan wrote: On 12/22/2009 12:06 PM, W. eWatson wrote: ... You must be starting IDLE without subprocess. Did you see this message IDLE 2.6.1 No Subprocess when starting IDLE. Yes, I usually start in a folder where I have my py program files, and do a right-click for IDLE edit. If you're on Windows, don't use the Edit with IDLE right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start menu. When I go to Start and select IDLE, Saves or Opens want to go into C:/Python25. I have to motor over to my folder where I keep the source code. The code is in a folder about 4 levels below the top. That's a bit awkward. What do subprocesses mean in this context? Why do I need them? line: a = 1. I choose Run Module, and it runs it. I verify in the interactive interpreter that a is 1. I then change that file to a = a + 1, and run it. Now, it errors out-- of course-- because IDLE cleared the namespace and re-ran the module. Hmmm, that appears to contrary to my numpy experience. I've never seen any re-starting msg. Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. That is irrelevant with numpy. If you start IDLE with subprocess, then every time before you run a script this message appears: = RESTART = PS: you can force IDLE to restart the subprocess with Ctrl+F6 It says in the interpreter its restarting, even. When IDLE is not run with subprocess, running a script is equivalent to copy and pasteing the script to the shell. I just tried Ctrl+F6 on both the shell and script window. Nothing happened. Does that occur only if I fired up Python from Start? Does a restart clear out the namespace? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On 12/29/2009 5:10 AM, W. eWatson wrote: Lie Ryan wrote: If you're on Windows, don't use the Edit with IDLE right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start menu. When I go to Start and select IDLE, Saves or Opens want to go into C:/Python25. I have to motor over to my folder where I keep the source code. The code is in a folder about 4 levels below the top. That's a bit awkward. I agree the Edit in IDLE not using subprocess is annoying. I personally considers this a bug in IDLE; I don't know whether there is any technical limitation why the Edit with IDLE submenu can't start python with subprocess, perhaps someone else can point something out. What do subprocesses mean in this context? Why do I need them? IDLE is written in python; when IDLE executes without subprocess, it will use IDLE's instance of the python.exe process to execute your script. That means you share the python.exe interpreter with IDLE itself. When IDLE is started properly with subprocess, IDLE will fork a new python.exe subprocess to run your program. When IDLE is not run with subprocess, running a script is equivalent to copy and pasteing the script to the shell. I just tried Ctrl+F6 on both the shell and script window. Nothing happened. Does that occur only if I fired up Python from Start? Yes. Does a restart clear out the namespace? Yes it will, occasional restart will be useful if you write from the Edit with IDLE menu. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On 12/22/2009 12:06 PM, W. eWatson wrote: Stephen Hansen wrote: On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wolftra...@invalid.com wrote: [snip Now, I go to the script and enter from math import * dir is now bulked up with the math functions. I change back math.cos to cos and the program runs well. This sort of figures. Apparently, I've added to the namespace by importing with *. Apparently? -- you precisely and explicitly added every object in 'math' to your current namespace. from math import * does precisely that. Well, it's a big surprise to me, because I thought each time I ran from the editor that it reloaded the modules in my imports, and cleared out any it didn't find. My point is that I'm betting different results. OK, fine. It appears the same thing happens with I modify the program itself with from math import * Different results? What different results are you talking about? It seems to me as I fool around with interpreter under the script window, Im creating a mess out of the namespace the program uses, and the program responds incorrectly. After a script's execution, IDLE's shell namespace uses the last scripts's namespace; this is similar to using the -i switch in the terminal: $ python -i myscript.py program output foo() # foo() is a function defined in myscript.py this is often useful for debugging If you want to access 'sin' without 'math.', you'll have to do 'from math import *' in each file where you want to do that. So IDLE is not clearing the namespace each time I *run* the program. This is not good. I've been fooled. So how do I either clear the namespace before each Run? Do I have to open the file in the editor again each time before trying to Run it? I hope there's a better way. How do you figure its 'not clearing the namespace'? In which namespace? I fire up IDLE, and start a new file, and put in a single Try this sequence. I just started plugging away again with IDLE and am pretty convinced that IDLE is something of an enemy. I started afresh loading this into the editor: import math print hello, math world. print math.cos(0.5) print math.sin(0.8) Run works fine. No errors. Now I do: dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math'] OK, swell. Now I import via the script window import numpy as np dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math', 'np'] I think I'm adding to the namespace, both the program the shell sees, because adding this ref to np in the program works fine. import math print hello, math world. print math.cos(0.5) print math.sin(0.8) print np.sin(2.2) --- There's no np in that code, but yet it works. It must be in the namespace it sees, and it was put there through the interactive shell. You must be starting IDLE without subprocess. Did you see this message IDLE 2.6.1 No Subprocess when starting IDLE. If you're on Windows, don't use the Edit with IDLE right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start menu. line: a = 1. I choose Run Module, and it runs it. I verify in the interactive interpreter that a is 1. I then change that file to a = a + 1, and run it. Now, it errors out-- of course-- because IDLE cleared the namespace and re-ran the module. Hmmm, that appears to contrary to my numpy experience. I've never seen any re-starting msg. Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. That is irrelevant with numpy. If you start IDLE with subprocess, then every time before you run a script this message appears: = RESTART = PS: you can force IDLE to restart the subprocess with Ctrl+F6 It says in the interpreter its restarting, even. When IDLE is not run with subprocess, running a script is equivalent to copy and pasteing the script to the shell. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
* Alf P. Steinbach: * W. eWatson: When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words without reasonable line breaks. \nNumPy\n=\n\nProvides\n 1. An array object of arbitrary homogeneous items\n 2. Fast mathematical operations over arrays\n 3. Linear Algebra, Fourier Transforms, Random Number ... Is there a way to get this formated properly. print( numpy.__doc__ ) (For Python 2.x you can and best should leave out the parenthesis) If I use dir(numpy), I get yet a very long list that starts as: ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT' ... I see this might be a dictionary. What can I do to make it more readable or useful, or is that it? Is there a more abc as in Linux? Something like (off the cuff, fix if eroRs!) for name in dir[numpy]: if name.startswith( _ ): pass else: doc_lines = getattr( numpy, name ).__doc__.split() Uh oh, 'splitlines' not 'split' ! print( format( {0:25} {1}.format( name, doc_lines[0] ) ) Should ideally work whether you use Python 2.x or 3.x. But as mentioned I just typed that in so there may be eroRs. It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? I suggest you download a programmers' editor (like Notepad++ or PsPad) for programming work and use the basic Python interpreter for interactive work. The basic interpreter lives in a standard Window console window where you can use up and down arrow keys, F8 completion, F7 for list of earlier commands, etc (as documented by the doskey command in the Windows command interpreter). Just forget IDLE in windows: while Windows console windows are something from the middle ages, IDLE seems to stem from a period before that! g Cheers hth., - Alf PS: Shameless plug: take a look at url: http://tinyurl.com/programmingbookP3, it's for Windows. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Lie Ryan wrote: On 12/21/2009 1:19 PM, W. eWatson wrote: When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words without reasonable line breaks. \nNumPy\n=\n\nProvides\n 1. An array object of arbitrary homogeneous items\n 2. Fast mathematical operations over arrays\n 3. Linear Algebra, Fourier Transforms, Random Number Is there a way to get this formated properly. help(object) If I use dir(numpy), I get yet a very long list that starts as: ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT' I see this might be a dictionary. What can I do to make it more readable or useful, or is that it? Is there a more abc as in Linux? You can use pprint module: import pprint pprint.pprint(dir(object)) though help() is usually better It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? Press Alt+P (Previous) and Alt+N (Next). Or you can click/select on the line you want to copy and press Enter. Add to this. Isn't there a way to see the arguments and descriptions of functions? Use help(). Or if you're doing this without human intervention, use `inspect` module. Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and a little window came up showing it was about to print hundreds of pages. I can canceled it, but too late. I turned off my printer quickly and eventually stopped the onslaught. I couldn't get Alt-P or N to work. Another question. In interactive mode, how does one know what modules are active? Is there a way to list them with a simple command? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On 12/22/2009 6:39 AM, W. eWatson wrote: Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and a little window came up showing it was about to print hundreds of pages. I can canceled it, but too late. I turned off my printer quickly and eventually stopped the onslaught. I couldn't get Alt-P or N to work. Another question. In interactive mode, how does one know what modules are active? Is there a way to list them with a simple command? What do you mean by active? All loaded modules, whether it is in your namespace or not? Then sys.modules. Else if you want all names in your namespace, dir() would do, though it'll show other things as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Lie Ryan wrote: On 12/22/2009 6:39 AM, W. eWatson wrote: Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and a little window came up showing it was about to print hundreds of pages. I can canceled it, but too late. I turned off my printer quickly and eventually stopped the onslaught. I couldn't get Alt-P or N to work. Another question. In interactive mode, how does one know what modules are active? Is there a way to list them with a simple command? What do you mean by active? All loaded modules, whether it is in your namespace or not? Then sys.modules. Else if you want all names in your namespace, dir() would do, though it'll show other things as well. Let's forget active. Isn't it true that math is automatically available to every module? From help(math): Help on built-in module math: NAME math FILE (built-in) DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. = So why do I need math.cos(...)? This is got to be some namespace issue. Maybe the help is incorrect. I have: dir(__builtins__) ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', '__name__', 'abs', 'all', 'any', 'apply', 'basestring', 'bool', 'buffer', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On Mon, Dec 21, 2009 at 1:51 PM, W. eWatson wolftra...@invalid.com wrote: Lie Ryan wrote: On 12/22/2009 6:39 AM, W. eWatson wrote: Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and a little window came up showing it was about to print hundreds of pages. I can canceled it, but too late. I turned off my printer quickly and eventually stopped the onslaught. I couldn't get Alt-P or N to work. Another question. In interactive mode, how does one know what modules are active? Is there a way to list them with a simple command? What do you mean by active? All loaded modules, whether it is in your namespace or not? Then sys.modules. Else if you want all names in your namespace, dir() would do, though it'll show other things as well. Let's forget active. Isn't it true that math is automatically available to every module? From help(math): No, its not true. A built-in module does not mean its available everywhere. It means its built into Python itself-- e.g., its directly linked into the python dll and not a separate file (like most of the the standard library). Lots of modules are built-in, but they don't pollute the __builtins__ / universal namespace. You import them to access them. If you want you can from math import * if you want the math module to fill out your module namespace (I don't recommend *'s personally, its better to import symbols explicitly by name) --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 1:51 PM, W. eWatson wolftra...@invalid.com wrote: Lie Ryan wrote: On 12/22/2009 6:39 AM, W. eWatson wrote: Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and No, its not true. A built-in module does not mean its available everywhere. It means its built into Python itself-- e.g., its directly linked into the python dll and not a separate file (like most of the the standard library). Lots of modules are built-in, but they don't pollute the __builtins__ / universal namespace. You import them to access them. If you want you can from math import * if you want the math module to fill out your module namespace (I don't recommend *'s personally, its better to import symbols explicitly by name) --S This has got to be some sort of IDLE issue then. When I run a simple program. If I open this program in the IDLE editor: #import math print hello, math world. print cos(0.5) print sin(0.8) then I get print cos(0.5) NameError: name 'cos' is not defined OK, dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib'] Fine. I now change the code to include import mat get the same: print cos(0.5) NameError: name 'cos' is not defined Now, dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math'] math is now available. so I change cos(0.5) to math.cos(0.5) and get print sin(0.8) NameError: name 'sin' is not defined Fine, it needs math. dir() is the same. Now, I go to the script and enter from math import * dir is now bulked up with the math functions. I change back math.cos to cos and the program runs well. This sort of figures. Apparently, I've added to the namespace by importing with *. My point is that I'm betting different results. OK, fine. It appears the same thing happens with I modify the program itself with from math import * So IDLE is not clearing the namespace each time I *run* the program. This is not good. I've been fooled. So how do I either clear the namespace before each Run? Do I have to open the file in the editor again each time before trying to Run it? I hope there's a better way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wolftra...@invalid.com wrote: This has got to be some sort of IDLE issue then. Huh? How do you figure? When I run a simple program. If I open this program in the IDLE editor: #import math print hello, math world. print cos(0.5) print sin(0.8) then I get print cos(0.5) NameError: name 'cos' is not defined Of course, because -- cos is not defined. As I stated in my previous email, math has to be imported to be used. OK, dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib'] Fine. I now change the code to include import mat get the same: print cos(0.5) NameError: name 'cos' is not defined Yes, because cos is inside math. [snip Now, I go to the script and enter from math import * dir is now bulked up with the math functions. I change back math.cos to cos and the program runs well. This sort of figures. Apparently, I've added to the namespace by importing with *. Apparently? -- you precisely and explicitly added every object in 'math' to your current namespace. from math import * does precisely that. My point is that I'm betting different results. OK, fine. It appears the same thing happens with I modify the program itself with from math import * Different results? What different results are you talking about? If you want to access 'sin' without 'math.', you'll have to do 'from math import *' in each file where you want to do that. So IDLE is not clearing the namespace each time I *run* the program. This is not good. I've been fooled. So how do I either clear the namespace before each Run? Do I have to open the file in the editor again each time before trying to Run it? I hope there's a better way. How do you figure its 'not clearing the namespace'? In which namespace? I fire up IDLE, and start a new file, and put in a single line: a = 1. I choose Run Module, and it runs it. I verify in the interactive interpreter that a is 1. I then change that file to a = a + 1, and run it. Now, it errors out-- of course-- because IDLE cleared the namespace and re-ran the module. It says in the interpreter its restarting, even. --S -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wolftra...@invalid.com wrote: This has got to be some sort of IDLE issue then. Huh? How do you figure? When I run a simple program. If I open this program in the IDLE editor: #import math print hello, math world. print cos(0.5) print sin(0.8) then I get print cos(0.5) NameError: name 'cos' is not defined Of course, because -- cos is not defined. As I stated in my previous email, math has to be imported to be used. Yes, I agree. OK, dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib'] Fine. I now change the code to include import mat get the same: print cos(0.5) NameError: name 'cos' is not defined Yes, because cos is inside math. True enough. Hang in there. [snip Now, I go to the script and enter from math import * dir is now bulked up with the math functions. I change back math.cos to cos and the program runs well. This sort of figures. Apparently, I've added to the namespace by importing with *. Apparently? -- you precisely and explicitly added every object in 'math' to your current namespace. from math import * does precisely that. Well, it's a big surprise to me, because I thought each time I ran from the editor that it reloaded the modules in my imports, and cleared out any it didn't find. My point is that I'm betting different results. OK, fine. It appears the same thing happens with I modify the program itself with from math import * Different results? What different results are you talking about? It seems to me as I fool around with interpreter under the script window, Im creating a mess out of the namespace the program uses, and the program responds incorrectly. If you want to access 'sin' without 'math.', you'll have to do 'from math import *' in each file where you want to do that. So IDLE is not clearing the namespace each time I *run* the program. This is not good. I've been fooled. So how do I either clear the namespace before each Run? Do I have to open the file in the editor again each time before trying to Run it? I hope there's a better way. How do you figure its 'not clearing the namespace'? In which namespace? I fire up IDLE, and start a new file, and put in a single Try this sequence. I just started plugging away again with IDLE and am pretty convinced that IDLE is something of an enemy. I started afresh loading this into the editor: import math print hello, math world. print math.cos(0.5) print math.sin(0.8) Run works fine. No errors. Now I do: dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math'] OK, swell. Now I import via the script window import numpy as np dir() ['__builtins__', '__doc__', '__file__', '__name__', 'idlelib', 'math', 'np'] I think I'm adding to the namespace, both the program the shell sees, because adding this ref to np in the program works fine. import math print hello, math world. print math.cos(0.5) print math.sin(0.8) print np.sin(2.2) --- There's no np in that code, but yet it works. It must be in the namespace it sees, and it was put there through the interactive shell. line: a = 1. I choose Run Module, and it runs it. I verify in the interactive interpreter that a is 1. I then change that file to a = a + 1, and run it. Now, it errors out-- of course-- because IDLE cleared the namespace and re-ran the module. Hmmm, that appears to contrary to my numpy experience. I've never seen any re-starting msg. Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type copyright, credits or license() for more information. It says in the interpreter its restarting, even. --S -- http://mail.python.org/mailman/listinfo/python-list
Windows, IDLE, __doc_, other
When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words without reasonable line breaks. \nNumPy\n=\n\nProvides\n 1. An array object of arbitrary homogeneous items\n 2. Fast mathematical operations over arrays\n 3. Linear Algebra, Fourier Transforms, Random Number ... Is there a way to get this formated properly. If I use dir(numpy), I get yet a very long list that starts as: ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT' ... I see this might be a dictionary. What can I do to make it more readable or useful, or is that it? Is there a more abc as in Linux? It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
Add to this. Isn't there a way to see the arguments and descriptions of functions? -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On 12/21/2009 1:19 PM, W. eWatson wrote: When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words without reasonable line breaks. \nNumPy\n=\n\nProvides\n 1. An array object of arbitrary homogeneous items\n 2. Fast mathematical operations over arrays\n 3. Linear Algebra, Fourier Transforms, Random Number Is there a way to get this formated properly. help(object) If I use dir(numpy), I get yet a very long list that starts as: ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT' I see this might be a dictionary. What can I do to make it more readable or useful, or is that it? Is there a more abc as in Linux? You can use pprint module: import pprint pprint.pprint(dir(object)) though help() is usually better It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? Press Alt+P (Previous) and Alt+N (Next). Or you can click/select on the line you want to copy and press Enter. Add to this. Isn't there a way to see the arguments and descriptions of functions? Use help(). Or if you're doing this without human intervention, use `inspect` module. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
On Sun, Dec 20, 2009 at 9:16 PM, W. eWatson wolftra...@invalid.com wrote: When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words without reasonable line breaks. \nNumPy\n=\n\nProvides\n 1. An array object of arbitrary homogeneous items\n 2. Fast mathematical operations over arrays\n 3. Linear Algebra, Fourier Transforms, Random Number ... Is there a way to get this formated properly. when you just do numpy.__doc__ you get the repr of the string, which uses the escaped characters. You'd get the same thing in the interactive interpreter. Try using print if you want to see it correctly. If I use dir(numpy), I get yet a very long list that starts as: ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT' ... I see this might be a dictionary. What can I do to make it more readable or useful, or is that it? Is there a more abc as in Linux? It's a list, not a dictionary. pprint.pprint will print 1 item per line. It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, IDLE, __doc_, other
* W. eWatson: When I use numpy.__doc__ in IDLE under Win XP, I get a heap of words without reasonable line breaks. \nNumPy\n=\n\nProvides\n 1. An array object of arbitrary homogeneous items\n 2. Fast mathematical operations over arrays\n 3. Linear Algebra, Fourier Transforms, Random Number ... Is there a way to get this formated properly. print( numpy.__doc__ ) (For Python 2.x you can and best should leave out the parenthesis) If I use dir(numpy), I get yet a very long list that starts as: ['ALLOW_THREADS', 'BUFSIZE', 'CLIP', 'DataSource', 'ERR_CALL', 'ERR_DEFAULT', 'ERR_DEFAULT2', 'ERR_IGNORE', 'ERR_LOG', 'ERR_PRINT', 'ERR_RAISE', 'ERR_WARN', 'FLOATING_POINT_SUPPORT', 'FPE_DIVIDEBYZERO', 'FPE_INVALID', 'FPE_OVERFLOW', 'FPE_UNDERFLOW', 'False_', 'Inf', 'Infinity', 'MAXDIMS', 'MachAr', 'NAN', 'NINF', 'NZERO', 'NaN', 'PINF', 'PZERO', 'PackageLoader', 'RAISE', 'RankWarning', 'SHIFT_DIVIDEBYZERO', 'SHIFT_INVALID', 'SHIFT_OVERFLOW', 'SHIFT_UNDERFLOW', 'ScalarType', 'Tester', 'True_', 'UFUNC_BUFSIZE_DEFAULT' ... I see this might be a dictionary. What can I do to make it more readable or useful, or is that it? Is there a more abc as in Linux? Something like (off the cuff, fix if eroRs!) for name in dir[numpy]: if name.startswith( _ ): pass else: doc_lines = getattr( numpy, name ).__doc__.split() print( format( {0:25} {1}.format( name, doc_lines[0] ) ) Should ideally work whether you use Python 2.x or 3.x. But as mentioned I just typed that in so there may be eroRs. It the IDLE shell, it's not possible to retrieve lines entered earlier without copying them. Is there an edit facility? I suggest you download a programmers' editor (like Notepad++ or PsPad) for programming work and use the basic Python interpreter for interactive work. The basic interpreter lives in a standard Window console window where you can use up and down arrow keys, F8 completion, F7 for list of earlier commands, etc (as documented by the doskey command in the Windows command interpreter). Just forget IDLE in windows: while Windows console windows are something from the middle ages, IDLE seems to stem from a period before that! g Cheers hth., - Alf PS: Shameless plug: take a look at url: http://tinyurl.com/programmingbookP3, it's for Windows. -- http://mail.python.org/mailman/listinfo/python-list