Re: re sub help

2005-11-05 Thread s99999999s2003
thanks for the reply.

i am still interested about using re, i find it useful. am still
learning it's uses.
so i did something like this for a start, trying to get everything in
between [startdelim] and [enddelim]

a =
"this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"

t = re.compile(r"\[startdelim\](.*)\[enddelim\]")

t.findall(a)
but it gives me []. it's the "\n" that prevents the results.
why can't (.*) work in this case? Or am i missing some steps to "read"
in the "\n"..?
thanks.

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


Re: How can I do this in Python?

2005-11-05 Thread Lad
Can you please explain in more details (1) choice?
Thanks
Regards,
L

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


Re: re sub help

2005-11-05 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote:

> i am still interested about using re, i find it useful. am still
> learning it's uses.
> so i did something like this for a start, trying to get everything in
> between [startdelim] and [enddelim]
>
> a =
> "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"
>
> t = re.compile(r"\[startdelim\](.*)\[enddelim\]")

"*" is greedy (=searches backwards from the right end), so that won't
do the right thing if you have multiple delimiters

to fix this, use "*?" instead.

> t.findall(a)
> but it gives me []. it's the "\n" that prevents the results.
> why can't (.*) work in this case? Or am i missing some steps to "read"
> in the "\n"..?

http://docs.python.org/lib/re-syntax.html

 (Dot.) In the default mode, this matches any character except
a newline. If the DOTALL flag has been specified, this matches any
character including a newline.

to fix this, pass in re.DOTALL or re.S as the flag argument, or
prepend (?s) to the expression.





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


Re: re sub help

2005-11-05 Thread Mike Meyer
[EMAIL PROTECTED] writes:
> i am still interested about using re, i find it useful. am still
> learning it's uses.
> so i did something like this for a start, trying to get everything in
> between [startdelim] and [enddelim]
>
> a =
> "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"
>
> t = re.compile(r"\[startdelim\](.*)\[enddelim\]")
>
> t.findall(a)
> but it gives me []. it's the "\n" that prevents the results.
> why can't (.*) work in this case? Or am i missing some steps to "read"
> in the "\n"..?
> thanks.

Newlines are magic to regular expressions. You use the flags in re to
change that. In this case, you want . to match them, so you use the
DOTALL flag:

>>> a = "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"
>>> t = re.compile(r"\[startdelim\](.*)\[enddelim\]", re.DOTALL)
>>> t.findall(a)
['this\nis\nanother']
>>> 

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting Python Accepted in my Organisation

2005-11-05 Thread Chris F.A. Johnson
On 2005-11-05, Steven D'Aprano wrote:
> On Fri, 04 Nov 2005 20:55:48 -0500, Chris F.A. Johnson wrote:
>
>
>
> So that people reading your reply know what you are commenting about.
>
> (Now, imagine that you're reading from a newsgroup where Chris' post has
> disappeared off the server, or perhaps never showed up at all.)

   Did I say something???

-- 
  Chris F.A. Johnson   | Author:
    |  Shell Scripting Recipes:
  Any code in this post is released|  A Problem-Solution Approach,
  under the GNU General Public Licence | 2005, Apress
-- 
http://mail.python.org/mailman/listinfo/python-list


modifying source at runtime - jython case

2005-11-05 Thread Jan Gregor
Hello folks

 I want to apply changes in my source code without stopping jython
 and JVM. Preferable are modifications directly to instances of
 classes. My application is a desktop app using swing library.
 
 Python solutions also interest me.

 Solution similiar to "lisp way" is ideal.


Thanks for response,
Jan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting Python Accepted in my Organisation

2005-11-05 Thread Steven D'Aprano
On Sat, 05 Nov 2005 04:12:38 -0500, Chris F.A. Johnson wrote:

> On 2005-11-05, Steven D'Aprano wrote:
>> On Fri, 04 Nov 2005 20:55:48 -0500, Chris F.A. Johnson wrote:
>>
>>
>>
>> So that people reading your reply know what you are commenting about.
>>
>> (Now, imagine that you're reading from a newsgroup where Chris' post has
>> disappeared off the server, or perhaps never showed up at all.)
> 
>Did I say something???

Yes.

Quoting from your earlier post, including the text you quoted:

[quote]
> I would only do in-line response type when there is a need for
> specific response in context.

If there's not, why would you quote anything?
[end quote]


You should almost always quote *something*, if only to give some
context. If there is no context at all, you almost certainly want to
start a new thread.


-- 
Steven.

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


Python doc problem example: gzip module (reprise)

2005-11-05 Thread Xah Lee
Python Doc Problem Example: gzip

Xah Lee, 20050831

Today i need to use Python to compress/decompress gzip files. Since
i've read the official Python tutorial 8 months ago, have spent 30
minutes with Python 3 times a week since, have 14 years of computing
experience, 8 years in mathematical computing and 4 years in unix admin
and perl, i have quickly found the official doc:
http://python.org/doc/2.4.1/lib/module-gzip.html

I'd imagine it being a function something like:

fileContent = GzipFile(filePath, comprress/decompress)

However, scanning the doc after 20 seconds there's no single example
showing how it is used.

Instead, the doc starts with some arcane info about compatibility with
some other compression module and other software. Then it talks in a
very haphazard way with confused writing about the main function
GzipFile. No perspectives whatsoever about using it to solve a problem
nor a concrete description of how to use it. Instead, jargons of Class,
Constructor, Object etc are thrown together with presumption of
reader's expertise of IO programing in Python and gzip compression
arcana.

After no understanding, and being not a Python expert, i wanted to read
about file objects but there's no link.

After locating the file object's doc page:
http://python.org/doc/2.4.1/lib/bltin-file-objects.html, but itself is
written and organized in a very unhelpful way.

Here's the detail of the problems of its documentation. It starts with:

«The data compression provided by the zlib module is compatible
with that used by the GNU compression program gzip. Accordingly, the
gzip module provides the GzipFile class to read and write gzip-format
files, automatically compressing or decompressing the data so it looks
like an ordinary file object. Note that additional file formats which
can be decompressed by the gzip and gunzip programs, such as those
produced by compress and pack, are not supported by this module.»

This intro paragraph is about 3 things: (1) the purpose of this gzip
module. (2) its relation with zlib module. (3) A gratuitous arcana
about gzip program's support of “compress and pack” software being
not supported by Python's gzip module. Necessarily mentioned because
how the writing in this paragraph is phrased. The writing itself is a
jumble.

Of the people using the gzip module, vast majority really just need to
decompress a gzip file. They don't need to know (2) and (3) in a
preamble. The worst aspect here is the jumbled writing.

