SC-Corporate-ID release

2005-05-11 Thread Bud P. Bruegger
Dear all,

I am very pleased to announce the release of SC-Corporate-ID.

SC-Corporate-ID is a commercial Smart Card security system that can be
extended by the user using the Python language.

SC-Corporate-ID is written in Python and wxPython for the most part (except
for the PCSC wrapper, the GINA dll and the crypto) on the PC side, and
in  other languages on the Smart Card side. The PCSC driver (PYCSC) and
the crypto (PYCRYPTO) are public domain packages (PYCSC was slightly
modified by us)

SC-Corporate-ID is an off-the shelf package: you can use it as is; yet, as
it is based on a set of libraries (SCF), it can be modified and customized
by the company using it (the restriction being the capabilities of the code
in the Smart Card which would have to be modified by us).

SC-Corporate-ID can be used for PC Access, Data Security (file
encryption/signature), Company Electronic Purse and Corporate
Identification. Some of its possible extentions are Building Access and WEB
Security.

SC-Corporate-ID cards can be delivered pre-programmed (firwmare + data) or
simply with the firmware so the user may handle its own cards issuance.

Although it is a commercial product, SC-Corporate-ID intends to be a true
low cost security solution for Corporations.

SC-Corporate-ID will soon be followed by a School/University ID as well as
an Health Card ID.

You may find information on SC-Corporate-ID at www.snakecard.com.


Best regards,


Philippe Martin




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

 Support the Python Software Foundation:
 http://www.python.org/psf/donations.html


-
Ing. Bud P. Bruegger, Ph.D. +39-0564-488577 
(voice),  -21139 (fax)
Servizio Elaborazione Datie-mail:  [EMAIL PROTECTED]
Comune di 
Grossetohttp://www.comune.grosseto.it/cie/
Via Ginori, 
43  http://OpenPortalGuard.sf.net
58100 Grosseto (Tuscany, Italy)   jabber:  [EMAIL PROTECTED]

Free Software in Public Administration:  not just a good idea, but a necessity

Perfection is attained, not when there is nothing more to be added, but 
when there is nothing more to be taken away -- Antoine de Saint-Exupery 

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


PyDO-2.0a1 released

2005-05-11 Thread Jacob Smullyan
I'm pleased to announce the second alpha release of PyDO 2.


What's New
--

* PyDO2 is now in the PyDO2 package, to facilitate peaceful
  coexistence with PyDO1.

* explicit schema support (as in 'myschema.mytable').

* The table attribute can now be left out if the class name
  is the name of the table.

* refetch behavior has been refactored.

* there are a bunch of classes to help in doing various kinds of
  joins.

What it is
--

PyDO is Drew Csillag's ORM (Object-Relational Mapper) database access
library for Python that facilitates writing a Python database access
layer.  PyDO attempts to be simple, flexible, extensible, and
unconstraining.

PyDO 2 is a rewrite of the 1.x series distributed with SkunkWeb.
It has several enhancements:

   * PyDO can now be used in multi-threaded or twisted-style
 asynchronous sitations, with or without a customizable connection
 pool.

   * PyDO objects are now dict subclasses, but also support attribute
 access to fields.

   * Projections -- subsets of the field list of a super-class -- are
 now supported by the PyDO.project() method.

   * Table attributes are now declared in a more concise way.

   * Overall, the API has been tightened and the code restructured.

It also has several limitations:

   * PyDO 2 is alpha code.  Bugs should be expected, and the API is not
 guaranteed to be stable.

   * Currently, PyDO 2 supports fewer database systems than PyDO 1
 (PostgreSQL, SQLite, and MySQL), although adding new drivers
 should not be difficult.

   * PyDO 2 requires Python 2.4 or later.

PyDO is dual GPL/BSD licensed.

The source tarball is available at SkunkWeb's berlios site:

   https://developer.berlios.de/projects/skunkweb/

or, more directly:

   http://download.berlios.de/skunkweb/PyDO-2.0a1.tar.gz

Questions pertaining to PyDO can be addressed to the SkunkWeb mailing
list at sourceforge:

   http://lists.sourceforge.net/lists/listinfo/skunkweb-list

Cheers,

js

-- 
Jacob Smullyan 


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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


CHANGE BayPIGgies: May *THIRD* Thurs

2005-05-11 Thread Aahz
Reminder:

We will *NOT* be meeting the *SECOND* Thursday (this week, May 12).

Our May meeting will be the *THIRD* Thursday, May 19.  This will be our
first meeting at Google, with Alex Martelli's presention on design
patterns.  More details soon!
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

And if that makes me an elitist...I couldn't be happier.  --JMS
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Python Args By Reference

2005-05-11 Thread Paul Rubin
ncf [EMAIL PROTECTED] writes:
 As I fail to see how an array could be used in this (my own
 stupidity?), would you have any such example? 

How's this (untested):

state = [A,B,C,D,E,F,G,H]
magic = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 
 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98 ]

def P(state, i, magic):
   a,b,c,d,e,f,g,h = state[i:] + state[:i]
   temp1 = h + S3(e) + F1(e,f,g) + K + x
   temp2 = S2(a) + F0(a,b,c)
   # d += temp1; h = temp1 + temp2
   state[(i+3)%8] += temp1; state[(i+7)%8] = temp1 + temp2

for i in range(9):
   P(state, i, W, magic)

Actually this isn't so good.  You have to be careful about arithmetic
overflow, i.e. do all the additions mod 2**32, so you don't get Python
longs.  I'll leave that as an exercise.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread Paul Rubin
Paul Rubin http://[EMAIL PROTECTED] writes:
 state = [A,B,C,D,E,F,G,H]
 magic = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 
  0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98 ]
 
 def P(state, i, magic):
a,b,c,d,e,f,g,h = state[i:] + state[:i]
temp1 = h + S3(e) + F1(e,f,g) + K + x

Woops, K is supposed to say magic[i].  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread Dan Bishop
ncf wrote:
 As I fail to see how an array could be used in this (my own
 stupidity?), would you have any such example? For reference, I'm
trying
 to translate this: http://www.cr0.net:8040/code/crypto/sha256/
(Inside
 sha256_process).

 Once again, thanks for the patience, I'm still picking up on all the
 little tid-bits. :)


def P(arr, x, k):
   a, b, c, d, e, f, g, h = arr
   temp1 = arr[7] + S3(arr[4]) + F1(*arr[4:7]) + k + x
   temp2 = S2(arr[0]) + F0(*arr[:3])
   arr[3] += temp1
   arr[7] = temp1 + temp2

K = [0x428A2F98, 0x71374491, 0xB5C0FBCF,
 0xE9B5DBA5, 0x3956C25B, 0x59F111F1,
 0x923F82A4, 0xAB1C5ED5, 0xD807AA98]

...

for i in xrange(9):
   P(arr, w[i], K[i])
   if i != 8: # don't rotate the last time
  arr = [arr[-1]] + arr[:-1] # rotate arr


The last line moves the last element of arr to the beginning (so the
positions are correct for the call to P).

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


Re: Solipsis: Python-powered Metaverse

2005-05-11 Thread Ville Vainio
 Paul == Paul McNett [EMAIL PROTECTED] writes:

Paul Only, I couldn't hear what they said back to me because I
Paul don't have UDP port 6000 open on my firewall and forwarding
Paul to my laptop (and don't want to do that either).

Paul It is a shame: peer to peer has the potential to enable
Paul really cool, imaginative multiuser worlds, but how many
Paul people are connecting directly to the internet these days?

FWIW, In Finland all home *DSL and Cable internet connections (that I
know of) are connected directly to the internet (in the sense that
all ports are open). Blocking is reserved for the modem, just the way
it should be...

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyvm -- faster python

2005-05-11 Thread Kay Schluehr

Paul Rubin wrote:
 Roger Binns [EMAIL PROTECTED] writes:
  Err, you proved my point!  Prothon was fine at the VM level.  The
  author couldn't figure out how to get a decent sized standard
  library, and ultimately ended up abandoning his VM for .Net since
  that gets you a large standard library.  Jython also gets a large
  standard library from the Java ones.

 What kind of stuff is in the existing Python C library that couldn't
 be reimplemented or retargeted pretty easily?  Most of it is either
 wrappers for standard C functions (system calls), stuff that
shouldn't
 be in C in the first place (the Python compiler and interpreter),
etc.

Delete the standard and You still obtain huge librarys for .Net, Java
and Python. I also regret that Prothon starved in infancy but it might
be exeggerated to demand that each language designer or one of his
apostels should manage a huge community that enjoys doing redundant
stuff like writing Tk-bindings, regexp-engines and all that.

 I hope that PyPy will replace CPython once it's solid enough.  Trying
 to stay backwards compatible with the legacy C API doesn't seem to me
 to be that important a goal.  Redoing the library may take more work
 than the Prothon guy was willing to do for Prothon, but PyPy has more
 community interest and maybe can attract more resources.

PyPy is a beast on it's own and provides interesting new ideas to
Python as well as runtime design in general. But I'm not quite shure
that it will stay in the boundarys of the current Python community
process and will subordinate to Guidos will. As a Marxist would say:
who controls the runtime also controls the language. Sooner or later
Python will go the LISP way of having a standardized Common-Python (
std_objectspace) and a number of dialects and DSLs running in their own
derived object spaces. Maybe Python 3000 is an illusion and will fade
away like a Fata Morgana the closer we seem come.

Kay

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


Re: windows directories for curr user

2005-05-11 Thread Dan Bishop
flamesrock wrote:
 Hi,

 Short, maybe newbish question: Is there a python method for finding
out
 who the current user is in the OS module?

 On older windows machines the directory I'm interested in is just
 c://my documents, but how do I walk to the current users my
documents
 folder?

path = '%s\\My Documents' % os.environ['USERPROFILE']

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


Re: Python Args By Reference

2005-05-11 Thread Donn Cave
Quoth ncf [EMAIL PROTECTED]:
...
| The two issues I am having in grasping all of this are as follows:
| 1) Being new to Python, terms like mutable and immutable. Although I
| have probably dealt with them in other languages, the terms by
| themselves are a little confusing, but managable overall, so this issue
| isn't so big.

It's often introduced in a confusing way.  We just say it's mutable
if it has one or more functions that modify its contents.  There
isn't any other distinction, any other difference than that.

| 2) LARGELY, my issue is as demonstrated by the following code. I was
| trying to accomplish an effect similar to what is possible in C.
| (Trying to make a pure-python FIPS-180-2 compliant implementation of
| the SHA-256 algorithm for more Python practice and to put into some
| code for a *trial* secure protocol.)
| Example C Code:
| #define P(a,b,c,d,e,f,g,h,x,K) \
| { \
| temp1 = h + S3(e) + F1(e,f,g) + K + x; \
| temp2 = S2(a) + F0(a,b,c); \
| d += temp1; h = temp1 + temp2; \
| }
|
| Python Code:
| def P(a,b,c,d,e,f,g,h,x,K):
| temp1 = h + S3(e) + F1(e,f,g) + K + x
| temp2 = S2(a) + F0(a,b,c)
| d += temp1; h = temp1 + temp2
|
| The reason why it'd be a pain to implement this by any of the methods
| provided in the Python FAQs is that SHA-256 rotates the variable order
| in the calls. Example code:
| P( A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98 );
| P( H, A, B, C, D, E, F, G, W[ 1], 0x71374491 );
| P( G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF );
| P( F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5 );
| P( E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B );
| P( D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1 );
| P( C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4 );
| P( B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5 );
| P( A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98 );
|
| Since I cannot simply do it the way I had originally seen it, would
| there be an alternative method to proforming the operations that I am
| missing?

I could be missing something, but I think you just have to suck it up
and do it one of the other two ways:

1.  The more or less functional way:  the function doesn't
have any side effects.  It just returns the values it
computes, and it's for the caller to bind them to variables.

  D, H = P(A, B, C, D, E, F, G, H, W[0], 0x428A2F98)
  C, G = (H, A, B, C, D, E, F, G, W[1], 0x71374491)
  ...

2.  The OOP way:  each object has the appropriate function
that modifies its content value.  That looks like a
big waste of time to me, but I mention it for conceptual
completeness.

Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyvm -- faster python

