Re: [Tutor] os.urandom()

2010-08-07 Thread Richard D. Moores
On Sat, Aug 7, 2010 at 17:00, Alan Gauld wrote: > > "Richard D. Moores" wrote > >> Yes, the number of bytes seems to <= 6, or is it?: > > os.urandom(6) >> >> b'\xf1\x1c\x15\x83\x14\x0e' > > ok > > os.urandom(6) >> >> b'l\xbb\xae\xb7\x0ft' > > still ok - the l and t at the ends are val

Re: [Tutor] os.urandom()

2010-08-07 Thread Steven D'Aprano
On Sun, 8 Aug 2010 09:32:02 am Richard D. Moores wrote: > On Sat, Aug 7, 2010 at 15:26, Alan Gauld wrote: > > Python is telling you its bytes with the b at the front. > > The \x tells you they are hex values. > > > > (*)The fact its 5 is odd since you seem to pass 6 as an argument! > > When I try

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
I think I'll print this and paste into the inside cover of my Python book. :-) I find it interesting that any Python book I've seen doesn't deal with distributing programs in some form or another. On 8/7/2010 3:33 PM, Alan Gauld wrote: "Emile van Sebille" wrote As others have mentioned, don

Re: [Tutor] word_probles.py

2010-08-07 Thread Hugo Arts
On Sat, Aug 7, 2010 at 7:12 PM, Shurui Liu wrote: > There is no tracebacks. > > I can run this program on putty.exe. That means the code is correct, but I > cannot run it on IDLE or PyScripter.exe. Both of these two platforms only > told me "Syntax Error" without tracebacks or something. > We'll

Re: [Tutor] word_probles.py

2010-08-07 Thread Shurui Liu
There is no tracebacks. I can run this program on putty.exe. That means the code is correct, but I cannot run it on IDLE or PyScripter.exe. Both of these two platforms only told me "Syntax Error" without tracebacks or something. ## Never had, never will.

Re: [Tutor] os.urandom()

2010-08-07 Thread Alan Gauld
"Richard D. Moores" wrote (*)The fact its 5 is odd since you seem to pass 6 as an argument! When I try it I get 6 bytes back. For some reason I never spotted the L at the end of the string last time. So it was 6 bytes. I suspect the L was read (by me) as the L at the end of a Long integer

Re: [Tutor] os.urandom()

2010-08-07 Thread Alan Gauld
"Richard D. Moores" wrote Yes, the number of bytes seems to <= 6, or is it?: os.urandom(6) b'\xf1\x1c\x15\x83\x14\x0e' ok os.urandom(6) b'l\xbb\xae\xb7\x0ft' still ok - the l and t at the ends are valid characters so Python prints the letter os.urandom(6) b'\x1f\x00~\xfbz\x98' Sa

Re: [Tutor] os.urandom()

2010-08-07 Thread Richard D. Moores
On Sat, Aug 7, 2010 at 16:34, bob gailer wrote: > [chr(x) for x in os.urandom(6))] Correcting this to [chr(x) for x in os.urandom(6)], most of the time I get an error: >>> [chr(x) for x in os.urandom(6)] Traceback (most recent call last): File "", line 1, in File "C:\Python31\lib\encodings

Re: [Tutor] os.urandom()

2010-08-07 Thread Richard D. Moores
On Sat, Aug 7, 2010 at 15:01, Dominik Danter wrote: > You could try something like binascii.hexlify(os.urandom(6)) to create hex. >>> os.urandom(6) b'f\xc8rnr\xea' >>> binascii.hexlify(b'f\xc8rnr\xea') b'66c8726e72ea' >>> os.urandom(6) b'D\xe9?\xda\xd80' >>> binascii.hexlify(b'D\xe9?\xda\xd80')

Re: [Tutor] os.urandom()

2010-08-07 Thread bob gailer
On 8/7/2010 6:29 PM, Evert Rol wrote: [a for a in map(chr, os.urandom(6))] Overkill! map(chr, os.urandom(6)) is sufficient. Or [chr(x) for x in os.urandom(6))] The latter is easier to read. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tuto

