Re: [Tutor] how to struct.pack a unicode string?

2012-11-30 Thread Steven D'Aprano
On 01/12/12 12:28, eryksun wrote: UTF-8 was designed to encode all of Unicode in a way that can seamlessly pass through libraries that process C strings (i.e. an array of non-null bytes terminated by a null byte). Byte values less than 128 are ASCII; beyond ASCII, UTF-8 uses 2-4 bytes, and all b

Re: [Tutor] how to struct.pack a unicode string?

2012-11-30 Thread eryksun
A clarification: in the default mode ('@'), struct uses native alignment padding, but not if you override this with <, >, =, or !, as you did. >> fmt = endianness + str(len(hello)) + "s" > > That's the wrong length. Use the length of the encoded string. Generally, however, you'd use a fixed size

Re: [Tutor] how to struct.pack a unicode string?

2012-11-30 Thread eryksun
On Fri, Nov 30, 2012 at 11:43 AM, Albert-Jan Roskam wrote: > > How can I pack a unicode string using the struct module? struct.pack is for packing an arbitrary sequence of data into a C-like struct. You have to manually add pad bytes. Alternatively you can use a ctypes.Structure. The struct modu

Re: [Tutor] how to struct.pack a unicode string?

2012-11-30 Thread Steven D'Aprano
On 01/12/12 03:43, Albert-Jan Roskam wrote: Hi, How can I pack a unicode string using the struct module? If I simply use packed = struct.pack(fmt, hello) in the code below (and 'hello' is a unicode string), I get this: "error: argument for 's' must be a string". To be precise, it must be a *by

Re: [Tutor] FW: (no subject)

2012-11-30 Thread Ed Owens
Hi, im trying to write a script which randomly generates 10,000 points(x,y) in the unit square(so range between 0 and 1 for both x and y). so far I have written the code below in red, however it only produces one random point. How do I get it to repeat this so it produces 10,000 different random p

Re: [Tutor] how to struct.pack a unicode string?

2012-11-30 Thread Peter Otten
Albert-Jan Roskam wrote: > How can I pack a unicode string using the struct module? If I simply use > packed = struct.pack(fmt, hello) in the code below (and 'hello' is a > unicode string), I get this: "error: argument for 's' must be a string". I > keep reading that I have to encode it to a utf-8

[Tutor] how to struct.pack a unicode string?

2012-11-30 Thread Albert-Jan Roskam
Hi, How can I pack a unicode string using the struct module? If I simply use packed = struct.pack(fmt, hello) in the code below (and 'hello' is a unicode string), I get this: "error: argument for 's' must be a string". I keep reading that I have to encode it to a utf-8 bytestring, but this does

Re: [Tutor] FW: (no subject)

2012-11-30 Thread Albert-Jan Roskam
>> Hi, im trying to write a script which randomly generates 10,000 points(x,y) >> in the unit square(so range between 0 and 1 for both x and y).so far I have >> written the code below in red, > >What red? I see no red. > >Please do not rely on colour in email, for at least two reasons: > >1) For

Re: [Tutor] Need a Python tutor

2012-11-30 Thread Steven D'Aprano
Hi Saly, My comments below. On 29/11/12 18:03, Oxford Learning Centre wrote: Hi there My son is in first year Engineering& he needs help with reviewing for his final next week on computer programming using Python language. Please if u have or know any one who can help him that will be a great

Re: [Tutor] FW: (no subject)

2012-11-30 Thread Steven D'Aprano
Hello Tara, or is it Leon? On 30/11/12 20:21, leon zaat wrote: Hi, im trying to write a script which randomly generates 10,000 points(x,y) in the unit square(so range between 0 and 1 for both x and y).so far I have written the code below in red, What red? I see no red. Please do not rely on

[Tutor] Pypi entry points

2012-11-30 Thread Albert-Jan Roskam
Hi, I am reading The Hitchhiker's Guide to Packaging 1.0 documentation, specifically http://guide.python-distribute.org/creation.html. I am struggling to understand the section about Entry Points. This appears to be a way to include extra functionality in a program, without the need to actually

[Tutor] FW: (no subject)

2012-11-30 Thread leon zaat
From: tara.nichol...@live.co.uk To: tutor@python.org Date: Tue, 20 Nov 2012 14:39:06 + Subject: [Tutor] (no subject) Hi, im trying to write a script which randomly generates 10,000 points(x,y) in the unit square(so range between 0 and 1 for both x and y).so far I have written the code

[Tutor] (no subject)

2012-11-30 Thread Tara Nicholson
Hi, im trying to write a script which randomly generates 10,000 points(x,y) in the unit square(so range between 0 and 1 for both x and y).so far I have written the code below in red, however it only produces one random point. How do I get it to repeat this so it produces 10,000 different random

Re: [Tutor] New to Python - simple question

2012-11-30 Thread Unaiza Ahsan
I'm on Chapter 1 of Solem's book. The following function definition needs to be added to imtools.py: [I did paste this I think in my first email]. import os from numpy import * def histeq(im,nbr_bins=256): """ Histogram equalization of a grayscale image. """ # get image histogram imhist,bins = hi

Re: [Tutor] pyXML i Python2.6

2012-11-30 Thread Sreenivasulu
Hi Ramith, Thank you for your reply . I have made some modifications in pyXMl and it is working fine . I have file named as Test.py and below is the code in the file from SOAPpy import WSDL SecurityServerUrlTemplate = "http:// %s/SpinSecurity/SpinInfoExchange.asmx?WSDL" secser1="Coputername

[Tutor] Need a Python tutor

2012-11-30 Thread Oxford Learning Centre
Hi there My son is in first year Engineering & he needs help with reviewing for his final next week on computer programming using Python language. Please if u have or know any one who can help him that will be a great help. He is in school in Hamilton Ontario , but you can reach me either by pho