Re: noob question

2005-06-27 Thread Alan Gauld
"Matt Hollingsworth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Very new to python, so a noob question.  When I've written
stuff in
> JavaScript or MEL in the past, I've always adopted the variable
naming
> convention of using a $ as the first character (no, I don't use
perl,

Can I ask why you did that?
Did someone tell you to or did you hit on the idea yourself?
Do you really find it useful? I mean do you often in your
Python coding find a problem with identifying your variables?

I'm curious because one of the things I like most about Python
is the fact I don't need to mess up my programs with spurious
characters like $ etc. And I never have any problem identifying
variables etc in my code. (The same is true of Object Pascal
in Delphi, my other favourite language).

The only place I've ever found Hungarian notation useful was
in C which is a weird mix of static typing and no-typing,
and there the prefix code gives a clue as to what kind of
value you might expect to find. But when I moved to C++ I
dropped the prefixes because they added no value.

In Python Hungarian notation is meaningless since variables
aren't typed anyway.

So I am curious as to why anyone would feel the need to introduce
these kinds of notational features into Python. What is the
problem that you are trying to solve?


-- 
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




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


Re: what is your opinion of zope?

2005-06-27 Thread Mir Nazim
http://www.zope.org/Wikis/ZODB/FrontPage/guide/index.html
This should solve this problem.
---
Mir Nazim
www.planetnazim.com

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


Re: Office COM automatisation - calling python from VBA

2005-06-27 Thread Guy Lateur
Thanks for the input, people! 


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


Re: Life of Python

2005-06-27 Thread Alan Gauld

"Uwe Mayer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> con: If you are planning larger applications (for a reasonable
value of
> "large") you have to discipline yourself to write well
structured code.

As always.

> Then you will want to specify interfaces, accessor functions
with different
> read /write access, ...

Why? What advantage does this really give you over indicative
doc strings? interfaces in particular are a modern madness.
Why not just define a class with a set of unimplemented methods.
Who cares if someone tries to instantiate it? What can they do
with it? They only make sense in languages which are statically
typed and rely on inheritance to implement polymorphism.

Pure accessor methods are usually a mistake anyway, but can
be done using properties if you really must.

> Unless you have designed the software interactions completely
bevorehand
> (which never works out) this is the only way to incorporate
changes without
> refactoring your source all the time.

On really big projects it is fairly normal to define the
structure of the code to quite a detailed level - often
using Case tools and UML etc - so refactoring is only needed
when you discover a hole. Thats true regardless of size of
project but the Case approach tends to limit the damage.

> this should be expanded further, i.e. more build-in decorators
for
> interfaces, abstract classes, parameter and return value
restrictions.

What kind of parameter and return value restrictions?
In a dynamically typed language there is a limit to what can
be applied, and much of that is of limited value IMHO.

> with Perl than with Python and since there is no way of forcing
a
> programmer to do it a certain way,

I'm always uncomfortable about trying to "force" a programmer
to do it a certain way. I can never know what circumstances
those client programmers might be facing when I write/design my
code. And I can never be sure that I know better than the
client programmer.

I've seen too much C++ code that begins

#define private public

to believe that trying to force programmers rather than inform
them is a good idea.

(And FWIW I have worked on several multi million line projects
with upwards of 400 programmers working in 5 or more locatons
in Lisp, C, SQL, COBOL etc. Attempts to impose rules rather
than agreed protocols have never been very helpful in my
experience)

> its often easyer to rewrite Perl programs over 400 lines

That probably has a lot more to do with Perl's inscrutable
syntax and "many ways to do it" approach than any of the
classifiers being discussed here! I certainly didn't find
us rewriting Lisp code rather than enhancing what was there,
and Lisp shares much of Python's approach to life.


-- 
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


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


Re: Sorting part of a list

2005-06-27 Thread Sibylle Koczian
Dennis Lee Bieber schrieb:
> On Fri, 24 Jun 2005 13:42:39 +0200, Sibylle Koczian
> <[EMAIL PROTECTED]> declaimed the following in
> comp.lang.python:
> 
> 
>   ll[2:] = ...
> 
> is not an object creation, merely an access into an existing object.
> 
That's what I hadn't understood. Although it's the same with ll[2].
> 
>   I'm still running 2.3.x -- did "sorted()" make it into 2.4? As I
> recall the discussion, the idea was to have a sort operation that would
> return the sorted data, instead of the current in-place sort and return
> of None. That would allow for:
> 
>   ll[2:] = ll[2:].sorted()
> 
It's not a list method, but it's a function:

 >>> ll = [3, 1, 4, 2]
 >>> ll[2:] = ll[2:].sorted()

Traceback (most recent call last):
   File "", line 1, in -toplevel-
 ll[2:] = ll[2:].sorted()
AttributeError: 'list' object has no attribute 'sorted'
 >>>

but this works:

 >>> ll = [3, 1, 4, 2]
 >>> ll[2:] = sorted(ll[2:])
 >>> ll
[3, 1, 2, 4]

I'm using 2.4, but didn't look carefully at the changes. Thanks to all 
who answered!

Sibylle

-- 
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg
e-mail : [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Using MSMQ on Windows (and Navision)

2005-06-27 Thread Tim Golden
[Andrew Gordon]
| 
| I'm investigating getting Microsoft Navision to do stuff from 
| a Python  script.  

[... snip ...]

No help here, I'm afraid.

| 2) Every character in the body of messages sent from send.py has a 0 
| value character after them (ie in hex 48 00 65 00 6C 00 6C 00 
| 6F 00 20 
| 00 57 00 00 6F 00 72 00 6C 00 64 00 21 00)

That looks to me like Hello World! in utf16. Quick test:


#
# Removed what looks like a spurious double zero after the 57
#
original = "48 00 65 00 6C 00 6C 00 6F 00 20 00 57 00 6F 00 72 00 6C 00 64 00 
21 00"
as_numbers = [int (i, 16) for i in original.split ()]
as_string = "".join ([chr (i) for i in as_numbers])
as_unicode = as_string.decode ("utf_16") # guess
print as_unicode

#
# Sure enough, Hello World!
#



Not adding much, I know, but at least confirming your suspicions.

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


Downloading files using URLLib

2005-06-27 Thread Oyvind Ostlund
Hello,

I have to download a lot of files. And at the moment i am trying with URLLib. 
But sometimes it doesn't download the whole file. It looks like it stops 
half way through or something. Is it possible to ask for the file size before 
you download, and then test afterwards if the whole file was read? If so please 
guid me a bit here. 


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


turn text lines into a list

2005-06-27 Thread Xah Lee
i have a large number of lines i want to turn into a list.
In perl, i can do

@corenames=qw(
rb_basic_islamic
sq1_pentagonTile
sq_arc501Tile
sq_arc503Tile
);

use Data::Dumper;
print Dumper([EMAIL PROTECTED]);

--
is there some shortcut to turn lines into list in Python?

 Xah
 [EMAIL PROTECTED]
∑ http://xahlee.org/

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

Re: turn text lines into a list

2005-06-27 Thread Reinhold Birkenfeld
Xah Lee wrote:
> i have a large number of lines i want to turn into a list.
> In perl, i can do
> 
> @corenames=qw(
> rb_basic_islamic
> sq1_pentagonTile
> sq_arc501Tile
> sq_arc503Tile
> );
> 
> use Data::Dumper;
> print Dumper([EMAIL PROTECTED]);
> 
> --
> is there some shortcut to turn lines into list in Python?

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


Re: turn text lines into a list

2005-06-27 Thread Gunnar Hjalmarsson
Xah Lee wrote:
> i have a large number of lines i want to turn into a list.
> In perl, i can do
> 
> @corenames=qw(
> rb_basic_islamic
> sq1_pentagonTile
> sq_arc501Tile
> sq_arc503Tile
> );

Impractical to mix code and data, isn't it?

chomp( my @corenames =  );

__DATA__
rb_basic_islamic
sq1_pentagonTile
sq_arc501Tile
sq_arc503Tile

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: turn text lines into a list

2005-06-27 Thread Matthias Huening
Xah Lee (27.06.2005 12:33):
> i have a large number of lines i want to turn into a list.
> In perl, i can do
> 
> @corenames=qw(
> rb_basic_islamic
> sq1_pentagonTile
> sq_arc501Tile
> sq_arc503Tile
> );
> 
> use Data::Dumper;
> print Dumper([EMAIL PROTECTED]);
> 
> --
> is there some shortcut to turn lines into list in Python?

txt = """rb_basic_islamic
sq1_pentagonTile
sq_arc501Tile
sq_arc503Tile"""

print txt.splitlines()

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


Re: Favorite non-python language trick?

2005-06-27 Thread Steven D'Aprano
On Sun, 26 Jun 2005 23:22:00 -0500, Terry Hancock wrote:

>> You need to differentiate
>>a = b = 1
>> from
>>a = b == 1
> 
> Okay, I see what you mean.  I can't ever recall having needed the
> second form, though.
> 
> Of course, you could still do assignment like this:
> 
> a, b = (1,)*2
> 
> But I guess that's not exactly elegant. ;-)

In general that is not the same thing as a = b = obj.

py> a, b = ([], [])
py> a.append(1)
py> b
[]
py> a = b = []
py> a.append(1)
py> b
[1]


-- 
Steven.

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


Reading files in /var/spool/rwho/whod.*

2005-06-27 Thread Fredrik Normann
Hello,

I'm trying to read the binary files under /var/spool/rwho/ so I'm wondering if 
anyone has done that before or could give me some clues on how to read those 
files. I've tried to use the binascii module without any luck.

Best regards,
-fredrik-normann-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noob question

2005-06-27 Thread Fredrik Lundh
Alan Gauld wrote:

> In Python Hungarian notation is meaningless since variables
> aren't typed anyway.

in real-life Python code, variables tend to be 'typed' in the hungarian
sense:

http://msdn.microsoft.com/library/en-us/dnvs600/html/hunganotat.asp

"/.../ the concept of 'type' in this context is determined by
the set of operations that can be applied to a quantity. The
test for type equivalence is simple: could the same set of
operations be meaningfully applied to the quantities in
questions? If so, the types are thought to be the same.
If there are operations that apply to a quantity in exclusion
of others, the type of the quantity is different."

 



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


Re: Favorite non-python language trick?

2005-06-27 Thread Robert Kern
Steven D'Aprano wrote:
> On Sun, 26 Jun 2005 23:22:00 -0500, Terry Hancock wrote:
> 
>>>You need to differentiate
>>>   a = b = 1
>>>from
>>>   a = b == 1
>>
>>Okay, I see what you mean.  I can't ever recall having needed the
>>second form, though.
>>
>>Of course, you could still do assignment like this:
>>
>>a, b = (1,)*2
>>
>>But I guess that's not exactly elegant. ;-)
> 
> In general that is not the same thing as a = b = obj.
> 
> py> a, b = ([], [])
> py> a.append(1)
> py> b
> []
> py> a = b = []
> py> a.append(1)
> py> b
> [1]

What you wrote isn't, but what Terry wrote is.

In [1]: a, b = ([],)*2

In [2]: a.append(1)

In [3]: b
Out[3]: [1]

In [4]: a is b
Out[4]: True

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


COM problem .py versus .exe

2005-06-27 Thread Greg Miller
I have a .DLL that I am extracting the file version from using wmi.py.
The specific code is:

c = wmi.WMI()
for f in
c.CIM_DataFile(Name="c:\\glossersdmsservices\\bin\\glosscmanager.dll"):
sdmsver = f.Version

this works fine when running the application as a python file, when I
build the application into an executable, using py2exe, I get the
following error:

Traceback (most recent call last):
  File "autoStart.pyc", line 241, in test
  File "wmi.pyc", line 138, in ?
  File "win32com\client\gencache.pyc", line 540, in EnsureDispatch
  File "win32com\client\CLSIDToClass.pyc", line 50, in GetClass
KeyError: '{D2F68443-85DC-427E-91D8-366554CC754C}'

the .dll resides outside the directory of the executable.  The one
thing I notice is that the KeyError value is a different id than the
COM object I am accessing.  I'm not sure where the value in the
KeyError listed is coming from.  Do I have to do some preprocessing in
the build script?  I am at a bit of a loss here, so any input would be
appreciated.  Thanks in advance.

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


Re: noob question

2005-06-27 Thread Steven D'Aprano
On Mon, 27 Jun 2005 07:14:07 +, Alan Gauld wrote:

> The only place I've ever found Hungarian notation useful was
> in C which is a weird mix of static typing and no-typing,
> and there the prefix code gives a clue as to what kind of
> value you might expect to find. But when I moved to C++ I
> dropped the prefixes because they added no value.
> 
> In Python Hungarian notation is meaningless since variables
> aren't typed anyway.

Not quite true. Objects are typed in Python:

py> type('')

py> type(1)


but names ("variables", almost) can be dynamically changed from one type
to another:

py> x = 1 # x starts as an int
py> x = '~' # now it is a string
py> x = [1] # and now a list

Even though names can refer to an object of any type, the actual
objects themselves are always strongly typed: "hello" is always a
string, {} is always a dict, and so on.

The best use of Hungarian notation is the original use, as introduced in
the application development team at Microsoft (before the operating system
team got their hands on it, and broke it).

Rather than prefixing variable names with the type which the compiler
already knows (eg "sName" for a string, "iAge" for an integer), the
original use of Hungarian notation was to use a prefix which explains what
the data is for: the "type" of object, but not types which compilers
understand.

Here are some good uses for Hungarian notation:

ixCurrent = 0  # ix~ means index into a list or array
cFound = 0 # c~ means a count
dxObject = object.width() # d means difference

No compiler in the world can tell that adding the width of an object in
pixels to the count of how many objects were found gives a meaningless
result. But a human programmer should immediately see the bug in:

ixHam = dxEgg + cTomato

even if they don't remember what Ham, Egg and Tomato represent.

Remember that space probe a few years back that crashed into Mars because
some NASA engineer forgot to convert metric to imperial or vice versa?
That sort of mistake is easy to make when you have something like this:

initialSpeed = 3572.8 # feet per second
# ~~~
# five pages of code
# ~~~
deceleration = 3.5 # metres per second squared
# ~~~
# five more pages of code
# ~~~
timeNeeded = initialSpeed/deceleration

Now imagine seeing this line instead:

timeNeeded = iInitialSpeed/mDeceleration

With just a glance you can see that there needs to be a conversion from
imperial (i~) to metric (m~) or vice versa, or else your $20 billion
dollar space probe turns the engines off too early and becomes a $20
billion hole in the ground.



The history and justification for Hungarian notation is explained here:

http://www.joelonsoftware.com/articles/Wrong.html


-- 
Steven.

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


RE: COM problem .py versus .exe

2005-06-27 Thread Tim Golden
[Greg Miller]
| I have a .DLL that I am extracting the file version from using wmi.py.
| The specific code is:
| 
| c = wmi.WMI()
| for f in
| c.CIM_DataFile(Name="c:\\glossersdmsservices\\bin\\glosscmanag
| er.dll"):
| sdmsver = f.Version
| 
| this works fine when running the application as a python file, when I
| build the application into an executable, using py2exe, I get the
| following error:
| 
| Traceback (most recent call last):
|   File "autoStart.pyc", line 241, in test
|   File "wmi.pyc", line 138, in ?
|   File "win32com\client\gencache.pyc", line 540, in EnsureDispatch
|   File "win32com\client\CLSIDToClass.pyc", line 50, in GetClass
| KeyError: '{D2F68443-85DC-427E-91D8-366554CC754C}'

You could try using the tweaked version 0.6b from:

http://timgolden.me.uk/python/downloads/wmi-0.6b.py

which doesn't use the EnsureDispatch and so doesn't
(I think) need the type library. If you do decide to
try, let me know if it works; it was designed for
someone else's py2exe-wmi issue, but I never heard
back as to whether he'd tried it.

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: noob question

2005-06-27 Thread Reinhold Birkenfeld
Alan Gauld wrote:

> The only place I've ever found Hungarian notation useful was
> in C which is a weird mix of static typing and no-typing,
> and there the prefix code gives a clue as to what kind of
> value you might expect to find. But when I moved to C++ I
> dropped the prefixes because they added no value.

> In Python Hungarian notation is meaningless since variables
> aren't typed anyway.

Unfortunately, the original concept of Hungarian is often misunderstood,
as shown by the article pointed out by Konstantin.

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


Re: Downloading files using URLLib

2005-06-27 Thread A. Murat Eren

 Hi,

On Monday 27 June 2005 12:10, Oyvind Ostlund wrote:
> I have to download a lot of files. And at the moment i am trying with
> URLLib. But sometimes it doesn't download the whole file. It looks like it
> stops half way through or something. Is it possible to ask for the file
> size before you download, and then test afterwards if the whole file was
> read? If so please guid me a bit here.

 You need something like that:

   import urllib2
   URI='http://cekirdek.uludag.org.tr/index.html'
   file = urllib2.urlopen(URI)
   headers = file.info()
   fsize = int(headers['Content-Length'])

 HTH..
 Ciao,
-- 

- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
 A. Murat Eren
 meren at uludag.org.tr
 http://cekirdek.uludag.org.tr/~meren/
 0x527D7293, 
 7BCD A5A1 8101 0F6D 84A4  BD11 FE46 2B92 527D 7293
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -

--
 Alan Cox sounds as if he hasn't followed the
 development of programming languages
 and compilers for the last 10 years (exa).
-


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

Re: COM problem .py versus .exe

2005-06-27 Thread Greg Miller
Thanks for the tweaked code, it worked on my desktop.  The acid test
will be when I put it on one of the "virgin" PC's ( no python
installed, just running the py2exe executable ) that run the machine.
I won't be getting one of those until later in the week, but I'm hoping
that since it cleared the problem here, it will also clear the problem
on that machine, ( the error message was slightly different ), so once
again thanks again.
  Greg

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


Re: noob question

2005-06-27 Thread bruno modulix
[EMAIL PROTECTED] wrote:
> Hi Matt,
> I also am almost a newbie (in Python) and my approach to variable
> naming
> follows more or less the Hungarian Type Notation Defined.

which is seen as a bad practice anywhere outside Win32...

http://mindprod.com/jgloss/unmainnaming.html


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


RE: COM problem .py versus .exe

2005-06-27 Thread Tim Golden
[Greg Miller]

| Thanks for the tweaked code, it worked on my desktop.  

Thanks for the confirmation; I don't use py2exe myself,
and while I could run up a test case (and probably should
given the number of queries I get like this) I've never
got round to it.

I'm close to releasing a version 1.0 of wmi which
includes that and couple of other changes. (The
version bump is just because it's as stable as it's
going to get and why hang around with sub-1.0 versions
forever?)

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: turn text lines into a list

2005-06-27 Thread Paul McGuire
See definition of splitlines().
(http://docs.python.org/lib/string-methods.html)

-- Paul

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


Re: Photo layout

2005-06-27 Thread Larry Bates
You can use Python Imaging Library (PIL) and ReportLab to resize and
place the photos on a page quite easily.  Actually ReportLab calls
PIL automatically to resize the photos when you call .drawInlineImage
method of the canvas object with the proper width and height arguments.

To get ReportLab go to: http://www.reportlab.org

Note: I'm assuming the photos are in .JPG, .TIF or some format that
PIL can recognize.  If they are in some proprietary RAW format you
will need to convert them first.

-Larry Bates

Stephen Boulet wrote:
> Is there a python solution that someone could recommend for the following:
> 
> I'd like to take a directory of photos and create a pdf document with
> four photos sized to fit on each (landscape) page.
> 
> Thanks.
> 
> Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter PhotoImage Question

2005-06-27 Thread Adonis
I have two classes one class inherits dict(), this class just takes in a 
path argument much like glob.glob() and loads the image using PhotoImage 
into itself, no biggie works fine. The other class inherits Frame and it 
implements an add(self, **kw) method passes all of its arguments to a 
Button. My question is that when I load the images with the first class 
and then use dict.get(name) as the image argument for the add method the 
image does not show up, mind you the variable holding the dict is seen 
by the whole class so its not a garbage collection issue, but if I put a 
command in the argument list it works just fine?

Any help is greatly appreciated.

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


Re: Downloading files using URLLib

2005-06-27 Thread Fuzzyman
> If so please guid me a bit here.

I aaume you mean 'guido' here ?

;-)

