No longer required.


----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <tutor@python.org>
Sent: Wednesday, December 29, 2004 6:00 AM
Subject: Tutor Digest, Vol 10, Issue 105



Send Tutor mailing list submissions to tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

You can reach the person managing the list at
[EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

  1. Re: Re: Soem list operation questions? (Orri Ganel)
  2. Re: Soem list operation questions? (Roel Schroeven)
  3. Re: Re: Soem list operation questions? (Karl Pfl?sterer )
  4. Re: Soem list operation questions? (Roel Schroeven)
  5. Re: Output to a printer (Alan Gauld)
  6. Using the ? symbol (David Holland)
  7. Re: O.T. (Liam Clarke)
  8. Re: networking (Bill Burns)


----------------------------------------------------------------------

Message: 1
Date: Tue, 28 Dec 2004 13:48:29 -0500
From: Orri Ganel <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Re: Soem list operation questions?
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII

Karl,
The ''.join() method was the first one suggested. Roel then suggested
a math-based method, which I attempted to improve upon.

--
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.


------------------------------

Message: 2
Date: Tue, 28 Dec 2004 20:27:29 +0100
From: Roel Schroeven <[EMAIL PROTECTED]>
Subject: [Tutor] Re: Soem list operation questions?
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Karl Pfldsterer wrote:
Sorry but IMO the above is too much complicated for such a simple task.

That depends on your point of view, I think; I find it conceptually at least as easy only to think in terms of numbers when both input and output are numbers. Our assumptions are different too: I assume the input consists of digits and the output is an integer, you allow for bigger numbers as input and assume the output is a string.

Either convert the digits to a string and concatenate them with:

def intlist_to_string (lst):
    return ''.join(map(str, lst))

As Orri said, other posts already showed that approach. I just wanted to point out an alternative.

The first solution is IMO clear.  It's also the fastest solution.  If
you time the functions you will see that if intlist_to_string needs 1
second intlist_to_string_red needs 2.3 seconds and your solution
listtoint needs 3.5 seconds.

Depends.

import timeit
def time_it (funs, num=1000):
    for fun in funs:
        call = '%s(range(100))' % fun
        imp = 'from __main__ import %s' % fun
        t = timeit.Timer(call, imp)
        print call
        print t.timeit(number=num)
        print '*'*50

I changed it somewhat, to make it work according to my (admittely possibly wrong) assumptions:

def time_it(funs, num=1000):
    for fun in funs:
        call = '%s(range(1,10)*10)' % fun
        imp = 'from __main__ import %s' % fun
        t = timeit.Timer(call, imp)
        print call
        print t.timeit(number=num)
        print '*'*50

and I used my version, without Orri's adaption to allow for non-digit
inputs.

I also changed your function to make it return an int instead of a
string, and ran it like:

time_it(('intlist_to_int', 'listtoint'), num=10000)

intlist_to_int(range(1,10)*10)
1.02976551489
**************************************************
listtoint(range(1,10)*10)
0.929201057676
**************************************************

Not that much difference, but mine seems to be somewhat faster in that
case. I guess it's because yours need (after I made it return an int,
assuming that's what kilovh wanted) to convert the string back to an
int. The algorithm to do that looks a lot like my function.

With Orri's adaption, listtoint slows down a lot, which explains your
results. I think different approaches are possible, and which one is
best depends on the circumstances.

Karl Pfldsterer wrote:
> Please do *not* send copies of replies to me.
> I read the list

I agree, but I got a copy of your reply in my inbox. Either gmane.org
screwed up or you inadvertently cc-ed me.

--
"Codito ergo sum"
Roel Schroeven



------------------------------

Message: 3
Date: Tue, 28 Dec 2004 21:29:46 +0100
From: [EMAIL PROTECTED] (Karl Pfl?sterer )
Subject: Re: [Tutor] Re: Soem list operation questions?
To: Orri Ganel <[EMAIL PROTECTED]>
Cc: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

On 28 Dez 2004, [EMAIL PROTECTED] wrote:

Karl,
The ''.join() method was the first one suggested. Roel then suggested
a math-based method, which I attempted to improve upon.

I know. I read it all; ''.join() was suggested together with a list comprehension (in such simple situations map() is IMO nicer to read so I used that).

'.join(...) is for that problem a perfekt solution: it's short, easy to
read and understand and scales well.  Why searching for a more
complicated solution if such a good one exists?  It may be a nice
lecture but then you should put a big exclamation mark near it, so
Python beginners (we are on a Tutor list) do not pick up wrong habits.



  Karl
--
Please do *not* send copies of replies to me.
I read the list



------------------------------

Message: 4
Date: Tue, 28 Dec 2004 21:52:58 +0100
From: Roel Schroeven <[EMAIL PROTECTED]>
Subject: [Tutor] Re: Soem list operation questions?
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Karl Pfldsterer wrote:
Why searching for a more complicated solution if such a good one
exists?  It may be a nice lecture but then you should put a big
exclamation mark near it, so Python beginners (we are on a Tutor
list) do not pick up wrong habits.

I guess you have a point there.

--
"Codito ergo sum"
Roel Schroeven



------------------------------

Message: 5
Date: Tue, 28 Dec 2004 22:09:15 -0000
From: "Alan Gauld" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Output to a printer
To: "Luc Saffre" <[EMAIL PROTECTED]>, "Alan Gauld"
<[EMAIL PROTECTED]>
Cc: Bob Fleming <[EMAIL PROTECTED]>, tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Hi Luc,

I'm interested.
Does it handle more than plain text - although even that would be
good!

I wrote a module that permits something like:

   d = Win32PrinterDocument(printerName,spoolFile)
   f = file(inputfile)
   for line in f.readlines():
      d.PrintLine(line.rstrip())
   d.endDoc()

Output will go to the specified Windows printer. Unfortunately I'll
need
some time to make it ready for the public. Tell me if you are
interested.

I was going to try doing something similar (if I ever get time!)
using the WSH objects. What approach are you taking? It looks
(from the EndDoc reference) that you are using the native GDI?

Alan G.



------------------------------

Message: 6
Date: Tue, 28 Dec 2004 22:21:22 +0000 (GMT)
From: David Holland <[EMAIL PROTECTED]>
Subject: [Tutor] Using the ? symbol
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=iso-8859-1

I am trying to use a program that usea s '#' symbolon
the pygame screen and I get this message :-
'sys:1: DeprecationWarning: Non-ASCII character '\xc2'
in file birdgame29e.py on line 88, but no encoding
declared; see http://www.python.org/peps/pep-0263.html
for details
line 86
'

Now I did look that however I am not sure a) how to do
this and b) what encoding to use.  Can anyone help ?