Re: [Tutor] os.urandom()

2010-08-07 Thread Richard D. Moores
On Sat, Aug 7, 2010 at 15:26, Alan Gauld wrote: > Python is telling you its bytes with the b at the front. > The \x tells you they are hex values. > > (*)The fact its 5 is odd since you seem to pass 6 as an argument! > When I try it I get 6 bytes back. Yes, the number of bytes seems to <= 6, or

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Alan Gauld
"Emile van Sebille" wrote As others have mentioned, don't use idle as you're doing. Give pythonwin (included with the activestate distribution) a try. Or try one of the free versions of Komodo or Wing. In fact I'd strongly recommend not to use ANY development tool to run your programs. Thes

Re: [Tutor] os.urandom()

2010-08-07 Thread Evert Rol
> > > using Vista, Python 3.1: > import os os.urandom(6) > b'\xd1\xfc\xb0\x14\xeaL' > > So what is this output? What in ascii? What in hex? Do those > questions even make sense? It returns just what it says in

Re: [Tutor] os.urandom()

2010-08-07 Thread Alan Gauld
"Richard D. Moores" wrote import os os.urandom(6) b'\xd1\xfc\xb0\x14\xeaL' So what is this output? What in ascii? What in hex? Do those questions even make sense? The documentation tells you: os.urandom(n)ΒΆ Return a string of n random bytes suitable for cryptographic use. So its a strin

[Tutor] os.urandom()

2010-08-07 Thread Richard D. Moores
using Vista, Python 3.1: >>> import os >>> os.urandom(6) b'\xd1\xfc\xb0\x14\xeaL' So what is this output? What in ascii? What in hex? Do those questions even make sense? I've tried 2 things to get at it: >>> import bina

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
Thanks. Looks interesting. On 8/7/2010 1:25 PM, Wayne Werner wrote: I just noticed this thread - if you want a great version of python that has numpy/scipy so you can be sure to have the same version, use Python XY: http://www.pythonxy.com/ It's got a host of scientific packages such as matpl

Re: [Tutor] word_probles.py

2010-08-07 Thread Wayne Werner
On Sat, Aug 7, 2010 at 2:17 PM, Shurui Liu wrote: > > Here is a code named "word_problems.py". I can run it on putty.exe, but I > don't understand why I cannot run it on IDLE or pyscripter.exe. Both of > these two platform show that there are syntax errors in the code, errors > are on those red

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Werner
I just noticed this thread - if you want a great version of python that has numpy/scipy so you can be sure to have the same version, use Python XY: http://www.pythonxy.com/ It's got a host of scientific packages such as matplotlib, numpy, and scipy. Then it has all sorts of other bells and whistl

[Tutor] word_probles.py

