Re: Windows GUIs from Python

2005-01-12 Thread Jon Perez
Still, what I think would appeal to a lot of people
(although they might not know it yet) as a GUI solution
for Python is Mozilla XUL with all the RDF and XPCOM
crap surgically removed from it.
If you've ever tried a couple of basic XUL tutorials, I
think you would be convinced that XUL is an even better
way to develop GUIs than visual RAD tools.
After years of doing web apps, I feel the DHTML/DOM
approach as applied to GUI creation is superior in terms
of learning curve, productivity and ease of code maintenance
to imperative language, event-driven, IDE-coupled frameworks
like Delphi, Windows Forms or Swing... except for the fact
that the HTML widgets (if you could even call them that) are
very primitive.
XUL essentially gives you full fledged GUI widgets and
allows you to script them from Javascript the same way
you script HTML elements via DOM or DHTML (very easily,
in other words).  Now, imagine being able to use Python
instead of Javascript... sounds like a match made in
heaven to me.
Unfortunately, the Mozilla developers are too enamoured
with Javascript and RDF and XPCOM to realize that
XUL (which is really shaping up beautifully if you look
at Firefox and Thunderbird) is the real star in their
stable and many people would like to use it without being
forced to deal with the other complicated, overengineered
technologies surrounding it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: complex numbers

2005-01-12 Thread Antoon Pardon
Op 2005-01-12, It's me schreef <[EMAIL PROTECTED]>:
>
> "Robert Kern" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>>
>> That's *it*.
>
> So, how would you overload an operator to do:
>
> With native complex support:
>
> def  twice(a):
> return 2*a
>
> print twice(3+4j), twice(2), twice("abc")
>
> Let's presume for a moment that complex is *not* a native data type in
> Python.  How would we implement the above - cleanly?


I suppose in the same way as (graphic) points and vectors can be
implemented cleanly.

A few years back I had written a Vector class in python, just
to get an understanding of how things worked. It worked without
a problem with your twice function.


>>> Vec(1.0,2.0)
Vector[1.0, 2.0]
>>> def twice(a):
...   return 2 * a
... 
>>> twice(Vec(1.0,2.0))
Vector[2.0, 4.0]
>>>


I suppose what can be done with a vector class could have been
done with a complex class should complex numbers not have been
native to python.

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wide Unicode build for Windows available somewhere?

2005-01-12 Thread "Martin v. Löwis"
[EMAIL PROTECTED] wrote:
I am trying to locate a windows binary of a recent python (2.4
preferred, but not essential) with support for Unicode characters
with values greater than 0x1. I have tested the python.org
binaries and those from Activestate, both give me a traceback on
unichr(0x1) and tell me its a "narrow" build.
Wide unicode is currently not supported on Windows. A number of
internal APIs (in particular for the registry, and for the "mbcs"
codec) assume that sizeof(Py_UNICODE) is 2. Contributions are
welcome.
Even with that fixed, Pythonwin would still need a major rework
to support wide Unicode.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread Jon Perez
This would be funny except for the fact that there are
actually people out there who will take this seriously.
http://rmitz.org/freebsd.daemon.html
Don't forget Python == Snake == Serpent == ...
;-D

[EMAIL PROTECTED] wrote:
> python.org = 194.109.137.226
>
> 194 + 109 + 137 + 226 = 666
>
> What is this website with such a demonic name and IP address?  What
> evils are the programmers who use this language up to?
--
http://mail.python.org/mailman/listinfo/python-list


Re: 20050111: list basics

2005-01-12 Thread Abigail
Xah Lee ([EMAIL PROTECTED]) wrote on CLII September MCMXCIII in
news:[EMAIL PROTECTED]>:
::  
::  # in perl, list is done with paren ().

Wrong. Except in a few cases, parens don't make lists. Parens are
used from precedence. *Context* makes lists.

::  # the at sign in front of variable is necessary.

The at sign in front of a variable means the variable is an array.
Arrays are *NOT* lists.

::  # it tells perl that it is a list.
::  @a = (0,1,2,'three',4,5,6,7,8,9);
::  
::  # perl can't print lists. To show a list content,
::  # load the package Data::Dumper, e.g.
::  use Data::Dumper;
::  print '@a is:', Dumper([EMAIL PROTECTED]);

Utter bullshit. Perl's print statement has no problem accepting a
list. In fact, YOUR EXAMPLE PASSES A LIST to print. But this works
fine too:

@a = ('Xah ', 'Lee ', 'does ', 'not ', 'know ', 'Perl');
print @a;
__END__
Xah Lee does not know Perl

::  # the backslash in front of @a is to tell Perl
::  # that "get the "address" of the "array" @a".

Wrong. Perl is not C. You get a reference, not a pointer.

::  # it is necessary in Dumper because Dumper is
::  # a function that takes a memory address.

Wrong. Perl functions don't take memory addresses. Perl doesn't allow
the programmer to do direct memory access.

::  # see perldoc -t Data::Dumper for the intricacies
::  # of the module.

Please do so yourself.

::  # to join two lists, just enclose them with ()
::  @b = (3,4);
::  @c = (@a,@b);
::  print '[EMAIL PROTECTED] is', Dumper [EMAIL PROTECTED];
::  # note: this does not create nested list.

There is no such thing as "nested lists". 

::  # to extrat list element, append with [index]
::  # the index can be multiple for multiple elements
::  @b = @a[3,1,5];
::  print Dumper [EMAIL PROTECTED];

Why are you printing to the Dumper filehandle?

::  # to replace parts, do
::  $a[3]= 333;
::  print ' is', Dumper [EMAIL PROTECTED];
::  # note the dollar sign.
::  # this tells Perl that this data is a scalar
::  # as opposed to a multiple.
::  # in perl, variable of scalars such as numbers and strings
::  # starts with a dollar sign, while arrays (lists) starts with

Again, arrays are NOT lists.

::  # a at @ sign. (and harshes/dictionaries starts with %)
::  # all perl variables must start with one of $,@,%.

Or *, or &. And some variables don't have a sigil in front of them.

::  # one creates nested list  by
::  # embedding the memory address into the parent list
::  @a=(1,2,3);
::  @b = (4,5, [EMAIL PROTECTED], 7);
::  print 'nested list is', Dumper [EMAIL PROTECTED];

Rubbish. That's not a nested list. @b is an *ARRAY*, whose third element
is a *REFERENCE* to another *ARRAY*.

::  # to extrat element from nested list,
::  $c = $b[2]->[1];
::  print '$b[2]=>[1] is', $c;
::  
::  # the syntax of nested lists in perl is quite arty, see
::  # perldoc -t perldata
::  Xah


Please Xah, do the Perl and Python communities a favour, and stop posting
bullshit.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
 BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.spawnv & stdin trouble

2005-01-12 Thread Denis S. Otkidach
On Tue, 11 Jan 2005 19:08:01 +0100
"Jelle Feringa // EZCT / Paris" <[EMAIL PROTECTED]> wrote:

> Using the subprocess module, but still not making any real progress...
> I'm trying to make the examples given in the __doc__ work, without any
> success I'm afraid, have you had more luck with it?
[...]
> p = Popen("xform" + " -t 0 8 0 wallo.rad", stdout=PIPE,
> shell=True).communicate()[0]
> p.stdout
> 
> p = Popen("dir" + " /w", stdout=PIPE, shell=True).communicate()[0]
> p.stdout

If you want passing parameters via shell (shell=True), than just use
os.system.  Nevertheless below is correct example of subprocess usage
with stdout redirected to file:

out_fp = open('wall0.TRANS.rad', 'wb')
subprocess.call(['c:\\Radiance\\bin\\xform.exe',
 '-t', '0', '8', '0', 'wallo.rad'],
stdout=out_fp)

-- 
Denis S. Otkidach
http://www.python.ru/  [ru]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The best way to do web apps with Python?

2005-01-12 Thread Ian Bicking
Paul Rubin wrote:
Steve Holden <[EMAIL PROTECTED]> writes:
You can read about it in Philip Eby's excellent PEP at
  http://www.python.org/peps/pep-0333.html

I looked at this and I have the impression that it tries to do
something worthwhile, but I can't tell precisely what.  The "rationale
and goals" section explains good reasons why it doesn't do various
certain things.  What's not explained is what DOES it do.  The only
thing I can tell is that it connects to an abstracted web server, and
builds up what looks like traditional CGI variables from the incoming
requests.
It's really meant for web framework developers (as opposed to web 
application developers, who use web frameworks).  Of course it's a fuzzy 
line, and people cross back and forth, especially since most all of it 
is open source.

So basically it is what you were thinking -- it's a way to connect a web 
server to a web application, for any server or application, including 
current servers and applications (not just ones that are developed in 
the future).  It can be a bit more interesting when you delve into 
middleware, which are programs that modify the request before handing it 
off to another application.  But while that opens up interesting 
possibilities (I've used that technique a fair amount in WSGIKit: 
http://svn.colorstudy.com/trunk/WSGIKit/ ), but it's not incredibly magical.

Mostly, it's the first forward movement we've had in a very long time, 
even if the movement isn't huge.  It provides a foundation for further 
standardization.

WSGI compliance also has some other potential benefits, like encouraging 
environment decoupling, and making mock requests easier to produce and 
responses easier to consume.  But those are somewhat vague side effects.

--
Ian Bicking  /  [EMAIL PROTECTED]  / http://blog.ianbicking.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Architecture of Python" was removed ?

2005-01-12 Thread Gerrit Muller
Nick Coghlan wrote:
cr999 wrote:
I found the "Architecture of Python" (
http://wiki.cs.uiuc.edu/cs427/PYTHON By Jim Jackson, Kar-Han Tan
)is very useful for my understanding of the Python's architecture.
But I found the link is not link to that document today. It seems
that the document was removed. Who knows what happened?
Does anyone here have a copy of that document? Or who can tell me
what is the email address of Jim Jackson or Kar-Han Tan.

http://web.archive.org/web/2003101953/http://wiki.cs.uiuc.edu/cs427/PYTHON
Cheers, Nick.
This is again a nice document, and an example of a document that 
presumably has been removed because of maintenance reasons. Shouldn't we 
have a collection (archive) of these documents at python.org?

kind regards, Gerrit
--
Gaudi systems architecting:

--
http://mail.python.org/mailman/listinfo/python-list


Re: tuples vs lists

2005-01-12 Thread Antoon Pardon
Op 2005-01-11, Reinhold Birkenfeld schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Op 2005-01-10, Bruno Desthuilliers schreef <[EMAIL PROTECTED]>:
>>> Antoon Pardon a écrit :
 Op 2005-01-08, Bruno Desthuilliers schreef <[EMAIL PROTECTED]>:
 
>worzel a écrit :
>
>>I get what the difference is between a tuple and a list, but why would I 
>>ever care about the tuple's immuutability?
>
>Because, from a purely pratical POV, only an immutable object can be 
>used as kay in a dict.
>>>
>>> s/kay/key/ 
>>>
 This is not true.
>>>
>>> Chapter and verse, please ?
>> 
>> I don't need chapter and verse. I have already used mutable
>> objects as keys and it works just fine.
>> 
> class hlst(list):
>  
>  def __hash__(self):
>sum = 0
>for el in self:
>  sum += hash(el)
>return sum % 0x3777
>
>
> Given this hash function, how do you handle changed keys?

I don't change keys. The fact that I like to use a mutable
as a key doesn't imply I want to mutate a key.

> And if you can't access the element when it's changed, what is the
> advantage over using tuples?

The debate over what the adavantage is of tuples over lists or vice
versa as keys in dictionaries is IMO misguided. Whether I use a list
or a tuple is not guided by whether they are going to be used as a
key or not, but how in general the data is to be manipulated.

If the typical manipulations are modifications of an existing object,
I use a list, if the typical manipulation creates new objects out
of old ones I use a tuple. If I then find that I need this object
as a key, I just provide a hash so that I can use this object as
a key in a straight forward manner, without the hassle of converting
to and from a tuple all the time.

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Securing a future for anonymous functions in Python

2005-01-12 Thread Jacek Generowicz
Jeff Shannon <[EMAIL PROTECTED]> writes:

> I guess we'll have to agree to disagree

Indeed :-)