2005-05-11 Thread Roger Binns

Paul Rubin http://[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Roger Binns [EMAIL PROTECTED] writes:
 What kind of stuff is in the existing Python C library that couldn't
 be reimplemented or retargeted pretty easily?  Most of it is either
 wrappers for standard C functions (system calls), stuff that shouldn't
 be in C in the first place (the Python compiler and interpreter), etc.

Some examples are gui toolkits (eg wxPython), SSL (eg M2Crypto, pyopenssl)
and database (pysqlite, APSW).  These aren't in the shipped with Python
library but are widely used.

 I hope that PyPy will replace CPython once it's solid enough.  Trying
 to stay backwards compatible with the legacy C API doesn't seem to me
 to be that important a goal.  Redoing the library may take more work
 than the Prothon guy was willing to do for Prothon, but PyPy has more
 community interest and maybe can attract more resources.

You don't have to stay backwards compatible.  It is best to provide
some sort of way of using the old extensions even if it is suboptimal
(eg some sort of mapping shim).  The extensions can later be improved,
but if there is no simple way of recompiling and running then it will
take a long time for all the extensions to get ported.

I already get burnt out on the matrix of CPython versions and different
platforms.  Adding another interpretter would make life even harder
for extension authors.

Roger 


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


Re: windows directories for curr user

2005-05-11 Thread flamesrock
thanks!!

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


Re: pyvm -- faster python

2005-05-11 Thread Paul Rubin
Kay Schluehr [EMAIL PROTECTED] writes:
 Delete the standard and You still obtain huge librarys for .Net, Java
 and Python. I also regret that Prothon starved in infancy but it might
 be exeggerated to demand that each language designer or one of his
 apostels should manage a huge community that enjoys doing redundant
 stuff like writing Tk-bindings, regexp-engines and all that.

Maybe there needs to be some kind of standard FFI (foreign function
interface) like Lisp implementations have.

 Sooner or later Python will go the LISP way of having a standardized
 Common-Python ( std_objectspace) and a number of dialects and DSLs
 running in their own derived object spaces. Maybe Python 3000 is an
 illusion and will fade away like a Fata Morgana the closer we seem come.

Right now Python feels about like Maclisp in the 1970's must have felt
(that was before my time so I can't know for certain).  Lots of
hackerly excitement, lots of cruft.  It needs to ascend to the next
level.  PyPy looks like the best vehicle for that so far.  See

   http://catb.org/~esr/jargon/html/M/MFTL.html

for the canonical remark about languages that can't be used to
implement their own compilers.  Python is fun and useful, but it
really isn't mature until PyPy is released for production use.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyvm -- faster python

2005-05-11 Thread Paul Rubin
Roger Binns [EMAIL PROTECTED] writes:
 Some examples are gui toolkits (eg wxPython), SSL (eg M2Crypto, pyopenssl)
 and database (pysqlite, APSW).  These aren't in the shipped with Python
 library but are widely used.

M2Crypto is a straightforward SWIG wrapper around OpenSSL, I thought.
I don't know about wxPython or pysqlite.  It seems to me that some
kind of SQL client should be part of the stdlib.  But why isn't a SWIG
wrapper enough?  The CPython stdlib has for possibly good reasons
avoided SWIG but a new implementation doesn't need to.

 You don't have to stay backwards compatible.  It is best to provide
 some sort of way of using the old extensions even if it is suboptimal
 (eg some sort of mapping shim).

Yeah, there's something to be said for that, if it doesn't cause too
much pain.

 I already get burnt out on the matrix of CPython versions and different
 platforms.  Adding another interpretter would make life even harder
 for extension authors.

There's already Jython and Python.net is on its way.  This is
something Lisp users have dealt with for decades and they've developed
workable machinery for it.  Maybe Python can adopt some of those
methods.
-- 
http://mail.python.org/mailman/listinfo/python-list


Pipes of binaries - IPC::Run

2005-05-11 Thread Swaroop C H
Is there a Python equivalent of Perl's IPC::Run module [
http://search.cpan.org/dist/IPC-Run/lib/IPC/Run.pm ] ?

Thanks!
-- 
Swaroop C H
Blog: http://www.swaroopch.info
Book: http://www.byteofpython.info
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Solipsis: Python-powered Metaverse

2005-05-11 Thread Heiko Wundram
On Wednesday 11 May 2005 08:02, Ville Vainio wrote:
 FWIW, In Finland all home *DSL and Cable internet connections (that I
 know of) are connected directly to the internet (in the sense that
 all ports are open). Blocking is reserved for the modem, just the way
 it should be...

Same here, and I'd be the first to protest when a provider I pay even remotely 
thinks of blocking a port. That's none of their business; a firewall should 
always be mine...!

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


Re: Merging overlapping spans/ranges

2005-05-11 Thread Jordan Rastrick
Should work fine as far as I can see. Of course, thats not very
'pythonic' - I should probably give at least 10 different unit tests
that it passes ;)

Its gratifying to know I'm not the only one who needed that final
yield.

Jim Sizelove wrote:
 Bengt Richter wrote:
  On Tue, 10 May 2005 15:14:47 +0200, Max M [EMAIL PROTECTED] wrote:
 
 
 I am writing a find-free-time function for a calendar. There are
a lot
 of time spans with start end times, some overlapping, some not.
 
 To find the free time spans, I first need to convert the events
into a
 list of non overlapping time spans meta-spans.
 
 This nice ascii graph should show what I mean.
 
 1) ---
 2) ---
 3)   ---
 4)  -
 5) -
 
 
 ---   # meta spans
 
 I can then iterate through the meta-spans and find non-busy times.
 
 I have written the class below, but it is rather O^2, so I wondered
if
 anybody has an idea for a better approach?
 
 
  Maybe (not tested beyond what you see ;-)

 It is with some trepidation that I write this message; after hanging
 around in c.l.p for the better part of a year, I have come to expect
 Bengt's messages to be right-on and error-free.

 However this time...  :)
def mergespans(spans):
   ...  start = end = None
   ...  for s,e in sorted(spans):
   ...  if start is None: start, end = s,e; continue
   ...  if s = end: end = e; continue
   ...  yield start, end
   ...  start,end = s,e
   ...  if start is not None: yield start, end
   ...
spans = [(0,3), (4,7), (2,5), (9,14), (12,17)]
list(mergespans(spans))
   [(0, 7), (9, 17)]

 There can be a problem in mergespans if one span fits inside another:

spans = [(0,5), (4,7), (2,3), (9,14), (12,17)]
list(mergespans(spans))
   [(0, 3), (4, 7), (9, 17)]

 Here is a revised version (not tested beyond what you see ;-)
def mergespans(spans):
   ... start = end = None
   ... for s,e in sorted(spans):
   ... if start is None:
   ... start, end = s,e
   ... continue
   ... if s = end:
   ... if end  e:
   ... end = e
   ... continue
   ... yield start, end
   ... start,end = s,e
   ... if start is not None:
   ... yield start, end
   ...
list(mergespans([(0,5), (4,7), (2,3), (9,14), (12,17)]))
   [(0, 7), (9, 17)]
list(mergespans([(0,3), (4,7), (2,5), (9,14), (12,17)]))
   [(0, 7), (9, 17)]

 Can anyone find any other errors in this? ;-)
 
 With humble regards,
 Jim Sizelove

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


RE: windows directories for curr user

2005-05-11 Thread Tim Golden
[Dan Bishop]
| flamesrock wrote:
|  Hi,
| 
|  Short, maybe newbish question: Is there a python method for finding
| out
|  who the current user is in the OS module?
| 
|  On older windows machines the directory I'm interested in is just
|  c://my documents, but how do I walk to the current users my
| documents
|  folder?
| 
| path = '%s\\My Documents' % os.environ['USERPROFILE']

Or, rather more generally:

code

from win32com.shell import shell, shellcon
import win32api
  
#
# Don't need this to find the right folder,
#  but since you asked...
#
print win32api.GetUserName ()

#
# This is the personal files which usually corresponds
#  to the My Documents folder, but in my case points to
#  h:\ since that's my home folder in my AD profile.
#
print shell.SHGetPathFromIDList (
  shell.SHGetSpecialFolderLocation (0, shellcon.CSIDL_PERSONAL)
)

#
# To see a list of possible CSIDL values:
#
for i in dir (shellcon):
  if i.startswith (CSIDL):
print i

/code



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

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


Re: Trouble saving unicode text to file

2005-05-11 Thread Thomas Bellman
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= [EMAIL PROTECTED] wrote:

Thomas Bellman wrote:
 Fixed-with characters *do* have advantages, even in the external
 representation.  With fixed-with characters you don't have to
 parse the entire file or stream in order to read the Nth character;
 instead you can skip or seek to an octet position that can be
 calculated directly from N.

 OTOH, encodings that are free of null bytes and ASCII compatible
 also have advantages.

Indeed, indeed.  But that's no reason to choose UTF-16 over UTF-32,
since you don't get those advantages then.

 And not the least, UTF-32 is *beautiful* compared to UTF-16.

 But ugly compared to UTF-8. Not only does it have the null byte
 and the ASCII incompatibility problem, but it also has the
 endianness problem. So for exchanging Unicode between systems,
 I can see no reason to use anything but UTF-8 (unless, of course,
 one end, or the protocol, already dictates a different encoding).

UTF-8 beats UTF-32 in the practicality department, due to its
compatibility with legacy software, but in my opinion UTF-32 wins
over UTF-8 for shear beauty, even with the endianness problem.

I do wish they had standardized on one single endianness for UTF-32
(and UTF-16), instead of allowing both to exist.  In the mid 1990's
I had to work with files in the TIFF format, which allows both
endianesses.  The specification *requires* you to read both, but it
was a rare sight to find MS Windows software that didn't barf on
big endian TIFF files. :-(  Unix software tended to be better at
reading both endians, but generally wrote in the native format,
meaning big endian on Sun Sparc.  Luckily I could convert files
using tiffcp on our Unix machines, but it was irritating to have to
introduce that extra step.  I fully expect the same problem to
happen with UTF-16 and UTF-32 too.

Anyway, back to UTF, my complaint is that UTF-16 doesn't give you
the advantages of *either* UTF-8, nor UTF-32, so if you have the
choice, UTF-16 is always the worst alternative of those three.  I
see no reason to recommend UTF-16 at all.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
God is real, but Jesus is an integer.  !  bellman @ lysator.liu.se
 !  Make Love -- Nicht Wahr!
-- 
http://mail.python.org/mailman/listinfo/python-list

Defunct Processes With subprocess.Popen

2005-05-11 Thread John Abel
Hi!

I'm currently writing a script which launches external programs, but it 
keeps leaving zombie/defunct processes behind, until I kill the 
launching script, which is a bit of a pain, as it's supposed to be a 
daemon.  The code I'm using is:

newPid = subprocess.Popen( cmdLine[ 1: ], executable=cmdLine[ 0 ], 
close_fds=True ).pid

I've tried calling it using the shell=True flag, but that leaves a 
zombie for the sh, instead.  I'm not interested in any output, the only 
thing I need returning, is the pid of the new process.  I've tried using 
spawn*, with the same results.  Does anyone have any ideas?

Thanks.

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


Re: Merging overlapping spans/ranges

2005-05-11 Thread Max M
Jim Sizelove wrote:


Wow! c.l.py is allmost like an AI program generator. But I guess it 
helps to ask questions about problems that programmers find interresting :-)

The linear approach is pretty simple to code and understand. I am just 
afraid what happens when many users tries to book that 14 day conference 
in the calendar sometimes this year.

365 * 24 * 60 = 525,600 booleans in the array

Well ok a few MBytes ain't too bad on a modern machine. It would even be 
possible to cut the resolution down to 15 minutes. Yielding 35,040 
bools, but the solution is still O^2 with regards to size of search 
window and number of events.

Bengts/Jims and Jordans solutions seems to be relatively similar. I will 
use one of those instead of my own code.


Thanks!


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Faster Way...

2005-05-11 Thread asmir . mehic
For efficient string concatenation in python look at:
http://www.skymind.com/~ocrow/python_string

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


Serving binary data from a cgi-script

