alan.gauld | 1 Jul 01:06 2002

RE: Matrix class problems

>     Firstly, I would like to know what exactly repr() does. I read the
> docs, and this is what I got :
> ...
> Return the canonical string representation of the object.
> For most object types, eval(repr(object)) == object.
> """
> 
> What does this mean and how is this different from str() ?

repr is a pythonic representation of an object as a string.
str is a human readable version.

You can see the difference at the prompt by typing values 
with and without the print command:

>>> print 5   # uses str()
5
>>> 5         # uses repr()
5
>>>  # the above are identical
>>> s = "Hello world"
>>> print s
Hello world
>>> s
"Hello world"
>>> # notice repr added qutes whereas str didn't

Coming back to the doc string comment consider what 
happens with eval:

(Continue reading)

Kalle Svensson | 1 Jul 02:09 2002
Picon
Picon
Picon

[OT] TECO and Emacs (Was: pair programming.)


[alan.gauld <at> bt.com]
> > The biggest problem with modality in vi*'s is that you may be in
> > command mode but think you're in insert and type some stuff which
> > will garble your text in a scary random-looking manner. 
> 
> > I myself never found this to be much of a problem, but I know some
> > people do..
> 
> Those folks obviously never used Tico... ;-)
> 
> The standard programmers game in Tico was to type your name and 
> try to guess what the effect would be on your code(*)! The only good 
> thing I can say about Tico is that it was so bad it drove 
> James Gosling to invent the original Emacs!

I think you mean TECO.  Also, Gosling didn't write the first Emacs.
Richard M. Stallman did that, merging two existing TECO macro
packages.  Gosling wrote the first implementation of Emacs in C.

Peace,
  Kalle
--

-- 
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
Andrei Kulakov | 1 Jul 09:13 2002

random distribution question

Hello tutors,

I have a tough and interesting problem here, I think..

In my player cymbaline, each track has a score from 0 to 100; tracks
with high scores play more often in random mode. There is a setting
called random slope that dictates just how much more often they play.

Here's how it was implemented until now:

runs = 0
while 1:
    n = -5
    for i in range(slope):
	n = random.randrange(n, 101)
    track = random.choice(rand_list)
    if track.score >= n or runs > 50:
	break
    runs += 1

slope was an int from 1 to 5. The higher it is, more likely would
high-scored tracks play, but I'm not too sure just how much more
likely..

Now I'm re-hauling all of the code (most of it is 1-2 years old).

Here's what I came up with:

import random, operator
slope = 1
(Continue reading)

Christopher Smith | 1 Jul 15:11 2002

Re: Matrix class problems

>[Tutor] Matrix class problems
>
>Hi,
>
>    I have recently got back to exploring python, and, being a Maths
>student, I decided to test my skills on a simple Matrix class. Now, I
>came across some questions which I hope you will help clear.
<cut>
>
>Also, I wrote a __mul__() function, which looks like so :
>
>"""
>    def __mul__ (self, other) :
>        if type(other) == type(0) :
>            return self._scalar_multiply(other)
>        else :
>            return self._matrix_multiply(other)
>"""
>
<cut>
>
>>>> print (m*2) 
>[ 2, 0, 0 ]
>[ 0, 2, 0 ]
>[ 0, 0, 2 ]
>>>> print (2*m) 
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>TypeError: unsupported operand type(s) for *: 'int' and 'instance'
>
(Continue reading)

Terje Johan Abrahamsen | 1 Jul 16:52 2002
Picon

Re: Dictionaries [lists]

Hello and thank you so much,

    I got it up and running now. This would probably have taken me just 
about forever before I had been able to figure it out by myself....

Have a great day,
Terje

>From: "Gregor Lingl" <glingl <at> aon.at>
>To: "Danny Yoo" <dyoo <at> hkn.eecs.berkeley.edu>,"Terje Johan Abrahamsen" 
><terjeja <at> hotmail.com>
>CC: <tutor <at> python.org>
>Subject: Re: [Tutor] Dictionaries    [lists]
>Date: Sat, 29 Jun 2002 10:24:08 +0200
>
>
>----- Original Message -----
>From: "Danny Yoo" <dyoo <at> hkn.eecs.berkeley.edu>
>To: "Terje Johan Abrahamsen" <terjeja <at> hotmail.com>
>Cc: <tutor <at> python.org>
>
>I'll post below one small correction of a type in Danny's explanation
>- and a slightly different version of his code. Therefore do also
>
> > Skip if you don't want to be spoiled.  *grin*
> >
> > *** Spoiler space ahead ***
> >
> >
> >
(Continue reading)

shendric | 1 Jul 18:29 2002
Picon

Mac and Tkinter

Hi all,

Are there any MacPython folks out there who might have tried to use 
Tkinter?  I'm primarily a Windows programmer, but I wanted to make a Mac 
version of a little application I wrote.  It involves Tkinter, but when 
I try to run the program, it tells me that "Tkinter not supported under 
Carbon (yet)".  I've heard of Carbon, but I've no experience with it.  
Does anyone have any suggestions for places I should look for more 
information on this issue?  I've been to the MacPython page, but still 
no luck.  I'm probably looking in the wrong places.

Sean

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Scott Comboni | 1 Jul 17:42 2002

Re: Progress Bar Help.

Thanks I will take a look.
Scott

On Fri, 2002-06-28 at 17:18, Marc wrote:
> Scott Comboni (scott <at> zenplex.com) wrote:
> 
> > I recently wrote a simple python script to install a bunch of software
> > apps and would like to jazz it up with some sort of graphical progress
> > bar.  Is there some URL someone can point me too to get some ideas on
> > how to code/create something like this?
> 
> You may find this module useful:
> http://www.chrisarndt.de/software/python/#xdialog
> 
> It's a wrapper for the great Xdialog program ,that, among other
> things, have a progress bar example.
> Hope that helps.
> 
> -- 
> I SeE NeRD pEoPle.
> .:: MarcoLinux ::.
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
--

-- 
_________

_______________________________________________
(Continue reading)

Danny Yoo | 1 Jul 18:51 2002
Picon

Re: Dictionaries [lists]


On Mon, 1 Jul 2002, Terje Johan Abrahamsen wrote:

> I got it up and running now. This would probably have taken me just
> about forever before I had been able to figure it out by myself....

I'm glad it works now!

If you want to look at this problem more, you can pick up any CS textbook
on the topic of "change-making".  Change-making is the problem of trying
to make change out of an unlimited number of quarters, dimes, nickels, and
pennies --- it's a "classic" problem that CS students hear about when
they're introducted to dynamic programming.

Here's one link that talks about the problem:

http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_idx_728

What you were working on is almost exactly like change-making, except that
we're using a limited number of coins.

Best of wishes to you!

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Danny Yoo | 1 Jul 19:03 2002
Picon

Re: Mac and Tkinter


On Mon, 1 Jul 2002 shendric <at> arches.uga.edu wrote:

> Are there any MacPython folks out there who might have tried to use
> Tkinter?  I'm primarily a Windows programmer, but I wanted to make a Mac
> version of a little application I wrote.  It involves Tkinter, but when
> I try to run the program, it tells me that "Tkinter not supported under
> Carbon (yet)".  I've heard of Carbon, but I've no experience with it.
> Does anyone have any suggestions for places I should look for more
> information on this issue?  I've been to the MacPython page, but still
> no luck.  I'm probably looking in the wrong places.

Hi Sean,

I'm not too familiar with Mac OS X either, but I think that Carbon is a
compatibility layer to make it easy to port older, OS 9-based programs.

I did a quick look on the "pythonmac" Special Interest Group, and Tony
Lownds's packaging of Python 2.2 appears to have native Tkinter working!

    http://tony.lownds.com/macosx/
    http://sourceforge.net/project/showfiles.php?group_id=10894

It's still experimental, so you might run into a few snags, but it sounds
like it works.  Hey, there's one more reason to try out a Mac.  *grin*


You may want to subscribe to pythonmac-sig and ask your question there
too; they're probably much more knowledgable about this.  Here's a link to
their mailing list:
(Continue reading)

alan.gauld | 1 Jul 19:09 2002

RE: drag-and-drop argument passing

 > Now, there is only one thing left in my way, but it is very vexing.  
 
>  I don't know how to generate raw strings on the fly.  
>  For example: this path would choke my script,  
>  because "\f" is a token: 
>  >>> "c:\ftp\test.txt" 
 
So use forward slashes Unix style.
 
If reading from a user raw_input will correctly escape
the backslashes for you:
 
C:\\ftp\\test.txt
 
 >   But how do I turn a string in a list, like sys.argv[], into a raw string?  
 >  for path in sys.argv[1:]:
 >       make_raw(path) 
 
Aha! Good example. Tricky that one, I don't know!
 
I look forward to seeing an answer.
 
Alan G

Gmane