Re: HEX to ASCII

2013-10-08 Thread Mark Lawrence
On 08/10/2013 09:13, markot...@gmail.com wrote: esmaspäev, 7. oktoober 2013 17:16.29 UTC+3 kirjutas Mark Lawrence: On 07/10/2013 14:54, markot...@gmail.com wrote: I forgot to tell. The teisendaja module that i have imported, is a number converter that allow to convert numbers from one base to

Re: HEX to ASCII

2013-10-08 Thread markotaht
esmaspäev, 7. oktoober 2013 17:16.29 UTC+3 kirjutas Mark Lawrence: > On 07/10/2013 14:54, markot...@gmail.com wrote: > > > I forgot to tell. The teisendaja module that i have imported, is a number > > converter that allow to convert numbers from one base to another. i mostly > > use it for HEX t

Re: HEX to ASCII

2013-10-08 Thread markotaht
esmaspäev, 7. oktoober 2013 18:52.21 UTC+3 kirjutas Piet van Oostrum: > markot...@gmail.com writes: > > > > > This is the code i came up with: > > > from teisendaja import * > > > from operator import * > > > import binascii > > > > > > teisendus = teisendus() > > > kood = input("Kood: ")

Re: HEX to ASCII

2013-10-07 Thread Piet van Oostrum
markot...@gmail.com writes: > This is the code i came up with: > from teisendaja import * > from operator import * > import binascii > > teisendus = teisendus() > kood = input("Kood: ") > key = input("Võti: ") > > chunksize = 2 > vastus = [teisendus.teisendus3(16,2,kood[i: (i + chunksize)]) for i

Re: HEX to ASCII

2013-10-07 Thread Mark Lawrence
On 07/10/2013 14:54, markot...@gmail.com wrote: I forgot to tell. The teisendaja module that i have imported, is a number converter that allow to convert numbers from one base to another. i mostly use it for HEX to BIN and vice versa, but it supports other bases too. That's nice to know, but

Re: HEX to ASCII

2013-10-07 Thread markotaht
I forgot to tell. The teisendaja module that i have imported, is a number converter that allow to convert numbers from one base to another. i mostly use it for HEX to BIN and vice versa, but it supports other bases too. -- https://mail.python.org/mailman/listinfo/python-list

Re: HEX to ASCII

2013-10-07 Thread markotaht
esmaspäev, 7. oktoober 2013 4:27.44 UTC+3 kirjutas Piet van Oostrum: > markot...@gmail.com writes: > > > > > problem is : Traceback (most recent call last): > > > File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in > > > > > print("Key-" + str(võti) + ": " + str("".j

Re: HEX to ASCII

2013-10-06 Thread Piet van Oostrum
markot...@gmail.com writes: > problem is : Traceback (most recent call last): > File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in > > print("Key-" + str(võti) + ": " + str("".join(tulemus2))) > TypeError: sequence item 0: expected str instance, bytes found > > If i

Re: HEX to ASCII

2013-10-06 Thread MRAB
On 06/10/2013 20:07, markot...@gmail.com wrote: problem is : Traceback (most recent call last): File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in print("Key-" + str(võti) + ": " + str("".join(tulemus2))) TypeError: sequence item 0: expected str instance, bytes found

Re: HEX to ASCII

2013-10-06 Thread Peter Otten
markot...@gmail.com wrote: > problem is : Traceback (most recent call last): > File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in > > print("Key-" + str(võti) + ": " + str("".join(tulemus2))) > TypeError: sequence item 0: expected str instance, bytes found > > If i tak

Re: hex dump w/ or w/out utf-8 chars

2013-07-24 Thread wxjmfauth
I do not find the thread, where a Python core dev spoke about French, so I'm putting here. This stupid Flexible String Representation splits Unicode in chunks and one of these chunks is latin-1 (iso-8859-1). If we consider that latin-1 is unusable for 17 (seventeen) European languages based on th

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Chris Angelico
On Mon, Jul 15, 2013 at 2:18 PM, Terry Reedy wrote: > On 7/14/2013 10:56 AM, Chris Angelico wrote: > As issue about finding stings in strings was opened last September and, as > reported on this list, fixes were applied about last March. As I remember, > some but not all of the optimizations were

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Terry Reedy
On 7/14/2013 10:56 AM, Chris Angelico wrote: On Sun, Jul 14, 2013 at 11:44 PM, wrote: timeit.repeat("a = 'hundred'; 'x' in a") [0.11785943134991479, 0.09850454944486256, 0.09761604599423179] timeit.repeat("a = 'hundreœ'; 'x' in a") [0.23955250303158593, 0.2195812612416752, 0.2213389699740

Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Chris Angelico
On Sun, Jul 14, 2013 at 11:44 PM, wrote: > Le dimanche 14 juillet 2013 12:44:12 UTC+2, Steven D'Aprano a écrit : >> On Sun, 14 Jul 2013 01:20:33 -0700, wxjmfauth wrote: >> >> >> >> > For a very simple reason, the latin-1 block: considered and accepted >> >> > today as beeing a Unicode design mist

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread wxjmfauth
Le dimanche 14 juillet 2013 12:44:12 UTC+2, Steven D'Aprano a écrit : > On Sun, 14 Jul 2013 01:20:33 -0700, wxjmfauth wrote: > > > > > For a very simple reason, the latin-1 block: considered and accepted > > > today as beeing a Unicode design mistake. > > > > Latin-1 (also known as ISO-8859-

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread Steven D'Aprano
On Sun, 14 Jul 2013 01:20:33 -0700, wxjmfauth wrote: > For a very simple reason, the latin-1 block: considered and accepted > today as beeing a Unicode design mistake. Latin-1 (also known as ISO-8859-1) was based on DEC's "Multinational Character Set", which goes back to 1983. ISO-8859-1 was fir

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread wxjmfauth
Le samedi 13 juillet 2013 21:02:24 UTC+2, Dave Angel a écrit : > On 07/13/2013 10:37 AM, wxjmfa...@gmail.com wrote: > > > > > > Fortunately for us, Python (in version 3.3 and later) and Pike did it > > right. Some day the others may decide to do similarly. > > > --- Possible but

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Neil Hodgson
wxjmfa...@gmail.com: The FSR is naive and badly working. I can not force people to understand the coding of the characters [*]. You could at least *try*. If there really was a problem with the FSR and you truly understood this problem then surely you would be able to communicate the pr

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Dave Angel
On 07/13/2013 10:37 AM, wxjmfa...@gmail.com wrote: The FSR is naive and badly working. I can not force people to understand the coding of the characters [*]. That would be very hard, since you certainly do not. I'm the first to recognize that Python and/or Pike are free to do what they wis

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread wxjmfauth
Le samedi 13 juillet 2013 11:49:10 UTC+2, Steven D'Aprano a écrit : > On Sat, 13 Jul 2013 00:56:52 -0700, wxjmfauth wrote: > > > > > You are confusing the knowledge of a coding scheme and the intrisinc > > > information a "coding scheme" *may* have, in a mandatory way, to work > > > properly.

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Chris Angelico
On Sat, Jul 13, 2013 at 7:49 PM, Steven D'Aprano wrote: > Ironically, Python has done the same thing for integers for many versions > too. They just didn't call it "Flexible Integer Representation", but > that's what it is. For integers smaller than 2**31, they are stored as C > longs (plus object

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Steven D'Aprano
On Sat, 13 Jul 2013 00:56:52 -0700, wxjmfauth wrote: > You are confusing the knowledge of a coding scheme and the intrisinc > information a "coding scheme" *may* have, in a mandatory way, to work > properly. These are conceptualy two different things. *May* have, in a *mandatory* way? JMF, I kno

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Chris Angelico
On Sat, Jul 13, 2013 at 5:56 PM, wrote: > Try to write an editor, a text widget, with with a coding > scheme like the Flexible String Represenation. You will > quickly notice, it is impossible (understand correctly). > (You do not need a computer, just a sheet of paper and a pencil) > Hint: what

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Steven D'Aprano
On Sat, 13 Jul 2013 00:56:52 -0700, wxjmfauth wrote: > I am convinced you are not conceptually understanding utf-8 very well. I > wrote many times, "utf-8 does not produce bytes, but Unicode Encoding > Units". Just because you write it many times, doesn't make it correct. You are simply wrong. U

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread Lele Gaifax
wxjmfa...@gmail.com writes: > Try to write an editor, a text widget, with with a coding > scheme like the Flexible String Represenation. You will > quickly notice, it is impossible (understand correctly). > (You do not need a computer, just a sheet of paper and a pencil) > Hint: what is the charac

Re: hex dump w/ or w/out utf-8 chars

2013-07-13 Thread wxjmfauth
Le vendredi 12 juillet 2013 04:16:21 UTC+2, Chris Angelico a écrit : > On Fri, Jul 12, 2013 at 4:42 AM, wrote: > > > BTW, since > > > when a serious coding scheme need an extermal marker? > > > > > > > All of them. > > > > Content-type: text/plain; charset=UTF-8 > > > > ChrisA --

Re: hex dump w/ or w/out utf-8 chars

2013-07-12 Thread Steven D'Aprano
On Fri, 12 Jul 2013 23:01:47 +0100, Joshua Landau wrote: > Isn't a superscript "c" the symbol for radians? Only in the sense that a superscript "o" is the symbol for degrees. Semantically, both degree-sign and radian-sign are different "things" than merely an o or c in superscript. Neverthele

Re: hex dump w/ or w/out utf-8 chars

2013-07-12 Thread Tim Roberts
Joshua Landau wrote: > >Isn't a superscript "c" the symbol for radians? That's very rarely used. More common is "rad". The problem with a superscript "c" is that it looks too much like a degree symbol. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mai

Re: hex dump w/ or w/out utf-8 chars

2013-07-12 Thread Joshua Landau
On 9 July 2013 10:34, wrote: > There is no symbole for radian because mathematically > radian is a pure number, a unitless number. You can > hower sepecify a = ... in radian (rad). > Isn't a superscript "c" the symbol for radians? -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-12 Thread wxjmfauth
Le vendredi 12 juillet 2013 05:18:44 UTC+2, Steven D'Aprano a écrit : > On Thu, 11 Jul 2013 11:42:26 -0700, wxjmfauth wrote: > > > Now all your strings will be just as heavy, every single variable name > > and attribute name will use four times as much memory. Happy now? > >>> 㑖 = 9

Re: hex dump w/ or w/out utf-8 chars

2013-07-12 Thread Chris Angelico
On Fri, Jul 12, 2013 at 4:42 AM, wrote: > BTW, since > when a serious coding scheme need an extermal marker? > All of them. Content-type: text/plain; charset=UTF-8 ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-11 Thread Steven D'Aprano
On Thu, 11 Jul 2013 11:42:26 -0700, wxjmfauth wrote: > And what to say about this "ucs4" char/string '\U0001d11e' which is > weighting 18 bytes more than an "a". > sys.getsizeof('\U0001d11e') > 44 > > A total absurdity. You should stick to Python 3.1 and 3.2 then: py> print(sys.version)

Re: hex dump w/ or w/out utf-8 chars

2013-07-11 Thread wxjmfauth
Le jeudi 11 juillet 2013 15:32:00 UTC+2, Chris Angelico a écrit : > On Thu, Jul 11, 2013 at 11:18 PM, wrote: > > > Just to stick with this funny character ẞ, a ucs-2 char > > > in the Flexible String Representation nomenclature. > > > > > > It seems to me that, when one needs more than ten by

Re: hex dump w/ or w/out utf-8 chars

2013-07-11 Thread wxjmfauth
Le jeudi 11 juillet 2013 20:42:26 UTC+2, wxjm...@gmail.com a écrit : > Le jeudi 11 juillet 2013 15:32:00 UTC+2, Chris Angelico a écrit : > > > On Thu, Jul 11, 2013 at 11:18 PM, wrote: > > > > > > > Just to stick with this funny character ẞ, a ucs-2 char > > > > > > > in the Flexible String

Re: hex dump w/ or w/out utf-8 chars

2013-07-11 Thread Chris Angelico
On Thu, Jul 11, 2013 at 11:18 PM, wrote: > Just to stick with this funny character ẞ, a ucs-2 char > in the Flexible String Representation nomenclature. > > It seems to me that, when one needs more than ten bytes > to encode it, > sys.getsizeof('a') > 26 sys.getsizeof('ẞ') > 40 > > this

Re: hex dump w/ or w/out utf-8 chars

2013-07-11 Thread wxjmfauth
Le lundi 8 juillet 2013 19:52:17 UTC+2, Chris Angelico a écrit : > On Tue, Jul 9, 2013 at 3:31 AM, wrote: > > > Unfortunately (as probably I told you before) I will never pass to > > > Python 3... Guido should not always listen only to gurus like him... > > > I don't like Python as before...s

Re: hex dump w/ or w/out utf-8 chars

2013-07-10 Thread wxjmfauth
For those who are interested. The official proposal request for the encoding of the Latin uppercase letter Sharp S in ISO/IEC 10646; DIN (The German Institute for Standardization) proposal is available on the web. A pdf with the rationale. I do not remember from where I got it, probably from a Germ

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Steven D'Aprano
On Tue, 09 Jul 2013 12:15:29 +0200, Chris “Kwpolska” Warrick wrote: > On Tue, Jul 9, 2013 at 11:34 AM, wrote: >> Note the difference between SS and ẞ 'FRANZ-JOSEF-STRAUSS-STRAẞE' > > This is a capital Eszett. Which just happens not to exist in German. > Germans do not use this character, it is

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Chris “Kwpolska” Warrick
On Tue, Jul 9, 2013 at 11:34 AM, wrote: > Note the difference between SS and ẞ > 'FRANZ-JOSEF-STRAUSS-STRAẞE' This is a capital Eszett. Which just happens not to exist in German. Germans do not use this character, it is not available on German keyboards, and the German spelling rules have you r

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Dave Angel
On 07/09/2013 09:00 AM, Neil Cerutti wrote: Interestingly similar scheme. It wonder if 5-bit chars was a common compression scheme. The Z-machine spec was never officially published either. I believe a "task force" reverse engineered it sometime in the 90's. Baudot was 5 bits. It used s

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Skip Montanaro
> It wonder if 5-bit chars was a > common compression scheme. http://en.wikipedia.org/wiki/List_of_binary_codes Baudot was pretty common, as I recall, though ASCII and EBCDIC ruled by the time I started punching cards. Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Neil Cerutti
On 2013-07-09, Dave Angel wrote: >> One of the first Python project I undertook was a program to >> dump the ZSCII strings from Infocom game files. They are >> mostly packed one character per 5 bits, with escapes to (I had >> to recheck the Z-machine spec) latin-1. Oh, those clever >> implementors

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Dave Angel
On 07/09/2013 08:22 AM, Neil Cerutti wrote: On 2013-07-08, Dave Angel wrote: I appreciate you've been around a long time, and worked in a lot of languages. I've programmed professionally in at least 35 languages since 1967. But we've come a long way from the 6bit characters I used in 1968. A

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Neil Cerutti
On 2013-07-08, Dave Angel wrote: > I appreciate you've been around a long time, and worked in a > lot of languages. I've programmed professionally in at least > 35 languages since 1967. But we've come a long way from the > 6bit characters I used in 1968. At that time, we packed them > 10 charac

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread wxjmfauth
Le mardi 9 juillet 2013 09:00:02 UTC+2, Steven D'Aprano a écrit : > On Mon, 08 Jul 2013 10:53:18 -0700, ferdy.blatsco wrote: > > > > > Not using python 3, for me (a programmer which was present at the > > > beginning of computer science, badly interacting with many languages > > > from assembl

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Steven D'Aprano
On Mon, 08 Jul 2013 10:53:18 -0700, ferdy.blatsco wrote: > Not using python 3, for me (a programmer which was present at the > beginning of computer science, badly interacting with many languages > from assembler to Fortran and from c to Pascal and so on) it was an hard > job to arrange the abrupt

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Steven D'Aprano
On Tue, 09 Jul 2013 07:49:45 +1000, Chris Angelico wrote: > On Tue, Jul 9, 2013 at 6:56 AM, Dave Angel wrote: >> But Unicode has nothing to do with Guido, and it has existed for about >> 25 years (if I recall correctly). > > Depends how you measure. According to [1], the work kinda began back >

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Steven D'Aprano
On Tue, 09 Jul 2013 00:32:00 +0100, MRAB wrote: > On 08/07/2013 23:02, Joshua Landau wrote: >> On 8 July 2013 22:38, MRAB wrote: >>> On 08/07/2013 21:56, Dave Angel wrote: Characters do not have a width. >>> >>> [snip] >>> >>> It depends what you mean by "width"! :-) >>> >>> Try this (Python

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread MRAB
On 08/07/2013 23:02, Joshua Landau wrote: On 8 July 2013 22:38, MRAB wrote: On 08/07/2013 21:56, Dave Angel wrote: Characters do not have a width. [snip] It depends what you mean by "width"! :-) Try this (Python 3): print("A\N{FULLWIDTH LATIN CAPITAL LETTER A}") AA Serious question: H

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Chris Angelico
On Tue, Jul 9, 2013 at 8:45 AM, Dave Angel wrote: > On 07/08/2013 05:49 PM, Chris Angelico wrote: >> >> On Tue, Jul 9, 2013 at 6:56 AM, Dave Angel wrote: >>> >>> But Unicode has nothing to do with Guido, and it has existed for about 25 >>> years (if I recall correctly). >> >> >> Depends how you m

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Dave Angel
On 07/08/2013 05:49 PM, Chris Angelico wrote: On Tue, Jul 9, 2013 at 6:56 AM, Dave Angel wrote: But Unicode has nothing to do with Guido, and it has existed for about 25 years (if I recall correctly). Depends how you measure. According to [1], the work kinda began back then (25 years ago bein

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Joshua Landau
On 8 July 2013 22:38, MRAB wrote: > On 08/07/2013 21:56, Dave Angel wrote: >> Characters do not have a width. > > [snip] > > It depends what you mean by "width"! :-) > > Try this (Python 3): > print("A\N{FULLWIDTH LATIN CAPITAL LETTER A}") > AA Serious question: How would one find the width

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Chris Angelico
On Tue, Jul 9, 2013 at 6:56 AM, Dave Angel wrote: > But Unicode has nothing to do with Guido, and it has existed for about 25 > years (if I recall correctly). Depends how you measure. According to [1], the work kinda began back then (25 years ago being 1988), but it wasn't till 1991/92 that the s

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread MRAB
On 08/07/2013 21:56, Dave Angel wrote: On 07/08/2013 01:53 PM, ferdy.blat...@gmail.com wrote: Hi Steven, thank you for your reply... I really needed another python guru which is also an English teacher! Sorry if English is not my mother tongue... "uncorrect" instead of "incorrect" (I misapplied

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Dave Angel
On 07/08/2013 01:53 PM, ferdy.blat...@gmail.com wrote: Hi Steven, thank you for your reply... I really needed another python guru which is also an English teacher! Sorry if English is not my mother tongue... "uncorrect" instead of "incorrect" (I misapplied the "similarity principle" like "unplea

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Chris Angelico
On Tue, Jul 9, 2013 at 3:53 AM, wrote: >>> All characters are UTF-8, characters. "a" is a UTF-8 character. So is "ă". > Not using python 3, for me (a programmer which was present at the beginning of > computer science, badly interacting with many languages from assembler to > Fortran and from c t

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread ferdy . blatsco
Hi Steven, thank you for your reply... I really needed another python guru which is also an English teacher! Sorry if English is not my mother tongue... "uncorrect" instead of "incorrect" (I misapplied the "similarity principle" like "unpleasant...>...uncorrect"). Apart from these trifles, you sa

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread Chris Angelico
On Tue, Jul 9, 2013 at 3:31 AM, wrote: > Unfortunately (as probably I told you before) I will never pass to > Python 3... Guido should not always listen only to gurus like him... > I don't like Python as before...starting from OOP and ending with codecs > like utf-8. Regarding OOP, much apprecia

Re: hex dump w/ or w/out utf-8 chars

2013-07-08 Thread ferdy . blatsco
Hi Chris, glad to have received your contribution, but I was expecting much more critics... Starting from the "little nitpick" about the comment dispositon in my script... you are correct... It is a bad habit on my part to place variables subjected to change at the beginning of the script... and t

Re: hex dump w/ or w/out utf-8 chars

2013-07-07 Thread Steven D'Aprano
On Sun, 07 Jul 2013 17:22:26 -0700, blatt wrote: > Hi all, > but a particular hello to Chris Angelino which with their critics and > suggestions pushed me to make a full revision of my application on hex > dump in presence of utf-8 chars. I don't understand what you are trying to say. All charact

Re: hex dump w/ or w/out utf-8 chars

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 10:22 AM, blatt wrote: > Hi all, > but a particular hello to Chris Angelino which with their critics and > suggestions pushed me to make a full revision of my application on > hex dump in presence of utf-8 chars. Hiya! Glad to have been of assistance :) > As I already told

Re: hex to bin 16 bit word

2012-04-27 Thread Grant Edwards
On 2012-04-27, Grant Edwards wrote: > On 2012-04-27, Grant Edwards wrote: >> On 2012-04-27, Paul Rubin wrote: >>> python writes: What to decode hex '0xC0A8' and return signed short int. >>> >>> Is this right? >>> >>> n = int('0xC0A8', 16) >>> if n >= 0x: >>>n -= 0x1000

Re: hex to bin 16 bit word

2012-04-27 Thread Grant Edwards
On 2012-04-27, Grant Edwards wrote: > On 2012-04-27, Paul Rubin wrote: >> python writes: >>> What to decode hex '0xC0A8' and return signed short int. >> >> Is this right? >> >> n = int('0xC0A8', 16) >> if n >= 0x: >>n -= 0x1 > > Yes, as long as the input value doesn't ex

Re: hex to bin 16 bit word

2012-04-27 Thread MRAB
On 27/04/2012 20:32, Ian Kelly wrote: On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin wrote: python writes: What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n>= 0x: n -= 0x1 No. n = int('0xC0A8', 16) if n>= 0x800

Re: hex to bin 16 bit word

2012-04-27 Thread Ian Kelly
On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin wrote: > python writes: >> What to decode hex '0xC0A8'  and return signed short int. > > Is this right? > >    n = int('0xC0A8', 16) >    if n >= 0x: >       n -= 0x1 No. n = int('0xC0A8', 16) if n >= 0x8000: n -= 0x1 -- http://mail.

Re: hex to bin 16 bit word

2012-04-27 Thread Paul Rubin
Steven D'Aprano writes: >> Is this right? >> >> n = int('0xC0A8', 16) >> if n >= 0x: >>n -= 0x1 > No. Oops, I meant n >= 0x7fff. Checking the sign bit. Grant Edwards writes: > Yes, as long as the input value doesn't exceed 0x1. This is > probably better: > > n

Re: hex to bin 16 bit word

2012-04-27 Thread Grant Edwards
On 2012-04-27, Paul Rubin wrote: > python writes: >> What to decode hex '0xC0A8' and return signed short int. > > Is this right? > > n = int('0xC0A8', 16) > if n >= 0x: >n -= 0x1 Yes, as long as the input value doesn't exceed 0x1. This is probably better: n = int(

Re: hex to bin 16 bit word

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 11:56:45 -0700, Paul Rubin wrote: > python writes: >> What to decode hex '0xC0A8' and return signed short int. > > Is this right? > > n = int('0xC0A8', 16) > if n >= 0x: >n -= 0x1 No. >>> struct.unpack('>h',b'\xC0\xA8') (-16216,) >>> n = int('0xC0

Re: hex to bin 16 bit word

2012-04-27 Thread Paul Rubin
python writes: > What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n >= 0x: n -= 0x1 -- http://mail.python.org/mailman/listinfo/python-list

Re: hex question

2010-06-25 Thread Dave Angel
Sneaky Wombat wrote: Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? You don't say what you do want. Currently, you have a literal that describes four characters. Were you tryin

Re: hex question

2010-06-25 Thread Matt McCredie
Sneaky Wombat gmail.com> writes: > > Why is python turning \x0a into a \n ? > > In [120]: h='\x0a\xa8\x19\x0b' > > In [121]: h > Out[121]: '\n\xa8\x19\x0b' > > I don't want this to happen, can I prevent it? 'h' is an ascii string. The ascii encoding for '\n' is the number(byte) 0x0A. When y

Re: hex question

2010-06-25 Thread Ethan Furman
Sneaky Wombat wrote: Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? '\x0a' == '\n' -- http://mail.python.org/mailman/listinfo/python-list

Re: hex question

2010-06-25 Thread Emile van Sebille
On 6/25/2010 1:20 PM Sneaky Wombat said... Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? It's not happening. What you're seeing is the representation of the four bytes, and \x0a

Re: Hex String

2010-05-10 Thread MRAB
Anthony Cole wrote: How can I concatenate 2 hex strings (e.g. '\x16' and '\xb9') then convert the answer to an integer? When I try i always end up with the ASCII equivalent! Those are just bytestrings (assuming you're using Python 2.x), ie strings using 1 byte per character. You can convert a

Re: Hex String

2010-05-10 Thread Chris Rebert
On Mon, May 10, 2010 at 12:55 PM, Anthony Cole wrote: > How can I concatenate 2 hex strings (e.g. '\x16' and '\xb9') then convert > the answer to an integer? > > When I try i always end up with the ASCII equivalent! I think you want the `struct` module: struct — Interpret strings as packed binary

Re: hex int and string

2009-11-30 Thread jessica
On 11月28日, 上午11时41分, "84715...@qq.com" <84715...@qq.com> wrote: > On 11月27日, 下午4时54分, luca72 wrote: > > > hello i have a problem > > > i have this > > > str = 'D3' > > and i need to trasform in 0xd3 type int and not type string how i can > > do this? > > if i do > > hex(int(str,16) ) i obtain a st

Re: hex int and string

2009-11-30 Thread jessica
On 11月27日, 下午6时59分, Marco Mariani wrote: > Ben Finney wrote: > >> i'm using pyscard > > > I don't know what that is; can you give a link to what you're referring > > to? > > Simple story: he has seen the examples with hex literals and didn't know > what they were. http://www.mbthome.net/ mbt shoe

Re: hex int and string

2009-11-30 Thread 84715...@qq.com
On 11月27日, 下午6时59分, Marco Mariani wrote: > Ben Finney wrote: > >> i'm using pyscard > > > I don't know what that is; can you give a link to what you're referring > > to? > > Simple story: he has seen the examples with hex literals and didn't know > what they were. http://www.jerseysup.com"; targ

Re: hex int and string

2009-11-30 Thread 84715...@qq.com
On 11月27日, 下午4时54分, luca72 wrote: > hello i have a problem > > i have this > > str = 'D3' > and i need to trasform in 0xd3 type int and not type string how i can > do this? > if i do > hex(int(str,16) ) i obtain a string and this is not what i need. > > thanks Luca http://www.jerseysup.com"; tar

Re: hex int and string

2009-11-28 Thread Tim Roberts
Marco Mariani wrote: >luca72 wrote: > >> i have checked and pyscard accept also the decimal notation, > >I'm not sure you ever understood what the problem was, or where, but I'm >happy you feel like you've solved it. +1 QOTW. Great reply. -- Tim Roberts, t...@probo.com Providenza & Boekelheid

Re: hex int and string

2009-11-27 Thread jessica
On 11月27日, 下午5时35分, "84715...@qq.com" <84715...@qq.com> wrote: > On 11月27日, 下午5时28分, luca72 wrote: > > > > > i'm using pyscard > > > and for send a command he need a list like this: > > > cmd = [0xdd,0xff, etc] > > > the problem is that i get a text > > like dd > > and i need to trasform it in 0xd

Re: hex int and string

2009-11-27 Thread jessica
On 11月27日, 下午4时54分, luca72 wrote: > hello i have a problem > > i have this > > str = 'D3' > and i need to trasform in 0xd3 type int and not type string how i can > do this? > if i do > hex(int(str,16) ) i obtain a string and this is not what i need. > > thanks Luca http://www.mbthome.net/ mbt sho

Re: hex int and string

2009-11-27 Thread Marco Mariani
Ben Finney wrote: i'm using pyscard I don't know what that is; can you give a link to what you're referring to? Simple story: he has seen the examples with hex literals and didn't know what they were. -- http://mail.python.org/mailman/listinfo/python-list

Re: hex int and string

2009-11-27 Thread Marco Mariani
luca72 wrote: i have checked and pyscard accept also the decimal notation, I'm not sure you ever understood what the problem was, or where, but I'm happy you feel like you've solved it. -- http://mail.python.org/mailman/listinfo/python-list

Re: hex int and string

2009-11-27 Thread Peter Otten
luca72 wrote: > i'm using pyscard > > and for send a command he need a list like this: > > cmd = [0xdd,0xff, etc] Note that 0xdd is exactly the same as 221: >>> 0xdd == 221 True It's just an alternative way to write an integer literal that is sometimes more convenient. Therefore you don't ne

Re: hex int and string

2009-11-27 Thread Ben Finney
(Please don't top-post; it makes the message difficult to follow. Instead, post inline to the quoted material you're responding to, and remove material that you're not responding to.) luca72 writes: > i'm using pyscard I don't know what that is; can you give a link to what you're referring to?

Re: hex int and string

2009-11-27 Thread luca72
i have checked and pyscard accept also the decimal notation, Thanks Luca On 27 Nov, 10:38, Lie Ryan wrote: > On 11/27/2009 8:28 PM, luca72 wrote: > > > i'm using pyscard > > > and for send a command he need a list like this: > > > cmd = [0xdd,0xff, etc] > > > the problem is that i get a text >

Re: hex int and string

2009-11-27 Thread Lie Ryan
On 11/27/2009 8:28 PM, luca72 wrote: i'm using pyscard and for send a command he need a list like this: cmd = [0xdd,0xff, etc] the problem is that i get a text like dd and i need to trasform it in 0xdd for the list and if i use hex i have a sting that is not what i need >>> # Do you know th

Re: hex int and string

2009-11-27 Thread 84715...@qq.com
On 11月27日, 下午5时28分, luca72 wrote: > i'm using pyscard > > and for send a command he need a list like this: > > cmd = [0xdd,0xff, etc] > > the problem is that i get a text > like dd > and i need to trasform it in 0xdd for the list and if i use hex i have > a sting that is not what i need > > Luca >

Re: hex int and string

2009-11-27 Thread luca72
i'm using pyscard and for send a command he need a list like this: cmd = [0xdd,0xff, etc] the problem is that i get a text like dd and i need to trasform it in 0xdd for the list and if i use hex i have a sting that is not what i need Luca On 27 Nov, 10:22, Ben Finney wrote: > luca72 writes:

Re: hex int and string

2009-11-27 Thread Ben Finney
luca72 writes: > str = 'D3' Be careful when choosing names. Here you have clobbered the existing string type binding to the name ‘str’. > and i need to trasform in 0xd3 type int and not type string how i can > do this? You already have the answer; you used it in your example below. I can only

Re: hex

2009-11-20 Thread Peter Otten
hong zhang wrote: > I want to input hex number instead of int number. in type="int" in > following, > > parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int", > default=0, help="index of 11n mcs table. Default: 0.") > > How can I do it? Workaround for the lazy: '0xff' on the comman

Re: hex

2009-11-20 Thread Diez B. Roggisch
hong zhang schrieb: List, I want to input hex number instead of int number. in type="int" in following, parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int", default=0, help="index of 11n mcs table. Default: 0.") How can I do it? You can't. You can get a string, and convert th

Re: hex

2009-11-19 Thread Rhodri James
On Thu, 19 Nov 2009 02:29:59 -, hong zhang wrote: List, I want to input hex number instead of int number. in type="int" in following, parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int", default=0, help="index of 11n mcs table. Default: 0.") How can I do it? Assu

Re: hex(dummy)[2:] - issue...

2009-05-07 Thread Florian Wollenschein
Tim Chase wrote: I need some advice :-) I'm using hex(dummy)[2:] to represent a color in hexadecimal format for the bgcolor in an html file. dummy is the color value in RGB of course... Now, if there's an R, G or B value of zero, this command only prints one single 0 instead of two. What's w

Re: hex(dummy)[2:] - issue...

2009-05-06 Thread Tim Chase
I need some advice :-) I'm using hex(dummy)[2:] to represent a color in hexadecimal format for the bgcolor in an html file. dummy is the color value in RGB of course... Now, if there's an R, G or B value of zero, this command only prints one single 0 instead of two. What's wrong with the code?

Re: hex(dummy)[2:] - issue...

2009-05-06 Thread MRAB
Florian Wollenschein wrote: Hi there, I need some advice :-) I'm using hex(dummy)[2:] to represent a color in hexadecimal format for the bgcolor in an html file. dummy is the color value in RGB of course... Now, if there's an R, G or B value of zero, this command only prints one single 0 ins

Re: Hex editor - Python beginner's code open to review

2007-08-12 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Aug 10, 10:36 pm, CC <[EMAIL PROTECTED]> wrote: >> Hi: >> >> http://web.newsguy.com/crcarl/python/hexl.py >> >> This is my first Python program other than tutorial code snippet >> experimentation. I chose a hex line editor. I may do a hex screen >> editor once this i

Re: Hex editor - Python beginner's code open to review

2007-08-12 Thread kyosohma
On Aug 10, 10:36 pm, CC <[EMAIL PROTECTED]> wrote: > Hi: > > http://web.newsguy.com/crcarl/python/hexl.py > > This is my first Python program other than tutorial code snippet > experimentation. I chose a hex line editor. I may do a hex screen > editor once this is done, if I feel like playing wit

Re: Hex editor display - can this be more pythonic?

2007-07-30 Thread Neil Cerutti
On 2007-07-30, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 29 Jul 2007 18:30:22 -0700, CC <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> >> Yeah, with this I'm not that concerned about Windows. Though, can WinXP >> still load the ansi.sys driver? >> > I'

  1   2   >