2005-05-11 Thread Thomas W
Hi,

I'm having some problems serving binary data in a simple CGI-script.
I'm setting content-type ( application/octet-stream ), content-length
and Content-disposition and I think these are correct, but the size of
the served file/data is different than the source. The read and write
the data I'm doing a plain :

f = open (..., 'rb')
d = f.read(2048)
while d:
  if not d: break
  print d
  d = f.read(2048)
f.close()

Any hints?

Best regards,
Thomas

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


Re: A Faster Way...

2005-05-11 Thread stasz
On Tue, 10 May 2005 18:11:27 -0700, gene.tani wrote:

 hmm, there's lots of ways, huh?  you can use itertools.zip instead of
 builtin zip, or do:
 
  map(None, list1, list2)
Not!
One should try a possible solution first,
 l1 = range(10)
 l2 = range(10,20)
 l1
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 l2
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
 map(None,l1,l2)
[(0, 10), (1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16), (7, 17), (8, 
18), (9, 19)]
 

Stas

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


Reading files into a 2D list.

2005-05-11 Thread Oyvind Ostlund
I am not sure what the right syntax is here. So please help me out (started 2 
days ago).

I have a list of about 20 files that I want to read line by line into a 2D 
list. So the first dimension will be each file, and the second every line in 
that file.


I tried to do something like this:

files_and_lines = [][]
filenumber = 0

for files in file_names:
try:
lexi_file = open(str(sys.path[0]) + /lexi/ + files, r)
files_and_lines[filenumber] = lexi_file.readlines()
filenumber = filenumber + 1

except(IOError):
print Something went wrong trying to read the file:
print ' + str(sys.path[0]) + files + '



But that was not very sucksessfully. I am not even sure on how to define an 
empty 2D list. Thanks for all help.

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


Re: Serving binary data from a cgi-script

2005-05-11 Thread Roland Heiber
Thomas W wrote:
   print d

Hi,

use sys.stdout.write instead, print is adding linebreaks ...

HtH, Roland
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyvm -- faster python

2005-05-11 Thread Stelios Xanthakis
Roger Binns wrote:
I am not very interested on C compatibility.
 
 
 That will rule out all the gui frameworks, SSL, cryptography
 and numerous other packages.  Have a look at what happened to
 Prothon.  What ultimately killed it was the problem of having
 a decent library.  You don't have to make the C library
 compatibility totally high performance, but having any form of
 it there will make adoption by others easier.
 

There are two kinds of C modules: those that do have a knowledge
of the C API (like sre, tkinter, etc) and those that are just C/C++
libraries which are simply wrapped as modules.  For the latter there
are two solutions besides adding a wrapper which makes pyvm appear
as libpython:
- an advanced ctypes module which will make dlopening libraries
and wrapping their symbols behind python functions, a matter of
python code.  I'm considering this approach to provide things
like 'raw_input'.
- hacking SWIG.  Shouldn't be too hard and will instantly give
us access to wx, qt, etc.

The thing is that the C API of pyvm is IMHO superior and much more fun.
You can wrap the entire sockets module in a couple of hours and also
enjoy it.  I wish I could clone myself to port the entire std library
to pyvm -- so much fun it is:)


thanks,

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


Re: pyvm -- faster python

2005-05-11 Thread Stelios Xanthakis
Paul Rubin wrote:
 
 I hope that PyPy will replace CPython once it's solid enough.  Trying
 to stay backwards compatible with the legacy C API doesn't seem to me
 to be that important a goal.  Redoing the library may take more work
 than the Prothon guy was willing to do for Prothon, but PyPy has more
 community interest and maybe can attract more resources.

I didn't know much about PyPy.  It seems that pyvm is *exactly* what
pypy needs to boost its performance.  Does pypy has the vm in python
as well?  Does pypy have a compiler that produces 2.4 bytecodes?

I think the next step in speeding up python (not that it's slow, I'm
in the group of people that don't think Python is slow), is the AST
compiler.  An AST compiler for CPython is in the works AFAIK, but it
would be more powerful in written in python.  It would be also easy
to have 'alternative' compilers that, for example are not whitespace
sensitive, or the code looks like perl :), but they all produce python
bytecode.


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


Re: Put a file on an ftp server over ssl

2005-05-11 Thread Lars
Daniel,

Why don't you just use the 'sftp' command line program, it's available
for all unixes and I bet you can find a build for windows to? Then you
could just do an os.system(..) and be done with it.

Cheers!
Lars

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


Re: Reading files into a 2D list.

2005-05-11 Thread Klaus Alexander Seistrup
Øyvind Østlund wrote:

 I have a list of about 20 files that I want to read line by
 line into a 2D list. So the first dimension will be each file,
 and the second every line in that file.

 I tried to do something like this:

 files_and_lines = [][]
 filenumber = 0
 
 for files in file_names:
 try:
 lexi_file = open(str(sys.path[0]) + /lexi/ + files, r)
 files_and_lines[filenumber] = lexi_file.readlines()
 filenumber = filenumber + 1

 except(IOError):
 print Something went wrong trying to read the file:
 print ' + str(sys.path[0]) + files + '

I'm not sure I understand you.  Do you wish to end up with an array 
like this:

#v+

[fileName0][fileLines0]
[fileName1][fileLines1]
  ...
[fileNameN][fileLinesN]

#v-

In that case try something like:

#v+

 files_and_lines = []
 for name in file_names:
 files_and_lines.append([name, open(name, 'r').readlines()])
 print 'Read %d files' % (len(files_and_lines),)

#v-

Add proper error checking.

At least, I think the [].append() method is what you're looking for.

Cheers,

-- 
Klaus Alexander Seistrup
Magnetic Ink, Copenhagen, Denmark
http://magnetic-ink.dk/
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Reading files into a 2D list.

2005-05-11 Thread Oyvind Ostlund
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Klaus Alexander 
Seistrup
Sent: Wednesday, May 11, 2005 12:14 PM
To: python-list@python.org
Subject: Re: Reading files into a 2D list.

Øyvind Østlund wrote:

 I have a list of about 20 files that I want to read line by line into 
 a 2D list. So the first dimension will be each file, and the second 
 every line in that file.

 I tried to do something like this:

 files_and_lines = [][]
 filenumber = 0
 
 for files in file_names:
 try:
 lexi_file = open(str(sys.path[0]) + /lexi/ + files, r)
 files_and_lines[filenumber] = lexi_file.readlines()
 filenumber = filenumber + 1

 except(IOError):
 print Something went wrong trying to read the file:
 print ' + str(sys.path[0]) + files + '

I'm not sure I understand you.  Do you wish to end up with an array like this:

#v+

[fileName0][fileLines0]
[fileName1][fileLines1]
  ...
[fileNameN][fileLinesN]

#v-

In that case try something like:

#v+

 files_and_lines = []
 for name in file_names:
 files_and_lines.append([name, open(name, 'r').readlines()]) 
 print 'Read %d files' % (len(files_and_lines),)

#v-

Add proper error checking.

At least, I think the [].append() method is what you're looking for.

Cheers,

--
Klaus Alexander Seistrup
Magnetic Ink, Copenhagen, Denmark
http://magnetic-ink.dk/
--
http://mail.python.org/mailman/listinfo/python-list


Thanks for the reply. But I might have been a bit clearer. 


What I want to do is to be able to write:

files_and_lines[5][5]

And then I am accessing the 6th line in the 6th file, so I can print that line 
if I want, or do what ever I want with it. So if I did this:

If files_and_lines[1][1] == files_and_lines[1][100]: 

Then I would check if those two lines had the same content. I tried your 
solution, and if I didn't do anything else wrong, I think you missunderstood me 
a bit, because if I try print files_and_lines[1][1] now, it prints whole lot 
more then just one line from file 2.


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


Regarding Mail sending smtplib Module

2005-05-11 Thread praba kar


Dear All,

 I have doubt regarding mail sending smtplib
module. The below code is I used to send  a mail.

##
import email.Message
import email.Utils
import mimetypes
import os,string

fromAddr=[EMAIL PROTECTED]
toAddr=
[[EMAIL PROTECTED],[EMAIL PROTECTED]]

mainMsg=email.Message.Message()
mainMsg[Date]=email.Utils.formatdate(localtime=1)
mainMsg[Subject]=en new contents
mainMsg[From]=fromAddr
mainMsg[To]= string.join(toAddr,,)

## I am sending below message ## here

mainMsg.set_payload(Good to win win\n)

server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromAddr, toAddr, mainMsg.as_string())
server.quit()

##

This is the output of above send mail program.

Here I want to avoid this line Received: from unknown
(HELO prabahar.enmail.com) (59.92.13.47)  by
mailserver with SMTP; 11 May 2005 10:09:11 -  How
can I do this? . Why python give this line? . Mail
sending Module in php will not give this type line.
Here I have another doubt Php mail sending module give
MessageId automatically
but python doesn't set that. why?

output
***

Return-Path: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 6865 invoked from network); 11 May
2005 10:09:11 -
Received: from unknown (HELO prabahar.enmail.com)
(59.92.13.47) by mailserver with SMTP; 11 May 2005
10:09:11 -

Received: (dqd 1118 invoked from network); 12 Apr 2005
06:38:59 -
Received: from unknown (HELO prabahar.enmail.com)
(127.0.0.1)
by prabahar.enmail.com with SMTP; 12 Apr 2005 06:38:59
-
Date: Tue, 12 Apr 2005 03:38:59 -0300
Subject: en new contents
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED],[EMAIL PROTECTED]

Good to win win


with regards
Prabahar


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread Roy Smith
ncf [EMAIL PROTECTED] wrote:
 The two issues I am having in grasping all of this are as follows:
 1) Being new to Python, terms like mutable and immutable. Although I
 have probably dealt with them in other languages, the terms by
 themselves are a little confusing, but managable overall, so this issue
 isn't so big.

If you know C++, imagine a class where every method is declared const.  
That's essentially what Python's immutable means.  Once you've created an 
object, you can never modify it (other than to destroy it).

The most common immutable objects you'll see are strings and tuples, and 
the main reason they're immutable is to allow them to be dict keys.

 2) LARGELY, my issue is as demonstrated by the following code. I was
 trying to accomplish an effect similar to what is possible in C.
 (Trying to make a pure-python FIPS-180-2 compliant implementation of
 the SHA-256 algorithm for more Python practice and to put into some
 code for a *trial* secure protocol.)
 Example C Code:
 #define P(a,b,c,d,e,f,g,h,x,K) \
 { \
 temp1 = h + S3(e) + F1(e,f,g) + K + x; \
 temp2 = S2(a) + F0(a,b,c); \
 d += temp1; h = temp1 + temp2; \
 }
 
 Python Code:
 def P(a,b,c,d,e,f,g,h,x,K):
 temp1 = h + S3(e) + F1(e,f,g) + K + x
 temp2 = S2(a) + F0(a,b,c)
 d += temp1; h = temp1 + temp2

Perhaps something like this:

def P(a,b,c,d,e,f,g,h,x,K):
temp1 = h + S3(e) + F1(e,f,g) + K + x
temp2 = S2(a) + F0(a,b,c)
return (d+temp1, temp1+temp2)

then you could call it as:

D, H = P( A, B, C, D, E, F, G, H, W[ 0], 0x428A2F98 )
D, H = P( H, A, B, C, D, E, F, G, W[ 1], 0x71374491 )
D, H = P( G, H, A, B, C, D, E, F, W[ 2], 0xB5C0FBCF )
D, H = P( F, G, H, A, B, C, D, E, W[ 3], 0xE9B5DBA5 )
D, H = P( E, F, G, H, A, B, C, D, W[ 4], 0x3956C25B )
D, H = P( D, E, F, G, H, A, B, C, W[ 5], 0x59F111F1 )
D, H = P( C, D, E, F, G, H, A, B, W[ 6], 0x923F82A4 )
D, H = P( B, C, D, E, F, G, H, A, W[ 7], 0xAB1C5ED5 )
D, H = P( A, B, C, D, E, F, G, H, W[ 8], 0xD807AA98 )
-- 
http://mail.python.org/mailman/listinfo/python-list


Problems with csv module

2005-05-11 Thread Florian Lindner
Hello,
I've one problem using the csv module.
The code: 

