Re: undefined symbol: PyUnicodeUCS4*

2005-09-20 Thread Analabha Roy
Fredrik Lundh wrote:

> Analabha Roy wrote:
> 
>> I'm running Fedora Core 3, and recently I've encountered serious problems
>> with apps that need python to run.
>>
>>  running any such app gives errors like:
>>
>> ImportError: /usr/lib/python2.3/site-packages/rhpl/iconv.so: undefined
>> symbol: PyUnicodeUCS4_AsUTF8String
>>
>> Well, all apps dont produce same error but similar errors. All undefined
>> symbols start with PyUnicodeUCS4.
>> What is wrong???
> 
> Python can be built with UCS2-based or UCS4-based Unicode support.
> It looks like you're trying to use extensions built for a UCS4-based
> version with an UCS2 build.





 Thanks for your response.
I did not build python from source at all, but installed it from rpm
(python-2.3.4-13.1) downloaded from fc3 repositories.

Is it necessary to build it from source? If so, should I download the
tarball from their website or downlaod some kind of "python-devel" rpm?






> 
> (I think, but I'm not sure, that installing extensions built for certain
> Red Hat versions on FC3 may cause this problem)
> 
> For instructions on how to build the core interpreter with Unicode
> support, run "./configure --help" and look for the "--enable-unicode"
> option.
> 
> 

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


Re: Python Doc Problem Example: os.path.split

2005-09-20 Thread Antoon Pardon
Op 2005-09-19, Diez B. Roggisch schreef <[EMAIL PROTECTED]>:
>> 
>> split(path)
>>  returns a pair (dirname,filename), where dirname is the part of path
>> up to the last slash, and filename is the rest of the string after the
>> last slash.
>
> Bullshit. Slash isn't always the path component delimiter. Get a clue on 
> what you're talking about before suggesting so-called "improvements". 
> And once and for all get it into your head that it's not the purpose of 
> this nor any other documentation effort to precisely fit your 
> nano-tube-narrow mindset.

I think this is unfair. The use of "slash" is a failing of the current
documentation. If his use is an indication of a nano-tube-narrow
mindset then so would be the use by the actual documentation writers.

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


py2exe 0.6.2 version resources

2005-09-20 Thread klaus . roedel
Hi @all,

I've implementet a simple setup script for my application with py2exe.
The setup.py works fine, but now I want to add version resources to my
*.exe-file. But how can I do it?
I've tested it with the setup.cfg, but that doesn't work. I alwayse
became the errormessage:
  error: error in setup.cfg: command 'py2exe' has no such option
'version_legalcopyright'
until I've deleted all options.
I'm using python 2.4.1 and py2exe 0.6.2 on Windows XP SP2.
Thanks for any help.

Greets,
Klaus

PS:
Here my example setup.py:

from distutils.core import setup
import glob
import py2exe

install = dict(script="startApp.py",
dest_base="My Application",
icon_resources=[(1, "img\\icon.ico")])

opts = dict(py2exe= dict(dist_dir="Application"))

setup(name = 'My Application',
  author="Klaus Rödel",
  data_files=[("img", glob.glob("img\\*.png")), ("img",
glob.glob("img\\*.ico")), ("", ["my_dll.dll"])],
  options = opts,
  windows=[install])

And here my example setup.cfg:

[py2exe]
version-companyname=which ever
version-filedescription=the little application name
version-fileversion=0.1.0
version-legalcopyright=Hmm...
version-legaltrademarks=blah blah
version-productname=the little applications product name
version-productversion=0.1.0

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


Re: C#3.0 and lambdas

2005-09-20 Thread Kay Schluehr
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > On Slashdot there is a discussion about the future C#3.0:
> > http://developers.slashdot.org/developers/05/09/18/0545217.shtml?tid=109&tid=8
> >
> > http://msdn.microsoft.com/vcsharp/future/
>
> "The extensions enable construction of compositional APIs that
> have equal expressive power of query languages in domains such
> as relational databases and XML."
>
> > There are many differences, but it looks a bit more like Python:
> > http://download.microsoft.com/download/9/5/0/9503e33e-fde6-4aed-b5d0-ffe749822f1b/csharp%203.0%20specification.doc
>
> meanwhile, over in python-dev land:
>
> "Is anyone truly attached to nested tuple function parameters; 'def
> fxn((a,b)): print a,b'?  /.../
>
> Would anyone really throw a huge fit if they went away?  I am willing
> to write a PEP for their removal in 2.6 with a deprecation in 2.5 if
> people are up for it."
>
> 

I won't get nervous if they will be refused in their poor current state
but I would get excited if they will be extended to something becoming
close to algebraic data types enabling pattern matching. Maybe it's an
irony of the Python development process that it tries to refuse
functional programming facilities in just a moment where mainstream
languages start to embrace them. Besides C# also VisualBasic gets
improved:

http://lambda-the-ultimate.org/node/view/967

For the Java platform Scala raises some attention too, after the
failure of the Java design team of integrating generics in a clean and
comprehensible way with the existing language.

Here is Scalas attempt for pattern matching called "case classes":

http://scala.epfl.ch/intro/caseclasses.html

I do think that gimmicks, syntax permutations and refusals of so called
"Python warts" are not sufficient to preserve language attraction in a
competing field that tries to make fast progress. 

Kay

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


Re: undefined symbol: PyUnicodeUCS4*

2005-09-20 Thread Fredrik Lundh
Analabha Roy wrote:

> I did not build python from source at all, but installed it from rpm
> (python-2.3.4-13.1) downloaded from fc3 repositories.

the problem isn't with the python interpreter, it's that you're using
add-on libraries that don't match your interpreter installation.

where did you get the RHPL library, for example?

   ImportError: /usr/lib/python2.3/site-packages/rhpl/iconv.so:
   undefined symbol: PyUnicodeUCS4_AsUTF8String

(iirc, RHPL is the RedHat Python Library)





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


services on linux

2005-09-20 Thread pt python
hi to all,
 
im moving from the windows world to the linux world and i need to make a python script to see if a service is instaled (ex: apache), if it is running or stoped and to start/stop a service like apache or mysql. Theres an API on windows to manage services and i need to know how to do that on linux. Can anyone help me with the module and API to work with services on linux?
 
by the way, im developing a app, maybe multi-plataform, to install and manage several open source packages like apache, mySQL, phpwebadmin, phpnuke, etc... if anyone have nice ideais i apreciate that.. 
 
thanks a lot...
teckV__Correo Yahoo!Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.espanol.yahoo.com/ -- 
http://mail.python.org/mailman/listinfo/python-list

Re: C#3.0 and lambdas

2005-09-20 Thread Fredrik Lundh
Kay Schluehr wrote:

> Maybe it's an irony of the Python development process that it tries
> to refuse functional programming facilities in just a moment where
> mainstream languages start to embrace them.

hey, at least one other person got my point ;-)

(fwiw, today's python-dev discussion is about changing the behaviour
of the "and" and "or" operators.  priorities, priorities...)





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


plateform info.

2005-09-20 Thread Monu Agrawal
Hi I want to know whether the program is being run on windows or on
Xnix. Is there any variable or method which tells me that it's windows?

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


Re: functional or object-oriented?

2005-09-20 Thread bruno modulix
beza1e1 wrote:
> This nails it down, yes. :)
> 
> I probably was too deep into OOP thinking-mode to work pythonic. So i
> am now rediscovering the python way.
> 
> Have you read Paul Grahams On Lisp (or was it one of his essays)? He is
> strongly in favor of functional programming.

Yes, but this does not implies that FP is the main trend in CommonLisp.
I discussed that point some years ago on c.l.lisp, and it turned out
that Paul Grahams POV was not perceived by the communauty as
representative of the most common usage of CommonLisp.

> Mainly because Lisp favors
> it. 

While being the father of FPLs, CommonLisp is not a 'pure' FPL, and
clearly a multiparadigm language. BTW, it's object model is probably one
of the most astonishing I've seen.

> He does say though, simulations and CAD programs are inherently OO.
> But now i am writing a game modelling engine, i find objects are not
> the best way anytime in these fields either.

Ok, but keep in mind you're using Python, not Lisp. While supporting
some FP features (first class functions, nested functions, closures,
list expressions, generators, and (a very restricted kind of) anonymous
functions...), Python is still a 'pure' OOPL (ie : everything's an
object). Not using the *class* statement when there's no use for it
doesn't mean not using *objects*. One of the pre-requisites for FP is
first-class functions, and Python provides this by defining functions as
instances of class function. So even the most FP Python programs are
still OO, at least under the hood !-)

My 2 cents
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: plateform info.

2005-09-20 Thread Juho Schultz
Monu Agrawal wrote:
> Hi I want to know whether the program is being run on windows or on
> Xnix. Is there any variable or method which tells me that it's windows?
> 

os.name - the value is "posix" for Linux/Unix, "nt" or "ce" for Windows,
and so on...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Organising a python project

2005-09-20 Thread bruno modulix
[EMAIL PROTECTED] wrote:
> Dear all,
> 
> Can anyone point me to a resource that describes the best way of
> organising a python project? My project (gausssum.sf.net) is based
> around a class, and has a GUI that allows 'easy-access' to the methods
> of the class. 

Err... Unless it's a *very* simple project, having the project based on
a *single* class smells of GodClassAntipattern (I can't say for sure
without seeing the source of course, so this is most a a priori than a
judgement !-).

> What is the best or typical directory structure that
> allows the easy creation of binary packages

'binary packages' ?

> for linux and windows,
> source distributions, etc.
> 
> Rather than make up my own way, I'd prefer to know if there is a
> typical python way...

Usually, a program project is made of one or more library modules,
eventually organized in packages, and a 'main' script that's the entry
point for the program [1]. Most Python projects being OSS, you can
examine existing projects.


[1] Note that this not Python specific. You'll find the same overall
organisation in C, C++, Java, etc...

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: plateform info.

2005-09-20 Thread Mikael Olofsson
Monu Agrawal wrote:
> Hi I want to know whether the program is being run on windows or on
> Xnix. Is there any variable or method which tells me that it's windows?

Will this help?

 >>> import sys
 >>> sys.platform
'win32'

There is also the platform module, that can give you a lot more 
information about the your platform. Try help(platform).

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


Re: undefined symbol: PyUnicodeUCS4*

2005-09-20 Thread Analabha Roy
Fredrik Lundh wrote:

> Analabha Roy wrote:
> 
>> I did not build python from source at all, but installed it from rpm
>> (python-2.3.4-13.1) downloaded from fc3 repositories.
> 
> the problem isn't with the python interpreter, it's that you're using
> add-on libraries that don't match your interpreter installation.
> 
> where did you get the RHPL library, for example?
> 
>ImportError: /usr/lib/python2.3/site-packages/rhpl/iconv.so:
>undefined symbol: PyUnicodeUCS4_AsUTF8String
> 


Oh, ok. Everything in my system is installed from rpms from apt repos for
Fedora Core 3. For instance

$rpm -qa|grep rhpl

rhpl-0.148.1-2

 Which I got from one of the repos in my /etc/apt/sources.list file



 For some reason, FC-3 installed both python2.3 and python2.4. It could be
that the addon libraries are for python2.4, but are configged to use
python2.3 interpreter or something (you'll have to excuse my ignorance
about such matters, I've not learned python). 
I uninstalled python2.4 completely, and rpm uninstalled some python bindings
for other things as dependencies. Presumably, the rpm deps left 
(PyQT, pygtk, rhpl etc)
should contain those 'add-on' libraries you mentioned (I dunno though) and
they depend on the python2.3 rpm (still installed). However, the same
problems above remain. Unless the packages are broken, what else could be
wrong?



> (iirc, RHPL is the RedHat Python Library)
> 
> 

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


Re: Python and Unix Commands

2005-09-20 Thread Adriaan Renting
>>>"Adriaan Renting" <[EMAIL PROTECTED]> 09/19/05 11:20 am >>> 
| 
|P.S. you don't need to post your question to this list every 5 minutes. 
| 
Hmmm, somehow my reply also got posted more than once...
At least that's what it looks like in my mail viewer, I only see one post in 
Google. 
Maybe it's just Groupwise that's giving me phantom messages, I appologize for 
my remark if that's the case.
I hope Groupwise 7 will be an improvement over my current 6.5.
 
 

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


Re: services on linux

2005-09-20 Thread Christoph Haas
On Tue, Sep 20, 2005 at 02:57:26AM -0500, pt python wrote:
> im moving from the windows world to the linux world and i need to make
> a python script to see if a service is instaled (ex: apache), if it is
> running or stoped and to start/stop a service like apache or mysql.
> Theres an API on windows to manage services and i need to know how to
> do that on linux. Can anyone help me with the module and API to work
> with services on linux?

Unless you really want to do that in Python. It's just a matter of "ps"
and "grep". Simple shell stuff.

Example: ps ax | grep apache

> by the way, im developing a app, maybe multi-plataform, to install and
> manage several open source packages like apache, mySQL, phpwebadmin,
> phpnuke, etc... if anyone have nice ideais i apreciate that..

That's usually the Linux distribution's job to handle the installed
packages. Some distributions do that better than others
(Debian). ;) Or what did you mean when you said "install
and manage"?