> I find that reading a lambda requires mentally pushing a stack frame
> to parse the lambda and another to translate map() into a loop,
> whereas a list comp's expression doesn't require such a shift

>  From the sounds of it, you may have the opposite experience with
>  reading map/lambda vs. reading list comps

No, I'm perefectly happy with both. I'm just trying to understand the
underlying reasons for people having trouble with one or the other, in
order to be better armed when the didactic need might arise.

One more question. Imagine that Python had something akin to Smalltalk
code blocks. Would something like

map([x | x+1], seq)

be any better for you than

map(lambda x:x+1, seq)

?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Securing a future for anonymous functions in Python

2005-01-12 Thread Jacek Generowicz
Donn Cave <[EMAIL PROTECTED]> writes:

> List incomprehensions do not parse well in my eyes.

Are you familiar with the Haskell syntax for list comprehensions?

For example:

 
http://www.zvon.org/other/haskell/Outputsyntax/listQcomprehension_reference.html

Does their striking similarity to mathematical set notation help at
all ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Robin Becker
Brion Vibber wrote:
Paul Rubin wrote:
I think mod_php doesn't play nice with apache2 but am not aware of any
cgi interoperability problems.

Generally it's recommended to configure apache2 in the child process 
mode (eg the way that 1.3 works) when using PHP as many library modules 
are alleged not to be threadsafe. Some Linux distributions ship standard 
this way.
...
unfortunately mod_python3 seems to need exactly the opposite ie apache2 
with threads. However, I originally tried to get php going with apache2 
in the standard mode and still had problems.
--
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help Optimizing Word Search

2005-01-12 Thread Ganesan R
> "Case" == Case Nelson <[EMAIL PROTECTED]> writes:

> Hi there I've just been playing around with some python code and I've
> got a fun little optimization problem I could use some help with.

> Basically, the program needs to take in a random list of no more than
> 10 letters,  and find all possible mutations that match a word in my
> dictionary (80k words). However a wildcard letter '?' is also an
> acceptable character which increases the worst case time significantly.
> So if the letters are ['a','b','c'] check a, b, c, ab, ac, ba, bc, ca,
> cb, abc, acb, bac, bca, cab, cba where only a, ba and cab would be
> added to the dict of words. If the letters are ['?','?'] check a-z, aa,
> ab, ac, ad, ..., az, ba, bb, bc, bd, ..., zz

You're trying to cheat at scrabble aren't you ;-). I once wrote a solution 
using regular expressions, which I brushed up and posted here. Can you
check how it compares with your version? 

Call as "wordsearch abcd". You can also use wildcards.

=
.#!/usr/bin/python
.
.import sys
.import os
.import re
.
.wordlist = "/usr/share/dict/words"
.
.def get_freq(str):
."""Create a hash of number of times a character occurs in string"""
.freq = { }
.for c in str:
.freq[c] = freq.get(c, 0) + 1
.return freq
.
.
.def main(argv = sys.argv):
.chars = argv[1]
.if argv[2]:
.wordlist = argv[2]
.wild = chars.count("?")
.if wild:
.chars = chars.replace("?", "")  # remove the wild cards
.if chars:
.charpat = "[" + chars + "]*"
.else:
.charpat = ""
.
.# create a regexp suitable for matching
.pattern = charpat
.for w in xrange(wild):
.pattern += ".?" + charpat
.pattern = "^" + pattern + "$"
.print >> sys.stderr, pattern
.
.# char count for our list of chars
.charfreq = get_freq(chars)
.
.pattern_re = re.compile(pattern, re.IGNORECASE)
.# for line in os.popen("zegrep -i '%s' %s" % (pattern, wordlist)):
.for line in open(wordlist):
.line = line.rstrip()
.if not pattern_re.search(line):
.continue
.if not line or len(line) > len(chars) + wild:
.continue
.line = line.lower()
.linefreq = get_freq(line)
.
.# check if chars occur fewer times than in the given string
.extra = 0
.for c in linefreq.keys():
.if linefreq[c] > charfreq.get(c, 0):
.extra += linefreq[c] - charfreq.get(c, 0)
.if extra > wild:
.break
.else:
.print line
.
.if __name__=='__main__':
.main()

=
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread kosh
On Tuesday 11 January 2005 7:06 pm, [EMAIL PROTECTED] wrote:
> python.org = 194.109.137.226
>
> 194 + 109 + 137 + 226 = 666
>
> What is this website with such a demonic name and IP address?  What
> evils are the programmers who use this language up to?

Geeze did you miss out on the demon summoning rituals last week? Wow that was 
a great thing you missed out on. I am sorry I can't tell you about the future 
events though. Only great wizards are allowed to come and they all know when 
the events are. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: Python.org, Website of Satan

2005-01-12 Thread Tim Churches
TimC <[EMAIL PROTECTED]> wrote:
> 
> Writing code that has to be indented *exactly* or it just won't
> work. I bet they all use eVIl VI too.
> 
> -- 
> TimC -- http://astronomy.swin.edu.au/staff/tconnors/

Hey, two (real, actual) TimCs from the same country posting to the same list on 
the 
same stupid topic...

TimC
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN]: twander 3.160 Released And Available

2005-01-12 Thread Tim Daneliuk
'twander' Version 3.160 is now released and available for download at:
 http://www.tundraware.com/Software/twander
The last public release was 3.146.
Existing users are encouraged to upgrade to this release as it has
a number of bug fixes and several nice new features including:
  - Mouse popups for all the menus (except Help).
  - Ability to force Unix-style paths under Windows when doing substitutions in
  command macros. (Very helpful for cygwin users.)
  - A smarter "adaptive" directory refresh mechanism.
  - A new "Shortcut" menu for fast navigation around the filesystem.
Complete details of all fixes, changes, and new features can be found in
the WHATSNEW.txt file included in the distribution.
Users are strongly encouraged to join the twander-users mailing list as
described in the documentation.

What Is 'twander'?
--
'twander' is a macro-programmable Filesystem Browser that runs on both
Unix-like systems as well as Win32 systems. It embraces the best ideas
of both similar GUI-driven programs (Konqueror, Windows Explorer) as
well as text-based interfaces (Midnight Commander, List, Sweep).
Or, If You Prefer The "Elevator Pitch"
--
'twander' is:
   - A better file browser for Unix and Win32. (Tested on FreeBSD, Linux, 
Win32.)
   - A way to make browsing the same on all the OSs you use.
   - A macro-programmable tool that lets *you* define the features.
   - A GUI navigation front-end for your shell.
   - A way to "can" workflows for your technically-challenged colleagues.
   - A way to free yourself from the shackles of the mouse.
   - A way to significantly speed up your day-to-day workflow.
   - A Python/Tkinter application - about 3100/1300 lines of code/comments
   - A RCT (Really Cool Tool) that will have you addicted in a day or two
See the web page for more information, a screen shot, and the complete
documentation.
--
Tim Daneliuk
[EMAIL PROTECTED]





--
http://mail.python.org/mailman/listinfo/python-list


[ANN]: twander 3.160 Released And Available

2005-01-12 Thread Tim Daneliuk
'twander' Version 3.160 is now released and available for download at:
 http://www.tundraware.com/Software/twander
The last public release was 3.146.
Existing users are encouraged to upgrade to this release as it has
a number of bug fixes and several nice new features including:
  - Mouse popups for all the menus (except Help).
  - Ability to force Unix-style paths under Windows when doing substitutions in
  command macros. (Very helpful for cygwin users.)
  - A smarter "adaptive" directory refresh mechanism.
  - A new "Shortcut" menu for fast navigation around the filesystem.
Complete details of all fixes, changes, and new features can be found in
the WHATSNEW.txt file included in the distribution.
Users are strongly encouraged to join the twander-users mailing list as
described in the documentation.

What Is 'twander'?
--
'twander' is a macro-programmable Filesystem Browser that runs on both
Unix-like systems as well as Win32 systems. It embraces the best ideas
of both similar GUI-driven programs (Konqueror, Windows Explorer) as
well as text-based interfaces (Midnight Commander, List, Sweep).
Or, If You Prefer The "Elevator Pitch"
--
'twander' is:
   - A better file browser for Unix and Win32. (Tested on FreeBSD, Linux, 
Win32.)
   - A way to make browsing the same on all the OSs you use.
   - A macro-programmable tool that lets *you* define the features.
   - A GUI navigation front-end for your shell.
   - A way to "can" workflows for your technically-challenged colleagues.
   - A way to free yourself from the shackles of the mouse.
   - A way to significantly speed up your day-to-day workflow.
   - A Python/Tkinter application - about 3100/1300 lines of code/comments
   - A RCT (Really Cool Tool) that will have you addicted in a day or two
See the web page for more information, a screen shot, and the complete
documentation.
--
Tim Daneliuk
[EMAIL PROTECTED]





--
http://mail.python.org/mailman/listinfo/python-list


PyCrypto 2.0, pysco 1.4 - Windows Binaries for 2.4

2005-01-12 Thread Fuzzyman
The location of the prebuilt windows installer for PyCypto 2.0 (for 
python 2.4) has changed. Apologies for any confusion, this is because of 
a website reorganisation at Voidspace.

The new location  is :
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
There is also a prebuilt windows installer for psyco 1.4 (for python 
2.4). This is because there isn't yet a prebuilt binary available from 
sourceforge.
http://www.voidspace.org.uk/python/modules.shtml#psyco

Both built using the free, Microsoft, optimizing compiler. Following 
instructions from :
http://www.vrplumber.com/programming/mstoolkit/index.html

Regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list


Re: Game programming in Python

2005-01-12 Thread Neil Benn
Baza wrote:
I'm looking for any books or on-line resources on game programming using
Python. Does anyone have any advice?
--  
Computer says, 'no'

 

Like the end quote :
eh, eh, eeehh!!
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-12 Thread Jon Perez
Max M wrote:
Jan Dries wrote:
[EMAIL PROTECTED] wrote:
And there is hope for Python, as Guido has recently been seen with a 
beard :-)
http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg

LOL, he is working on linux, isn't he?
So it was about bloody time.
Guido Van Rossum is now working on linux??
--
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-12 Thread Bengt Richter
On Wed, 12 Jan 2005 17:54:49 +0800, Jon Perez <[EMAIL PROTECTED]> wrote:

>Max M wrote:
>> Jan Dries wrote:
>> 
>>> [EMAIL PROTECTED] wrote:
>>> And there is hope for Python, as Guido has recently been seen with a 
>>> beard :-)
>>> http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg
>> 
>> 
>> LOL, he is working on linux, isn't he?
>> 
>> So it was about bloody time.
>
>Guido Van Rossum is now working on linux??

Are they both left-handed? Hm, sinister ...

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


distutils linux script installation broken?

2005-01-12 Thread Cory Davis
Hi all,
I have been successfully deploying my own python package with distutils 
for some time now, but lately, with Python 2.4, the build_scripts 
command has been behaving badly.  In the part where it is supposed to 
adjust the first line of the script it now produces

#!None
instead of
#!/whereverpythonis/python
Has anyone else encountered this?
Cheers,
Cory.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-12 Thread Antoon Pardon
Op 2005-01-11, Jeff Shannon schreef <[EMAIL PROTECTED]>:
> Paul Rubin wrote:
>
>> Steve Holden <[EMAIL PROTECTED]> writes:
>> 
>>>[...] and if you think that
>>>newbies will have their lives made easier by the addition of ad hoc
>>>syntax extensions then you and I come from a different world (and I
>>>suspect the walls might be considerably harder in mine than in yours).
>> 
>> I'm saying that many proposals for ad hoc extensions could instead be
>> taken care of with macros.  Newbies come to clpy all the time asking
>> how to do assignment expressions, or conditional expressions, or
>> call-by-reference.  Sometimes new syntax results.  Lots of times,
>> macros could take care of it.
>
> Personally, given the requests in question, I'm extremely thankful 
> that I don't have to worry about reading Python code that uses them. 
> I don't *want* people to be able to make up their own 
> control-structure syntax, because that means I need to be able to 
> decipher the code of someone who wants to write Visual Basic as 
> filtered through Java and Perl...

No you don't. 

You could just as well claim that you don't want people to write
code in other languages because you then would need to be able
to decipher code written in that language.

> If I want mental gymnastics when 
> reading code, I'd use Lisp (or Forth).  (These are both great 
> languages, and mental gymnastics would probably do me good, but I 
> wouldn't want it as part of my day-to-day requirements...)

Your day-to-day requirements are a contract between you and your
employer or between you and your clients. That you don't want
mental gymnastics as part of that, shouldn't be a concern for
how the language develops.

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list


[Ann] PyName and downman

2005-01-12 Thread Fuzzyman
A couple of new 'modules' available from Voidspace Pythonutils.
PyName
http://www.voidspace.org.uk/python/modules.shtml#pyname
Slightly tongue in cheek, this isn't really a python module. It's three 
lists of English words containing 'py' - intended to be helpful to those 
choosing names for python projects. The word lists were produced from an 
initial file of about 8mb. Words selected all contain 'py', single words 
or hyphenated words, but no compound words.
  
* pywordlist.txt  All words contain 'py' 23kb - 1946 words
* pywordlist2.txt All words starting or ending in 'py' 16kb - 1406 words
* pywordlist3.txt All words as pywordlist2, but only words less than 10 
chars long 5kb - 658 words.

downman.py  
Version 0.2.1 14th December 2004
Simple Download Manager
http://www.voidspace.org.uk/python/cgi.shtml#downman

This is a simple download manager tool. It may be egotistical, but I 
like to know which of my projects are being downloaded (and which 
aren't). Simply make your files available in a single directory and have 
the links point to downman (see the download link for downman itself for 
an example) and downman will track the downloads. At the moment it only 
presents simple data - but all the raw data is collected to do per 
week/last month (or whatever) analysis. It will also manage links as well.

See the example output at 
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py

Regards,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python & unicode

2005-01-12 Thread P
Scott David Daniels wrote:
[EMAIL PROTECTED] wrote:
Because the coding is only supported in string literals.
But I'm not sure exactly why. 
The why is the same as why we write in English on this newsgroup.
Not because English is better, but because that leaves a single
language for everyone to use to communicate in.
Fair enough. Though people can communicate in other languages
if they want, or have specific newsgroups for other languages.
If you allow
non-ASCII characters in symbol names, your source code will be
unviewable (and uneditable) for people with ASCII-only terminals,
never mind how comprehensible it might otherwise be.
So how does one edit non ascii string literals at the moment?
It is a
least-common-denominator argument, not a "this is better"
argument.
If one edited the whole file in the specified coding
then one wouldn't have to switch editing modes when
editing strings which is a real pain.
--
PÃdraig Brady - http://www.pixelbeat.org
--
--
http://mail.python.org/mailman/listinfo/python-list


Re: else condition in list comprehension

2005-01-12 Thread Nick Coghlan
Luis M. Gonzalez wrote:
Hi there,
I'd like to know if there is a way to add and else condition into a
list comprehension. I'm sure that I read somewhere an easy way to do
it, but I forgot it and now I can't find it...
for example:
z=[i+2 for i in range(10) if i%2==0]
what if I want i to be "i-2" if i%2 is not equal to 0?
Hmm:
z = [newval(i) for i in range(10)] using:
def newval(x):
if x % 2:
return x - 2
else:
return x + 2
Just some more mental twiddling relating to the thread on statement local 
namespaces.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


[Ann] Voidspace Pythonutils Website Change and Updates

2005-01-12 Thread Michael Foord
The Voidspace Pythonutil Pages have had a long overdue overhaul. The url 
of the Voidspace Pythonutils homepage has changed. It is now :
http://www.voidspace.org.uk/python/index.html

There are now separate pages for programs, modules, recipes, and CGIs. 
Several of the bigger modules and programs have their own pages.

The following modules have also been updated :
StandOut
Version 2.1.0 6th Jan 2005
http://www.voidspace.org.uk/python/modules.shtml#standout
This simple 'Flexible Output Object' has now been updated to work with 
sys.stderr as well as sys.stdout. It can log them separately or to the 
same file.

StandOut is a simple way of adding 'variable verbosity levels' to your 
program *and* logging, just using normal print commands.

guestbook.py
http://www.voidspace.org.uk/python/cgi.shtml#guestbook
Version 1.2.0 3rd December 2004
The Voidspace Python Guestbook has been updated.
You can now use sendmail instead of smtplib as an option (my current 
host will only allow sendmail).
License change (again!) - now the BSD license.
Changed to use the UTF-8 encoding throughout. We ought to be able to 
accept 'foreign' (non-ascii) entries now.

ConfigObj  
Version 3.2.3 2nd December 2004
Fixes a critical bug and a couple of minor improvements.

ConfigObj is for simple but powerful config file parsing/creation.
Fixed bug in creating non-flatfiles from scratch. (__comments__ 
KeyError). (critical bugfix)
Tuple entries are written out as lists rather than being converted to 
strings.
When an exception is raised, it's no longer printed first.
Added the istrue method.
Changed the license to BSD-License.

As far as I know these are the only substantial changes to modules. A 
few others have had *minor* bugfix updates as well.

Regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list


Re: Command line and GUI tools : need a single threading solution

2005-01-12 Thread Adrian Casey
Adrian Casey wrote:

> Diez B. Roggisch wrote:
> 
>>> I'm thinking it may be possible to modify the command line tools to use
>>> qt
>>> threads instead of native python threads.  Is this the way to go?  Are
>>> there other options?
>> 
>> Why don't you use python threads in qt - I do so and so far it didn't
>> make any troubles for me. And I would strongly advise against using
>> qthreads with your commandline-tools, as these then would only run on
>> machines where pyqt is installed - which opens a small part of
>> "dependency hell" for your users.
>> 
> I have a QThread which polls a queue object via queue.get().  The command
> line tools spawn a number of threads each of which writes its output to
> this queue using queue.put().  As soon as the gui gets something off the
> queue, it creates a QCustomEvent and sets the data property with the data
> read from the queue.  My application has a customEvent() method which
> reads the data item from the customEvent and processes it accordingly.
> 
> The odd thing is, I have a non-threaded version of the command line tools
> which work 100% with the gui.  The multi-threaded version of the command
> line tools all work OK at the console - just not with the gui.
> 
> I will try your suggestion and replace my QCustomEvent mechanism with a
> plain python queue.
I tried replacing the QThread part with native python threads and, although
it worked for a few minutes, I started to see XWindow errors and my
application would then crash.

On Phil Thompson's advice, I updated PyQt and sip.  The problem appears to
be fixed.

Adrian.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread ToYKillAS
[EMAIL PROTECTED] wrote:
python.org = 194.109.137.226
194 + 109 + 137 + 226 = 666
What is this website with such a demonic name and IP address?  What
evils are the programmers who use this language up to?
damn Franc Maçons
--
Even though I walk through the valley of the shadow of death,
I will fear no evil, for you are with me;
your rod and your staff, they comfort me.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Ann] Voidspace Pythonutils Website Change and Updates

2005-01-12 Thread Thorsten Pferdekämper
"Michael Foord" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> The Voidspace Pythonutil Pages have had a long overdue overhaul. The url
> of the Voidspace Pythonutils homepage has changed. It is now :
> http://www.voidspace.org.uk/python/index.html
>

Hi,
do you mean
http://www.voidspace.org.uk/python/index.shtml?
Regards,
Thorsten

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python guy ide

2005-01-12 Thread lbolognini
This is commercial. Never tried it but it exists:
http://visualwx.altervista.org/

Lorenzo

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils linux script installation broken?

2005-01-12 Thread Albert Hofkamp
On Wed, 12 Jan 2005 10:09:03 +, Cory Davis <[EMAIL PROTECTED]> wrote:
> command has been behaving badly.  In the part where it is supposed to 
> adjust the first line of the script it now produces
> 
> #!None
> 
> instead of
> 
> #!/whereverpythonis/python
> 
> Has anyone else encountered this?

I haven't (as I am not using 2.4 :-) )

However, there is an easy way around this, just use

#!/usr/bin env python

instead.


Albert
-- 
Unlike popular belief, the .doc format is not an open publically available 
format.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Ann] Voidspace Pythonutils Website Change and Updates

2005-01-12 Thread Fuzzyman
Blinkin nora... I did... sorry. Better add a redirect *sigh*.
Thanks
Fuzzy
http://www.voidspace.org.uk/python/index.shtml

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils linux script installation broken?

2005-01-12 Thread Cory Davis
Thanks Albert.
I already do use #!/usr/bin/env python in my package directory, but the 
build_scripts part of "setup.py install" changes this line to #!None 
before copying to my bin directory.

Cheers,
Cory.
Albert Hofkamp wrote:
On Wed, 12 Jan 2005 10:09:03 +, Cory Davis <[EMAIL PROTECTED]> wrote:
command has been behaving badly.  In the part where it is supposed to 
adjust the first line of the script it now produces