self.reader = csv.reader(f, delimiter = ,)

works perfectly. But when I use a variable for delimiter:

self.reader = csv.reader(f, delimiter = Adelimiter)

I get the traceback:


File /home/florian/visualizer/ConfigReader.py, line 13, in __init__
self.reader = csv.reader(f, delimiter = Adelimiter)
TypeError: bad argument type for built-in operation


The command

print Adelimiter: , Adelimiter, len(Adelimiter)

prints

Adelimiter:  , 1

So I think Adelimiter is ok?!

What is wrong there?

It is Python 2.3.5.

Thx,

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


Re: Listing of declared variables and functions

2005-05-11 Thread Cameron Laird
In article [EMAIL PROTECTED],
Fernando Perez  [EMAIL PROTECTED] wrote:
ohms377 wrote:

 Dear python users,
 
 In interactive mode, I was wondering if there is a way to list all
 declared variables and functions (and from global workspace).

In [1]: def foo(): pass
   ...:

In [2]: x=1

In [3]: a='hello'

In [4]: import re

In [5]: whos
Variable   TypeData/Info

a  str hello
foofunctionfunction foo at 0x403b725c
re module  module 're' from '/usr/lib/python2.3/re.pyc'
x  int 1

In [6]: whos int
Variable   TypeData/Info

x  int 1


This is using ipython for the interactive work.
.
.
.
Fernando's IPython is indeed a great thing, one I often recommend.
I think you might want to know, though, that local and global heaps
are readily available even without it:
  Python 2.3.5 (#2, Mar 26 2005, 17:32:32) 
  [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
  Type help, copyright, credits or license for more information.
   a = 3
   locals()
  {'__builtins__': module '__builtin__' (built-in), '__name__':
  '__main__', '__doc__': None, 'a': 3}
   globals()
  {'__builtins__': module '__builtin__' (built-in), '__name__':
  '__main__', '__doc__': None, 'a': 3}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using TCL files in Python ?

2005-05-11 Thread Cameron Laird
In article [EMAIL PROTECTED],
Peter Moscatt  [EMAIL PROTECTED] wrote:
I am reasonably new to programming in Python. [Using LINUX]

Up until now I have been using GUI widgets supplied by 'Tkinter' but
starting to realise that Tkinter have limited widgets.

I have been given the lead that I should look at other sources for GUI
widgets - namely TCL.

I have just done a search for 'tcl' files on my 'Fedora 3' installation
and find I have available:

  Tix8.1
  Tcl8.4
  Tk8.4

I have never used TCL code under Python so I assume I can use widgets from
any of these providers ?

Where is a good resource I can use to help understand how to use TCL files
in Python ?
.
.
.
It's likely to take a few rounds to make these things clear.  I'll start.

You want more widgets than base Tkinter supplies.  I understand that.
Please read URL: http://starship.python.net/crew/cjr/tkinter.html .

It is indeed useful to look to Tcl for functionality to use in Tkinter.
I detect a couple of missteps in how you're thinking about this, though.
First, Tcl adepts generally speak of Tk or Tcl/Tk when considering
widgetry; in idiomatic Tcl-speak, Tcl itself has no widgets.

You're right to mention Tix, Tk, and Tcl as Tcl-related installations
Fedora includes.  There actually are a few more, but you needn't concern
yourself with them now.  Of these, Tkinter already includes all the
functionality of Tcl and Tk, and the hyperlink provided above explains
Tix.

What if you encounter other Tcl packages?  Keep in mind that many Tcl
packages have nothing to do with graphical user interfaces (GUIs); they
do network programming or satellite management or locomotive control or
other domain-specific stuff that's orthogonal to GUIing.  Tkinter *can*,
generally, exploit Tcl-coded GUI extensions.  One of us will follow-up
with a reference to that topic.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with csv module

2005-05-11 Thread Richie Hindle

[Florian]
 I've one problem using the csv module.
 The code: 
 
 self.reader = csv.reader(f, delimiter = ,)
 
 works perfectly. But when I use a variable for delimiter:
 
 self.reader = csv.reader(f, delimiter = Adelimiter)
 
 I get the traceback:
 
 
 File /home/florian/visualizer/ConfigReader.py, line 13, in __init__
 self.reader = csv.reader(f, delimiter = Adelimiter)
 TypeError: bad argument type for built-in operation

Is this your problem?:

 Adelimiter = u','
 reader = csv.reader(f, delimiter=Adelimiter)
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: bad argument type for built-in operation
 print type(Adelimiter)
type 'unicode'

-- 
Richie Hindle
[EMAIL PROTECTED]

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


CGIHTTPServer on Windows?

2005-05-11 Thread Chris Curvey
Hi all,

I'm trying to work around my cgi-driving-IE problem by creating my own
server, but CGIHTTPServer on Windows (python 2.3.5) seems to be having
troubles.  Trying to run a hello world CGI gives me:

COMPAQ.ANTIQUES - - [11/May/2005 07:18:50] GET /cgi-bin/hello.py
HTTP/1.1 200
-
COMPAQ.ANTIQUES - - [11/May/2005 07:18:50] command: c:\program
files\python235\p
ython.exe -u C:\Documents and Settings\chris\My
Documents\cgi-bin\hello.py 
COMPAQ.ANTIQUES - - [11/May/2005 07:18:50] 'c:\program' is not
recognized as an
internal or external command,
operable program or batch file.

COMPAQ.ANTIQUES - - [11/May/2005 07:18:50] CGI script exit status 0x1

I tried hacking the source of do_POST to put quotes around the name of
the python executable and the script, but that didn't get me anywhere.
Is there a solution to this, or does this approach require me to use
pathnames without embedded spaces?

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


Re: Problems with csv module

2005-05-11 Thread Florian Lindner
Richie Hindle wrote:

 
 [Florian]
 I've one problem using the csv module.
 The code:
 
 self.reader = csv.reader(f, delimiter = ,)
 
 works perfectly. But when I use a variable for delimiter:
 
 self.reader = csv.reader(f, delimiter = Adelimiter)
 
 I get the traceback:
 
 
 File /home/florian/visualizer/ConfigReader.py, line 13, in __init__
 self.reader = csv.reader(f, delimiter = Adelimiter)
 TypeError: bad argument type for built-in operation
 
 Is this your problem?:
 
 Adelimiter = u','
 reader = csv.reader(f, delimiter=Adelimiter)
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: bad argument type for built-in operation
 print type(Adelimiter)
 type 'unicode'

Yes, thats my problem.

You mean that csv.reader can't work with unicode as the delimiter parameter?
Sorry, I don't really get your point what you're saying...

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


Re: Problems with csv module

2005-05-11 Thread Richie Hindle

[Florian]
 You mean that csv.reader can't work with unicode as the delimiter parameter?

Exactly.  http://www.python.org/doc/2.3.5/lib/module-csv.html says:

Note: This version of the csv module doesn't support Unicode input. Also,
there are currently some issues regarding ASCII NUL characters. Accordingly,
all input should generally be printable ASCII to be safe. These restrictions
will be removed in the future. 

That note is still there in the current development docs, so it looks like
it hasn't yet been fixed.

-- 
Richie Hindle
[EMAIL PROTECTED]

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


Re: Python Graphing Utilities.

2005-05-11 Thread Bill Mill
On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote:
 Hallöchen!
 
 Fernando Perez [EMAIL PROTECTED] writes:
 
  [...]
 
  And I'd also second the matplotlib suggestion, to which I've by
  now fully switched after years of faithful gnuplot usage.
  Matplotlib is very good, has an active development community, and
  it is designed from the ground up not only as a library for
  rendering plots to screen/disk, but also for embedding into guis
  (with support for Tk, WX, GTK, QT and FLTK).
 
 Why not for Gnuplot, by the way?
 
 On sceen, matplotlib looks extremely good, however, I still need
 Gnuplot for the hardcopy version[*].  It *seems* to me that the
 programming interfaces are quite different, so a Gnuplot backend for
 matplotlib would be helpful for me.

By hardcopy version, I assume you mean Postscript? From
http://matplotlib.sourceforge.net/fonts.html :

Postscript
Postscript, despite its age, is still a great output format. Most
publishers accept it, it scales to arbitrary resolutions, you can
import it directly into LaTeX document, and send it directly to
postscript printers.

The only requirement to generate postscript output is the Numeric
module and some AFM fonts on your system. Even the latter is only a
quasi-requirement, because matplotlib ships with some of the most
popular font files. These are Adobe Font Metric files, which have the
'*.afm' extension. matplotlib comes with it's own AFM parser to read
these files and select the best match for the font you've chosen. If
you want additional fonts, set the AFMPATH environment variable to
point to the dir containing your AFM font files. matplotlib willl
recursively search any directory in AFMPATH, so you only need to
specify a base directory if multiple subdirectories contaning '*.afm'
files.

Peace
Bill Mill
bill.mill at gmail.com

 
 Tschö,
 Torsten.
 
 [*] because of the pslatex backend, which means that the plot is
 typeset by the same LaTeX run as your document -- consistent fonts,
 TeX-quality formulae
 --
 Torsten Bronger, aquisgrana, europa vetus
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with csv module

2005-05-11 Thread Florian Lindner
Richie Hindle wrote:

 
 [Florian]
 You mean that csv.reader can't work with unicode as the delimiter
 parameter?
 
 Exactly.  http://www.python.org/doc/2.3.5/lib/module-csv.html says:
 
 Note: This version of the csv module doesn't support Unicode input. Also,
 there are currently some issues regarding ASCII NUL characters.
 Accordingly, all input should generally be printable ASCII to be safe.
 These restrictions will be removed in the future. 
 
 That note is still there in the current development docs, so it looks like
 it hasn't yet been fixed.

Uhh.. thanks!

How can I convert Unicode to ASCII?

Thx,

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


Re: Python Graphing Utilities.

2005-05-11 Thread Torsten Bronger
Hallchen!

Bill Mill [EMAIL PROTECTED] writes:

 On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote:

 Fernando Perez [EMAIL PROTECTED] writes:
 
 [...]

 [...]  Matplotlib is very good, has an active development
 community, and it is designed from the ground up not only as a
 library for rendering plots to screen/disk, but also for
 embedding into guis (with support for Tk, WX, GTK, QT and FLTK).
 
 Why not for Gnuplot, by the way?
 
 On sceen, matplotlib looks extremely good, however, I still need
 Gnuplot for the hardcopy version[*].  It *seems* to me that the
 programming interfaces are quite different, so a Gnuplot backend
 for matplotlib would be helpful for me.

 By hardcopy version, I assume you mean Postscript?

Not really.  Gnuplot's output is LaTeX with a couple of native
Postscript directives inbetween.  It's inluded into my document with
\input plot.plt rather than \includegraphics{plot.eps}.

I mentioned the advantages of this approach in the footnote:

 [...]

 [*] because of the pslatex backend, which means that the plot
 is typeset by the same LaTeX run as your document -- consistent
 fonts, TeX-quality formulae

Tsch,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
-- 
http://mail.python.org/mailman/listinfo/python-list

HELP Printing with wxPython

2005-05-11 Thread Mario
Hello all, I'm trying hard to make possible to print some simple text from
python to the default printer using wxPython, after days of internet
searches I found this page: http://wiki.wxpython.org/index.cgi/Printing but
is impossible to use this script even if I do exactly as said there. I think
the script is buggy or I am not able to use it, even if seems very simple to
use...

Anyone can give me an hint on how to easily and simply print some text? Is
there a library ready to download and use? Something like SendPrinter(some
text\n)?

Thanks in advance if anyone can give any help.

Mario


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


Re: Problems with csv module

2005-05-11 Thread Richie Hindle

[Florian]
 How can I convert Unicode to ASCII?

You're writing code using Unicode and you don't know how to convert it
ASCII?  You need to do some reading.  Here are a few links - Google can
provide many more:

  http://docs.python.org/tut/node5.html#SECTION00513
  http://diveintopython.org/xml_processing/unicode.html
  http://www.jorendorff.com/articles/unicode/python.html

The short answer to your question is this:

 U = u'My string'
 A = U.encode('ascii')
 print U, type(U), A, type(A)
My string type 'unicode' My string type 'str'

but you should really do some reading.

-- 
Richie Hindle
[EMAIL PROTECTED]

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


Re: Jabber/XML-RPC lib in Python?

2005-05-11 Thread Skip Montanaro

Michael I was wanting to write a program that lets two machines
Michael communicate (without user intervention) using XML-RPC over a
Michael Jabber network. Does anyone know of an existing library suited
Michael to that task?

Googling for Jabber XML-RPC Python yielded this as the first hit:

http://pyhacks.suddenthinks.com/

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


Re: Using TCL files in Python ?

2005-05-11 Thread Jeff Epler
While I've never used it, there *is* a Tix module in Python which
appears to wrap the widgets provided by Tix.  In Fedora Core 2, Python
doesn't seem to be configured to use Tix OOTB but a one-liner (that
should be harmless elsewhere) does make it work.

These classes are defined in the Tix module:
['Shell', 'Meter', 'TixSubWidget', 'ExFileSelectDialog',
'NoteBookFrame', 'DirSelectDialog', 'Control', 'LabelEntry',
'ButtonBox', 'ScrolledTList', 'Select', 'HList', 'Balloon', 'PopupMenu',
'DirSelectBox', 'ComboBox', 'ScrolledWindow', 'Grid', 'CheckList',
'DialogShell', 'Tree', 'DirList', 'ResizeHandle', 'NoteBook',
'ListNoteBook', 'ScrolledGrid', 'FileEntry', 'ScrolledHList', 'DirTree',
'OptionMenu', 'ScrolledText', 'LabelFrame', 'FileSelectBox',
'ScrolledListBox', 'InputOnly', 'PanedWindow', 'StdButtonBox',
'FileSelectDialog', 'CObjView', 'ExFileSelectBox', 'TList']

Here's what I did to get a simple Tix widget to work:
 import Tkinter, Tix
 t = Tkinter.Tk()
 t.tk.call(package, require, Tix)
'8.1.8.4'
 u = Tix.ComboBox(t)
 for i in range(30): u.insert(end, Item %d % i)
... 
 u.pack()

Jeff


pgpGhydrXScIo.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Replacing open builtin

2005-05-11 Thread rmm
If I replace the open builtin eg

import main
__main__.__builtins__.open=None

Is there any way, from here on, to access the original open function??

Extending this slightly, lets say I put a reference to the original
open function inside a class called Isolate and protect this reference
using __getattribute__ and __setattr__.  Is the original function now
isolated and only able to be referenced within Isolate.

In summary, are there any references to builtin functions others than
through __builtins__ and is __getattribute__, __setattr__ secure

Regards

RMM

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


libraries with distutils

2005-05-11 Thread Glenn Pierce
Hi I have a question about writing a portable setup.py script for distutils.

I have a directory structure like this.

FreeImage/
  |--Source/
  ||-- FreeImage.h
  |
  |--Dist/
  ||--FreeImage.lib
  ||--FreeImage.dll
  |
  |--Wrapper/
   |-Python/
   |--build/
   |
   
|--freeimagemodule.c
   |--setup.py



I want to create a setup file that works on both unix and Windows but I 
am having trouble with windows.
My setup.py file is like the following:

from distutils.core import setup, Extension

ext_module = Extension('freeimagewrapper',
define_macros = [('MAJOR_VERSION', '3'),
 ('MINOR_VERSION', '7')],
include_dirs = ['../../Source/'],
library_dirs=['../../Dist/'],
libraries = ['FreeImage'], 
sources = ['freeimagemodule.c'])

setup (name = 'freeimage',
   version = '1.0',
   author = 'Glenn Pierce',
   description = 'Python wrapper for the freeimage library',
   ext_modules = [ext_module])


I am getting link errors as vs can't seem to find ../../Dist/FreeImage.lib

The output is

running build
running build_ext
building 'freeimagewrapper' extension
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL 
/nologo
 /INCREMENTAL:NO /LIBPATH:../../Dist/ /LIBPATH:C:\Program 
Files\Python24\libs
/LIBPATH:C:\Program Files\Python24\PCBuild FreeImage.lib 
/EXPORT:initfreeimage
wrapper build\temp.win32-2.4\Release\freeimagemodule.obj 
/OUT:build\lib.win32-2.
4\freeimagewrapper.pyd 
/IMPLIB:build\temp.win32-2.4\Release\freeimagewrapper.lib

The errors are like

 Creating library build\temp.win32-2.4\Release\freeimagewrapper.lib and 
object
build\temp.win32-2.4\Release\freeimagewrapper.exp
freeimagemodule.obj : error LNK2019: unresolved external symbol 
_FreeImage_Unloa
d referenced in function _destroy

Also I guess when the python module is installed it will still need to 
find FreeImage.dll in a libray path searched by the system or will 
distutils place the actual dll and lib files where thay can be found ?

I have read the distutils guide but wasn't clear on the library section 
for ext modules.

Thanks for any help.

Glenn

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


Interactive shell for demonstration purposes

2005-05-11 Thread Brian Quinlan
Can anyone recommend a Python interactive shell for use in presentations?

Ideal characteristics (priority order):
o configurable font size
o full screen mode
o readline support
o syntax coloring

I've tried ipython but, since it runs inside a console window, and the 
console window has a limited number of selectable fonts, it doesn't 
work terribly well.

I've seen presentations using some sort of PyGame implemented shell. 
Does anyone have an information on that?

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


RE: Interactive shell for demonstration purposes

2005-05-11 Thread Tim Golden
[Brian Quinlan]
| 
| Can anyone recommend a Python interactive shell for use in 
| presentations?
| 
| Ideal characteristics (priority order):
| o configurable font size
| o full screen mode
| o readline support
| o syntax coloring
| 
| I've tried ipython but, since it runs inside a console 
| window, and the 
| console window has a limited number of selectable fonts, it doesn't 
| work terribly well.
| 
| I've seen presentations using some sort of PyGame implemented shell. 
| Does anyone have an information on that?

Warning: untested response.

Since I remembered that Michael Hudson had done such
a thing once, I Googled and came across this:

http://codespeak.net/py/current/doc/execnet.html

which might get you started.

TJG


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

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


Re: Replacing open builtin

2005-05-11 Thread rmm
Sorry, should maybe have used __import__ as an example.
Let's say I grab import, store the reference within the Isolate class
and then redirect the builtin import to a function in the Isolate class
which only allows certain modules to be imported -eg not sys.   Would
this be secure?

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


Question about XML Parser in Python.

2005-05-11 Thread Amitpython5



Hello,

 Well, I'm fairly new to Python and have encountered a strange error 
while reading an XML document in Python. I used the SAX parser, and my input XML 
is fairly large with 30 records. I extract about 25 fields from each record 
and spit out a csv file. The strange thing is that after about 2000 records, 
some value (one of the 25) is missing in the csv file, so it just appears as 
',,', as if the value was missing from the Input file. I checked the Input file 
and all values are intact.

 It is not field specific, as this behavior is repeated for different 
fields every time. I'm really confused, is this a bug with the parser? or just 
too many records to process?

Please help.

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

Importing modules

2005-05-11 Thread qwweeeit
The pythonic way of programming requires, as far as I know, to spread a
big application in plenty of more manageable scripts, using import or
from ... import to connect the various modules.
In some cases there is a further complication: module importing through
an indirect mechanism, like: exec from  + xxx +  import *.

A part the fact that I have not understood the real difference
between import and from ... import (or also from... import *), is it
possible to re-build the application in only one chunck?
This is only to better understand the application's structure, in order
to implement a flow chart tool.

I have already developed a cross reference tool and I applied it to
PySol (solitary card games). PySol is made up of almost 100 modules for
a total of almost 3 lines.
To understand a program, however, you need also a flow chart...

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


Re: Encryption with Python?

2005-05-11 Thread Peter Hansen
Robert Kern wrote:
 Peter Hansen wrote:
 
 Back to Paul's question then: why use an unreliable and 
 probably-useless-for-all-but-spawning-lengthy-but-educational-threads 
 encryption method when there are relatively reliable and, uh, less 
 discussed and non-edifying, uh... well, you get the picture. ;-)
 
 Well, I'd say ARCFOUR has been discussed a hell of a lot more than what 
 this thread ever mustered up. I also submit that implementing ARCFOUR or 
 studying p3.py would be a hell of a lot more educational than posting a 
 lousy algorithm, calling it unbreakable, and responding to criticisms 
 with I don't understand so you must be wrong.
 
 Education is a process one must engage in. You don't just step in it.