Anyway - you probably want to be using urllib2 as the other poster
points out.

Regards,

Fuzzy

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


Re: Getting binary data out of a postgre database

2005-06-27 Thread projecktzero
Sorry for the late reply. I didn't check the group/list over the
weekend.

Anyway, I added a print rec[0] just after the fetchone. Then I ran it
from the command line, and it spewed a bunch of binary gibberish nearly
locking up Putty.

To me, it seems like it's coming out in the right format, but I'm not
sure what I'm doing wrong.  If you have any ideas, I'd really
appreciate it.

Thanks,

Mike

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


pulling multiple instances of a module into memory

2005-06-27 Thread Gabriel Jiva
I have a Python app, spam.py, that uses a C shared library, eggs.so.
This shared library is an interface that makes connections to another
system (Ham), and among other things uses callback functions.
Therefore, if I want to make multiple connections to Ham, I need
eggs.so to be instantiated in memory multiple times so that everything
works fine.

Right now, in spam.py, let's say I want to make two connections to the
Ham system.  I call

eggs.start('Connection1')
eggs.start('Connection2')

On the second one, I get a 'duplicate call' error.  Because Python is
optimized to only load a module into memory once, I can never make more
than one connection from the same Python script.

Any ideas to work around this would be great.

Gabriel

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


Re: Daten Kinderheilkunde

2005-06-27 Thread Peter Maas
Peter Maas schrieb:
> vielen Dank für die Zusendung der Daten. Es handelt sich allerdings
> nicht um jpeg-Dateien, wie die Erweiterung nahelegt. Wir konnten sie
> nur mit dem PictureViewer auf einem Apple anzeigen. Sie werden unter
> MacOS als Adobe-Photoshop-Dokument angezeigt.

Sorry, my fault. Please disregard this :)

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list

Daten Kinderheilkunde

2005-06-27 Thread Peter Maas
Sehr geehrter Herr Wurm,

vielen Dank für die Zusendung der Daten. Es handelt sich allerdings
nicht um jpeg-Dateien, wie die Erweiterung nahelegt. Wir konnten sie
nur mit dem PictureViewer auf einem Apple anzeigen. Sie werden unter
MacOS als Adobe-Photoshop-Dokument angezeigt.

Können wir die Dateien als jpegs bekommen oder sollen wir sie selbst
umwandeln?

Mit freundlichen Gruessen,

Peter Maas

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread John Roth
"Reinhold Birkenfeld" <[EMAIL PROTECTED]> wrote in 
message news:[EMAIL PROTECTED]
> [EMAIL PROTECTED] wrote:
>> Hi,
>>
>> Thanks for your reply! A new thing learned
>>
>> Allow me to follow that up with another question:
>>
>> Let's say I have a result from a module called pyparsing:
>>
>> Results1 = ['abc', 'def']
>> Results2 = ['abc']
>>
>> They are of the ParseResults type:
>>
> type(Results1)
>> 
> type(Results2)
>> 
>>
>> I want to convert them into Python lists. list() will work fine on
>> Results1, but on Results2, it will return:
>>
>> ['a', 'b', 'c']
>>
>> Because 'abc' is a string. But I want it to return ['abc'].
>>
>> In short, my question is: how do I typecast an arbitrary object,
>> whether a list-like object or a string, into a Python list without
>> having Python split my strings into characters?
>
> This seems like a glitch in pyparsing. If a ParseResults class emulates
> a list, it should do so every time, not only if there is more than one
> value in it.

Unfortunately, I've seen that behavior a number of times:
no output is None, one output is the object, more than one
is a list of objects. That forces you to have checks for None
and list types all over the place. Granted, sometimes your
program logic would need checks anyway, but frequently
just returning a possibly empty list would save the caller
a lot of grief.

John Roth
>
> Reinhold 

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


Re: tkinter radiobutton

2005-06-27 Thread William Gill
 >> to determine if it is selected?, or can this only be achieved via
 >> control variables?

 > The value and variable options for a radiobutton seem to be what
 > you're looking for.

Thanks, I knew that, but I was looking for a way to read the 
selected/unselected status directly.  Using control variables gets a 
little messy because of the relationship of the rb matrix.  They are 
arranged in a 4 X 4 matrix where each column is grouped (via intVars) so 
that no more than 1 rb per column can be selected, but each row makes up 
the 'status' on one 'item' so any combination of buttons in a row is 
acceptable.

One solution I have been contemplating requires setting the value of 
each rb to the row number ( 0, 1, 2, or 3 or 1,2,3, or 4 in case I need 
to use 0 for 'none selected'), and using one intVar for each column. 
Then I would have to loop through all four intVars four times to 
determine which radiobuttons are selected in each row.  That's what I 
mean by messy.

Bill

Eric Brunel wrote:
> On Sat, 25 Jun 2005 19:34:50 GMT, William Gill <[EMAIL PROTECTED]> wrote:
> 
>> I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep
>> references to them in a 2 dimensional list ( rBtns[r][c] ).  It works
>> fine, and I can even make it so only one button per column can be
>> selected, by assigning each column to an intVar.  In many languages a
>> radiobutton has a property that can be directly read to see if it is
>> selected on unselected.  Tkinter radiobuttons don't seem to have any
>> such property.  Is there any way to look (via the script not the screen)
>> to determine if it is selected?, or can this only be achieved via
>> control variables?
> 
> 
> The value and variable options for a radiobutton seem to be what you're 
> looking for. Here is an example showing how to use them:
> 
> 
> from Tkinter import *
> 
> root = Tk()
> v = StringVar()
> Radiobutton(root, text='foo', value='foo', variable=v).pack()
> Radiobutton(root, text='bar', value='bar', variable=v).pack()
> 
> def p():
>   print v.get()
> 
> Button(root, command=p, text='Print').pack()
> 
> root.mainloop()
> 
> 
> HTH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: turn text lines into a list

2005-06-27 Thread Grant Edwards
On 2005-06-27, Xah Lee <[EMAIL PROTECTED]> wrote:
> i have a large number of lines i want to turn into a list.
> In perl, i can do
>
> @corenames=qw(
> rb_basic_islamic
> sq1_pentagonTile
> sq_arc501Tile
> sq_arc503Tile
> );
>
> use Data::Dumper;
> print Dumper([EMAIL PROTECTED]);
>
> --
> is there some shortcut to turn lines into list in Python?

corenames = [ "rb_basic_islamic",
  "sq1_pentagonTile",
  "sq_arc501Tile",
  "sq_arc503Tile"]

-- 
Grant Edwards   grante Yow!  TAILFINS!!...click...
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Paul McGuire
David -

I'm not getting the same results.  Run this test program:
---
import pyparsing as pp
import sys

def test(s):
results = pp.OneOrMore( pp.Word(pp.alphas) ).parseString( s )
print repr(s),"->",list(results)

print "Python version:", sys.version
print "pyparsing version:", pp.__version__
test("abc def")
test("abc")
---
The output I get is:
Python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit
(Intel)]
pyparsing version: 1.3.1
'abc def' -> ['abc', 'def']
'abc' -> ['abc']

What versions of pyparsing and Python are you using?

-- Paul

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


Re: Favorite non-python language trick?

2005-06-27 Thread Tim Peters
[Terry Hancock]
> Probably the most pointless Python wart, I would think. The =/==
> distinction makes sense in C, but since Python doesn't allow assignments
> in expressions, I don't think there is any situation in which the distinction
> is needed.  Python could easily figure out whether you meant assignment
> or equality from the context, just like the programmer does.

That's what Python originally did, before release 0.9.6 (search
Misc/HISTORY for eqfix.py).  Even this is ambigous then:

a = b

Especially at an interactive prompt, it's wholly ambiguous then
whether you want to change a's binding, or want to know whether a and
b compare equal.

Just yesterday, I wrote this in a script:

lastinline = ci == ncs - 1

This:

lastinline = ci = ncs - 1

means something very different (or means something identical,
depending on exactly how it is Python "could easily figure out" what I
intended ).

Of course strange rules could have resolved this, like, say, "=" means
assignment, unless that would give a syntax error, and then "=" means
equality.  Then

lastinline = ci = ncs - 1

would have been chained assignment, and something like

lastinline = (ci = ncs - 1)

would have been needed to get the intent of the current

lastinline = ci == ncs - 1
-- 
http://mail.python.org/mailman/listinfo/python-list


delphi to python converter

2005-06-27 Thread Thys Meintjes
Greets,

I have need of a Delphi/pascal to python converter. Googling didn't
suggest any obvious leads so I'm trying here...

Thanks
Thys

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


['ext.IsDOMString', 'ext.SplitQName']

2005-06-27 Thread Farkov, Serge






I am using python 2.4, py2exe 0.5.3, PyXML 0.8.4., and have the same warning.

 

 

My research shows that this is due to
wrong references in PyXML code.

 

For example, I found such definition (and couple more similar):

 

c:\python24\lib\site-packages\_xmlplus\dom\Element.py(27) from ext
import SplitQName, IsDOMString

 

Should be changed to “from xml.dom.ext import SplitQName, IsDOMString”
to be properly resolved by py2exe

 

To get Adhoc solution for this problem, scan the code and replace all
occurrences of “from ext” to “from xml.dom.ext”

 

Regards,

Serge Farkov 
 

 









***


This e-mail message is privileged, confidential and subject
to copyright. Any unauthorized use or disclosure is prohibited.

