なりなり日記

Appleと折りたたみ自転車(BROMPTON / Tern Vektron S10 / BESV PSF1)の情報を中心に発信中!

【Pythonista】iOSでPythonプログラミングと実行が出来る!


スポンサーリンク

こんにちは、なりなりです(^ ^)

新世代のBASIC⁉︎ プログラミング言語Python始めました! - なりなり日記

Pythonを始めてみて、iPhoneでも勉強できたら良いなと思ってiTunesで検索してみると、意外にも幾つかのアプリが見つかりましたが、さて、どれがどの程度出来るものか分からないなと思って調べてみると


iOS上で動作する革命的ものづくり環境「Pythonista 3」の魅力をとくと語る

こちらで、そのうちのひとつのPythonistaについて熱く書かれていて、確かにこれは凄そうだと思って、早速ダウンロードしました。


Pythonista 3

Pythonista 3

  • omz:software
  • 仕事効率化
  • ¥1,220


最初に起動するとこんなメッセージが。

# Welcome to Pythonista

Thank you for downloading Pythonista! You now have everything you need to build and run Python scripts directly on your iPhone or iPad.

To give you an idea of what you can do with the app, various sample scripts are included in the *Examples* folder. Feel free to use them as starting points for your own experiments. To share your creations, get help with coding problems, or just to meet fellow Pythonistas, please visit our [community forum](http://forum.omz-software.com).


# Getting Started

If you're new to Pythonista, here are some tips to help you get up and running:

To create a new script, first tap `≡` to reveal the library, then `+` (at the bottom). You can also use left and right swipe gestures to switch between the file browser, editor, and console panels.

The settings ("gear" button in the file browser) contain useful options to customize the editor font, color theme, indentation type (tabs/spaces), and much more.

Swipe left to show the **console** panel. This is where text output appears, and you can use the prompt at the bottom to evaluate individual lines of Python code directly.

You'll also find the included **documentation** in the console panel; simply tap the `(?)` button to open it in a separate tab. Reference documentation is also available while you're editing code -- simply select a word (e.g. a function name), and choose *Help…* from the menu.

For easier navigation in long scripts, tap the file name at the top to show a list of classes and functions. This is also where you can rename the current file.

If you enjoy coding in Pythonista, please consider leaving a rating or review in the App Store. Thank you!

💚

# Tips

Tap and hold the run (▷) button for some additional options, e.g. to pass arguments (`sys.argv`) to your scripts, or to run the integrated PEP8 style checker.

Tap the *Edit* button in the "wrench" menu to add your own script shortcuts there. You can use this to launch your favorite scripts more quickly, or to extend the editor's functionality with the `editor` module.

A lot of keys on Pythonista's extra keyboard row have multiple mappings. For example, you can tap and hold the tab key to get an unindent option.

Tap with two fingers in the editor to select an entire line of code.

You can run Pythonista scripts directly within other apps that support the standard iOS share sheet. To get started, open the share sheet in a supported app (e.g. Safari, Notes, Maps...) and select "More..." to add the Pythonista action extension. You can use the `appex` module to access data that was passed to the share sheet (e.g. the current URL in Safari, location data in Maps, etc.).

If you use Pythonista with an external (Bluetooth) keyboard, you can show a list of available shortcuts by pressing and holding the `Cmd` key.

Swipe left on a file in the script library to open it in a new tab or move it to the trash.


# What's New in 3.1

For full release notes, and to see what was added in previous releases, please refer to the "What's New in Pythonista" section in the documentation.

The console contains a new object inspector panel that allows you to view a list of all global variables and their attributes/members. Tap the `(i)` button to show or hide it.

The new Pythonista Today widget allows you to run a script in Notification Center (or on the home/lock screen). You can find more information in the `appex` module documentation, and various examples of widget scripts are available in the updated *Examples* folder.

Python 2 mode now uses Python 2.7.12 instead of 2.7.5.

When using the share sheet extension with a file input (e.g. sharing a Mail attachment), an additional "Import File" option is shown for non-Python files.

The `speech` module contains new functions for speech recognition, in addition to speech synthesis (iOS 10 only).

The `sound` module contains a new `Recorder` class for recording audio files from the microphone. `sound.play_effect` and `sound.Player` have also been improved to support stereo panning.


# Feedback

I hope you enjoy coding in Pythonista. If you have any feedback, please send an email to , or visit the [community forum][forum] to share code and get help with your programming questions. You can also find me on Twitter:[@olemoritz][twitter].

    • -

[forum]: https://forum.omz-software.com
[twitter]: http://twitter.com/olemoritz


Google翻訳したのがこちら。

#Pythonistaへようこそ

Pythonistaをダウンロードしていただきありがとうございます!あなたのiPhoneやiPadで直接Pythonスクリプトをビルドして実行するのに必要なものはすべてあります。

あなたがアプリで何ができるかを知るために、様々なサンプルスクリプトが* Examples *フォルダに含まれています。自分の実験の出発点として自由に使用してください。あなたの創造物を共有したり、コーディングの問題を助けたり、仲間のPythonistasに会うためには、[コミュニティフォーラム](http://forum.omz-software.com)をご覧ください。


# 入門

Pythonistaを初めてお使いの方は、立ち上げと実行に役立つヒントをいくつかご紹介します:

新しいスクリプトを作成するには、最初に `≡`をタップしてライブラリを表示し、次に` + `(下部に)をタップします。左右のスワイプジェスチャーを使用して、ファイルブラウザー、エディター、およびコンソールパネルを切り替えることもできます。

設定(ファイルブラウザの「歯車」ボタン)には、エディタのフォント、色のテーマ、インデントタイプ(タブ/スペース)などをカスタマイズするための便利なオプションがあります。

左にスワイプして** console **パネルを表示します。これはテキスト出力が現れる場所で、下のプロンプトを使ってPythonコードの個々の行を直接評価することができます。

コンソールパネルに付属の**ドキュメンテーション**もあります。 `(?)`ボタンをタップするだけで別のタブで開くことができます。コードを編集しているときに参照ドキュメントも利用できます。単語(例:関数名)を選択し、メニューから*ヘルプ... *を選択するだけです。

長いスクリプトで簡単にナビゲートするには、上部のファイル名をタップして、クラスと関数のリストを表示します。現在のファイルの名前を変更することもできます。

Pythonistaでのコーディングを楽しんでいる場合は、評価や評価をApp Storeに残すことを検討してください。ありがとうございました!

💚

#ヒント

実行(▷)ボタンをタップして押し続けると、いくつかの追加オプションが表示されます。スクリプトに引数( `sys.argv`)を渡したり、統合されたPEP8形式のチェッカーを実行することができます。

「レンチ」メニューの*編集*ボタンをタップすると、そこに独自のスクリプトショートカットが追加されます。これを使ってお気に入りのスクリプトをより速く起動させたり、エディタの機能を `editor`モジュールで拡張することができます。

Pythonistaの余分なキーボード行の多くのキーには、複数のマッピングがあります。たとえば、タブキーをタップ&ホールドすると、インデントされていないオプションが表示されます。

エディタで2本の指でタップすると、コード全体を選択できます。

Pythonistaスクリプトは、標準のiOS共有シートをサポートする他のアプリで直接実行できます。開始するには、サポートされているアプリ(Safari、Notes、Mapsなど)で共有シートを開き、[その他]を選択してPythonistaアクション拡張を追加します。 `appex`モジュールを使って、共有シートに渡されたデータ(例えば、Safariの現在のURL、マップ内の位置データなど)にアクセスすることができます。

外部(Bluetooth)キーボードでPythonistaを使用している場合、 `Cmd`キーを押し続けて使用可能なショートカットのリストを表示することができます。

スクリプトライブラリのファイルを左にスワイプして新しいタブで開くか、ゴミ箱に移動します。


#3.1の新機能

完全なリリースノート、および以前のリリースで追加された内容を確認するには、ドキュメントの「Pythonistaの新機能」のセクションを参照してください。

コンソールには、すべてのグローバル変数とその属性/メンバーのリストを表示できる新しいオブジェクトインスペクタパネルが含まれています。 `(i)`ボタンをタップすると表示/非表示になります。

新しいPythonista Todayウィジェットでは、通知センター(またはホーム/ロック画面)でスクリプトを実行できます。 `appex`モジュールのドキュメントに詳細があります。更新された* Examples *フォルダにはウィジェットスクリプトのさまざまな例があります。

Python 2モードでは2.7.5の代わりにPython 2.7.12を使用するようになりました。

ファイルの入力時に共有シート拡張子を使用する場合(Mail添付ファイルを共有するなど)、Python以外のファイルの場合は、[ファイルのインポート]オプションが表示されます。

`speech`モジュールには、音声合成(iOS 10のみ)に加えて、音声認識のための新しい機能が含まれています。

`sound`モジュールには、マイクからのオーディオファイルを記録するための新しい` Recorder`クラスが含まれています。 `sound.play_effect`と` sound.Player`も改良され、ステレオパンニングをサポートしています。


#フィードバック

私はあなたがPythonistaでコーディングを楽しむことを願っています。ご意見がありましたら、まで電子メールを送信するか、[community forum] [forum]を訪問してコードを共有し、プログラミングに関する質問にお答えください。あなたはTwitterでも私を見つけることができます:[@ olemoritz] [twitter]。


Overview — Python 3.6.1 documentation

Pythonistaに関する公式ドキュメントはこちら。

今時は、英語が厳しければGoogle翻訳で何とかなりますが、不安であれば、まずはPCでPythonを覚えた方が良いです。

Pythonista Modules — Python 3.6.1 documentation

使えるモジュールもとても豊富!


iPhoneのプログラム作成は、iPhone 3Gを手に入れた時に夢見ましたが、Objective-Cなんていう、はっきり言ってローカルな言語を覚えなくてはいけないし、iPhoneで動かすにはDeveloper Programに年1万円ほども払わなくてはいけないしで断念しました。

それが、Pythonという汎用言語を使って、1,200円のアプリでiPhone上で開発出来てしまうなんて、夢のよう!!

あの閉鎖的なAppleが、よくこのアプリを許可したものだと思います。


Python自体は

プログラミング言語 Python 総合情報サイト - python.jp

日本語公式サイトが有るので、個人のブログ情報を合わせれば習得可能です。

勿論、他の言語でプログラミングをした事が無く、全く始めてのプログラミングであれば、何がしかの本を読んだ方が良いですけど。日本での普及はまだまだなのかと思いきや、「Python はじめて」や「Python 入門」でAmazonや楽天で検索すると、たくさんの本が見つかりますよ!

Pythonが国内でこんなに盛り上がってるなんて知りませんでした(^◇^;)