The education to which I was referring was that which _most_ of us just 
received by reading Paul's and your replies, not from anything in the 
OP's postings.  ;-)

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


Re: Python Graphing Utilities.

2005-05-11 Thread Bill Mill
On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote:
 Hallöchen!
 
 Bill Mill [EMAIL PROTECTED] writes:
 
  On 5/11/05, Torsten Bronger [EMAIL PROTECTED] wrote:
 
  Fernando Perez [EMAIL PROTECTED] writes:
 
  [...]
 
  [...]  Matplotlib is very good, has an active development
  community, and it is designed from the ground up not only as a
  library for rendering plots to screen/disk, but also for
  embedding into guis (with support for Tk, WX, GTK, QT and FLTK).
 
  Why not for Gnuplot, by the way?
 
  On sceen, matplotlib looks extremely good, however, I still need
  Gnuplot for the hardcopy version[*].  It *seems* to me that the
  programming interfaces are quite different, so a Gnuplot backend
  for matplotlib would be helpful for me.
 
  By hardcopy version, I assume you mean Postscript?
 
 Not really.  Gnuplot's output is LaTeX with a couple of native
 Postscript directives inbetween.  It's inluded into my document with
 \input plot.plt rather than \includegraphics{plot.eps}.
 
 I mentioned the advantages of this approach in the footnote:
 

Tha's cool, I saw what you wrote. First off, I wasn't sure what you
meant by hardcopy, so I thought I'd let you know that matplotlib has
PS output. Second, the page I linked to talks about all the font-type
features of matplotlib, which I thought might interest you. Having not
gotten funky with them, I cannot vouch for their quality.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HELP Printing with wxPython

2005-05-11 Thread Tim G
 Hello all, I'm trying hard to make possible to print some simple text
from
 python to the default printer using wxPython, after days of internet
 searches I found this page:
http://wiki.wxpython.org/index.cgi/Printing but
 is impossible to use this script even if I do exactly as said there.
I think
 the script is buggy or I am not able to use it, even if seems very
simple to
 use...

 Anyone can give me an hint on how to easily and simply print some
text? Is
 there a library ready to download and use? Something like
SendPrinter(some
 text\n)?

On the strict wxPython front, I can't help
you, but I might be able to offer some help.
Depends a little bit on how much you're tied
to wxPython and how much you need to be cross-platform.

Essentially, if you're on Windows (and have no need
to run on anything else) then consider some of the
solutions here:

http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html

If you're on Unix / whatever with no need to do
anything else, then I'm sure there are straightforward
ways to push stuff to a printer. (Something using lpr
he thinks, hoping someone with real knowledge can chip
in).

If you *really* want to use wxPython for cross-platform
needs, or just because you think it's cleaner, then try
on the wxPython lists if you haven't already.

TJG

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


Re: Replacing open builtin

2005-05-11 Thread Jp Calderone
On 11 May 2005 05:56:04 -0700, [EMAIL PROTECTED] wrote:
Sorry, should maybe have used __import__ as an example.
Let's say I grab import, store the reference within the Isolate class
and then redirect the builtin import to a function in the Isolate class
which only allows certain modules to be imported -eg not sys.   Would
this be secure?


  Probably not.  For example:

 (1).__class__.__bases__[0].__subclasses__()[-1]('/dev/null')
open file '/dev/null', mode 'r' at 0xb7df53c8

  Security through subtracting features usually ends up leaving some holes 