Regards
 Christoph
-- 
~
~
~
".signature" [Modified] 3 lines --100%--3,41 All
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: End or Identify (EOI) character ?

2005-09-20 Thread Adriaan Renting
You might be able to find more about GPIB under the names IEEE488 and HP-IB.
It's a 8-bit parallel communications bus used in lab-automation. But it's been 
like 10 years since I used it so I don't remember the specifics. I once wrote a 
driver for it under windows 3.0.
Most of the communication is indeed human readable ASCII, but there are some 
extra lines used. On googling I found: 
 "The five interface management lines (ATN, EOI, IFC, REN, SRQ) manage the flow 
of control and data bytes across the interface" 
in this document:
http://www.techsoft.de/htbasic/tutgpibm.htm?tutgpib.htm

This means that EOI isn't an ASCII character, because it's not transmitted on 
any of the data lines. You'll probably need to access some specific adress in 
the GPIB controller, or use it's driver, to get/set the state of the management 
and the handshake lines.
 
>>>Donn Cave <[EMAIL PROTECTED]> 09/19/05 6:33 pm >>> 
In article <[EMAIL PROTECTED]>, 
"Terry Reedy" <[EMAIL PROTECTED]> wrote: 
 
>"Madhusudan Singh" <[EMAIL PROTECTED]> wrote in message 
>news:[EMAIL PROTECTED] 
>>Hi 
>> 
>>I was wondering how does one detect the above character. It is returned 
>>by 
>>an instrument I am controlling via GPIB. 
> 
>EOI = chr(n) # where n is ASCII number of the character. 
># then whenever later 
>if gpid_in == EOI: #do whatever 
 
Which begs the question, what is the ASCII number of the 
character?  I was curious enough to feed GPIB and EOI into 
a search engine, and from what I got back, I believe it is 
not a character, but rather a hardware line that may be 
asserted or not.  GPIB, whatever that is, may support some 
configuration options where EOI causes a character output, 
but the actual value depends on configuration.  The documentation 
is probably the place to find out more about this stuff. 
 
  Donn Cave, [EMAIL PROTECTED] 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Simpler transition to PEP 3000 "Unicode only strings"?

2005-09-20 Thread Petr Prikryl
Hi all, 

My question is: How do you tackle with mixing
Unicode and non-Unicode parts of your application?

Context: 


The PEP 3000 says 
"Make all strings be Unicode, and have a separate bytes() type."

Until then, I am forced to write 
  # -*- coding: cp123456 -*- 
(see 2.1.4 Encoding declarations) and use...
  myString = u'text with funny letters'
  
This leads to a source polution that will be
difficult to remove later.

The idea:
=

What do you think about the following proposal
that goes the half way

  If the Python source file is stored in UTF-8 (or
  other recognised Unicode file format), then the
  encoding declaration must reflect the format or
  can be omitted entirely. In such case, all
  simple string literals will be treated as
  unicode string literals.
  
Would this break any existing code?

Thanks for your time and experience,
  pepr
  
-- 
Petr Prikryl (prikrylp at skil dot cz) 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows paths, Java, and command-line arguments, oh my!

2005-09-20 Thread Daniel Dittmar
Steve M wrote:

About your main problem: I'm still convinced that it's the order of -jar 
and -D that is important, see my other post.

> I have tried (not entirely systematically but pretty exhaustively)
> every combination of backslashes in the cmd string, e.g.:
>  -Dsalesforce.config.dir=c\:\\config
>  -Dsalesforce.config.dir=c:\\config
>  -Dsalesforce.config.dir=c\\:\config
>  -Dsalesforce.config.dir=c\\:\\config
>  etc.

A hint:
- if you're unsure how something must be entered as a literal, test it 
in the interactive interpreter:

 >>> raw_input ('enter a path: ')
enter a path: c:\config
'c:\\config'

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


strange import phenomenon

2005-09-20 Thread Christoph Zwerschke
Just hitting a strange problem with Python import behavior. It is the 
same on all Python 2.x versions and it is probably correct, but I 
currently don't understand why this happens.

I have created a directory "dir" with the following three module, 
__init__, hello, and test2; and another module test1 in the parent 
directory, like that:


--- test1.py --
from dir import test2



--- dir/__init__.py ---
print "init"
---


--- dir/hello.py --
print "hello world"
---


--- dir/test2.py --
import sys
sys.path = []

import hello
---


The script test2.py removes all entries from the sys.path. So when I run 
test2.py directly, I get an ImportError because the hello module cannot 
be imported. This is as expected.

However, if I run test1, the hello module *is* imported and I get the 
"hello world" message. Why is that??

Probably there is a simple explanation, but currently I simply don't get it.


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


Re: How to write this iterator?

2005-09-20 Thread severa
>> Sorry, my description was not very good, I meant something behaving as:
>>
>> >>>example=Liter("abc","12345","XY")
>> >>>for x in example: print x,
>>
>> a 1 X b 2 Y c 3 4 5
>>
>> or for that append() method,
>>
>> >>>example=Liter("abc", "12345")
>> >>>for i in range(3): print example.next(),
>>
>> a 1 b
>>
>> >>>example.append("XY")
>> >>>for x in example: print x,
>>
>> 2 c X 3 Y 4 5

>Check the module I posted on
>http://rafb.net/paste/results/CRT7bS68.html. append() makes things more
>complicated -- mainly because generators don't accept attributes, so it
>has to be wrapped in a class -- but the simple generator (without
>append) is more manageable

Thank you very much for your solution. Actually I needed that append() 
method quite a lot, so maybe my solution (posted at the beginning of this 
thread) was not that stupid :) (to inflate my ego a bit)

Anyway, this is roughly what I used it for; is it a sane use of iterators?

I was looking for the Holy Grail. I had an iterator 'quest' that produced 
either junk that was to be thrown away, or the Holy Grail itself, or 
another iterator of the same kind (that had to be searched for the Holy 
Grail as well). The iterators were potentially infinite. The code was 
rougly:

quest=Liter(quest)
for x in quest:
if is_Holy_Grail(x):
share_and_enjoy(x)
break
elif is_another_iterator(x):
quest.append(x) 


Best regards
P.

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


ready-made file format for "file pibes"?

2005-09-20 Thread Frithiof Andreas Jensen
I am writing an application that does a lot of filtering of much data
through a sequence of filters.

After some thinking and wasting a lot of time with an object oriented design
with GUI and all, I decided that the Real Way to do this is to create the
filters as independent programs that take input and produce output in the
good, olde UNIX way, using good olde MAKE to track what needs to be done
next.

Now, I need to simplify even further and leach on even more common knowledge
:) so it is obvious to anyone how to extend the collection of filtering
methods.

Is there a Python library for defining and using a good (i.e. humanly
readable), text-based format that one can use for the intermediate files?

ZConfig is - as I understand it - read-only and it is difficult (for me) to
completely understand what the general principles are because anything
appears possible with it. I am unsure of Pyxie mainly because the
documentation does not describe the "philosophy" and I would rather not hack
up a parser for XML myself for my very-own-xml-format-that-no-one
understands.

If the experience with ZConfig is good, then maybe one can sidestep this and
simply write files that can later be read by ZConfig?

I need to save state between filter runs too and I would like to use the
same mechanism everywhere.

I also need some form of hierachi, i.e. for including information from
further up the chain to know what triggered a filter so that downstream
tools can get that information.

Something as simple as a stansa-format (like .netrc) will probably be
servicable with a little work - but if someone has already defined a better,
more commonly-used format, I am all game.

Any Clues??

mvh,
frithiof jensen.


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


Re: py2exe 0.6.2 version resources

2005-09-20 Thread Thomas Heller
[EMAIL PROTECTED] writes:

> Hi @all,
>
> I've implementet a simple setup script for my application with py2exe.
> The setup.py works fine, but now I want to add version resources to my
> *.exe-file. But how can I do it?
> I've tested it with the setup.cfg, but that doesn't work. I alwayse
> became the errormessage:
>   error: error in setup.cfg: command 'py2exe' has no such option
> 'version_legalcopyright'
> until I've deleted all options.
> I'm using python 2.4.1 and py2exe 0.6.2 on Windows XP SP2.
> Thanks for any help.

In py2exe 0.5 and 0.6 you can no longer specify the versionresource in
setup.cfg.  The advanced sample in
lib\site-packages\py2exe\samples\advanced demonstrated how to do it.

> Greets,
> Klaus

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


Re: How to write this iterator?

2005-09-20 Thread Cyril Bazin
Ok!
Now, you wrote your expected results I understand better what you want to do...

Your solution seems fine except the "except IndexError:" part.
I would have wrote:

--
...
           except IndexError:
                if self.iters:
                   self.i=0

                else:
                    raise StopIteration
...
---

- Use the operator "==" if you want to compare values
- if you want to test if a list is empty, test the list itself not the length
- Also, prefer to use "while 1:" in place of "while True:" it's more
optimised since 1 is a constant and True is not a constant (but using
True works fine too)

Anyway, if you are really a python beginner, I should say your program is very good.

Cyril
On 9/20/05, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:>> Sorry, my description was not very good, I meant something behaving as:
 >>>example=Liter("abc","12345","XY")>> >>>for x in example: print x, a 1 X b 2 Y c 3 4 5 or for that append() method,
 >>>example=Liter("abc", "12345")>> >>>for i in range(3): print example.next(), a 1 b >>>example.append
("XY")>> >>>for x in example: print x, 2 c X 3 Y 4 5>Check the module I posted on>http://rafb.net/paste/results/CRT7bS68.html
. append() makes things more>complicated -- mainly because generators don't accept attributes, so it>has to be wrapped in a class -- but the simple generator (without>append) is more manageable
Thank you very much for your solution. Actually I needed that append()method quite a lot, so maybe my solution (posted at the beginning of thisthread) was not that stupid :) (to inflate my ego a bit)Anyway, this is roughly what I used it for; is it a sane use of iterators?
I was looking for the Holy Grail. I had an iterator 'quest' that producedeither junk that was to be thrown away, or the Holy Grail itself, oranother iterator of the same kind (that had to be searched for the Holy
Grail as well). The iterators were potentially infinite. The code wasrougly:quest=Liter(quest)for x in quest:if is_Holy_Grail(x):share_and_enjoy(x)breakelif is_another_iterator(x):
quest.append(x)Best regardsP.--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Do thread die?

2005-09-20 Thread Frithiof Andreas Jensen

"Maurice LING" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> I do have another dumb question which is OT here. Say aFunc method
> instantiates a SOAP server that serves forever, will it prevent bFunc
> from running as a separate thread?

If the SOAP server thread never sleeps or block, it will effectively stop
everything else in your program by eating all the CPU time available. If it
does some IO and other OS functions, probably not because it is likely to
block on those - I do not know SOAPpy in detail, but it being a socket-based
server it should end up in a select loop somewhere. i.e. block when no work
is available. which is what you want.

> For example,
>
> class myClass4:
>  def repeat(self, s): return s+s
>  def aFunc(self, a):
>  import SOAPpy
>  serv = SOAPpy.SOAPServer((a[0], a[1]))
>  serv.registerFunction(repeat)
>  serv.serve_forever()
>  def bFunc(self, b): pass
>  def runAll(self, a, b):
>  threading.Thread(target=self.aFunc, args = (a)).start()
>  threading.Thread(target=self.bFunc, args = (b)).start()
>
> if __name__=='__main__': myClass4().runAll(['localhost', 8000], 'hi')
>
> Will the 2nd thread (bFunc) ever run since the 1st thread is running
> forever? Intuitively, I think that both threads will run but I just want
> to be doubly sure, because some of my program logic depends on the 2nd
> thread running while the 1st thread acts as a SOAP server or something.

Both should run independently, sharing the CPU-time available for your
application. Remember "main" is a thread  too, so you will want "main" to
hang around while your threads are running and you will want "main" to block
on something also, thread.join(), time.sleep(), command line parser e.t.c.
whatever is natural.


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


Re: very high-level IO functions?

2005-09-20 Thread Tom Anderson

On Mon, 19 Sep 2005, Bruno Desthuilliers wrote:


York a écrit :
(snip)

I love python. However, as a biologist, I like some high-levels 
functions in R. I don't want to spend my time on parse a data file.


http://www.python.org/doc/current/lib/module-csv.html

Then in my python script, I call R to read data file and write them 
into an MySQL table. If python can do this easily, I don't need R at 
all.


So you don't need R at all.


Did you even read the OP's post? Specifically, this bit:

R language has very high-level IO functions, its read.table can read a 
total .csv file and recogonize the types of each column.

^^^

Python's csv module gives you tuples of strings; it makes no effort to 
recognise the types of the data. AFAIK, python doesn't have any IO 
facilities like this.


Larry's point that automagical type detection is risky because it can make 
mistakes is a good one, but that doesn't mean that magic is useless - on 
the contrary, for the majority of cases, it works fine, and is extremely 
convenient.


The good news is that it's reasonably easy to write such a function: you 
just need a function 'type_convert' which takes a string and returns an 
object of the right type; then you can do:


import csv

def read_table(f):
for row in csv.reader(f):
yield map(type_convert, row)

This is a very, very rough cut - it doesn't do comment stripping, skipping 
blank lines, dealing with the presence of a header line or the use of 
different separators, etc, but all that's pretty easy to add. Also, note 
that this returns an iterator rather than a list; use list(read_table(f)) 
if you want an actual list, or change the implementation of the function.


type_convert is itself fairly simple:

def _bool(s): # helper method for booleans
s = s.lower()
if (s == "true"): return True
elif (s == "false"): return False
else: raise ValueError, s

types = (int, float, complex, _bool, str)

def type_convert(s):
for type in types:
try:
return type(s)
except ValueError:
pass
raise ValueError, s

This whole thing isn't quite as sophisticated as R's table.convert; R 
reads the whole table in, then tries to find a type for each column which 
will fit all the values in that column, whereas i do each cell 
individually. Again, it wouldn't be too hard to do this the other way 
round.


Anyway, hope this helps. Bear in mind that there are python bindings for 
the R engine, so you could just use R's version of read.table in python.


tom

--
Don't trust the laws of men. Trust the laws of mathematics.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How am I doing?

2005-09-20 Thread Tom Anderson
On Mon, 19 Sep 2005, Brett Hoerner wrote:

> Wouldn't the standard idiom be to actually put the code under the 
> if-name, and not make a whole new main() function?

Yes.

The nice thing about the main() function, though, is that you can do the 
most basic argument parsing in the if-block. Like so:

def powers(n):
m = 1
while True:
yield m
m = m * n

def main(n, limit):
for power in powers(n):
if (power > limit): break
print power

import sys

if (__name__ == "__main__"):
main(int(sys.argv[1]), int(sys.argv[2]))

That serves as a sort of documentation on the arguments to the script, and 
also makes it easier for other scripts to reuse the main logic of the 
program, since they don't have to package parameters up as a string array. 
It is more verbose, though.

> I'm not sure I see the reason behind main(), couldn't that also 
> interfere with other modules since main() seems like it might be common, 
> not sure how it would work as I'm pretty new to Python myself.

The two mains would be in different namespaces, so they wouldn't conflict.

> from script import *

Don't do that. 'from script import x' is, IMNERHO, bad practice, and 'from 
script import *' is exceptionally bad practice. I know a lot of people do, 
but that doesn't make it right; namespaces are there for a reason.

tom

-- 
Science runs with us, making us Gods.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functional or object-oriented?

2005-09-20 Thread Tom Anderson
On Mon, 19 Sep 2005, beza1e1 wrote:

> I see myself shifting more and more over to the functional kind of
> coding. Could be related to the Haskell, we had to learn in CS. Now i
> was wondering, how other people use Python?

I'm a lot like you. I grew up with java, and learned to write classical 
object-oriented code. When i came over to python, i very quickly found 
myself writing more procedural, and in fact functional, code.

I think this is a result of the kind of programs i'm writing. Objects are 
good when you have entities that will live a long and unpredictable life - 
chunks of text in a word processor, for example. If you're writing 
programs with simpler narratives, though, as i often am ("read in this 
data, parse it, transform it like so, shuffle it like this, then write it 
out like this"), a functional approach allows a simpler, cleaner factoring 
of the code.

> With functional i mean my files mostly consist of functions and only 
> rarely i use "class". The library modules seem to be mostly written the 
> object-way on the other hand.

The thing about OO code is that the pieces are self-contained, which makes 
this a good way to write library code. That's not a good explanation, but 
i haven't had any coffee this morning, so that's the best i can do right 
now.

tom

-- 
Science runs with us, making us Gods.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: services on linux

2005-09-20 Thread Martin Franklin
Christoph Haas wrote:
> On Tue, Sep 20, 2005 at 02:57:26AM -0500, pt python wrote:
> 
>>im moving from the windows world to the linux world and i need to make
>>a python script to see if a service is instaled (ex: apache), if it is
>>running or stoped and to start/stop a service like apache or mysql.
>>Theres an API on windows to manage services and i need to know how to
>>do that on linux. Can anyone help me with the module and API to work
>>with services on linux?
> 
> 
> Unless you really want to do that in Python. It's just a matter of "ps"
> and "grep". Simple shell stuff.
> 
> Example: ps ax | grep apache
> 


On RedHat based distro's (fedora in my case)


/sbin/service sshd status


gives me (as a normal user) the status of my ssh server not sure if 
other distro's have this...



> 
>>by the way, im developing a app, maybe multi-plataform, to install and
>>manage several open source packages like apache, mySQL, phpwebadmin,
>>phpnuke, etc... if anyone have nice ideais i apreciate that..
> 
> 
> That's usually the Linux distribution's job to handle the installed
> packages. Some distributions do that better than others
> (Debian). ;) Or what did you mean when you said "install
> and manage"?
> 


yeah you really need to look at the tools you have been given with your 
distro, rpm, deb, etc for the best way.  If it's pure python then the 
distutils package (in the python standard library) may help, also I 
noticed that PyInstaller 1.0 has just been released

http://pyinstaller.hpcf.upr.edu/pyinstaller


and has options to create single file installers for Linux / IRIX and 
Windows...







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


Re: Validating XML parsers

2005-09-20 Thread Dale Strickland-Clark
Robert Kern wrote:

> Dale Strickland-Clark wrote:
>> A few days ago there was a discussion about which XML parser to use with
>> Python.
>> However, the discussion didn't cover validating parsers, at least, not
>> w3.org XML Schemas.
>> 
>> I looked into all the parsers that came up in the discussion but found no
>> mention of w3.org schemas.
> 
> Apparently not all that came up.
> 
> http://codespeak.net/lxml/
> 
That's great. Thanks.
-- 
Dale Strickland-Clark
Riverhall Systems - www.riverhall.co.uk

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


Re: services on linux

2005-09-20 Thread Timothy Smith
Martin Franklin wrote:

>Christoph Haas wrote:
>  
>
>>On Tue, Sep 20, 2005 at 02:57:26AM -0500, pt python wrote:
>>
>>
>>
>>>im moving from the windows world to the linux world and i need to make
>>>a python script to see if a service is instaled (ex: apache), if it is
>>>running or stoped and to start/stop a service like apache or mysql.
>>>Theres an API on windows to manage services and i need to know how to
>>>do that on linux. Can anyone help me with the module and API to work
>>>with services on linux?
>>>  
>>>
>>Unless you really want to do that in Python. It's just a matter of "ps"
>>and "grep". Simple shell stuff.
>>
>>Example: ps ax | grep apache
>>
>>
>>
>
>
>On RedHat based distro's (fedora in my case)
>
>
>/sbin/service sshd status
>
>
>gives me (as a normal user) the status of my ssh server not sure if 
>other distro's have this...
>
>
>
>  
>
>>>by the way, im developing a app, maybe multi-plataform, to install and
>>>manage several open source packages like apache, mySQL, phpwebadmin,
>>>phpnuke, etc... if anyone have nice ideais i apreciate that..
>>>  
>>>
>>That's usually the Linux distribution's job to handle the installed
>>packages. Some distributions do that better than others
>>(Debian). ;) Or what did you mean when you said "install
>>and manage"?
>>
>>
>>
>
>
>yeah you really need to look at the tools you have been given with your 
>distro, rpm, deb, etc for the best way.  If it's pure python then the 
>distutils package (in the python standard library) may help, also I 
>noticed that PyInstaller 1.0 has just been released
>
>  
>
i'd be very careful using a distro specific tool. it's no good if it 
only works on redhat.

>http://pyinstaller.hpcf.upr.edu/pyinstaller
>
>
>and has options to create single file installers for Linux / IRIX and 
>Windows...
>
>
>
>
>
>
>
>  
>

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


Question about smtplib, and mail servers in general.

2005-09-20 Thread Chris Dewin
Hi. I've been thinking about using smtplib to run a mailing list from my 
website.

s = smtplib.SMTP("server")
s.sendmail(fromaddress, toaddresess, msg)

I know that in this instance, the toaddresses variable can be a variable
of type list.

Suppose the list contains well over 100 emails. Would that create some
sort of drain on the mail server? Would I be better off doing it in some
other way? 

-- 
www.wintergreen.in

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


zlib written in python

2005-09-20 Thread Andreas Lobinger
Aloha,

is a pure _python_ implementation of the zlib available?
I have broken zlib streams and need to patch the deocder to
get them back.

Wishing a happy day
LOBI

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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Tim Williams (gmail)
On 20/09/05, Chris Dewin <[EMAIL PROTECTED]> wrote:
> 
> s = smtplib.SMTP("server")
> s.sendmail(fromaddress, toaddresess, msg)
> 
> I know that in this instance, the toaddresses variable can be a variable
> of type list.
> 
> Suppose the list contains well over 100 emails. Would that create some
> sort of drain on the mail server? Would I be better off doing it in some
> other way?

 
> Suppose the list contains well over 100 emails

You mean the list of recipients (toaddresses) ?  

The 2 lines of example code send a *single* email to "server" with
len(toaddresses) recipients.  The server will then split the email
into smaller (or individual) email groups to send (depending on the
server in use and the mechanisms it uses to relay  the email)

You could send a single email for each recipient to "server"

> s = smtplib.SMTP("server")
>for addr in toaddresses:
>  s.sendmail(fromaddress,[addr], msg)
# in later revisions, [addr] can be a list,  or a string of one address

but that would create much more load on your machine AND server

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


print there!

2005-09-20 Thread Godwin Burby
Dear Pythoneer,
 I am writing a python script which inserts or updates a database
from a csv file. i've done the functionality. But i would to like to
show the user the current row being inserted or updated in the screen.
This can be done as follows:
print 'c:\godwin\bl.csv',
for i,row in enumerate(reader):
# inserts or updates the database
print i,
This displays on the screen as :
c:\godwin\bl.csv 1 2 3 4 5 6 7 8
 ^
But i want it to show the above numbers on the same spot denoted by the
carat character. Can it be done with print statement or any other trick?

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


Exception raised in wrong thread?

2005-09-20 Thread Krzysztof Nowak
Hello all python experts.

I have problem and I ask you for help. Probably there is some quite
easy solution, but I can't see it.

I'm trying to perform some action that have to be timeout safe. So
here is the structure of my program:

\\\
def TimeoutHandler():
  print '!'
  raise Exception

class Active:
  def Action:
  timer = Timer(1, TimeoutHandler)
  print '1'
  timer.start()
  try:
  print '2'
  time.sleep(20)
  print '3'
  except:
  print '4'
  else:
  print '5'
  timer.cancel()
  print '6'

active = Active()
active.Action()

///
The output is:
12!356

My question is, why exception is not raised correctly? Could be the
reason that (probably) timer is another thread and there is no
exception in the main thread? How to solve this problem? [My timeout
should be smaller than one second so I can't use signal.alarm()]

Thanks for your reply,
Krzysztof Nowak
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print there!

2005-09-20 Thread Fredrik Lundh
Godwin Burby wrote:

> print 'c:\godwin\bl.csv',
> for i,row in enumerate(reader):
># inserts or updates the database
>print i,
> This displays on the screen as :
> c:\godwin\bl.csv 1 2 3 4 5 6 7 8
> ^
> But i want it to show the above numbers on the same spot denoted by the
> carat character. Can it be done with print statement or any other trick?

carriage return is your friend:

filename = 'c:\\godwin\\bl.csv',
for i,row in enumerate(reader):
# inserts or updates the database
print "\r" + filename, i,
print

 



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


Re: How to write this iterator?

2005-09-20 Thread Jordan Rastrick
I've written this kind of iterator before, using collections.deque,
which personally I find a little more elegant than the list based
approach:

from collections import deque

def interleave(*iterables):
iters = deque(iter(iterable) for iterable in iterables)
while iters:
it = iters.popleft()
try:
yield it.next()
except StopIteration:
continue
iters.append(it)

>>> for item in interleave(xrange(6), "abc", ["gamma", "delta"]): print item

0
a
gamma
1
b
delta
2
c
3
4
5

I too came across the need for it while dealing with infinite
generators, where itertools.chain obviously won't suffice.

If you extended this approach to the class based solution it would have
the advantage of making append() an 0(1) operation, which is nice.


[EMAIL PROTECTED] wrote:
> >> Sorry, my description was not very good, I meant something behaving as:
> >>
> >> >>>example=Liter("abc","12345","XY")
> >> >>>for x in example: print x,
> >>
> >> a 1 X b 2 Y c 3 4 5
> >>
> >> or for that append() method,
> >>
> >> >>>example=Liter("abc", "12345")
> >> >>>for i in range(3): print example.next(),
> >>
> >> a 1 b
> >>
> >> >>>example.append("XY")
> >> >>>for x in example: print x,
> >>
> >> 2 c X 3 Y 4 5
>
> >Check the module I posted on
> >http://rafb.net/paste/results/CRT7bS68.html. append() makes things more
> >complicated -- mainly because generators don't accept attributes, so it
> >has to be wrapped in a class -- but the simple generator (without
> >append) is more manageable
>
> Thank you very much for your solution. Actually I needed that append()
> method quite a lot, so maybe my solution (posted at the beginning of this
> thread) was not that stupid :) (to inflate my ego a bit)
>
> Anyway, this is roughly what I used it for; is it a sane use of iterators?
>
> I was looking for the Holy Grail. I had an iterator 'quest' that produced
> either junk that was to be thrown away, or the Holy Grail itself, or
> another iterator of the same kind (that had to be searched for the Holy
> Grail as well). The iterators were potentially infinite. The code was
> rougly:
>
> quest=Liter(quest)
> for x in quest:
> if is_Holy_Grail(x):
> share_and_enjoy(x)
> break
> elif is_another_iterator(x):
> quest.append(x) 
> 
> 
> Best regards
> P.

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


