Pythonのお勉強 Part45at TECH
Pythonのお勉強 Part45 - 暇つぶし2ch956:954
12/01/28 19:41:22.81
スマン、よく見てみるとキーワードは確かにダメだね。

957:952
12/01/29 15:08:11.81
>>953
それ俺だけじゃなかったんだな
俺は自分でCHMをデコンパイルして直してたわ。文字コードもCP932って指定されてて会社の環境だと文字化けするから
Shift_jisにしてた。
それでエディタにCHMを登録してキーワードを選択してF1キーで検索するのがマジ便利。

958:デフォルトの名無しさん
12/01/29 18:16:32.00
おいちょっと待て
本当に感謝すべきは>>950じゃなくて>>947だろ?


959:デフォルトの名無しさん
12/01/30 23:34:05.11
gdb 使用中に python2.7 使えることが分かって便利で助かるんだけど、
なんで使えるの?いつ、誰が設定しているの?

$PYTHON/Misc/gdbinit にも書いてなかったし、/etc/gdbinitにも書かれていない。
どうなってるのでしょうか?教えて~教えて~教えて!

(gdb) python
>import sys
>print(sys.version)
>sys.path
>end
2.7.2+ (default, Oct 4 2011, 20:29:37)

(gdb) python print("{:x}".format(0x848a & 0xaaaa))
808a

(gdb) python
>import sys
>print(sys.path)
>end
['/usr/share/gdb/python', '/usr/local/lib/python2.7/dist-packages/mercurial-1.9.
1-py2.7-linux-i686.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/
...
s/ubuntuone-storage-protocol']

960:デフォルトの名無しさん
12/01/30 23:42:20.64
下手糞な教えて君だったかな。
猛省。

961:デフォルトの名無しさん
12/01/30 23:43:34.92
(gdb) help python

962:デフォルトの名無しさん
12/01/30 23:54:00.75
いえ、それくらいは試してましてですね。

(gdb) help python
Evaluate a Python command.

The command can be given as an argument, for instance:

python print 23

If no argument is given, the following lines are read and used
as the Python commands. Type a line containing "end" to indicate
the end of the command.

いつ、誰が設定しているのか分からなくてちょっと不気味なわけです。
更にいうと、本当はpython3.2を使いたいので、
どうやって設定しているか分かればpython2.7 -> python3.2と
変更できて嬉しいなーと思っているんです。

which python
/usr/bin/python

となっている /usr/bin 以下のpythonを python3.2と差し替えてみても
>import sys
>print(sys.version)
>end
2.7.2+ (default, Oct 4 2011, 20:29:37)

となって結局python2.7.2を使うことになってしまうので、
gdbの設定で何かやってるんだろうなーぐらいは思いますが、
どうやっているのか分からなくて気味が悪いという状態です。

963:デフォルトの名無しさん
12/01/31 00:02:02.51
>>962
組み込み(configure --with-python)
バージョンを変えられるかどうかは知らん

964:デフォルトの名無しさん
12/01/31 00:29:45.17
私の環境のpython, python2.7はどれもこれも20:03:08に作成されたようですが、
gdbのpythonは 2.7.2+ (default, Oct 4 2011, 20:29:37) となっているので、
私の環境のpythonを使っているのではなく、
別の環境でcompileされたもののようです。

gdbにbinary組み込みで入っているのかなーと思い始めました。

$ python2.7
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
'2.7.2+ (default, Oct 4 2011, 20:03:08) \n[GCC 4.6.1]'

gdb7.4をsourceから入れて --with-python を試してみます。

965:デフォルトの名無しさん
12/01/31 01:01:58.66
試してみましたが、余計分からなくなりました。

timestampが2.7.2+ (default, Oct 4 2011, 20:29:37) の理由が分からん、
全く分からん、さっぱり分からん。
地物のgdbもubuntuにいつの間にか入っていたgdbの持つ
pythonのsys.versionと一致してしまいました・・・

configureのoption --with-python 有りなしで変えて
configure && makeしてみましたが、
--with-pythonを設定しない方でもpythonを使えてしまいました。

gdbにpythonを組み込んでいるのかな?とは思いますが
なんか、よく分からないです。

URLリンク(sourceware.org)
23.2 Scripting gdb using Python

You can script gdb using the Python programming language.
This feature is available only if gdb was configured using --with-python.

Python scripts used by gdb should be installed in data-directory/python,
where data-directory is the data directory as determined at gdb startup
(see Data Files). This directory, known as the python directory, is automatically
added to the Python Search Path in order to allow the Python interpreter to
locate all scripts installed at this location.

Additionally, gdb commands and convenience functions which are written in
Python and are located in the data-directory/python/gdb/command or
data-directory/python/gdb/function directories are automatically imported
when gdb starts.

966:デフォルトの名無しさん
12/01/31 01:02:57.75
   *``・*。        。*・``*     *``・*。       。*・``*
もう|   `*。 `  。 *`    |☆  |    ` *。  `。*`    |
  ,。∩ ∧,,∧ *` ☆   ∧,,,/∩  ☆∩ ∧,,,∧   ☆ `* ∧,,/∩。,
  + ( ´・ω・)*。+゚ + (・ω・` )*。+゚+。*( ´・ω・) + ゚+。*(・ω・` ) +
  `*。ヽ   つ*゚*☆・+。⊂   ノ。+ ☆ +。ヽ   つ。+・☆*゚*⊂   ノ 。*` どうにでも
   `・+。*・`゚⊃+∩∧,,∧・+。*+・` ゚ `・+*。+・∧,,∧∩+ ⊂゚`・*。+・`
   ☆ ∪~ 。*゚ . (´・ω・`)∪ ☆    ∪(´・ω・`) . ゚*。. .~∪ ☆
   `・+。*・ ゚ ☆ `・+。  つ─*゚・ ☆・゚*─⊂  。+・`☆ ゚ ・*。+・`
           ⊂  `・+・*+・`゚  ゚`・+*・+・ `  ⊃
             ~∪    なーれ♪  ∪~

967:デフォルトの名無しさん
12/01/31 05:39:46.15
Fixing the Python subprocess interface (github.com)
URLリンク(github.com)

968:デフォルトの名無しさん
12/01/31 20:29:39.06
Python3.2の動作方法の全体像を掴みたいのですが、
以下の資料を参考にすればよいということで良いでしょうか?

Design of CPython’s Compiler
URLリンク(docs.python.org)

具体的には、どこの関数でa.pyを読み込んで、
どこの関数でa.pyの一行一行を読み込み、解析して、
どこの関数で実行するのかということを知りたいです。

C言語の段階でのCPythonの動作方法を把握したいです。
と言った方が良いでしょうか。

もし、日本語で解説している資料があるのであれば、そちらも知りたいです。

969:デフォルトの名無しさん
12/01/31 20:46:03.15
投稿した後に、
5. Embedding Python in Another Application
python-3.2.2-docs-html/extending/embedding.html#very-high-level-embedding
この存在を思い出しまして、

#include <Python.h>

int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print('Today is', ctime(time()))\n");
Py_Finalize();
return 0;
}

ここに思いっきり、PyRun_SimpleString()ってのが出ていましたので、

Python/pythonrun.c を読んでいって
PyParser_ParseStringFlagsFilenameEx()
PyParser_ASTFromString()

やら、Python/ast.cの
PyAST_FromNode()

やらをふむふむすればいいのかな?と思っていますが、当たっていますか?

970:デフォルトの名無しさん
12/02/02 19:03:15.81
ironpythonはスレ違い?

971:デフォルトの名無しさん
12/02/02 19:06:23.16
その化石の名前を久しぶりに聞いた

972:デフォルトの名無しさん
12/02/02 19:09:02.57
いいろん

973:デフォルトの名無しさん
12/02/02 20:12:19.31
>>970
Microsoft IronPython 1.0
スレリンク(tech板)

974:デフォルトの名無しさん
12/02/02 20:20:20.47
>>973
人いないんだもん

975:デフォルトの名無しさん
12/02/03 15:01:50.72
鉄器時代のPython

976:デフォルトの名無しさん
12/02/03 15:28:25.21
というかMSはやる気あんのか?
Visual Pythonを単体で出せよ


最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch