Re: [Tutor] Function for converting ints from base10 to base2?

2007-02-20 Thread Dick Moores
Well, I can't compare mine with yours (where is it?), but using the template in timeit.py: template = """ def inner(_it, _timer): from decToBin import computeBin _t0 = _timer() for _i in _it: computeBin(12345678901234567890) _t1 = _timer() return _t1 - _t0 """ I

Re: [Tutor] list problem

2007-02-20 Thread Luke Paireepinart
Kirk: Please reply to this message, not the other one I sent, and please reply on-list in the future, using the 'reply-all' button rather than 'reply.' Otherwise the message just goes to me instead of to everyone, which is the default on this list. This copy of your e-mail is forwarded to the lis

Re: [Tutor] list problem

2007-02-20 Thread Rikard Bosnjakovic
On 2/21/07, Kirk Bailey <[EMAIL PROTECTED]> wrote: [...] > Discussion on or off list is saught. Constructive criticism will be > graciously received and thanked. Without links, pointers, code or anything grippable I find it difficult to comment or discuss anything, since i haven't got the faintes

Re: [Tutor] list problem

2007-02-20 Thread Luke Paireepinart
Kirk Bailey wrote: > ok, getting back to python and wikiness, I have a problem, this software > of mine seems to exibit different behavior under the latest edition of > python (2.5) than under the version used when I first wrote it (2.3). > > It loads the page file, but returns it as a list (whic

[Tutor] list problem

2007-02-20 Thread Kirk Bailey
ok, getting back to python and wikiness, I have a problem, this software of mine seems to exibit different behavior under the latest edition of python (2.5) than under the version used when I first wrote it (2.3). It loads the page file, but returns it as a list (which is correcft) of one eleme

Re: [Tutor] Function for converting ints from base10 to base2?

2007-02-20 Thread David Perlman
I suspect the function I sent out earlier, using octal conversion and a lookup table, will be faster. But it would be very interesting to see some simple benchmarks. On Feb 20, 2007, at 10:47 PM, Dick Moores wrote: > I was surprised to be unable to find a function in Python for > converting

[Tutor] Function for converting ints from base10 to base2?

2007-02-20 Thread Dick Moores
I was surprised to be unable to find a function in Python for converting ints from base10 to base2. Is there one? I wrote one, but have I reinvented the wheel again? (Even if I have, it was an interesting exercise for me.) I know some of you CS people won't like what I do with negative ints, b

Re: [Tutor] how to read one bit of a byte

2007-02-20 Thread shawn bright
great, thanks for this. appreciate it a lot. sk On 2/20/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote: shawn bright wrote: > lo there all, > > i am reading a binary file with open('myfile', 'rb') > > then i do a read(1) to read one byte. cool so far. > > but how do i read the individual bits

Re: [Tutor] summer_v04.py

2007-02-20 Thread Rikard Bosnjakovic
On 2/21/07, John Fouhy <[EMAIL PROTECTED]> wrote: > (because you are using a generator expression, and they were only > introduced in 2.4) List comprehensions were implemented in v2.0. The OP probably does not use an older version, but as far as I can see, his syntax error line uses parenthesis -

Re: [Tutor] re and MULTILINE

2007-02-20 Thread Marilyn Davis
On Tue, 20 Feb 2007, Kent Johnson wrote: > Marilyn Davis wrote: > > Hello Tutors, > > > > I'm trying to get a grip on MULTILINE and I guess I don't have it. > > > > Here's some code: > > > > #!/usr/bin/env python > > import re > > > > def sub_it(mo): > > return 'xxx' > > > > def test(re_str, d

Re: [Tutor] summer_v04.py

2007-02-20 Thread John Fouhy
On 21/02/07, Christopher Spears <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] ./text_proc 151> ./summer_v04.py > table.txt > File "./summer_v04.py", line 6 > numCols = max(len(cols) for cols in line_list) > ^ > SyntaxError: invalid syntax What version of python

[Tutor] summer_v04.py

2007-02-20 Thread Christopher Spears
I've been working on a version of a script I found in "Programming Python". The helpful users of this forum gave me some advice to make the code less wordy. Here is the code: #!/usr/bin/python import string def find_longest_line(fileName): line_list = [line.split() for line in open(file

Re: [Tutor] re and MULTILINE

2007-02-20 Thread Kent Johnson
Marilyn Davis wrote: > Hello Tutors, > > I'm trying to get a grip on MULTILINE and I guess I don't have it. > > Here's some code: > > #!/usr/bin/env python > import re > > def sub_it(mo): > return 'xxx' > > def test(re_str, data): > return re.sub(re_str, sub_it, data, re.MULTILINE) > The

[Tutor] Reading compressed files

2007-02-20 Thread Shadab Sayani
Hi, I have compressed files compressed using different techniques (especially unix compress). So I want to have a module that reads any of these (.Z,.bz,.tgz files) files and manipulates the data. The data has a syntax.It contains HEADER (some information) BODY (some information)

[Tutor] re and MULTILINE

2007-02-20 Thread Marilyn Davis
Hello Tutors, I'm trying to get a grip on MULTILINE and I guess I don't have it. Here's some code: #!/usr/bin/env python import re def sub_it(mo): return 'xxx' def test(re_str, data): return re.sub(re_str, sub_it, data, re.MULTILINE) if __name__ == '__main__': data = '''Be

Re: [Tutor] how to read one bit of a byte