Re: Help! Python either hangs or core dumps when calling C malloc

2005-09-20 Thread Frithiof Andreas Jensen

"Lil" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I already double checked my C code. It runs perfectly fine in C without
> any errors.

Errr - It runs perfectly fine without *announcing* any errors (while
gleefully urinating all over its memory space).

The programming model for "C" is "*you* asked for it, you got it mate!" - so
you have to "tell" the program how to debug memory by rebuilding it with
f.ex. Electric Fence, or whatever memory debug lib is preferred for your
box, and running that again.

The tools will spot mistakes faster and more reliable than the developer who
wrote the code. Use them.

> So in my python program, I added a pdb.set_trace()
> and step through the program and it did not dump. But when i took out
> the tracing, the core dump came back. "sigh"

So??

You re-jiggled the bits, so something important got thrashed this time.

Run the C program trough with gdb and see what it does. It thrashes
something.


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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Daniel Dittmar
Chris Dewin wrote:
> Hi. I've been thinking about using smtplib to run a mailing list from my 
> website.
> 
> s = smtplib.SMTP("server")
> s.sendmail(fromaddress, toaddresess, msg)
> 
> I know that in this instance, the toaddresses variable can be a variable
> of type list.
> 
> Suppose the list contains well over 100 emails. Would that create some
> sort of drain on the mail server? Would I be better off doing it in some
> other way? 
> 

Not really an answer to your question, but it's probably considered bad 
style to publish the email addresses of the recipients via the address 
list. Use a neutral To-address (best: the mailing list address) and add 
the recipients via bcc: headers.

You might also want to look at mailman 
http://www.gnu.org/software/mailman/, which is a complete mailing list 
solution written in Python.

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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Tim Williams (gmail)
On 20/09/05, Daniel Dittmar <[EMAIL PROTECTED]> wrote:
> Chris Dewin wrote:
> > Hi. I've been thinking about using smtplib to run a mailing list from my 
> > website.
> >
> > s = smtplib.SMTP("server")
> > s.sendmail(fromaddress, toaddresess, msg)

> >
> 
> Not really an answer to your question, but it's probably considered bad
> style to publish the email addresses of the recipients via the address
> list. Use a neutral To-address (best: the mailing list address) and add
> the recipients via bcc: headers.
> 

For clarity

The toaddreses don't show in the email,  they are the envelope TO:
addreses.   The addresses in the email's TO: Headers are shown to the
recipient and these are the ones that should be "disguised" as best
practice for mailing lists.

The email module's replace_header('to', 'new-text) will do the job for you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help! Python either hangs or core dumps when calling C malloc

2005-09-20 Thread Frithiof Andreas Jensen

"Christian Stapfer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> Check your program for _uninitialized_variables_.

good point.

> (Just a guess: but what other side-effect than
> changing the values of uninitialized variables
> - and the program's timing, of course - might
> the stepping through with a debugger have?)

that, f.ex. with some debuggers, all application memory is conveniently
zeroed so you might survive popping NOP's off the stack until you eventually
hit a valid return ...

I once traced through an embedded assembly program - that had been working
for years - with a logic analyser to re-create the source from the old flow
charts and the hundreds of patches that had been applied to the thing during
"comissioning", i.e. On Site Development.

I found that the "correct" program would somtimes get hit by an unitialised
interupt, the CPU would land between two instructions and start executing
garbage until it chrashed over something else and magically re-synchronised.
Fine stuff.

The reassembled program executed 40% faster without all the jump-to-patch
stuff so I had to re-adjust all the timers too.


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


Release of Shed Skin 0.0.2: Easy Windows/OSX Installation

2005-09-20 Thread Mark Dufour
Hi!

Shed Skin 0.0.2 is up on SourceForge. It should install easily under
Windows 2000/XP and OSX. Please give it a try and let me know if there
are still some problems.

If you would like to help me improve Shed Skin, please send me small
code snippets, preferrably extracted from real-life use cases, that
the compiler has problems with.

Thanks to everyone who has helped me out, especially Khalid, Leonardo
and Luis here on python-list, and Denis de Leeuw Duarte right here in
the street :-)

http://shedskin.sourceforge.net
http://shed-skin.blogspot.com



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


Re: How am I doing?

2005-09-20 Thread Jason
Tom Anderson wrote:
> On Mon, 19 Sep 2005, Brett Hoerner wrote:
> 
>> Wouldn't the standard idiom be to actually put the code under the 
>> if-name, and not make a whole new main() function?
> 
> Yes.
> 
> The nice thing about the main() function, though, is that you can do the 
> most basic argument parsing in the if-block. Like so:
> 
> def powers(n):
>   m = 1
>   while True:
>   yield m
>   m = m * n
> 
> def main(n, limit):
>   for power in powers(n):
>   if (power > limit): break
>   print power
> 
> import sys
> 
> if (__name__ == "__main__"):
>   main(int(sys.argv[1]), int(sys.argv[2]))
> 
> That serves as a sort of documentation on the arguments to the script, and 
> also makes it easier for other scripts to reuse the main logic of the 
> program, since they don't have to package parameters up as a string array. 
> It is more verbose, though.
> 
>> I'm not sure I see the reason behind main(), couldn't that also 
>> interfere with other modules since main() seems like it might be common, 
>> not sure how it would work as I'm pretty new to Python myself.
> 
> The two mains would be in different namespaces, so they wouldn't conflict.
> 
>> from script import *
> 
> Don't do that. 'from script import x' is, IMNERHO, bad practice, and 'from 
> script import *' is exceptionally bad practice. I know a lot of people do, 
> but that doesn't make it right; namespaces are there for a reason.
> 
> tom
> 

I haven't a clue what all this means, but it looks important ! lol

Thanks for the headsup, will take note of what you've said.

Incidentally, at work my main programming platform is VisualStudio .Net, 
and I never import the children of namespaces so hopefully this practice 
I have will be carried over to Python.

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


Release of Shed Skin 0.0.2: Easy Windows/OSX Installation

2005-09-20 Thread Mark Dufour
Hi!

Shed Skin is an experimental Python-to-C++ compiler. Along with
GNU/Linux, version 0.0.2 should now also install easily under Windows
2000/XP and OSX. Please give it a try and let me know if there are
still some problems.

If you would like to help me improve Shed Skin, please send me small
code snippets, preferrably extracted from real-life use cases, that
the compiler has problems with.

Thanks to everyone who has helped me out, especially Khalid, Leonardo
and Luis here on python-list, and Denis de Leeuw Duarte right here in
the street :-)

http://shedskin.sourceforge.net
http://shed-skin.blogspot.com



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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Peter Hansen
Daniel Dittmar wrote:
> Chris Dewin wrote:
> 
>> Hi. I've been thinking about using smtplib to run a mailing list from 
>> my website.
>>
>> s = smtplib.SMTP("server")
>> s.sendmail(fromaddress, toaddresess, msg)
>>
>> I know that in this instance, the toaddresses variable can be a variable
>> of type list.
>>
>> Suppose the list contains well over 100 emails. Would that create some
>> sort of drain on the mail server? Would I be better off doing it in some
>> other way?
> 
> Not really an answer to your question, but it's probably considered bad 
> style to publish the email addresses of the recipients via the address 
> list. Use a neutral To-address (best: the mailing list address) and add 
> the recipients via bcc: headers.

Not only not an answer, but also not a valid point in this case.  The 
list of recipients used in the sendmail() call (which become RCPT TO: 
commands in SMTP) do *not* show up in the received emails.  Only those 
items explicitly listed in the headers, such as the To: header, will 
appear.  In fact, you could easily make a Bcc: header which actually 
lists everyone and it would probably not even be stripped by most mail 
programs (though I haven't tried that).  Your confusion is caused by not 
distinguishing between mail client programs and a lower level utility 
such as smtplib, which doesn't even look at the To: addresses in the header.

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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Peter Hansen
Chris Dewin wrote:
> Hi. I've been thinking about using smtplib to run a mailing list from my 
> website.
> 
> s = smtplib.SMTP("server")
> s.sendmail(fromaddress, toaddresess, msg)
> 
> I know that in this instance, the toaddresses variable can be a variable
> of type list.
> 
> Suppose the list contains well over 100 emails. Would that create some
> sort of drain on the mail server? Would I be better off doing it in some
> other way? 

Definitely consider a proper mailing list program like Mailman, as 
Daniel suggested.

In any case, unless the mail server will allow "relaying", which most 
don't these days (to prevent spamming), then it won't work the way you 
are hoping unless *all* the 100 addresses are local ones, to be 
delivered to users on the server you are sending the mail to.

If the addresses are scattered all over the planet, and the server 
allows relaying, then it's intended for exactly this sort of use (other 
than if it's spam ;-) ), and no, you won't be putting a "drain" on the 
server.

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


Re: multithread exception handling

2005-09-20 Thread Piet van Oostrum
> [EMAIL PROTECTED] (p) wrote:

[Timer example snipped]
>p> My question is, why exception is not raised correctly? Could be the
>p> reason that (probably) timer is another thread and there is no
>p> exception in the main thread? 

yes, the doc of Timer says it is a subclass of Thread, and therefore runs in
a new thread.
By the way, your program isn't even correct Python, so how can it give the
output you have written down?

When I run a similar (but corrct python) program, I do get an exception,
but it is in another thread, and therefore not caught.
You can post a signal to the main thread, however, to catch the exception:

def TimeoutHandler():
print '!'
os.kill(0, signal.SIGUSR1)

def handler():
raise Exception

class Active:
def __init__(self):
signal.signal(signal.SIGUSR1, handler)
timer = Timer(1, TimeoutHandler)
etc.
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception raised in wrong thread?

2005-09-20 Thread Piet van Oostrum
Please don't post the same question twice with different subjects.
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Doc Problem Example: os.path.split

2005-09-20 Thread Diez B. Roggisch

> I think this is unfair. The use of "slash" is a failing of the current
> documentation. If his use is an indication of a nano-tube-narrow
> mindset then so would be the use by the actual documentation writers.


You're right - I missed that somehow, as the original docs talk about
components - which made me assume that these are independently defined
from the slash.

But I stand by the nano-tube-narrow mind-set of Xah Lee. Besides his
tourette syndrome he also is simply unwilling to read documentation if
it is not what _he_ expects it to be.

Diez

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


QCheckListItem signal question

2005-09-20 Thread Artur M. Piwko
Is there a way to distinguish if QCheckListItem was checked/unchecked
or clicked?

-- 
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:213B ]
[ 15:36:46 user up 10740 days,  3:31,  1 user, load average: 0.06, 0.06, 0.06 ]

   Grain grows best in shit.
-- 
http://mail.python.org/mailman/listinfo/python-list


Replacing an XML element?

2005-09-20 Thread Nick Vargish
I've been trying to figure out how to do something that seems
relatively simple, but it's just not coming together for me. I'm
hoping someone will deign to give me a little insight here.

The problem: We have XML documents that use a custom table format that
was designed primarily for typesetting documents. It's a column-first
oriented scheme, and now we need a way to convert these table elements
to HTML style row-first tables.

I would like to be able to do something like this:

doc = xml.dom.minidom.parse(input)
for table in doc.getElementsByTagName('COLTABLE'):
newtable = coltable_to_rowtable(table)
## this is what I can't figure out
doc.replace(table, newtable)
output.write(doc.toxml('utf-8'))

I'm pretty sure I'm missing something obvious, but haven't been able
to find any examples. 

Someone please whack me with a cluestick,

Nick

-- 
#include/* sigmask (sig.c) 20041028 PUBLIC DOMAIN */
int main(c,v)char *v;{return !c?putchar(*   /* cc -o sig sig.c */
v-1)&&main(0,v+1):main(0,"Ojdl!Wbshjti!=ojdlAwbshjti/psh?\v\1");}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Doc Problem Example: os.path.split

2005-09-20 Thread Peter Hansen
Diez B. Roggisch wrote:
>>I think this is unfair. The use of "slash" is a failing of the current
>>documentation. If his use is an indication of a nano-tube-narrow
>>mindset then so would be the use by the actual documentation writers.
> 
> You're right - I missed that somehow, as the original docs talk about
> components - which made me assume that these are independently defined
> from the slash.

That's okay.  We hardly lack for examples of his double standard: note 
his claim that split() returns a (dirname, filename) pair, which is not 
correct in all cases either, making his suggestion no better than the 
stuff he criticizes, at best.

> But I stand by the nano-tube-narrow mind-set of Xah Lee. Besides his
> tourette syndrome he also is simply unwilling to read documentation if
> it is not what _he_ expects it to be.

It's interesting to note that c.l.p still manages to give cordial and 
helpful replies when his posts are not offensive ... in spite of us all 
repeatedly being labelled "fuckers" and worse.

I strongly suspect (and here I manage to get this on-topic, to the shock 
of all) that he learned English from something written (apparently) by 
Monty Python, and mistakenly thought this was how most people speak in 
public (see http://www.sigg3.net/myself/fuck.html for but one copy).

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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Steve Holden
Peter Hansen wrote:
> Chris Dewin wrote:
> 
>>Hi. I've been thinking about using smtplib to run a mailing list from my 
>>website.
>>
>>s = smtplib.SMTP("server")
>>s.sendmail(fromaddress, toaddresess, msg)
>>
>>I know that in this instance, the toaddresses variable can be a variable
>>of type list.
>>
>>Suppose the list contains well over 100 emails. Would that create some
>>sort of drain on the mail server? Would I be better off doing it in some
>>other way? 
> 
> 
> Definitely consider a proper mailing list program like Mailman, as 
> Daniel suggested.
> 
> In any case, unless the mail server will allow "relaying", which most 
> don't these days (to prevent spamming), then it won't work the way you 
> are hoping unless *all* the 100 addresses are local ones, to be 
> delivered to users on the server you are sending the mail to.
> 
> If the addresses are scattered all over the planet, and the server 
> allows relaying, then it's intended for exactly this sort of use (other 
> than if it's spam ;-) ), and no, you won't be putting a "drain" on the 
> server.
> 
> -Peter
To add one final note, if the "fromaddress" belongs to a domain that's 
properly handled by the SMTP server then you aren't relaying (since you 
are a legitimate domain user) so the mails should go through.

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

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


Re: Replacing an XML element?

2005-09-20 Thread Max Erickson
Nick Vargish <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> I've been trying to figure out how to do something that seems
> relatively simple, but it's just not coming together for me. I'm
> hoping someone will deign to give me a little insight here.
> 
> The problem: We have XML documents that use a custom table format
> that was designed primarily for typesetting documents. It's a
> column-first oriented scheme, and now we need a way to convert
> these table elements to HTML style row-first tables.
> 
> I would like to be able to do something like this:
> 
> doc = xml.dom.minidom.parse(input)
> for table in doc.getElementsByTagName('COLTABLE'):
> newtable = coltable_to_rowtable(table)
> ## this is what I can't figure out
> doc.replace(table, newtable)
> output.write(doc.toxml('utf-8'))
> 
> I'm pretty sure I'm missing something obvious, but haven't been
> able to find any examples. 
> 
> Someone please whack me with a cluestick,
> 
> Nick
> 

table.parentNode.replaceChild(newtable, table)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Organising a python project

2005-09-20 Thread Scott David Daniels
bruno modulix wrote:
> [EMAIL PROTECTED] wrote:
> 
>>What is the best or typical directory structure that
>>allows the easy creation of binary packages

somedir:
 test/
 test_product.py# Really do include tests
 product.py
 setup.py

Look at distutils documentation.  Also read up on "Python Eggs."

You might consider doing it as a package under a you-specific name:

somedir:
 yourname:
 test/
 test_product.py# See unittest module
 __init__.py # can be empty (and often is), also might have a
 # doc string, author, copyright, and license info
 # and a line like: __version__ = "0.2"
 product.py
 setup.py

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: zlib written in python

2005-09-20 Thread Scott David Daniels
Andreas Lobinger wrote:
> Aloha,
> 
> is a pure _python_ implementation of the zlib available?
> I have broken zlib streams and need to patch the deocder to
> get them back.
> 
> Wishing a happy day
> LOBI
> 
Check your zlib version: import zlib; print zlib.ZLIB_VERSION
There were some fixes you can see described at 'http://www.zlib.net/'
that are going into python 2.5.  If you can figure it out yourself,
you could build an alternative zlib module to either sit beside
/DLLs/zlib.pyd  or  replace it.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


win32 service and time.sleep()

2005-09-20 Thread rbt
I have a win32 service written in Python. It works well. It sends a
report of the status of the machine via email periodically. The one
problem I have is this... while trying to send an email, the script
loops until a send happens and then it breaks. Should it be unable to
send, it sleeps for 10 minutes with time.sleep(600) and then wakes and
tries again. This is when the problem occurs. I can't stop the service
while the program is sleeping. When I try, it just hangs until a reboot.
Can some suggest how to fix this?

Thanks,
rbt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: are variables local only to try/except blocks?

2005-09-20 Thread Dan
> try:
>try:
>   doSomething1
>   excp = 0
>except:
>   excp = 1
>#endTry

Note that you can use "else" after "except" for precisely this purpose:

try:
   foo()
except:
   print 'Exception raised'
else:
   print 'No exception raised'

-- 
   Optimism is the faith that leads to achievement; nothing can be
   done without hope.
- Helen Keller


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


win32 service and time.sleep()

2005-09-20 Thread rbt
I have a win32 service written in Python. It works well. It sends a
report of the status of the machine via email periodically. The one
problem I have is this... while trying to send an email, the script
loops until a send happens and then it breaks. Should it be unable to
send, it sleeps for 10 minutes with time.sleep(600) and then wakes and
tries again. This is when the problem occurs. I can't stop the service
while the program is sleeping. When I try, it just hangs until a reboot.
Can some suggest how to fix this?

Thanks,
rbt

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


Re: python script under windows

2005-09-20 Thread cg
I ran into a similar issue a couple of months back, the solution on
Windows is to run it as a service. It is very simple, you need Mark
Hammond's Win32 extensions. For path you have to use absolute filepath
for all local files and for network drive use the UNC path i.e.
\\servername\folder-filename\ . All these steps will let your machine
running the program survive logouts after a login. If your machine is
part of windows network and there is domain login then in order for it
to work after a machine restart you need to goto the Service panel (in
Control Panel) find the Python service you registered, right-click and
goto its properties, goto the "Log On" panel, select a domain user for
"This account" by clicking the Browse button, note the selected user
has access to windows domain and admin access to that particular
machine. Enter user network password, hit Apply, OK and there u go. All
this requires admin access to machine. You can configure a couple of
things about the service in the Services panel.

The code itself is simple:
#--
import win32service, win32serviceutil

class MyService(win32serviceutil.ServiceFramework):
"""NT Service."""

_svc_name_ = "MyServiceName"
_svc_display_name_ = "A Little More Descriptive"

def SvcDoRun(self):
#do your stuff here, call your main application code.

def SvcStop(self):
#the following line is not really needed, basically put here
any code that should execute
#before the service stops
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

if __name__ == '__main__':
win32serviceutil.HandleCommandLine(MyService)
#--
After this if you have python in your path and Win32 extensions
installed, goto command prompt and run:
c:\> MyService.py -startup=auto install

Trying to have your service have Network access after a machine restart
is a bit tricky. This thing works but somehow I feel there is more to
it. If anyone has a better way, please post.

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


Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Piet van Oostrum
> Steve Holden <[EMAIL PROTECTED]> (SH) wrote:

>SH> To add one final note, if the "fromaddress" belongs to a domain that's
>SH> properly handled by the SMTP server then you aren't relaying (since you are
>SH> a legitimate domain user) so the mails should go through.

And most smtp servers that I know also pass mail from any from-address to
any to-address if the IP number of he client machine belongs to a trusted
range (usually the range that belongs to the ISP). So I can send both my
private mail and my work mail from both my home ISP's smtp server and my
work's smtp server (but only if I am at the proper location).
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: QCheckListItem signal question

2005-09-20 Thread David Boddie
You could connect the currentChanged() or clicked() signals in your
QListView to a slot in some other object (perhaps the parent of the
QListView). When the signal is emitted, you can examine the state of
the item passed to the slot.

Hope this helps,

David

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


Re: Replacing an XML element?

2005-09-20 Thread Nick Vargish
Max Erickson <[EMAIL PROTECTED]> writes:

> table.parentNode.replaceChild(newtable, table)

I knew it had to be something simple (but not as simple as I am,
apparently :^).

Thanks much, Max, you've saved the rest of my day.

Nick

-- 
#include/* sigmask (sig.c) 20041028 PUBLIC DOMAIN */
int main(c,v)char *v;{return !c?putchar(*   /* cc -o sig sig.c */
v-1)&&main(0,v+1):main(0,"Ojdl!Wbshjti!=ojdlAwbshjti/psh?\v\1");}
-- 
http://mail.python.org/mailman/listinfo/python-list


vendor-packages directory

2005-09-20 Thread Rich Burridge

Hi,

I work in the Accessibility Program Office at Sun Microsystems. I'm
part of a team that is using Python to create a screen reader called
Orca, that'll help blind people (and people with low vision) have
access to the GNOME desktop for Solaris and Linux.

See:

   http://cvs.gnome.org/viewcvs/*checkout*/orca/docs/doc-set/orca.html

for more details.

Orca in turn uses several packages that interface between Python and the
various "native" libraries in the GNOME desktop:

   * pyorbit   - Python bindings for ORBit2
   * pygtk - GTK+ Python bindings
   * gnome-python  - Python bindings for various GNOME libraries

We will be presenting our project in front of one of the archirectural
review committees within Sun soon, in order to try to get this software
in a future release of the Solaris operating system. It's Open Sources,
so other Linux vendors will also be able to pick it up (if they so desire),
to include with their software distributions.

We've been given a heads-up on the following problem.

Until now we've been using "/usr/lib/python2.4/site-packages" as the
directory to install the various Python files that these packages use.

We have been told that this directory is inappropriate for vendor supplied
packages, just as "site_perl" is inappropriate for Perl. With Perl, vendor
supplied packages go under "vendor_perl". Unfortunately there isn't such an
equivalent for Python.

But it does seem appropriate that there should be.

Now we could easily create a "/usr/lib/python2.4/vendor-packages"
directory and put out files under there, but what I don't like about it
is that it doesn't "just work". In other words, it's not one of the known
places that Python will look for library or application Python files.
I don't think it's reasonable to make developers who wants to use
"standard" GNOME Python files, to have to set PYTHONPATH and make sure
that "/usr/lib/python2.4/vendor-packages" is on it.

What I'd like to see is a future release of Python automatically checking
for this directory and appending it to the list of directories that it'll
search.

Here's a patch to do this:

--- Python-2.4.1/Lib/site.pyMon Sep 19 12:37:00 PDT 2005
+++ Python-2.4.1-new/Lib/site.pyMon Sep 19 12:37:00 PDT 2005
@@ -182,7 +182,11 @@
   "lib",
   "python" + sys.version[:3],
   "site-packages"),
-os.path.join(prefix, "lib", "site-python")]
+os.path.join(prefix, "lib", "site-python"),
+os.path.join(prefix,
+ "lib",
+ "python" + sys.version[:3],
+ "vendor-packages")]
  else:
  sitedirs = [prefix, os.path.join(prefix, "lib", 
"site-packages")]
  if sys.platform == 'darwin':

Is this something that would be considered for a future Python release?

Thanks.

--

Rich Burridge   Email: [EMAIL PROTECTED]
Sun Microsystems Inc. (MPK14-260),  Phone: +1.650.786.5188
4150 Network Circle,AIM/YAHOO: RicBurridge
Santa Clara, CA 95054   Blog:  http://blogs.sun.com/richb

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


Re: win32 service and time.sleep()

2005-09-20 Thread Oracle
On Tue, 20 Sep 2005 10:49:13 -0400, rbt wrote:

> I have a win32 service written in Python. It works well. It sends a
> report of the status of the machine via email periodically. The one
> problem I have is this... while trying to send an email, the script
> loops until a send happens and then it breaks. Should it be unable to
> send, it sleeps for 10 minutes with time.sleep(600) and then wakes and
> tries again. This is when the problem occurs. I can't stop the service
> while the program is sleeping. When I try, it just hangs until a reboot.
> Can some suggest how to fix this?
> 

