Re: [Tutor] New to Python and Linux

2007-09-28 Thread Thorsten Kampe
* Armand Nell (Wed, 26 Sep 2007 08:07:12 +0200)
 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'.
 [...]
 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?

It's exactly the same as with with Visual Basic (visual basics? Are 
you sure you have experience in that language?) and Windows: run it 
in a command window (like python myscript.py) or associate the file 
type (.py) with the program.

How you do that depends on your desktop environment (KDE or Gnome 
probably) but it shouldn't take you more than ten seconds to find out 
how to do it.


Thorsten

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python and Linux

2007-09-28 Thread Thorsten Kampe
* Thorsten Kampe (Fri, 28 Sep 2007 14:09:24 +0100)
 It's exactly the same as with with Visual Basic [...]

Guess I mixed that up with VBScript...

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python and Linux

2007-09-26 Thread Michael Langford
Somewhere in the start menu, you'll be able to open a terminal. It
might be called GTerm, Gnome Term, xterm, or any number of things with
term in the name.

Once you've done that, you need to see if python is in your path. Do
that by typing python in the terminal. If you enter the python shell,
you're in luck.exit out (Ctrl-Z return, probably),  If not, you need
to install/find python and add it to your path by typing

export PATHTOPY=/usr/bin/python   #I don't know where python is for
you...this is just a guess
export PATH=$PATH:$PYTHTOPY

If you google bashrc, you'll learn how to make it so you don't have to
type this every time.

Now, you should be able to type cd python in a terminal you broght
up. This will change into the python directory you said you made in
your home dir. Now type ls. That should show you a list of files in
the directory. If there is a python file there, say, named foo.py,
then you'd type

python foo.py

to run the application.


You can also set python up as the default app when you click a .py ext
file. I dislike this, then again, on windows, that's exactly how I
have it setup (while not in windows). To change this to match the
windows behavior, you need to right click on the .py file, and pray
that you see an Open with option. If you don't, ask for help on a
Gnome mailing list :o). If you do see the Open with option, select it,
then select other, then using the folder on the command line, browse
to your python executable.  I don't know where it is. If you open up a
terminal and type:

which python

that *may* show you where it is.

-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.TierOneDesign.com/
Entertaining: http://www.ThisIsYourCruiseDirectorSpeaking.com

On 9/26/07, Armand Nell [EMAIL PROTECTED] 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@python.org
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python and Linux

2007-09-26 Thread Jason M Barnes
Hi,

Another way to execute your program is to open up your file with
gedit, and on the very first line type (sans quotes) #!/usr/bin/env
python by itself and save it.  Then, go to the terminal like Michael
said, and cd into the directory with your file.  Type chmod 0700
your-program.py at the prompt.  This allows you to execute your
program without invoking python first.  That way when you are cd'ed
into the directory that contains your program, you can type
./your-program.py at the prompt, and it should run.

If you're going to switch to linux, then you'll need to learn how to
make the most of your CLI.  I'd suggest googling for tutorials on the
linux command line.

Jason
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python and Linux

2007-09-26 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Well, chmod 0700 is usually not want you want:

a) 0700 gives only read/write/execute rights to the user. Technically
for historical reason permissions can be written as an octal number,
with the first digit being optional, encoding stuff like setuid/setgid
permissions. The last 3 digits code permissions for user, group and
other, one octal digit each. 4 is read, 2 is write and 1 is execute. We
aware that on directories execute permission allows you to access/search
the directory, while read allows you to read (==list) the directory.
So a typical permission for scripts would be 755 (read/exec for all,
write on top of that for the owner), or 775 (on distributions that give
each user their own primary group).

b) Specifying permissions as octal numbers is not really necessary
nowadays (and has not been necessary for over a decade, at least on
Linux): chmod a+x = add eXecute rights to All. chmod u=rwx,og=rx = set 755

Andreas

Jason M Barnes wrote:
 Hi,
 
 Another way to execute your program is to open up your file with
 gedit, and on the very first line type (sans quotes) #!/usr/bin/env
 python by itself and save it.  Then, go to the terminal like Michael
 said, and cd into the directory with your file.  Type chmod 0700
 your-program.py at the prompt.  This allows you to execute your
 program without invoking python first.  That way when you are cd'ed
 into the directory that contains your program, you can type
 ./your-program.py at the prompt, and it should run.
 
 If you're going to switch to linux, then you'll need to learn how to
 make the most of your CLI.  I'd suggest googling for tutorials on the
 linux command line.
 
 Jason
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+gnyHJdudm4KnO0RAgyXAJ9YGKU2OU9p2pnG4YyS15ZLwzj8vACfRAQD
H7jawyovWfkd9fEm36MfBBs=
=FquY
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python and Linux

2007-09-26 Thread bhaaluu
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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