#!None
instead of
#!/whereverpythonis/python
Has anyone else encountered this?

I haven't (as I am not using 2.4 :-) )
However, there is an easy way around this, just use
#!/usr/bin env python
instead.
Albert
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Installation

2005-01-12 Thread Simon Brunning
On Tue, 11 Jan 2005 21:00:40 +0100, Fredrik Lundh
<[EMAIL PROTECTED]> wrote:
> Steve Holden wrote:
> 
> > Hmm, effbot.org seems to be down just now. Sure it'll be back soon, though.
> 
> http://news.bbc.co.uk/2/hi/europe/4158809.stm

Good to see that it was effbot.org that was down, rather that the
effbot himself.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] SciTe

2005-01-12 Thread Lucas Raab
Fouff wrote:
I use Scintilla which is Scite with a lot of configurations files.
In directory exists a file "cpp.properties" and near the end of the file 
is describe the command line use to compile, to link, ...

I think you would be able to change here the compiler.
regards
Fouff
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: distutils linux script installation broken?

2005-01-12 Thread Christopher De Vries
I just installed python2.4 and used it to install a set of scripts I
had previously been using distutils with. It worked fine, and replaced
the first line with:

#!/usr/local/bin/python2.4

distutils should replace that first line with the location of the
binary used to run setup.py. Are you running setup with the following
command line?

python setup.py install

-- 
http://mail.python.org/mailman/listinfo/python-list


how to visualize symbol table?

2005-01-12 Thread Thomas Korimort
Hi,
how can i visualize the content of the symbol table in Python?
Sometimes i want to know which symbols are imported from apackage and 
such kind of things

Greetings, THomas Korimort
--
http://mail.python.org/mailman/listinfo/python-list


Re: distutils linux script installation broken?

2005-01-12 Thread Cory Davis
Hi Christopher
distutils should replace that first line with the location of the
binary used to run setup.py. Are you running setup with the following
command line?
python setup.py install
Yes.
A possible complication is that I also have python 2.3.? on that 
machine, which I am reluctant to remove incase it disturbs my linux 
distribution (Fedora Core 2).
Its also possible that I have done something silly to an environment 
variable.  To check this I will try installing my package either as root 
or another user.

Cheers,
Cory.
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to visualize symbol table?

2005-01-12 Thread Pierre Barbier de Reuille
Thomas Korimort a écrit :
Hi,
how can i visualize the content of the symbol table in Python?
Sometimes i want to know which symbols are imported from apackage and 
such kind of things

Greetings, THomas Korimort
Do you mean something like :
dir(module)
???
Pierre
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help Optimizing Word Search

2005-01-12 Thread Win
Hi Case.

Just in case you're really, truly looking for a fast Scrabble
word-search algorithm, the classic AI/CS article here is:

Andrew W. Appel and Guy J. Jacobson, The world's fastest Scrabble
program, Communications of the ACM, 31(5), pp 572--578, May 1988.

You can find a copy of this article at, for example:
http://counties.csc.calpoly.edu/~team12fk/F02/acm_worlds_fastest_scrabble_program.pdf

This algorithm uses a "dawg" (Directed Acyclic Word Graph). You can
find a well-documented example of this data structure implemented in
Python in the the WordUtils package:
http://cedar-solutions.com/software/wordutils/

Regards,

Win

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread Simon Brunning
On Wed, 12 Jan 2005 15:18:09 +0800, sam <[EMAIL PROTECTED]> wrote:
> I m wondering which Excel module is good to be used by Python?

If you are on Windows, and you have Excel, then the Python for Windows
extensions[1] are all you need to drive Excel via COM. O'Reilly's
"Python Programming on Win32" covers COM scripting extensively - and
by good fortune, driving Excel is the example they use, and the COM
scripting chapter is on-line[2].

You'll also need to know the objects and methods that Excel exposes.
These are documented on Microsoft's web site[3], or in the Excel VBA
help, which is an optional part of they Office installation.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/

[1] http://starship.python.net/crew/mhammond/
[2] http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html
[3] 
http://msdn.microsoft.com/library/en-us/modcore/html/deovrWorkingWithMicrosoftExcelObjects.asp
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread Peter Hansen
sam wrote:
I m wondering which Excel module is good to be used by Python?
Just use Excel's COM interface.
See also this helpful page to improve future responses:
http://www.catb.org/~esr/faqs/smart-questions.html
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python & unicode

2005-01-12 Thread Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
Hi !

Sorry, but I think that, for russians, english is an *add-on*, and not a
common-denominator.
English is the most known language, but it is not common.  It is the same
difference as between co-operation and colonization.

Have a good day
-- 
Michel Claveau








-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Simo Melenius
[EMAIL PROTECTED] writes:

> This is a bizarre idea if you want to make Python run faster. It is
> not so bizarre if what you want is to have access to Python from
> Lisp/Scheme in the same sense Jython has access to Java.

And it sounds very nice if you prefer writing Lisp code (or resort to
it if needed) and run it on a cross-platform environment that's
available almost everywhere, and access a large standard library of
modern utilities.


br,
S
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shutil.move has a mind of its own

2005-01-12 Thread Istvan Albert
Daniel Bickett wrote:
In my script, rather than a file being moved to the desired location,
it is, rather, moved to the current working directory (in this case,
my desktop -- without any exceptions, mind you). As it happens, the
what is the output generated by the lines:
fdir, fname = randFileInfo.new()
debugMess( "Generated file information: %s, %s" % ( fdir, fname ) )
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> > I can't imagine how it could be worse than the learning curve of
> > __metaclass__, which we already have.
> 
> To me, learning macros *and their subtilities* was much more difficult
> than learning metaclasses.

I guess I've only used Lisp macros in pretty straightforward ways,
that weren't hard to understand.  That's enough for anything I've
needed.  But we don't hear much about __metaclass__ because almost
nobody understands it.

> Go to comp.lang.scheme and google for "macros and module system";
> you will get everything you want to know and much more!

OK, I might do this.

> Well, I see this as a positive fact. If a syntax is contrived (such
> as a ternary operator, for instance) it is better *not* to have it
> than to have one hundred custom made syntaxes. At the end, we are
> just talking about syntax sugar here, not about lack of
> functionality.

I think the idea is there would be some experimentation and then one of
the versions would make it into the standard library.

> > [compiling Lisp to Python bytecode]
> This is a bizarre idea if you want to make Python run faster. It is
> not so bizarre if what you want is to have access to Python from
> Lisp/Scheme in the same sense Jython has access to Java.

Why not just use a foreign function interface?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to set doc-string of new-style classes

2005-01-12 Thread harold fellermann
On 11.01.2005, at 19:35, Alex Martelli wrote:
harold fellermann <[EMAIL PROTECTED]> wrote:
   ...
But, I cannot
even find out a way to set the doc string, when I CREATE a class using
type(name,bases,dict) ... At least this should be possible, IMHO.

x=type('x',(),dict(__doc__='hi there'))
x.__doc__
'hi there'
yes, you're right ... a subsequent question, that puzzles me:
where can I apply for the "most-stupid-question"-award, now *g*
thanks anyway,
- harold -
--
The opposite of a correct statement is a false statement.
But the opposite of a profound truth may be another profound truth.
-- Niels Bohr
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help Optimizing Word Search

2005-01-12 Thread Scott David Daniels
Paul Rubin wrote:
"Case  Nelson" <[EMAIL PROTECTED]> writes:
Basically, the program needs to take in a random list of no more than
10 letters,  and find all possible mutations that match a word in my
dictionary (80k words). However a wildcard letter '?' is also an
acceptable character which increases the worst case time significantly.

For that size pattern and dictionary, simply compiling the pattern to
a regexp, joining the dictionary together into one big string ("abc
def ghijk..."), and matching the regexp against the big string, may
well be faster than using some fancy algorithm coded completely in
python.
If these queries happen often, build a dictionary of sorted letters to
lists-of-words.  The setup will be slow, but use of such a secondary
dictionary should be quite fast, with relatively easy dealing with ?s
by iterations.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Time script help sought!

2005-01-12 Thread kpp9c
paul that is awesome so much better than what i did which was lamo
brute force method. I formmatted and reformatted my input data and
stuffed it in a HUGE dictionary it was stupid and kludgy i hope
to study all these approaches and learn something here's what i
came up with ... with my pea sized brain...

#!/usr/bin/env python

# New in version 2.3 is the 'datetime' module (see standard library
reference)
# http://www.python.org/doc/lib/module-datetime.html

import datetime

inseqs = { (1) : ['DAT_1', '01', '00:00:23', '00:08:23'],
(2) : ['DAT_1', '02', '00:08:23', '00:09:41'],
(513) : ['DAT_75', '10', '00:59:55', '01:11:05'],
(514) : ['DAT_75', '11', '01:11:05', '01:16:15'],
(515) : ['DAT_75', '12', '01:16:15', '01:34:15'],
(516) : ['DAT_75', '13', '01:34:15', '01:45:15'],
(517) : ['DAT_75', '14', '01:45:15', '01:48:00'] }


mykeys = inseqs.keys()  # first make a copy of the keys
mykeys.sort()   # now sort that copy in place

for key in mykeys:
event = inseqs[key]
print '\n','Item #', key, event
TD = datetime.timedelta
h, m, s = event[2].split(':')
zero_adjust = TD(hours=int(h), minutes=int(m),seconds=int(s))
#
print ' Q___ ', key, event[:2], ': ',
for item in event[2:]:
hrs, mins, secs, = item.split(':')
time1 = TD(hours=int(hrs), minutes=int(mins),seconds=int(secs))
print time1 - zero_adjust,

print

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python & unicode

2005-01-12 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
Scott David Daniels wrote:
If you allow
non-ASCII characters in symbol names, your source code will be
unviewable (and uneditable) for people with ASCII-only terminals,
never mind how comprehensible it might otherwise be.
So how does one edit non ascii string literals at the moment?
Generally by using editors that leave bytes alone if they cannot
be understood.  For many applications where I'll work on a program,
I don't need to read the strings, but rather the code that uses
those strings.  I am at a disadvantage if I cannot understand the
derivation of the names, no doubt, but at least I know when two
letters are different, and what tokens are distinct.
If one edited the whole file in the specified coding
then one wouldn't have to switch editing modes when
editing strings which is a real pain.
No question, but ASCII is available as a subset for many encodings.
As you might note, my conception is that I might be helping on a
program with many programmers.  Python spent a lot of effort to
avoid favoring a character set as much as possible, while still
being a medium for sharing code.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread sam
Simon Brunning wrote:
On Wed, 12 Jan 2005 15:18:09 +0800, sam <[EMAIL PROTECTED]> wrote:
I m wondering which Excel module is good to be used by Python?

If you are on Windows, and you have Excel, then the Python for Windows
extensions[1] are all you need to drive Excel via COM. O'Reilly's
"Python Programming on Win32" covers COM scripting extensively - and
by good fortune, driving Excel is the example they use, and the COM
scripting chapter is on-line[2].
You'll also need to know the objects and methods that Excel exposes.
These are documented on Microsoft's web site[3], or in the Excel VBA
help, which is an optional part of they Office installation.
No, I don't use MS windows. I need to generate Excel file by printing 
data to it, just like Perl module Spreadsheet::WriteExcel.

