�n�߂悤

Python�̒��� Python�̗p�r Python�Ɨގ��c�[��

Python �v���O�����̎��s

�p�X�̐ݒ�

���̃A�v���P�[�V�����ł��ꏏ�����C�R�}���h���C���X�g�[�����Ă����Ă� �p�X���ʂ��Ă��Ȃ��Ǝg���Ȃ��D
% which python
no python in /usr/bin /bin /usr/openwin/bin
% set path = (/pub/solaris/python/bin $path)
% which python
/pub/solaris/python/bin/python
% python
[GCC 2.8.1] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> 

�Θb�I��(�C���^���N�e�B�u)

% python
>>> print 'Hello world!'
Hello world!
>>> 35 + 65
100
>>> x = 35
>>> y = 65
>>> print x + y
100
>>> (Ctrl+D) or (Ctrl+Z) �I��

���W���[���t�@�C���̎��s

% cat > spam.py
import sys
print sys.argv
(Ctrl+D)
�܂��́C�e�L�X�g�G�f�B�^��vi�Ȃǂō쐬���Ă��悢�D
% python spam.py -i eggs -o bacon
['spam.py', '-i', 'eggs', '-o', 'bacon']

�X�N���v�g�̍쐬�Ǝ��s

% cat > brian
#!/pub/solaris/python/bin/python
print 'The Bright Side of Life ...'
(Ctrl+D)
�܂��́C�e�L�X�g�G�f�B�^��vi�Ȃǂō쐬���Ă��悢�D
% chmod +x brian
% brian
The Bright Side of Life ...
Python �� �s�̒��� # �������ƁC����������R�����g�Ƃ݂Ȃ��̂ŁC python brian �ł������悤�Ɏ��s�ł���D
�܂��C�ŏ��̍s�� #!/usr/bin/env python �ł��悢�D

���W���[���t�@�C���ɂ‚���

���W���[���� import �ł���D
% cat > myfile.py
title = "The Meaning of Life"
(Ctrl+D)
�܂��́C�e�L�X�g�G�f�B�^��vi�Ȃǂō쐬���Ă��悢�D
% python
>>> import myfile
>>> print myfile.title
The Meaning of Life
���邢�́C
% python
>>> from myfile import title
>>> print title
The Meaning of Life

���O���

dir �֐�

Python �̊‹��ݒ�

C�V�F���� path �ϐ���ݒ�D(�܂��� �‹��ϐ� PATH ��ݒ�)
~/.cshrc �� path ��ݒ肵�Ă���Ƃ��낪����̂ŁC/pub/solaris/python/bin �� �t�������Ă������D
�V�X�e���ɂ���Ă͋��ȏ��̂悤�� setenv ���K�v��������Ȃ��D

GUI�e�X�g

% python
>>> from Tkinter import *
>>> w = Button(text='Hello', command='exit')
>>> w.pack()
>>> w.mainloop()

���K���