around (because there's just that *one* more thing you missed).  What the holes 
are depends on the details of the implementation, but they pretty much always 
exist.  Making a reference-restricted Python interpreter is a large challenge: 
you either have to spend a huge amount of effort taking things out of CPython 
(months and months of development time, at least), or write a new interpreter 
from scratch.

  Older versions of Python thought they had this licked, see the rexec module 
for the attempt that is no longer maintained.

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


RE: Interactive shell for demonstration purposes

2005-05-11 Thread Jp Calderone
On Wed, 11 May 2005 13:55:38 +0100, Tim Golden [EMAIL PROTECTED] wrote:
[Brian Quinlan]
|
| Can anyone recommend a Python interactive shell for use in
| presentations?
|
| Ideal characteristics (priority order):
| o configurable font size
| o full screen mode
| o readline support
| o syntax coloring
|
| I've tried ipython but, since it runs inside a console
| window, and the
| console window has a limited number of selectable fonts, it doesn't
| work terribly well.
|
| I've seen presentations using some sort of PyGame implemented shell.
| Does anyone have an information on that?

Warning: untested response.

Since I remembered that Michael Hudson had done such
a thing once, I Googled and came across this:

http://codespeak.net/py/current/doc/execnet.html

which might get you started.


  execnet lets you easily run arbitrary Python code on remote hosts.  This 
doesn't seem too closely related to the OP's question, which seems directed at 
finding a pretty GUI to display the results of such execution.

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


Re: Put a file on an ftp server over ssl

2005-05-11 Thread Rick Holbert
Have a look at Putty's pscp and PySCP...

http://www.chiark.greenend.org.uk/~sgtatham/putty/
http://py.vaults.ca/apyllo.py/990075885.195097684.69935243

Rick

Lars wrote:

 Daniel,
 
 Why don't you just use the 'sftp' command line program, it's available
 for all unixes and I bet you can find a build for windows to? Then you
 could just do an os.system(..) and be done with it.
 
 Cheers!
 Lars

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


Re: Encryption with Python?

2005-05-11 Thread Robert Kern
Peter Hansen wrote:

Education is a process one must engage in. You don't just step in it.
 
 The education to which I was referring was that which _most_ of us just 
 received by reading Paul's and your replies, not from anything in the 
 OP's postings.  ;-)

Okay, I'll buy that.  :-)

-- 
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: Interactive shell for demonstration purposes

2005-05-11 Thread Tim Golden
[Jp Calderone]
| 
| [Tim Golden ]
|
| [Brian Quinlan]
| |
| | Can anyone recommend a Python interactive shell for use in
| | presentations?
|
|  I Googled and came across this:
| 
| http://codespeak.net/py/current/doc/execnet.html
| 
| which might get you started.
| 
| 
|   execnet lets you easily run arbitrary Python code on remote 
| hosts.  This doesn't seem too closely related to the OP's 
| question, which seems directed at finding a pretty GUI to 
| display the results of such execution.
| 
|   Jp

Sorry. Quite right. I assumed that because it referred to
the demo system I vaguely remembered hearing about from
EuroPython, it was doing something similar enough to be
useful. That'll teach me to respond too quickly.

TJG


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

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


Decompyle will not Compile.

2005-05-11 Thread eternl_knight
Ironically enough - the decompyle module will not compile on my
machine. I am using Python 2.2 and MSVC7 (i.e. .NET). However it tells
me there is an undefined external as follows:

marshal_22_for_20.obj : error LNK2001: unresolved external symbol
initdecompyle/marshal_20

I am writing code for Poser 6 (which has not as yet updated to the
latest Python) and have just lost a substantial chunk of code - part of
which being an algorithm I have been tweaking for a couple of weeks
now. As such, getting even part of the PYC to decompile would be a
great help.

Thanks,
B.J.Tolputt

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


Re: Python Graphing Utilities.

2005-05-11 Thread Robert Kern
Bill Mill wrote:

 Tha's cool, I saw what you wrote. First off, I wasn't sure what you
 meant by hardcopy, so I thought I'd let you know that matplotlib has
 PS output. Second, the page I linked to talks about all the font-type
 features of matplotlib, which I thought might interest you. Having not
 gotten funky with them, I cannot vouch for their quality.

They're not TeX-quality. Yet.

A pslatex backend certainly would be interesting. A Gnuplot backend 
would probably not be feasible. Does it expose its raw drawing operations?

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


FutureWarning in win32com?

2005-05-11 Thread Chris Curvey
Hi all,

When trying to automate IE thru win32com (using PAMIE), I'm getting
this message out

C:\Program Files\Plone
2\Python\lib\site-packages\win32com\client\dynamic.py:463
: FutureWarning: %u/%o/%x/%X of negative int will return a signed
string in Pyth
on 2.4 and up
  debug_attr_print(Getting property Id 0x%x from OLE object %
retEntry.dispid)

The underlying code works fine (the browser ends up where it's supposed
to), but this warning seems to be actually sent to stdout or stderr --
it's not a raised exception that I can catch.

How can I suppress this message?

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


Re: Interactive shell for demonstration purposes

2005-05-11 Thread Ville Vainio
 Brian == Brian Quinlan [EMAIL PROTECTED] writes:

Brian Can anyone recommend a Python interactive shell for use in
Brian presentations?

Brian I've tried ipython but, since it runs inside a console
Brian window, and the console window has a limited number of
Brian selectable fonts, it doesn't work terribly well.

Hmm, do you consider the fonts in a console window unreadable? I've
given a few presentations using ipython on win32 and it worked alright
- but I suppose the projector quality is a factor here...

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread Peter Hansen
Roy Smith wrote:
 The most common immutable objects you'll see are strings and tuples, and 
 the main reason they're immutable is to allow them to be dict keys.

And ints.  Strings, tuples and ints are the *three* most common 
immutable objects you'll see...

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


Re: Replacing open builtin

2005-05-11 Thread rmm
I had a quick look at the python source code and fileobject.c is one of
the core classes which, I would imagine, is why a reference can be
obtained.  The other classes (method, dictionaries etc) don't look so
much of a liability.  I'll maybe try disabling the fopen calls in
fileobject and see if it breaks anything (I've no need to open/close
files using the standard libraries).

Are there any other holes you can think of in the following scenario-
I disable all builtins except import which I protect in my 'Isolate'
class, I then only allow import to import a single module name.

Thanks for the speedy and informative replies.

RMM

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


Re: Pipes of binaries - IPC::Run

2005-05-11 Thread Peter Hansen
Swaroop C H wrote:
 Is there a Python equivalent of Perl's IPC::Run module [
 http://search.cpan.org/dist/IPC-Run/lib/IPC/Run.pm ] ?

I don't know Perl, and don't plan to read all of that page you 
referenced, but judging from the subject line and the half-sentence 
description near the top of that page, you are looking for:

os.system
os.popen
popen2 (module)
subprocess (module, in 2.4)

Read about each and, preferring subprocess (as the most recent), try 
them out for yourself.

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


Re: Reading files into a 2D list.

2005-05-11 Thread Larry Bates
Few observations.

1) Don't concatenate pathnames yourself use os.path.join, that
makes your code portable.

lexi_file = open(os.path.join(sys.path[0],lexi,files), r)

2) Start with an empty list and append your lines lists:

files_and_lines=[]
filenumber = 0

for files in file_names:
fpath=os.path.join(sys.path[0]),lexi, files)
try:
lexi_file = open(fpath, r)
files_and_lines.append(lexi_file.readlines())

except(IOError):
print Something went wrong trying to read the file:
print '%s' % fpath

lexi_file.close() # Remember to close each file

Now you have:

files_and_lines[0][0] - Line 1 of the first file
files_and_lines[0][1] - Line 2 of the first file
.
.
.
files_and_lines[0][n] - Line n of the first file
files_and_lines[1][0] - Line 1 of the second file
.
.
.

Larry Bates

Oyvind Ostlund wrote:
 I am not sure what the right syntax is here. So please help me out (started 2 
 days ago).
 
 I have a list of about 20 files that I want to read line by line into a 2D 
 list. So the first dimension will be each file, and the second every line in 
 that file.
 
 
 I tried to do something like this:
 
 files_and_lines = [][]
 filenumber = 0
 
 for files in file_names:
 try:
 lexi_file = open(str(sys.path[0]) + /lexi/ + files, r)
 files_and_lines[filenumber] = lexi_file.readlines()
 filenumber = filenumber + 1
 
 except(IOError):
 print Something went wrong trying to read the file:
 print ' + str(sys.path[0]) + files + '
 
 
 
 But that was not very sucksessfully. I am not even sure on how to define an 
 empty 2D list. Thanks for all help.
 
 ØØ

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


Re: HELP Printing with wxPython

2005-05-11 Thread James Carroll
Hi Mario,

  Something like SendPrinter(some text\n)?

If you are doing this just for yourself, and you know you have a
printer that will really print just the plain text when you send it
plain text (like a dot matrix printer from the early 90s) then you can
probably open the printer device  and send it text.  Under windows you
can try opening LPT1  or on unix it's probably /dev/lpr or something
like that.

wxPython makes it pretty easy to give full modern support for any
printer, including letting the user select which printer to print to,
and getting a print preview, choosing paper size, etc.

I especially like the HtmlEasyPrinting write-up here:
   http://wiki.wxpython.org/index.cgi/Printing

-Jim




On 5/11/05, Mario [EMAIL PROTECTED] wrote:
 Hello all, I'm trying hard to make possible to print some simple text from
 python to the default printer using wxPython, after days of internet
 searches I found this page: http://wiki.wxpython.org/index.cgi/Printing but
 is impossible to use this script even if I do exactly as said there. I think
 the script is buggy or I am not able to use it, even if seems very simple to
 use...
 
 Anyone can give me an hint on how to easily and simply print some text? Is
 there a library ready to download and use? Something like SendPrinter(some
 text\n)?
 
 Thanks in advance if anyone can give any help.
 
 Mario
 
 --
 http://mail.python.org/mailman/listinfo/python-list
 

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


Re: HELP Printing with wxPython

2005-05-11 Thread Larry Bates
Mario,

Here is a function stripped from a working program that uses printpreview
from wxWindows to print out cells from a grid that the user is working
on.  Hopefully this can point you in the proper direction.

Regards,
Larry Bates