thanks
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Re: distutils linux script installation broken?

2005-01-12 Thread Christopher De Vries
I've got python 2.3.3, 2.4, and 1.5.2 (which came preinstalled) on my
linux box. It's redhat 7.2 (I know... I would upgrade, but it would
void my service contract, so I just install things in /usr/local). You
can check if PYTHONHOME or PYTHONPATH are set, which may somehow be
interfering. I don't have those variables set. If they are set, you
could try running:

python -E setup.py install

The -E option should make python ignore those environment variables.
Good luck, I hope this helps.

Chris

-- 
http://mail.python.org/mailman/listinfo/python-list


java 5 could like python?

2005-01-12 Thread vegetax
I was a java developer one year ago ,before i moved to python i realy liked 
it at the beggining, but i got very disapointed lately since my 
previus two python proyects where relatively big,and python didnt feel 
well suited for the task.

The reasons are mainly due to the standard library,the language
performance was aceptable, but the library, in my opinion has several grave
issues:

-No naming convention. The speech of "it fits in my head" is no longer valid
when i use a lot of functionality,modules,classes in a large proyect.

For example if i remember a function i want ie:get attribute, i dont
remember if the module implementer coded it as
getAttribute,GetAttribute,get_attribute, then i have to go and check the
doc, every time,which is a waste of time.

-library Organization,we have modules that can have 20 classes(I imagine
that is because of the commodity of having all in one file) which makes
reading the doc horribly painfull and is very hard to find the stuff
coupled with the "pool" of modules that is the python installation
directory,all throwed away at the installation directory without a
categorization.

-Is python library half object oriented? half functional oriented? I can
understand that python allows some functional programing components when
they are necesary,but there are libraries that totaly ignore object
orientation which makes them problematic to use.for example,Whats with the
os.path module and files? why do i have to say os.path.getfilesize(f.name)
all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
items instead of an URL object? why there isnt an URL object? and so on.. 

I havent figured out a way to overcome those factors,the delaying and lost
of focus that is having to check the docs all the time,every 5 seconds and
having to make object oriented wrapers for several libraries or having to
go and read the source code to know what the heck a function returns or
what are its arguments makes coding unpleasant an very slow , i often have
15 pydocs windows open at the same time. What should i do?  

-Realying on ides is imposible due to python dinamic nature,very litle(next
to nothing) assistance can be espected from them.

-Memorazing all the function names,parameters,return values,conventions of
the modules i use doesnt look like a good solution.

Join it with poor and outdated documention and we have a very unpleasant
standard library.

In the other hand, with the recent changes in java 5 i can pythonize
java,And take advantage of a well designed library that coupled with the
"apache commons" libraries has no match,not even .Net.

 for example with the static import feature i can say:

import static mylib.Toolbox.print;
import static mylib.Console.run;
// or import static mylib.Toolbox.*;

class C{
 public void func(){
   print("hello world"); // instead of System.out.println("hello world");
   print(run("ls /tmp"));
 }
}

Same for almost all python builtin functions.

The new for statement :
 
 for (int i : mylist)
   print(i);
 
I guess i could use a cleaver hack to also include the map,filter and other
nice functional components python has.

Also there is the generics support and so on..

But for some reason i dont know,the switch back feels wrong =( ,would it be
posible to imitate python's behavior with the new java features and some
hacks? would be worth the effort? If not what can i do to use efficiently
python modules and libraries? I recall, i didnt had this problem when doing
small applications with a small set of modules.

Sorry for my bad english.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread Simon Brunning
On Wed, 12 Jan 2005 23:19:44 +0800, sam <[EMAIL PROTECTED]> wrote:
>
> No, I don't use MS windows. I need to generate Excel file by printing
> data to it, just like Perl module Spreadsheet::WriteExcel.

If it's just data that needs to go into your spreadsheet, then I'd
just build a CSV file if I were you. Excel opens them perfectly
happily.

If you need to write out formulae, formratting, that kind of thing,
then I think you'll need to write a 'real' Excel file. I don't have a
clue how to do that - sorry.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread Peter Hansen
sam wrote:
On Wed, 12 Jan 2005 15:18:09 +0800, sam <[EMAIL PROTECTED]> wrote:
I m wondering which Excel module is good to be used by Python?
[snip]
No, I don't use MS windows. I need to generate Excel file by printing 
data to it, just like Perl module Spreadsheet::WriteExcel.
Excel can read CSV files, so just use the standard Python module "csv"
and write your files that way.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Detecting shutdown of remote socket endpoint.

2005-01-12 Thread Michael Hobbs
Tim Gosselin <[EMAIL PROTECTED]> wrote:
> I am writing a tcp tunnel but cannot find a way of detecting when a socket
> shuts down its read end without writing to the socket. For testing the
> write end of the remote endpoint I just do a:
> 
> if not sock.recv(buffsize)
> 
> I cannot write to the socket and check if send returns 0 though, because
> that involves sending data out of the which may not have come in yet.
> 
> When I try polling the socket with:
> r, w, e=select([],[sock],[], 0)
> w returns with the socket still writable, even if the other end was
> closed.

Even at the C level, I believe there were some differences between
Unix and Windows sockets in regard to this, so this advice may be
dependent on your platform.

At any rate, on both Unix and Windows, a closed socket will continue
to report itself as writable. To detect the closed socket, I believe
that one system reports the socket as being in error whereas the
other system reports the socket as being readable (where read() will
then immediately return 0 because the socket is closed).

So in summary, instead of:
  r, w, e=select([],[sock],[], 0)
try this:
  r, w, e=select([sock],[],[sock], 0)
If r or e is non-empty, then the socket has been closed (or there's
some other error).

HTH,
- Mike
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Excel module for Python

2005-01-12 Thread Tim Golden
[Simon Brunning]
[sam <[EMAIL PROTECTED]>] wrote:
| > No, I don't use MS windows. I need to generate Excel file 
| by printing
| > data to it, just like Perl module Spreadsheet::WriteExcel.
| 
| If you need to write out formulae, formratting, that kind of thing,
| then I think you'll need to write a 'real' Excel file. I don't have a
| clue how to do that - sorry.

I think http://sourceforge.net/projects/pyxlwriter/ will do it;
haven't used it myself, mind you. You need to know that the
magic search term is "BIFF" which is -- for some reason --
the name of the Excel file format.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

-- 
http://mail.python.org/mailman/listinfo/python-list


2 versions of python on 1 machine

2005-01-12 Thread flupke
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 15
Message-ID: <[EMAIL PROTECTED]>
Date: Thu, 06 Jan 2005 15:13:42 GMT
NNTP-Posting-Host: 212.123.8.34
X-Complaints-To: [EMAIL PROTECTED]
X-Trace: phobos.telenet-ops.be 1105024422 212.123.8.34 (Thu, 06 Jan 2005 
16:13:42 MET)
NNTP-Posting-Date: Thu, 06 Jan 2005 16:13:42 MET
Organization: Telenet Internet
Path: 
cernne01.cern.ch!news-zh.switch.ch!switch.ch!news.mailgate.org!newsfeed.stueberl.de!newsgate.cistron.nl!skynet.be!skynet.be!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail
Xref: cernne01.cern.ch comp.lang.python:6747

I searched with Google and on this newsgroups and i didn't find any info 
regarding this. If there is more info, please redirect me to that info.

I have version 2.3.4 and 2.4 installed on windows and i thought that by 
switching the PYTHONPATH parameter to the dir of the 2.4 version that 
that would make python 2.4 active.

However when i envoke python from the commandline, it still runs 2.3.4
Is it possible to have 2 versions installed and switching versions when
you need to?

How can i do that?

Thanks,
Benedict

--
http://mail.python.org/mailman/listinfo/python-list


Iteration over two sequences

2005-01-12 Thread Henrik Holm
I am just starting to learn Python, mostly by going through the examples
in Dive Into Python and by playing around.

Quite frequently, I find the need to iterate over two sequences at the
same time, and I have a bit of a hard time finding a way to do this in a
"pythonic" fashion.  One example is a dot product.  The straight-ahead
C-like way of doing it would be:

def dotproduct(a, b):
psum = 0
for i in range(len(a)):
psum += a[i]*b[i]
return psum

However, the range(len(a)) term is awfully un-pythonic :)
The built-in function map() gives me a way of "transposing" the a list
and the b list, and  now I can handle it with a list comprehension:

def dotproduct(a, b):
return sum([x*y for x, y in map(None, a, b)])

My concern is one of efficiency: it seems to me that I have two loops
there: first one implied with map(...) and then the for loop -- which
seems like a waste since I feel I should be able to do the
multiplication via an argument to map.  So far I have come up with an
alternative via defining a separate function:

def dotproduct(a, b):
def prod(x,y): return x*y
return sum(map(prod, a, b))

I suppose I could also use a lambda here -- but is there a different,
efficient, and obvious solution that I'm overlooking?


Thanks,
Henrik

-- 
"On some great and glorious day the plain folks of the land will reach
in their heart's desire at last and the White House will be adorned by
a downright moron."
 -H.L. Mencken (1880-1956) American Writer 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread Gerhard Haering
On Wed, Jan 12, 2005 at 10:15:34AM -0500, Jane wrote:
> [...] Some people have too much time on their hands...

OMG, PyPy is full of evil, too!!!1

print sum([ord(x) for x in "PyPy"])

or, if you haven't upgraded to 2.4, yet:

import operator
print reduce(operator.add, [ord(x) for x in "PyPy"])

-- Gerhard


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Iteration over two sequences

2005-01-12 Thread Diez B. Roggisch
zip or izip is your friend:

import itertools

a = [1,2,3]
b = ['a', 'b', 'c']

for a,b in itertools.izip(a, b):
print a, b

-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie: module structure and import question

2005-01-12 Thread Ziong
hi all,
i have question on how to design a module structure.
for example, i have 3 files.
[somewhere]/main.py
[somewhere]/myLib/Base/BaseA.py
[somewhere]/myLib/ClassA.py

main.py
===
from myLib.ClassA import ClassA

a = classA()
dir(a)

myLib/ClassA.py
===
from myLib.Base.BaseA import BaseA

class ClassA(BaseA):
   def __init__(self):
   BaseA.__init__(self)
   print "classA"

if (__name__ == "__main__"):
   print "test class A"
   a = ClassA()
   print a


myLib/Base/BaseA.py
===
class BaseA:
   def __init__(self):
 print "BaseA"


It's fine when i run main.py.
however when i run ClassA.py individually, it would fail in import
statment since the import path is incorrect.
I would like to know is something wrong in my design, or something i
missed.

Also, in practical usage, is that one class in one py file?

thx!

a python newbie
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iteration over two sequences