You could try doing it the hard way.  In a loop, sleep for 1-5 seconds at
a time.  Everytime you complete a sleep, check the elapsed time.  If the
elapsed time is >= the total sleep duration, fall out of the sleep loop
and try your email again.  This should allow your service to stop within
1-5 seconds of your request while imposing little to no load on the system.



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


Re: Python Doc Problem Example: os.path.split

2005-09-20 Thread Steve Holden
Peter Hansen wrote:
> Diez B. Roggisch wrote:
[...]
>>But I stand by the nano-tube-narrow mind-set of Xah Lee. Besides his
>>tourette syndrome he also is simply unwilling to read documentation if
>>it is not what _he_ expects it to be.
> 
> 
> It's interesting to note that c.l.p still manages to give cordial and 
> helpful replies when his posts are not offensive ... in spite of us all 
> repeatedly being labelled "fuckers" and worse.
> 
That's the friendly fuckers on c.l.py for you ...

> I strongly suspect (and here I manage to get this on-topic, to the shock 
> of all) that he learned English from something written (apparently) by 
> Monty Python, and mistakenly thought this was how most people speak in 
> public (see http://www.sigg3.net/myself/fuck.html for but one copy).
> 
While this surmise does bring us close to being on-topic I fear you are 
being far more charitable than is justified here. But I *am* getting a 
bit fucking tired of his rather limited style of discourse.

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

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


Re: Two questions on PyDev for Eclipse

2005-09-20 Thread Fabio Zadrozny
Hi,

for 2: as far as I know, eclipse must have 'local', or at least 
'emulated' local access, so, if you have samba access, it should do what 
you want.

for 1... I use it a LOT without any problems for some really big 
projects ( with about 2.000 python modules -- not counting the python 
installation) -- but as I also develop it, so, I may be kind of 
impartial ;-)

Cheers,

Fabio

Kenneth McDonald wrote:

>The first is general; what are users' experience with PyDev for  
>Eclipse. It looks pretty good to me right now, but I've only started  
>playing with it. Converting to Eclipse is a major effort, and if  
>there are problems which would prevent pydev from being useful right  
>now, I'd certainly appreciate knowing about them.
>
>The second question is specific; is it possible to use Eclipse to  
>edit a remote file, i.e. through SFTP or something equivalent? My  
>current (limited) understanding of Eclipse is that it maintains an on- 
>disk directory of files in a project. Unfortunately, for what I'm  
>doing, a fair number of the files (mostly Python files) I'm editing  
>are on a remote server, so whatever editor I use, the ability to edit  
>remote files would be a big help.
>
>Thanks,
>Ken
>  
>


-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com


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


Alternatives to Stackless Python?

2005-09-20 Thread [EMAIL PROTECTED]
After recently getting excited about the possibilities that stackless
python has to offer
(http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/)
and then discovering that the most recent version of stackless
available on stackless.com was for python 2.2 I am wondering if
Stackless is dead/declining and if so, are there any viable
alternatives that exist today?

I found LGT http://lgt.berlios.de/ but it didn't seem as if the
NanoThreads module had the same capabilites as stackless.

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


Dr. Dobb's Python-URL! - weekly Python news and links (Sep 19)

2005-09-20 Thread Diez B. Roggisch
QOTW:  "Python makes data-driven programming easy :-)" -- Kent

"Python rewards abstraction." -- Alex Martelli


As unicode becomes more and more prevalent, the issue of regular
expressions matching unicode character sets occurs more often. A
current thread has advice:
http://groups.google.com/group/comp.lang.python/msg/a4b7d3e24a514afd

Todd Steury learns about large float representations in python - and
that applying some algebra sometimes yields better results than the
naive approach:
http://groups.google.com/group/comp.lang.python/msg/7f5afb4976277ddc

pyparsing, the de-facto-standard for parser generation in python, is
available at version 1.3.3: 

http://groups.google.com/group/comp.lang.python.announce/msg/ff39b02ac712ac79

A new PyRex version addressing bugs ships:

http://groups.google.com/group/comp.lang.python.announce/msg/b30bd0575b6bd080

Metaclasses are so complicated as to make some of their artifacts
appear buggy - but luckily they aren't ...
http://groups.google.com/group/comp.lang.python/msg/a1190851125ce7b5

.NET 3.0 features provoke a discussion on python's nested-tuple
function arguments:
http://groups.google.com/group/comp.lang.python/msg/ee80ba95b76d76b

Stackless receives popular publicity for its gaming ability:

http://developers.slashdot.org/developers/05/09/17/182207.shtml?tid=156&tid=10
Note how dramatically memory-management perspectives can differ:
http://developers.slashdot.org/comments.pl?sid=162565&cid=13587741

Sudoku puzzles are fun to solve -- both "in real", and by writing
software solvers. Python-based solvers on different levels of
complexity can be seen here:
http://groups.google.com/group/comp.lang.python/msg/f7cb534119b877b9

Accessing COM-components from python is usually done with
win32com -- but in certain corner cases, comtypes serves you better
(or at all):
http://groups.google.com/group/comp.lang.python/msg/e4075543c2d30200

Creating histograms is a common problem -- another problem is which one
is the preferred way to do so:

http://groups.google.com/group/comp.lang.python/browse_frm/thread/60d405c5282ad36a/faa050cc5d76f6f0?q=dictionary&rnum=2#faa050cc5d76f6f0



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://w

Re: win32 service and time.sleep()

2005-09-20 Thread Laszlo Zsolt Nagy
rbt wrote:

>I have a win32 service written in Python. It works well. It sends a
>report of the status of the machine via email periodically. The one
>problem I have is this... while trying to send an email, the script
>loops until a send happens and then it breaks. Should it be unable to
>send, it sleeps for 10 minutes with time.sleep(600) and then wakes and
>tries again. This is when the problem occurs. I can't stop the service
>while the program is sleeping. When I try, it just hangs until a reboot.
>Can some suggest how to fix this?
>  
>
Yes. Generally, most of the win32 services work like this:

- the main thread listens to win32 service commands
- when starting the service, you should create a new worker thread that 
does the job for you
- when stopping the service, your service should report 
win32service.SERVICE_STOP_PENDING immediately, and ask the worker thread 
to terminate
- you should be continuously reporting win32service.SERVICE_STOP_PENDING 
until your workder thread has stopped

Here is a simple module that uses a 'Processor' class and a new thread 
to do the work.
(The full program is here: http://mess.hu/download/SimpleHTTPService.zip )

class Service(win32serviceutil.ServiceFramework):
_svc_name_ = SERVICE_NAME
_svc_display_name_ = SERVICE_DISPLAY
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.stopped = threading.Event()
self.stopped.clear()
self.logger = getLogger(SERVICE_NAME)

def SvcStop(self):
self.logger.info("Got SvcStop, trying to stop service...")
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.stopped.set()

def SvcDoRun(self):
"""Write an event log record - in debug mode we will also see 
this message printed."""
try:
import servicemanager
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, '')
)
self.logger.info("Started.")
self.logger.debug("Creating processor instance")
processor = Processor(self.stopped)
self.logger.debug("Starting processor thread")
thread.start_new_thread(processor.Process,())
self.logger.debug("Waiting for the processor thread to finish")
self.stopped.wait()
self.logger.debug("Stopping")
time.sleep(1)
while not processor.stopped.isSet():

self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING, 5000)
time.sleep(5)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, "")
)
self.logger.info("Stopped")
except:
self.logger.error('',exc_info = sys.exc_info())


if __name__=='__main__':
win32serviceutil.HandleCommandLine(Service)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: are variables local only to try/except blocks?

2005-09-20 Thread Steve Holden
BarrySearle wrote:
>  # Is this valid (or is excp local to try/except)?
>  try:
> try:
>doSomething1
>excp = 0

This block is problematic because excp won;t be set if doSomething1 
raises an exception.

> except:
>excp = 1
> #endTry
> if (_excp_): doSomething1 # is excp defined here?

Presumably you are expecting doSomething1 to fail or succeed in some 
non-deterministic way? Otherwise this will just raise the same exception 
again!

> excp = 0
>  except:
> excp = 1
> #endTry
> if (excp): doSomething2 # is excp defined here?
> 
> 
>  # valid, but more verbose (and maybe redundant?)
>  excp = 0
>  try:
> excp = 0
> try:
>doSomething1
>excp = 0  # reset incase future inner block
> except:
>excp = 1
> #endTry
> if (_excp_): doSomething1
> excp = 0  # reset incase inner block set excp=1
>  except:
> excp = 1
> #endTry
> if (excp): doSomething2
> 
> I am not so interested in what a particular version of the
> Python/Jython interpreter does, but rather what is "right".
> 
> Pls "CC" replies to [EMAIL PROTECTED] (as well as newsgroup)
> Barry Searle,[EMAIL PROTECTED]
> 
Your approach to exception handling is a little simplistic, resulting on 
code that reads about as well as a plate of spaghetti.

What are you actually trying to *do*? What problem do you need to solve?

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

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


Where is my exception

2005-09-20 Thread Laszlo Zsolt Nagy
I have this code in a wxWidgets program:

class HtmlHintWindow(wx.Frame):
def __init__(self,pos,hint,config):
global _current_hint_window
# Determine the size of the screen
self.screensize = wx.ClientDisplayRect()[2:]
# Calculate the size of the hint ;-)
self.renderer = MegaXMLRenderer()
self.renderer.LoadStyle(config.style)
self.cookie, self.parsed_xml = self.renderer.Parse(hint)
print "point 1"
try:
self.image = self.renderer.Render(
self.cookie,
self.parsed_xml,
(0,0,self.screensize[0],self.screensize[1]),
draw=True
)
finally:
print "point 2"
raise

The program prints out "point 1" but it does not print "point 2". What 
am I missing?

   Les

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


Re: win32 service and time.sleep()

2005-09-20 Thread Steve Holden
rbt wrote:
> I have a win32 service written in Python. It works well. It sends a
> report of the status of the machine via email periodically. The one
> problem I have is this... while trying to send an email, the script
> loops until a send happens and then it breaks. Should it be unable to
> send, it sleeps for 10 minutes with time.sleep(600) and then wakes and
> tries again. This is when the problem occurs. I can't stop the service
> while the program is sleeping. When I try, it just hangs until a reboot.
> Can some suggest how to fix this?

One way would be to maintain a Queue.Queue containing the messages that 
need to be sent and, rather than sleeping to retry just retrying when 
enough time has elapsed. That way you can keep pumping messages and so 
on to your heart's content, though you will have to keep track of the 
messages still to be sent.

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

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


Re: QCheckListItem signal question

2005-09-20 Thread Artur M. Piwko
In the darkest hour on 20 Sep 2005 08:07:47 -0700,
David Boddie <[EMAIL PROTECTED]> screamed:
> You could connect the currentChanged() or clicked() signals in your
> QListView to a slot in some other object (perhaps the parent of the
> QListView). When the signal is emitted, you can examine the state of
> the item passed to the slot.
>

Yes, but those signals don't let me distinguish between item change
and check/uncheck. I found the way - override QCheckListItem method
activate().

-- 
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:212B ]
[ 17:58:41 user up 10740 days,  5:53,  1 user, load average: 0.06, 0.06, 0.06 ]

 My computer NEVER cras
-- 
http://mail.python.org/mailman/listinfo/python-list


testing a website from python

2005-09-20 Thread M.N.A.Smadi
hi;

I just want to test that a given website is up or not from a python 
script.  I thought of using wget as an os command.  Any better ideas?

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


Re: testing a website from python

2005-09-20 Thread Laszlo Zsolt Nagy
M.N.A.Smadi wrote:

>hi;
>
>I just want to test that a given website is up or not from a python 
>script.  I thought of using wget as an os command.  Any better ideas?
>  
>
urllib

http://www.python.org/doc/current/lib/module-urllib.html

If you only want to test if the HTTP port is open or not:

socket

http://docs.python.org/lib/module-socket.html

   Les

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


Crypto.Cipher.ARC4, bust or me doing something wrong?

2005-09-20 Thread Michael Sparks
Hi,


I suspect this is a bug with AMK's Crypto package from
http://www.amk.ca/python/code/crypto , but want to
check to see if I'm being dumb before posting a bug
report.

I'm looking at using this library and to familiarise myself writing
small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
found that I can't get it to decode what it encodes. This might be a
case of PEBKAC, but I'm trying the following:

>>> from Crypto.Cipher import ARC4 as cipher
>>> key = ""
>>> obj = cipher.new(key)
>>> obj.encrypt("This is some random text")
')f\xd4\xf6\xa6Lm\x9a%}\x8a\x95\x8ef\x00\xd6:\x12\x00!\xf3k\xafX'
>>> X=_
>>> X
')f\xd4\xf6\xa6Lm\x9a%}\x8a\x95\x8ef\x00\xd6:\x12\x00!\xf3k\xafX'
>>> obj.decrypt(X)
'\x87\xe1\x83\xc1\x93\xdb\xed\x93U\xe4_\x92}\x9f\xdb\x84Y\xa3\xd4b\x9eHu~'