2007-02-20 Thread Luke Paireepinart
shawn bright wrote: > lo there all, > > i am reading a binary file with open('myfile', 'rb') > > then i do a read(1) to read one byte. cool so far. > > but how do i read the individual bits of a byte > > i mean if i have a = read(1) > > how do i know what the msb of a is ? > > i need to know becaus

[Tutor] how to read one bit of a byte

2007-02-20 Thread shawn bright
lo there all, i am reading a binary file with open('myfile', 'rb') then i do a read(1) to read one byte. cool so far. but how do i read the individual bits of a byte i mean if i have a = read(1) how do i know what the msb of a is ? i need to know because i have to see if the msb is set and i

Re: [Tutor] using SQLite with matplotlib - queries vs. lists

2007-02-20 Thread Kent Johnson
Pine Marten wrote: > I'm a novice hoping to use data stored in an SQLite database to make simple > graphs using matplotlib embedded in a wxPython GUI. I noticed that > matplotlib uses lists of integers to make graphs, such as the simple example > (from the tutorial) of: > > from pylab import *

[Tutor] using SQLite with matplotlib - queries vs. lists

2007-02-20 Thread Pine Marten
I'm a novice hoping to use data stored in an SQLite database to make simple graphs using matplotlib embedded in a wxPython GUI. I noticed that matplotlib uses lists of integers to make graphs, such as the simple example (from the tutorial) of: from pylab import * plot([1,2,3,4]) show() But SQ

Re: [Tutor] Visual Basic versus Python.. What to choose??

2007-02-20 Thread Asrarahmed Kadri
Thanks a lot for the support... Cheers On 2/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi! With python, you can work with a lot of Database, likes mysql, oracle, sqlite, SQLServer, PostgreSQL If you use Python2.5, sqlite3 is already installed. However, you can choose any da

[Tutor] It lives...

2007-02-20 Thread Kirk Z Bailey
I'm back. Melted my life, got a divorce, gutted the house, acquired true love, 2 cats, redid house, new job, and dentures. Let's see, I still need a total blood change-out, but other than that, I did it all. Now I can start paying attention to python and wiki's again. And this is good, because

Re: [Tutor] Visual Basic versus Python.. What to choose??

2007-02-20 Thread johnf
On Tuesday 20 February 2007 06:49, Don Taylor wrote: > Asrarahmed Kadri wrote: > > I want to develop an application which uses a database and some forms to > > enter/modify the database. > > The application should also generate reports based on some fields. > > > > What should I be using? Python or

Re: [Tutor] Visual Basic versus Python.. What to choose??

2007-02-20 Thread Don Taylor
Asrarahmed Kadri wrote: > I want to develop an application which uses a database and some forms to > enter/modify the database. > The application should also generate reports based on some fields. > > What should I be using? Python or VB... That is both a religious question, and fighting words

Re: [Tutor] Visual Basic versus Python.. What to choose??

2007-02-20 Thread Bob Gailer
Asrarahmed Kadri wrote: > > Hi folks, > > I want to develop an application which uses a database and some forms > to enter/modify the database. > The application should also generate reports based on some fields. > > What should I be using? Python or VB... > > I want to use Python.. IN that

Re: [Tutor] Visual Basic versus Python.. What to choose??

2007-02-20 Thread carpentier . th
Selon [EMAIL PROTECTED]: > Hi! > > With python, you can work with a lot of Database, likes mysql, oracle, > sqlite, > SQLServer, PostgreSQL > > If you use Python2.5, sqlite3 is already installed. > > However, you can choose any data base which you want to use. > > Thomas > > > Selon Asrarahmed

Re: [Tutor] file.read() doesn't give full contents of compressed files

2007-02-20 Thread Barton David
I see. Thanks for that. dave -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: 20 February 2007 13:30 To: Barton David Cc: tutor@python.org Subject: Re: [Tutor] file.read() doesn't give full contents of compressed files Barton David wrote: > Oh... of course. Thanks

Re: [Tutor] file.read() doesn't give full contents of compressed files

2007-02-20 Thread Kent Johnson
Barton David wrote: > Oh... of course. Thanks and sorry for missing the bleeding obvious. > > Mind you, when reading in 'txt mode' rather than binary, len() actually > gives a much *smaller* size than getsize. Does the conversion into txt > happen to introduce some sort of terminator character tha

Re: [Tutor] file.read() doesn't give full contents of compressed files

2007-02-20 Thread Barton David
Oh... of course. Thanks and sorry for missing the bleeding obvious. Mind you, when reading in 'txt mode' rather than binary, len() actually gives a much *smaller* size than getsize. Does the conversion into txt happen to introduce some sort of terminator character that stops file.read() from going

Re: [Tutor] file.read() doesn't give full contents of compressed files

2007-02-20 Thread Kent Johnson
Barton David wrote: > Hi, > I'm really confused, and I hope somebody can explain this for me... > > I've been playing with compression and archives, and have some .zip, > .tar, .gz and .tgz example files to test my code on. > I can read them using either zipfile, tarfile, gzip or zlib, and that'

[Tutor] file.read() doesn't give full contents of compressed files

2007-02-20 Thread Barton David
Hi, I'm really confused, and I hope somebody can explain this for me... I've been playing with compression and archives, and have some .zip, .tar, .gz and .tgz example files to test my code on. I can read them using either zipfile, tarfile, gzip or zlib, and that's fine. But just reading them in

[Tutor] Visual Basic versus Python.. What to choose??

2007-02-20 Thread Asrarahmed Kadri
Hi folks, I want to develop an application which uses a database and some forms to enter/modify the database. The application should also generate reports based on some fields. What should I be using? Python or VB... I want to use Python.. IN that case, what should be my choice for the Database