2005-01-12 Thread Paul McGuire
"Henrik Holm" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am just starting to learn Python, mostly by going through the examples
> in Dive Into Python and by playing around.
>
> Quite frequently, I find the need to iterate over two sequences at the
> same time, and I have a bit of a hard time finding a way to do this in a
> "pythonic" fashion.  One example is a dot product.  The straight-ahead
> C-like way of doing it would be:
>
> def dotproduct(a, b):
> psum = 0
> for i in range(len(a)):
> psum += a[i]*b[i]
> return psum
>
> However, the range(len(a)) term is awfully un-pythonic :)
> The built-in function map() gives me a way of "transposing" the a list
> and the b list, and  now I can handle it with a list comprehension:
>
> def dotproduct(a, b):
> return sum([x*y for x, y in map(None, a, b)])
>
> My concern is one of efficiency: it seems to me that I have two loops
> there: first one implied with map(...) and then the for loop -- which
> seems like a waste since I feel I should be able to do the
> multiplication via an argument to map.  So far I have come up with an
> alternative via defining a separate function:
>
> def dotproduct(a, b):
> def prod(x,y): return x*y
> return sum(map(prod, a, b))
>
> I suppose I could also use a lambda here -- but is there a different,
> efficient, and obvious solution that I'm overlooking?
>
>
> Thanks,
> Henrik
>
> -- 
> "On some great and glorious day the plain folks of the land will reach
> in their heart's desire at last and the White House will be adorned by
> a downright moron."
>  -H.L. Mencken (1880-1956) American Writer

zip maybe?

def dotproduct(a,b):
return sum([x*y for x,y in zip(a,b)])

-- Paul


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iteration over two sequences

2005-01-12 Thread Richard Brodie

"Henrik Holm" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> I suppose I could also use a lambda here -- but is there a different,
> efficient, and obvious solution that I'm overlooking?

Check the itertools recipes in the library documentation.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread Jane

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> python.org = 194.109.137.226
>
> 194 + 109 + 137 + 226 = 666
>
> What is this website with such a demonic name and IP address?  What
> evils are the programmers who use this language up to?
>
Some people have too much time on their hands...

Jane


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Excel module for Python

2005-01-12 Thread [EMAIL PROTECTED]
that's easy. Just make an html file of your data, using tables and save
it as a "*.xls" and excel will think it's an excel file.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iteration over two sequences

2005-01-12 Thread Henrik Holm
Richard Brodie <[EMAIL PROTECTED]> wrote:

> "Henrik Holm" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> > I suppose I could also use a lambda here -- but is there a different,
> > efficient, and obvious solution that I'm overlooking?
> 
> Check the itertools recipes in the library documentation.

Thanks,

the itertools seem to contain several useful functions.

-- 
"On some great and glorious day the plain folks of the land will reach
in their heart's desire at last and the White House will be adorned by
a downright moron."
 -H.L. Mencken (1880-1956) American Writer 
-- 
http://mail.python.org/mailman/listinfo/python-list


ConfigParser - add a stop sentinel?

2005-01-12 Thread rzed
I am working with PythonCard in one of my apps. For its purposes, it 
uses an .ini file that is passed to ConfigParser. For my app, I also 
need configuration information, but for various reasons, I'd rather 
use a syntax that ConfigParser can't handle.

I know I can maintain two separate configuration files, and if I have 
to I will, but I'd rather avoid that, if possible, and a solution 
that suits my purposes is quite straightforward. I insert a sentinel 
in the ini file and modify my local ConfigParser's _read method to 
stop accepting input when it encounters that value. I handle my app's 
portion of the configuration myself.

This all works fine, but I was wondering whether it might be 
worthwhile to add a standard stop flag in ConfigParser itself. Am I 
the only one with this sort of use case? If there were a standard way 
of doing this, I'd much rather use that, particularly if I ever have 
reason to distribute the app elsewhere.
-- 
rzed

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: java 5 could like python?

2005-01-12 Thread Roman Suzi


On Wed, 12 Jan 2005, vegetax wrote:

>-No naming convention. The speech of "it fits in my head" is no longer valid
>when i use a lot of functionality,modules,classes in a large proyect.

>For example if i remember a function i want ie:get attribute, i dont
>remember if the module implementer coded it as
>getAttribute,GetAttribute,get_attribute, then i have to go and check the
>doc, every time,which is a waste of time.

Or yes, I hate those 'get' too. Why not to use just obj.attribute instead?
Otherwise, the pluralism present in Python, makes me feel more at home.

>-library Organization,we have modules that can have 20 classes(I imagine
>that is because of the commodity of having all in one file) which makes
>reading the doc horribly painfull and is very hard to find the stuff
>coupled with the "pool" of modules that is the python installation
>directory,all throwed away at the installation directory without a
>categorization.

Probably some Really Large Corporation could add Python Standard Library
Enterprise Edition and win big.

>-Is python library half object oriented? half functional oriented? I can

Right now it change its orientation to iterator/generators...
I image a nice box with Python 3 in it, where there will be no more
inconsistencies with naming, etc.

>understand that python allows some functional programing components when
>they are necesary,but there are libraries that totaly ignore object
>orientation which makes them problematic to use.for example,Whats with the
>os.path module and files? why do i have to say os.path.getfilesize(f.name)
>all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
>items instead of an URL object? why there isnt an URL object? and so on..

This reminds me of attributes vs. tags debate of how to structure XML.

size(f) or f.size() - that is the question

>I havent figured out a way to overcome those factors,the delaying and lost
>of focus that is having to check the docs all the time,every 5 seconds and
>having to make object oriented wrapers for several libraries or having to
>go and read the source code to know what the heck a function returns or
>what are its arguments makes coding unpleasant an very slow , i often have
>15 pydocs windows open at the same time. What should i do?

Do not use windows. Sit for an evening add read all the docs.
Coding will becaome much faster.

>-Realying on ides is imposible due to python dinamic nature,very litle(next
>to nothing) assistance can be espected from them.

Class browsing and auto-completion are probably the only features
I sometime miss. But otherwise what IDEs are for?

>-Memorazing all the function names,parameters,return values,conventions of
>the modules i use doesnt look like a good solution.

But it is a must: how do you communicate if you do not nother to
remember words?

>Join it with poor and outdated documention and we have a very unpleasant
>standard library.

>class C{
> public void func(){
>   print("hello world"); // instead of System.out.println("hello world");

Probably print statement will not make it into Python 3.0. Very sad.

>   print(run("ls /tmp"));
> }
>}
>
>Same for almost all python builtin functions.
>
>Also there is the generics support and so on..
>
>But for some reason i dont know,the switch back feels wrong =( ,would it be
>posible to imitate python's behavior with the new java features and some
>hacks? would be worth the effort? If not what can i do to use efficiently
>python modules and libraries? I recall, i didnt had this problem when doing
>small applications with a small set of modules.
>
>Sorry for my bad english.

That is it. I hate English. It has sooo much exceptions to remember!
Esperanto is much cleaner language. UN should drop all it's
official languages and use Esperanto instead.



Sincerely yours, Roman Suzi
-- 
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: java 5 could like python?

2005-01-12 Thread Istvan Albert
vegetax wrote:
previus two python proyects where relatively big,and python didnt feel 
well suited for the task.
One typical problem that others might talk about in more detail
is that you might be writing java code in python. That means
using Java style class hierarchies, methods and overall
organization. That does not work well in python.
-No naming convention. 
That is result of open source model that evolved over a
long time.
getAttribute,GetAttribute,get_attribute, then i have to go and check the
doc, every time,which is a waste of time.
Create a simple wrapper that does exactly what you want. For
example it would take just a few minutes to create a URL class
that you wanted. Then you have to figure it out only once.
-Is python library half object oriented? half functional oriented? 
Yes. As should most solutions be.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: complex numbers

2005-01-12 Thread It's me
Precisely.   One have to convert complex number into vectors, and vector of
complex numbers into vector of vectors, list of complex numbers into list of
vectors, , you get the idea.

And my code no longer look like the equation I have on paper...

Like I said, I've travelled down that path before with C++ and Modelica.
It gets ugly.

Anyway.



"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Op 2005-01-12, It's me schreef <[EMAIL PROTECTED]>:
> >
> > "Robert Kern" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >>
> >> That's *it*.
> >
> > So, how would you overload an operator to do:
> >
> > With native complex support:
> >
> > def  twice(a):
> > return 2*a
> >
> > print twice(3+4j), twice(2), twice("abc")
> >
> > Let's presume for a moment that complex is *not* a native data type in
> > Python.  How would we implement the above - cleanly?
>
>
> I suppose in the same way as (graphic) points and vectors can be
> implemented cleanly.
>
> A few years back I had written a Vector class in python, just
> to get an understanding of how things worked. It worked without
> a problem with your twice function.
>
>
> >>> Vec(1.0,2.0)
> Vector[1.0, 2.0]
> >>> def twice(a):
> ...   return 2 * a
> ...
> >>> twice(Vec(1.0,2.0))
> Vector[2.0, 4.0]
> >>>
>
>
> I suppose what can be done with a vector class could have been
> done with a complex class should complex numbers not have been
> native to python.
>
> -- 
> Antoon Pardon


-- 
http://mail.python.org/mailman/listinfo/python-list


property () for Java Programmers ?

2005-01-12 Thread michael
Hi there,

I am somewhat confused by the following :

class C(object):
def getx(self): return self.__x
def setx(self, value): self.__x = "extended" + value
def delx(self): del self.__x
x = property(getx, setx, delx, "I'm the 'x' property.")

So far so good :-) But what to do with this now

>>> c = C
>>> c

>>> dir (c)
['__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__weakref__', 'delx', 'getx', 'setx', 'x']
>>> c.x

>>>

?? What can I do with this "property object" now.

Confused greetings

Michael
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iteration over two sequences

2005-01-12 Thread John Lenton
> Quite frequently, I find the need to iterate over two sequences at
the
> same time, and I have a bit of a hard time finding a way to do this
in a
> "pythonic" fashion. One example is a dot product. The straight-ahead
> C-like way of doing it would be:
>
> def dotproduct(a, b):
>psum = 0
>for i in range(len(a)):
>psum += a[i]*b[i]
>return psum

for this particular example, the most pythonic way is to do nothing at
all, or, if you must call it dotproduct,
>>> from Numeric import dot as dotproduct

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2 versions of python on 1 machine

2005-01-12 Thread Peter Hansen
flupke wrote:
I searched with Google and on this newsgroups and i didn't find any info 
regarding this. If there is more info, please redirect me to that info.
[snip]
The above looks like a glitch or accidental repost of the post that
started this thread:
http://groups.google.ca/groups?threadm=YLedndIVKMWwhn3cRVn-rA%40powergate.ca
(Was it just on my server or did others get this strange repost?)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread Craig Ringer
On Wed, 2005-01-12 at 16:58 +0100, Gerhard Haering wrote:
> On Wed, Jan 12, 2005 at 10:15:34AM -0500, Jane wrote:
> > [...] Some people have too much time on their hands...
> 
> OMG, PyPy is full of evil, too!!!1
> 
> print sum([ord(x) for x in "PyPy"])
> 
> or, if you haven't upgraded to 2.4, yet:

That'll work fine in Python 2.3. I think you meant:

print sum(ord(x) for x in "PyPy")

which is a different matter entirely (well, regarding compatibility
anyway).

--
Craig Ringer

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANNOUNCE] Twenty-first release of PythonCAD now available

2005-01-12 Thread Art Haas
I'm pleased to announce the twenty-first development release of PythonCAD,
a CAD package for open-source software users. As the name implies,
PythonCAD is written entirely in Python. The goal of this project is
to create a fully scriptable drafting program that will match and eventually
exceed features found in commercial CAD software. PythonCAD is released
under the GNU Public License (GPL).

PythonCAD requires Python 2.2 or newer. The interface is GTK 2.0
based, and uses the PyGTK module for interfacing to GTK. The design of
PythonCAD is built around the idea of separating the interface
from the back end as much as possible. By doing this, it is hoped
that both GNOME and KDE interfaces can be added to PythonCAD through
usage of the appropriate Python module. Addition of other PythonCAD 
interfaces will depend on the availability of a Python module for that
particular interface and developer interest and action.

The twenty-first release of PythonCAD adds the ability to save
the visibility and locked status of entities when saving a drawing.
This release also includes improved code for handling the undo/redo
operations by simplifying various routines as well as making
similiar routines in various modules consistent. Like all previous
releases, numerous bug fixes and code improvements have been applied.

A mailing list for the development and use of PythonCAD is available.
Visit the following page for information about subscribing and viewing
the mailing list archive:

http://mail.python.org/mailman/listinfo/pythoncad

Visit the PythonCAD web site for more information about what PythonCAD
does and aims to be:

http://www.pythoncad.org/

Come and join me in developing PythonCAD into a world class drafting
program!

Art Haas
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822
-- 
http://mail.python.org/mailman/listinfo/python-list


Why would I get a TypeEror?

2005-01-12 Thread It's me
For this code snip:

a=3

b=(1,len(a))[isinstance(a,(list,tuple,dict))]

Why would I get a TypeError from the len function?

Thanks,


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: property () for Java Programmers ?

2005-01-12 Thread Steven Bethard
michael wrote:
Hi there,
I am somewhat confused by the following :
class C(object):
def getx(self): return self.__x
def setx(self, value): self.__x = "extended" + value
def delx(self): del self.__x
x = property(getx, setx, delx, "I'm the 'x' property.")
So far so good :-) But what to do with this now

c = C
c

dir (c)
['__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__weakref__', 'delx', 'getx', 'setx', 'x']
c.x

?? What can I do with this "property object" now.
Well, if you actually want your getx/setx/delx to be called, then you 
need an *instance* of class C:

py> c = C()
py> c.x
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 2, in getx
AttributeError: 'C' object has no attribute '_C__x'
py> c.x = "42"
py> c.x
'extended42'
py> del c.x
py> c.x
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 2, in getx
AttributeError: 'C' object has no attribute '_C__x'
Note that I used 'c = C()' instead of 'c = C' as in your code.
STeve
--
http://mail.python.org/mailman/listinfo/python-list


Removing M2Crypto debug data in production code

2005-01-12 Thread Ola Natvig
Hi all
I'm writing a SSL server and we are using M2Crypto as our SSL engine. 
What bothers me is that on every accept it prints a lot of 'junk-data' 
to my stdout. It would be nice if someone knew a way to get M2Crypto out 
 of debug mode and into a more silent mode.

LOOP: SSL accept: before/accept initialization
LOOP: SSL accept: SSLv3 read client hello A
LOOP: SSL accept: SSLv3 write server hello A
LOOP: SSL accept: SSLv3 write certificate A
LOOP: SSL accept: SSLv3 write key exchange A
LOOP: SSL accept: SSLv3 write server done A
LOOP: SSL accept: SSLv3 flush data
LOOP: SSL accept: SSLv3 read client key exchange A
LOOP: SSL accept: SSLv3 read finished A
LOOP: SSL accept: SSLv3 write change cipher spec A
LOOP: SSL accept: SSLv3 write finished A
LOOP: SSL accept: SSLv3 flush data
INFO: SSL accept: SSL negotiation finished successfully
regards
Ola Natvig
--
--
 Ola Natvig <[EMAIL PROTECTED]>
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Architecture of Python" was removed ?

2005-01-12 Thread Skip Montanaro

Someone> Does anyone here have a copy of that document? Or who can tell
Someone> me what is the email address of Jim Jackson or Kar-Han Tan.

Nick> 
http://web.archive.org/web/2003101953/http://wiki.cs.uiuc.edu/cs427/PYTHON

Gerrit> This is again a nice document, and an example of a document that
Gerrit> presumably has been removed because of maintenance
Gerrit> reasons. Shouldn't we have a collection (archive) of these
Gerrit> documents at python.org?

Yes, perhaps.  Note that it doesn't appear that the Wayback Machine contains
the meat of the essay, just the front page.  It came from a wiki.  Perhaps
the sysadmin folks at UIUC can dredge the content up from backup, though I
suspect they'd be unlikely to do that. 

Ah, wait...  Google to the rescue yet again.  Try Googling for

python cs427 site:uiuc.edu

then pull the pages of interest out of Google's cache.

Jim Jackson's UIUC email address is/was [EMAIL PROTECTED]  Jim, if
you're out there, is it okay to reconstruct your old C427 assignment
somewhere else?

-- 
Skip Montanaro
[EMAIL PROTECTED]
http://www.mojam.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a new Perl/Python a day

2005-01-12 Thread Jeff Shannon
Jon Perez wrote:
... or why 'Perl monkey' is an oft-heard term whereas 'Python
monkey' just doesn't seem to be appropriate?
That's just because pythons are more likely to *eat* a monkey than to 
be one  :)

Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: MoinMoin and Mediawiki?

2005-01-12 Thread Alexander Schremmer
On 11 Jan 2005 21:24:51 -0800, Paul Rubin wrote:

[backlinks]
>> Searching instead of indexing makes it very resilient :-)
> 
> How does it do that?  It has to scan every page in the entire wiki?!
> That's totally impractical for a large wiki.

So you want to say that c2 is not a large wiki? :-)

Kind regards,
Alexander
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: java 5 could like python?

2005-01-12 Thread more i squawed
vegetax wrote :
I was a java developer one year ago ,before i moved to python i realy liked 
it at the beggining, but i got very disapointed lately since my 
previus two python proyects where relatively big,and python didnt feel 
well suited for the task.

The reasons are mainly due to the standard library,the language
performance was aceptable, but the library, in my opinion has several grave
issues:
-No naming convention. The speech of "it fits in my head" is no longer valid
when i use a lot of functionality,modules,classes in a large proyect.
For example if i remember a function i want ie:get attribute, i dont
remember if the module implementer coded it as
getAttribute,GetAttribute,get_attribute, then i have to go and check the
doc, every time,which is a waste of time.
I believe this is a rather ill-suited example. People will react.
-library Organization,we have modules that can have 20 classes(I imagine
that is because of the commodity of having all in one file)
I challenge you to comparative statistics with Java.
which makes
reading the doc horribly painfull and is very hard to find the stuff
coupled with the "pool" of modules that is the python installation
directory,all throwed away at the installation directory without a
categorization.
Well, for the soothing it can provide, I often feel nostalgic of the 
python documentation when I use javadoc.

-Is python library half object oriented? half functional oriented? I can
understand that python allows some functional programing components when
they are necesary,but there are libraries that totaly ignore object
orientation which makes them problematic to use.for example,Whats with the
os.path module and files? why do i have to say os.path.getfilesize(f.name)
all the time? why cant i say f.size? Why does urlparse returns a tuple of 7
items instead of an URL object? why there isnt an URL object? and so on.. 

I havent figured out a way to overcome those factors,the delaying and lost
of focus that is having to check the docs all the time,every 5 seconds and
having to make object oriented wrapers for several libraries or having to
go and read the source code to know what the heck a function returns or
what are its arguments makes coding unpleasant an very slow , i often have
15 pydocs windows open at the same time. What should i do?
First, you should believe the newsgroup when you get told that reading 
the source code "to know what the heck a function returns" is a not a 
need the python documentation leaves most pythoneers with.

-Realying on ides is imposible due to python dinamic nature,very litle(next
to nothing) assistance can be espected from them.
-Memorazing all the function names,parameters,return values,conventions of
the modules i use doesnt look like a good solution.
Join it with poor and outdated documention and we have a very unpleasant
standard library.
You would be much closer to the mark, imho, by admitting that the main 
issue with "knowing a programming language" is knowing its standard 
library while feeling at home with the documentation thereof; *and* then 
admitting that changing languages generally implies the unpleasant 
experience of loosing touch with the content and style of one's beloved 
standard library and docs.

In the other hand, with the recent changes in java 5 i can pythonize
java,And take advantage of a well designed library that coupled with the
"apache commons" libraries has no match,not even .Net.
 for example with the static import feature i can say:
import static mylib.Toolbox.print;
import static mylib.Console.run;
// or import static mylib.Toolbox.*;
class C{
 public void func(){
   print("hello world"); // instead of System.out.println("hello world");
   print(run("ls /tmp"));
 }
}
Well you should provide the complete python equivalent, and I anticipate 
that you will be hard pressed to find someone on clp who will share your 
feeling that this java version is evidently better.

Regards.
--
http://mail.python.org/mailman/listinfo/python-list


Refactoring; arbitrary expression in lists

2005-01-12 Thread Frans Englich

As continuation to a previous thread, "PyChecker messages", I have a question 
regarding code refactoring which the following snippet leads to:

> > runner.py:200: Function (detectMimeType) has too many returns (11)
> >
> > The function is simply a long "else-if" clause, branching out to
> > different return statements. What's wrong? It's simply a "probably ugly
> > code" advice?
>
> That is also advice.  Generally you use a dict of functions, or some other
> structure to lookup what you want to do.

More specifically, my function looks like this:

#--
def detectMimeType( filename ):

extension = filename[-3:]
basename = os.path.basename(filename)

if extension == "php":
return "application/x-php"

elif extension == "cpp" or extension.endswith("cc"):
return "text/x-c++-src"
# etcetera
elif extension == "xsl":
return "text/xsl"

elif basename.find( "Makefile" ) != -1:
return "text/x-makefile"
   else:
raise NoMimeError
#--
(don't bother if the MIME detection looks like stone age, it's temporary until 
PyXDG gets support for the XDG mime type spec..)

I'm now wondering if it's possible to write this in a more compact way, such 
that the if-clause isn't necessary? Of course, the current code works, but 
perhaps it could be prettier.

I'm thinking along the lines of nested lists, but what is the obstacle for me 
is that both the test and return statement are simple expressions; not  
functions or a particular data type. Any ideas?


Cheers,

Frans

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why would I get a TypeEror?

2005-01-12 Thread harold fellermann
On 12.01.2005, at 18:35, It's me wrote:
For this code snip:
a=3

b=(1,len(a))[isinstance(a,(list,tuple,dict))]
Why would I get a TypeError from the len function?
because len() works only for sequence and mapping objects:
>>> help(len)
Help on built-in function len in module __builtin__:
len(...)
len(object) -> integer
Return the number of items of a sequence or mapping.
- harold -
--
Ceci n'est pas une signature.
--
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why would I get a TypeEror?

2005-01-12 Thread harold fellermann
On 12.01.2005, at 18:35, It's me wrote:
For this code snip:
a=3

b=(1,len(a))[isinstance(a,(list,tuple,dict))]
Why would I get a TypeError from the len function?
the problem is, that (1,len(a)) is evaluated, neither what type a 
actually has
(python has no builtin lazy evaluation like ML). You have to do it this 
way
instead:

a=3
...
b = isinstance(a,(list,tuple,dict)) and len(a) or 1
- harold -
--
The opposite of a correct statement is a false statement.
But the opposite of a profound truth may be another profound truth.
-- Niels Bohr
--
http://mail.python.org/mailman/listinfo/python-list


Re: ConfigParser - add a stop sentinel?

2005-01-12 Thread Larry Bates
You should probably consider NOT doing what you suggest.  You
would need to do some rather extensive work so you can support
the .write method of ConfigParser.  With a little ingenuity
I've been able to user ConfigParser to support some very
different and complex syntaxes on different projects.  If this
won't work, just have two different (separate) files.
If you are dead set on combining these two, put your foreign
syntax lines into the file as comments.  ConfigParser will
not process them, and you can have some other class extract
only the comments and parse them independently.
Regards,
Larry Bates

rzed wrote:
I am working with PythonCard in one of my apps. For its purposes, it 
uses an .ini file that is passed to ConfigParser. For my app, I also 
need configuration information, but for various reasons, I'd rather 
use a syntax that ConfigParser can't handle.

I know I can maintain two separate configuration files, and if I have 
to I will, but I'd rather avoid that, if possible, and a solution 
that suits my purposes is quite straightforward. I insert a sentinel 
in the ini file and modify my local ConfigParser's _read method to 
stop accepting input when it encounters that value. I handle my app's 
portion of the configuration myself.

This all works fine, but I was wondering whether it might be 
worthwhile to add a standard stop flag in ConfigParser itself. Am I 
the only one with this sort of use case? If there were a standard way 
of doing this, I'd much rather use that, particularly if I ever have 
reason to distribute the app elsewhere.
--
http://mail.python.org/mailman/listinfo/python-list


counting items

2005-01-12 Thread It's me
Okay, I give up.

What's the best way to count number of items in a list?

For instance,

a=[[1,2,4],4,5,[2,3]]

I want to know how many items are there in a (answer should be 7 - I don't
want it to be 4)

I tried:

b=len([x for y in a for x in y])

That doesn't work because you would get an iteration over non-sequence.

I tried:

g=lambda x: (1,len(x))[isinstance(x,(list,tuple,dict))]
b=sum(lambda(x) for x in a)

and that didn't work because I get a TypeError from the len function (don't
know why)

I can, of course:

i=0
for x in a:
if isinstance(x,(list,tuple,dict)):
i += len(x)
else:
i += 1

but that's so C-like...

Thanks,


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iteration over two sequences

2005-01-12 Thread It's me
I tried this and I got:

[(1, 'a'), (2, 'b'), (3, 'c')]

But if I change:

a=[1,2]

I got:

[(1, 'c')]

Why is that?  I thought I should be getting:

[(1, 'a'),(2,'b')]

?


"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> zip or izip is your friend:
>
> import itertools
>
> a = [1,2,3]
> b = ['a', 'b', 'c']
>
> for a,b in itertools.izip(a, b):
> print a, b
>
> -- 
> Regards,
>
> Diez B. Roggisch


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why would I get a TypeEror?

2005-01-12 Thread Peter Hansen
It's me wrote:
For this code snip:
a=3

b=(1,len(a))[isinstance(a,(list,tuple,dict))]
Why would I get a TypeError from the len function?
What did you expect the "length" of the integer 3 to be?
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: counting items

2005-01-12 Thread Andrew Koenig
"It's me" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> What's the best way to count number of items in a list?
>
> For instance,
>
> a=[[1,2,4],4,5,[2,3]]
>
> I want to know how many items are there in a (answer should be 7 - I don't
> want it to be 4)

How about this?

def totallen(x):
if isinstance(x, (list, tuple, dict)):
return sum(map(totallen, x))
return 1


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: counting items

2005-01-12 Thread Mark McEahern
It's me wrote:
Okay, I give up.
What's the best way to count number of items in a list [that may contain lists]?
 

a = [[1,2,4],4,5,[2,3]]
def iterall(seq):
   for item in seq:
   try:
   for subitem in iterall(item):
   yield subitem
   except TypeError:
   yield item
all = [x for x in iterall(a)]
print len(all)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: Pythonwin

2005-01-12 Thread drs
"Brent W. Hughes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 1)  I'm running a program within Pythonwin.  It's taking too long and I
want
> to stop/kill it.  What do I do (other than ctrl-alt-del)?
>
Right click on the little python icon in the sys tray and select break into
running code



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: counting items

2005-01-12 Thread Paul McGuire
"It's me" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Okay, I give up.
>
> What's the best way to count number of items in a list?
>
> For instance,
>
> a=[[1,2,4],4,5,[2,3]]
>
> I want to know how many items are there in a (answer should be 7 - I don't
> want it to be 4)
>


I've sure seen a lot of questions about the flattening of lists.  I found
this version of flatten somewhere, I thought I got it from the Python
Cookbook but I can't find it now.  Perhaps it was posted here on c.l.py.  I
*don't* claim authorship, I'm merely an admirer of such a clean-looking
solution.

def flatten(a):
if not isinstance(a, (tuple,list)): return [a]
if len(a)==0: return []
return flatten(a[0])+flatten(a[1:])

a = [[1, 2, 4], 4, 5, [2, 3], 6, [6], [], 'askjdf']

print len(flatten(a))

gives the value 10.

Considering how often this comes up, might there be a place for some sort of
flatten() routine in the std dist, perhaps itertools?

-- Paul


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iteration over two sequences

2005-01-12 Thread Henrik Holm
John Lenton <[EMAIL PROTECTED]> wrote:

> > def dotproduct(a, b):
> >psum = 0
> >for i in range(len(a)):
> >psum += a[i]*b[i]
> >return psum
> 
> for this particular example, the most pythonic way is to do nothing at
> all, or, if you must call it dotproduct,
> >>> from Numeric import dot as dotproduct

Downloading, installing, and getting to know numerical modules for
Python is mext on my list :).  However, I was under the impression that
Numarray is preferred to Numeric -- is that correct?  Are these two
competing packages?  (Hopefully this is not flame war bait...)

-- 
"On some great and glorious day the plain folks of the land will reach
in their heart's desire at last and the White House will be adorned by
a downright moron."
 -H.L. Mencken (1880-1956) American Writer 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: complex numbers

2005-01-12 Thread Robert Kern
It's me wrote:
"Robert Kern" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
That's *it*.

So, how would you overload an operator to do:
With native complex support:
def  twice(a):
return 2*a
print twice(3+4j), twice(2), twice("abc")
Let's presume for a moment that complex is *not* a native data type in
Python.  How would we implement the above - cleanly?
The way it's implemented now. See the file Object/complexobject.c for 
details. Numeric operations on ints, longs, floats, and complex numbers 
are all implemented using operator overloading.

There's nothing special about the complex object. One can even remove it 
from the language quite easily. Some of the embedded versions of Python 
have in fact done so.

--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: counting items

2005-01-12 Thread Anthony
On Wed, 12 Jan 2005 17:42:50 GMT, It's me <[EMAIL PROTECTED]> wrote:
> Okay, I give up.
> 
> What's the best way to count number of items in a list?

How long is a piece of string? There are many different ways, which
give you different trade offs.

> For instance,
> 
> a=[[1,2,4],4,5,[2,3]]
> 
> I want to know how many items are there in a (answer should be 7 - I don't
> want it to be 4)
> 
> I tried:
> 
> b=len([x for y in a for x in y])
> 
> That doesn't work because you would get an iteration over non-sequence.

And is very unreadable.

> I tried:
> 
> g=lambda x: (1,len(x))[isinstance(x,(list,tuple,dict))]
> b=sum(lambda(x) for x in a)
> 
> and that didn't work because I get a TypeError from the len function (don't
> know why)

Because you're trying to get the length of an integer, which is what's failing.

If you know that the list nesting is only one deep, you can do something like:

===
#!/usr/local/bin/python

compoundList = [[1,2,4],4,5,[2,3]]

listLengths = [len(item) for item in compoundList if type(item) not in
[int,long,str,float]]
print listLengths

compoundLength = len(compoundList) - len(listLengths) + sum(listLengths)
print compoundLength
===

If the nesting is 2 deep or more, then the next two options that I
would explore would be:

1. Have a look in the standard library. I'm pretty sure that there are
list-manipulation libraries that'll do what you want (not sure on
names, though).
2. Write a function to do what you want. Some sort of recursive thing
should be pretty easy to write. Of course it depends on how fast you
need to go, but that should give you a good first approximation.

Anthony

-- 
-
 HyPEraCtiVE? HeY, WhO aRE YoU cALliNg HypERaCtIve?!
 [EMAIL PROTECTED]
-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why would I get a TypeEror?

2005-01-12 Thread It's me
Sorry if my question was a little "lazy" and yes, I was asking about the
"lazy evaluation".  :=)

I am surprised about this (and this can be dangerous, I guess).

If this is true, I would run into trouble real quick if I do a:

(1/x,1.0e99)[x==0]

and that's not good.

Something to keep in mind.  :-(


"harold fellermann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> On 12.01.2005, at 18:35, It's me wrote:
>
> > For this code snip:
> >
> > a=3
> > 
> > b=(1,len(a))[isinstance(a,(list,tuple,dict))]
> >
> > Why would I get a TypeError from the len function?
>
> the problem is, that (1,len(a)) is evaluated, neither what type a
> actually has
> (python has no builtin lazy evaluation like ML). You have to do it this
> way
> instead:
>
> a=3
> ...
> b = isinstance(a,(list,tuple,dict)) and len(a) or 1
>
> - harold -
>
> --
> The opposite of a correct statement is a false statement.
> But the opposite of a profound truth may be another profound truth.
> -- Niels Bohr
>


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: complex numbers

2005-01-12 Thread Terry Reedy

"It's me" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Precisely.   One have to convert complex number into vectors, and vector 
> of
> complex numbers into vector of vectors, list of complex numbers into list 
> of
> vectors, , you get the idea.

No, one would have a class with all the appropriate special methods 
defined.  This is what people did before complex was made built-in.  The 
advantage of builtin-ness is being able to write complex literals: 1 + 1j, 
etc, instead of Complex(1,1).  This and speed were two reasons to make 
complex numbers builtin.

The new decimal type, in spite of being builtin (written in C), has the 
same 'problem' because decimal literals were alread being converted to 
binary floating point.  Perhaps some day we might have 1.23d to indicate 
conversion to decimal instead.  Or perhaps 1.23 will become a decimal and 
1.23f a float.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >