Re: triangulation

2005-11-09 Thread Kristian Zoerhoff
On 11/9/05, Shi Mu <[EMAIL PROTECTED]> wrote:
> Delaunay triangulations
>
> On 11/9/05, Robert Kern <[EMAIL PROTECTED]> wrote:
> > Shi Mu wrote:
> > > is there any sample code to triangulation? many thanks!
> >
> > Triangulation of what? Scattered points in a plane? 2D manifolds
> > embedded in a 3D space?
> >
> > Delaunay triangulations? Constrained triangulations?

Googling "delaunay triangulation python" gives this as the first hit:

http://www.python.org/pypi/Delny/0.1.0a2

--
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: odd behavior

2005-11-11 Thread Kristian Zoerhoff
On 11 Nov 2005 11:34:47 -0800, Greg <[EMAIL PROTECTED]> wrote:
> Forgive me, and be kind, as I am just a newby learning this language
> out of M.L. Hetland's book.  The following behavior of 2.4.1 seems very
> strange
> >>> x = ['aardvark', 'abalone', 'acme', 'add',
>  'aerate']
> >>> x.sort(key=len)
> >>> x
> ['add', 'acme', 'aerate', 'abalone', 'aardvark']
> >>> x.sort(reverse=True)
> >>> x
> ['aerate', 'add', 'acme', 'abalone', 'aardvark']
> The function called on line 4, at least to me, should work on x as it
> was on line 3, not the previously existing x on line 1.  What gives?

The key option defaults to an alphabetic sort *every time* you call
sort, so if you want to change this, you must call for your sort key
each time. To do what you want, roll the sorts into one step:

>>> x.sort(key=len, reverse=True)
>>> x
['aardvark', 'abalone', 'aerate', 'acme', 'add']


--
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Print to Windows default Printer

2005-01-20 Thread Kristian Zoerhoff
On Thu, 20 Jan 2005 19:14:10 -, Tim Golden
<[EMAIL PROTECTED]> wrote:
> [Kristian Zoerhoff]
> |
> | On Thu, 20 Jan 2005 18:58:25 -, Tim Golden
> | <[EMAIL PROTECTED]> wrote:
> | >
> | > Can anyone else try a "PRINT blah" or a "COPY blah LPT1:"
> | > on XP SP2?
> |
> | The printer is probably connected via USB, not the parallel port
> | (LPT1), so the above won't work. I googled, and found some sage advice
> | here:
> |
> | http://www.winnetmag.com/Article/ArticleID/39674/39674.html
> |
> | that may assist the OP.
> 
> Ah. I'm so old-fashioned, the idea of a USB printer had
> never occurred to me (I've never used one, in fact).
> 
> Thanks for the info. Did you post back to the list as well?
> 

Whoops. I am now :-)

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Two questions on lambda:

2005-06-24 Thread Kristian Zoerhoff
On 6/24/05, Xavier Décoret <[EMAIL PROTECTED]> wrote:
> 
> For example, the code
> 
> # f = lambda : print "hello"
> # f()
> does not compile, although:
> 
> # def f():
> #   print "hello"
> # f()
> 
> does compile. Is there a particular syntax for lambda that I am missing
> or is it simply limited and I cannot do what I want with lambda.

lambda calls can only include functions; print is a statement, not a
function. Try this instead:

import sys
f = lambda : sys.stdout.writelines("Hello")
f()

However, if you're going to be binding the function to a name, there
is no need to use lambda at all; just def a function and be done with
it.

> In the same spirit, how can I do to compute intermediary values in the
> body of a lambda function. Let's say (dummy example):

I leave this to someone more expert than I.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing to printer

2005-08-11 Thread Kristian Zoerhoff
On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote:
> Hello,
> 
>I'm having problems sending information from a python
> script to a printer. I was wondering if someone might send me
> in the right direction. I wasn't able to find much by Google

Which platform? Directions will vary wildly.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing to printer

2005-08-11 Thread Kristian Zoerhoff
On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote:
> Kristian Zoerhoff wrote:
> 
> > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote:
> >> Hello,
> >>
> >>I'm having problems sending information from a python
> >> script to a printer. I was wondering if someone might send me
> >> in the right direction. I wasn't able to find much by Google
> >
> > Which platform? Directions will vary wildly.
> >
> Ooops, sorry forgot to mention I'm using Suse 9.0 and Python 2.3x

Assuming a local printer, you could just open the appropriate device
file (e.g. /dev/lp0) in write mode and write the text to it. Another
option would be to create a temp file, and then feed that to the lpr
or enscript commands via the subprocess module.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble with time --again