def DO_printpreview(self, event):
if self._trace:
self.logf.writelines(T,Entering OuterFrame.DO_printpreview)
self.SetStatusText('Generating Print Preview', 0)
#
# Define the columns on the printout
#
columndefs=((Cust#,8.0/16.0, wxALIGN_LEFT),
(Customer Name,   29.0/16.0, wxALIGN_LEFT),
(Reference,   16.0/16.0, wxALIGN_LEFT),
(Type, 6.0/16.0, wxALIGN_CENTRE),
(Inv. #,   8.0/16.0, wxALIGN_CENTRE),
(InvDate,  9.0/16.0, wxALIGN_CENTRE),
(L#,   4.0/16.0, wxALIGN_CENTRE),
(Item #,  12.0/16.0, wxALIGN_CENTRE),
(Item Description,45.0/16.0, wxALIGN_LEFT),
(Qty,  6.0/16.0, wxALIGN_RIGHT),
(Cost,10.0/16.0, wxALIGN_RIGHT),
(OMMC $,  10.0/16.0, wxALIGN_RIGHT)
)
columncount=len(columndefs)
#
# Create a new frame for the print preview and give it to PrintTable
#
self.previewframe=PreviewFrame(None, sys.stdout)
if self._trace:
log.writelines(T,DO_ppv-Creating PrintTable instance)
prt=PrintTable(self.previewframe)
#
# Set printout column widths
#
if self._trace: self.logf.writelines(T,DO_ppv-Setting column widths)
prt.set_column=[a[1] for a in columndefs]
#
# Set the column labels (headings)
#
if self._trace:
self.logf.writelines(T,DO-ppv-Setting column headings)
prt.label=[a[0] for a in columndefs]
#
# Set the column alignments
#
if self._trace:
self.logf.writelines(T, DO-ppv-Setting column alignments)
map(prt.SetColAlignment, range(columncount), [a[2] for a in columndefs])
#
# Get the data values from the grid that are selected
#
data=self._getdata('1')
#
# Skip the first (flag) column and columns 11,13,15,16
# to delete them from the printout.
#
data=[[v[1],v[2],v[3],v[4][0:2],v[5],v[6],
   v[7],v[8],v[9],v[10],v[12],v[14]] for v in data]
#
# Loop over the lines and insert a blank line between customers
#
blankline=columncount*['']# Create a blank output line
lastcustomer=None
pdata=[]
for values in data:
if lastcustomer != None and values[0] != lastcustomer:
pdata.append(blankline)

lastcustomer=values[0]
pdata.append(values)

pdata.append(blankline)
prt.data=pdata
prt.left_margin=0.3
prt.SetLandscape()
prt.SetHeader(OMMC Recap Listing-Hardware Items)
prt.SetFooter()
prt.SetFooter(Date: , type = Date  Time, \
   align=wxALIGN_LEFT, \indent=prt.left_margin)
#
# Override the default font sizes
#
prt.text_font_size = 8
#prt.label_font_size= 7
prt.cell_left_margin = 1.0/32.0
prt.Preview()
if self._trace:
self.logf.writelines(T,Entering OuterFrame.DO_printpreview)
return


Mario wrote:
 Hello all, I'm trying hard to make possible to print some simple text from
 python to the default printer using wxPython, after days of internet
 searches I found this page: http://wiki.wxpython.org/index.cgi/Printing but
 is impossible to use this script even if I do exactly as said there. I think
 the script is buggy or I am not able to use it, even if seems very simple to
 use...
 
 Anyone can give me an hint on how to easily and simply print some text? Is
 there a library ready to download and use? Something like SendPrinter(some
 text\n)?
 
 Thanks in advance if anyone can give any help.
 
 Mario
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decompyle will not Compile.

2005-05-11 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
 I am writing code for Poser 6 (which has not as yet updated to the
 latest Python) and have just lost a substantial chunk of code - part of
 which being an algorithm I have been tweaking for a couple of weeks
 now. As such, getting even part of the PYC to decompile would be a
 great help.

Apparently this site will let you get your code back, though for a fee. 
  Not sure you were aware of it.

http://www.crazy-compilers.com/decompyle/service.html

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


Re: Replacing open builtin

2005-05-11 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
 I had a quick look at the python source code and fileobject.c is one of
 the core classes which, I would imagine, is why a reference can be
 obtained.  The other classes (method, dictionaries etc) don't look so
 much of a liability.  I'll maybe try disabling the fopen calls in
 fileobject and see if it breaks anything (I've no need to open/close
 files using the standard libraries).
 
 Are there any other holes you can think of in the following scenario-
 I disable all builtins except import which I protect in my 'Isolate'
 class, I then only allow import to import a single module name.

You *really* ought to be checking the list archives for the *many* past 
discussions of this, and the many ways in which it is nowhere near as 
easy as you seem to think it might be, as well as for the variety of 
partially completed efforts -- some of which closely resemble your 
approach -- which have been abandoned after it was demonstrated how the 
could not work.

On the other hand, after reading all that, you just might be the one to 
come up with the solution that combines just enough of each approach to 
solve the problem once and for all, and the community would be very 
grateful to you.

But I doubt you'll solve this by asking Jp to review (and, inevitably, 
shoot down) each idea you come up with.  Give him a break until you've 
read some of the archived material on this. :-)

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


RE: Reading files into a 2D list.

2005-05-11 Thread Oyvind Ostlund
 Thanks a lot. That works great. I can't belive how close I was in the end. 
Well that was the last lines of this application, so thanks a lot.

And thanks for the tip about the portability stuff. I can't belive I didn't 
think about that. Been writing to much in non portable languages and libs like 
DirectX lately.


Thanks
ØØ

-Original Message-
From: Larry Bates [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 11, 2005 3:55 PM
To: Oyvind Ostlund
Cc: python-list@python.org
Subject: Re: Reading files into a 2D list.

Few observations.

1) Don't concatenate pathnames yourself use os.path.join, that makes your code 
portable.

lexi_file = open(os.path.join(sys.path[0],lexi,files), r)

2) Start with an empty list and append your lines lists:

files_and_lines=[]
filenumber = 0

for files in file_names:
fpath=os.path.join(sys.path[0]),lexi, files)
try:
lexi_file = open(fpath, r)
files_and_lines.append(lexi_file.readlines())

except(IOError):
print Something went wrong trying to read the file:
print '%s' % fpath

lexi_file.close() # Remember to close each file

Now you have:

files_and_lines[0][0] - Line 1 of the first file files_and_lines[0][1] - Line 
2 of the first file .
.
.
files_and_lines[0][n] - Line n of the first file files_and_lines[1][0] - Line 
1 of the second file .
.
.

Larry Bates

Oyvind Ostlund wrote:
 I am not sure what the right syntax is here. So please help me out (started 2 
 days ago).
 
 I have a list of about 20 files that I want to read line by line into a 2D 
 list. So the first dimension will be each file, and the second every line in 
 that file.
 
 
 I tried to do something like this:
 
 files_and_lines = [][]
 filenumber = 0
 
 for files in file_names:
 try:
 lexi_file = open(str(sys.path[0]) + /lexi/ + files, r)
 files_and_lines[filenumber] = lexi_file.readlines()
 filenumber = filenumber + 1
 
 except(IOError):
 print Something went wrong trying to read the file:
 print ' + str(sys.path[0]) + files + '
 
 
 
 But that was not very sucksessfully. I am not even sure on how to define an 
 empty 2D list. Thanks for all help.
 
 ØØ

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


Re: Interactive shell for demonstration purposes

2005-05-11 Thread Brian Quinlan
Ville Vainio wrote:
 Hmm, do you consider the fonts in a console window unreadable? 

In fullscreen mode, yes (you get no choice of font size in Windows XP).
In Windowed mode you still only get a limited font selection (only two 
fonts and only a few type sizes [most of which are small]).

 I've
 given a few presentations using ipython on win32 and it worked alright
 - but I suppose the projector quality is a factor here...

I'll get by but I was hoping for something better.

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


reg mail sending without smtp module

2005-05-11 Thread praba kar
Dear All,

 Is it possible to send a message as a mail
with out smtplib module?  If you find out any module
for mail sending(without smtplib) kindly mail me.

regards
Prabahar
 


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread Grant Edwards
On 2005-05-11, Roy Smith [EMAIL PROTECTED] wrote:

 The most common immutable objects you'll see are strings and tuples,

And integers.  They're immutable, aren't they?  At least the
small ones.  And floats.

-- 
Grant Edwards   grante Yow!  .. bleakness
  at   desolation plastic
   visi.comforks...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread Grant Edwards
On 2005-05-11, Peter Hansen [EMAIL PROTECTED] wrote:

 The most common immutable objects you'll see are strings and
 tuples, and the main reason they're immutable is to allow them
 to be dict keys.

 And ints.  Strings, tuples and ints are the *three* most
 common immutable objects you'll see...

Right.  In Python, strings tuples and ints are the five most
common immutable objects you'll see.

-- 
Grant Edwards   grante Yow!  You were s'posed
  at   to laugh!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


pylab: plot update

2005-05-11 Thread Jan Wienhausen
Hi,
I need to do a plot of data that is beeing acuired. For that the plot 
needs to be updated after aquiering a new tuple.
At the moment I allways do this after a new tuple is aqcuired:

plot(ar[0,i-1:i],br[1,i-1:i],'ro')
show()
#ar is arrays were the new tuple is put in position [0,i] and [1,i]

After that i call sleep(5) until I can acuire the next tuple.
But during that I can't use the zoom/pan, save etc in the window.

Moreover the first time I call plot and show the first point is drawn 
correctly but I have to close the window otherwise the program does not 
run any further. But after closing the window ones it runs without any 
problems.

Is there any better way to do this easily?

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


Re: Python Graphing Utilities.

2005-05-11 Thread Torsten Bronger
Hallchen!

Robert Kern [EMAIL PROTECTED] writes:

 [...]

 A pslatex backend certainly would be interesting. A Gnuplot
 backend would probably not be feasible. Does it expose its raw
 drawing operations?

Probably not raw enough, but I don't know how basic matplotlib
wants it to be.  You could switch the axes off and draw everything
as lines using plot coordinates, but I don't know how sensible this
would be.

On the other hand, the pslatex output of Gnuplot is one of the
very few things that hold me there.  If matplotlib produced
something equivalent, (at least) I wouldn't call for a Gnuplot
backend anymore.

Tsch,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
-- 
http://mail.python.org/mailman/listinfo/python-list

CHANGE BayPIGgies: May *THIRD* Thurs

2005-05-11 Thread Aahz
Reminder:

We will *NOT* be meeting the *SECOND* Thursday (this week, May 12).

Our May meeting will be the *THIRD* Thursday, May 19.  This will be our
first meeting at Google, with Alex Martelli's presention on design
patterns.  More details soon!
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

And if that makes me an elitist...I couldn't be happier.  --JMS
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reg mail sending without smtp module

2005-05-11 Thread John Abel
praba kar wrote:

Dear All,

 Is it possible to send a message as a mail
with out smtplib module?  If you find out any module
for mail sending(without smtplib) kindly mail me.

regards
Prabahar
 


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
  

socket

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


Fwd: Interactive shell for demonstration purposes

2005-05-11 Thread James Carroll
-- Forwarded message --
From: James Carroll [EMAIL PROTECTED]
Date: May 11, 2005 10:43 AM
Subject: Re: Interactive shell for demonstration purposes
To: Brian Quinlan [EMAIL PROTECTED]


I would personally try looking at the PyCrust.py that's included with
wxPython.  It has a standard shell, and you can use the Ctrl-]  hotkey
to increase the font size.  You can make it big and readable...  (but
not bold, which would be nice.)  Then, hide your taskbars (or system
menus) and maximize...

-Jim


On 5/11/05, Brian Quinlan [EMAIL PROTECTED] wrote:
 Ville Vainio wrote:
  Hmm, do you consider the fonts in a console window unreadable?

 In fullscreen mode, yes (you get no choice of font size in Windows XP).
 In Windowed mode you still only get a limited font selection (only two
 fonts and only a few type sizes [most of which are small]).

  I've
  given a few presentations using ipython on win32 and it worked alright
  - but I suppose the projector quality is a factor here...

 I'll get by but I was hoping for something better.

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


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


Re: Supercomputer and encryption and compression @ rate of 96%

2005-05-11 Thread TZOTZIOY
On Mon, 2 May 2005 23:11:54 +0530, rumours say that km
[EMAIL PROTECTED] might have written:

Hi all,

This was posted long ago.
I tried to compress a  mp3 file but i couldnt get the keycode+.out file 
which is of size 1 bit. instead it is printed to STDOUT. i am usng python 2.4 
. i understand that the keycode is embedded in the filename itself. Is it a 
problem with python not able to create a file with such a big filename ? 
any workarounds ? 

Ah...

Perhaps your humour is too subtle for me, in which case my reply is
totally off.  In any case:

Python does not restrict filename lengths; it happily creates filenames
of length less than or equal to the limit imposed by the underlying
operating system.

Now, in our universe there cannot be a compression algorithm that
reduces entropy and file size at the same time.  The code was a joke (I
even suggested a correction, which was a mistake because I hadn't
understood the full joke[1] :)

