[Tutor] New to Python and Linux

bhaaluu bhaaluu at gmail.com
Wed Sep 26 15:06:07 CEST 2007


Greetings,

I don't know how to do ms-windows, but I use GNU/Linux on a daily
basis. There is a nice IDE (Integrated Development Environment) for
Python called IDLE. It is available for ms-windows, GNU/Linux, and maybe
another OS as well. There is information about IDLE at Python.Org.  I'd
suggest that you Check It Out. If it isn't already installed on your FedoraCore
distro, you'll have to download it.  http://www.python.org/idle/
IDLE has a shell, an editor, a debugger, and all sorts of bells and whistles.

What you'll find out about GNU/Linux is: it isn't very difficult at all.....
you're just unfamiliar with it. The unfamiliarity makes it seem difficult. =)
It's actually easier to use than ms-windows, once you become familiar
with it, much easier.  You should see me trying to do anything on a
ms-windows computer... it seems so braindead to me, I flop around
like a fish out of water because I'm not familiar with it. Okay, enuff of that.
(That was my version of encouragement. =)

I use vim.
vim is "vi improved".
vi (pronounced "vee-eye") is the 'vi'sual editor.
There is some version of vi on just about every *nix box out there.
vi has been around since almost the very beginning of creation.
(the beginning of creation is counted from 1970-01-01 or thereabouts...
The vi editor was developed starting around 1976 by Bill Joy, who was
then a graduate student at the University of California at Berkeley.
... )

So, why vim, and not an easier editor, like pico or nano, or a swiss-army-editor
like emacs, or a GUI editor like Gedit, or Nedit, or Kate, or Kwrite?
pico and nano are extremely limited. Yeah, they're easy: too easy!
You can't really do anything serious with them.
Your favorite GUI editor might not be available. I once watched a couple
of guys who were thrown out of X to a console, trying to edit a config file
to get X going, using vi. They didn't have their favorite GUI editor, and
they were completely lost. It was hilarious to watch them. I let them
suffer for a few minutes before offering suggestions. Too funny! 8^D
emacs? I won't go there... it's like dicussing religion, or something. There
are Python bindings for emacs, which will allow you to run it like an IDE.

vim is ubiquitous, powerful, and very, very sexy.  That last part was to
make you curious enough to try it. Do you have vim on your fedoracore?
Maybe. I always have to download it with a new install of my distro.
nvi is the default version of vi with a new install of my distro.

vim.
Open a terminal and type: which vim
If you get something like: /usr/bin/vim
then you're in business. Otherwise, you'll have to grab it and install it.
Once you have it, you start it by typing vim at the prompt.
Once in vim, press Shift-colon ( : ) help
:help
To exit vim, press Shift-colon q
:q
(you may have to do it a couple of times, if you're in help)

vim comes with an interactive tutorial called: vimtutor
Just type: vimtutor at the prompt to start it. It has enough stuff in it
to get you started. Once you've started, you can pick up more
advanced stuff as you need it.

Now the part you've been waiting for!
To make vim a Python IDE, copy/paste this file into your home directory:

" .vimrc
"
" Created by Jeff Elkner 23 January 2006
" Last modified 2 February 2006
"
" Turn on syntax highlighting and autoindenting
syntax enable
filetype indent on
" set autoindent width to 4 spaces (see
" http://www.vim.org/tips/tip.php?tip_id=83)
set nu
set et
set sw=4
set smarttab
" Bind <f2> key to running the python interpreter on the currently active
" file.  (curtesy of Steve Howell from email dated 1 Feb 2006).
map <f2> :w\|!python %<cr>

Now edit your Python code in an editor that has line numbers
(my addition to the original file, found at:
http://www.ibiblio.org/obp/pyBiblio/tips/elkner/vim4python.php )
syntax highlighting, auto-indent, AND, just press the F2 function
key to run the code from the editor (no quitting the editor, running
the code, starting the editor....).

Here is an interesting and helpful Visual vi tutorial:
http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html

Finally, from the same site:
"Why, oh WHY, do those #?@! nutheads use vi?"
http://www.viemu.com/a-why-vi-vim.html

What fun, eh? ;-)
-- 
b h a a l u u at g m a i l dot c o m
http://www.geocities.com/ek.bhaaluu/index.html

On 9/26/07, Armand Nell <hobo.online at gmail.com> wrote:
> Hi
>
> I am new to python programming and also the linux enviroment most of my
> skills are windows based and programming skills is visual basics. I decided
> that it would be a great start and new direction for me to learn python and
> at the same time linux. However I have already run into a wall, and any help
> would be appreciated even if you can direct me where to find the info or
> 'turor'.
>
> I am running Fedoracore 7 and Python 2.5
>
> In windows, if i write a program in Python and save it I then can simply
> double click the icon and the program will execute in a console window. Now
> under Fedoracore I write my program in gedit save it in my
> \home\(username)\python directory, when I double click it, it opens up agian
> in gedit. Now true it is maybe a simple error from me but mostly it is me
> that don't know how to work with python on linux.
>
> I would like to know how do I test(run) the programs I write under
> fedoracore?
>
> Simple yet challanging for me,
>
> Your patience and wisdom on this subject will be greatly appreciated.
>
> Regards
>
> Digitalhobo
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


More information about the Tutor mailing list