I don't understand why with the code:
for k in range(8,12,1):
print(k.to_bytes(2,byteorder='big'))
one gets the following output:
b'\x00\x08'
b'\x00\t'
b'\x00\n'
b'\x00\x0b'
I mean the 2nd and 3rd should be b'\x00\x09' and b'x00\x0a'.
Anyway, how could I get the output in t
From an int one can use to_bytes to get its individual bytes,
but how can one reconstruct the int from the sequence of bytes?
Thanks in advance.
M. K. Shen
--
http://mail.python.org/mailman/listinfo/python-list
Am 27.05.2013 17:30, schrieb Ned Batchelder:
On 5/27/2013 10:45 AM, Mok-Kong Shen wrote:
From an int one can use to_bytes to get its individual bytes,
but how can one reconstruct the int from the sequence of bytes?
The next thing in the docs after int.to_bytes is int.from_bytes:
http
Am 28.05.2013 17:35, schrieb Grant Edwards:
On 2013-05-26, Mok-Kong Shen wrote:
I don't understand why with the code:
for k in range(8,12,1):
print(k.to_bytes(2,byteorder='big'))
one gets the following output:
b'\x00\x08'
b'\x00\t'
Am 30.05.2013 21:22, schrieb Ned Batchelder:
On 5/30/2013 2:26 PM, Mok-Kong Shen wrote:
Am 27.05.2013 17:30, schrieb Ned Batchelder:
On 5/27/2013 10:45 AM, Mok-Kong Shen wrote:
From an int one can use to_bytes to get its individual bytes,
but how can one reconstruct the int from the sequence
Could one write Python codes and have them run on one's own mobile
phone? If yes, are there some good literatures? Thanks in advance.
M. K. Shen
--
http://mail.python.org/mailman/listinfo/python-list
I ran the following code:
def xx(nlist):
print("begin: ",nlist)
nlist+=[999]
print("middle:",nlist)
nlist=nlist[:-1]
print("final: ",nlist)
u=[1,2,3,4]
print(u)
xx(u)
print(u)
and obtained the following result:
[1, 2, 3, 4]
begin: [1, 2, 3, 4]
middle: [1, 2, 3, 4, 999]
final: [1, 2
If I have a string "abcd" then, with 8-bit encoding of each character,
there is a corresponding 32-bit binary integer. How could I best
obtain that integer and from that integer backwards again obtain the
original string? Thanks in advance.
M. K. Shen
--
http://mail.python.org/mailman/listinfo/p
Am 06.08.2012 22:59, schrieb Tobiah:
The binascii module looks like it might have
something for you. I've never used it.
Thanks for the hint, but if I don't err, the module binascii doesn't
seem to work. I typed:
import binascii
and a line that's given as example in the document:
crc = bina
In an earlier question about lists, I was told about the issue of
creation of local names in a function. However, I still can't
understand why the program below outputs:
[999] sss
[999]
and not two identical lines of output. For both operators "+=" should
anyway work in similar manner in the fu
Am 10.08.2012 11:48, schrieb Roman Vashkevich:
[snip]
>The function It takes list by reference and creates a new local
> str. When it's called with listb and strb arguments, listb is passed
> by reference and mutated. A string "sss" is concatenated with an
> empty local str. Nothing more ha
Am 10.08.2012 12:07, schrieb Dave Angel:
[snip]
At this point, in top-level code, the listb object has been modified,
and the strb one has not; it still is bound to the old value.
This means there is no way of modifying a string at the top level
via a function, excepting through returning a ne
Am 10.08.2012 12:40, schrieb Chris Angelico:
But it's probably worth thinking about exactly why you're wanting to
change that string, and what you're really looking to accomplish.
There may well be a better way.
My problem is the following: I have at top level 3 lists and 3 strings:
lista, lis
Am 10.08.2012 12:56, schrieb Roman Vashkevich:
I am not sure I understand your question. Can you rephrase it or make it more
explicit?
I have just detailed my problem and Dave Angel has shown how to solve
it properly.
M. K. Shen
--
http://mail.python.org/mailman/listinfo/python-list
I heard of names of two systems for Python users to do symbolic
computations: SymPy and Sage. Could someone say a few lines
from experiences about their comparisons? Thanks in advance.
M. K. Shen
--
http://mail.python.org/mailman/listinfo/python-list
def test(list1,list2):
list1+=[4,5,6]
list2=list2+[4,5,6]
print("inside ",list1,list2)
return
# With
list1=list2=[1,2,3]
test(list1,list2)
print("outside",list1,list2)
# I got the following:
# inside [1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6, 4, 5, 6]
# outside [1, 2, 3, 4, 5, 6] [1, 2, 3,
Am 11.08.2016 um 23:49 schrieb Gary Herron:
On 08/11/2016 03:06 PM, Mok-Kong Shen wrote:
def test(list1,list2):
list1+=[4,5,6]
list2=list2+[4,5,6]
print("inside ",list1,list2)
return
[snip]
# With
list1=[1,2,3]
list2=[1,2,3]
test(list1,list2)
print("outside",l
Am 13.08.2016 um 03:08 schrieb Steven D'Aprano:
On Sat, 13 Aug 2016 06:44 am, Mok-Kong Shen wrote:
list2 = [1,2,3]
list1 += [4,5,6]
print(list1, list2)
[1, 2, 3, 4, 5, 6] [1, 2, 3]
Does that help?
I don't yet understand why in my 2nd example list2 came out as
[1, 2, 3] outside.
Am 14.08.2016 um 13:06 schrieb ast:
[snip]
Thanks. The use of id() is very helpful in clarifying
what acutally happens in the present case.
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
WORDLISTTEXTSTEGANOGRAPHY is a new software (employing an extensive
English word list) which, while performing linguistic steganography,
also involves pseudo-random separation of the word list into two
sublists (for denoting 0 and 1 bits) that are dependent on dynamic
session-key materials, thus
I don't understand the following phenomenon. Could someone kindly
explain it? Thanks in advance.
M. K. Shen
-
count=5
def test():
print(count)
if count==5:
count+=0 ### Error message if this line is active, otherwise ok.
print(cou
Could someone kindly explain a phenomenon in the following where:
(1) I first typed in a dictionary but got a printout in a reordered
form.
(2) I then typed in the reordered form but got a printout in the
order that I typed in originally in (1).
That is, there is no stable "standard" ordering.
A newbie's question of curiosity:
If I have
g=[1,[2]] and
bg=bytearray(str(g),"latin-1")
could I somehow get back from bg a list g1 that is the same as g?
Thanks in advance.
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
The code attached below produces in one of the two IMHO similar cases
(excepting the sizes of the lists involved) MemoryError. Could experts
kindly tell why that's so and whether there is any work-around feasible.
Thanks in advances.
M. K. Shen
-
Am 14.04.2014 09:46, schrieb Peter Otten:
You ran into a limitation of the compiler. For us to suggest a workaround
you'd have to explain why you want to convert the list returned from
buildhuffmantree() into python source code and back.
That list gives the Huffman encoding tree for compressin
Am 14.04.2014 15:59, schrieb Peter Otten:
You could use json, but you may run into the same problem with that, too
(only later):
import json
items = []
for i in range(1000):
... s = json.dumps(items)
... items = [items]
...
Traceback (most recent call last):
File "", line 2, in
Am 15.04.2014 01:51, schrieb Gregory Ewing:
Mok-Kong Shen wrote:
I have yet a question out of curiosity: Why is my 2nd list structure,
that apparently is too complex for handling by eval and json, seemingly
not a problem for pickle?
Pickle is intended for arbitrary data structures, so it
is
I have seen by chance a number of years ago a book on Python programming
for running on mobile phones (of a certain producer only). What is the
current state of the art in that? Could someone kindly give a few good
literature references? Thanks in advance.
M. K. Shen
--
https://mail.python.org/m
I like to compute log base 2 of a fairly large integer n but
with math.log(n,2) I got:
OverflowError: long int too large to convert to float.
Is there any feasible work-around for that?
Thanks in advance.
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
Am 13.08.2014 13:55, schrieb alister:
[snip]
A related question: How could one write a Python program and
have it run on a mobile phone in general (independent of a PC)?
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
Am 13.08.2014 15:32, schrieb Steven D'Aprano:
Mok-Kong Shen wrote:
I like to compute log base 2 of a fairly large integer n but
with math.log(n,2) I got:
OverflowError: long int too large to convert to float.
Is there any feasible work-around for that?
If you want the integer log2,
Am 13.08.2014 15:16, schrieb Skip Montanaro:
http://gnumbers.blogspot.com/2011/10/logarithm-of-large-number-it-is-not.html
Might be worth studying for ideas.
Thanks. I think the idea may help.
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
Version 2 of my natural language steganographical scheme
WORDLISTTEXTSTEGANOGRAPHY
is available on my home page http://mokkong-shen.privat.t-online.de ,
together with
a few other cryptological and steganographical software of mine. See update
notes in it for the differences to earlier versions
Due to a new convention of my Internet provider, my current home page is
now:
http://mokkong-shen.homepage.t-online.de
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
Version 2.1 of my natural language text steganography scheme
WORDLISTTEXTSTEGANOGRAPHY, having left behind a few initial
shortcomings and tiny problems stemming e.g from version
incompatibilities of Python, is available on my new home page:
http://mok-kong-shen.de.
M. K. Shen
--
https://mail.pyt
How could one obtain an up-to-date document of tkinter. I ask this
question because apparently there are stuffs of tkinter that
worked in Python 3.5 but no longer in Python 3.6.1.
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
Am 20.04.2017 um 02:16 schrieb breamore...@gmail.com:
On Thursday, April 20, 2017 at 1:09:45 AM UTC+1, Mok-Kong Shen wrote:
How could one obtain an up-to-date document of tkinter. I ask this
question because apparently there are stuffs of tkinter that
worked in Python 3.5 but no longer in
Am 20.04.2017 um 08:08 schrieb Terry Reedy:
On 4/19/2017 8:09 PM, Mok-Kong Shen wrote:
[snip]
I ask this
question because apparently there are stuffs of tkinter that
worked in Python 3.5 but no longer in Python 3.6.1.
I don't know of any such.
Please see my reply to breamoreboy.
I ran the attached program and got the following output:
[1, 2, 3]
[3, 6, 9]
I don't understand why the modification doesn't work in the case of
test() but does work in the case of test1().
Thanks for your help in advance.
M. K. Shen
---
Am 14.08.2017 um 20:50 schrieb Ned Batchelder:
On 8/14/17 2:21 PM, Mok-Kong Shen wrote:
I ran the attached program and got the following output:
[1, 2, 3]
[3, 6, 9]
I don't understand why the modification doesn't work in the case of
test() but does work in the case of test1().
Am 14.08.2017 um 21:53 schrieb Ned Batchelder:
On 8/14/17 3:21 PM, Mok-Kong Shen wrote:
Am 14.08.2017 um 20:50 schrieb Ned Batchelder:
On 8/14/17 2:21 PM, Mok-Kong Shen wrote:
I ran the attached program and got the following output:
[1, 2, 3]
[3, 6, 9]
I don't understand wh
without a global statement, a name is local, then alist[0]=3 should
not work globally, if it works at all, in my layman's logic.
M. K. Shen
On Mon, 14 Aug 2017 at 16:06 Mok-Kong Shen
wrote:
Am 14.08.2017 um 21:53 schrieb Ned Batchelder:
On 8/14/17 3:21 PM, Mok-Kong Shen wrote:
Am 14.0
Am 15.08.2017 um 20:47 schrieb Larry Hudson:
[snip]
=== test2() code ==
def test2(alist): ss ─┬─> [1, 2, 3]
alist ─┘
-
ss ─┬─> [3, 6, 9]
alist ─┘
Am 16.08.2017 um 23:20 schrieb Ned Batchelder:
On 8/16/17 5:06 PM, Mok-Kong Shen wrote:
Am 15.08.2017 um 20:47 schrieb Larry Hudson:
[snip]
=== test2() code ==
def test2(alist): ss ─┬─> [1, 2, 3]
al
Am 17.08.2017 um 00:39 schrieb Chris Angelico:
On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen
wrote:
I have earlier learned some other (older) programming languages. For
these the formal parameters are either "by reference" or "by value".
In the first case, any modifi
Am 17.08.2017 um 01:58 schrieb Cameron Simpson:
On 17Aug2017 01:03, Mok-Kong Shen wrote:
Am 17.08.2017 um 00:39 schrieb Chris Angelico:
On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen
wrote:
Chris wrote:
objects exist independently of names, and names refer to
objects. If you do "
Am 17.08.2017 um 02:41 schrieb Steve D'Aprano:
On Thu, 17 Aug 2017 08:29 am, Mok-Kong Shen wrote:
I have earlier learned some other (older) programming languages. For
these the formal parameters are either "by reference" or "by value".
By reference and by v
Am 17.08.2017 um 02:14 schrieb Ned Batchelder:
On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote:
Anyway, while
any new user of a programming language certainly can be expected to
take good efforts to learn a lot of new stuffs, I suppose it's good
for any practical programming langua
48 matches
Mail list logo