Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79806

Re: different behavior from idle/pycharm and shell

Newsgroups comp.lang.python
Date 2014-10-27 15:49 -0700
References <4417873a-f05f-43b9-9803-1226b1b4ddda@googlegroups.com>
Message-ID <fa3ed4f8-95cc-41b9-af44-675b261312a4@googlegroups.com> (permalink)
Subject Re: different behavior from idle/pycharm and shell
From sohcahtoa82@gmail.com

Show all headers | View raw


On Monday, October 27, 2014 3:38:31 PM UTC-7, kiuh...@yahoo.it wrote:
> Consider this code:
> 
> ---
> from ctypes import *
> 
> user32 = windll.user32
> user32.MessageBoxA(0, 'ok', 'ok', 0)
> ---
> 
> If I run it in idle or from pycharm, the messagebox shows 'o' instead of 'ok', but if I run it from shell, it shows 'ok' like it should.
> The same happens with msvcrt.printf().
> Why?

If I had to take a guess, in the shell, it is encoding the string characters as single bytes as expected, but in Idle or PyCharm, it is encoding them as WCHARs, which are two-bytes wide.

Two things to try:

1. Change the call to MessageBoxW and see if it works in Idle/PyCharm.  Note that this will probably break the call from the shell.
2. Try a string longer than two characters and see what you get.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

different behavior from idle/pycharm and shell kiuhnm03@yahoo.it - 2014-10-27 15:38 -0700
  Re: different behavior from idle/pycharm and shell sohcahtoa82@gmail.com - 2014-10-27 15:49 -0700
  Re: different behavior from idle/pycharm and shell MRAB <python@mrabarnett.plus.com> - 2014-10-27 22:55 +0000
    Re: different behavior from idle/pycharm and shell kiuhnm03@yahoo.it - 2014-10-27 16:14 -0700

csiph-web