Re: [Tutor] how to edit program files in Python?
On 19/12/13 19:33, Laurie Stephan wrote: Hello, My son and I just opened "Python for Kids" and we're working our way through the lessons. Sometimes he mistypes the lines and hits return and discovers after that that he made a mistake in the line. But, when we try to correct the line, we are not able to. We just get that loud beepy sound telling us it's not possible. I'm going to guess that you are on Windows of some variety? If so you should be able to go to Start->All Programs->Python and see an item called Python GUI. Drag that onto your desktop and use that to start Python. It will give you the IDLE tool that others have mentioned. There are some (free?) video tutorials on using IDLE on the showmedo web site. http://www.showmedo.com/videos/series?name=pythonOzsvaldPyNewbieSeries Video 4 in the list is a starter. Alternatively there is a more static one here: http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html Its quite an old version on XP but the principles are all still valid. So... is there any way to go back up to the previous line and correct the syntax? As it is now we are starting the entire file over. It's really cumbersome. Is it supposed to be this way? There are ways to do that in the cmd shell too but IDLE will make it much easier! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to edit program files in Python?
On Thu, Dec 19, 2013 at 2:33 PM, Laurie Stephan wrote: > Hello, > My son and I just opened "Python for Kids" and we're working our way through > the lessons. Sometimes he mistypes the lines and hits return and discovers > after that that he made a mistake in the line. But, when we try to correct > the line, we are not able to. We just get that loud beepy sound telling us > it's not possible. > > So... is there any way to go back up to the previous line and correct the > syntax? As it is now we are starting the entire file over. It's really > cumbersome. Is it supposed to be this way? I don't own this product. (My grandson is only 5) There can be several answers to your question. I would recommend using IDLE. I believe it's mentioned in your documentation. Depending on your computer type you may need to download some other things before IDLE will work. You didn't mention what computer/OS and Python version you are using. You should always state that when asking for help. The author has a web site http://jasonrbriggs.com You may want to ask there. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to edit program files in Python?
Hi, On 19 December 2013 19:33, Laurie Stephan wrote: > My son and I just opened "Python for Kids" and we're working our way through > the lessons. Sometimes he mistypes the lines and hits return and discovers > after that that he made a mistake in the line. But, when we try to correct > the line, we are not able to. We just get that loud beepy sound telling us > it's not possible. > > So... is there any way to go back up to the previous line and correct the > syntax? As it is now we are starting the entire file over. It's really > cumbersome. Is it supposed to be this way? I'm not familiar with this book so my comments are not directed at it and you've not mentioned exactly how you're running Python or on what OS which makes it difficult to give you specific solutions guaranteed to solve your problems. But, in short, there's several ways to run Python code, and by what you're describing it sounds like you're working with the Python interpreter directly. That's fine for experimenting and testing language constructs interactively but is not the way you'd write bigger programs. For that you use some sort of text editor and/or development environment. Python comes with a simple development environment called "IDLE". When run this by default also provides an interactive Python interpreter window to experiment with. It also has the ability to create/open Python program files and then run them in the Python interpreter. (Click "File"->"New", then type some Python code, save it under a suitable filename with a .py extension, then press F5 to run it. Then go back to editing it and press F5 again etc.) You should be able to find it in your program files menu (assuming Windows) pretty easily. Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to edit program files in Python?
Hi, > My son and I just opened "Python for Kids" and we're working our way > through the lessons. Sometimes he mistypes the lines and hits return > and discovers after that that he made a mistake in the line. But, > when we try to correct the line, we are not able to. We just get that > loud beepy sound telling us it's not possible. That's because you are using some interpreter (or wrapper) that is not suited for the job (maybe not suited for anything, really ;)). I guess this thing might be IDLE. I am not going into detail about why I do not see IDLE fit for learning Python ... > So... is there any way to go back up to the previous line and correct > the syntax? As it is now we are starting the entire file over. It's > really cumbersome. Is it supposed to be this way? ... and I won't go into detail about why I do not see the book you are ... reading fit for learning Python ;). To get to the core of your question: Just choose your favourite text editor, write the code in a text file, save it as .py and then execute that script. Cheers, Nik -- * concerning Mozilla code leaking assertion failures to tty without D-BUS * That means, D-BUS is a tool that makes software look better than it actually is. PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17 FD26 B79A 3C16 A0C4 F296 signature.asc Description: Digital signature ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Getting Started
On Thu, Dec 19, 2013 at 8:46 AM, Oscar Benjamin wrote: > So what then is the purpose of running "cmd /c some_console_app"? For > example the git-bash launcher on my desktop runs > C:\WINDOWS\system32\cmd.exe /c ""Q:\TOOLS\Git\bin\sh.exe" --login -i" I guess you're using 32-bit XP. Looking at the history of the Inno Setup config, I see that originally it used system32\cmd.exe /c only for "Git Bash Here", to change the drive:\directory with pushd before running sh.exe. On 64-bit NT 5 (XP) this had problems using 64-bit cmd.exe to start 32-bit sh.exe. A patch was accepted to use {syswow64}\cmd.exe (on 64-bit Windows that's the 32-bit SysWoW64 folder; on 32-bit Windows it's just system32). That patch also switched to using cmd.exe for the desktop shortcut. I don't know why. Currently "Git Bash Here" is handled by the script "Git Bash.vbs". Also, for NT 6+ it configures the shortcut and .sh extension association to run sh.exe directly, instead of via cmd /c. https://github.com/msysgit/msysgit/blob/Git-1.8.4-preview20130916/share/WinGit/install.iss > I think in the future it will be good to advise Windows users to use > the py.exe launcher. Although this wasn't the initial reason for > adding the launcher it usually solves the issue of needing to set PATH > before being able to locate "python" in the shell. py.exe is installed to %windir% for an all-users installation. Otherwise I think it's placed alongside python.exe. Anyway, the 3.3 installer has an option to update the PATH. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Pedantry
On Thu, Dec 19, 2013 at 6:00 AM, wrote: > Correction: no practical way to discourage pedants from correcting anyone > has been found yet. Your statement has no effect (at best). > Correction: small positive effects might occur, but complete elimination of pedantry is unlikely. Negative effects are somewhat probable. I only wish I had something on the terminal comments... -- Keith ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] how to edit program files in Python?
Hello, My son and I just opened "Python for Kids" and we're working our way through the lessons. Sometimes he mistypes the lines and hits return and discovers after that that he made a mistake in the line. But, when we try to correct the line, we are not able to. We just get that loud beepy sound telling us it's not possible. So... is there any way to go back up to the previous line and correct the syntax? As it is now we are starting the entire file over. It's really cumbersome. Is it supposed to be this way? Thank you!!! Laurie___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Saving files in Python, IDE's & editors
On 19/12/13 11:45, Oscar Benjamin wrote: Seriously though, I showed my girlfriend (a social worker) how to do alt-tab a couple of months ago and she was really pleased Never underestimate the ignorance of the average user. When work was slack a few years ago my boss put together a team of "IT consultants" (aka our programmers) and sent them off to client departments in the organization to identify potential productivity gains. The vast majority were showing folks how to do cut n' paste using right mouse clicks and keyboard shortcuts. For advanced users we showed them how to record a macro in MS Word/Excel.. It was so successful the boss got an award! Thankfully work picked up again and we got back to programming before the idea caught on too much! But it was weird being introduced as a "computer guru" just because you'd shown somebody how to hit Ctrl-X/C/V! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Getting Started
On 19 December 2013 12:21, eryksun wrote: > On Thu, Dec 19, 2013 at 4:48 AM, Oscar Benjamin > wrote: >> >> The graphical window that you describe is called cmd.exe and it is the >> standard "terminal emulator" for Windows. > > Oscar, > > cmd doesn't create or manage the console window. That's done by > another process that acts as the console server (conhost, or csrss in > older versions). cmd is just a command-line shell. When you run > another program in cmd, like python.exe, the shell's thread just waits > for the child process to exit. The child process inherits the console > and standard I/O handles for talking to the console server. > > If you run python.exe from Explorer, Windows creates a new console > window since the executable is marked as a console application. On > Windows 7 (NT 6.1) it creates 2 processes: python.exe and conhost.exe. > cmd.exe isn't in the loop. Thanks for the correction Eryksun. I was confusing cmd.exe with the console process. So what then is the purpose of running "cmd /c some_console_app"? For example the git-bash launcher on my desktop runs C:\WINDOWS\system32\cmd.exe /c ""Q:\TOOLS\Git\bin\sh.exe" --login -i" I thought that cmd.exe was being invoked to create the graphical console. > >> Now here's what happens if I just type "py" to enter the Python console: > > Note that py.exe is installed by Python 3.3. If you haven't installed > 3.3, you can download the launcher from the project site: > > https://bitbucket.org/vinay.sajip/pylauncher The OP is using 3.3. I think in the future it will be good to advise Windows users to use the py.exe launcher. Although this wasn't the initial reason for adding the launcher it usually solves the issue of needing to set PATH before being able to locate "python" in the shell. Oscar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Getting Started
On Thu, Dec 19, 2013 at 4:48 AM, Oscar Benjamin wrote: > > The graphical window that you describe is called cmd.exe and it is the > standard "terminal emulator" for Windows. Oscar, cmd doesn't create or manage the console window. That's done by another process that acts as the console server (conhost, or csrss in older versions). cmd is just a command-line shell. When you run another program in cmd, like python.exe, the shell's thread just waits for the child process to exit. The child process inherits the console and standard I/O handles for talking to the console server. If you run python.exe from Explorer, Windows creates a new console window since the executable is marked as a console application. On Windows 7 (NT 6.1) it creates 2 processes: python.exe and conhost.exe. cmd.exe isn't in the loop. > Now here's what happens if I just type "py" to enter the Python console: Note that py.exe is installed by Python 3.3. If you haven't installed 3.3, you can download the launcher from the project site: https://bitbucket.org/vinay.sajip/pylauncher ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Saving files in Python, IDE's & editors
On 19 December 2013 11:15, spir wrote: > > I do agree with most of what you say, except for one point, actually more a > complement than an contradiction: I find it great whenever editors (I > virtually never used IDE's properly) have an integrated terminal (emulator, > in fact), like geany or gedit. Most, nearly all of my actual programming > time (as opposed to just thinking in the wild about current projects) is > spent in code / run / diagnose loops; this means I would constantly be > switching from/to editor/terminal. Pretty annoying, in my view. I've got a great keyboard shortcut for that: alt-tab. The best thing about it is that it works for everything so your editor doesn't also need to integrate every other piece of software that's already available on your system. :) Seriously though, I showed my girlfriend (a social worker) how to do alt-tab a couple of months ago and she was really pleased with the productivity boost; she showed everyone at her work and is now considered an IT pro in her office! Oscar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Saving files in Python, IDE's & editors
On 12/19/2013 12:56 AM, Steven D'Aprano wrote: On Tue, Dec 17, 2013 at 09:28:14PM -0500, Keith Winston wrote: On Tue, Dec 17, 2013 at 7:26 PM, wrote: What else do I need to do to make this version of Python an actually usable programming environment? Chris Acreman Chris, I'm also a noob, but I would recommend you install/use an IDE, such as IDLE which comes free with all (I think) Python installs. An Integrated Development Environment will help with formatting & debugging, but the way I like to use IDLE is open up a window on the right side of my screen with the file I'm working on, and whenever I want to run it I save (ctrl-S, or menu) and run (F5, or menu), and then watch it go in the other window. Very efficient. I do the same thing, but the IDE I use is called "Unix" or "Linux". With just two windows, possibly three, I have access to everything I need to program: - I have an editor open in one window; - a terminal open in another; - and optionally a web browser for looking things up on the Internet. In the editor, I can have as many tabs open as needed. I normally use kate (the KDE Advanced Text Editor), but from KDE 3 only, not KDE 4 which is rubbish. I've also started using Geany, which isn't bad. Sometimes I'll use kwrite, but that has the disadvantage that it doesn't have window tabs, but if I just need one or two files open it is perfectly adaquate. In the terminal, multiple tabs are also needed. I'll have at least two tabs open: one is set to an interactive Python session, where I can try out small code snippets, look up help, and so on; another is set to a shell prompt where I can run Python non-interactively, manage files, perform version control (e.g. using hg or git), run unit tests, etc. Additional tabs are only a click away. The great thing about Unix as an IDE is that I'm not tied to any one single editor. If I decide that editor X is rubbish, I can start using editor Y without having to learn a completely new way to run my unit tests. If I discover a better way to do source code version control, I don't have to throw away my editor. All the individual tools in my tool box are separate. Another good thing about Linux as an IDE is that, with the exception of the GUI editor, I can do it all over SSH on a remote computer: ssh to the other computer, then use the "screen" command to open as many virtual screens as I need. I don't have a GUI, but other than having to use a different editor, everything else works exactly the same. More here: http://blog.sanctum.geek.nz/series/unix-as-ide/ And quoting Zed Shaw: An IDE, or “Integrated Development Environment” will turn you stupid. They are the worst tools if you want to be a good programmer because they hide what’s going on from you, and your job is to know what’s going on. They are useful if you’re trying to get something done and the platform is designed around a particular IDE, but for learning to code C (and many other languages) they are pointless. http://michaelochurch.wordpress.com/2013/01/09/ide-culture-vs-unix-philosophy/ I do agree with most of what you say, except for one point, actually more a complement than an contradiction: I find it great whenever editors (I virtually never used IDE's properly) have an integrated terminal (emulator, in fact), like geany or gedit. Most, nearly all of my actual programming time (as opposed to just thinking in the wild about current projects) is spent in code / run / diagnose loops; this means I would constantly be switching from/to editor/terminal. Pretty annoying, in my view. (That's also a point I disliked in IDLE --maybe it has changed since then: the pseudo-terminal was a separate window.) Indeed, the integrated terminal also permit side tasks like file management or version control, again in the same environment, and without distraction. As a side-note, I consider the following features of a (programming) editor fundamental, even more than syntax highlighting: * code folding * integrated terminal * duplicate (^D in general) (reason why I don't just use gedit, but instead geany) About syntax highlighting, it is for me rather noise than help if ever I cannot precisely, exactly, set it as I like it. Typically there are too many colors, and too saturated (in fact, usually pure colors, "toy-store colors" or as a friend calls them "Disney colors": veeery baaad, and ugly ;-). Denis ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] set locals
On 12/18/2013 09:45 PM, Alan Gauld wrote: On 18/12/13 17:45, Mark Lawrence wrote: Can I be so bold as to ask how discussing metaclasses and __setattr__ on a tutor mailing list is going to help the newbie who's having problems with their "hello world" program? It won't, but the tutor list is also for experienced programmers new to Python, so it might help there. Although I do grant it's a tad more exotic (I nearly said erotic!) than our usual fare. And I'd probably expect to see it on the main Python list. But IMO it is within the group's remit - just! But there is the equally valid counterpoint that overly exotic discussion here can turn away the real newbies who are our bread and butter audience. You are right. Actually, I preferred to susbscribe to tutor (1) because there's far too much traffic on the main python list (2) because other people's questions help and exploring python further (or remember forgotten points) (3) I can at times help myself, which is also enjoyable. Thus, in fact, in practice I consider tutor as if it were a mutual help list rather than dedicated to novice (python) programmers (but I do know this is what it is intended to be). So, sorry for the occasionnal e(x|r)otic stuff; and if you ask to stop it, I won't protest. (You may even ask for it off-list, Alan, if you prefer not to pollute the list more with meta-threads.) Denis ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Getting Started
Oscar Benjamin wrote: > I have to qualify my > statement with this caveat to discourage pedants from correcting me. Correction: no practical way to discourage pedants from correcting anyone has been found yet. Your statement has no effect (at best). ;) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] import error
On 19/12/13 09:14, prashant wrote: hi, I am trying add some python packages required for keystone,but I am getting following error, What is keystone? Do they have a support forum/mail list? /usr/lib/python2.6/site-packages/nose/plugins/manager.py:364: RuntimeWarning: Unable to load plugin pylons = pylons.test:PylonsPlugin: cannot import name fix_call Pylons is a third party Python web framework. Maybe you need to install it separately? Maybe the Pylons support forums will know about this? The best I can offer. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Getting Started
On 19 December 2013 00:11, Chris Acreman wrote: > > "Can you be more specific about the 'Python screen' ?" -- Amit > "How are you running Python at the moment? Is it just the command line > interpreter? Or do you have some kind of GUI tool?" -- Alan > > The "Python Screen" is what opens up when I click the Python button on the > desktop. The book calls it a "console window, window that can display only > text." It is a command line interpreter, with no apparent GUI tools. The > book does have a chapter entitled "GUI Development: The Mad Lib," so I > assume it will include instructions for writing programs with GUIs. > > It is black with gray lettering. The first four lines of text are: >Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012. 10:57:17) [MSC v.1600 64 > bit (AM >D64)] on win 32 >Type "help", "copyright", "credits" or "license" for more information. >>>> > > The screen can be stretched vertically but not horizontally. It is 80 > columns wide. There are a couple of different things going on here which is a little confusing so I'll try to explain. I apologise in advance if you already know all/most of this. The graphical window that you describe is called cmd.exe and it is the standard "terminal emulator" for Windows. Terminal emulators are also called "console windows", "terminal windows" or just "terminals". This particular one is sometimes called "the DOS prompt" or the "DOS box" - although both of those terms are inaccurate so I have to qualify my statement with this caveat to discourage pedants from correcting me. :) http://en.wikipedia.org/wiki/Terminal_emulator Unfortunately MS hasn't put much development effort into this particular part of Windows (cmd.exe) over the last 10-15 years so that it is now massively inferior to most other terminal emulators. Every other operating system I have used (OSX, Linux etc.) ships with a significantly better terminal emulator then cmd.exe. Hence the fact that it is ugly, doesn't resize horizontally, doesn't handle cut and paste very well etc. The terminal emulator can be used to run many different programs. The types of programs that are designed to run in a terminal emulator are often known as "command-line programs" or "console applications". This is to be contrasted with the "graphical" or "GUI" applications that most computer users are familiar with. http://en.wikipedia.org/wiki/Console_application http://en.wikipedia.org/wiki/Graphical_user_interface In particular python.exe on Windows is a console application so when you run it it cmd.exe will open up to show you the output and allow you to type input. This is what happens when you click the Python button on your desktop. You can also run cmd.exe directly without Python. To do this you would push Win-R i.e. hold the "Windows key" and push the "R" key. This opens the "run" dialog. There if you type "cmd" and hit enter it will open cmd.exe. Then you should be able to run Python by typing "py" and hitting enter. Then you will be in the Python console and can type Python commands. To exit Python use the key combination Ctrl-Z. This way you can switch between typing commands into the cmd console or into the Python console. A Python script is a plain-text file with the .py extension that contains Python code. If you have such a file and it is saved in "C:\myfiles\myscript.py" then you can run it in cmd.exe without entering the Python console by typing "py C:\myfiles\myscript.py". This is how I would normally run my Python programs*. Here's an example of how it looks when I run cmd.exe, Change the Directory (cd) to where my Python script is and then run my Python script. O:\>q: Q:\>cd tempdir Q:\tempdir>dir Volume in drive Q has no label. Volume Serial Number is 18AB-2D00 Directory of Q:\tempdir 19/12/2013 09:42 . 19/12/2013 09:42 .. 19/12/2013 09:4222 myscript.py 1 File(s) 22 bytes 2 Dir(s) 178,230,497,280 bytes free Q:\tempdir>py myscript.py Hello World! Now here's what happens if I just type "py" to enter the Python console: Q:\tempdir>py Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> print('Hello World!') Hello World! >>> [** Here I push Ctrl-Z to exit the Python console **] Q:\tempdir> So you don't need to use IDLE or anything like that if you don't want. You just need an editor that can edit plain-text files to write and save your Python scripts and then you can run them with cmd.exe. Again the standard plain-text editing program that ships with Windows (notepad) is absolutely terrible - but there are many others that you could install and use. The standard editor on the Windows systems where I work is called "notepad++" and is vastly better than notepad but it doesn't come with Windows so you need to install it yourself. http://notepad-plus-plus.org/ *
[Tutor] import error
hi, I am trying add some python packages required for keystone,but I am getting following error, /usr/lib/python2.6/site-packages/nose/plugins/manager.py:364: RuntimeWarning: Unable to load plugin pylons = pylons.test:PylonsPlugin: cannot import name fix_call I am stuck here,please anybody help me with this? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Getting Started
On 19/12/13 06:34, eryksun wrote: you need to set. You can read about them by typing 'help cmd' in the console itself. That's assuming the user ran cmd.exe to use its "help" command. Windows automatically opens a console window for python.exe if the process doesn't inherit one. That's what I would expect from a desktop shortcut. Ah yes, good catch! To the OP: You can run a console on its own using the Start->Run dialog and typing 'cmd'. Once you do that you should get a prompt like C:\WINDOWS> or similar From there you can type 'help cmd' as above. You can also start python by typing 'python' and execute one of your programs by typing 'python myprog.py' The latter is how to see any hidden messages etc in the event of a problem. If you are not familiar with cmd and its friends it's worth getting to know them. Programmers tend to use them a lot... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor