Главное меню
Мы солидарны с Украиной. Узнайте здесь, как можно поддержать Украину.

Вопросы о Python-е

Автор Квас, декабря 23, 2011, 00:14

0 Пользователи и 1 гость просматривают эту тему.

Квас

Пишите письма! :)

RawonaM

Цитата: Квас от апреля 22, 2012, 12:31
Generally, I don't see any essential advantages of IDLE over the console, except, perhaps, the copypaste.
La console a copypaste aussi.

RawonaM

Цитата: Квас от апреля 22, 2012, 12:34
Ce matin j'ai découvert que j'avais désappris toutes les langues. Quel dommage ! :(
Quel dommage de voir que quelqu'un, qui peut écrire français, écrit cette autre langue :(

RawonaM


Demetrius

Цитата: Квас от апреля 22, 2012, 12:31
I'm afraid IDLE won't do tricks like this:
http://www.scipy.org/Cookbook/OptimizationDemo1
Generally, I don't see any essential advantages of IDLE over the console, except, perhaps, the copypaste. On the other hand, the console has the command history.
I'm not sure about what the screenshot demonstrates, but why do you think IDLE can't do this?  :donno:

RawonaM

Цитата: Demetrius от апреля 22, 2012, 12:40
Цитата: Квас от апреля 22, 2012, 12:31I'm afraid IDLE won't do tricks like this:
http://www.scipy.org/Cookbook/OptimizationDemo1
Generally, I don't see any essential advantages of IDLE over the console, except, perhaps, the copypaste. On the other hand, the console has the command history.
I'm not sure about what the screenshot demonstrates, but why do you think IDLE can't do this?  :donno:
Il peut, pas de problème. C'est la fonctionalité de python, pas d'une shell.

Квас

Offtop
Цитата: RawonaM от апреля 22, 2012, 12:37
Цитата: Квас от апреля 22, 2012, 12:34Ce matin j'ai découvert que j'avais désappris toutes les langues. Quel dommage ! :(
Quel dommage de voir que quelqu'un, qui peut écrire français, écrit cette autre langue :(

Pas aujourd'hui. :( Je ne peux pas me figurer combien de temps il me demandrait d'écrire en français ce que j'ai écrit en anglais. Alors je fais ce que je peux pour internationaliser LF.
Пишите письма! :)

Квас

Цитата: Demetrius от апреля 22, 2012, 12:40
Цитата: Квас от апреля 22, 2012, 12:31I'm afraid IDLE won't do tricks like this:
http://www.scipy.org/Cookbook/OptimizationDemo1
Generally, I don't see any essential advantages of IDLE over the console, except, perhaps, the copypaste. On the other hand, the console has the command history.
I'm not sure about what the screenshot demonstrates, but why do you think IDLE can't do this?  :donno:

If I manage to find instructions, I'll give it a try. I understand that all this Python stuff may be extremely powerful tools, but it all is so counter-intuitive. For example, my second attempt to install IPython succeeded, but qtconsole kept asking for packages and other stuff until it spat out a UnicodeDecodeError, and now I'm quite at a loss.  :wall:
Пишите письма! :)

RawonaM

Цитата: Квас от апреля 22, 2012, 12:50
If I manage to find instructions, I'll give it a try. I understand that all this Python stuff may be extremely powerful tools, but it all is so counter-intuitive. For example, my second attempt to install IPython succeeded, but qtconsole kept asking for packages and other stuff until it spat out a UnicodeDecodeError, and now I'm quite at a loss.  :wall:
Use Linux, feel libre :) apt-get — solves tout!

Квас

Now I see that the cause of the error is not the IPython itself, but a package called 'socket': socket.gethostbyname_ex('localhost') raises the UnicodeDecodeError. Perhaps it has something to do with non-ASCII characters in my user name. :(
Пишите письма! :)


Квас

Цитата: Квас от апреля 22, 2012, 23:45
Now I see that the cause of the error is not the IPython itself, but a package called 'socket': socket.gethostbyname_ex('localhost') raises the UnicodeDecodeError. Perhaps it has something to do with non-ASCII characters in my user name. :(

This proved a minor problem. The cyrillic letters in the localhost mattered. I found out that socket.gethostbyname_ex('localhost') didn't work on my computer altogether and commented out a couple of lines in ipython (I'm sure it was safe, but I'm too lazy to explain why).

Finally qt console appeared. Alas! At the very moment Windows notified me that python.exe had to stop right away. The sad truth is that I've never managed to use the qt console and apparently I have to wait for further releases. Such a pity! I won't see any embedded pictures. :'(

Yet I've managed to get ipython working. From the very beginning I had problems with encodings: the shell works in cp866, whereas it thinks it reads files in cp1251. Goddammit! I've learnt I can change the shell's encoding with chcp (this is the advantage of ipython: it can function as the shell), and I've replaced the contents of //cp1251.py with that of utf_8.py—now I can run utf-8 encoded scripts interactively!
Пишите письма! :)

Квас

Не подскажете, как запускают программу с параметрами?
Пишите письма! :)

RawonaM

Цитата: Квас от апреля 30, 2012, 11:55
Не подскажете, как запускают программу с параметрами?
Quels paramétres?

Квас

К примеру, "c:\blah-blah\sumatrapdf.exe" -reuse-intance <имя файла> <номер строки>
Пишите письма! :)



Квас

Мне бы из скрипта запустить программу и передать ей параметры.
Пишите письма! :)


Квас

Спасибо! Вроде заработало. Но думает слишком долго. :-\
Пишите письма! :)

Квас

Ещё люди, оказывается, через //subprocess.call делают. Я пытаюсь настроить прямой поиск из вима (ТеХ) в суматре (пдф) — должно «летать», но оба питоновские решения думают по нескольку секунд. Так не пойдёт.
Пишите письма! :)

Квас

Вопрос из вима, но больше, как понимаю, питоноспецифический. Главным образом, виндоспецифический.

Пытаюсь пробовать применять фильтрацию текста: текст из вима передаётся через stdin питону, который должен его обработать. Я пробовал
sys.stdin.read()
— работает для русских и английских букв. Если сделать
sys.stdin.buffer.read().decode('cp1251'),
аналогично. Если же
sys.stdin.buffer.read().decode('utf-8'),
то для русских не работает. Для греческих не работает ни в каком варианте.

При этом вимовский файл в utf-8. То есть когда он передаёт текст питону, тот почему-то уверен, что это cp1251. Есть ли способ его разубедить?

Вообще, может кто-нибудь знает форум, где есть про вим и питон вместе, и желательно русский?
Пишите письма! :)

Квас

Кстати, по поводу вызова внешних приложений. Если вызывать процесс через os.system, скрипт будет ждать его завершения. Можно воспользоваться subprocess.Popen. Я написал себе на пробу скриптик — консольный поисковик страницы в одном отсканированном словаре, тандем python—SumatraPDF работает замечательно.
Пишите письма! :)

RawonaM


Квас

Цитата: RawonaM от мая  6, 2012, 15:13
Peux-tu montrer le code entier?

C'est python 3.2.


import sys
#inp=sys.stdin.buffer.read().decode('cp1251')
inp=sys.stdin.read()
outp=inp + '\nαβγδ.'
sys.stdout.buffer.write(outp.encode())
# the following assumes the output should be in cp1251
# and doesn't accept Greek letters
#sys.stdout.write(outp)



En effet, je comprends que mes questions sont peut-être trop spécifique, mais à présent je ne connais pas de bons forums informatiques. (En effet, je crois que LF n'est point mal à cet égard.)
Пишите письма! :)

Быстрый ответ

Обратите внимание: данное сообщение не будет отображаться, пока модератор не одобрит его.

Имя:
Имейл:
Проверка:
Оставьте это поле пустым:
Наберите символы, которые изображены на картинке
Прослушать / Запросить другое изображение

Наберите символы, которые изображены на картинке:

√36:
ALT+S — отправить
ALT+P — предварительный просмотр