«class GzipFile( [filename[, mode[, compresslevel[, fileobj)
Constructor for the GzipFile class, which simulates most of the methods
of a file object, with the exception of the readinto() and truncate()
methods. At least one of fileobj and filename must be given a
non-trivial value. The new class instance is based on fileobj, which
can be a regular file, a StringIO object, or any other object which
simulates a file. It defaults to None, in which case filename is opened
to provide a file object.»

This paragraph assumes that readers are thoroughly familiar with
Python's File Objects and its methods. The writing is haphazard and
extremely confusive. Instead of explicitness and clarity, it tries to
convey its meanings by side effects.

• The words “simulate” are usd twice inanely. The sentence
“...Gzipfile class, which simulates...” is better said by
“Gzipfile is modeled after Python's File Objects class.”

• The intention to state that it has all Python's File Object methods
except two of them, is ambiguous phrased. It is as if to say all
methods exists, except that two of them works differently.

• The used of the word “non-trivial value” is inane. What does a
non-trivial value mean here? Does “non-trivial value” have specific
meaning in Python? Or, is it meant with generic English interpretation?
If the latter, then what does it mean to say: “At least one of
fileobj and filename must be given a non-trivial value”? Does it
simply mean one of these parameters must be given?

• The rest of the paragraph is just incomprehensible.

«When fileobj is not None, the filename argument is only used to
be included in the gzip file header, which may includes the original
filename of the uncompressed file. It defaults to the filename of
fileobj, if discernible; otherwise, it defaults to the empty string,
and in this case the original filename is not included in the header.»

“discernible”? This writing is very confused, and it assumes the
reader is familiar with the technical specification of Gzip.

«The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or
'wb', depending on whether the file will be read or written. The
default is the mode of fileobj if discernible; otherwise, the default
is 'rb'. If not given, the 'b' flag will be added to the mode to ensure
the file is opened in binary mode for cross-platform portability.»

“discernible”? Again, familiarity with the working of Python's file
object is implicitly assumed. For people who do not have expertise 

Using Which Version of Linux

2005-11-05 Thread [EMAIL PROTECTED]
ok, i m going to use Linux for my Python Programs, mainly because i 
need to see what will these fork() and exec() do. So, can anyone tell 
me which flavour of linux i should use, some say that Debian is more 
programmer friendly, or shold i use fedora, or Solaris. Because these 
three are the only ones i know of that are popular and free.
-- 
 * Posted with NewsLeecher v3.0 Beta 7
 * http://www.newsleecher.com/?usenet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread [EMAIL PROTECTED]
They are all the same as you don't have specific requirements
mentioned. Based on the way you ask, I would say some debian derivative
like ubuntu. debian is not programmer friendly but admin friendly I
would say. In general programmer friendly distro to me would mean
install everything one can possiblity think of by default so everything
is at hand for use.

Never tried the new solaris so I have no idea but I had some problem
when installed their old x86 a few years back however things may have
changed a lot.

I tried briefly with fedora but its packaging system is not up to par,
comparing with debian. However, you get newer things in fedora, in
general. Fedora has the advantage that it works better with commercial
stuff like Oracle/Sybase. I had problem making Sybase installed under
debian(the reason why I tried fedora).

[EMAIL PROTECTED] wrote:
> ok, i m going to use Linux for my Python Programs, mainly because i
> need to see what will these fork() and exec() do. So, can anyone tell
> me which flavour of linux i should use, some say that Debian is more
> programmer friendly, or shold i use fedora, or Solaris. Because these
> three are the only ones i know of that are popular and free.
> --
>  * Posted with NewsLeecher v3.0 Beta 7
>  * http://www.newsleecher.com/?usenet

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


Converting a List into a String

2005-11-05 Thread [EMAIL PROTECTED]
I have a List

list = ['f', 'e', 'd', 'c', 'b', 'a']

How can i convert it into a string so the output is

fedcba

i used

for a in list:
  print a,

the output is 

f e d c b a

How can i remove the spaces b/w each letter?
-- 
 * Posted with NewsLeecher v3.0 Beta 7
 * http://www.newsleecher.com/?usenet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting a List into a String

2005-11-05 Thread [EMAIL PROTECTED]
''.join['h','i']

[EMAIL PROTECTED] wrote:
> I have a List
>
> list = ['f', 'e', 'd', 'c', 'b', 'a']
>
> How can i convert it into a string so the output is
>
> fedcba
>
> i used
>
> for a in list:
>   print a,
>
> the output is
>
> f e d c b a
>
> How can i remove the spaces b/w each letter?
> --
>  * Posted with NewsLeecher v3.0 Beta 7
>  * http://www.newsleecher.com/?usenet

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


Re: Converting a List into a String

2005-11-05 Thread Will McGugan
[EMAIL PROTECTED] wrote:
> I have a List
> 
> list = ['f', 'e', 'd', 'c', 'b', 'a']
> 
> How can i convert it into a string so the output is
> 
> fedcba
> 
> i used
> 
> for a in list:
>   print a,
> 
> the output is 
> 
> f e d c b a
> 
> How can i remove the spaces b/w each letter?

print "".join(list)

BTW list isnt a good name for a list, it hides the built in type.


Will McGugan
-- 
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
"jvyy*jvyyzpthtna^pbz")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread Maciej Dziardziel
blahman ([EMAIL PROTECTED]) wrote:

> ok, i m going to use Linux for my Python Programs, mainly because i
> need to see what will these fork() and exec() do. So, can anyone tell
> me which flavour of linux i should use, some say that Debian is more
> programmer friendly, or shold i use fedora, or Solaris. Because these
> three are the only ones i know of that are popular and free.

A standard answer is - use that one, which is known to your friends, so they
can help you. Actually all Linux distros come with python and huge amount
of additional modules, so choose any. Fedora, Mandrake, Suse and Ubuntu
willi be easier for begginers, as they are targeted on inexperienced Linux
users (what doesn't mean they cannot be used by experienced),
Debian requires some knowledge (well, way more then other distros) but i
like it for its clarity, wonderful package manager apt and control i have
over it, it is also well documented and popular. I suggest first use
Knoppix - Debian based distro, that boots from cd, doesn't require
installation and contains tons of software, including python of course.
Solaris is a different os, has nothing to do with Linux.

-- 
Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
www.fiedzia.prv.pl

It is my fondest hope that you are reading these while you should be  
   working. Isn't that what the net's really about anyways? Sort of a place  
   to go 'researching' while you should be getting stuff done!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread Mike Meyer
blahman ([EMAIL PROTECTED]) writes:
> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.

You seem a bit confused. Solaris isn't a Linux distribution, it's
(System V) Unix. Linux isn't Unix - it's a Unix look-like. *BSD is
Unix, but they can't call it that for licensing reasons.

"Programmer-friendly" is pretty vague. Gentoo is the only Linux distro
I've run into (which excludes a *lot* of Unix distros) that I'd
consider programmer friendly, because it doesn't split packages up
into "user stuff" and "developer stuff". That means you have to
install two packages instead of one if you want to build things
against that software. On the other hand, it uses it's own "package"
manager - emerge - so you can't take advantage of rpms/debs from other
systems (or you couldn't last time I looked into it). It also installs
the least amount of "bundled" software, which I consider a programmer
friendly behavior.

Personally, I run FreeBSD - and I like gentoo because it has a lot in
common with a BSD distribution. FreeBSD is the most popular of the
BSDs. BSDs differ from Linuxen in that a BSD distribution is an
integrated whole - the kernel and userland are maintained by the same
group, in the same repository. So the number of BSD kernels to choose
from is much greater than the number of Linux kernels, but the number
of BSD distributions is much fewer.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python gc performance in large apps

2005-11-05 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, Robby 
Dermody <[EMAIL PROTECTED]> writes
>An update (along with a request for paid help at the end): Over the 
>past week and a half I've improved the memory usage situation by quite 
>a bit. Going to python 2.4, linux kernel 2.6, twisted 2.0 and altering 
>some code

I don't know if you have a Windows version of this software but if you 
do you may find Python Memory Validator useful.

http://www.softwareverify.com/pythonMemoryValidator/index.html

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: modifying source at runtime - jython case

2005-11-05 Thread Alan Kennedy
[Jan Gregor]
>  I want to apply changes in my source code without stopping jython
>  and JVM. Preferable are modifications directly to instances of
>  classes. My application is a desktop app using swing library.
>  
>  Python solutions also interest me.
> 
>  Solution similiar to "lisp way" is ideal.

OK, I'll play 20 questions with you.

How close is the following to what you're thinking?

begin SelfMod.java ---
//
import org.python.util.PythonInterpreter;
import org.python.core.*;

class SelfMod
   {

   static String my_class_source =
 "class MyJyClass:\n" +
 "  def hello(self):\n" +
 "print 'Hello World!'\n";

   static String create_instance = "my_instance = MyJyClass()\n";

   static String invoke_hello = "my_instance.hello()";

   static String overwrite_meth =
 "def goodbye():\n"+
 "  print 'Goodbye world!'\n" +
 "\n" +
 "my_instance.hello = goodbye\n";

   public static void main ( String args[] )
 {
 PythonInterpreter interp = new PythonInterpreter();
 interp.exec(my_class_source);
 interp.exec(create_instance);
 interp.exec(invoke_hello);
 interp.exec(overwrite_meth);
 interp.exec(invoke_hello);
 }

   }
//
end SelfMod.java -

need-to-complete-my-coursework-for-telepathy-101-ly y'rs

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting a List into a String

2005-11-05 Thread Leif K-Brooks
[EMAIL PROTECTED] wrote:
> list = ['f', 'e', 'd', 'c', 'b', 'a']
> 
> How can i convert it into a string so the output is
> 
> fedcba

print ''.join(list)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using graphviz to visualize trace.py output, anybody?

2005-11-05 Thread Pieter Swart

[EMAIL PROTECTED] wrote:
> I was originally thinking of piping the output of trace.py into a text
> file and then have python massage that text file into a dot file for
> graphviz to visualize.
>
> Some formatting is possible with graphviz, but I would expect the graph
> to be very dependent on how the program under test runs so I have
> little idea what to expect.
>

To mangle graphs and their drawing via graphviz on multilple platforms,
you might also want to try networkx combined with pygraphviz
(available from networkx.lanl.gov)

Cheers, Pieter

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


Re: I Need Motivation Part 2

2005-11-05 Thread Sybren Stuvel
Dennis Lee Bieber enlightened us with:
> I show 185 .py files in the top level Python library. That's a close
> match for the base VC include directory -- and I be willing to bet
> that site-packages and other add-ins don't add up to another 700 .py
> files

Sorry, bet lost. I have 1891 .py files in my site-packages.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Gerard Flanagan
Xah Lee wrote:
> Python Doc Problem Example: gzip
>
> Xah Lee, 20050831
>
> Today i need to use Python to compress/decompress gzip files. Since
> i've read the official Python tutorial 8 months ago, have spent 30
> minutes with Python 3 times a week since, have 14 years of computing
> experience, 8 years in mathematical computing and 4 years in unix admin
> and perl, i have quickly found the official doc:
> http://python.org/doc/2.4.1/lib/module-gzip.html
>
> I'd imagine it being a function something like:
>
> fileContent = GzipFile(filePath, comprress/decompress)
>
> However, scanning the doc after 20 seconds there's no single example
> showing how it is used.
>
> Instead, the doc starts with some arcane info about compatibility with
> some other compression module and other software. Then it talks in a
> very haphazard way with confused writing about the main function
> GzipFile. No perspectives whatsoever about using it to solve a problem
> nor a concrete description of how to use it. Instead, jargons of Class,
> Constructor, Object etc are thrown together with presumption of
> reader's expertise of IO programing in Python and gzip compression
> arcana.
>
> After no understanding, and being not a Python expert, i wanted to read
> about file objects but there's no link.
>
> After locating the file object's doc page:
> http://python.org/doc/2.4.1/lib/bltin-file-objects.html, but itself is
> written and organized in a very unhelpful way.
>
> Here's the detail of the problems of its documentation. It starts with:
>
> «The data compression provided by the zlib module is compatible
> with that used by the GNU compression program gzip. Accordingly, the
> gzip module provides the GzipFile class to read and write gzip-format
> files, automatically compressing or decompressing the data so it looks
> like an ordinary file object. Note that additional file formats which
> can be decompressed by the gzip and gunzip programs, such as those
> produced by compress and pack, are not supported by this module.»
>
> This intro paragraph is about 3 things: (1) the purpose of this gzip
> module. (2) its relation with zlib module. (3) A gratuitous arcana
> about gzip program's support of “compress and pack” software being
> not supported by Python's gzip module. Necessarily mentioned because
> how the writing in this paragraph is phrased. The writing itself is a
> jumble.
>
> Of the people using the gzip module, vast majority really just need to
> decompress a gzip file. They don't need to know (2) and (3) in a
> preamble. The worst aspect here is the jumbled writing.
>
> «class GzipFile( [filename[, mode[, compresslevel[, fileobj)
> Constructor for the GzipFile class, which simulates most of the methods
> of a file object, with the exception of the readinto() and truncate()
> methods. At least one of fileobj and filename must be given a
> non-trivial value. The new class instance is based on fileobj, which
> can be a regular file, a StringIO object, or any other object which
> simulates a file. It defaults to None, in which case filename is opened
> to provide a file object.»
>
> This paragraph assumes that readers are thoroughly familiar with
> Python's File Objects and its methods. The writing is haphazard and
> extremely confusive. Instead of explicitness and clarity, it tries to
> convey its meanings by side effects.
>
> • The words “simulate” are usd twice inanely. The sentence
> “...Gzipfile class, which simulates...” is better said by
> “Gzipfile is modeled after Python's File Objects class.”
>
> • The intention to state that it has all Python's File Object methods
> except two of them, is ambiguous phrased. It is as if to say all
> methods exists, except that two of them works differently.
>
> • The used of the word “non-trivial value” is inane. What does a
> non-trivial value mean here? Does “non-trivial value” have specific
> meaning in Python? Or, is it meant with generic English interpretation?
> If the latter, then what does it mean to say: “At least one of
> fileobj and filename must be given a non-trivial value”? Does it
> simply mean one of these parameters must be given?
>
> • The rest of the paragraph is just incomprehensible.
>
> «When fileobj is not None, the filename argument is only used to
> be included in the gzip file header, which may includes the original
> filename of the uncompressed file. It defaults to the filename of
> fileobj, if discernible; otherwise, it defaults to the empty string,
> and in this case the original filename is not included in the header.»
>
> “discernible”? This writing is very confused, and it assumes the
> reader is familiar with the technical specification of Gzip.
>
> «The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or
> 'wb', depending on whether the file will be read or written. The
> default is the mode of fileobj if discernible; otherwise, the default
> is 'rb'. If not given, the 'b' flag will be added to the mode to ensure
> the file 

Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Jeffrey Schwab
Xah Lee wrote:

> i've read the official Python tutorial 8 months ago, have spent 30
> minutes with Python 3 times a week since, have 14 years of computing
> experience, 8 years in mathematical computing and 4 years in unix admin
> and perl

I can wiggle my ears.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: control webbrowser remotely?

2005-11-05 Thread Diez B. Roggisch
Martin Bless wrote:
> Web browsers like Firefox have really cool abilities nowadays. Objects
> in the current document can be addressed and manipulated by
> Javascript. Not very comfortable and not easy to debug.
> 
> Q: Is there a way to reach objects in the document from Python?
> That would be cool!
> 
> Like for instance it's possible to control Excel remotely on Windows.
> 
> Anybody knows something?

Its called automation and available in windows for ages. Its implemented 
via the COM component object model, and this can be used with Mark 
Hammond's win32 extensions for Python.

However, the Firefox object model (based on XCOM I believe) is a 
different beast - might be able to get a grip on it, but its firefox own 
thing then. And I'm not sure if it is possible to embed python instead 
of JScript.

Regards,

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


Re: Using Which Version of Linux

2005-11-05 Thread Jeffrey Schwab
[EMAIL PROTECTED] wrote:
> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.

Solaris isn't Linux, but it is good.  I've never installed it from 
scratch, though.

I might get lambasted for suggesting this, but try Slackware.  It will 
let you do a very minimal installation, which means there's less stuff 
that can go wrong.  It also has nice, beginner-friendly FAQs to help you 
get started.  Like the other distros already suggested, it comes with 
the graphical desktop environments Gnome and KDE, too.

If at all possible, have another computer available with a working 
internet connection and a floppy disc drive or CD burner.

Like Maciej said, if you have a buddy nearby who is already an expert on 
a particular distro, try that distro.  This is especially true for 
distros like Gentoo that have...  their own way of doing things. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python gc performance in large apps

2005-11-05 Thread Jay Parlar
You may also want to look at the following Summer of Code project:

http://pysizer.8325.org/

Their SVN repo is at http://codespeak.net/svn/user/nick8325/sizer/  I 
haven't had a chance to try it yet, but it might be exactly what you 
need. The project is described as

"PySizer is a library for measuring memory use of Python code"

Jay P.

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


ANN: Leo 4.4a2 withdrawn

2005-11-05 Thread Edward K. Ream
Leo 4.4a2 has been withdrawn due to problems that can cause Leo to lose what 
you have recently typed.

Leo 4.4a3 will be released in about a week.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Rick Wotnaz
"Gerard Flanagan" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> Xah Lee wrote:
>> Python Doc Problem Example: gzip
>>
[...]
>> A quality documentation should be clear, succinct, precise.
>> And, the least it assumes reader's expertise to obtain these
>> qualities, the better it is.
>>
>> Vast majority of programers using this module really just want
>> to compress or decompress a file. They do not need to know any
>> more details about the technicalities of this module nor about
>> the Gzip compression specification. Here's what Python
>> documentation writers should do to improve it:
>>
>> • Rewrite the intro paragraph. Example: “This module prov
> ides a
>> simple interface to compress and decompress files using the GNU
>> compression format gzip. For detailed working with gzip format,
>> use the zlib module.”. The “zlib module” phrase should be
>  linked to its
>> documentation.
>>
>> • Near the top of the documentation, add a example of usage.
>> A example is worth a thousand words:
>>
>>  # decompressing a file
>> import gzip
>> fileObj = gzip.GzipFile("/Users/joe/war_and_peace.txt.gz",
>> 'rb'); fileContent = fileObj.read()
>> fileObj.close()
>>
>>  # compressing a file
>> import gzip
>> fileObj = gzip.GzipFile("/Users/mary/hamlet.txt.gz", 'wb');
>> fileObj.write(fileContent)
>> fileObj.close()
>>
> 
> """
> You want to create the world before which you can kneel: this is
> your ultimate hope and intoxication.
> 
> Also sprach Zarathustra.
 
I've managed to avoid reading Xah Lee's diatribes for the most 
part. Since you included the *WHOLE THING* in your post, I had an 
"opportunity" to see what he had to say, and for once I agree with 
some of it. Some of us learn by example; sometimes an example is 
all we need to use a particular feature (especially one that we 
don't often have need for). The criticism that the documentation 
would be improved by adding some model code is valid for *all* 
documentation, I think, not just Python's.

Typically, when someone proposes changes to documentation to an 
open source project, someone else will come along and remind 
everyone that it's all volunteer effort, so why shouldn't the one 
doing the propopsing be the one to make the change? In the case of 
documentation, that approach would mean that those who have the 
least idea of how a module works should be the ones to describe it 
for everyone else, which seems a little backward to me. The 
examples should come from those who know what they're doing and 
they should explain what the example is doing -- just the sort of 
things a casual user wants to learn quickly.

Someone is sure to jump in now and point to sample code, which 
nearly all reasonably major packages include. That's good stuff. 
With (for example) wxPython, it's the only useful documentation, or 
rather, it's the only thing that makes the wxWidgets documentation 
useful. Links to code samples in the documentation would be fine in 
lieu of snippets of example calls. But there's not enough of either 
in most documentation.

I would love to see examples for essentially every function and 
method. And not just something that echoes the signature, but some 
context to show how it might be useful. That would be in the 
"intoxication" class of ultimate hopes. In most cases, though, it 
would be *extremely* helpful for a casual user of that part of the 
package.

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

Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Peter Hansen
Jeffrey Schwab wrote:
> Xah Lee wrote:
> 
>> i've read the official Python tutorial 8 months ago, have spent 30
>> minutes with Python 3 times a week since, have 14 years of computing
>> experience, 8 years in mathematical computing and 4 years in unix admin
>> and perl
> 
> I can wiggle my ears.

Which is almost as good as having spent, um, let's see... a grand total 
of 52 hours attempting to code in Python!  Which is to say roughly one 
week with a little overtime.

I've had a large number of co-op students and junior programmers come on 
board in a Python/agile group.  I've said here before that most of them 
were able to code reasonably in Python after only about one week, at 
least enough to contribute and participate.  Several took a few weeks to 
completely abandon their bad habits from other languages (e.g. coding 
"C"-style iterate-over-chars-in-a-string loops in Python).

Of course, most of them had a basic competence and ability to learn, so 
maybe for them 52 hours was much more effective than it is for others. 
Still, 52 hours is "nothing"... and doing it as "30 minutes, 3 times a 
week, for 8 months" vastly decreases the value of those 52 hours, even 
if it makes it sound much more impressive.  I'm not surprised now at 
what we keeping seeing here...

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


Re: How can I do this in Python?

2005-11-05 Thread Kent Johnson
Lad wrote:
> Can you please explain in more details (1) choice?

If you are using CGI you might be interested in the VoidSpace logintools which 
seems to handle much of this process. See
http://www.voidspace.org.uk/python/logintools.html#no-login-no-access

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


Re: Calling Class' Child Methods

2005-11-05 Thread Kent Johnson
Steve Holden wrote:
> Andrea Gavana wrote:
>> The class "Custom" has a lot of methods (functions), but the user 
>> won't call
>> directly this class, he/she will call the MainClass class to construct 
>> the
>> GUI app. However, all the methods that the user can call refer to the
>> "Custom" class, not the MainClass class. That is, the methods that the 
>> user
>> call should propagate to the "Custom" class. However, I know I can do:
>>
>> # Inside MainClass
>> def SomeMethod(self, param):
>> self.customwidget.SomeMethod(param)
>>
> It seems that what you need is a generic delegation.
> 
> This pattern (in Python, anyway) makes use of the fact that if the 
> interpreter can't find a method or other attribute for an object it will 
> call the object's __getattr__() method.

Another alternative is to delegate specific method by creating new attributes 
in MainClass. In MainClass.__init__() you can write
  self.SomeMethod = self.customwidget.SomeMethod
to automatically delegate SomeMethod. You can do this from a list of method 
names:
  for method in [ 'SomeMethod', 'SomeOtherMethod' ]:
setattr(self, method, getattr(self.customwidget, method))

This gives you more control over which methods are delegated - if there are 
some Custom methods that you do *not* want to expose in MainClass this might be 
a better approach.

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


Re: re sub help

2005-11-05 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
> hi
> 
> i have a string :
> a =
> "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"
> 
> inside the string, there are "\n". I don't want to substitute the '\n'
> in between
> the [startdelim] and [enddelim] to ''. I only want to get rid of the
> '\n' everywhere else.

Here is a solution using re.sub and a class that maintains state. It works when 
the input text contains multiple startdelim/enddelim pairs.

import re

a = "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n" * 2

class subber(object):
def __init__(self):
self.delimiterSeen = False

def __call__(self, m):
text = m.group()
if text == 'startdelim':
self.delimiterSeen = True
return text

if text == 'enddelim':
self.delimiterSeen = False
return text

if self.delimiterSeen:
return text

return ''

delimRe = re.compile('\n|startdelim|enddelim')

newText = delimRe.sub(subber(), a)
print repr(newText)


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


Re: Pythonwin - Word automation - Removing watermark not working

2005-11-05 Thread Simon Brunning
On 04/11/05, Gregory Piñero <[EMAIL PROTECTED]> wrote:
> Is there a different group/mailing list I should try?  Does anyone know if
> there is a pythonwin group/list for example?

There is: .

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


Re: Using Which Version of Linux

2005-11-05 Thread Terrance N. Phillip
Jeffrey Schwab wrote:

> 
> I might get lambasted for suggesting this, but try Slackware.  It will 
> let you do a very minimal installation, which means there's less stuff 
> that can go wrong.  It also has nice, beginner-friendly FAQs to help you 
> get started.  Like the other distros already suggested, it comes with 
> the graphical desktop environments Gnome and KDE, too.
What I like about Slackware/python is that you get the full python 
distribution. My last experience with Debian & subordinates was that 
only the "core" python was included with the distribution, and a bit of 
hunting was required to get Tkinter working. Maybe this has improved in 
the last year or two?

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


Re: how to compile c-extensions under WinXP?

2005-11-05 Thread Peter Notebaert

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> What should I do to be able to compile C-extensions (with python 2.4,
> winXP)? I get an error message, approximately "The .NET Framework SDK
> needs to be installed"; I tried to get something from the Microsoft web
> site, but maybe not the right version (or didn't set some variables),
> since the error remains. Could you please help me (it will need some
> patience with a computer newbie)?
>

You need the Microsoft .NET Visual Studio environment. A stripped and free 
version is available at http://msdn.microsoft.com/visualc/vctoolkit2003/
However I am not sure if everything will work with this stripped version.

Peter 


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


Re: lists <-> tuple

2005-11-05 Thread Peter Notebaert

"Jim" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>> Tuples or lists for matrix-like functionality?
>
> Use lists.  Tuples are meant for small immutable sets of things that go
> together.  Lists are more like arrays, and you can assign to one
> existing element if you want.
>
> One exception, is a short vector is often a tuple like (x, y, z) and
> you might want to multiply that vector by your matrix.  You can convert
> a tuple to a list with   list(aTuple)  or back with  tuple(aList.)
>
> Even better, take a look at numarray (or numpy or scipy or scipy_core.)
> They all have really nice matrix code and there are C APIs that let
> you manipulate them.  Chances are they do everything you're intending
> to implement.
>
> Immutability example:
> tup = ("a", "b", "c")
> tup[1] = "g"
> Traceback (most recent call last):
>  File "", line 1, in ?
> TypeError: object does not support item assignment
> lst = ["a", "b", "c"]
> lst[1] = "g"
> lst
> ['a', 'g', 'c']
>
>
> -Jim
>

Thanks! 


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


Re: lists <-> tuple

2005-11-05 Thread Peter Notebaert

"Robert Kern" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Peter Notebaert wrote:
>> I am new to Python and have to create an import library in C that uses
>> matrices.
>>
>> These matrices can be one-dimensional (vectors) or two-dimensional. If I
>> look in the ActivePython 2.4 documentation at data structures, then I see 
>> at
>> least 2 posibilities to represent them: Lists and Tuples.
>>
>> The documention doesn't give me much information on what the best choice 
>> is
>> for the data type to provide/return these matrices.
>>
>> So my question is, should I use lists or tuples to represent my matrices 
>> in
>> and why?
>
> You'll probably want to use scipy_core. It's a package designed
> specifically to deal with multidimensional arrays of homogeneous,
> (usually) numeric data.
>
>  http://numeric.scipy.org
>
> -- 
> Robert Kern
> [EMAIL PROTECTED]
>
> "In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."
>  -- Richard Harter
>

Thanks! 


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


Re: modifying source at runtime - jython case

2005-11-05 Thread Jan Gregor
In article <[EMAIL PROTECTED]>, Alan Kennedy wrote:
> [Jan Gregor]
>>  I want to apply changes in my source code without stopping jython
>>  and JVM. Preferable are modifications directly to instances of
>>  classes. My application is a desktop app using swing library.
>>  
>>  Python solutions also interest me.
>> 
>>  Solution similiar to "lisp way" is ideal.
> 
> OK, I'll play 20 questions with you.
> 
> How close is the following to what you're thinking?

I see.

Following try showed me that instances aren't affected by
modification in class definition.
but this helped
   x.test = a().test  OR  x.test = y.test

The only thing left is how to initiate modification, it's a
swing application and i think interp.exec don't stop until
it's done. Maybe somehow call it from jython itself - but need
to pass PythonInterpreter instance.


Thanks.


class a:
def test(self):
print 'first'

x= a()

class a:
def test(self):
print 'second'

y= a()

x.test()
y.test()

> 
> begin SelfMod.java ---
> //
> import org.python.util.PythonInterpreter;
> import org.python.core.*;
> 
> class SelfMod
>{
> 
>static String my_class_source =
>  "class MyJyClass:\n" +
>  "  def hello(self):\n" +
>  "print 'Hello World!'\n";
> 
>static String create_instance = "my_instance = MyJyClass()\n";
> 
>static String invoke_hello = "my_instance.hello()";
> 
>static String overwrite_meth =
>  "def goodbye():\n"+
>  "  print 'Goodbye world!'\n" +
>  "\n" +
>  "my_instance.hello = goodbye\n";
> 
>public static void main ( String args[] )
>  {
>  PythonInterpreter interp = new PythonInterpreter();
>  interp.exec(my_class_source);
>  interp.exec(create_instance);
>  interp.exec(invoke_hello);
>  interp.exec(overwrite_meth);
>  interp.exec(invoke_hello);
>  }
> 
>}
> //
> end SelfMod.java -
> 
> need-to-complete-my-coursework-for-telepathy-101-ly y'rs
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: modifying source at runtime - jython case

2005-11-05 Thread Kent Johnson
Jan Gregor wrote:
> Hello folks
> 
>  I want to apply changes in my source code without stopping jython
>  and JVM. Preferable are modifications directly to instances of
>  classes. My application is a desktop app using swing library.

Can you be more specific? Python and Jython allow classes to be modified at 
runtime without changing the source code or compiling new code. For example you 
can add and remove methods and attributes from a class and change the base 
classes of a class. You can also modify individual instances of a class to 
change their attributes and behaviour independently of other instances of the 
class. What are you trying to do? For example see
http://groups.google.com/group/comp.lang.python/browse_frm/thread/8f7d87975eab0ca4/18215f7ce8f5d609?rnum=15#18215f7ce8f5d609
http://groups.google.com/group/comp.lang.python/browse_frm/thread/a0b19b37ac48deaa/e599041de4b8feb0?rnum=22#e599041de4b8feb0

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


Re: how to compile c-extensions under WinXP?

2005-11-05 Thread Steve Holden
Steve Holden wrote:
> [EMAIL PROTECTED] wrote:
> 
>>What should I do to be able to compile C-extensions (with python 2.4, 
>>winXP)? I get an error message, approximately "The .NET Framework SDK 
>>needs to be installed"; I tried to get something from the Microsoft web 
>>site, but maybe not the right version (or didn't set some variables), 
>>since the error remains. Could you please help me (it will need some 
>>patience with a computer newbie)?
>>
> 
> See
> 
>http://www.vrplumber.com/programming/mstoolkit
> 
> and say thanks to Mike Farmer.
> 

That's Mike Fletcher [sorry, Mike].

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Pythonwin - Word automation - Removing watermark not working

2005-11-05 Thread Gregory Piñero
Thanks Simon, I'll try that.  And if that doesn't work, why I'll try a Microsoft word group!

-Greg
On 11/5/05, Simon Brunning <[EMAIL PROTECTED]> wrote:
On 04/11/05, Gregory Piñero <[EMAIL PROTECTED]> wrote:> Is there a different group/mailing list I should try?  Does anyone know if> there is a pythonwin group/list for example?
There is: .--Cheers,Simon B,
[EMAIL PROTECTED],http://www.brunningonline.net/simon/blog/-- Gregory PiñeroChief Innovation Officer
Blended Technologies(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list

SCLOGON 0.1 Smart Card event daemon for GNU/Linux

2005-11-05 Thread Philippe C. Martin

Dear all,

This is to announce the release of the event deamon I intend to use in
SCLOGIN; a GPL project that attempts to:
1) give the current logon managers (gdm, kdm, ...) the necessary plugins to
support vendor-independant smart card logon
2) be a complete logon manager itself

SCLOGIN will be discussed here: www.snakecard.com/WordPress and found here:
www.snakecard.com/SCLOGON.



Regards,

Philippe

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


Python gui

2005-11-05 Thread Philippe C. Martin
Hi,

Is wxWidget now part of python ? or will it be ?

regards,

Philippe


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


Re: how to call basic browser functions?

2005-11-05 Thread BLElliott
Great!  I've never looked in to the urllibs before, but it sounds like 
they're just what I need.  And no, I'm not thinking of anything so 
sophisticated as executing applets or anything -- just those "Save * as 
..." functions, where * might be "page", "image", "link target" etc.

I also hadn't known about wget, so that's good to know, too.

thanks!
- bruce

Peter Hansen wrote:
> BLElliott wrote:
> 
>> I think this is a very basic question, so feel free to direct me to a 
>> FAQ or other resource to go and get myself educated, if that's the 
>> best answer.
>>
>> Can I perform web browser functions from a script, for example, doing 
>> file downloads, if I can construct the file URL within my script?  As 
>> an example, suppose there's a file I download periodically, but its 
>> URL changes with the current date.  If I can write a script that will 
>> automatically generate the URL, can it then go and fetch the file for me?
> 
> 
> Yes, you can definitely do that.  Look for examples of using "urllib" or 
> "urllib2".  There should be many that are close to the sort of thing you 
> want.  Or you could simply use a command line utility such as "wget" to 
> accomplish much the same thing and avoid almost any programming.
> 
> (Note that if in addition to downloading the actual contents of the 
> page, you will require more sophisticated features of a real browser, 
> such as Javascript or Java execution, you'll need capabilities far 
> beyond what urllib2 can provide.  And you probably don't want to go 
> there right now.)
> 
> -Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: /usr/lib/python2.4/posixfile.py error

2005-11-05 Thread Chris
In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] says...
> Chris wrote:
> > Wonder if anyone can help me?
> 
> I very much doubt that, with as little information you gave us.
> 
> > I am trying to run a perl script but I keep getting this error:
> > 
> > /usr/lib/python2.4/posixfile.py:59: DeprecationWarning: The posixfile 
> > module is obsolete and will disappear in the future
> >   DeprecationWarning)
> 
> It's very strange that you get a Python error when running a Perl
> script.

So I thought ;)

However, it's a perl script that invokes python.  

http://search.cpan.org/~rprice/Nokia-File-NFB-0.01/lib/Nokia/File/NFB.pm

> > Any ideas on why it's failing on that python module?
> 
> It's not failing. It's a warning, not an error. The warning is
> that the Python code you are running uses the posixfile module,
> and it should be rewritten to stop doing so, as the posixfile
> module will go away eventually.
> 

Ok, many thanks.  I got it working in the end, appears that the nfb.py 
script requires the file it is processing to be in the same directory.  
Which is quite annoying, but at least I know how to sort it now.

Many thanks for your quick reply and apologies for my late one :(

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


Re: Using Which Version of Linux

2005-11-05 Thread Dan M
On Sat, 05 Nov 2005 04:26:38 -0600, blahman wrote:

> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.

Personally I would recommend staying away from Fedora unless you have a
friend who is well-versed in it and willing to help. I like the
distributin ok (I run it on the laptop I'm writing this from) but it uses
RPMs for package distribution, and the rpm tools don't know how to
automatically downloaded dependencies like yum or apt do. Because of that
I have to say that the RPM package tools suck quite badly.

Debian and SUSE are both pretty good choices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python gui

2005-11-05 Thread Diez B. Roggisch
Philippe C. Martin wrote:
> Hi,
> 
> Is wxWidget now part of python ? or will it be ?

1) No. 2) I guess no. Because it has pretty heavy dependencies (wx, 
GTK/other toolkit)


Tkinter is what comes ou of the box - and thats it.

Regards,

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


Re: Using Which Version of Linux

2005-11-05 Thread D.Hering
And for complete control and customization of your os and hardware...
There's nothing like Gentoo!

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


Re: Python gui

2005-11-05 Thread Philippe C. Martin
Thanks, Tkinter it is.

Regards,


Philippe

Diez B. Roggisch wrote:

> Philippe C. Martin wrote:
>> Hi,
>> 
>> Is wxWidget now part of python ? or will it be ?
> 
> 1) No. 2) I guess no. Because it has pretty heavy dependencies (wx,
> GTK/other toolkit)
> 
> 
> Tkinter is what comes ou of the box - and thats it.
> 
> Regards,
> 
> Diez

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


Re: Using Which Version of Linux

2005-11-05 Thread Michael Schneider
I have been away from unix/linux for a couple of years.

I went with SUSE.   Just do an install all, and 10 gig later you
are done.

Very simple install, very easy admin with YAST.

If you are a power admin, there may be better release.  But if you want
simple, but powerful, SUSE has worked well for me.

Good Luck,
Mike


[EMAIL PROTECTED] wrote:
> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python gui

2005-11-05 Thread Lawrence Oluyede
Il 2005-11-05, Philippe C. Martin <[EMAIL PROTECTED]> ha scritto:
> Hi,
>
> Is wxWidget now part of python ? or will it be ?

No it's not part of the official distribution of CPython,
ad AFAIK it will not be anytime soon.

-- 
Lawrence
http://www.oluyede.org/blog
-- 
http://mail.python.org/mailman/listinfo/python-list


starting an X11 session from Python

2005-11-05 Thread Philippe C. Martin
Hi,

Have there been any attempt to do so, and is there any source out there that
could help me get started ?

Regards,

Philippe

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


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Charlton Wilbur
> "RW" == Rick Wotnaz <[EMAIL PROTECTED]> writes:

RW> Someone is sure to jump in now and point to sample code, which
RW> nearly all reasonably major packages include. That's good
RW> stuff.  With (for example) wxPython, it's the only useful
RW> documentation, or rather, it's the only thing that makes the
RW> wxWidgets documentation useful. Links to code samples in the
RW> documentation would be fine in lieu of snippets of example
RW> calls. But there's not enough of either in most documentation.

This is one of the places where Apple's Cocoa documentation shines:
there are frequently snippets of code accompanying more complicated
methods, which is nice, but there are a couple dozen small sample
programs that demonstrate how to use particular aspects of the
framework, available with full source code.

RW> I would love to see examples for essentially every function
RW> and method. And not just something that echoes the signature,
RW> but some context to show how it might be useful. That would be
RW> in the "intoxication" class of ultimate hopes. In most cases,
RW> though, it would be *extremely* helpful for a casual user of
RW> that part of the package.

Well, at some level you have to consider - who is the target audience
of the documentation?  There's usually a tradeoff involved in that
documentation aimed at novice users is usually not useful to advanced
users; there's also a ridiculous amount of work involved in making
*all* documentation available to all users, and there's usually a
better payoff involved in writing documentation that shows novice
users how to be intermediate users.

To take another example: in Cocoa, there's a well-defined and
well-documented approach to memory management, and conventions used
consistently throughout the whole Cocoa framework.  These conventions
could be documented over again for each and every class, but it's a
much better use of resources to document them once and to assume in
the documentation for each class that the reader is familiar with the
conventions.

Charlton


-- 
cwilbur at chromatico dot net
cwilbur at mac dot com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread qwweeeit
Hi Michael,
I too use SUSE (9.3). The Novell operation has convinced me to
go back to SUSE, after some trials with Mandrake and Ubuntu.
Especially on the Python side all is ready up. But I will not go
into the complications of "fork" and "thread" programming...
Bye.

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


Re: Print to printer

2005-11-05 Thread avnit
Wow. That worked perfectly. Thanks a lot.

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


Re: Print to printer

2005-11-05 Thread avnit
Do you know if there's a way to print a file? I'm trying to print an
HTML file, so your solution is good, but doesn't really work for me.
Just reading the HTML file and the printing the content obviously
wouldn't work. I also tried:

>>> printer.write(file('path/to/file.ext'))

but apparently this function only takes strings as parameters.

Thanks.

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


Re: starting an X11 session from Python

2005-11-05 Thread Sybren Stuvel
Philippe C. Martin enlightened us with:
> Have there been any attempt to do so, and is there any source out
> there that could help me get started ?

What's stopping you from using system(), exec() or the likes to start
"startx", "xinit" or simply "X"?

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: starting an X11 session from Python

2005-11-05 Thread Philippe C. Martin
Nothing, but that was not my question.

Regards,

Philippe


Sybren Stuvel wrote:

> Philippe C. Martin enlightened us with:
>> Have there been any attempt to do so, and is there any source out
>> there that could help me get started ?
> 
> What's stopping you from using system(), exec() or the likes to start
> "startx", "xinit" or simply "X"?
> 
> Sybren

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


Re: starting an X11 session from Python

2005-11-05 Thread Philippe C. Martin
PS: my goal is to write an equivalent of gdm/kdm/xdm ... in python

Regards,

Philippe


Philippe C. Martin wrote:

> Nothing, but that was not my question.
> 
> Regards,
> 
> Philippe
> 
> 
> Sybren Stuvel wrote:
> 
>> Philippe C. Martin enlightened us with:
>>> Have there been any attempt to do so, and is there any source out
>>> there that could help me get started ?
>> 
>> What's stopping you from using system(), exec() or the likes to start
>> "startx", "xinit" or simply "X"?
>> 
>> Sybren

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


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Andrea Gavana
Hello NG,

> I've managed to avoid reading Xah Lee's diatribes for the most
> part. Since you included the *WHOLE THING* in your post, I had an
> "opportunity" to see what he had to say, and for once I agree with
> some of it.



> I would love to see examples for essentially every function and
> method. And not just something that echoes the signature, but some
> context to show how it might be useful. That would be in the
> "intoxication" class of ultimate hopes. In most cases, though, it
> would be *extremely* helpful for a casual user of that part of the
> package.

I tend to agree with you, Rick. I usually don't like Xah's "posting
behavior", but  this time he has done, in my opinion, a "constructive"
criticism (and he didn't even say *fuck* once in the whole post!!!). I am
quite a newbie in Python, I usually deal with wxPython that is sometimes not
very "pythonic", or not enough "pythonic". As a newbie (in whatever language
you wish), I would like to open the docs about a particular library, class
or method and find a small "sample application" of it. I think many newbies
learn by examples. I don't mean to say anything negative about the docs or
the docs' authors, but I would imagine that having a simple example of use
for all the methods in a class/library would be a nice and valuable
improvement for the docs.
OTOH, usually by using some simple google-fu, it is easy to find a sample
application for a particular method. This is due mainly to the popularity of
Python, and its popularity is due to its beauty as a language. Compared to
other I learnt in the past, like C++, Fortran and Matlab, I have about 99%
less jitters now that I use Python ;-) .

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77


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


Re: Class Variable Access and Assignment

2005-11-05 Thread Bengt Richter
On Fri, 04 Nov 2005 21:14:17 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote:

>[EMAIL PROTECTED] (Bengt Richter) writes:
>> On Thu, 03 Nov 2005 13:37:08 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote:
>> [...]
 I think it even less sane, if the same occurce of b.a refers to two
 different objects, like in b.a += 2
>>>
>>>That's a wart in +=, nothing less. The fix to that is to remove +=
>>>from the language, but it's a bit late for that.
>>>
>> Hm, "the" fix? Why wouldn't e.g. treating augassign as shorthand for a 
>> source transformation
>> (i.e., asstgt = expr  becomes by simple text substitution asstgt = 
>> asstgt  expr)
>> be as good a fix? Then we could discuss what
>>
>> b.a = b.a + 2
>>
>> should mean ;-)
>
>The problem with += is how it behaves, not how you treat it. But you
>can't treat it as a simple text substitution, because that would imply
>that asstgt gets evaluated twice, which doesn't happen.
I meant that it would _make_ that happen, and no one would wonder ;-)

BTW, if b.a is evaluated once each for __get__ and __set__, does that not
count as getting evaluated twice?

 >>> class shared(object):
 ... def __init__(self, v=0): self.v=v
 ... def __get__(self, *any): print '__get__'; return self.v
 ... def __set__(self, _, v): print '__set__'; self.v = v
 ...
 >>> class B(object):
 ... a = shared(1)
 ...
 >>> b=B()
 >>> b.a
 __get__
 1
 >>> b.a += 2
 __get__
 __set__
 >>> B.a
 __get__
 3

Same number of get/sets:

 >>> b.a = b.a + 10
 __get__
 __set__
 >>> b.a
 __get__
 13

I posted the disassembly in another part of the thread, but I'll repeat:

 >>> def foo():
 ... a.b += 2
 ... a.b = a.b + 2
 ...
 >>> import dis
 >>> dis.dis(foo)
   2   0 LOAD_GLOBAL  0 (a)
   3 DUP_TOP
   4 LOAD_ATTR1 (b)
   7 LOAD_CONST   1 (2)
  10 INPLACE_ADD
  11 ROT_TWO
  12 STORE_ATTR   1 (b)

   3  15 LOAD_GLOBAL  0 (a)
  18 LOAD_ATTR1 (b)
  21 LOAD_CONST   1 (2)
  24 BINARY_ADD
  25 LOAD_GLOBAL  0 (a)
  28 STORE_ATTR   1 (b)
  31 LOAD_CONST   0 (None)
  34 RETURN_VALUE

It looks like the thing that's done only once for += is the LOAD_GLOBAL (a)
but DUP_TOP provides the two copies of the reference which are
used either way with LOAD_ATTR followed by STORE_ATTR, which UIAM
lead to the loading of the (descriptor above) attribute twice -- once each
for the __GET__ and __SET__ calls respectively logged either way above.

>
>> OTOH, we could discuss how you can confuse yourself with the results of b.a 
>> += 2
>> after defining a class variable "a" as an instance of a class defining 
>> __iadd__ ;-)
>
>You may confuse yourself that way, I don't have any problems with it
>per se.
I should have said "one can confuse oneself," sorry ;-)
Anyway, I wondered about the semantics of defining __iadd__, since it seems to 
work just
like __add__ except for allowing you to know what source got you there. So 
whatever you
return (unless you otherwise intercept instance attribute binding) will get 
bound to the
instance, even though you internally mutated the target and return None by 
default (which
gives me the idea of returning NotImplemented, but (see below) even that gets 
bound :-(

BTW, semantically does/should not __iadd__ really implement a _statement_ and 
therefore
have no business returning any expression value to bind anywhere?

 >>> class DoIadd(object):
 ... def __init__(self, v=0, **kw):
 ... self.v = v
 ... self.kw = kw
 ... def __iadd__(self, other):
 ... print '__iadd__(%r, %r) => '%(self, other),
 ... self.v += other
 ... retv = self.kw.get('retv', self.v)
 ... print repr(retv)
 ... return retv
 ...
 >>> class B(object):
 ... a = DoIadd(1)
 ...
 >>> b=B()
 >>> b.a
 <__main__.DoIadd object at 0x02EF374C>
 >>> b.a.v
 1

The normal(?) mutating way:
 >>> b.a += 2
 __iadd__(<__main__.DoIadd object at 0x02EF374C>, 2) =>  3
 >>> vars(b)
 {'a': 3}
 >>> B.a
 <__main__.DoIadd object at 0x02EF374C>
 >>> B.a.v
 3

Now fake attempt to mutate self without returning anything (=> None)
 >>> B.a = DoIadd(1, retv=None) # naive default
 >>> b.a
 3
Oops, remove instance attr
 >>> del b.a
 >>> b.a
 <__main__.DoIadd object at 0x02EF3D6C>
 >>> b.a.v
 1
Ok, now try it
 >>> b.a +=2
 __iadd__(<__main__.DoIadd object at 0x02EF3D6C>, 2) =>  None
 >>> vars(b)
 {'a': None}
Returned value None still got bound to instance
 >>> B.a.v
 3
Mutation did happen as planned

Now let's try NotImplemented as a return
 >>> B.a = DoIadd(1, retv=NotImplemented) # mutate but probably do __add__ too
 >>> del b.a
 >>> b.a
 <__main__.DoIadd object at 0x02EF374C>
 >>> b.a.v
 1
 >>> b.a +=2
 __iadd__(<__main__.DoIadd object at 0x02EF374C>, 2) =>  NotImplemented
 __iadd__(<

Re: Python gui

2005-11-05 Thread Andrea Gavana
Hello Philippe,

> Is wxWidget now part of python ? or will it be ?

No, I don't think it will ever be part of Python. But, wxWidgets is written
in C++, so it has nothing *pythonic* in it. There is, however, a "Python
Binding" of wxWidgets, called (obviously ;-) ) wxPython. If you can install
a site-package, I would suggest you to visit http://www.wxpython.org/.
wxPython has a very active newsgroup and a lot of nice user contribution. If
you can not install a site-package, I think that Tkinter is the only choice
you have (but I may be wrong here).

HTH.

Andrea.

-- 
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77


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


Re: Using Which Version of Linux

2005-11-05 Thread malv
[EMAIL PROTECTED] wrote:
> ok, i m going to use Linux for my Python Programs, mainly because i
> need to see what will these fork() and exec() do. So, can anyone tell
> me which flavour of linux i should use, some say that Debian is more
> programmer friendly, or shold i use fedora, or Solaris. Because these
> three are the only ones i know of that are popular and free.
> --
>  * Posted with NewsLeecher v3.0 Beta 7
>  * http://www.newsleecher.com/?usenet
You have to look out for the version of Python the distro comes with
2.4. Some don't and it may be nasty having to deal with different
versions installed next to one another. (You will probably not be able
to safely remove the original version as the distro uses it for many
things.)

Another point to watch for is things like Python bindings and easyness
of gui (free) installation. FWIW, I like Suse10.0 (Novell). It has
kde-Python bindings to Qt installed. It also has eric3 available. So
without any additional cost or trouble, you'll have a powerful, dream
developer's system.
malv

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


Re: Using Which Version of Linux

2005-11-05 Thread Norman Silverstone
On Sat, 05 Nov 2005 04:26:38 -0600, blahman wrote:

> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.

I use the latest version of Ubuntu and find it very good in all respects.
It's free and regularly maintained.

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


mod_python

2005-11-05 Thread Little
I can't figure out how to build this type of program using the
publisher handler. I have the following connected to the program
SetHandler python-program
PythonHandler mod_python.publisher
PythonDebug On

But what I would like to do would be have a german word as the
parameter in the HTTP request and have the english world printed out on
the screen. Yes this will be a small dictionary but I just want to be
able to understand how to build the program and have it work without
any errors. Thanks for any help.

PS I understand the example of printing the say portion in the
mod_python manual but can't get past that.

Again Thanks!!

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


Re: starting an X11 session from Python

2005-11-05 Thread Richard Townsend
On Sat, 05 Nov 2005 19:51:40 +, Philippe C. Martin wrote:

> Hi,
> 
> Have there been any attempt to do so, and is there any source out there that
> could help me get started ?
> 
> Regards,
> 
> Philippe

Have you tried:
http://python-xlib.sourceforge.net/
http://sourceforge.net/projects/python-xlib

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


pickle - recursion - stack size limit - MS windows

2005-11-05 Thread Andy Leszczynski
I need to pickle quite complex objects and first limitation was default
200 for the recursion. sys.setrecursionlimit helped, but still bigger
objects fail to be pickled because of XP stack size limitation.

Any idea how to get around the problem ...

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


Re: Class Variable Access and Assignment

2005-11-05 Thread Bengt Richter
On Sat, 05 Nov 2005 14:37:19 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote:

>On Sat, 05 Nov 2005 00:25:34 +, Bengt Richter wrote:
>
>> On Fri, 04 Nov 2005 02:59:35 +1100, Steven D'Aprano <[EMAIL PROTECTED]> 
>> wrote:
>> 
>>>On Thu, 03 Nov 2005 14:13:13 +, Antoon Pardon wrote:
>>>
 Fine, we have the code:
 
   b.a += 2
 
 We found the class variable, because there is no instance variable,
 then why is the class variable not incremented by two now?
>> Because the class variable doesn't define a self-mutating __iadd__
>> (which is because it's an immutable int, of course). If you want
>> b.__dict__['a'] += 2 or b.__class__.__dict__['a'] += 2 you can
>> always write it that way ;-)
>> 
>> (Of course, you can use a descriptor to define pretty much whatever semantics
>> you want, when it comes to attributes).
>> 
>>>
>>>Because b.a += 2 expands to b.a = b.a + 2. Why would you want b.a =
>> 
>> No, it doesn't expand like that. (Although, BTW, a custom import could
>> make it so by transforming the AST before compiling it ;-)
>> 
>> Note BINARY_ADD is not INPLACE_ADD:
>
>Think about *what* b.a += 2 does, not *how* it does it. Perhaps for some
what it does, or what in the abstract it was intended to do? (which we need
BDFL channeling to know for sure ;-)

It looks like it means, "add two to ". I think Antoon
is unhappy that  is not determined once for the one b.a
expression in the statement. I sympathize, though it's a matter of defining
what b.a += 2 is really intended to mean. 
The parses are certainly distinguishable:

 >>> import compiler
 >>> compiler.parse('b.a +=2','exec').node
 Stmt([AugAssign(Getattr(Name('b'), 'a'), '+=', Const(2))])
 >>> compiler.parse('b.a = b.a + 2','exec').node
 Stmt([Assign([AssAttr(Name('b'), 'a', 'OP_ASSIGN')], Add((Getattr(Name('b'), 
'a'), Const(2])

Which I think leads to the different (BINARY_ADD vs INPLACE_ADD) code, which 
probably really
ought to have a conditional STORE_ATTR for the result of INPLACE_ADD, so that 
if __iadd__
was defined, it would be assumed that the object took care of everything 
(normally mutating itself)
and no STORE_ATTR should be done. But that's not the way it works now. (See 
also my reply to Mike).

Perhaps all types that want to be usable with inplace ops ought to inherit from 
some base providing
that, and there should never be a return value. This would be tricky for 
immutables though, since
re-binding is necessary, and the __iadd__ method would have to be passed the 
necessary binding context
and methods. Probably too much of a rewrite to be practical.

>other data type it would make a difference whether the mechanism was
>BINARY_ADD (__add__) or INPLACE_ADD (__iadd__), but in this case it does
>not. Both of them do the same thing.
Unfortunately you seem to be right in this case.
>
>Actually, no "perhaps" about it -- we've already discussed the case of
>lists.
Well, custom objects have to be considered too. And where attribute access
is involved, descriptors.

>
>Sometimes implementation makes a difference. I assume BINARY_ADD and
>INPLACE_ADD work significantly differently for lists, because their
>results are significantly (but subtly) different:
>
>py> L = [1,2,3]; id(L)
>-151501076
>py> L += [4,5]; id(L)
>-151501076
>py> L = L + []; id(L)
>-151501428
>
Yes.
>
>But all of this is irrelevant to the discussion about binding b.a
>differently on the left and right sides of the equals sign. We have
>discussed that the behaviour is different with mutable objects, because
>they are mutable -- if I recall correctly, I was the first one in this
>thread to bring up the different behaviour when you append to a list
>rather than reassign, that is, modify the class attribute in place.
>
>I'll admit that my choice of terminology was not the best, but it wasn't
>misleading. b.a += 2 can not modify ints in place, and so the
>effect of b.a += 2 is the same as b.a = b.a + 2, regardless of what
>byte-codes are used, or even what C code eventually implements that
>add-and-store.
It is so currently, but that doesn't mean that it couldn't be otherwise.
I think there is some sense to the idea that b.a should be re-bound in
the same namespace where it was found with the single apparent evaluation
of "b.a" in "b.a += 2" (which incidentally is Antoon's point, I think).
This is just for augassign, of course.

OTOH, this would be find-and-rebind logic for attributes when augassigned,
and that would enable some tricky name-collision bugs for typos, and code
that used instance.attr += incr depending on current behavior would break.

>
>In the case of lists, setting Class.a = [] and then calling instance.a +=
>[1] would not exhibit the behaviour Antoon does not like, because the
>addition is done in place. But calling instance.a = instance.a + [1]
>would.
>
>My question still stands: why would you want instance.a = 
>to operate as instance.__class__.a = ?
>
Because in the case of instance.a += , "instance.a"
is a short spelling fo

Re: Using Which Version of Linux

2005-11-05 Thread Rod Haper
Dan M wrote:
> 
> Personally I would recommend staying away from Fedora unless you have a
> friend who is well-versed in it and willing to help. I like the
> distributin ok (I run it on the laptop I'm writing this from) but it uses
> RPMs for package distribution, and the rpm tools don't know how to
> automatically downloaded dependencies like yum or apt do. Because of that
> I have to say that the RPM package tools suck quite badly.

Dan,

I don't know what version of Fedora you are running but FC4 and FC3 use 
yum for updating.

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


Re: Using Which Version of Linux

2005-11-05 Thread Steven D'Aprano
On Sat, 05 Nov 2005 04:26:38 -0600, blahman wrote:

> ok, i m going to use Linux for my Python Programs, mainly because i 
> need to see what will these fork() and exec() do. So, can anyone tell 
> me which flavour of linux i should use, some say that Debian is more 
> programmer friendly, or shold i use fedora, or Solaris. Because these 
> three are the only ones i know of that are popular and free.

Solaris is not Linux, although both are like Unix.

In my opinion, Debian is not newbie friendly.

In my experience, Ubunto is HUGELY over rated. The installation was easy,
the user experience was like being poked in the eye with a blunt stick.

In my experience, Fedora is very newbie friendly, as well as being quite
powerful for non-newbies. If you are in Australia or the USA, and start
looking for commercial support, you'll have less grief if you use Fedora
than most other distros. Although it has to be said, multimedia support is
rather lacking due to licencing issues. (And, in fairness, multimedia
support is still Linux's biggest weakness compared to OS X and Windows.)

I hear that Mandrake and SuSE are very popular in Europe.

If you don't mind really horrible German industrial industrial punk themed
desktops, you could do a lot worse than play around with the Knoppix
LiveCD. That would be the quickest way to get started: no installation
necessary.


-- 
Steven.

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


Re: Using Which Version of Linux

2005-11-05 Thread Grant Edwards
On 2005-11-05, Mike Meyer <[EMAIL PROTECTED]> wrote:

> "Programmer-friendly" is pretty vague. Gentoo is the only Linux distro
> I've run into (which excludes a *lot* of Unix distros) that I'd
> consider programmer friendly, because it doesn't split packages up
> into "user stuff" and "developer stuff". That means you have to
> install two packages instead of one if you want to build things
> against that software. On the other hand, it uses it's own "package"
> manager - emerge - so you can't take advantage of rpms/debs from other
> systems (or you couldn't last time I looked into it). It also installs
> the least amount of "bundled" software, which I consider a programmer
> friendly behavior.

I just switched one of my computers to gentoo, and I like it a
lot.  It's very no-nonsense, but there are alot of available
packages and everything (so far) just works.  However, it's not
for the impatient (or at least not for the poor and impatient).
Since it compiles packages from source, a full-featured desktop
install on a slow machine can take days to finish.

-- 
Grant Edwards   grante Yow!  if it GLISTENS,
  at   gobble it!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread Grant Edwards
On 2005-11-05, Dan M <[EMAIL PROTECTED]> wrote:

> Personally I would recommend staying away from Fedora unless you have a
> friend who is well-versed in it and willing to help. I like the
> distributin ok (I run it on the laptop I'm writing this from) but it uses
> RPMs for package distribution, and the rpm tools don't know how to
> automatically downloaded dependencies like yum or apt do.

Nonsense.  You're comparing apples to oranges.  If you want to
compare rpm with something it would be dpkg. If you want to
talk about yum or apt, then you should be comparing them to
something like urpmi. If you tell it to install package X, it
will analyze prerequisites, and then download and install
everything required.  It works almost exactly like apt-get
does.  Urpmi is text-mode, but there are also GUI front-ends
that do the same thing.

> Because of that I have to say that the RPM package tools suck
> quite badly.

You'd say the same think about Debian if all you had ever used
was dpgk, and I dare you to try to do anything with dselect.

> Debian and SUSE are both pretty good choices.

-- 
Grant Edwards   grante Yow!  I just got my PRINCE
  at   bumper sticker... But now I
   visi.comcan't remember WHO he is...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread Steven D'Aprano
On Sat, 05 Nov 2005 12:50:44 +, Jeffrey Schwab wrote:

> [EMAIL PROTECTED] wrote:
>> ok, i m going to use Linux for my Python Programs, mainly because i 
>> need to see what will these fork() and exec() do. So, can anyone tell 
>> me which flavour of linux i should use, some say that Debian is more 
>> programmer friendly, or shold i use fedora, or Solaris. Because these 
>> three are the only ones i know of that are popular and free.
> 
> Solaris isn't Linux, but it is good.  I've never installed it from 
> scratch, though.
> 
> I might get lambasted for suggesting this, but try Slackware.

If only you knew how hard I had to work to overcome the bad impression
Slackware makes on first-time Linux users.

> It will 
> let you do a very minimal installation, which means there's less stuff 
> that can go wrong.  

And less stuff that can go right, because it just isn't there. There is
something sort of sad about watching an experienced Linux guru trying to
get things done on Slackware, especially when the purist set it up with
FVWM2 as the window manager. It is kind of like going back in time to 1980...

> It also has nice, beginner-friendly FAQs to help you 
> get started.  

Just so you understand what Jeffrey is talking about, by
"beginner-friendly" he means the FAQs walk you through the process of
compiling your own kernel. (Okay, okay, so that's a *tiny* bit of an
exaggeration... but not much. Slackware isn't quite Gentoo *wink*)


-- 
Steven.

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


Modify HTML data

2005-11-05 Thread Swarna
Hi all,

Can anyone help me with this ?

I am using scp in python to copy a html file on remote server, to my
local machine. Now, i need to update this html file in my local machine
( by adding a new Hyperlink to the existing table od hyperlinks ) and
copy it back (overwriting the old copy ) to the remote server.

Thanks, for your time !
Swarna.

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


Re: re sub help

2005-11-05 Thread Bengt Richter
On 4 Nov 2005 22:49:03 -0800, [EMAIL PROTECTED] wrote:

>hi
>
>i have a string :
>a =
>"this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"
>
>inside the string, there are "\n". I don't want to substitute the '\n'
>in between
>the [startdelim] and [enddelim] to ''. I only want to get rid of the
>'\n' everywhere else.
>
>i have read the tutorial and came across negative/positive lookahead
>and i think it can solve the problem.but am confused on how to use it.
>anyone can give me some advice? or is there better way other than
>lookaheads ...thanks..
>

Sometimes splitting and processing the pieces selectively can be a solution, 
e.g.,
if delimiters are properly paired, splitting (with parens to keep matches) 
should
give you a repeating pattern modulo 4 of
 <"everywhere else" as you said> ...

 >>> a = 
 >>> "this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n"
 >>> import re
 >>> splitter = re.compile(r'(?s)(\[startdelim\]|\[enddelim\])')
 >>> sp = splitter.split(a)
 >>> sp
 ['this\nis\na\nsentence', '[startdelim]', 'this\nis\nanother', '[enddelim]', 
'this\nis\n']
 >>> ''.join([(lambda s:s, lambda s:s.replace('\n',''))[not i%4](s) for i,s in 
 >>> enumerate(sp)])
 'thisisasentence[startdelim]this\nis\nanother[enddelim]thisis'
 >>> print ''.join([(lambda s:s, lambda s:s.replace('\n',''))[not i%4](s) for 
 >>> i,s in enumerate(sp)])
 thisisasentence[startdelim]this
 is
 another[enddelim]thisis

I haven't checked for corner cases, but HTH
Maybe I'll try two pairs of delimiters:

 >>> a += 
 >>> "\n33\n4\n[startdelim]\n77\n888[enddelim]\n00\n"
 >>> sp = splitter.split(a)
 >>> print ''.join([(lambda s:s, lambda s:s.replace('\n',''))[not i%4](s) for 
 >>> i,s in enumerate(sp)])
 thisisasentence[startdelim]this
 is
 another[enddelim]thisis334[startdelim]
 77
 888[enddelim]00

which came from
 >>> sp
 ['this\nis\na\nsentence', '[startdelim]', 'this\nis\nanother', '[enddelim]', 
'this\nis\n\n33
 \n4\n', '[startdelim]', '\n77\n888', '[enddelim]', 
'\n00\n']

Which had the replacing when not i%4 was true

 >>> for i,s in enumerate(sp): print '%6s: %r'%(not i%4,s)
 ...
   True: 'this\nis\na\nsentence'
  False: '[startdelim]'
  False: 'this\nis\nanother'
  False: '[enddelim]'
   True: 'this\nis\n\n33\n4\n'
  False: '[startdelim]'
  False: '\n77\n888'
  False: '[enddelim]'
   True: '\n00\n'

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


Re: Class Variable Access and Assignment

2005-11-05 Thread Steven D'Aprano
On Sat, 05 Nov 2005 21:26:22 +, Bengt Richter wrote:

> BTW, semantically does/should not __iadd__ really implement a _statement_ and 
> therefore
> have no business returning any expression value to bind anywhere?

We get to practicality versus purity here.

Consider x += y for some object type x. If x is a mutable object, then
__iadd__ could be a statement, because it can/should/must modify x in
place. That is the pure solution.

But do you want x += y to work for immutable objects as well? Then
__iadd__ cannot be a statement, because x can't be modified in place.
Our pure "add in place" solution fails in practice, unless we needlessly
restrict what can use it, or have the same syntactical expression (x +=
y) bind to two different methods (__iadd__ statement, and __riadd__
function, r for return). Either pure solution is yucky. (That's a
technical term for "it sucks".) So for practical reasons, __iadd__ can't
be a statement, it needs to return an object which gets bound to x.

Fortunately, that behaviour works for mutables as well, because __iadd__
simply returns self, which gets re-bound to x.

While I am enjoying the hoops people are jumping through to modify the
language so that b.a += 2 assigns b.a in the same scope as it was
accessed, I'm still rather perplexed as to why you would want that
behaviour. It seems to me like spending many hours building a wonderfully
polished, ornate, exquisite device for building hiking boots for mountain
goats.


-- 
Steven.

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


Re: Modify HTML data

2005-11-05 Thread Peter Hansen
Swarna wrote:
> I am using scp in python to copy a html file on remote server, to my
> local machine. Now, i need to update this html file in my local machine
> ( by adding a new Hyperlink to the existing table od hyperlinks ) and
> copy it back (overwriting the old copy ) to the remote server.

If you are using scp to copy the file from the remote server in the 
first place, what's stopping you from using scp to copy it back?
-- 
http://mail.python.org/mailman/listinfo/python-list


Multiples of a number

2005-11-05 Thread Ivan Shevanski
I've searched on google for a bit but I can't seem to find a way to get
multiples of a number. . .For instance what would I do if I wanted
something to happen every time x reached a multiple of 100 in this
sample code:

x = 0
while x < 2000:
 x += 1

Thanks in advance,
-Ivan
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Access and Assignment

2005-11-05 Thread Steven D'Aprano
On Fri, 04 Nov 2005 22:19:39 -0800, Paul Rubin wrote:

> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> > Next you get some performance gain by using gmpy to handle the long int 
>> > arithmetic,
>> 
>> Then whatever happens next will be my own stupid fault for prematurely 
>> optimising code.
> 
> Huh?  There's nothing premature about using gmpy if you need better long int 
> performance.
> It was written for a reason, after all.

Sure, but I would be willing to bet that incrementing a counter isn't it.


>> What exactly is your point? That bugs can happen if the behaviour of your
>> underlying libraries changes? 
> 
> That your initialization scheme is brittle--the idea of data
> abstraction is being able to change object behaviors -without- making
> surprising bugs like that one.  You don't even need the contrived gmpy
> example.  You might replace the level number with, say, a list of
> levels that have been visited.

Do you expect level += 1 to still work when you change level to a list of
levels?

The problem with data abstraction is if you take it seriously, it means
"You should be able to do anything with anything". If I change
object.__dict__ to None, attribute lookup should work, yes? No? Then
Python isn't sufficiently abstract.

As soon as you accept that there are some things you can't do with some
data, you have to stop abstracting. *Prematurely* locking yourself into
one *specific* data structure is bad: as a basic principle, data
abstraction is very valuable -- but in practice there comes a time where
you have to say "Look, just choose a damn design and live with it." If you
choose sensibly, then it won't matter if your counter is an int or a long
or a float or a rational -- but you can't sensibly expect to change your
counter to a binary tree without a major redesign of your code.

I've watched developers with an obsession with data abstraction in
practice. I've watched one comp sci graduate, the ink on his diploma not
even dry yet, spend an hour mapping out state diagrams for a factorial
function.

Hello McFly? The customer is paying for this you know. Get a move on. I've
written five different implementations of factorial in ten minutes, and
while none of them worked with symbolic algebra I didn't need symbolic
algebra support, so I lost nothing by not supporting it.

So I hope you'll understand why I get a bad taste in my mouth when people
start talking about data abstraction.


 
> I don't think the culprit is the mutable/immutable distinction +=
> uses, though that is certainly somewhat odd.  I think Antoon is on the
> right track: namespaces in Python live in sort of a ghetto unbecoming
> of how the Zen list describes them as a "honking great idea".  These
> things we call variables are boxed objects where the namespace is the
> box.  So having x+=y resolve x to a slot in a namespace before
> incrementing that same slot by y, maybe better uses the notion of
> namespaces than what happens now.

Perhaps it does, but it breaks inheritance, which is more important than
purity of namespace resolution. Practicality beats purity.


> I'm too sleepy to see for sure
> whether it gets rid of the mutable/immutable weirdness.

What weirdness? What would be weird is if mutable and immutable objects
worked the same as each other. They behave differently because they are
different. If you fail to see that, you are guilty of excessive data
abstraction.


-- 
Steven.

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


Re: Class Variable Access and Assignment

2005-11-05 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> But do you want x += y to work for immutable objects as well? Then
> __iadd__ cannot be a statement, because x can't be modified in place.

It never occurred to me that immutable objects could implement __iadd__.
If they can, I'm puzzled as to why.  

> While I am enjoying the hoops people are jumping through to modify the
> language so that b.a += 2 assigns b.a in the same scope as it was
> accessed, I'm still rather perplexed as to why you would want that
> behaviour.

Weren't you the one saying += acting differently for mutables and
immutables was a wart?  If it's such a wart, why are do you find it so
important to be able to rely on the more bizarre consequences of the
wartiness?  Warts should be (if not fixed) avoided, not relied on.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Which Version of Linux

2005-11-05 Thread Mike Meyer
Grant Edwards <[EMAIL PROTECTED]> writes:
> On 2005-11-05, Mike Meyer <[EMAIL PROTECTED]> wrote:
>> "Programmer-friendly" is pretty vague. Gentoo is the only Linux distro
>> I've run into (which excludes a *lot* of Unix distros) that I'd
>> consider programmer friendly, because it doesn't split packages up
>> into "user stuff" and "developer stuff". That means you have to
>> install two packages instead of one if you want to build things
>> against that software. On the other hand, it uses it's own "package"
>> manager - emerge - so you can't take advantage of rpms/debs from other
>> systems (or you couldn't last time I looked into it). It also installs
>> the least amount of "bundled" software, which I consider a programmer
>> friendly behavior.
> I just switched one of my computers to gentoo, and I like it a
> lot.  It's very no-nonsense, but there are alot of available
> packages and everything (so far) just works.  However, it's not
> for the impatient (or at least not for the poor and impatient).
> Since it compiles packages from source, a full-featured desktop
> install on a slow machine can take days to finish.

This is one of the things I love about the *BSD systems. The package
system is "two-headed". You an do pkg_add, and it'll act like yum or
apt-get, and install binaries for the package and all the
requirements for it. Or you can cd to /usr/ports/category/pkg-name
and do "make install", and it will download, compile and install all
the required software and the port you're building (I do that to
change the isntalltion prefix on the packages). If you want to create
customized packages, you just do "make package". I found creating a
port (and hence package) to be much easier than creating a .deb or
.rpm, but that may just be me. For real control, you can install the
portupgrade package.

That said, the author of the BSD ports system thinks the architecture
is wrong. It handles the building, installation, fetching and
requirements all by itself. He thinks the yum/apt-get approach, where
one tool handles package installation duties, and another deals with
requirements fetching is much saner.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Mike Meyer
"Andrea Gavana" <[EMAIL PROTECTED]> writes:
> I tend to agree with you, Rick. I usually don't like Xah's "posting
> behavior", but  this time he has done, in my opinion, a "constructive"
> criticism (and he didn't even say *fuck* once in the whole post!!!). I am
> quite a newbie in Python, I usually deal with wxPython that is sometimes not
> very "pythonic", or not enough "pythonic". As a newbie (in whatever language
> you wish), I would like to open the docs about a particular library, class
> or method and find a small "sample application" of it. I think many newbies
> learn by examples. I don't mean to say anything negative about the docs or
> the docs' authors, but I would imagine that having a simple example of use
> for all the methods in a class/library would be a nice and valuable
> improvement for the docs.

The thing is, the library documentation that Xah Lee is complaining
about is a *reference document*. It says so right in the title:
"Python Library Reference". As such, it makes lousy tutorial
documentation. Xah correctly points this out, which is akin to
pointing out that the sky is not green.

Now, if he wanted to call the PSF to task for not providing sufficient
tutorial documentation, he might have a point. On the other hand, the
PSF has limited resources, and:

> OTOH, usually by using some simple google-fu, it is easy to find a sample
> application for a particular method.

The Python Cookbook should show up a lot in this search. If other
people are providing tutorial documentation, then it's not at clear
that the PSF should be duplicating that effort. If they had infinite
resources, it's clear they should be providng the documentation Xah
Lee wants. It doesn't, so letting third parties provide tutorial
documentation is probably the best use of the limited resources that
they have available.

And, since we're talking about Mr. Lee, let's add the obligatory
request that you help google find him by description by adding this
link to your page: http://xahlee.org/";>stupider than spam

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes:
> The thing is, the library documentation that Xah Lee is complaining
> about is a *reference document*. It says so right in the title:
> "Python Library Reference". As such, it makes lousy tutorial
> documentation.

I'm not sure which particular library Xah Lee was complaining about
but lots of the lib docs are awful even as references.

> The Python Cookbook should show up a lot in this search. If other
> people are providing tutorial documentation, then it's not at clear
> that the PSF should be duplicating that effort. 

It seems to me that since the PSF is so persnickety about code
licenses (and that is a good thing), it should be persnickety about
documentation licenses too.  Lots of FSF documentation projects were
undertaken because while there were good docs in existence for
whatever it was, there were none that the FSF could include in its
distros.  It's similarly not so great if Python users have to rely on
proprietary docs.  Of course the PSF has to prioritize its tasks and
some things will necessarily stay far down on the "list" for quite a
while, but they should at least BE on the list.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-05 Thread Steven D'Aprano
On Sat, 05 Nov 2005 16:27:00 -0800, Paul Rubin wrote:

> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> But do you want x += y to work for immutable objects as well? Then
>> __iadd__ cannot be a statement, because x can't be modified in place.
> 
> It never occurred to me that immutable objects could implement __iadd__.
> If they can, I'm puzzled as to why.  

???

The classic += idiom comes from C, where you typically use it on ints and
pointers.

In C, ints aren't objects, they are just bytes, so you can modify them
in place. I'm surprised that it never occurred to you that people might
want to do something like x = 1; x += 1 in Python, especially as the
lack of such a feature (as I recall) was one of the biggest complaints
from C programmers crossing over to Python.

Personally, I'm not fussed about +=. Now that it is in the language, I'll
use it, but I never missed it when it wasn't in the language.

>> While I am enjoying the hoops people are jumping through to modify the
>> language so that b.a += 2 assigns b.a in the same scope as it was
>> accessed, I'm still rather perplexed as to why you would want that
>> behaviour.
> 
> Weren't you the one saying += acting differently for mutables and
> immutables was a wart?  

Nope, not me.

> If it's such a wart, why are do you find it so
> important to be able to rely on the more bizarre consequences of the
> wartiness?  Warts should be (if not fixed) avoided, not relied on.

The consequences of instance.attribute += 1 may be unexpected for those
who haven't thought it through, or read the documentation, but they aren't
bizarre. Whether that makes it a feature or a wart depends on whether you
think non-method attributes should be inherited or not. I think they
should be.

I can respect the position of somebody who says that only methods
should be inherited -- somebody, I think it was you, suggested that there
is at least one existing OO language that doesn't allow inheritance for
attributes, but never responded to my asking what language it was.
Personally, I would not like an OO language that didn't inherit
attributes, but at least that is consistent. (At least, if you don't
consider methods to be a particular sort of attribute.)

But I can't understand the position of folks who want inheritance but
don't want the behaviour that Python currently exhibits.
instance.attribute sometimes reading from the class attribute is a feature
of inheritance; instance.attribute always writing to the instance is a
feature of OOP; instance.attribute sometimes writing to the instance and
sometimes writing to the class would be, in my opinion, not just a wart
but a full-blown misfeature.

I ask and I ask and I ask for some use of this proposed behaviour, and
nobody is either willing or able to tell me where how or why it would be
useful. What should I conclude from this?


-- 
Steven.

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


python problems

2005-11-05 Thread Mostapha Amenchar



http://maven.smith.edu/~thiebaut/classes/111/111.html
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Multiples of a number

2005-11-05 Thread Carl Friedrich Bolz
Hi!

Ivan Shevanski wrote:
> I've searched on google for a bit but I can't seem to find a way to get 
> multiples of a number. . .For instance what would I do if I wanted 
> something to happen every time x reached a multiple of 100 in this 
> sample code:
> 
> x = 0
> while x < 2000:
>  x += 1
> 

The idea is to use to modulo operator % which gives you the residue of a 
number when divided by another number:

x = 0
while x < 2000:
 x += 1
 if x % 100 == 0:
  do_something()


Note that it is probably more appropriate to use a for loop:

for x in range(2000):
 if x % 100 == 0:
 do_something()


Cheers,

Carl Friedrich Bolz

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


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Mike Meyer
Paul Rubin  writes:
> Mike Meyer <[EMAIL PROTECTED]> writes:
>> The thing is, the library documentation that Xah Lee is complaining
>> about is a *reference document*. It says so right in the title:
>> "Python Library Reference". As such, it makes lousy tutorial
>> documentation.
> I'm not sure which particular library Xah Lee was complaining about
> but lots of the lib docs are awful even as references.

That's true, but Xah Lee's proposed fixes do nothing to address this
problem.

>> The Python Cookbook should show up a lot in this search. If other
>> people are providing tutorial documentation, then it's not at clear
>> that the PSF should be duplicating that effort. 
> It seems to me that since the PSF is so persnickety about code
> licenses (and that is a good thing), it should be persnickety about
> documentation licenses too.  Lots of FSF documentation projects were
> undertaken because while there were good docs in existence for
> whatever it was, there were none that the FSF could include in its
> distros.  It's similarly not so great if Python users have to rely on
> proprietary docs.  Of course the PSF has to prioritize its tasks and
> some things will necessarily stay far down on the "list" for quite a
> while, but they should at least BE on the list.

To my knowledge the PSF isn't doing anything about including the
documentation with their distribution, so they shouldn't care about
the licenses. Wanting to bundle a good tutorial for everything in the
library might be on the list, but the licenses on third-party
tutorials shouldn't matter until you are considering bundling them. In
that light, the only major omission I can think of is Tkinter, as the
only good docs - tutorial, reference, or otherwise - is the Grayson's
book.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-05 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > It never occurred to me that immutable objects could implement __iadd__.
> > If they can, I'm puzzled as to why.  

> I'm surprised that it never occurred to you that people might
> want to do something like x = 1; x += 1 in Python,

But I wouldn't expect that to mean that ints implement __iadd__.  I'd expect
the x+=1 to just use __add__.  I haven't checked the spec though.

> I can respect the position of somebody who says that only methods
> should be inherited -- somebody, I think it was you, suggested that there
> is at least one existing OO language that doesn't allow inheritance for
> attributes, but never responded to my asking what language it was.

I was thinking of Flavors.  You use a special function (send) to do method
calls.  But people generally felt that was kludgy and CLOS eliminated it.
I'm not sure what happens in Smalltalk.

> instance.attribute sometimes reading from the class attribute is a feature
> of inheritance; instance.attribute always writing to the instance is a
> feature of OOP; instance.attribute sometimes writing to the instance and
> sometimes writing to the class would be, in my opinion, not just a wart
> but a full-blown misfeature.

But that is what you're advocating: x.y+=1 writes to the instance or
the class depending on whether x.y is mutable or not.  Say you have an
immutable class with a mutable subclass or vice versa.  You'd like to
be able to replace a class instance with a subclass instance and not
have the behavior change (Liskov substitution principle), etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes:
> To my knowledge the PSF isn't doing anything about including the
> documentation with their distribution, so they shouldn't care about
> the licenses. Wanting to bundle a good tutorial for everything in
> the library might be on the list, but the licenses on third-party
> tutorials shouldn't matter until you are considering bundling them. 

It's only -because- of those licenses that there's any reason not to
bundle.  Are there any good Python docs outside of the distro, that
are licensed suitably for bundling?  If yes, I'd say there's a good
case for bundling them.

> In that light, the only major omission I can think of is Tkinter, as
> the only good docs - tutorial, reference, or otherwise - is the
> Grayson's book.

I found 

  http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html

to be a pretty good tutorial, though incomplete as a reference.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-05 Thread Steve Holden
Steven D'Aprano wrote:
[...]
> 
> But I can't understand the position of folks who want inheritance but
> don't want the behaviour that Python currently exhibits.
> instance.attribute sometimes reading from the class attribute is a feature
> of inheritance; instance.attribute always writing to the instance is a
> feature of OOP; instance.attribute sometimes writing to the instance and
> sometimes writing to the class would be, in my opinion, not just a wart
> but a full-blown misfeature.
> 
> I ask and I ask and I ask for some use of this proposed behaviour, and
> nobody is either willing or able to tell me where how or why it would be
> useful. What should I conclude from this?
> 
> 

You should conclude that some readers of this group are happier 
designing languages with theoretical purity completely disconnected from 
users' needs. But of course we pragmatists know that practicality beats 
purity :-)

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Using Which Version of Linux

2005-11-05 Thread Steve Holden
Dan M wrote:
> On Sat, 05 Nov 2005 04:26:38 -0600, blahman wrote:
> 
> 
>>ok, i m going to use Linux for my Python Programs, mainly because i 
>>need to see what will these fork() and exec() do. So, can anyone tell 
>>me which flavour of linux i should use, some say that Debian is more 
>>programmer friendly, or shold i use fedora, or Solaris. Because these 
>>three are the only ones i know of that are popular and free.
> 
> 
> Personally I would recommend staying away from Fedora unless you have a
> friend who is well-versed in it and willing to help. I like the
> distributin ok (I run it on the laptop I'm writing this from) but it uses
> RPMs for package distribution, and the rpm tools don't know how to
> automatically downloaded dependencies like yum or apt do. Because of that
> I have to say that the RPM package tools suck quite badly.
> 
> Debian and SUSE are both pretty good choices.

I used yum on Fedora Core 2, and it downloaded and installed 
dependencies fine.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Mike Meyer
Paul Rubin  writes:

>> To my knowledge the PSF isn't doing anything about including the
>> documentation with their distribution, so they shouldn't care about
>> the licenses. Wanting to bundle a good tutorial for everything in
>> the library might be on the list, but the licenses on third-party
>> tutorials shouldn't matter until you are considering bundling them. 
> It's only -because- of those licenses that there's any reason not to
> bundle.

Actually, there are other reasons, just as there are reasons besides
licensing for not simply including third party libraries into the
standard library. Most important is the issue of maintenance: is
someone going to commit to keeping an added document up to date with
the distribution? Bundling out of date documentation is a bad
thing. Bundling documentation that is going to be left out of the next
release because nobody updated it isn't much better. The author of the
documentation is the logical person to do this, but if they wanted the
documentation bundled with Python, they probably would have submitted
it as a PR (I know that's what I do for OSS projects).

>> In that light, the only major omission I can think of is Tkinter, as
>> the only good docs - tutorial, reference, or otherwise - is the
>> Grayson's book.
> I found 
>   http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html
> to be a pretty good tutorial, though incomplete as a reference.

Thanks for the URL, but that's just a short list of links, most of
which I've already seen.

http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes:
> > It's only -because- of those licenses that there's any reason not to
> > bundle.
> 
> Actually, there are other reasons, just as there are reasons besides
> licensing for not simply including third party libraries into the
> standard library.

I'm not talking about 3rd party libraries, I'm talking about 3rd party
documentation for modules that are already in the Python standard
library.  For example, if someone wrote a good Tkinter manual that
were licensed in a way that the PSF could drop it into the Python
distro, then PSF should certainly consider including it.  The same
goes for good docs about urllib2, or various other modules that
currently have lousy docs.

> > I found 
> >   http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html
> > to be a pretty good tutorial, though incomplete as a reference.
> 
> Thanks for the URL, but that's just a short list of links, most of
> which I've already seen.

Sorry, I meant:

  http://infohost.nmt.edu/tcc/help/pubs/tkinter/ (html)
  http://www.nmt.edu/tcc/help/pubs/tkinter.pdf   (pdf of same)

You've probably seen this manual already.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modify HTML data

2005-11-05 Thread [EMAIL PROTECTED]

Swarna wrote:
> Hi all,
>
> Can anyone help me with this ?
>
> I am using scp in python to copy a html file on remote server, to my
> local machine. Now, i need to update this html file in my local machine
> ( by adding a new Hyperlink to the existing table od hyperlinks ) and
> copy it back (overwriting the old copy ) to the remote server.

If I understand correctly you need something like PyMeld, ElementTree
or BeautifulSoup

Lorenzo

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


Re: mod_python

2005-11-05 Thread Little
I have created the following database but the following errors occur
when trying to execute the code.

html source:


Click here to display information from Chocolate menu:


Press to view the display




Please provide data for chocolate to be added:



Name:
Rating:  
Price :  






form.py source

import MySQLdb

def addchocolate(z_Name, z_rating, z_price):

# make sure the user provided all the parameters
if not (z_Name and z_rating and z_price):
return "A required parameter is missing, \
   please go back and correct the error"
db =
MySQLdb.connect(host="localhost",user="hayward",passwd="hayward",db="hayward")
cursor = db.cursor()
cursor.execute(
"""INSERT INTO InventoryList (artist, title, rating) VALUES (%s,
%s, %s)""", (z_Name, z_rating, z_price) )
db.commit()
cursor.close()
db.close()

def display(rating):
db =
MySQLdb.connect(host="localhost",user="hayward",passwd="hayward",db="hayward")
cursor = db.cursor()
cursor.execute("""SELECT * FROM InventoryList""")
result = cursor.fetchall()
cursor.close()
db.close()
parsesongs(result)
return

def parsesongs(rawstring):
print 'Chocolate Inventory'
print
'---'
print 'Name   Rating
Price  '
print
'---'
for i in range (0, len(rawstring)):
table = ''
Name = rawstring[i][0]
table = table + Name
for j in range (0, (29 - len(Name))):
table = table + ' '
Rating = rawstring[i][1]
table = table + Rating
for k in range (0, (29 - len(Rating))):
table = table + ' '
Price = str(rawstring[i][2])
table = table + Price
print table
print
'---'
return

errors that occur
press display:
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
193, in Dispatch
result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line
173, in handler
result = apply(object, (), args)

TypeError: display() takes exactly 1 argument (0 given)

press the addition of the items:
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
193, in Dispatch
result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line
173, in handler
result = apply(object, (), args)

  File
"/home/hayward/public_html/Homework/Python_Executable_Publisher/form.py",
line 11, in addchocolate
cursor.execute(

  File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 137,
in execute
self.errorhandler(self, exc, value)

  File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line
33, in defaulterrorhandler
raise errorclass, errorvalue

OperationalError: (1054, "Unknown column 'artist' in 'field list'")
 
Thanks for the help

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


Re: GMPY: divm() memory leak revisited

2005-11-05 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
...
> Unfortunately, I don't have any means of testing this theory.

Yep -- I reproduced the memory leak you mentioned, and easily fixed it
(exactly as you suggest) in the current CVS version of gmpy (meant to be
"1.01 release candidate").  I need to fix some other pending bugs, then
remind myself of how the (expl.del) one makes a release on Sourceforge,
then it shd be fine (except for Windows -- I have no Windows development
system around to do anything... Mac and Linux only).

One of the bugs I must still get around to examining is the algorithmic
one you mention in your next post, btw.

Thanks for your diagnostic and debugging help.  BTW, should you wish to
mail me privately, I'm "aleaxit" (my favourite userid, with or w/o the
trailing "it" depending on service -- see www.aleax.com to understand
why that is the case), and the best way to reach me these days is
through "gmail.com" .


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


Re: Class Variable Access and Assignment

2005-11-05 Thread Steven D'Aprano
On Sat, 05 Nov 2005 18:14:03 -0800, Paul Rubin wrote:

>> instance.attribute sometimes reading from the class attribute is a feature
>> of inheritance; instance.attribute always writing to the instance is a
>> feature of OOP; instance.attribute sometimes writing to the instance and
>> sometimes writing to the class would be, in my opinion, not just a wart
>> but a full-blown misfeature.
> 
> But that is what you're advocating: x.y+=1 writes to the instance or
> the class depending on whether x.y is mutable or not.

Scenario 1:

Pre-conditions: class.a exists; instance.a exists.
Post-conditions: class.a unchanged; instance.a modified.

I give that a big thumbs up, expected and proper behaviour.

Scenario 2:

Pre-conditions: class.a exists and is immutable; instance.a does not
exist.
Post-conditions: class.a unchanged; instance.a exists.

Again, expected and proper behaviour.

(Note: this is the scenario that Antoon's proposed behaviour would change
to class.a modified; instance.a does not exist.)

Scenario 3:

Pre-conditions: class.a exists and is mutable; instance.a exists.
Post-conditions: class.a unchanged; instance.a is modified.

Again, expected and proper behaviour.

Scenario 4:

Pre-conditions: class.a exists and is mutable; instance.a does
not exist.
Post-conditions: class.a modified; instance.a does not exist.

Well, that is a wart. It is the same wart, and for the same reasons, as
the behaviour of:

def function(value=[]):
value.append(None)

I can live with that. It is a familiar wart, and keeps inheritance of
attributes working the right way. And who knows? If your attributes are
mutable, AND you want Antoon's behaviour, then you get it for free just by
using b.a += 1 instead of b.a = b.a + 1.


> Say you have an
> immutable class with a mutable subclass or vice versa.  You'd like to
> be able to replace a class instance with a subclass instance and not
> have the behavior change (Liskov substitution principle), etc.

That's easy. You just have to make sure that the subclass implements
__iadd__ the same way that the immutable parent class does. 

You can't expect a class that performs += in place to act the
same as a class that doesn't perform += in place. Excessive data
abstraction, remember? 

L = list("Liskov substitution principle")
L.sort()  # sorts in place
print L   # prints the sorted list

class immutable_list(list):
# __init__ not shown, but does the right thing
def sort(self):
tmp = list(self)
tmp.sort()
return immutable_list(tmp)

L = immutable_list("Liskov substitution principle")
L.sort()  # throws the sorted list away
print L   # prints the unsorted list

The only way the Liskov substitution principle works is if everything
works the same way, which means that all subclasses, all *possible*
subclasses, must have no more functionality than the subclass that does
the absolute least. Since the least is nothing, well, you work it out.

-- 
Steven.

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


Re: Multiples of a number

2005-11-05 Thread Steven D'Aprano
On Sun, 06 Nov 2005 02:39:40 +0100, Carl Friedrich Bolz wrote:

> Hi!
> 
> Ivan Shevanski wrote:
>> I've searched on google for a bit but I can't seem to find a way to get 
>> multiples of a number. . .For instance what would I do if I wanted 
>> something to happen every time x reached a multiple of 100 in this 
>> sample code:
>> 
>> x = 0
>> while x < 2000:
>>  x += 1
>> 
> 
> The idea is to use to modulo operator % which gives you the residue of a 
> number when divided by another number:

> for x in range(2000):
>  if x % 100 == 0:
>  do_something()

Another way is, if you aren't doing anything *except* counting for the
other 99 values of x, just skip them completely:

fox x in range(20):
do_something(x*100)


Ivan, what are you trying to do?


-- 
Steven.

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


Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Mike Meyer
Paul Rubin  writes:
> Mike Meyer <[EMAIL PROTECTED]> writes:
>> > It's only -because- of those licenses that there's any reason not to
>> > bundle.
>> Actually, there are other reasons, just as there are reasons besides
>> licensing for not simply including third party libraries into the
>> standard library.
>
> I'm not talking about 3rd party libraries, I'm talking about 3rd party
> documentation for modules that are already in the Python standard
> library.

So am I. My point is that many of the considerations as to why you
don't simply include a module in the library also apply when it comes
to including documentation in the distribution. I gave some examples,
including why they were important for *documentation*, but you
carefully elided those.

> For example, if someone wrote a good Tkinter manual that
> were licensed in a way that the PSF could drop it into the Python
> distro, then PSF should certainly consider including it.  The same
> goes for good docs about urllib2, or various other modules that
> currently have lousy docs.

The key word is "consider". They have to deal with all the issues I
pointed out before, of which licensing is just the beginning.

> Sorry, I meant:
>   http://infohost.nmt.edu/tcc/help/pubs/tkinter/ (html)
>   http://www.nmt.edu/tcc/help/pubs/tkinter.pdf   (pdf of same)
> You've probably seen this manual already.

Yes, I have. I still say the only good documentation is Grayson's
book.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiples of a number

2005-11-05 Thread Robert Kern
Steven D'Aprano wrote:

> Another way is, if you aren't doing anything *except* counting for the
> other 99 values of x, just skip them completely:
> 
> fox x in range(20):
> do_something(x*100)
> 
> Ivan, what are you trying to do?

Presumably he's doing something substantive on every 1-increment; he
just needs to do something extra (like print some diagnostic
information) on every 100-increment.

-- 
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


Distributed Cache Server?

2005-11-05 Thread [EMAIL PROTECTED]
Does anyone know if a "distributed caching system" has been developed
for use with Python? I've seen mention of memcached, but was really
after something natively python.

Yes, "distributed caching system" is a bit of a general term, but am
really just talking about something as simple as key + value (arbitrary
class) which can be split over a number of machines in an efficient
manner.

I've started development of such a system, but am wondering if
something already exists out there.

KenF

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


  1   2   >