1 May 2002 05:31

### Re: more newbie questions

```
>
>def combo(n, r=None):
>         if r is None: r = int(n/2)
>         assert 0 <= r <= n, "r must be between 0 and n"
>         return int(fact(n,r)/fact(r))

Check this post by Tim Peters (archives, edu-sig) for
an optimized version of combo:

http://aspn.activestate.com/ASPN/Mail/Message/580860

Kirby

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

```
1 May 2002 15:39

### Re: more newbie questions

```Thanks.  An interesting read.

I think Python2.2 helps greatly on the overflow front. int * int will
now return a long when necessary.  Converting a float to a non-float
still seems to require a test (that I omitted) to choose between long
and int.

Kirby Urner wrote:

>
>>
>> def combo(n, r=None):
>>         if r is None: r = int(n/2)
>>         assert 0 <= r <= n, "r must be between 0 and n"
>>         return int(fact(n,r)/fact(r))
>
>
> Check this post by Tim Peters (archives, edu-sig) for
> an optimized version of combo:
>
> http://aspn.activestate.com/ASPN/Mail/Message/580860
>
> Kirby
>
>

--

--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
```

1 May 2002 18:03

### Re: HP preinstalled Python!

```I'm a computer tech, and I've worked on three new HP's in the last few
weeks. All three had python 1.5 preinstalled. No links to the program on the
start menu, and python wasn't in the path, but it was there, and listed in
add/remove programs on two of them.

----- Original Message -----
From: Lance E Sloan <lsloan <at> umich.edu>
To: <tutor <at> python.org>
Sent: Sunday, April 28, 2002 12:31 PM
Subject: [Tutor] HP preinstalled Python!

> This weekend, my wife and I finally gave in and bought a Windows computer.
Well, we've had one before, but we mostly used Macs and I use UNIX a lot.
This is our first purchase of a brand-new, semi-beefy Windows computer.  My
wife wanted it to run certain programs that were only available for Windows
and I figured it's best to "know thy enemy".  So we bought an HP Pavilion
531w.  It's not the most powerful machine, but good enough.
>
> So, as I was installing various apps, I discovered that in the "Program
Files" directory, there is a Python directory.  And there was also a TCL
directory.  Both of them apparently have working versions of those
I figure that among the other third-party programs HP installed, there must
be one that uses Python, probably with Tkinter.
>
> Has anybody else noticed this on new HP computers?
>
> --
> Lance E Sloan
> Web Services, Univ. of Michigan: Full-service Web and database design,
```

1 May 2002 18:06

### Re: HP preinstalled Python!

```A google.com search for "HP Python" and a search at hp.com for "Python"
indicate that HP has taken more than a casual interest in Python.

Rob
http://uselesspython.com

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

```
1 May 2002 18:39

### RE: newbie with some basic questions

```Sorry if this is answered I'm playing catch up on
the digests(again!)

> im a total newbie to both programming and python (well i can write a
> decent shell script...).

So I'll assume you are on *nix...

> just a few questions, most important one first:
> 1.whats better for a newbie like myself, learning python or
> core python programming? or any other recommendations?

If you can do non trivial shell scripts then either is fine.
If you are only doing basic shell scripts then I'd go with
Core Python or maybe quick Python. (Or even my book!

> 2.how can i make input take only one character and not requrie a CR?

You can't. You need curses.getch()

> 3.i have a simple list of lists for example: people =
> [["A","john","12345"],["B","joe","1231234"],["X","sally","1234"]]
> and i need to do something like:
> some_variable = X
> new_variable = people[*][0]
> that is, find the corresponding list with the list that has [0] = X
>
> i could use a dictionary like {"X":["sally","1234"]} but is there a
> better way to do it?

```

1 May 2002 18:49

### RE: more newbie questions

```> 1. how to simply clear the screen?

Clearing a screen is never simple since like any console
specific thing(like reading a character without hitting ENTER)

On DOS the easiest thing is probably:

os.system('CLS')

on *nix:

os.system('clear')

There will also be escape codes that you can use but they
are terminal specific - my old Wyse terminal was ESC J ESC H
I dunno what a vt100/vt200 sequence is...

Or generically on *nix I think there is a clrscr() call
in curses.

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld

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

```

1 May 2002 18:56

### RE: Multifunction mapping

```> I have a sequence of characters  (a,b,c,d,e,f,g,h,i)
I assume they are meant to have quotes around them?
Otherwise they are a list of variables!

> (61,62,63,64,65,66,67,68,69)
OK
> (061,062,063,064,065,066,067,068,069)
and these must be strings since the leading
zero has no significance for an int...?

> (061062063064065066067068069)
And this is one big string...?

def fixChar(c):
s = ord(c)
s = '0%d' % i  #get string
return s

string.join(map(fixChar, letters))

Something like that - sorry no python to test it...

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld

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

```

1 May 2002 19:01

### Re: Multifunction mapping

```On  0, alan.gauld <at> bt.com wrote:
> > (061,062,063,064,065,066,067,068,069)
> and these must be strings since the leading
> zero has no significance for an int...?

If only that were true.

Python still has the moronic syntax from the C world, where a literal with a
leading 0 is considered to be in octal (which sometimes leads to weird bugs).

>>> 067
55

067 is 6*8+7 = 55, while 068 is actually a syntax error.

But I think he meant strings, yes.

--

--
Remco Gerlich

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

```
1 May 2002 16:13

### Re: more newbie questions

```On Wednesday 01 May 2002 09:39 am, Lloyd Kvam wrote:
>
> I think Python2.2 helps greatly on the overflow front. int * int will
> now return a long when necessary.

True.

Another aspect of Tim's approach which makes it faster is
it doesn't allow the factorial in the numerator to build up
so high before dividing.  It's a more divide-as-you-go
approach that potentialy avoids a huge long/long at the end.

Kirby

> > Check this post by Tim Peters (archives, edu-sig) for
> > an optimized version of combo:
> >
> > http://aspn.activestate.com/ASPN/Mail/Message/580860

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

```
2 May 2002 00:32

### Re: Printable versions of "What's new" documents?

```On Apr 30 2002, Alexandre Ratti wrote:
> I just uploaded them to:
>
>         http://alexandre.ratti.free.fr/python/docs/

Hi, Alexandre.

Thank you very much for putting the documents on your site. I
brief skimming, they seem to be a very useful aid in learning
more about Python, as I thought earlier.

Thank you very much, Roger...

--

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rogério Brito - rbrito <at> iname.com - http://www.ime.usp.br/~rbrito/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

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

```

Gmane