Le contenu du pr'esent courriel est privil'egi'e, confidentiel et
soumis `a des droits d'auteur. Il est interdit de l'utiliser ou
de le divulguer sans autorisation.


***

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

Re: Favorite non-python language trick?

2005-06-27 Thread Steve Jorgensen
On 24 Jun 2005 19:09:05 +0400, Sergei Organov <[EMAIL PROTECTED]> wrote:

>Steven D'Aprano <[EMAIL PROTECTED]> writes:
>
>> On Fri, 24 Jun 2005 00:55:38 -0600, Joseph Garvin wrote:
>> 
>> > I'm curious -- what is everyone's favorite trick from a non-python 
>> > language? And -- why isn't it in Python?
>> 
>> Long ago, I used to dabble in Forth. You could say, the entire Forth
>> language was a trick :-) It was interesting to be able to define your own
>> compiler commands, loop constructs and so forth.
>> 
>> One of the things I liked in Pascal was the "with" keyword. You could
>> write something like this:
>> 
>> with colour do begin
>> red := 0; blue := 255; green := 0;
>> end;
>> 
>> instead of:
>> 
>> colour.red := 0; colour.blue := 255; colour.green := 0;
>> 
>> Okay, so maybe it is more of a feature than a trick, but I miss it and it
>> would be nice to have in Python.
>
>... that quickly becomes quite messy:

 - When abused -

>with A do begin
>  .
>  with B do begin
>.
>with C do begin
>  x := y;
>end;
>  end;
>end;

Like many features that can be helpful when used well, and harmful when used
poorly, it's not a simple question whether it should be in any given language.
It also makes sense to consider whether other features already in the language
can fill the same need (though I don't know Python well enough to address that
yet).  Even though I like "With" in VB and use it often, I always consider its
use a warning that perhaps that code should be factored into the class
somehow.

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


Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Paul McGuire
John -

I just modified my test program BNF to use ZeroOrMore instead of
OneOrMore, and parsed an empty string.  Calling list() on the returned
results gives an empty list.  What version of pyparsing are you seeing
this None/object/list behavior?

-- Paul

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


Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Jeff Epler
On Mon, Jun 27, 2005 at 08:21:41AM -0600, John Roth wrote:
> Unfortunately, I've seen that behavior a number of times:
> no output is None, one output is the object, more than one
> is a list of objects. That forces you to have checks for None
> and list types all over the place.

maybe you can at least push this into a single convenience function...

def destupid(x, constructor=tuple, sequencetypes=(tuple, list)):
if x is None: return constructor()
if isinstance(x, sequencetypes): return x
return constructor((x,))

Jeff


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

Re: Beginner question: Converting Single-Element tuples to list

2005-06-27 Thread Paul McGuire
Modified version of test program, to handle empty strings -> empty
lists.

import pyparsing as pp
import sys

def test(s):
results = pp.ZeroOrMore( pp.Word(pp.alphas) ).parseString( s )
print repr(s),"->",list(results)

print "Python version:", sys.version
print "pyparsing version:", pp.__version__
test("abc def")
test("abc")
test("")

Prints:
Python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit
(Intel)]
pyparsing version: 1.3.1
'abc def' -> ['abc', 'def']
'abc' -> ['abc']
'' -> []

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


Modules for inclusion in standard library?

2005-06-27 Thread Reinhold Birkenfeld
Hello,

at the moment python-dev is discussing including Jason Orendorff's path module
into the standard library.

Do you have any other good and valued Python modules that you would think are
bug-free, mature (that includes a long release distance) and useful enough to
be granted a place in the stdlib?

For my part, ctypes seems like a suggestion to start with.

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


Re: execute python code and save the stdout as a string

2005-06-27 Thread jwaixs
Thank you, this really looks cool!

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


Re: Photo layout

2005-06-27 Thread Miki Tebeka
Hello Stephen,

> I'd like to take a directory of photos and create a pdf document with
> four photos sized to fit on each (landscape) page.
Use LaTex (pdflatex that is, see www.tug.org). It know how to embed
pictures and how to resize them.

Bye.
--

Miki Tebeka <[EMAIL PROTECTED]>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys


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

Re: delphi to python converter

2005-06-27 Thread bruno modulix
Thys Meintjes wrote:
> Greets,
> 
> I have need of a Delphi/pascal to python converter. Googling didn't
> suggest any obvious leads so I'm trying here...

Have you tried with "python/delphi programer" ?-)


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


Re: turn text lines into a list

2005-06-27 Thread F. Petitjean
[En-tête "Followup-To:" positionné à comp.lang.python.]
Le Mon, 27 Jun 2005 14:27:28 -, Grant Edwards a écrit :
> On 2005-06-27, Xah Lee <[EMAIL PROTECTED]> wrote:
>> i have a large number of lines i want to turn into a list.
>> In perl, i can do
>>
>> @corenames=qw(
>> rb_basic_islamic
>> sq1_pentagonTile
>> sq_arc501Tile
>> sq_arc503Tile
>> );
>>
>> use Data::Dumper;
>> print Dumper([EMAIL PROTECTED]);
>>
>> --
>> is there some shortcut to turn lines into list in Python?
>
> corenames = [ "rb_basic_islamic",
>   "sq1_pentagonTile",
>   "sq_arc501Tile",
>   "sq_arc503Tile"]
>
Another way : (less typing of quotes)

all_names = """
rb_basic_islamic
sq1_pentagonTile
sq_arc501Tile
sq_arc503Tile
"""

corenames = all_names.split()

Regards.

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


Re: tkinter radiobutton

2005-06-27 Thread Peter Otten
William Gill wrote:

> I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep
> references to them in a 2 dimensional list ( rBtns[r][c] ).  It works
> fine, and I can even make it so only one button per column can be
> selected, by assigning each column to an intVar.  In many languages a
> radiobutton has a property that can be directly read to see if it is
> selected on unselected.  Tkinter radiobuttons don't seem to have any
> such property.  Is there any way to look (via the script not the screen)
> to determine if it is selected?, or can this only be achieved via
> control variables?

You can either write a little helper function

def selected(rbn):
return rbn.getvar(rbn["variable"]) == rbn["value"]

or use a custom subclass of Tkinter.Radiobutton with a 'selected' attribute:

class Radiobutton(Tkinter.Radiobutton):
def __getattr__(self, name):
if name == "selected":
return self.getvar(self["variable"]) == self["value"]
raise AttributeError


Peter

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


Re: turn text lines into a list

2005-06-27 Thread Bengt Richter
On 27 Jun 2005 16:56:34 GMT, "F. Petitjean" <[EMAIL PROTECTED]> wrote:

>[En-tête "Followup-To:" positionné à comp.lang.python.]
>Le Mon, 27 Jun 2005 14:27:28 -, Grant Edwards a écrit :
>> On 2005-06-27, Xah Lee <[EMAIL PROTECTED]> wrote:
>>> i have a large number of lines i want to turn into a list.
>>> In perl, i can do
>>>
>>> @corenames=qw(
>>> rb_basic_islamic
>>> sq1_pentagonTile
>>> sq_arc501Tile
>>> sq_arc503Tile
>>> );
>>>
>>> use Data::Dumper;
>>> print Dumper([EMAIL PROTECTED]);
>>>
>>> --
>>> is there some shortcut to turn lines into list in Python?
>>
>> corenames = [ "rb_basic_islamic",
>>   "sq1_pentagonTile",
>>   "sq_arc501Tile",
>>   "sq_arc503Tile"]
>>
>Another way : (less typing of quotes)
>
>all_names = """
>rb_basic_islamic
>sq1_pentagonTile
>sq_arc501Tile
>sq_arc503Tile
>"""
>
>corenames = all_names.split()

Of course, the lines better not have embedded spaces or they'll be split
into several lines. For lines per se, probably I'd do

 corenames = """\
 rb_basic_islamic
 sq1_pentagonTile
 sq_arc501Tile
 sq_arc503Tile
 """.splitlines()

Note the \ to avoid a blank leading line.

 >>> """\
 ... solid
 ... embedded space
 ...  leading
 ... trailing
 ...  both
 ... """.splitlines()
 ['solid', 'embedded space', ' leading', 'trailing ', ' both ']

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

Re: Life of Python

2005-06-27 Thread Terry Hancock
On Monday 27 June 2005 02:34 am, Alan Gauld wrote:
> "Uwe Mayer" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > con: If you are planning larger applications (for a reasonable
> > [...]
> > Then you will want to specify interfaces, accessor functions
> with different
> > read /write access, ...
> 
> Why? What advantage does this really give you over indicative
> doc strings? interfaces in particular are a modern madness.

Interfaces, IMHO are best viewed as documentation.  I have used
the Zope 3 interfaces module, and I think it's going to be very
useful to me.  Although, theoretically, you could do all of this
with doc strings, being able to check that you've documented
everything that should be (including methods and attributes).

With interfaces, you distribute the docstrings over the class. Also,
the interpreter helps you with documentation problems, because
standardized means are used to represent what methods expect
as arguments, and so on.  They don't really force you to do it that
way, but they generally catch broken attempts to implement the
interface.

> Why not just define a class with a set of unimplemented methods.

Takes too much time, and gets mixed in with functionality.
Basically, it's more boilerplate than the better interface modules
written for Python.

> Who cares if someone tries to instantiate it? What can they do
> with it? They only make sense in languages which are statically
> typed and rely on inheritance to implement polymorphism.

> Pure accessor methods are usually a mistake anyway, but can
> be done using properties if you really must.

Yes -- there's just no reason to do that in Python.  Properties mean
you don't have to worry about an attribute changing into a method,
so there's no reason to try to "preempt the damage".  No damage,
so no preemption needed.  I personally, really prefer attributes (or
properties) over explicit get/set methods.

> > Unless you have designed the software interactions completely
> bevorehand
> > (which never works out) this is the only way to incorporate
> changes without
> > refactoring your source all the time.
> 
> On really big projects it is fairly normal to define the
> structure of the code to quite a detailed level - often
> using Case tools and UML etc - so refactoring is only needed
> when you discover a hole. Thats true regardless of size of
> project but the Case approach tends to limit the damage.

Okay. This makes sense if the software is:

1) Designed by one institution.
2) Designed almost entirely before deployment.
3) Not designed to be worked on by users and
semi-trained developers.

In other words --- proprietary software.

For a free-software application, in which you want to maximize
your collaborative advantage, you want to make one-sided
cooperation as easy as possible.  I do not *know* who my
collaborators will be.  They may well not be privy to UML diagrams
and CASE tools I may have used.  Certainly a lot of them wouldn't
bother to look if they could avoid it.  OTOH, a well-defined
set of interfaces shows them where they can make clean breaks
in the design in order to localize what they need to learn and
what they need to fix -- and it's all right there in the source code.

It's just like fixing an old house. The biggest problem is knowing
where to stop --- how much of that plumbing do you want to
take out and rework?  If it has cutoff valves and unions in the
right places, it will come apart in sections and you have a much
better chance of fixing it without getting into an intractable mess.
Software interfaces can be used to the same effect --- making the
job easier for the next person who comes along.

If you are trying to trade on a free-software advantage, then it is
absolutely in your best interest to make the way as easy as
possible for the people who follow you.
 
> > this should be expanded further, i.e. more build-in decorators
> for
> > interfaces, abstract classes, parameter and return value
> restrictions.

Specifically, *I* would like one of the available interface
implementations to find its way into the standard library. Obviously,
*my* life would be easier if it's the Zope 3 implementation, but I'll
learn to use whatever gets in there.

> What kind of parameter and return value restrictions?
> In a dynamically typed language there is a limit to what can
> be applied, and much of that is of limited value IMHO.

Yes, there is a limit, and it's madness to go beyond it. But there
is a useful middle ground.  For example, it is quite useful to
specify that an argument of a method should expect an object
which implements a given interface. For simple objects, this is
usually handled by things in the interface module.  A method
which expects a number may check that the object has __add__,
__mul__, etc.

But the real win is when it's supposed to be a much more
elaborate object defined by the application.

Intelligent use, of course, will suggest many cases where constraint
is unnecessary boi

Re: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Aahz
In article <[EMAIL PROTECTED]>,
John Roth <[EMAIL PROTECTED]> wrote:
>
>What's being ignored is that type information is useful for other
>things than compile type checking. The major case in point is the
>way IDEs such as IntelliJ and Eclipse use type information to do
>refactoring, code completion and eventually numerous other things. A
>Java programmer using IntelliJ or Eclipse can eliminate the advantage
>that Python used to have, and possibly even pull ahead.

Perhaps.  But adding the time to learn those IDEs in addition to the time
to learn Java is ridiculous.  I've been forced to use Java a bit to
support credit cards for our web application; I've got a friend whose
Java-vs-Python argument hinges on the use of Eclipse; I was unable to
make use of Eclipse in the time I had available for the project.

Meanwhile, I'm busy with a code base that I doubt any IDE could handle...
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Help - im a beinner in using python

2005-06-27 Thread enas khalil












dear all
could you if you please tell me how can i start learning python 
im reading on tutorial and i have  questions about:
- how can i adjust the environmental variable on windows platform
 -where should i put the NLTK data to be accessible by python
-how can i use TKinter in python is it only the "fom Tkinter import *" command ,i did this it sometimes woks and sometimes doesnt 
-i want to know the way to have a Tkinter GUI fo any python code i write
 
thanks in advance 
 
 
		Yahoo! Mail 
Stay connected, organized, and protected. Take the tour-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Modules for inclusion in standard library?

2005-06-27 Thread Thomas Heller
Reinhold Birkenfeld <[EMAIL PROTECTED]> writes:

> Hello,
>
> at the moment python-dev is discussing including Jason Orendorff's path module
> into the standard library.

I have never used the path module before, although I've heard good
things about it.  But, it seems to have problems with unicode pathnames,
at least on windows:

C:\>mkdir späm

C:\späm>py24
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from path import path
>>> path.getcwd()
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\TSS5\components\_Pythonlib\path.py", line 97, in getcwd
return path(os.getcwd())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 5: ordinal 
not in range(128)
>>>

Although it seems this could be fixed by adding this constructor to the
path class:

def __new__(cls, init=u""):
if isinstance(init, unicode):
return _base.__new__(cls, init)
return _base.__new__(cls, init, sys.getfilesystemencoding())

I would really appreciate if Python's unicode support would be better
;-), and maybe it's easier to add this to the path module than to
os.path.

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


Re: Favorite non-python language trick?

2005-06-27 Thread GodFoca
> if a.value == True:
> return a

> if not database.connect == error:
> database.query(q)

Yeah, yeah, I know that :-)
What I mean is that most of the time I find the code more "readable" (I
know that more readable code ain't better code, but it helps when you
work with other people...).

> "unless" seems to become "while not", as opposed to "if not". Should be
> more consistent.

My mistake :-S
The comment in the code was erroneous, I shouldn't write messages to
the list while asleep ^_^

'unless' works as 'if not', not as 'while not'. Sorry for that :-)

Anyway, it does improve readability. I know that it doesn't necessarily
makes code better, but it's a nice "trick" that I like :-)

Other nice thing about ruby is declaring regexps as /regexp/ rather
than having to re.compile("regexp"), and having a built-in operator to
match against them (of course, as everything in ruby, overloadable in
each class :-))

-NIcolas

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


Boss wants me to program

2005-06-27 Thread xeys_00
I'm a manager where I work(one of the cogs in a food service company).
The boss needed one of us to become the "tech guy", and part of that is
writing small windows programs for the office. He wants the development
work done in house, and he knows I am in school for a CS minor. I know
basic C++(Part 2 of that is in the fall), and I will be taking Java 1
in the fall also. What is the easiest way for me to make windows
programs that will do basic things like(Inventory, Menu Management,
etc...)? I have heard visual basic is where it's at. I want to keep an
open mind though, so I am wondering if python could be an option. The
programs have
no speed requirement.  But they must be pretty, and not confuse my
boss. Plus he wants well documented help for each function. I asked the
windows programming group, but I thought I would ask here also. Thanks.

Xeys

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


Re: delphi to python converter

2005-06-27 Thread Cappy2112


Thys Meintjes wrote:
> Greets,
>
> I have need of a Delphi/pascal to python converter. Googling didn't
> suggest any obvious leads so I'm trying here...
>
> Thanks
> Thys

This isn't what you want, but you can probably achieve similar results,
by embedding Pyton in your delphi app.

http://www.atug.com/andypatterns/pythonDelphiTalk.htm

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


Re: Boss wants me to program

2005-06-27 Thread Apple Grew
I think since speed is not such an issue (I heard that python can make 
faster GUI programs) you should use Visual Basic. It is  very well 
suited for Windows programming. There is the good thing that you can 
visually create the GUI hence it is easier to create the GUI.

[EMAIL PROTECTED] wrote:

>I'm a manager where I work(one of the cogs in a food service company).
>The boss needed one of us to become the "tech guy", and part of that is
>writing small windows programs for the office. He wants the development
>work done in house, and he knows I am in school for a CS minor. I know
>basic C++(Part 2 of that is in the fall), and I will be taking Java 1
>in the fall also. What is the easiest way for me to make windows
>programs that will do basic things like(Inventory, Menu Management,
>etc...)? I have heard visual basic is where it's at. I want to keep an
>open mind though, so I am wondering if python could be an option. The
>programs have
>no speed requirement.  But they must be pretty, and not confuse my
>boss. Plus he wants well documented help for each function. I asked the
>windows programming group, but I thought I would ask here also. Thanks.
>
>Xeys
>
>  
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-27 Thread Fredrik Johansson
On 6/27/05, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote:
> Do you have any other good and valued Python modules that you would think are
> bug-free, mature (that includes a long release distance) and useful enough to
> be granted a place in the stdlib?

First of all, numeric/numarray, obviously!

I'd also like to see wxPython, pygame and SciPy, but these may be too
heavy-weight. A good distribution system for widely used packages may
be a better solution than including everything in the standard
library.

> For my part, ctypes seems like a suggestion to start with.

I think ctypes simply *must* go in there sooner later. My experience
dealing with binary data in Python is that it's a pain in the neck
compared to C, and the more machine-like behaviour and elegant code
you want, the slower it gets. I have refrained from using ctypes for a
number of reasons, but I would probably use it if it was in the
standard library.

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


Re: Modules for inclusion in standard library?

2005-06-27 Thread Steven Bethard
Reinhold Birkenfeld wrote:
> For my part, ctypes seems like a suggestion to start with.

I believe this has been discussed somewhere before and the conclusion 
was that ctypes should not be a candidate for inclusion in the Python 
stdlib because people don't want things in the stdlib that can make 
Python segfault.

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


Re: Modules for inclusion in standard library?

2005-06-27 Thread Steven Bethard
Fredrik Johansson wrote:
> On 6/27/05, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote:
> 
>>Do you have any other good and valued Python modules that you would think are
>>bug-free, mature (that includes a long release distance) and useful enough to
>>be granted a place in the stdlib?
> 
> First of all, numeric/numarray, obviously!

There has been recent discussion about this.  Check the python-dev list 
archives I think.  It's unlikely that all of numeric/numarray could go 
into the Python stdlib because there still is disagreement between the 
two camps as to the module architecture.  However, there does seem to be 
some agreement at the level of the basic array object, so it may be 
possible that at least the array object itself might join the stdlib in 
the not too distant future.  I suspect there's more detailed discussion 
of this in the numeric/numarray lists.

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


Re: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Ivan Van Laningham
Hi All--

Aahz wrote:
> 
> Perhaps.  But adding the time to learn those IDEs in addition to the time
> to learn Java is ridiculous.  I've been forced to use Java a bit to
> support credit cards for our web application; I've got a friend whose
> Java-vs-Python argument hinges on the use of Eclipse; I was unable to
> make use of Eclipse in the time I had available for the project.
> 

Were there _good_ reasons not to do the credit card part of the web app
in Java instead of Python?  As in, there is no secure module, or you
didn't have time, or Python doesn't support crucial APIs?  I'm very
curious.

> f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
>

l tk t.

Metta,
Ivan 
--
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-27 Thread [EMAIL PROTECTED]
I guess you need a database plus GUI layer for your apps, you might
look in to MS Access (or Open Office 2.0 Base, but this is still beta,
so I don't think your boss will like that) for that

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


Re: delphi to python converter

2005-06-27 Thread Jarek Zgoda
Thys Meintjes napisał(a):

> I have need of a Delphi/pascal to python converter. Googling didn't
> suggest any obvious leads so I'm trying here...

Don't think something like that even exists...

-- 
Jarek Zgoda
http://jpa.berlios.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-27 Thread Björn Lindström
Apple Grew <[EMAIL PROTECTED]> writes:

> I think since speed is not such an issue (I heard that python can make
> faster GUI programs) you should use Visual Basic. It is very well
> suited for Windows programming. There is the good thing that you can
> visually create the GUI hence it is easier to create the GUI.

Of course, you can do that with Python, too, with Glade
(http://www.jamesh.id.au/software/libglade/) or Boa Constructor
(http://boa-constructor.sourceforge.net/). (There might be more of
them.)

-- 
Björn Lindström <[EMAIL PROTECTED]>
Student of computational linguistics, Uppsala University, Sweden
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Modules for inclusion in standard library?

2005-06-27 Thread George Sakkis
I'd love to see IPython replace the standard interpreter. Pychecker
seems to be a strong candidate too.

George

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


Python + Lisp integration - Part II

2005-06-27 Thread Simo Melenius

I'm posting a self-followup to my post in last December about Python
and Lisp integration:

http://groups-beta.google.com/group/comp.lang.python/msg/ff6345845045fb47?hl=en>

Now, just yesterday I just stumbled upon Lython:

http://www.caddr.com/code/lython/>

It's a bit edgy but it can be made to work :-). It does do simple
macros and compiles to Python bytecode (via AST generation). So,
effectively you could be writing your code in Lisp and then running it
in the vast environment of Python standard library and modules.

This was FYI, if interested.


cheers,
S

-- 
[EMAIL PROTECTED] -- Today is the car of the cdr of your life.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-27 Thread Robert Kern
Reinhold Birkenfeld wrote:
> Hello,
> 
> at the moment python-dev is discussing including Jason Orendorff's path module
> into the standard library.
> 
> Do you have any other good and valued Python modules that you would think are
> bug-free, mature (that includes a long release distance) and useful enough to
> be granted a place in the stdlib?

I would like to see the setuptools/PythonEggs/EasyInstall trifecta get 
more attention and eyeballs. Once it is mature, I think that it will 
obviate the desire for stdlibification of most of the packages being 
requested here.

-- 
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: Running Python interpreter in Emacs

2005-06-27 Thread Sells, Fred
It works for me in W2000; I have an ancient .emacs file that someone gave me
that I use on each new system, wheter unix or windows and have never had a
problem.  It usually has to be installed at C:/ to work, unless you
understand emacs better than I.  I've inserted the file ".emacs" below, for
those who have attachment blocking.  I make no guarantees, nor do I
understand it, I just use it:
-snip---
---
(setq initial-major-mode 'c-mode)
(setq text-mode-hook 'turn-on-auto-fill)
(setq-default indent-tabs-mode nil)
(global-set-key "\C-z" 'narten-suspend-emacs)
(global-set-key "\C-_" 'help-command)
(setq help-char 31)
(define-key global-map "\C-h" 'backward-delete-char-untabify)
(global-set-key "\C-x\C-e" 'compile)
(global-set-key "\C-x1" 'my-delete-other-windows)
(setq manual-program "man")
(setq manual-formatted-dir-prefix (list "/usr/man/cat"
"/usr/local/X11R4/man"))
(setq manual-formatted-dirlist (list
"/usr/man/cat1" "/usr/man/cat2" "/usr/man/cat3" "/usr/man/cat4"
"/usr/man/cat5" "/usr/man/cat6" "/usr/man/cat7" "/usr/man/cat8"
"/usr/man/catl" "/usr/man/catn" "/usr/local/X11R4/man/catn"
"/usr/local/X11R4/man/cat3" ))
(global-set-key "\em" 'manual-entry)
(global-set-key "\eg" 'goto-line)
(global-set-key "\C-xb" 'my-switch-to-buffer)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\C-q" 'electric-buffer-list)
(global-set-key "\C-x\C-b" 'buffer-menu)
(global-set-key "\C-x\C-y" 'cd)
(global-set-key "\es" 'shell)
(global-set-key "\C-xd" 'display-filename)
(global-set-key "\C-i" 'narten-do-a-tab)
(global-set-key "\C-x\C-b" 'buffer-menu)
(global-set-key "\C-_\C-_" 'help-for-help)
(global-set-key "\C-_\C-a" 'apropos)
(global-unset-key "\C-_\C-c")
(global-unset-key "\C-_\C-d")
(global-unset-key "\C-_\C-n")
(global-unset-key "\C-_\C-w")
(defun my-delete-other-windows ()
  (interactive)
  (delete-other-windows)
  (recenter))
(defun narten-suspend-emacs ()
  (interactive)
  (save-all-buffers)
  (suspend-emacs))
(defun narten-do-a-tab ()
  (interactive)
  (cond ((looking-at "^") 
 (progn (delete-horizontal-space)
(indent-relative)))
((looking-at "[ \t]*")
 (tab-to-tab-stop)))
  (let ((beg (point)))
(re-search-backward "[^ \t]")
(tabify (point) beg))
  (re-search-forward "[ \t]+"))
(defun display-filename ()
  (interactive)
  (message buffer-file-name))
(defun save-all-buffers ()
  (interactive)
  (save-some-buffers 1)
  (message "done!"))
(defun my-switch-to-buffer () 
  "switch to buffer, using completion to prevent bogus buffer names from
being given"
  (interactive)
  (switch-to-buffer (read-buffer "Switch to buffer: " (other-buffer) "t")))
;;;
;;; GNUS stuff
;;;
(setq gnus-nntp-server "astro")
(setq gnus-your-domain "sunrise.com")
(setq gnus-your-organization "Sunrise Software International")

(setq display-time-day-and-date t)
(setq display-time-no-load t)
(setq display-newmail-beep t)
(display-time)
;;(setq-default tab-width 4 )fred

(put 'narrow-to-region 'disabled nil)


(put 'narrow-to-page 'disabled nil)

(put 'insert-file 'disabled nil)

(autoload 'python-mode "python-mode" "" t)
(setq auto-mode-alist
  (cons '("\\.py$" . python-mode) auto-mode-alist))
;;(my-delete-other-windows)
;;(electric-buffer-list)

;;(cond (window-system
;;   (setq hilit-mode-enable-list  '(not text-mode)
;; hilit-background-mode   'light
;; hilit-inhibit-hooks nil
;; hilit-inhibit-rebinding nil)
;;
;;   (require 'hilit19)
;;   ))

;;
;; Hilit stuff
;;
;;(cond (window-system
;;   (setq hilit-mode-enable-list  '(not text-mode)
;; hilit-background-mode   'light
;; hilit-inhibit-hooks nil
;; hilit-inhibit-rebinding nil)
;;
;;   (require 'hilit19)
;;   ))
;;(require 'paren)

(setq-default transient-mark-mode t)

;;(electric-buffer-menu-mode)
(my-delete-other-windows)
snip
ends--




-Original Message-
From: Rex Eastbourne [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 26, 2005 2:49 PM
To: python-list@python.org
Subject: Re: Running Python interpreter in Emacs


I went to My Computer | Properties | Advanced | Environment Variables
and added c:\program files\python24 to both the PYTHONPATH and Path
variables. Still no luck. I don't know whether the path I'm talking
about is the same as the $PATH you referred to, or whether I'm supposed
to put python.exe explicitly somewhere; could someone refer me to a
place where I can read about these things?

Thanks!

Rex

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

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby n

Re: Boss wants me to program

2005-06-27 Thread Brian
Hi Xeys,

Even though I absolutely love Python...

Microsoft Visual Basic (.NET) would be your best bet for this type of 
software development.  It allows you to create GUI apps that can work 
with a variety of database options, such as Access or MS SQL Server.

My personal opinion is this:

1) Python shines the best on the server realm.
2) VB.net shines the best on the client-computer realm.

Brian
---



[EMAIL PROTECTED] wrote:
> I'm a manager where I work(one of the cogs in a food service company).
> The boss needed one of us to become the "tech guy", and part of that is
> writing small windows programs for the office. He wants the development
> work done in house, and he knows I am in school for a CS minor. I know
> basic C++(Part 2 of that is in the fall), and I will be taking Java 1
> in the fall also. What is the easiest way for me to make windows
> programs that will do basic things like(Inventory, Menu Management,
> etc...)? I have heard visual basic is where it's at. I want to keep an
> open mind though, so I am wondering if python could be an option. The
> programs have
> no speed requirement.  But they must be pretty, and not confuse my
> boss. Plus he wants well documented help for each function. I asked the
> windows programming group, but I thought I would ask here also. Thanks.
> 
> Xeys
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-27 Thread phil
I see several on this list have their opinion and lean toward VB.
Not me, done that and vc++. Hate'em.  Been developing 30 years
and I like control over what I'm doing and Python and Tkinter are
the best tools I've ever used. And for the most part IDE's like
BOA Constructor are just confusing. IMHO.

[EMAIL PROTECTED] wrote:

> I'm a manager where I work(one of the cogs in a food service company).
> The boss needed one of us to become the "tech guy", and part of that is
> writing small windows programs for the office. He wants the development
> work done in house, and he knows I am in school for a CS minor. I know
> basic C++(Part 2 of that is in the fall), and I will be taking Java 1
> in the fall also. What is the easiest way for me to make windows
> programs that will do basic things like(Inventory, Menu Management,
> etc...)? I have heard visual basic is where it's at. I want to keep an
> open mind though, so I am wondering if python could be an option. The
> programs have
> no speed requirement.  But they must be pretty, and not confuse my
> boss. Plus he wants well documented help for each function. I asked the
> windows programming group, but I thought I would ask here also. Thanks.
> 
> Xeys
> 
> 



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


Re: Boss wants me to program

2005-06-27 Thread Philippe C. Martin
As well as wxDesigner (great!)

http://www.roebling.de/

Regards,

Philippe


Björn Lindström wrote:

> Apple Grew <[EMAIL PROTECTED]> writes:
> 
>> I think since speed is not such an issue (I heard that python can make
>> faster GUI programs) you should use Visual Basic. It is very well
>> suited for Windows programming. There is the good thing that you can
>> visually create the GUI hence it is easier to create the GUI.
> 
> Of course, you can do that with Python, too, with Glade
> (http://www.jamesh.id.au/software/libglade/) or Boa Constructor
> (http://boa-constructor.sourceforge.net/). (There might be more of
> them.)
> 

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

Re: Boss wants me to program

2005-06-27 Thread Thomas Bartkus
"Brian" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi Xeys,
>
> Even though I absolutely love Python...
>
> Microsoft Visual Basic (.NET) would be your best bet for this type of
> software development.  It allows you to create GUI apps that can work
> with a variety of database options, such as Access or MS SQL Server.
>
> My personal opinion is this:
> 
> 1) Python shines the best on the server realm.
> 2) VB.net shines the best on the client-computer realm.
>
I would modify that.

1) VB shines in the MS Windows/Office realm.
2) Python shines everywhere else.

Thomas Bartkus


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


Re: Getting binary data out of a postgre database

2005-06-27 Thread Diez B. Roggisch
projecktzero wrote:
> Sorry for the late reply. I didn't check the group/list over the
> weekend.
> 
> Anyway, I added a print rec[0] just after the fetchone. Then I ran it
> from the command line, and it spewed a bunch of binary gibberish nearly
> locking up Putty.
> 
> To me, it seems like it's coming out in the right format, but I'm not
> sure what I'm doing wrong.  If you have any ideas, I'd really
> appreciate it.

What does

print rec[0].__class__

give you?

And what about using

tempFile.write(str(rec[0]))

if print really resulted in the binary data, this might help.

The DB-Api isn't too detailed about binary columns at all - the just 
mentioned a Binary() object, and something about buffer objects. I'm not 
sure how to ndeal with these - they seem to be mentioned in the 
C-Api-Section only.


Sorry that I can't be of more help.
Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules for inclusion in standard library?

2005-06-27 Thread Michael Hoffman
Robert Kern wrote:

> I would like to see the setuptools/PythonEggs/EasyInstall trifecta get 
> more attention and eyeballs. Once it is mature, I think that it will 
> obviate the desire for stdlibification of most of the packages being 
> requested here.

Looks pretty cool!
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


rsync protocol in python

2005-06-27 Thread David Bear
I was wondering if anyone has implemented the rsync protocol in python.

-- 
David Bear
-- let me buy your intellectual property, I want to own your thoughts --
-- 
http://mail.python.org/mailman/listinfo/python-list


Non-blocking raw_input

2005-06-27 Thread Jorge Louis de Castro
Hi,

Could anyone tell me whether I can find a non blocking alternative to 
raw_input that works on windows? Is there not a python way of achieving 
this? Can I find it somewhere in the documentation?
Any help will be highly appreciated

Cheers
j.


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


Re: rsync protocol in python

2005-06-27 Thread Robert Kern
David Bear wrote:
> I was wondering if anyone has implemented the rsync protocol in python.

GIYF.

http://directory.fsf.org/pysync.html

-- 
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: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Delaney, Timothy (Tim)
Aahz wrote:

> Perhaps.  But adding the time to learn those IDEs in addition to the
> time 
> to learn Java is ridiculous.  I've been forced to use Java a bit to
> support credit cards for our web application; I've got a friend whose
> Java-vs-Python argument hinges on the use of Eclipse; I was unable to
> make use of Eclipse in the time I had available for the project.

Absolutely. I've really tried to use Eclipse - it's the standard editor
for my current project (Java - blegh!). I *hate* it. It's huge, bulky,
slow ... I've gone back to my text editor. I'm a hell of a lot more
productive because the IDE isn't getting in my way.

The only IDE I've ever actually liked using was Metrowerks CodeWarrior
(on MacOS classic). Simple, unobtrusive. Good project management,
without trying to control every aspect of the development process. And
it allowed me to use the entire screen for editing if I wished whilst
still having everything readily available.

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


FlashMX and Py2exe doesn't fly...

2005-06-27 Thread Grooooops
Flash and Python could be a VERY powerful pair of tools for building
quick apps, Yet I don't see much on the web about it.

I was excited to see that it is possible to make them play together
here:
http://www.klaustrofobik.org/blog/archives/000235.html

Unfortunately, these folks seem to have gotten stuck on compiling the
py files to exe, and since I don't see reference to it anywhere else, I
was wondering if anyone here knew why it didn't work, or if anyone had
ideas about how to make it work.

Normally I would put some test code here, but I'm way out of my league.
Just insanely curious...

Any thoughts???


Thanks,
-J

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


Re: Thoughts on Guido's ITC audio interview

2005-06-27 Thread Aahz
In article <[EMAIL PROTECTED]>,
Ivan Van Laningham  <[EMAIL PROTECTED]> wrote:
>Aahz wrote:
>> 
>> Perhaps.  But adding the time to learn those IDEs in addition to the time
>> to learn Java is ridiculous.  I've been forced to use Java a bit to
>> support credit cards for our web application; I've got a friend whose
>> Java-vs-Python argument hinges on the use of Eclipse; I was unable to
>> make use of Eclipse in the time I had available for the project.
>
>Were there _good_ reasons not to do the credit card part of the web app
>in Java instead of Python?  As in, there is no secure module, or you
>didn't have time, or Python doesn't support crucial APIs?  I'm very
>curious.

The problem was that we needed to use a vendor-supplied library.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boss wants me to program

2005-06-27 Thread Brian
Thomas Bartkus wrote:
> I would modify that.
> 
> 1) VB shines in the MS Windows/Office realm.
> 2) Python shines everywhere else.

True.  However, it's also important to remember that most computer 
systems (at least in the United States) come with Microsoft Windows 
installed on them.  You have to write software for the platform that one 
will be working with -- in most cases, that's Microsoft Windows.  :-)

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


Re: Python & firewall control (Win32)

2005-06-27 Thread Tim Williams (gmail)
On 6/17/05, Tim Williams <[EMAIL PROTECTED]> wrote:
> 
> > - Original Message -
> > From: "Tom Anderson" <[EMAIL PROTECTED]>
> > 
> re: http://wipfw.sourceforge.net/?page=home
> 
> Tom,  this looks good.   I had it downloaded, installed and running some
> custom rules in under 5 minutes.  Very simple and straightforward.
> 
> > AIUI, you won't be stopping and restarting ipfw
> 
> This is correct,  the service doesn't appear to restart,the rule updates
> are actioned very quickly (instantaneous)
> 
> I haven't had chance to try it integrated into a Python app,  but it looks
> very promising,.
>

Tom,  I found that controlling the firewall via popen3 is perfect,  I
now have server applications that can firewall themselves when they
detect possible attacks or abuse from individual IPs, ranges etc

eg:

import  win32pipe as W

#add a rule at position 100
i,o,e = W.popen3('C:\\ipfw\\bin\\ipfw add 100 allow IP from me to 192.0.0.1')
-or-
# list all rules
i,o,e = W.popen3('C:\\ipfw\\bin\\ipfw list')
-or-
#delete rule 100
i,o,e = W.popen3('C:\\ipfw\\bin\\ipfw delete 100')

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


SCF 1.1 with BasicCard support released

2005-06-27 Thread Philippe C. Martin
Dear all,

I am very happy to announce the release of SCF 1.1, a Python based Smart
Card development framework for Windows® and Linux.

SCF 1.1 introduces support for BasicCard® Enhanced and Professional under
GNU/Linux and Windows®.
All commands are supported as well as firmware image parsing so you have
full control of the personalization process: application + data.

The SCF Shell is now "BasicCard-aware". 

SCF is available on www.snakecard.com for download and free testing. 
You may also browse the reference guide online.

Best regards,

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

Re: pulling multiple instances of a module into memory

2005-06-27 Thread Grooooops
in spam.py, how about something like this:

try:
  eggs.someFunction()
except:
  import eggs

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


Plain text email?

2005-06-27 Thread Inkiniteo
Hi guys. I have a script that sends the info by email, but i'd like to
avoid the convertion to HTML by the email client or Gmail, because it
ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
be able to send SMTP mail  and the receiver only get it in plain text.

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


Re: Non-blocking raw_input

2005-06-27 Thread Peter Hansen
Jorge Louis de Castro wrote:
> Could anyone tell me whether I can find a non blocking alternative to 
> raw_input that works on windows? Is there not a python way of achieving 
> this? Can I find it somewhere in the documentation?
> Any help will be highly appreciated

Depending on what your requirements are (since you don't really say), 
the functionality in the standard msvcrt module might help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pulling multiple instances of a module into memory

2005-06-27 Thread infidel
Do you have control over the eggs.so module?  Seems to me the best
answer is to make the start method return a connection object

conn1 = eggs.start('Connection1')
conn2 = eggs.start('Connection2')

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


Re: Modules for inclusion in standard library?

2005-06-27 Thread Chris Connett
pyparsing is the far and away the easiest general purpose parser out
there that I've encountered; BNF-style grammar parsing is a *pleasure*
with pyparsing.  And it all comes in a single pure python module to
boot.

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


Re: Plain text email?

2005-06-27 Thread Tim Williams (gmail)
On 27 Jun 2005 15:38:59 -0700, Inkiniteo <[EMAIL PROTECTED]> wrote:
> Hi guys. I have a script that sends the info by email, but i'd like to
> avoid the convertion to HTML by the email client or Gmail, because it
> ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
> be able to send SMTP mail  and the receiver only get it in plain text.
> 

Can you give a short example of how you are building the email ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread TZOTZIOY
On 27 Jun 2005 15:38:59 -0700, rumours say that "Inkiniteo"
<[EMAIL PROTECTED]> might have written:

>Hi guys. I have a script that sends the info by email, but i'd like to
>avoid the convertion to HTML by the email client or Gmail, because it
>ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
>be able to send SMTP mail  and the receiver only get it in plain text.

Please tell us what you do more precisely:

* do you send the "info" as an attachment using the email package?
* do you create alternative text and HTML parts for the body?

I have never managed to send plain text email and receive it as HTML.
Perhaps you mean that some "smart" client does something stupid with
your text, eg. it removes line-breaks you have in your message?


Try this:

import smtplib

def send(server, from_whom, to_whom_list):
smtp = smtplib.SMTP(server)
smtp.sendmail(from_whom, to_whom_list,
"""From: %s
To: %s
Subject: test email

This is a test.
It has line breaks.
Does it come as three separate lines?""")

I tried it as

send('localhost', '[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'])

and I had no problem.  What happens for you (substitute other server and
email addresses, obviously :) ?
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread TZOTZIOY
On 27 Jun 2005 15:38:59 -0700, rumours say that "Inkiniteo"
<[EMAIL PROTECTED]> might have written:

>Hi guys. I have a script that sends the info by email, but i'd like to
>avoid the convertion to HTML by the email client or Gmail, because it
>ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
>be able to send SMTP mail  and the receiver only get it in plain text.

Please tell us what you do more precisely:

* do you send the "info" as an attachment using the email package?
* do you create alternative text and HTML parts for the body?

I have never managed to send plain text email and receive it as HTML.
Perhaps you mean that some "smart" client does something stupid with
your text, eg. it removes line-breaks you have in your message?


Try this:

import smtplib

def send(server, from_whom, to_whom_list):
smtp = smtplib.SMTP(server)
smtp.sendmail(from_whom, to_whom_list,
"""From: %s
To: %s
Subject: test email

This is a test.
It has line breaks.
Does it come as three separate lines?""" % (from_whom,
", ".join(to_whom_list))

I tried it as

send('localhost', '[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'])

and I had no problem.  What happens for you (substitute other server and
email addresses, obviously :) ?
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread Inkiniteo
Humm. I just create the message this way:

message = 'Serie:\t\t' + str(type) + str(series) + \
  '\t\t\tUbicación:\t\t\t' + place + '\n' + \
  'Date&Time:\t' + date

and send it with:
message = header + message
server = smtplib.SMTP('localhost')
server.sendmail('[EMAIL PROTECTED]', email, message)
server.quit()

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


Re: Plain text email?

2005-06-27 Thread TZOTZIOY
On 27 Jun 2005 16:09:38 -0700, rumours say that "Inkiniteo"
<[EMAIL PROTECTED]> might have written:

>Humm. I just create the message this way:

>message = 'Serie:\t\t' + str(type) + str(series) + \
>  '\t\t\tUbicación:\t\t\t' + place + '\n' + \
>  'Date&Time:\t' + date

>and send it with:
>message = header + message
>server = smtplib.SMTP('localhost')
>server.sendmail('[EMAIL PROTECTED]', email, message)
>server.quit()

And what goes wrong when you see the message?  (BTW you don't have a
newline before "Ubicación:"; is it intentional?)

Tabs are infamous confusers of email clients, unfortunately.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a dictionary from a list

2005-06-27 Thread Raymond Hettinger
[Roy Smith]
> I also think the published description is needlessly confusing.  Why does
> it use
>
>{'one': 2, 'two': 3}
>
> as the example mapping when
>
>{'one': 1, 'two': 2}
>
> would illustrate exactly the same point but be easier to comprehend.  The
> mapping given is the kind of thing I would expect to see in an obfuscated
> programming contest.
>
> Also, what's the point of the last example:
>
>dict([(['one', 'two'][i-2], i) for i in (2, 3)])
>
> It boils down to passing a list of tuples as an argument, which is already
> illustrated by other examples.  This is just a complicated and obtuse way
> to construct the list of tuples.  What does it add to the understanding of
> how the dict() constructor works?

If you can switch from indignation to constructive criticism, then
consider sending a note to Andrew Kuchling suggesting ways to improve
the examples.


Raymond

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


Re: a dictionary from a list

2005-06-27 Thread Raymond Hettinger
[Roy Smith]
> I also think the published description is needlessly confusing.  Why does
> it use
>
>{'one': 2, 'two': 3}
>
> as the example mapping when
>
>{'one': 1, 'two': 2}
>
> would illustrate exactly the same point but be easier to comprehend.  The
> mapping given is the kind of thing I would expect to see in an obfuscated
> programming contest.
>
> Also, what's the point of the last example:
>
>dict([(['one', 'two'][i-2], i) for i in (2, 3)])
>
> It boils down to passing a list of tuples as an argument, which is already
> illustrated by other examples.  This is just a complicated and obtuse way
> to construct the list of tuples.  What does it add to the understanding of
> how the dict() constructor works?

If you can switch from indignation to constructive criticism, then
consider sending a note to Andrew Kuchling suggesting ways to improve
the examples.


Raymond

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


Re: Plain text email?

2005-06-27 Thread Philippe C. Martin
Hi,

I had the exact opposite problem :-)

Hope this helps

Regards,

Philippe



#
def Mail(self,p_data): #data is string of text

you = wx.GetTextFromUser('EMAIL ADDRESS','ID')
if len(you) == 0:
return

self.__m_config = Config()

self.__m_config.Load()

me = self.__m_config.dict['ACCOUNT']
host = self.__m_config.dict['SMTP']
s = smtplib.SMTP()
s.connect(host)


s.login(me,self.__m_config.GPW())

the_text = p_data
msg = MIMEText(the_text)

# ***GET RID OF THIS LINE TO HAVE PLAIN TEXT

msg.replace_header('Content-Type', 'text/html') 
# ***GET RID OF THIS LINE TO HAVE PLAIN TEXT

#msg.add_header('Content-Type', 'text/html')

msg['To'] = you
msg['Subject'] = self.__m_title
msg['From'] = self.__m_config.dict['FROM']   
s.sendmail(me, [you], msg.as_string())
self.__m_list = []



Inkiniteo wrote:

> Hi guys. I have a script that sends the info by email, but i'd like to
> avoid the convertion to HTML by the email client or Gmail, because it
> ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
> be able to send SMTP mail  and the receiver only get it in plain text.

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


Re: FlashMX and Py2exe doesn't fly...

2005-06-27 Thread Myles Strous
Grops wrote:
> Flash and Python could be a VERY powerful pair of tools for building
> quick apps, Yet I don't see much on the web about it.
>
> I was excited to see that it is possible to make them play together
> here:
> http://www.klaustrofobik.org/blog/archives/000235.html
>
> Unfortunately, these folks seem to have gotten stuck on compiling the
> py files to exe, and since I don't see reference to it anywhere else, I
> was wondering if anyone here knew why it didn't work, or if anyone had
> ideas about how to make it work.

They seem to have fixed it (haven't tried it myself) in a later
discussion:
see http://www.klaustrofobik.org/blog/archives/000236.html

Regards, Myles.

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


Re: Photo layout

2005-06-27 Thread stephen
Thanks! This works well -- I was letting myself be too intimidated with
reportlab before looking at the documentation, but it was really not
hard at all. I think I figured out how to do landscape mode too.

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter

def insertPicture(c):
c.drawInlineImage("geese1.jpg",100,100,200,150)

width, height = letter
letter = height, width # change to landscape
c = canvas.Canvas("picture.pdf",pagesize=letter)
insertPicture(c)
c.showPage()
c.save()

Larry Bates wrote:
> You can use Python Imaging Library (PIL) and ReportLab to resize and
> place the photos on a page quite easily.  Actually ReportLab calls
> PIL automatically to resize the photos when you call .drawInlineImage
> method of the canvas object with the proper width and height arguments.
>
> To get ReportLab go to: http://www.reportlab.org
>
> Note: I'm assuming the photos are in .JPG, .TIF or some format that
> PIL can recognize.  If they are in some proprietary RAW format you
> will need to convert them first.
>
> -Larry Bates
>
> Stephen Boulet wrote:
> > Is there a python solution that someone could recommend for the following:
> >
> > I'd like to take a directory of photos and create a pdf document with
> > four photos sized to fit on each (landscape) page.
> > 
> > Thanks.
> > 
> > Stephen

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


Re: FlashMX and Py2exe doesn't fly...

2005-06-27 Thread James Carroll
They did it with Gush: (I think)
   http://2entwine.com/

It's a py program that embeds Flash very nice.

-Jim

On 27 Jun 2005 15:11:11 -0700, Grops <[EMAIL PROTECTED]> wrote:
> Flash and Python could be a VERY powerful pair of tools for building
> quick apps, Yet I don't see much on the web about it.
> 
> I was excited to see that it is possible to make them play together
> here:
> http://www.klaustrofobik.org/blog/archives/000235.html
> 
> Unfortunately, these folks seem to have gotten stuck on compiling the
> py files to exe, and since I don't see reference to it anywhere else, I
> was wondering if anyone here knew why it didn't work, or if anyone had
> ideas about how to make it work.
> 
> Normally I would put some test code here, but I'm way out of my league.
> Just insanely curious...
> 
> Any thoughts???
> 
> 
> Thanks,
> -J
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plain text email?

2005-06-27 Thread John Roth
"Inkiniteo" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi guys. I have a script that sends the info by email, but i'd like to
> avoid the convertion to HTML by the email client or Gmail, because it
> ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
> be able to send SMTP mail  and the receiver only get it in plain text.

As long as your mimetype is text/plain you should have
minimal trouble. There's no way you can control what
the recipient's mail client does, however.

In particular, there are a lot of mail clients out there that
handle tabs poorly. Outlook Express is the poster child
for this: it ignores tabs completely, however it is by no
means the only culprit. It's simply the most widespread one.

In other words, use strings of spaces rather than tabs,
and you'll probably find your messages coming out
looking better.

John Roth
> 

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


  1   2   >