Clearly this decode doesn't match the encode. Me being dumb or bug?

Any comments welcome :)


Michael.
-- 
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.

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


Re: Crypto.Cipher.ARC4, bust or me doing something wrong?

2005-09-20 Thread Jp Calderone
On Tue, 20 Sep 2005 16:08:19 +0100, Michael Sparks <[EMAIL PROTECTED]> wrote:
>Hi,
>
>
>I suspect this is a bug with AMK's Crypto package from
>http://www.amk.ca/python/code/crypto , but want to
>check to see if I'm being dumb before posting a bug
>report.
>
>I'm looking at using this library and to familiarise myself writing
>small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
>found that I can't get it to decode what it encodes. This might be a
>case of PEBKAC, but I'm trying the following:
>
 from Crypto.Cipher import ARC4 as cipher
 key = ""
 obj = cipher.new(key)
 obj.encrypt("This is some random text")
>')f\xd4\xf6\xa6Lm\x9a%}\x8a\x95\x8ef\x00\xd6:\x12\x00!\xf3k\xafX'
 X=_
 X
>')f\xd4\xf6\xa6Lm\x9a%}\x8a\x95\x8ef\x00\xd6:\x12\x00!\xf3k\xafX'
 obj.decrypt(X)
>'\x87\xe1\x83\xc1\x93\xdb\xed\x93U\xe4_\x92}\x9f\xdb\x84Y\xa3\xd4b\x9eHu~'
>
>Clearly this decode doesn't match the encode. Me being dumb or bug?
>
>Any comments welcome :)
>

You need two ARC4 instances.  Performing any operation alters the internal 
state (as it is a stream cipher), which is why your bytes did not come out 
intact.

  >>> import Crypto.Cipher.ARC4 as ARC4
  >>> o = ARC4.new('hello monkeys')
  >>> p = ARC4.new('hello monkeys')
  >>> p.decrypt(o.encrypt('super secret message of doom'))
  'super secret message of doom'
  >>>

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


Re: Where is my exception

2005-09-20 Thread Laszlo Zsolt Nagy

>The program prints out "point 1" but it does not print "point 2". What 
>am I missing?
>  
>
Sorry from all. I should have been looked at the processor before I 
posted. There is no exception. It was an infinite loop inside the try 
block, but it was called from an event handler. I did not notice that my 
CPU is at 100%. :-(

   Les


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


Re: How to write this iterator?

2005-09-20 Thread George Sakkis
"Jordan Rastrick" <[EMAIL PROTECTED]> wrote:

> I've written this kind of iterator before, using collections.deque,
> which personally I find a little more elegant than the list based
> approach:

Nice, that's *much* more elegant and simple ! Here's the class-based version 
with append; note that
interleave is modified to put back the popped iterator before yield, otherwise 
append doesn't work
properly:

from collections import deque

class Interleave(object):
"""Iterator that cycles over one or more iterables, yielding one item from
each iterable at a time. Once an iterable is exhausted, it is removed from
the cycle. This iterator is exhausted when all participating iterables are
exhausted.

>>> it = Interleave("abc","12345","XY")
>>> list(it)
['a', '1', 'X', 'b', '2', 'Y', 'c', '3', '4', '5']
>>> list(it)
[]
"""

def __init__(self, *iterables):
iters = self.__iters = deque(map(iter, iterables))
def generator():
while iters:
it = iters.popleft()
try:
next = it.next()
except StopIteration:
continue
else:
iters.append(it)
yield next
self.__this_iter = generator()

def append(self,iterable):
"""Adds an iterable to the existing cycle of iterables.

The given iterable is added in front of the current position in the
cycle so that it's called only after all the others.

>>> example = Interleave("abc", "12345")
>>> [example.next() for i in range(3)]
['a', '1', 'b']
>>> example.append("XY")
>>> list(example)
['2', 'c', 'X', '3', 'Y', '4', '5']
"""
self.__iters.append(iter(iterable))

def __iter__(self):
return self

def next(self):
return self.__this_iter.next()


if __name__ == '__main__':
import doctest
doctest.testmod()


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


Getting tired with py2exe

2005-09-20 Thread Thomas Heller
I'm slowly getting tired maintaining py2exe.  It is far from perfect,
although it has interesting features (I would say).

The problem, apart from the work, is that it is good enough for me - I
can do everything that I need with it.  But I assume I use far less
libaries than other Python programmers, so a lot of bugs will never bite
me.

It is also interesting that the recently introduced bundle-files option,
which allows to build single-file exes has gained a lot of interest -
although the ONLY use case (so far) I have myself for it is to implement
inproc COM servers which will compatible with Python clients (and other
Python inproc COM servers) because of the total isolation of the Python
VMs.

Is anyone interested in taking over the maintainance, documentation, and
further development?

Should py2exe be integrated into another, larger, package?  Pywin32
comes to mind, but also Philip Eby's setuptools (that's why I post to
distutils-sig as well)...

Thomas

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


Re: vendor-packages directory

2005-09-20 Thread Michael Ekstrand
On Tuesday 20 September 2005 10:22, Rich Burridge wrote:
> [lots of well-written and logical information about a proposed
> vendor-packages directory snipped] 
> Is this something that would be considered for a future Python
> release?

+1 to that from me... it looks like good idea - have you submitted the 
patch to SourceForge?

Alternatively, though, there is another option, and it seems to be what 
Debian tries to encourage: the distribution places its packages 
in /usr/lib/python2.3/site-packages. The local administrator can then 
place his/her packages in /usr/local/lib/python2.3/site-packages. Both 
locations are searched.

Unfortunately, the Python distutils default 
to /usr/lib/python2.3/site-packages, so that administrator-installed 
packages are also placed in /usr/lib with the vendor/distro packages. 
If this was changed, so that /usr/local/lib... actually became the 
default for locally-installed packages, that would be a good thing 
IMHO. But it is probably not as elegant as a vendor-packages directory.

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


Re: Best Encryption for Python Client/Server

2005-09-20 Thread Robert Kern
Ed Hotchkiss wrote:
> No worries, I apologize for my outburst. I will check out the viability
> of using an SSH module, or using pyCrypto or something to encrypt the data.
>  
> Here's my mission: simple P2P class with encryption of whatever type of
> file is being sent, and authentication via encrypted user name/password.
> So any type of file or login being sent over the net, any communication
> between the scripts should be encrypted, regardless of whether it is
> client/server communication, or file transfer. 
>  
> Now that I've finally stated what I want to do (sorry) Is SSH a good
> option, or just using sockets with pycrypto? Thanks in advance.  

As I've said before, authoring new security protocols yourself is rarely
a good idea. You *will* get it wrong even if you get the actual
encryption parts right. SSH has implemented a good security model, and
piggybacking on that is preferable to writing your own authentication
protocol. With SSH, you have two clear options, use the SCP protocol
(Secure CoPy) or doing your own file transfers through an
SSH-established and -authenticated tunnel (google:stunnel). A Python
implementation of SSH is provided by the package Paramiko.

Good luck.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: Alternatives to Stackless Python?

2005-09-20 Thread Stephan Diehl
On Tue, 20 Sep 2005 08:50:44 -0700, [EMAIL PROTECTED] wrote:

> After recently getting excited about the possibilities that stackless
> python has to offer
> (http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/)
> and then discovering that the most recent version of stackless
> available on stackless.com was for python 2.2 I am wondering if
> Stackless is dead/declining and if so, are there any viable
> alternatives that exist today?

Well, it's not dead and the last recent version is for python 2.3
The developer of stackless, Christian Tismer, is one of the main
developers of the PyPy project. (http://codespeak.net/pypy)
For this reason, there is an extremely good chance that the ideas
behind stackless will survive :-) .
Visit www.stackless.com for further info.
---
Stephan
-- 
http://mail.python.org/mailman/listinfo/python-list


Using PyGILState_Ensure

2005-09-20 Thread Ralf Riemer
Hi,

I have some questions concerning the global interpreter lock:

I am working with Windows XP Professional Version 5.1, Python version 2.4.1
and Microsoft Visual C++.Net Version 7.1.
>From Python I call a function from a C++ dll using
calldll.call_foreign_function. This C++ function does a callback of a python
function.
Do get it running I use PyGILState_Ensure before PyEval_CallObject and
PyGILState_Release afterwards.
The code looks like this:

static PyObject *my_callback = NULL;

...

// my_callback is set from Python using a 
function SetCallback
...


/* Time to call the callback */
ppyobjArgList = Py_BuildValue("()", NULL);  
   
//General Interpreter Lock (essential for succesful
calling of any python function)
PyGILState_STATE gstate;
//Ensure that the current thread is ready to call
the Python C API 
gstate = PyGILState_Ensure();

ppyobjResult = PyEval_CallObject(my_callback,
ppyobjArgList);
if (!((DWORD_PTR)ppyobjResult))
{
//Error handling
...
} else {
Py_DECREF(ppyobjResult);
}
 
Py_DECREF(ppyobjArgList);

PyGILState_Release(gstate);

Now my questions:
Are there any risks aquiring the global interpreter lock?
Do I invoke by PyEval_CallObject a new python process? (I suppose not)
How long my this call of PyEval_CallObject last? Are there restictions to
the code I use in the called function.
Is it allowed to force the thread to wait (by aquiring the GIL)?
Is there a risk that windows hangs up?
Doing several calls of my dll function with the callback, is there a risk
that the calls overlap and information gets lost?

Thanks for your help!
Ralf

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: vendor-packages directory

2005-09-20 Thread Steve Holden
Rich:

You made it to the States, then? How ironic, I've just been working in 
VA for nine years, but recently returned to Scotland and ended up living 
in Linlithgow, known to most Sun long-timers.

Hope mp is still providing good service.

Rich Burridge wrote:
> Hi,
> 
> I work in the Accessibility Program Office at Sun Microsystems. I'm
> part of a team that is using Python to create a screen reader called
> Orca, that'll help blind people (and people with low vision) have
> access to the GNOME desktop for Solaris and Linux.
> 
[...]

Sorry to hijack your inquiry for personal reasons, but your name leaped 
out at me from the newsreader.

I'm not a developer so I can't really tell you whether that patch will 
be accepted. Since they are talking about "vendor supplied" software, 
there's really no reason why the vendor in question shouldn't make sure 
(probably by the addition of a .pth file) that the required directory is 
added to the search path.

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

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


How to Handle exceptions using OpenerDirector

2005-09-20 Thread swarna pulavarty




Hi all, 
 
 I am trying to figure out a way to handle exceptions for error code 4xx , and 5xx 's . I came to know that these can be handled using OpenerDirector class and urllib2 module in Python. I could'nt find the right syntax or examples of how to use these Handlers.
 
Any help is greatly appreciated !
 
 
Swarna.



		 
Yahoo! India Matrimony: Find your partner now.-- 
http://mail.python.org/mailman/listinfo/python-list

mailing from with python

2005-09-20 Thread M.N.A.Smadi
hi;
if i want to send a mail message using the "mail" client on a machine 
that has smtp protocol is there an easy way (i.e. like bash where you 
would just type mail -s SUBJECT message RECIPIENT) to do it from a 
python script?

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


Re: Two questions on PyDev for Eclipse

2005-09-20 Thread Fabio Zadrozny
Fabio Zadrozny wrote:

>Hi,
>
>for 2: as far as I know, eclipse must have 'local', or at least 
>'emulated' local access, so, if you have samba access, it should do what 
>you want.
>
>for 1... I use it a LOT without any problems for some really big 
>projects ( with about 2.000 python modules -- not counting the python 
>installation) -- but as I also develop it, so, I may be kind of 
>impartial ;-)
>  
>
I meant partial ;-)

>Cheers,
>
>Fabio
>
>Kenneth McDonald wrote:
>
>  
>
>>The first is general; what are users' experience with PyDev for  
>>Eclipse. It looks pretty good to me right now, but I've only started  
>>playing with it. Converting to Eclipse is a major effort, and if  
>>there are problems which would prevent pydev from being useful right  
>>now, I'd certainly appreciate knowing about them.
>>
>>The second question is specific; is it possible to use Eclipse to  
>>edit a remote file, i.e. through SFTP or something equivalent? My  
>>current (limited) understanding of Eclipse is that it maintains an on- 
>>disk directory of files in a project. Unfortunately, for what I'm  
>>doing, a fair number of the files (mostly Python files) I'm editing  
>>are on a remote server, so whatever editor I use, the ability to edit  
>>remote files would be a big help.
>>
>>Thanks,
>>Ken
>> 
>>
>>
>>
>
>
>  
>


-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com


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