2010-08-07 Thread Shurui Liu
print \ """ If a pregnant hippo, weighing 2,000 pounds, gives birth to a 100 pound calf, but then eats 50 pounds of food, how much does she weigh?""" raw_input("Press the enter key to find out.") print "2000 - 100 + 50 = ", print 2000 - 100 + 50 print \ """ If an adventurer returns from a success

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
(I cancelled the post, since the file was 120K, and unacceptable. It's now 27K, so everyone should see it, but the print might be a bit tiny.) Sounds like a plan. I'll give it a go. For what it's worth, our sponsor has suggested it was the way to go, i.e., use IDLE to execute it, his large app

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Emile van Sebille
On 8/7/2010 8:16 AM Wayne Watson said... An easy way out might be to ask him to uninstall Python and any modules like numpy. I'm not even sure how to do that. More reasons to start out simpler. Have your partner install one of the remote access tools (GoToMyPC, LogMeIn, VNC, etc) and do the

Re: [Tutor] LOCATION ISSUES

2010-08-07 Thread Chris King
On 7/13/2010 2:13 AM, Dipo Elegbede wrote: Hello All, Kindly help me with the location for the files created by this codes. I have already compiled the codes and it has no error. I copied the code from the following url: http://www.pythonware.com/library/pil/handbook/image.htm This is supposed

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
Actually, I arranged to have them on my Yahoo Group. He seemed to ignore that, so I gave him very specific instructions, including a snaphot with an arrow pointing to one of the files, to download. It's the one that seems to be troublesome Numpy. So instead he downloads another one. There's onl

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
Solved the version question with the other thread two days ago. On 8/6/2010 8:38 PM, Che M wrote: > #, showing his output. We need to make sure we are on the same playing > ground with numpy and scipy. I don't think we are. He barely knows > Python, but did, supposedly, a install of i

Re: [Tutor] Word to Sound

2010-08-07 Thread Steven D'Aprano
On Sun, 8 Aug 2010 01:43:25 am Chris King wrote: > Dear Tutors, > How do you convert a string into a sound object. What do you mean by "sound object"? Can you give an example of what you want to do? -- Steven D'Aprano ___ Tutor maillist - Tu

[Tutor] Word to Sound

2010-08-07 Thread Chris King
Dear Tutors, How do you convert a string into a sound object. Sincerely, Chris ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
Yes, that might work, but it gets into other issues that I would rather avoid. I hope I mentioned in my original msg that this is a Windows envirnoment. I don't know much about dsutils, but it might work for these situations. Just enough to mention it seems like it package an environment. An

Re: [Tutor] Distributing Python Code for Commercial Porpoises?

2010-08-07 Thread Wayne Watson
Thanks, but my partner has enough difficulty with a simple Python install, let alone VM or anything beyond Windows. On 8/6/2010 11:42 AM, Chris Fuller wrote: It sounds like maybe you could use Enthought Python, which is a bundle of most of the popular numerical libraries by the scipy sponsors.

Re: [Tutor] modify csv textfile

2010-08-07 Thread Sander Sweers
On 7 August 2010 13:45, TGW wrote: >> You can test if one item in your list begins with example like: >> ' example125 oo3 3456'.lstrip()[:7].lower() == 'example' > > I think I need to use regex here. Perhaps you will agree. You could but you don't have to, consider this. r = '1234|Avail|53|Potat

Re: [Tutor] modify csv textfile

2010-08-07 Thread David Hutto
On Sat, Aug 7, 2010 at 8:26 AM, David Hutto wrote: > On Sat, Aug 7, 2010 at 7:26 AM, Alan Gauld wrote: >> >> "TGW" wrote >>> >>> What I want to output is: >>> 12345|some text|some more text|example|example32423 >>> 11223|more text|and more|example|example455667 >>> >>> So column 4 is where the c

Re: [Tutor] modify csv textfile

2010-08-07 Thread David Hutto
On Sat, Aug 7, 2010 at 7:26 AM, Alan Gauld wrote: > > "TGW" wrote >> >> What I want to output is: >> 12345|some text|some more text|example|example32423 >> 11223|more text|and more|example|example455667 >> >> So column 4 is where the change occurs, but only if the beginning >> of the string in co

Re: [Tutor] modify csv textfile

2010-08-07 Thread Alan Gauld
"TGW" wrote What I want to output is: 12345|some text|some more text|example|example32423 11223|more text|and more|example|example455667 So column 4 is where the change occurs, but only if the beginning of the string in column 4 =~ /^example/i # and it should be case insensitive reader

Re: [Tutor] modify csv textfile

2010-08-07 Thread TGW
> You can test if one item in your list begins with example like: > ' example125 oo3 3456'.lstrip()[:7].lower() == 'example' I think I need to use regex here. Perhaps you will agree. Input file: 1119|Avail|53|Potato Chips 1234|Avail|53|Potato Chips and salse 1399|Avail|53|potato chips 1445|Avail|

Re: [Tutor] modify csv textfile

2010-08-07 Thread Sander Sweers
On 7 August 2010 04:35, TGW wrote: > I have a pipe delimited text file with 5 columns which looks like this: > 12345|some text|some more text|example125 oo3 3456|example32423 > 11223|more text|and more|example/73d 77665|example455667 > 12677|text|more|anotherexample 123|anotherexample45 > > What I