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


Groups > comp.lang.python > #46273

Re: Problems with python and pyQT

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'method.': 0.07; 'converts': 0.09; 'function,': 0.09; 'try:': 0.09; 'width': 0.09; 'command.': 0.16; 'example)': 0.16; 'hex': 0.16; 'prefix,': 0.16; 'str.format()': 0.16; 'subject:Problems': 0.16; 'uppercase': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'command': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; '(for': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'characters': 0.30; 'question:': 0.31; 'another': 0.32; 'url:python': 0.33; 'subject:with': 0.35; 'display': 0.35; 'add': 0.35; 'thanks': 0.36; 'possible': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'field.': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'charset:windows-1252': 0.65; 'received:74.208': 0.68; 'received:74.208.4.194': 0.84; 'starters,': 0.84
Date Tue, 28 May 2013 06:59:27 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6
MIME-Version 1.0
To python-list@python.org
Subject Re: Problems with python and pyQT
References <8d8fd7fc-2509-457e-a4c9-0a1ac1f65c02@googlegroups.com> <mailman.2249.1369660253.3114.python-list@python.org> <646e6bae-b0fc-46fe-bf60-23ec9b4958a3@googlegroups.com>
In-Reply-To <646e6bae-b0fc-46fe-bf60-23ec9b4958a3@googlegroups.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:AQeB/L7Se6K8OjIUJRwnR940WnQSeES3Ds0JPqFh+XL 3emyl8zYktXbm7WQyLySBHaaPwW7FQKf6d2xC+EZb7COn5PkHR EVV1nlXV2//Psi7HiR0O9g8BhXHsvy2NxTiVxJEayFVmYbhOdT xO8AcQBg4mPf8bS3F1EqV5ZSOuDyuNx6qtmMRPHACcF1LNdi7A 2da8InRQz/MDhE7pAmwhvp5WiMhih3mja8mXNTOLwtroz28tns d0BwBoqcdkboiAVmUIo7sbcBAqVxyiowQ4MMXZ29yeZr+aRaAy 5aH6cXQTsvhfuh85k3ZNQu7N9PZEH4ZwH0D90TIaf+mDGw1kuF U3gr7ouSGuDylNj9ovXY=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2291.1369738782.3114.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369738782 news.xs4all.nl 15943 [2001:888:2000:d::a6]:48113
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46273

Show key headers only | View raw


On 05/28/2013 05:41 AM, silusilusilu@gmail.com wrote:
> Thanks for your reply: very useful!!
> I have another question: with hex command i display (for example)
>
> 0x1
>
> is it possible to display 0x01?

hex() is a function, not a command.  And it only takes the one 
parameter, the int to be converted.

For more generality, try the str.format() method.  The x type converts 
to hex without any prefix, and then you can add the width and fill field.

http://docs.python.org/2/library/stdtypes.html#str.format
http://docs.python.org/2/library/string.html#formatstrings
http://docs.python.org/2/library/string.html#format-specification-mini-language

For starters, try:

print "0x{0:0>2x}".format(12)
or
print "0x{0:0>2X}".format(12)
     if you like uppercase hex characters

-- 
DaveA

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


Thread

Problems with python and pyQT silusilusilu@gmail.com - 2013-05-27 02:26 -0700
  Re: Problems with python and pyQT Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-05-27 15:10 +0200
    Re: Problems with python and pyQT silusilusilu@gmail.com - 2013-05-28 02:41 -0700
      Re: Problems with python and pyQT Dave Angel <davea@davea.name> - 2013-05-28 06:59 -0400

csiph-web