2005-08-30 Thread Kristian Zoerhoff
On 30 Aug 2005 10:42:41 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hey there,
> could someone show me where i am going wrong here?
> 
> >>> date1 = '2005-01-01 8:20:00'
> >>> date1 = strptime('%Y-%m-%d %H:%M:%S',date1)
> 
> raise ValueError("time data did not match format:  data=%s  fmt=%s" %
> ValueError: time data did not match format:  data=%Y-%m-%d%H:%M:%S
> fmt=2005-01-01 8:20:00

Try:

>>> date1 = strptime(date1, '%Y-%m-%d %H:%M:%S')

I think you have the data and format strings swapped.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble with time --again

2005-08-30 Thread Kristian Zoerhoff
On 30 Aug 2005 10:54:29 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> i feel like a complete idiot.

Now don't go and do that. Mistakes happen.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: curious problem with large numbers

2005-04-07 Thread Kristian Zoerhoff
On Apr 7, 2005 3:34 PM, David M. Cooke 
> 
> I don't do Windows, so I can't say this will work, but try
> 
> >>> inf = 1e308*2

I *do* do Windows, and that does work. The value of inf then becomes
'1.#INF' as expected. Strangely, doing

float('1.#INF')

still fails on Windows. Weird, weird.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Kristian Zoerhoff
On 13 Apr 2005 12:06:26 -0400, Roy Smith <[EMAIL PROTECTED]> wrote:
> Scott David Daniels  <[EMAIL PROTECTED]> wrote:
> >If you think those are fun, try base (1j - 1)
> 
> Get real.  I can't imagine using anything so complex.

+1 QOTW

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find the drive in python/cygwin?

2005-04-26 Thread Kristian Zoerhoff
On 26 Apr 2005 11:29:26 -0700, Mayer <[EMAIL PROTECTED]> wrote:
> Hello:
> 
> I'm running python under cygwin and need to find the drive letter.
> Cygwin has a way of calling my drives by a name relative to the Cygwin
> directory, so I get things like /home/user rather than
> /cygdrive/g/cygwin/home/usr, etc. How can I find the letter of the
> drive, or in the above example, the letter 'g'?

Generally, drive N gets mapped to /cygdrive/n/ but you could call the
'mount' command and parse the output to see what drive letter got
assigned to a given path. On my system, mount returns:

$ mount
C:\cygwin\usr\X11R6\lib\X11\fonts on /usr/X11R6/lib/X11/fonts type
system (binmode)
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)
c: on /cygdrive/c type user (binmode,noumount)
d: on /cygdrive/d type user (binmode,noumount)
g: on /cygdrive/g type user (binmode,noumount)
x: on /cygdrive/x type user (binmode,noumount)
z: on /cygdrive/z type user (binmode,noumount)
 
> My program needs to run on an external media that comes with Cygwin on
> it. I have no control over what drive is assigned to that media, but
> for some reason, I do need to know the letter.

Why?

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
--
http://mail.python.org/mailman/listinfo/python-list


Fwd: how to find the drive in python/cygwin?

2005-04-26 Thread Kristian Zoerhoff
Forwarding to list, as you forgot to Reply-all (Don't worry, we all do
it at least once!).

-- Forwarded message --
From: Mayer Goldberg <[EMAIL PROTECTED]>
Date: Apr 26, 2005 3:01 PM
Subject: Re: how to find the drive in python/cygwin?
To: Kristian Zoerhoff <[EMAIL PROTECTED]>


Dear Kristian:

Thanks for the very fast reply! I wasn't thinking of the mount command
-- this is really the correct way to think about my problem.

>>My program needs to run on an external media that comes with Cygwin on
>>it. I have no control over what drive is assigned to that media, but
>>for some reason, I do need to know the letter.
>
> Why?

Basically this has to do with moving around: I use different computers
throughout the day, and need to carry with me a sane and productive
computing environment. Rebooting to linux is not an option for me, so I
need a Windows solution. I found it in the form of a 40G pocket hard
drive with a USB connection. I plug in the connection, go to my software
subdirectory and run what I need. I have a mixture of Unix and Windows
programs, and often I have to run a Windows program instead of a unix
program (for example, I run miktex instead of the tetex that comes with
cygwin). The Windows utilities need to be passed arguments in DOS
format, i.e., something like G:\FOO\foo.dll. Cygwin is only one specific
application I use, so I didn't install everything under the / (which
would have solved many problems for me!). As a result, I need to know
the drive letter.

Thanks again,

Mayer


-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: trouble with lists

2005-05-03 Thread Kristian Zoerhoff
On 3 May 2005 10:42:43 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I'm new to python. I tried doing this
> 
> >>> x = [[]] * 3
> >>> print x
> [ [] [] [] ]
> >>> x[0].append( 2 )
> [ [2] [2] [2] ]
> 
> I confused with the last line output. I actually expected something
> like
> 
> [ [2] [] [] ]

I think you want

>>> x[0] = [2]

But I have no idea why you're using nested lists in this case ([2] is
a one-item-long list, so x is actually a list of lists here). Are you
sure this is really what you want?

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble with lists

2005-05-03 Thread Kristian Zoerhoff
On 5/3/05, Anand Kumar <[EMAIL PROTECTED]> wrote:
> 
> I am actually trying to mimic a multi dimensional array in C.
> I tried doing things like

Python lists are not arrays in that sense. If you really want an
array, you probably want Numeric or Numarray. Head over to
http://numeric.scipy.org/ to take a look.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread Kristian Zoerhoff
On 1 Jun 2005 09:41:53 -0700, infidel <[EMAIL PROTECTED]> wrote:
> Why in the name of all that is holy and just would you need to do such
> a thing?

Is anyone else amused that this came from the mouth of someone named "Infidel"?

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list