Re: Crypto.Cipher.ARC4, bust or me doing something wrong?

2005-09-20 Thread Michael Sparks
Jp Calderone wrote:

> On Tue, 20 Sep 2005 16:08:19 +0100, Michael Sparks <[EMAIL PROTECTED]>
> wrote:
>>Hi,
>>
>>
>>I suspect this is a bug with AMK's Crypto package from
>>http://www.amk.ca/python/code/crypto , but want to
>>check to see if I'm being dumb before posting a bug
>>report.
>>
>>I'm looking at using this library and to familiarise myself writing
>>small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
>>found that I can't get it to decode what it encodes. This might be a
>>case of PEBKAC, but I'm trying the following:
>>
> from Crypto.Cipher import ARC4 as cipher
> key = ""
> obj = cipher.new(key)
> obj.encrypt("This is some random text")
>>')f\xd4\xf6\xa6Lm\x9a%}\x8a\x95\x8ef\x00\xd6:\x12\x00!\xf3k\xafX'
> X=_
> X
>>')f\xd4\xf6\xa6Lm\x9a%}\x8a\x95\x8ef\x00\xd6:\x12\x00!\xf3k\xafX'
> obj.decrypt(X)
>>'\x87\xe1\x83\xc1\x93\xdb\xed\x93U\xe4_\x92}\x9f\xdb\x84Y\xa3\xd4b\x9eHu~'
>>
>>Clearly this decode doesn't match the encode. Me being dumb or bug?
>>
>>Any comments welcome :)
>>
> 
> You need two ARC4 instances.  Performing any operation alters the internal
> state (as it is a stream cipher), which is why your bytes did not come out
> intact.

Ahh. That makes perfect sense. (I thought it must be me missing something)

Many thanks! 

:-)

Regards,


Michael.

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


Re: mailing from with python

2005-09-20 Thread Tim Williams (gmail)
On 20/09/05, M.N.A.Smadi <[EMAIL PROTECTED]> wrote:
> hi;
> if i want to send a mail message using the "mail" client on a machine
> that has smtp protocol is there an easy way (i.e. like bash where you
> would just type mail -s SUBJECT message RECIPIENT) to do it from a
> python script?

Any mail client using SMTP will be outbound only,  you wouldn't be
able to send mail "through" the client using SMTP.

>From a post earlier today :)

s = smtplib.SMTP("server")
s.sendmail(fromaddress, toaddresess, msg)

You can send email directly to your local server (or direct to the
recipeint server) directly from your python "script"

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


Monitoring a directory for changes

2005-09-20 Thread Florian Lindner
Hello,
is there a python lib (preferably in the std lib) to monitor a directory for
changes (adding / deleting files) for Linux 2.6?

Thanks,

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


Re: vendor-packages directory

2005-09-20 Thread Terry Reedy

"Rich Burridge" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I work in the Accessibility Program Office at Sun Microsystems. I'm
> part of a team that is using Python to create a screen reader called
> Orca, that'll help blind people (and people with low vision) have
> access to the GNOME desktop for Solaris and Linux.
>   http://cvs.gnome.org/viewcvs/*checkout*/orca/docs/doc-set/orca.html

Very nice.  I am old enough to know I might need such a program some day.

> Orca in turn uses several packages that interface between Python and the
> various "native" libraries in the GNOME desktop:
>
>   * pyorbit   - Python bindings for ORBit2
>   * pygtk - GTK+ Python bindings
>   * gnome-python  - Python bindings for various GNOME libraries
>
> We will be presenting our project in front of one of the archirectural
> review committees within Sun soon, in order to try to get this software
> in a future release of the Solaris operating system. It's Open Sources,
> so other Linux vendors will also be able to pick it up (if they so 
> desire),
> to include with their software distributions.
>
> We've been given a heads-up on the following problem.
>
> Until now we've been using "/usr/lib/python2.4/site-packages" as the
> directory to install the various Python files that these packages use.

My impression is that this is exactly the intended place for general-use 
support packages.

> We have been told that this directory is inappropriate for vendor 
> supplied
> packages,

As you of course know, 'appropriateness' in in the eye of the beholder. 
>From Python's viewpoint, there is no difference that I know of between 
'vender' supplied packages and 'sharer' supplied packages.  So this looks 
to me like arbitrary whim.  Is there any rationale that I am missing.

> Now we could easily create a "/usr/lib/python2.4/vendor-packages"
[... snip]

If there are other package writers who don't use site-packages, perhaps 
they will read this and share their experiences and solutions.

> What I'd like to see is a future release of Python automatically checking
> for this directory and appending it to the list of directories that it'll
> search.

Python has done fine, it seems, without this.  What benefit would I and 
hundreds of thousands of other people get from having such a directory on 
our machines?

> Here's a patch to do this:
>
> --- Python-2.4.1/Lib/site.py Mon Sep 19 12:37:00 PDT 2005
> +++ Python-2.4.1-new/Lib/site.py Mon Sep 19 12:37:00 PDT 2005
> @@ -182,7 +182,11 @@
>   "lib",
>   "python" + sys.version[:3],
>   "site-packages"),
> -os.path.join(prefix, "lib", "site-python")]
> +os.path.join(prefix, "lib", "site-python"),
> +os.path.join(prefix,
> + "lib",
> + "python" + sys.version[:3],
> + "vendor-packages")]
>  else:
>  sitedirs = [prefix, os.path.join(prefix, "lib", 
> "site-packages")]
>  if sys.platform == 'darwin':

Patches generally belong on one of the Python sourceforge trackers.  If you 
decide to pursue this, this could go either under Patches or maybe RFEs.

> Is this something that would be considered for a future Python release?

My guess would be no, better to persuade whoever to let you use Python as 
intended.  But I don't really know.  The decision would be made either by 
GvR, who will not see this here, or one of the top developers, who might or 
might not.  But I am pretty sure you would need a better rationale than 'my 
superior is hung up on the directory name' or 'Perl has two package 
directories'.  Support from other package venders would definitely be a 
plus.

Terry J. Reedy



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


Re: Organising a python project

2005-09-20 Thread Ron Adam
[EMAIL PROTECTED] wrote:

> Dear all,
> 
> Can anyone point me to a resource that describes the best way of
> organising a python project? My project (gausssum.sf.net) is based
> around a class, and has a GUI that allows 'easy-access' to the methods
> of the class. What is the best or typical directory structure that
> allows the easy creation of binary packages for linux and windows,
> source distributions, etc.
> 
> Rather than make up my own way, I'd prefer to know if there is a
> typical python way...
> 
> Regards,
> baoilleach


Here's what I've settled on for windows. This also keeps my src dir 
clean and separate form all the additional install files needed. I don't 
use automatic version control or CVS yet,  but this seems to work well 
enough for me.  You could probably just add the neccisary script to 
create linux distribution as well.

projectname <- main project directory

projectname1 <- version dir
dist <- py2exe output dir
docs <- addition documents, license, etc, dir
icons<- icons file(s) for exe file dir
src  <- stand alone python source dir
notes<- addition development notes dir
Output   <- inno setup output dir
makeexe.py   <- py2exe script
pack.iss <- inno setup script

projectname2 <- next version...
...  #  copy the previous version to start.
...


Below is my basic py2exe script. You'll need to change it to suite your 
own needs of course.  The rmtree is my own module to remove directories 
and contents.  The newest version of py2exe I think does a better job of 
cleaning up I think.

Cheers,
Ron



# makeexe.py
"""
 Create a stand alone distribution using py2exe.
"""

from distutils.core import setup
import py2exe
import sys
import os
from mytools import rmtree

sys.path += ['.\\src']

try: rmtree.rmtree('dist')
except OSError: pass

try: rmtree.rmtree('build')
except OSError: pass

# Avoid having to use the command line.
# If run without args, build executables, in quiet mode.
if len(sys.argv) == 1:
 #sys.argv.append("-h")  # show options
 sys.argv.append("py2exe")

opts = {
 "py2exe": {
 "optimize": "2",
 }
 }

setup(
 options = opts,
 name = 'Aztec',
 windows = [{
 "script": "src\\aztec.py",
 "icon_resources": [(1, "icons\\aztec.ico")],
 }]
 )

os.rename('dist\\aztec.exe', 'dist\\aztec.scr')

try: rmtree.rmtree('build')
except OSError: pass





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


Re: Monitoring a directory for changes

2005-09-20 Thread Reinhold Birkenfeld
Florian Lindner wrote:
> Hello,
> is there a python lib (preferably in the std lib) to monitor a directory for
> changes (adding / deleting files) for Linux 2.6?

There isn't, but if you don't want to use dnotify/inotify, it is trivial to
implement: use a timer and check the listdir() return value.

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


Re: Would you pls tell me a tool to step debug python program?

2005-09-20 Thread SPE - Stani's Python Editor
SPE ships with a debugger as well: http://pythonide.stani.be It's free
& open source.

Johnny Lee wrote:
> Hi,
>I've met a problem to understand the code at hand. And I wonder
> whether there is any useful tools to provide me a way of step debug?
> Just like the F10 in VC...
> 
> Thanks for your help.
> 
> Regards,
> Johnny

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


Re: Getting tired with py2exe

2005-09-20 Thread Steve M
What about PyInstaller that was announced the other day? The feature
list looks great, and it appears the developers intend to maintain and
enhance the program indefinitely.

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b487056b7b1f99bc/583da383c1749d9f?q=ANN&rnum=1&hl=en#583da383c1749d9f

http://pyinstaller.hpcf.upr.edu/pyinstaller

Feature highlights:
* Packaging of Python programs into standard executables, that work on
computers without Python installed.
 * Multiplatform: works under Windows, Linux and Irix.
 * Multiversion: works under any version of Python since 1.5.
 * Dual packaging mode:
   * Single directory: build a directory containing an executable plus
all
the external binary modules (.dll, .pyd, .so) used by the program.
   * Single file: build a single executable file, totally
self-contained,
which runs without any external dependency.
 * Support for automatic binary packing through the well-known UPX
compressor.
 * Optional console mode (see standard output and standard error at
runtime).
 * Selectable executable icon (Windows only).
 * Fully configurable version resource section in executable (Windows
only).
 * Support for building COM servers (Windows only).

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


Re: Getting tired with py2exe

2005-09-20 Thread James Stroud
On Tuesday 20 September 2005 11:43, Steve M wrote:
> What about PyInstaller that was announced the other day? The feature
> list looks great, and it appears the developers intend to maintain and
> enhance the program indefinitely.
...
>
> http://pyinstaller.hpcf.upr.edu/pyinstaller

That's one short "indefinitely":

Not Found
The requested URL /pyinstaller was not found on this server.
Apache/2.0.53 (Fedora) Server at pyinstaller.hpcf.upr.edu Port 80

James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Release of Shed Skin 0.0.2: Easy Windows/OSX Installation

2005-09-20 Thread Michael Sparks
Mark Dufour wrote:
> Shed Skin is an experimental Python-to-C++ compiler. Along with
> GNU/Linux, version 0.0.2 should now also install easily under Windows
> 2000/XP and OSX. Please give it a try and let me know if there are
> still some problems.

ss.py writes a make file, but unfortunately doesn't detect correctly whether
you need libdl linked in or not. As a result the generated Makefile for the
test includes this for me:

MAINOBJ=test.o
test:   $(MAINOBJ) /home/zathras/Documents/shedskin-0.0.2/libss.a
$(CC) $(CCFLAGS)
$(MAINOBJ) /home/zathras/Documents/shedskin-0.0.2/libss.a -lgc -o test

Whereas it would need to be the following because I'm under linux:

MAINOBJ=test.o
test:   $(MAINOBJ) /home/michaels/Documents/shedskin-0.0.2/libss.a
$(CC) $(CCFLAGS)
$(MAINOBJ) /home/michaels/Documents/shedskin-0.0.2/libss.a -lgc -ldl -o
test

(The reason I'm not suggesting just throwing in -ldl is because that will
then break on other platforms... You need to detect whether it's needed or
not for the platform it's currently compiling for)

Regards,


Michael.

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


Re: Simpler transition to PEP 3000 "Unicode only strings"?

2005-09-20 Thread Martin v. Löwis
Petr Prikryl wrote:
> Would this break any existing code?

Yes, it would break code which currently contains

# -*- coding: utf-8 -*-

and also contains byte string literals.

Notice that there is an alternative form of the UTF-8
declaration: if the Python file starts with an UTF-8
signature (BOM), then it is automatically considered
as UTF-8, with no explicit conding:-declaration
required. Set IDLE's Options/General/Default Source
Encoding to UTF-8 to have IDLE automatically use the
UTF-8 signature when saving files with non-ASCII
characters.

As for dropping the u prefix on string literals:
Just try the -U option of the interpreter some time,
which makes all string literals Unicode. If you manage
to get the standard library working this way, you
won't need a per-file decision anymore: just start
your program with 'python -U'.

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


  1   2   >