___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com



------------------------------

Message: 7
Date: Wed, 29 Dec 2004 16:23:43 +1300
From: Liam Clarke <[EMAIL PROTECTED]>
Subject: Re: [Tutor] O.T.
To: Tutor <tutor@python.org>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII

I'm 23, married, 3 month old son, employed in New Zealand's social
welfare department, in a totally non IT role, learning Python purely
out of personal interest and a desire to stop working for New
Zealand's social welfare department someday.

I too climb mountains, having previously been based in a village of 50
people deep in the Southern Alps. I can't ski.


On Tue, 28 Dec 2004 09:10:58 -0700, Bob Gailer <[EMAIL PROTECTED]> wrote:
I'm 64. Degrees in EE and MDiv. Career a mixture of engineering, computers,
minister, teacher, ....
Just started a new romantic relationship!
Programmed in more languages than I care to recall. The more
interesting/arcane include
IBM 650: machine language (my first), SOAP, CLASSMATE
GE 415: FORTRAN, Assembler
Singer 10: Assembler, Machine language
PDP 8: FOCAL
PL/I, APL, 370 Assembler and Machine language
Motorola 8080? Assembler and Machine language
CMS Pipelines
And finally Python. Sorta like discovering APL. And I have some desire to
integrate some APL features into Python. Anyone else want to join me in
that effort?


Hot topics for me: African Marimba Music (I teach it, design & build
instruments). I'm also a DJ on public radio for African Music, as well as a
talk show host.
Nonviolent Communication as taught by Marshall Rosenberg. A most
life-transforming process! I highly recommend it. www.cnvc.org.


Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.



------------------------------

Message: 8
Date: Tue, 28 Dec 2004 23:15:05 -0500
From: Bill Burns <[EMAIL PROTECTED]>
Subject: Re: [Tutor] networking
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain;  charset="iso-8859-1"

On Monday 27 December 2004 4:22 pm, Marco wrote:
Hi python tutors,
Im interested on learning python but i would like to focus in a specific
topic, networking, where can i find documention networking in python?
sockets and all that stuff? i looked for some information but all of them
were just vague. thanks in advance,
Marco

Hi Marco,

You may want to take a look at Pyro which you can find here:
http://pyro.sourceforge.net/

And you can find the mailing-list here:
http://lists.sourceforge.net/lists/listinfo/pyro-core

I've downloaded & installed it but I've not had a chance to try it out yet.

HTH

Bill


------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 10, Issue 105
**************************************



_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to