[snip effbot's code]


[1] I thought that Fredrik just made up something that looked like
working, and he explained that his code *was* working.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or PHP?

2005-05-11 Thread TZOTZIOY
On Tue, 26 Apr 2005 00:35:59 GMT, rumours say that Jorey Bump
[EMAIL PROTECTED] might have written:

Lad [EMAIL PROTECTED] wrote in news:1114254894.512656.297040
@l41g2000cwc.googlegroups.com:

 Is anyone capable of providing Python advantages over PHP if there are
 any?


As you learn Python, you will find that your PHP code will improve, 
possibly becoming more and more concise until it disappears completely.

+1 QOTW
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Args By Reference

2005-05-11 Thread ncf
Thanks to everyone for your assistance. I shall reread this a couple
times and then try to make something that works.

Many thanks and have a GREAT day.
-Wes

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


Re: Regarding Mail sending smtplib Module

2005-05-11 Thread Sion Arrowsmith
praba kar  [EMAIL PROTECTED] wrote:
Here I want to avoid this line Received: from unknown
(HELO prabahar.enmail.com) (59.92.13.47)  by
mailserver with SMTP; 11 May 2005 10:09:11 -  How
can I do this? . Why python give this line? . Mail
sending Module in php will not give this type line.

To quote http://docs.python.org/lib/SMTP-objects.html :
The SMTP[sic] does not modify the message headers in any way.
The Received: header is being added by your SMTP server. Goodness
knows how PHP avoids it -- direct use of sendmail maybe?

Here I have another doubt Php mail sending module give
MessageId automatically
but python doesn't set that. why?

Because The SMTP[sic] does not modify the message headers in
any way. Or, to look at it another way, there are obvious
advantages to having message ids created by the client app
rather than the library. (OTOH, the library author is more
likely to write better id-producing code than the average
client app author, but IMHO this is outweighed by the greater
utility of having the app do it and the consistency of not
having SMTP touch the headers.) If PHP mail adds a message id,
that would be consistent with it using sendmail rather than
talking directly to the SMTP server.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: reg mail sending without smtp module

2005-05-11 Thread Tim Williams
- Original Message - 
From: John Abel [EMAIL PROTECTED]


 praba kar wrote:

 Dear All,
 
  Is it possible to send a message as a mail
 with out smtplib module?  If you find out any module
 for mail sending(without smtplib) kindly mail me.
 
 regards
 Prabahar
 

 socket


Telnetlib,   though you will effectively have to write your own SMTP client
(ie your own version of smtplib).

Why don't you want to use smtplib ?

:)

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


Re: pyvm -- faster python

2005-05-11 Thread Cameron Laird
In article [EMAIL PROTECTED],
Roger Binns [EMAIL PROTECTED] wrote:
 could You tell us a bit more about Your motivation to create an
 alternative C-Python interpreter?

I'd also be curious to know if the performance gains would remain
once it gets fleshed out with things like closures, long numbers,
new style classes and a C library compatibility shim.

Roger 



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


Re: Regarding Mail sending smtplib Module

2005-05-11 Thread Tim Williams
praba kar  [EMAIL PROTECTED] wrote:
Here I want to avoid this line Received: from unknown
(HELO prabahar.enmail.com) (59.92.13.47)  by
mailserver with SMTP; 11 May 2005 10:09:11 -  How
can I do this? . Why python give this line? . Mail
sending Module in php will not give this type line.

Received headers are added by the receiving server, not by smtplib

The unknown refers to the DNS PTR (ie hostname) or lack of one,  of the
machine/address that the email was received from.

HTH :)


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


Re: Solipsis: Python-powered Metaverse

2005-05-11 Thread Paul McNett
Ville Vainio wrote:
Paul == Paul McNett [EMAIL PROTECTED] writes:
 
 
 Paul Only, I couldn't hear what they said back to me because I
 Paul don't have UDP port 6000 open on my firewall and forwarding
 Paul to my laptop (and don't want to do that either).
 
 Paul It is a shame: peer to peer has the potential to enable
 Paul really cool, imaginative multiuser worlds, but how many
 Paul people are connecting directly to the internet these days?
 
 FWIW, In Finland all home *DSL and Cable internet connections (that I
 know of) are connected directly to the internet (in the sense that
 all ports are open). Blocking is reserved for the modem, just the way
 it should be...

Sure, that's how it is here in the US too. You have a modem/router
supplied by the cable or DSL company that provides DHCP and NAT for
outbound traffic. The fact that the internal computers have private
addresses (eg 192.168.1.5) keeps them from being accessed directly from
the outside. The modem still gets access to all ports[1], and most have
ways to set up simple port forwarding to, say, listen for UDP traffic
on port 6000 and forward it on to 192.168.1.20.

The problem is, that last step required setup by the user of one of the 
computers in the LAN. Sure, this is a home so there is likely only one 
or two computers in the LAN, but it is still a painful thing to ask 
normal users to configure their firewall, and what if both computers 
wanted to participate on the port 6000 fun?

[1] Although, some ISP's are taking it upon themselves to drop or reject 
port 25 traffic. A wrong but understandable stopgap solution to the 
problem of peoples toy machines getting infected by malware - at least 
those machines won't be able to send mailbombs anywhere else.

-- 
pkm ~ http://paulmcnett.com


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


Re: __brace__ (PEP?)

2005-05-11 Thread Terry Hancock
On Sunday 08 May 2005 06:29 pm, James Stroud wrote:
 If __call__ allows anobject() and __getitem__ allows anobject[arange], 
 why 
 not have __brace__ (or some other, better name) for anobject{something}. 
 Such braces might be useful for cross-sectioning nested data structures:
[...]
 Though I positively can not see what is wrong with this suggestion, I am sure 
 this will raise more than a few objections. Please bash my naivete publicly 
 on the list.

I think it's backwards to come up with some symbolic syntax that we haven't
used and then flail around looking for a semantics application.

It's good to think that we have such options still (despite the fact that the
small space of symbolic operators is getting fairly full and fairly overloaded
already).  But surely the right approach is to wait until a pressing need for
some new semantics comes along, and *then* flail around looking for the
right syntax to represent it?

I think this is whence comes the criticism for the use case you made --- it
doesn't seem compelling enough an application to warrant fundamental
additions to Python's syntax.

Also, I think you have to realize that Python has chosen a very definite
design trade in making *most* operations loadable by module and making
most syntax use words, because those approaches are better self-documenting.

Symbolic language is reserved for only the very most common operations
where the overhead of using a word operator like PLUS would just be
ludicrous (Cobal anyone?).  I think it's a good design decision, and I
suspect it accounts for an awful lot of my intuitive preference for Python
over languages like Perl.

I agree that the syntax could be made to work, and I'm intrigued by
the thought.  But no, we don't need it, so we shouldn't do it.

The comparison to __call__ is a bit spurious. We need that, because we
need the ability to make classes act like functions for interface reasons.
We need __getitem__ because we need them to act like sequences or
collections at other times.  What would __brace__  make the class act
like?  I think it's just something else, and that can be handled with
methods.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: mysql.h: No such file or directory when building MySQL-python

2005-05-11 Thread francescomoi
Thank you Andy for your answer.

I tried by using '1.2.1c1' and '1.2.1c2', but with no success:
---
creating build/temp.linux-i686-2.3
gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -march=i386
-mcpu=i686 - D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.3 -c
_mysql.c -o build/temp.linu x-i686-2.3/_mysql.o -I'/usr/include/mysql'
_mysql.c:41:19: mysql.h: No such file or directory


Finally I decided to copy '/usr/include/mysql/*.*' to my work
directory,
and I managed to build it. But when trying to execute a simple test,
I get this error message:
-
Traceback (most recent call last):
  File ./db.py, line 7, in ?
db = test)
  File /usr/lib/python2.3/site-packages/MySQLdb/__init__.py, line 66,
in Connect
return Connection(*args, **kwargs)
  File /usr/lib/python2.3/site-packages/MySQLdb/connections.py, line
134, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (2))
---

Any suggestion?. Regards


Andy Dustman wrote:
 [EMAIL PROTECTED] wrote:

  I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2:
 ...
  gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -march=i386
  -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.3 -c
  _mysql.c -o build/temp.linux-i686-2.3/_mysql.o
-I'/usr/include/mysql'
  _mysql.c:41:19: mysql.h: No such file or directory
 ...
  My server configuration:
  ---
  [ ]# /usr/local/mysql/bin/mysql_config
  --cflags[-I'/usr/local/mysql/include/mysql']
  --libs  [-L'/usr/local/mysql/lib/mysql'
-lmysqlclient
  -lz -lcrypt -lnsl -lm]
  --socket[/tmp/mysql.sock]
  --port  [3306]
  --version   [3.23.58]
 ...
  Any suggestion? Thank you very much.

 Fedora's mysql_config puts quotes around the directory names, which
 confuses things. Try MySQL-python-1.2.1c1. I don't think this
entirely
 solves the problem, but I think I know how to fix it for 1.2.1c2. But
 try it and report your results here:


https://sourceforge.net/tracker/index.php?func=detailaid=1146226group_id=22307atid=374932

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


Jesus said, I am the way, the truth and the life: no one can come to the Father(God)(in Heaven), but by me. (John 14:6) This means that if you die without trusting in Jesus Christ as your Lord and Saviour you will die in your sins and be forever separated from the love of God in a place called Hell. The Holy Bible descibes Hell as a place of eternal torment, suffering, pain and agony for all those who have rejected Jesus Christ. The good news is that you can avoid Hell by allowing Jesus Christ to save you today. Only then will you have true peace in your life knowing that no matter what happens you are on your way to Heaven. by BluWater0523@yahoo.com

2005-05-11 Thread BluWater0523
http://hypershrink.com/SinnersPrayer  I saw this website on a search
directory. Great Resource!

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


working directory for debugging in pythonwin

2005-05-11 Thread Thomas Pfaff
Hello all,

I started using the nice Pythonwin IDE together with Python 2.3 (I have
come to prefer its editor to IDLE).
My problem is, that when I want to run a script in the debugger, I can
give the script name and arguments, but I can't tell it in which
directory it should run.

I googled this group but didn't find anything helpful so far.

I could use some os.chdir in my code, but that's ugly and I neither want
to copy the script around to the places where I would like to test it.

Any suggestions?

Thanks in advance


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


OO design question / Transform object in place?

2005-05-11 Thread andy2O
Hello comp.lang.py,

Can you help me with ideas for the following (somewhat newbie) OO
design question in Python? Note, I'm using psuedo-code, not actual
Python for the examples!

Background:
---
I need to represent a small variety of mathematical constructs
symbolically using Python classes.

1) I have classes, representing numbers, symbolic variables etc.
2) I have classes for groups of these objects, such as a symbolic Sums.
3) To simplify the mathematical constructs, I've provided each of the
   classes with a simplify(self) method.

The following psuedo-code gives an example

a = Variable('a')
b = Variable('b')
two = Number(2) #Yes there are good reason not
#to just use Python's int object! :-)

expression1 = Sum([a,b,a,a,two]) #This represents a+b+a+a+2

then calling expression1.simplify() would invoke Sum.simplify() and
reduce expression1 to 3*a+b+2

Question:
-

Now suppose I set expression2 = Sum([a,-a]) and Sum.simplify()
recognises that the two terms cancel and the Sum has value 0.

Can I make expression2.simplify() transform expression2 from an
instance of Sum to an instance of Number(0) **in place**? Is that
possibe, or do I really have to write

expression2 = SimplifyFunction(expression2)

and use the function return to set expression2 to be a Number(0)
object, which is annoying for a variety of reasons! Have I made a
mistake in the design?

Many thanks,
andy.

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


Re: Python Args By Reference

2005-05-11 Thread Terry Hancock
On Wednesday 11 May 2005 08:43 am, Peter Hansen wrote:
 Roy Smith wrote:
  The most common immutable objects you'll see are strings and tuples, and 
  the main reason they're immutable is to allow them to be dict keys.
 
 And ints.  Strings, tuples and ints are the *three* most common 
 immutable objects you'll see...

And floats.  Floats, strings, tuples, and ints art the *four* most common
immutable objects you'll see...

Time to break out the comfy chair. ;-)
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


TAKE_FOCUS

2005-05-11 Thread phil
WM_TAKE_FOCUS does not work on WinXP ??
I was sure I had used that on win before.
Works on Linux.

I have a function I need to run when the window
gets the focus. How do you do that in Tkinter
on Win32?
Thanks

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


Re: A Faster Way...

2005-05-11 Thread Fredrik Lundh
stasz wrote:

  hmm, there's lots of ways, huh?  you can use itertools.zip instead of
  builtin zip, or do:
 
   map(None, list1, list2)

 Not!

huh?

 One should try a possible solution first,
  l1 = range(10)
  l2 = range(10,20)
  l1
 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  l2
 [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
  map(None,l1,l2)
 [(0, 10), (1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16), (7, 17), (8, 
 18), (9, 19)]

and that's different from zip in exactly what way?

 zip(l1,l2)
[(0, 10), (1, 11), (2, 12), (3, 13), (4, 14), (5, 15), (6, 16), (7, 17), (8, 
18), (9, 19)]

(as Gene pointed out, the only difference between map(None, ...) and
zip(...) is that map() pads the shorter sequence, while zip() truncates
the long sequence).

/F



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


  1   2   3   >