Re: Python becoming less Lisp-like

2005-03-15 Thread Torsten Bronger
HallÃchen!

Steven Bethard <[EMAIL PROTECTED]> writes:

> Torsten Bronger wrote:
>
>> the underlying constructs are utterly ugly, as are some of
>> Python's features (e.g. __getattr__ and such, and decorators, in
>> order to get nice class properties).
>
> What do you find ugly about __getattr__?

[First, I wanted to say "descriptors" instead of "decorators" (I
superseded my post).]

The goal is to trigger function calls when attributes are accessed.
This is called properties in C# (and maybe in Ruby, too).  Python
now also has this concept.  What I find ugly is that it is not a
syntax element.  It looks artificially added to the language.  In
C#, the "set" and "get" methods form with its attribute a syntactic
unity.  Everything is together, and no "property" function is
necessary.

>> I looked for a new language for my hobby programming.
>
> [snip]
>
>> I want to go with Python, but you can definitely see that it's
>> the oldest one: Many parts of its syntax are awkward and look
>> like patchwork.
>
> Interesting.  I've never thought that.  What parts strike you as
> "patchwork"?

Well, with a little bit of experience in the field of programming
languages, you can see which elements had been added later (ie years
after Python's creation).  Properties surely would have looked
*very* different 15 years ago.

There would be keywords for static and class methods, no distinction
between Unicode and non-Unicode, and probably no multiple
inheritance (which seem to have caused a lot of trouble recently),
and no __new__.

At first, I was very pleased by Python's syntax (and still I am).
Then, after two weeks, I learned about descriptors and metaclasses
and such and understood nothing (for the first time in syntax I felt
totally lost).

The reason why I stay with Python is (apart from the indenting
syntax, huge community, and equally huge library) my feeling that
the Python developers what to unify the language, even by dropping
features.  The current snapshot is a transitional Python and thus
with some double features.  The numerical types and two kinds of
classes are examples.  I'm very surprised about this, because Python
is a production language, but I'm happy, too.

TschÃ,
Torsten.

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


Re: variable arguments question

2005-03-15 Thread Stephan Diehl
On Tue, 15 Mar 2005 03:48:40 -0400, vegetax wrote:

> if i have a dictionary: 
> d = {'a':2,'b':3 }
> l = (1,2)
> 
> how can i pass it to a generic function that takes variable keywords as
> arguments? same thing with variable arguments, i need to pass a list of
> arguments to the function
> 
> def asd(**kw): print kw
> def efg(*arg): print arg
> 
> asd(d) 
> doesnt work
> asd(kw = d) 
> doesnt work

but asd(**d)

> 
> efg(l)
> doesnt work

and efg(*l)

will work.
> 
> i need to pass those as a dictionary and a list,since i dont know ahead of
> time if which items would have d and l

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


Re: variable arguments question

2005-03-15 Thread Roel Schroeven
vegetax wrote:
> if i have a dictionary: 
> d = {'a':2,'b':3 }
> l = (1,2)
> 
> how can i pass it to a generic function that takes variable keywords as
> arguments? same thing with variable arguments, i need to pass a list of
> arguments to the function
> 
> def asd(**kw): print kw
> def efg(*arg): print arg
> 
> i need to pass those as a dictionary and a list,since i dont know ahead of
> time if which items would have d and l

You can call them with a syntax resembling the way you defined them:

>>> asd(**d)
{'a': 2, 'b': 3}
>>> efg(*l)
(1, 2)


-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: urllib (and urllib2) read all data from page on open()?

2005-03-15 Thread Fuzzyman

Bengt Richter wrote:
> On Mon, 14 Mar 2005 14:48:25 -, "Alex Stapleton"
<[EMAIL PROTECTED]> wrote:
>
> >Whilst it might be able to do what I want I feel this to be a flaw
in urllib
> >that should be fixed, or at least added to a buglist somewhere so I
can at
> >least pretend someone other than me cares.
> >
> Someone cares about top-posting. Please don't ;-)

Actually for many methods of reading usenet posts, and particularly for
archived usenet posts - e.g. google groups - selective top posting can
make threads a lot easier to read.

Heresy though it may be.

;-)

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

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


Re: How can I load a module when I will only know the name 'on the fly'

2005-03-15 Thread gene . tani
imp.find_module() and imp.load_module:

http://www.python.org/doc/2.3.4/whatsnew/section-pep302.html
http://docs.python.org/lib/module-imp.html

renwei wrote:
> use built-in function:  __import__
>
> m = __import__('sys', globals())
> print m.platform
>
> weir
>
>
>
> "Tobiah" <[EMAIL PROTECTED]> >
> >
> > m = get_next_module()
> >
> > some_nice_function_somehow_loads( m )
> >
> > Thanks,
> >
> > Tobiah

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


Re: Tkinter Bitmap Newbie question

2005-03-15 Thread Eric Brunel
On Tue, 15 Mar 2005 00:00:57 GMT, Neil Hodgson <[EMAIL PROTECTED]> wrote:
Wim Goffin:
But just to make sure I'm on the right track,
- Is XBM the best way to for bitmaps? The ones I saw so far are all black
and white. Do they also exist in color?
   XPM is the version of XBM with colour.
- Is XBM also the best format for glyphs on the Windows platform? Or would
'Images' of a different format be nicer?
   It depends on what you want to do with icons. Do you want users to be
able to change icons? It is less likely Windows users will have tools
for manipulating XPM files. The only feature that you are likely to want
that is not available from XPM is multi-level transparency which is
available from PNG files.
   My generic advice without additional details of your project is that
PNG is the best format for icons displayed by your code. Icons used by
the operating system such as for applications should be in a format
supported by that OS: Windows prefers ICO files.
XPM, PNG and ICO files are not natively supported by tk/Tkinter. The only 
natively supported format is GIF, apparently mainly for historical reasons. 
There are tcl/tk extensions allowing to handle other image formats, but they 
may be weird to use from Tkinter (never tried them). If you want a portable 
application or if you just don't want to bother, you'd better use either XBM or 
GIF files for images.
HTH
--
python -c 'print "".join([chr(154 - ord(c)) for c in 
"U(17zX(%,5.z^5(17l8(%,5.Z*(93-965$l7+-"])'
--
http://mail.python.org/mailman/listinfo/python-list


Downloading all files older than 3 hours from a ftp-server.

2005-03-15 Thread Thomas W
I need to download all files older than 3 hours from a ftp-server.
What's the easiest way to this? I've looked into the standard ftplib,
but it seems like the only way to go is to parse the
ftp.retrlines('LIST') command and that seems to be very easy to mess
up. 

any hints? 

Best regards,
Thomas W

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


Lisp-likeness

2005-03-15 Thread Kay Schluehr
Maybe You can answer my question what this simple LISP function does ?

(defun addn (n)
  #'(lambda (x)
  (+ x n)))

This is correct LISP-syntax if You bear in mind LISPs powerwull macro
language...

I think Guido and python-dev are very carefull in adding new power to
Python. They have to balance the needs for powerfull language features
on the one hand, simplicity on the other hand. That this relation
drifts towards more power and more complexity since Python 2.2. is a
correct observation, but You probably may have notized that the number
of large projects using Python as their primal language is growing. The
boundary between that what was formerly called "systems programming"
and "scripting" is blurred ( if Your mindset reduces
"systems-programming" on the availability of pointers You certainly
don't have any problems with the common public prejudices ).

> The real problem with Python is that it has been very successful as a
> scripting language in the static-typing/C/C++ world. Those
> programmers, instead of adapting their evil ways to Python, and
> realizing the advantages of a dynamic language, are influencing
> Python's design and forcing it into the static-typing mold. Python is
> going the C++ way: piling feature upon feature, adding bells and
> whistles while ignoring or damaging its core design.

Maybe You should explain what You regard as Pythons "core design", what
belongs to the core and what to the periphery? Otherwise Your statement
seems to be plain emotional.

> The new 'perlified' syntax for decorators, the new static type bonds
> and the weird decision to kill lambda instead of fixing it are good
> examples that show that Python is going the wrong way.

My hypothesis about lambda: lambda will be trashed because it is an
alien in the language. It is impure. Trashing it is an expression of
Pythons rassism. There is no way of "doing it right" without exceeding
it's power and making it  less controlable. When Guido once stated that
the generator way of doing things is Pythons future it was also a
renouncement of lambda. Compared with this ideological orientation the
introduction of the @-syntax is a minor sacrilege on syntax esthetics -
though this special character may hurd the souls of the believers more
that everything else introduced into the language.

Kay

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


Bitmaps On Buttons ?

2005-03-15 Thread PGMoscatt
I am slowly progressing with my python app.

I have got to the point where I would like to place images onto my buttons. 
I use Tkinter as my GUI libary.

The following is how I understand I place an image onto a button - but I am
not having much success with it all.

Any ideas ?

Pete

b=Button(ToolBar,padx=1,pady=1,width=2,height=1,command=callquit,)
b.bitmap="@button_cancel.xbm"
b.place(x=0,y=0)

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


Re: win32 shell extension (virtual drive)

2005-03-15 Thread Fuzzyman
Not much help... but the place to be looking is in the win32 api.
You'll then need to see if the functionality is already exposed in the
win32 extensions by Mark Hammond - if not you can use ctypes to access
it. The ctypes mailing list might be a useful place to ask questions -
but it's not something I can help with... although if someone feels
like writing a tutorial it's a subject I would be very interested in...

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml.

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


Re: is there a problem on this simple code

2005-03-15 Thread jrlen balane
rx_data = ser.read(19)
byte[] = unpack('19B', rx_data)

for k in range(9):
if byte[k] == 70
if byte[k+2] == 6
if byte[k+9] ==
-(byte[k]+byte[k+1]+byte[k+2]+byte[k+3]+byte[k+4]+byte[k+5]+byte[k+6]+byte[k+7]+byte[k+8])
& 0xff
print byte[k:k+9]

what i am doing here is creating an array from based on the unpacked data
then i am searching for the array member that is equal to "70" since
it is going to be my reference. once i find it, i'll based my received
data from that point. then if the succeding tests are confirmed, i can
get my data.

please help(again) :(


On Tue, 15 Mar 2005 08:05:04 GMT, Dennis Lee Bieber
<[EMAIL PROTECTED]> wrote:
> On 14 Mar 2005 17:04:13 -0800, "John Machin" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
> 
> >
> > jrlen balane wrote:
> > > @sir John
> > > could you please show me how to do this exactly? it's in the "tip of
> > > my toungue" but i just can get it, please...
> > >
> >
> > You've had far too much help already for a school project. Asking for
> > someone to write the code for you is "over the fence".
> 
> The repetition /is/ getting tedious, isn't it...
> 
> At the least, getting a formal definition of the protocol the
> microcontroller uses would be nice. If it is continuously sending "70"
> status reports, WITHOUT handshaking (RTS/CTS), then I'd strongly
> recommend making the reader code a separate thread -- hopefully one
> won't lose bytes during other processing. When a valid status report is
> found, put it onto a Queue, which the main code can read when ever it
> finds time.
> 
> Heck, at this point in time... I'd remove everything involved
> with /sending/ commands. Start with coding something that only reads the
> status from the microcontroller (since it sounds like the controller is
> always sending). When the reader works correctly, then start trying to
> add the command writer.
> 
> --
>  > == <
>  >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >  [EMAIL PROTECTED] |   Bestiaria Support Staff   <
>  > == <
>  >   Home Page: <
>  >Overflow Page: <
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] RELEASED Python 2.4.1, release candidate 1

2005-03-15 Thread Richie Hindle

[Richie]
> It's possibly that it was an all-users installation but I
> copied the DLL into C:\Python24 for some reason

[Martin]
> Ah, ok. I could not have thought of *that*. That also explains it: the
> upgrading simply did not manage to remove/replace your copy of
> python24.dll.
> 
> It's easy to see the effect, then: Windows looks for python24.dll first
> in the directory of python.exe (where no DLL should have been found), 
> and would only fallback to system32 then (which it didn't in your case).

Yes, that's what's happened.  I've copied the new python24.dll into
C:\python24, and everything now thinks it's 2.4.1c1.  Sorry about that.

(I wish I could remember why I'd copied the DLL, but I can't.  I'd like to
think there was a good reason.  8-)

-- 
Richie Hindle
[EMAIL PROTECTED]

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


Re: Bitmaps On Buttons ?

2005-03-15 Thread Martin Franklin
PGMoscatt wrote:
I am slowly progressing with my python app.
I have got to the point where I would like to place images onto my buttons. 
I use Tkinter as my GUI libary.

The following is how I understand I place an image onto a button - but I am
not having much success with it all.
Any ideas ?
Pete
b=Button(ToolBar,padx=1,pady=1,width=2,height=1,command=callquit,)
b.bitmap="@button_cancel.xbm"
b.place(x=0,y=0)
put the bitmap= inside the construction of the button widget like so:
b = Button(ToolBar, padx=1, pady=1, width=2, height=1, command=callquit,
bitmap="@button_cancel.xbm")
BTW  You shouldn't need to set the height and width - the button will
take it's size from the bitmap
BTW2  I notice you are using place geometry manager you may get a 
'better' behaved GUI with the pack or grid geometry manager, it will
resize much better as widgets are pack'ed or grid'ed relative to each other

for more help you could try:
http://www.pythonware.com/library/tkinter/introduction/
or the Wiki that has links to other sources of help (including the
Tkinter mailing list
http://tkinter.unpythonic.net/wiki/FrontPage
Cheers
Martin

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Nick Craig-Wood
Torsten Bronger <[EMAIL PROTECTED]> wrote:
>  The current snapshot is a transitional Python and thus
>  with some double features.  The numerical types and two kinds of
>  classes are examples.  I'm very surprised about this, because Python
>  is a production language, but I'm happy, too.

As long as python 2.x -> 3.x/3000 isn't like perl 5.x -> perl 6.x I'll
be perfectly happy too.

"Less is more" is a much better philosophy for a language and having
the courage to take things out differentiates python from the crowd.

Of course we users will complain about removals, but we'll knuckle
down and take our medicine eventually ;-)

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web framework

2005-03-15 Thread Joe
On Tue, 15 Mar 2005 00:07:34 -0500, Benji York <[EMAIL PROTECTED]>
wrote:
>That's not entirely true of Zope 2, and not true at all for Zope 3.  All 
>code for Zope 3 is loaded from the file system.

Great news :-) I'll go check it out.

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


Re: is there a problem on this simple code

2005-03-15 Thread jrlen balane
did some editing:

rx_data = ser.read(19)
byte[0:18] = unpack('19B', rx_data)

   for k in range(9):
   if byte[k] == 70:
   if byte[k+2] == 6:
   if byte[k+9] ==
-(byte[k]+byte[k+1]+byte[k+2]+byte[k+3]+byte[k+4]+byte[k+5]+byte[k+6]+byte[k+7]+byte[k+8])
& 0xff:
   print byte[k:k+9]

heres the error:
Traceback (most recent call last):
  File "C:\Python23\practices\serialnewesttest2.py", line 28, in -toplevel-
byte[0:18] = unpack('19B', rx_data)
error: unpack str size does not match format

what i am doing here is creating an array from based on the unpacked data
then i am searching for the array member that is equal to "70" since
it is going to be my reference. once i find it, i'll based my received
data from that point. then if the succeding tests are confirmed, i can
get my data.

please help(again) :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python becoming less Lisp-like

2005-03-15 Thread Carl Banks

Torsten Bronger wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
> > Interesting.  I've never thought that.  What parts strike you as
> > "patchwork"?
>
> Well, with a little bit of experience in the field of programming
> languages, you can see which elements had been added later (ie years
> after Python's creation).  Properties surely would have looked
> *very* different 15 years ago.
>
> There would be keywords for static and class methods,

I don't think there would be.  For one thing, I doubt the Python
leadership thinks static and class methods are important enough to
warrant keywords.  For another thing, it violates Python's idea of how
much special belongs in class definitions (i.e., none at all).

In Python, classes aren't some magical land where the usual rules don't
hold (as they are in many other languages).  That's why "self." is used
on class variables, for instance.  A class is nothing more than a scope
that uses a smittering of magic to turn it into a type.

> no distinction
> between Unicode and non-Unicode,

True.

> and probably no multiple
> inheritance

I highly doubt it.  A couple years ago, when Python made the transition
to new-style classes, there was an opportunity to toss out multiple
inheritance.  Not only did the Python developers not toss it or
deprecate it, they put in a lot of work and effort to improve it.  We
now have a spiffy stable MRO algorithm to handle resolution of
attributes.

Besides, in the tradition of dynamic languages, MI is pretty par for
the course, unlike for static languages where it is seen as kind of
exotic.

>(which seem to have caused a lot of trouble recently),

Not sure what you're talking about here.  Was the problem with
XMLRPCServer related to MI?

> and no __new__.

Perhaps.  More likely, there would have been __new__ but no __init__.
At the C level, new and init do seem to serve distinct purposes, but I
don't know how important it would be in a new design.

> At first, I was very pleased by Python's syntax (and still I am).
> Then, after two weeks, I learned about descriptors and metaclasses
> and such and understood nothing (for the first time in syntax I felt
> totally lost).

Metaclasses weren't something that Python just threw in because it was
cool.  Rather, they were mostly a side effect of how Python constructs
classes.  When Python transistioned to new-style classes, the gods
decided to expose the metaclass functionality, because it could prove
useful in a lot of cases.

I believe, however, that there was an intentional lack of effort to
make them less obscure than they already are.  They didn't want average
people to be hacking metaclasses left and right.

> The reason why I stay with Python is (apart from the indenting
> syntax, huge community, and equally huge library) my feeling that
> the Python developers what to unify the language, even by dropping
> features.

Yes, fortunately that happens.  It's good, too.

> The current snapshot is a transitional Python and thus
> with some double features.  The numerical types and two kinds of
> classes are examples.  I'm very surprised about this, because Python
> is a production language, but I'm happy, too.

Yeah, well that's the price you gotta pay when remedying old mistakes
or restrictions.


-- 
CARL BANKS

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


Re: Can't seem to insert rows into a MySQL table

2005-03-15 Thread Anthra Norell
Very true!
I could verify that cursor.execute () seems to understand  "... %s ...",
..."string"... where print () doesn't.. I didn't know that.
I could also verify that gumfish's ineffective insertion command works fine
for me. (Python 2.4, mysql-3.23.38). So it looks like the problem is with
MySQL (e.g. table name, column names, ...)
Frederic

- Original Message -
From: "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To: 
Sent: Monday, March 14, 2005 11:55 PM
Subject: Re: Can't seem to insert rows into a MySQL table


> In <[EMAIL PROTECTED]>, Anthra Norell
> wrote:
>
> > Try to use % instead of a comma (a Python quirk) and quotes around your
> > strings (a MySQL quirk):
> >
> >cursor.execute("INSERT INTO edict (kanji, kana, meaning) VALUES
('%s',
> > '%s', '%s')" % ("a", "b", "c") )
>
> AFAIK grumfish made the Right Thingâ.  If you use '%', some interesting
> things can happen, e.g. if your values contain "'" characters.  The "%s"s
> without quotes and the comma let the DB module format and *escape* the
> inserted values for you in a safe way.
>
> Ciao,
> Marc 'BlackJack' Rintsch
> --
> http://mail.python.org/mailman/listinfo/python-list

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


raising an exception in one thread from an other. (PyThreadState_SetAsyncExc)

2005-03-15 Thread Antoon Pardon
I have been playing a bit with PyThreadState_SetAsyncExc. Now the
documentation abouth this call states the following:

| Returns the number of thread states modified; if it returns a number
| greater than one, you're in trouble, and you should call it again with
| exc set to NULL to revert the effect. 


Now I don't have trouble with it returning numbers greater that one.
However it does sometimes return zero. I have the impression this
happens when the thread in question has already finished. I have
two questions.

1) Should I call it again with exc set to NULL when it returned zero?

2) Would the following be a decent way to handle numbers returned
   greater than one? (Note the following is just to illustrate
   what I want to do, not functioning code)

  def raise_in_thread(thread_id, exception):

Nr = PyThreadState_SetAsyncExc(thread_id, exception)
while Nr > 1:
  PyThreadState_SetAsyncExc(thread_id, NULL)
  sleep(0.1)
  Nr = PyThreadState_SetAsyncExc(thread_id, exception)


What this basically does is when a number greater than one
is returned go in a loop to cancel the effect wait a short
time and try again.

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


python version anachronism

2005-03-15 Thread Xah Lee

this url:
http://www.python.org/doc/2.4/
sayz:
Python 2.4 Documentation  (released November 30, 2004)

but this url:
http://www.python.org/doc/2.3.5/
sayz:
Python 2.3.5 Documentation  (released February 8th, 2005)


so, python 2.3.5 is released about 2 months later than 2.4??

also, does the "released ..." indicates the doc or the doc and the
software?

 Xah
 [EMAIL PROTECTED]
 http://xahlee.org/PageTwo_dir/more.html

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


simulated samba server

2005-03-15 Thread tc
Does anyone know of a module for python which simulates a samba server
(windows fileshare). Instead of sharing a Phisical Device I'd like to
share a database based filesystem which is spread over various numbers
of drives and servers.

Any hints?

TC

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


Re: python version anachronism

2005-03-15 Thread Swaroop C H
--- Xah Lee <[EMAIL PROTECTED]> wrote:
> so, python 2.3.5 is released about 2 months later than 2.4??

As far as I understand, 2.3.5 is a maintenance release in the 2.3
branch. It is independent of the 2.4 branch.



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


[perl-python] unicode study with unicodedata module

2005-03-15 Thread Xah Lee
python has this nice unicodedata module that deals with unicode nicely.

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

from unicodedata import *

# each unicode char has a unique name.
# one can use the âlookupâ func to find it

mychar=lookup('greek cApital letter sIgma')
# note letter case doesn't matter
print mychar.encode('utf-8')

m=lookup('CJK UNIFIED IDEOGRAPH-5929')
# for some reason, case must be right here.
print m.encode('utf-8')

# to find a char's name, use the ânameâ function
print name(u'å')

basically, in unicode, each char has a number of attributes (called
properties) besides its name. These attributes provides necessary info
to form letters, words, or processing such as sorting, capitalization,
etc, of varous human scripts. For example, Latin alphabets has two
forms of upper case and lower case. Korean alphabets are stacked
together. While many symbols corresponds to numbers, and there are also

combining forms used for example to put a bar over any letter or
character. Also some writings systems are directional. In order to form

these symbols for display or process them for computing, info of these
on each char is necessary.

the rest of functions in unicodedata return these attributes.

see unicodedata doc:
http://python.org/doc/2.4/lib/module-unicodedata.html

Official word on unicode character properties:
http://www.unicode.org/uni2book/ch04.pdf

--
i don't know what's the state of Perl's unicode. Is there something
similar?

--
this post is archived at
http://xahlee.org/perl-python/unicodedata_module.html

 Xah
 [EMAIL PROTECTED]
 http://xahlee.org/PageTwo_dir/more.html

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


Re: is there a problem on this simple code

2005-03-15 Thread John Machin

jrlen balane wrote:
> did some editing:
>

The error means that you received less than 19 bytes of data.

> rx_data = ser.read(19)
!rx_len = len(rx_data)
!print 'rx_len', rx_len
> byte[0:18] = unpack('19B', rx_data)
!# trash the above, do this
!byte = [ord(x) for x in rx_data]
!print 'received', byte
!if rx_len < 10:
!   print 'it is not pumping data out as fast as we assumed!'
!   sys.exit(1)
>
!for k in range(rx_len - 9):
>if byte[k] == 70:
>if byte[k+2] == 6:
>if byte[k+9] ==
>
-(byte[k]+byte[k+1]+byte[k+2]+byte[k+3]+byte[k+4]+byte[k+5]+byte[k+6]+byte[k+7]+byte[k+8])
> & 0xff:

Yuk!

(1) use 'and'
(2) when you find yourself typing repetitive crap like that, your brain
should be shrieking "There must be a better way!!"

if byte[k] == 70 \
and byte[k+2] == 6 \
and sum(byte[k:k+10]) & 0xff == 0:



>print byte[k:k+9] <<=== you probably mean 10,
not nine
> 
> heres the error:
> Traceback (most recent call last):
>   File "C:\Python23\practices\serialnewesttest2.py", line 28, in
-toplevel-
> byte[0:18] = unpack('19B', rx_data)
> error: unpack str size does not match format
>
> what i am doing here is creating an array from based on the unpacked
data
> then i am searching for the array member that is equal to "70" since
> it is going to be my reference. once i find it, i'll based my
received
> data from that point. then if the succeding tests are confirmed, i
can
> get my data.
> 
> please help(again) :(

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


Re: Tkinter Bitmap Newbie question

2005-03-15 Thread klappnase
Neil Hodgson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Wim Goffin:
> 
> > But just to make sure I'm on the right track,
> > - Is XBM the best way to for bitmaps? The ones I saw so far are all black 
> > and white. Do they also exist in color?
> 
>XPM is the version of XBM with colour.
> 
> > - Is XBM also the best format for glyphs on the Windows platform? Or would 
> > 'Images' of a different format be nicer?
> 
>It depends on what you want to do with icons. Do you want users to be 
> able to change icons? It is less likely Windows users will have tools 
> for manipulating XPM files. The only feature that you are likely to want 
> that is not available from XPM is multi-level transparency which is 
> available from PNG files. 
> 
>My generic advice without additional details of your project is that 
> PNG is the best format for icons displayed by your code. Icons used by 
> the operating system such as for applications should be in a format 
> supported by that OS: Windows prefers ICO files.
> 
> > - Does someone know of a nice downloadable collection of standard glyphs 
> > (Bitmaps for Open file, New file, Save file, ...) with a free license?
> 
> http://sourceforge.net/projects/icon-collection/
> 
>Neil

However, if you want to use Tkinter you should be aware that Tkinter
only supports xbm-Bitmaps and gif-Images out of the box. You can use
the python imaging library to add support for other image formats but
I think that PIL just does an on the fly format conversion into gif
for you, so you might experience a quality loss if you use for example
png icons, so you are probably better off looking for a collection of
gifs.

Best regards

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


Re: python reading excel thru ADO ?

2005-03-15 Thread Simon Brunning
On Mon, 14 Mar 2005 16:20:17 GMT, Chris Curvey <[EMAIL PROTECTED]> wrote:
> I've been reading http://www.mayukhbose.com/python/ado/ad-connection.php
> , which seems to infer that I can read an Excel file using the ADO
> interface with Python on Windows.  Unfortunately, the usual problem with
> ADO -- connection strings -- is raising it's ugly head.
> 
> Has anyone made this work, and would you share the connection string
> that you used?

Never tried it, I'm afraid.

No, strike that. I'm actually pretty glad that I've never tried it. ;-)

But in any case this might help: http://www.connectionstrings.com/

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


Re: python version anachronism

2005-03-15 Thread Simon Brunning
On 15 Mar 2005 02:05:24 -0800, Xah Lee <[EMAIL PROTECTED]> wrote:
> so, python 2.3.5 is released about 2 months later than 2.4??

Yes. 3.2.5 is a bugfix release of the 2.3 branch, 2.4 is a major
release. 2.4.1 is coming soon, BTW.

> also, does the "released ..." indicates the doc or the doc and the
> software?

The docs and the software - both are released together.

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


Re: Web framework

2005-03-15 Thread Stephen Thorne
On Sun, 13 Mar 2005 13:21:27 -0800, Venkat B <[EMAIL PROTECTED]> wrote:
> > I'd say Nevow! For apache setup, you might be interested in my wsgi [1]
> > implementation.
> 
> Hi Sridhar,
> 
> Are you aware of Nevow's "integrability" with the webservers (CGIHTTPServer
> in particular) that come packaged with Python itself ?

Nevow functions as its own web server. You don't need CGIHTTPServer,
you just run twisted.web instead.

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


Re: python reading excel thru ADO ?

2005-03-15 Thread tc
I always used win32com.client to access excel files and parse them,
save them as website, csv and so on.

why exactly is it that u use ado for solving this?

TC

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Tim Daneliuk
In-Reply-To: <[EMAIL PROTECTED]>
X-Enigmail-Version: 0.90.0.0
X-Enigmail-Supports: pgp-inline, pgp-mime
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Nick Craig-Wood wrote:

> Torsten Bronger <[EMAIL PROTECTED]> wrote:
> 
>> The current snapshot is a transitional Python and thus
>> with some double features.  The numerical types and two kinds of
>> classes are examples.  I'm very surprised about this, because Python
>> is a production language, but I'm happy, too.
> 
> 
> As long as python 2.x -> 3.x/3000 isn't like perl 5.x -> perl 6.x I'll
> be perfectly happy too.
> 
> "Less is more" is a much better philosophy for a language and having
> the courage to take things out differentiates python from the crowd.
> 
> Of course we users will complain about removals, but we'll knuckle
> down and take our medicine eventually ;-)
> 

Except that in this case, removal will also complicate code in some
cases.  Consider this fragment of Tkinter logic:

UI.CmdBtn.menu.add_command(label="MyLabel",
command=lambda cmd=cmdkey: 
CommandMenuSelection(cmd))

Would it not be the case that, without lambda, we will need to pollute
the name space with a bunch of specialized little functions for each
and every construct like this?

-- 

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP: Print Without Intervening Space

2005-03-15 Thread Antoon Pardon
Op 2005-03-11, Marcin Ciura schreef <[EMAIL PROTECTED]>:
>  Moreover, all of them require creating one or two temporary
>  objects to hold the entire result.  If the programmers use one of
>  them without qualms, it is only because their mind is warped by
>  the limitation of print.
>
>  Using write() is not especially appealing either, especially if
>  the print statements are used elsewhere in the code:

Personnaly I think just the reversed. I don't use print anywhere
unless for debugging purposes. I always use write 

>  import sys
>  for x in seq:
>  sys.stdout.write(fn(x))
>  print # or sys.stdout.write('\n')
>
>  The proposed extension to the print statement is to use two
>  commas to signal that no space should be written after an
>  expression:
>
>  for x in seq:
>  print fn(x),,
>  print
>
>  To quote "The Zen of Python" [2]: "Beautiful is better than ugly.
>  Simple is better than complex.  Readability counts."

IMO that favors using always write instead of using print with it
various extentions.

For instance if I do the following

   a = 1,

I have assigned a one element tuple to a.

But if I do

   print 1,

It doesn't print a one element tuple.

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Serge Orlov
Torsten Bronger wrote:
> > Interesting.  I've never thought that.  What parts strike you as
> > "patchwork"?
>
> Well, with a little bit of experience in the field of programming
> languages, you can see which elements had been added later (ie years
> after Python's creation).  Properties surely would have looked
> *very* different 15 years ago.
>
> There would be keywords for static and class methods, no distinction
> between Unicode and non-Unicode

You couldn't do that 15 years ago because there were no Unicode that
time.

  Serge.

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


Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Harlin Seritt
I was looking at the Tcl/Tk sourceforge page and found that there were
a couple of new widgets being produced for Tcl 8.5. Does anyone know if
there are any Tkinter wrappers somewhere?

thanks,

Harlin

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


Re: Downloading all files older than 3 hours from a ftp-server.

2005-03-15 Thread TZOTZIOY
On 15 Mar 2005 00:38:20 -0800, rumours say that "Thomas W"
<[EMAIL PROTECTED]> might have written:

>I need to download all files older than 3 hours from a ftp-server.
>What's the easiest way to this? I've looked into the standard ftplib,
>but it seems like the only way to go is to parse the
>ftp.retrlines('LIST') command and that seems to be very easy to mess
>up. 
>
>any hints? 

google brings this up:

http://www.sschwarzer.net/python/ftputil.html

ISTR seeing a parsedate (or similar) for ftp sites by the effbot, but I am not
sure.
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simulated samba server

2005-03-15 Thread TZOTZIOY
On 15 Mar 2005 02:08:55 -0800, rumours say that "tc" <[EMAIL PROTECTED]>
might have written:

>Does anyone know of a module for python which simulates a samba server
>(windows fileshare). Instead of sharing a Phisical Device I'd like to
>share a database based filesystem which is spread over various numbers
>of drives and servers.

I haven't seen one so far; however, is it possible that you could serve your
users through HTTP?  I have done so in a similar situation like yours.
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python version anachronism

2005-03-15 Thread TZOTZIOY
On Tue, 15 Mar 2005 10:23:02 +, rumours say that Simon Brunning
<[EMAIL PROTECTED]> might have written:

>3.2.5 is a bugfix release of the 2.3 branch

Damn, we're on Python 3 already?  Where are all the PEPs I missed?-)
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python becoming less Lisp-like

2005-03-15 Thread Torsten Bronger
HallÃchen!

"Serge Orlov" <[EMAIL PROTECTED]> writes:

> Torsten Bronger wrote:
>
>>> Interesting.  I've never thought that.  What parts strike you as
>>> "patchwork"?
>>
>> Well, with a little bit of experience in the field of programming
>> languages, you can see which elements had been added later (ie
>> years after Python's creation).  Properties surely would have
>> looked *very* different 15 years ago.
>>
>> There would be keywords for static and class methods, no
>> distinction between Unicode and non-Unicode
>
> You couldn't do that 15 years ago because there were no Unicode
> that time.

I've never said that Guido was just too stupid at that time.  I only
said "but you can definitely see that it's the oldest one".  In
other words, a Ruby six years older than the real one would have the
same problem.  And who knows how C# looks like in 10 years.

But I want to program now, and this is the current situation in my
opinion.

TschÃ,
Torsten.

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


Re: simulated samba server

2005-03-15 Thread Ola Natvig
Christos TZOTZIOY Georgiou wrote:
On 15 Mar 2005 02:08:55 -0800, rumours say that "tc" <[EMAIL PROTECTED]>
might have written:

Does anyone know of a module for python which simulates a samba server
(windows fileshare). Instead of sharing a Phisical Device I'd like to
share a database based filesystem which is spread over various numbers
of drives and servers.

I haven't seen one so far; however, is it possible that you could serve your
users through HTTP?  I have done so in a similar situation like yours.
Or FTP..
--
--
 Ola Natvig <[EMAIL PROTECTED]>
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list


Re: simulated samba server

2005-03-15 Thread tc
HTTP isn't a solution. I thought of that also, but I need it to
simulate a drive, because various programs (also such that don't
support webDAV / HTTP) need to access the files on that storage, as if
it where a local or a network drive.

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


Re: simulated samba server

2005-03-15 Thread tc
neither...

I really need a network drive or a shell integration (like virtual cd
drive...)


cheers

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Martin Franklin
Tim Daneliuk wrote:
In-Reply-To: <[EMAIL PROTECTED]>
X-Enigmail-Version: 0.90.0.0
X-Enigmail-Supports: pgp-inline, pgp-mime
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Nick Craig-Wood wrote:

Torsten Bronger <[EMAIL PROTECTED]> wrote:

The current snapshot is a transitional Python and thus
with some double features.  The numerical types and two kinds of
classes are examples.  I'm very surprised about this, because Python
is a production language, but I'm happy, too.

As long as python 2.x -> 3.x/3000 isn't like perl 5.x -> perl 6.x I'll
be perfectly happy too.
"Less is more" is a much better philosophy for a language and having
the courage to take things out differentiates python from the crowd.
Of course we users will complain about removals, but we'll knuckle
down and take our medicine eventually ;-)

Except that in this case, removal will also complicate code in some
cases.  Consider this fragment of Tkinter logic:
UI.CmdBtn.menu.add_command(label="MyLabel",
command=lambda cmd=cmdkey: 
CommandMenuSelection(cmd))
In this case you perhaps should try using a class like so:-
UI.CmdBtn.menu.add_command(label="MyLabel",
   command=CommandMenuSelectionCallback(cmdkey))
Where CommandMenuSelectionCallback is a class like so:
class CommandMenuSelectionCallback:
def __init__(self, key):
self.key = key
def __call__(self):
print self.key
Would it not be the case that, without lambda, we will need to pollute
the name space with a bunch of specialized little functions for each
and every construct like this?
--
http://mail.python.org/mailman/listinfo/python-list


Re: simulated samba server

2005-03-15 Thread Diez B. Roggisch
tc wrote:

> Does anyone know of a module for python which simulates a samba server
> (windows fileshare). Instead of sharing a Phisical Device I'd like to
> share a database based filesystem which is spread over various numbers
> of drives and servers.
> 
> Any hints?

If you can use a linux server, you can create a linux user mode file system
- there is a python binding for that - which in turn you could then share
using samba. 

http://www.freenet.org.nz/python/lufs-python/

-- 
Regards,

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Peter Maas
Carl Banks schrieb:
In Python, classes aren't some magical land where the usual rules don't
hold (as they are in many other languages).  That's why "self." is used
on class variables, for instance.  A class is nothing more than a scope
that uses a smittering of magic to turn it into a type.
scope -> dictionary
--
---
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


Jython Phone Interview Advice

2005-03-15 Thread George Jempty
I'm undergoing a phone interview for a Jython job today.  Anybody have
practical advice for me?  I haven't worked with Python in years, but I
have been working with Java in the meantime (resume at
http://scriptify.com/george_jempty_resume.pdf).  I've been reading up:
my old "Quick Python" (Harris/McDonald) book, a somewhat more current
"Visual Quickstart Guide" (Fehily), as well as "Jython for Java
Programmers" (Bill) via safari.oreilly.com.

My interviewer today will be a somewhat technical manager.  A key thing
I plan to ask is will this be primarily maintenance or new development.
 I don't think I'm cut out for new development considering my
inexperience.

Some things I'm noticing upon (re)reading my books.  Triple quoted
strings: those provide functionality similar to Perl's "here"
documents.

Also, considering Javascript will be a substantial component of my job,
I'm noticing that Javascript's array/"hash" literal syntax is EXACTLY
the same as that for Python lists/dictionaries.  This could lead to
easily sharing data between the client and server side, though I think
I should probably keep this one under my hat, at least with a manager.
Though if things go well I will probably subsequently interview with
more technical folks.

Otherwise, the only thing I can think to tell a manager in a phone
screen is that I'm willing to undergo brainbench.com's Python
certification.

Any advice would be much appreciated.  Thanks in advance

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Paul Boddie
Torsten Bronger <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> 
> At first, I was very pleased by Python's syntax (and still I am).
> Then, after two weeks, I learned about descriptors and metaclasses
> and such and understood nothing (for the first time in syntax I felt
> totally lost).

Well, I've been using Python for almost ten years, and I've managed to
deliberately ignore descriptors and metaclasses quite successfully. I
get the impression that descriptors in particular are a detail of the
low-level implementation that get a disproportionate level of coverage
because of the "hack value" they can provide (albeit with seemingly
inappropriate application to certain problem areas).

Still, having new- and old-style classes, a separate old-style
exception class hierarchy, and various other "transitional" features
doesn't seem very "Pythonic", does it? ;-)

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


Re: simulated samba server

2005-03-15 Thread tc
GREAT, thanks that should just do the trick.  Maybe that way i'll
generate a bit more network traffic (because it first transfers the
data from different servers to the linux server and the sends it from
there...) but it actually will work just fine.

thanks alot

cheers tc

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Martin Franklin
Harlin Seritt wrote:
I was looking at the Tcl/Tk sourceforge page and found that there were
a couple of new widgets being produced for Tcl 8.5. Does anyone know if
there are any Tkinter wrappers somewhere?
thanks,
Harlin
Harlin,
I can't see the web page saying these will be included in Tk 8.5 can you
give me the URL?
As far as wrappers go, if they don't exist (and I don't think they do)
it is fairly easy to create them provided they are written in a very
similar style to 'standard' Tk widgets.  Somone usually steps up and
patches Tkinter.py to include changes in the Tk core, but usually only 
when a new _final_ version is released...

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


Re: win32 shell extension (virtual drive)

2005-03-15 Thread Roger Upole
There's an example shell extension in the Pywin32 demos
that creates a pseudo-folder whose contents are determined by
python code.  Take a look at
\win32comext\shell\demos\servers\shell_view.py.
However, I don't think it qualifies as 'simple' ;)

 Roger

"Tiziano Bettio" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi there
>
> I'm looking for a simple solution of a win32 shell extension (virtual
> drive).
>
> It should make available a new drive with letter, which will be
> read-only. Instead of a network drive or similar it then should query a
> server application for directory/file listing.
>
> Would be nice to have a lib or similar for that.
>
> Any hints??
>
> tizi
> 




== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python becoming less Lisp-like

2005-03-15 Thread Torsten Bronger
HallÃchen!

[EMAIL PROTECTED] (Paul Boddie) writes:

> Torsten Bronger <[EMAIL PROTECTED]> wrote:
>
>> At first, I was very pleased by Python's syntax (and still I am).
>> Then, after two weeks, I learned about descriptors and
>> metaclasses and such and understood nothing (for the first time
>> in syntax I felt totally lost).
>
> Well, I've been using Python for almost ten years, and I've
> managed to deliberately ignore descriptors and metaclasses quite
> successfully. I get the impression that descriptors in particular
> are a detail of the low-level implementation that get a
> disproportionate level of coverage because of the "hack value"
> they can provide (albeit with seemingly inappropriate application
> to certain problem areas).

I have exactly the same impression, but for me it's the reason why I
feel uncomfortable with them.  For example, I fear that a skilled
package writer could create a module with surprising behaviour by
using the magic of these constructs.  I don't know Python well
enough to get more specific, but flexibility almost always make
confusing situations for non-hackers possible.

I know that such magic is inavoidable with dynamic languages, but
descriptors will be used almost exclusively for properties, and
therefore I think it would have been better to hard-wire properties
in the interpreter rather than pollute the language with this sort
of proto-properties (aka descriptors).

TeX is extremely dynamic.  It can modify its own scanner in order to
become an XML parser or AFM (Adobe font metrics) reader.  This is
highly confusing for all but those five or six people on this planet
who speak TeX fluently.  Since I saw raw TeX, I dislike
"proto-syntaxes" (or meta-syntaxes if you wish).

TschÃ,
Torsten.

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


Re: pre-PEP: Print Without Intervening Space

2005-03-15 Thread Thomas Bellman
Antoon Pardon <[EMAIL PROTECTED]> wrote:

> For instance if I do the following
>a = 1,
> I have assigned a one element tuple to a.
> But if I do
>print 1,
> It doesn't print a one element tuple.

And if you do

parrot(1,)

you won't call parrot() with a one-element tuple either.  However,
'parrot(1)' and 'parrot(1,)' means exactly the same thing, while
'print 1' and 'print 1,' does not.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"Adde parvum parvo magnus acervus erit"   ! bellman @ lysator.liu.se
  (From The Mythical Man-Month)   ! Make Love -- Nicht Wahr!

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Harlin Seritt
Martin,

Take a look here:
http://mail.python.org/pipermail/tkinter-discuss/2004-March/10.html
It is a well-known post from what I understand. You may have already
seen it before. Actually, (as I'm looking at a 8.4 demo set from
ActiveTcl distribution), it seems the Tree widget has been added to the
8.4 set. I don't think the Tiles has been added just yet though.

Harlin

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


Re: Jython Phone Interview Advice

2005-03-15 Thread Harlin Seritt
George,

Know what they will be wanting you to do with Jython. This has bitten
me in @ss a couple of times. I guess it was lack of attention to
detail. :-)

Good Luck!

Harlin Seritt

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Ville Vainio
> "Tim" == Tim Daneliuk <[EMAIL PROTECTED]> writes:

Tim> Except that in this case, removal will also complicate code
Tim> in some cases.  Consider this fragment of Tkinter logic:

Tim> UI.CmdBtn.menu.add_command(label="MyLabel",
Tim> command=lambda cmd=cmdkey: CommandMenuSelection(cmd))

Tim> Would it not be the case that, without lambda, we will need
Tim> to pollute the name space with a bunch of specialized little
Tim> functions for each and every construct like this?

You can reuse the same name for all those little functions to avoid
polluting the namespace. Choose 'L' if it gives you that cozy
lambda-ish feel.

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Martin Franklin
Harlin Seritt wrote:
Martin,
Take a look here:
http://mail.python.org/pipermail/tkinter-discuss/2004-March/10.html
It is a well-known post from what I understand. You may have already
seen it before. Actually, (as I'm looking at a 8.4 demo set from
ActiveTcl distribution), it seems the Tree widget has been added to the
8.4 set. I don't think the Tiles has been added just yet though.
Harlin

Thanks, I must have missed it first time round...
after more googling I did find a reference to Tile going
into Tk 8.5 but it was not on the tcltk wiki recent changes
for 8.5:
http://wiki.tcl.tk/10630
Which made me think it will not go in.
Cheers,
Martin.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python becoming less Lisp-like

2005-03-15 Thread Ville Vainio
> "Torsten" == Torsten Bronger <[EMAIL PROTECTED]> writes:

>>> There would be keywords for static and class methods, no
>>> distinction between Unicode and non-Unicode

>> You couldn't do that 15 years ago because there were no Unicode
>> that time.

Torsten> I've never said that Guido was just too stupid at that
Torsten> time.  I only said "but you can definitely see that it's
Torsten> the oldest one".  In other words, a Ruby six years older
Torsten> than the real one would have the same problem.  And who
Torsten> knows how C# looks like in 10 years.

http://c2.com/cgi/wiki?PythonVsRuby

seems to suggest that Python has better Unicode support than Ruby.

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


Re: Lisp-likeness

2005-03-15 Thread ole . rohne
Kay> Maybe You can answer my question what this simple LISP function does ?
Kay> (defun addn (n)
Kay>  #'(lambda (x)
Kay>  (+ x n)))

Is that a real question or are you making a rhetorical point here?

Kay> This is correct LISP-syntax if You bear in mind LISPs powerwull macro
Kay> language...

It's indeed correct CL syntax, but I don't see much macro usage in there.

Try (mapcar (addn 4) (list 1 2 3))...

Ole

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Torsten Bronger
HallÃchen!

Ville Vainio <[EMAIL PROTECTED]> writes:

>> "Torsten" == Torsten Bronger <[EMAIL PROTECTED]> writes:
>
> >>> There would be keywords for static and class methods, no
> >>> distinction between Unicode and non-Unicode
>
> >> You couldn't do that 15 years ago because there were no Unicode
> >> that time.
>
> Torsten> I've never said that Guido was just too stupid at that
> Torsten> time.  I only said "but you can definitely see that it's
> Torsten> the oldest one".  In other words, a Ruby six years older
> Torsten> than the real one would have the same problem.  And who
> Torsten> knows how C# looks like in 10 years.
>
> http://c2.com/cgi/wiki?PythonVsRuby
>
> seems to suggest that Python has better Unicode support than Ruby.

True.  When you google for it, you read "Japanese hate Unicode".
:-/  Well, then this is an invalid example.

TschÃ,
Torsten.

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


Re: unicode study with unicodedata module

2005-03-15 Thread Xah Lee
how do i get a unicode's number?

e.g. 03ba for greek lowercase kappa? (or in decimal form)

 Xah


Xah Lee wrote:
> python has this nice unicodedata module that deals with unicode
nicely.
>
> #-*- coding: utf-8 -*-
> # python
>
> from unicodedata import *
>
> # each unicode char has a unique name.
> # one can use the âlookupâ func to find it
>
> mychar=lookup('greek cApital letter sIgma')
> # note letter case doesn't matter
> print mychar.encode('utf-8')
>
> m=lookup('CJK UNIFIED IDEOGRAPH-5929')
> # for some reason, case must be right here.
> print m.encode('utf-8')
>
> # to find a char's name, use the ânameâ function
> print name(u'å')
>
> basically, in unicode, each char has a number of attributes (called
> properties) besides its name. These attributes provides necessary
info
> to form letters, words, or processing such as sorting,
capitalization,
> etc, of varous human scripts. For example, Latin alphabets has two
> forms of upper case and lower case. Korean alphabets are stacked
> together. While many symbols corresponds to numbers, and there are
also
>
> combining forms used for example to put a bar over any letter or
> character. Also some writings systems are directional. In order to
form
>
> these symbols for display or process them for computing, info of
these
> on each char is necessary.
>
> the rest of functions in unicodedata return these attributes.
>
> see unicodedata doc:
> http://python.org/doc/2.4/lib/module-unicodedata.html
>
> Official word on unicode character properties:
> http://www.unicode.org/uni2book/ch04.pdf
>
> --
> i don't know what's the state of Perl's unicode. Is there something
> similar?
>
> --
> this post is archived at
> http://xahlee.org/perl-python/unicodedata_module.html
> 
>  Xah
>  [EMAIL PROTECTED]
>  http://xahlee.org/PageTwo_dir/more.html

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


Re: Getting the process list on win98

2005-03-15 Thread Roger Upole
   WMI didn't come installed on Win98.  You can download the
addon for win98 from Microsoft.
   If I recall correctly from when I last used it on 98, GetObject
didn't work for wmi.  You might have to use
win32com.client.Dispatch('Wbemscripting.Swbemlocator')
to create the object.

hth
 Roger

"Ron" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've written a screen saver which opens multiple copies on windows 98. I'm 
> trying to check the process list to determine if it is already running.
>
> So far all the example win32 routines I've found, through google, only 
> work on newer xp and nt versions of windows. This is the current attempt 
> to get the process list on windows 98:
>
> def GetProcessNameList():
> from win32com.client import GetObject
> WMI = GetObject('winmgmts:')
> processes = WMI.InstancesOf('Win32_Process')
> names = []
> for process in processes:
> names += [process.Properties_('Name').Value]
> return names
>
> def IsRunning( filename ):
> n = 0
> for process in GetProcessNameList():
> if process.lower() == filename.lower():
> n += 1
> return n
>
>
> Then in the startup section:
>
> filename = os.path.basename(sys.argv[0])
> # Wait for preview window to exit.
> t = clock()
> while IsRunning( filename) > 1 and clock() < t + 3:
> sleep(.01)
> # Start screen saver if only self is running.
> if IsRunning( filename)==1:
> saver = Screensaver()
> saver.launchScreenSaver()
>
>
> Results in this error on windows 98, works fine on windows xp:
>
> Traceback (most recent call last):
>   File "Aztec.pyw", line 255, in ?
>   File "Aztec.pyw", line 38, in IsRunning
>   File "Aztec.pyw", line 29, in GetProcessNameList
>   File "win32com\client\__init__.pyc", line 73, in GetObject
>   File "win32com\client\__init__.pyc", line 88, in Moniker
> pywintypes.com_error: (-2147221014, 'Moniker cannot open file', None, 
> None)
>
> The program is in python v2.3 and packaged using pyexe, and inno setup.
> 




== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Truncated file without unbuffered mode

2005-03-15 Thread Fuzzyman
I use a simple python script to monitor downloads from my website.
http://www.voidspace.org.uk/python/cgi.shtml#downman

It serves the file in a loop using our old friend :

``sys.stdout.write(chunk)``

(After sending the relevant headers with filename and filesize of
course).

I am testing this locally under windows using Xitami as localhost. If I
run in unbuffered mode (shebang line ``#!/usr/bin/python -u``) it works
fine. Without unbuffered mode (shebang line ``#!/usr/bin/python``) it
truncates the file.

This happens even if I add ``sys.stdout.flush()`` into the loop.

Does anyone know why this might happen ?

Regards,


Fuzzy
http://www.voidspace.org.uk/python/index.shtml

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Harlin Seritt
Martin,

If I may ask, who actually works on the Tkinter module? Is there a
certain group that does this? I'm just curious as I've never been able
to find this information. I know there are, of course, someone who
develops Tk but just not sure who does this on the Python side.

Thanks,

Harlin

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


Re: unicode study with unicodedata module

2005-03-15 Thread TZOTZIOY
On 15 Mar 2005 04:55:17 -0800, rumours say that "Xah Lee" <[EMAIL PROTECTED]> 
might
have written:

>how do i get a unicode's number?
>
>e.g. 03ba for greek lowercase kappa? (or in decimal form)

you get the character with:

.>> uc = u"\N{GREEK SMALL LETTER KAPPA}"

or with

.>> uc = unicodedata.lookup("GREEK SMALL LETTER KAPPA")

and you get the ordinal with:

.>> ord(uc)

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


possible solution for bsddb > get data results on the internet.

2005-03-15 Thread martijn
H!

I have a big bsddb database created with python and that works fast.
I know that I can use the python_apache module to show the data results
online.

//--- python_apache module




//---

but my question is:
Is there a faster/easy way to get the records online using a bsddb
database ?
with php script maybe ?

Or must I use python and apache to get the fastest resonse...

Thanks for helping/info
GC-Martijn

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


Re: {SPAM} start a python application as a win NT service

2005-03-15 Thread Frank Millman

Gijs Korremans wrote:
> Hi,
>
> I'm using windows 2003 small business server and I want to install my
python programm as a NT (it's just an old name) service. Does anybody
know how to do this?
>
>
> Kind regards,
>
>
> Gijs Korremans
> R&D Department
>
> Global Supply Chain Services (pty) Ltd.
> P.O. Box 1263
> Rivonia 2128
> South Africa
> Tel: +27 (0)11 802 1329
> Fax: +27 (0)11 802 6528
> E-mail: [EMAIL PROTECTED]
>

Hi Gijs

I asked this question a few months ago, and got some useful replies.
Here is the link.

http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/3b6ca01be1c70c76/1d172ee2d5c627b8?q=srvany#1d172ee2d5c627b8

I hope this comes out in a usable form - it seems rather long. If it
does not work, search in google groups for 'srvany' and look for the
message dated July 2004.

HTH

Frank Millman

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Martin Franklin
Harlin Seritt wrote:
Martin,
If I may ask, who actually works on the Tkinter module? Is there a
certain group that does this? I'm just curious as I've never been able
to find this information. I know there are, of course, someone who
develops Tk but just not sure who does this on the Python side.
Thanks,
Harlin
Harlin,
There is no Tkinter group of core developers, if somthing needs doing
then it is done by those who need it (AFAIK) I have made a few small
patches to Tkinter.py in the past and will do so again should I need to
I have been looking some more at Tile - it's come a long way in the
last few  months (since the last time I looked at it), I have even
started writting a *test* wrapper for it (I first had to build tcl, tk,
tile and python from source!)
I have created a Style class (as a mixin like the Pack and Grid classes
in Tkinter.py
I have also wrapped the Tile.Button but right now it extends
Tkinter.Widget class (as it is starting to look like a large chunk of
work wrapping Tile from scratch;-)
That said I have got a Tile Button example working (and I can change
it's style) so perhaps not that much work
I've cc'd the tkinter mailing list to see if there is any more interest 
over there...

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Serge Orlov
Fernando wrote:
> On Sun, 13 Mar 2005 18:23:05 GMT, Peter Seibel
<[EMAIL PROTECTED]>
> wrote:
>
> >Looks like the BDFL is planning to take lambda, reduce, filter, and
> >map out of Python in the next big rev of Python (so called Python
> >3000):
> >
> >  
>
> Basically, it says that it will get rid of the explicit map, filter
> and reduce and substitute them by some syntactic sugar that uses them
> implicitly. That's ok, and not a big deal.
>
> It will also get rid of lambda, and it's not a great loss, since
> python's version is so limited that it's almost useless. Besides,
> given the syntactic sugar used to replace map, reduce and filter,
> there's no real need for lambda in the most usual cases.
>
> The real problem with Python is that it has been very successful as a
> scripting language in the static-typing/C/C++ world. Those
> programmers, instead of adapting their evil ways to Python, and
> realizing the advantages of a dynamic language, are influencing
> Python's design and forcing it into the static-typing mold. Python is
> going the C++ way: piling feature upon feature, adding bells and
> whistles while ignoring or damaging its core design.

You're wrong about design: http://www.artima.com/intv/pyscale.html
Quoting Guido: The first sound bite I had for Python was, "Bridge
the gap between the shell and C." So I never intended Python to be
the primary language for programmers.


>
> The new 'perlified' syntax for decorators, the new static type bonds
> and the weird decision to kill lambda instead of fixing it are good
> examples that show that Python is going the wrong way. What used to
> be a cool language will soon be an interpreted C/C++ without any
> redeeming value. A real pity...

Yeah, that was a good time. After a nice bridge between the shell
and C was built they never ceased piling feature upon feature and
kept adding bells and wristles.

  Serge.

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Harlin Seritt
(snip)
>>That said I have got a Tile Button example working (and I can change
>>it's style) so perhaps not that much work

Do you happen to have a sampling of this that I can get my hands on??

>>I've cc'd the tkinter mailing list to see if there is any more
interest 
>>over there... 

Thanks for doing so!

Harlin

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


pygtk: edited signal and selected column

2005-03-15 Thread _v_tiziano
Hi,

I'm trying to get the selected column from the callback for the signal
"edited" of a gtk.CellRendererCombo.
This callback return only the gtk.CellRendererCombo object, the
selected path and the new text is being to be inserted.

:(

Any idea?

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


Re: Lisp-likeness

2005-03-15 Thread Albert Reiner
[EMAIL PROTECTED], Tue, 15 Mar 2005 13:10:52 +0100]:
> It's indeed correct CL syntax, but I don't see much macro usage in there.

defun?

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


Re: Tkinter wrappers for TkTreeCtrl and Tile

2005-03-15 Thread Martin Franklin
Harlin Seritt wrote:
(snip)
That said I have got a Tile Button example working (and I can change
it's style) so perhaps not that much work

Do you happen to have a sampling of this that I can get my hands on??

I've cc'd the tkinter mailing list to see if there is any more
interest 

over there... 

Thanks for doing so!
Harlin

Harlin,
Sure here is all 90 lines of it:-
##
import Tkinter
from Tkconstants import *
class Style:
def default(self, style, **kw):
"""Sets the default value of the specified option(s) in style"""
pass
def map_style(self, **kw):
"""Sets dynamic values of the specified option(s) in style. See
"STATE MAPS", below."""
pass
def layout(self, style, layoutSpec):
"""Define the widget layout for style style. See "LAYOUTS" below
for the format of layoutSpec. If layoutSpec is omitted, return the
layout specification for style style. """
pass
def element_create(self, name, type, *args):
"""Creates a new element in the current theme of type type. The
only built-in element type is image (see image(n)), although
themes may define other element types (see
Ttk_RegisterElementFactory).
"""
pass
def element_names(self):
"""Returns a list of all elements defined in the current theme. 
 """
pass

def theme_create(self, name, parent=None, basedon=None):
"""Creates a new theme. It is an error if themeName already 
exists.
If -parent is specified, the new theme will inherit styles, 
elements,
and layouts from the parent theme basedon. If -settings is 
present,
script is evaluated in the context of the new theme as per 
style theme
settings.
"""
pass

def theme_settings(self, name, script):
"""Temporarily sets the current theme to themeName, evaluate 
script,
then restore the previous theme. Typically script simply 
defines styles
and elements, though arbitrary Tcl code may appear.
"""
pass

def theme_names(self):
"""Returns a list of the available themes. """
return self.tk.call("style", "theme", "names")
def theme_use(self, theme):
"""Sets the current theme to themeName, and refreshes all 
widgets."""
return self.tk.call("style", "theme", "use", theme)


class Button(Tkinter.Widget, Style):
def __init__(self, master=None, cnf={}, **kw):
master.tk.call("package", "require", "tile")
Tkinter.Widget.__init__(self, master, 'ttk::button', cnf, kw)
class Treeview(Tkinter.Widget):
def __init__(self, master=None, cnf={}, **kw):
master.tk.call("package", "require", "tile")
Tkinter.Widget.__init__(self, master, 'ttk::treeview', cnf, kw)

def callback():
print "Hello"
root = Tkinter.Tk()
b = Button(root, text="Tile Button", command=callback)
b.pack()
print b.theme_names()
b.theme_use("step")
b1 = Tkinter.Button(root, text="Tk Button", command=callback)
b1.pack()
tree = Treeview(root)
tree.pack()
root.mainloop()
##
--
http://mail.python.org/mailman/listinfo/python-list


Re: Getting the process list on win98

2005-03-15 Thread Ron
Thanks for the reply Roger,
Since will put this on my web site for general use, I don't want users 
to have to install additional software.

I'll try win32com.client.Dispatch('Wbemscripting.Swbemlocator') see what 
that does.

As a last resort, I use a registry key as a run status varable.  Not my 
first choice, but I think it will work for all win9x systems.

Roger Upole wrote:
   WMI didn't come installed on Win98.  You can download the
addon for win98 from Microsoft.
   If I recall correctly from when I last used it on 98, GetObject
didn't work for wmi.  You might have to use
win32com.client.Dispatch('Wbemscripting.Swbemlocator')
to create the object.
hth
 Roger
--
http://mail.python.org/mailman/listinfo/python-list


Re: Jython Phone Interview Advice

2005-03-15 Thread Paul Watson
"George Jempty" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'm undergoing a phone interview for a Jython job today.  Anybody have
> practical advice for me?  I haven't worked with Python in years, but I
> have been working with Java in the meantime (resume at
> http://scriptify.com/george_jempty_resume.pdf).  I've been reading up:
> my old "Quick Python" (Harris/McDonald) book, a somewhat more current
> "Visual Quickstart Guide" (Fehily), as well as "Jython for Java
> Programmers" (Bill) via safari.oreilly.com.
>
> My interviewer today will be a somewhat technical manager.  A key thing
> I plan to ask is will this be primarily maintenance or new development.
> I don't think I'm cut out for new development considering my
> inexperience.
>
> Some things I'm noticing upon (re)reading my books.  Triple quoted
> strings: those provide functionality similar to Perl's "here"
> documents.
>
> Also, considering Javascript will be a substantial component of my job,
> I'm noticing that Javascript's array/"hash" literal syntax is EXACTLY
> the same as that for Python lists/dictionaries.  This could lead to
> easily sharing data between the client and server side, though I think
> I should probably keep this one under my hat, at least with a manager.
> Though if things go well I will probably subsequently interview with
> more technical folks.
>
> Otherwise, the only thing I can think to tell a manager in a phone
> screen is that I'm willing to undergo brainbench.com's Python
> certification.
>
> Any advice would be much appreciated.  Thanks in advance

Gee, George.  I wonder if the interviewing manager or anyone in their 
company has access to newsgroups? 


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


Re: How do I pass structures using a C extension?

2005-03-15 Thread [EMAIL PROTECTED]
I have access to the source, so it seems that I can create shareable
libs for the libraries I want to use using distutils. I do a
glob.glob() on the *.c files in the libscr directory.  If I copy the
main library.h file over to where my module.i file is, I can do a
%include on it and things seem to get built fine. (I still need to
actually call something to see if it works.)

Is there a way to change my setup.py file to look in the locations
specified by the 'include_dirs' argument? This argument works for my C
compiling, but it doesn't get passed to swig.


#!/bin/env python
import sys, os, glob
from distutils.core import setup, Extension

py_version='python%d.%d' % (sys.version_info[0],sys.version_info[1])
OTB_HOME='/vps/otbknox/williams/OTB_2.0'
OTB_INCLDIR=[
os.path.join(OTB_HOME, 'include', 'global'),
os.path.join(OTB_HOME, 'include', 'libinc'),
os.path.join(sys.prefix,'include',py_version),
OTB_HOME
]
libsrcs=glob.glob(os.path.join(OTB_HOME,'libsrc','libcmdline','*.c'))

setup (name = 'OTB_libs',
   version='1.0',
   author="Tim Williams",
##   packages=['cmdline'],
##   ext_package='OTB_libs',
   ext_modules=[Extension('_cmdline',
  sources=['cmdline.i']+ libsrcs,
  include_dirs=OTB_INCLDIR
  )
]
   )


running build
running build_ext
building '_cmdline' extension
swigging cmdline.i to cmdline_wrap.c
swig -python -o cmdline_wrap.c cmdline.i
cmdline.i:9: Unable to find 'libcmdline.h'
error: command 'swig' failed with exit status 1

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


Re: Python becoming less Lisp-like

2005-03-15 Thread Steven Bethard
Torsten Bronger wrote:
[EMAIL PROTECTED] (Paul Boddie) writes:
Well, I've been using Python for almost ten years, and I've
managed to deliberately ignore descriptors and metaclasses quite
successfully. I get the impression that descriptors in particular
are a detail of the low-level implementation that get a
disproportionate level of coverage because of the "hack value"
they can provide (albeit with seemingly inappropriate application
to certain problem areas).
I have exactly the same impression, but for me it's the reason why I
feel uncomfortable with them.  For example, I fear that a skilled
package writer could create a module with surprising behaviour by
using the magic of these constructs.  I don't know Python well
enough to get more specific, but flexibility almost always make
confusing situations for non-hackers possible.
I know that such magic is inavoidable with dynamic languages, but
descriptors will be used almost exclusively for properties, and
therefore I think it would have been better to hard-wire properties
in the interpreter rather than pollute the language with this sort
of proto-properties (aka descriptors).
Certainly descriptors in the "wrong hands" could lead to confusing, 
unreadable code.  But Python is a "we're all adults here" language, and 
so we have to trust other coders to be responsible.  There are some very 
reasonable uses for descriptors which I don't believe are really 
confusing, for example the lazy property recipe:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/363602
While writing too many descriptors is a code smell, the functionality is 
there as an implementation detail of new-style classes, and I'm quite 
happy that Python trusts me enough to expose this detail for when I need it.

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


Python CGI discussion Group

2005-03-15 Thread Fuzzyman
There is a `web design` group over on google-groups.
http://groups-beta.google.com/group/wd

It's brief is for ``Discussion of web design (html, php, flash,
wysiwig, cgi, perl, python, css, design concepts, etc.).``, but it's
very quiet. I'd love to see it become a discussion forum for Python
CGIs and associated issues (web design, the http protocol etc).

Regards,

Fuzzy
http://www.voidspace.org.uk/python/cgi.shtml

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


Re: Jython Phone Interview Advice

2005-03-15 Thread George Jempty
Paul Watson wrote:
>
> Gee, George.  I wonder if the interviewing manager or anyone in their

> company has access to newsgroups?

Then I hope they would see that I was trying to properly prepare for
the interview.  I've given it to them straight so far: I'm no
Python/Jython guru.  And I'll give it to them straight if they say this
is primarily new development: that I don't think I'm their man.

If they somehow construe my reliance on this newsgroup negatively, I
would never want to work for them.

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


Question about string.printable and non-printable characters

2005-03-15 Thread Daniel Alexandre
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi there,
I'm using the following method in my program to check whether a message 
received is printable or not and to strip the non-printable characters:

CheckPrintable(self,message):
	printablemessage = ""
	for char in message:
		if char in string.printable: printablemessage = printablemessage + 
char
	return printablemessage

The method is working fine, except in one detail, it's also stripping 
the accented letters which I didn't want to happen. Is there a 
string.printable declaration which contains accented letters? Thanks in 
advance. If you can, please reply to my email.
- -- 
Best Regards,
Daniel Alexandre ( [EMAIL PROTECTED] )
PGP Public Key: http://student.dei.uc.pt/~dfcruz/pubring.html
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFCNv94L3+DjgQV3LgRAk0yAKDN5lzrXqsVY5zgvZD2X3oGtWS5IwCcCtsA
qv5d+KGP3n9Gbx0iUm46f/k=
=sw9h
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python becoming less Lisp-like

2005-03-15 Thread James Graves
Fernando   <[EMAIL PROTECTED]> wrote:

> Peter Seibel <[EMAIL PROTECTED]> wrote:
>
> > Looks like the BDFL is planning to take lambda, reduce, filter, and
> > map out of Python in the next big rev of Python (so called Python
> > 3000):
> >
> >  
>
>Basically, it says that it will get rid of the explicit map, filter
>and reduce and substitute them by some syntactic sugar that uses them
>implicitly. That's ok, and not a big deal.
>
>It will also get rid of lambda, and it's not a great loss, since
>python's version is so limited that it's almost useless. Besides,
>given the syntactic sugar used to replace map, reduce and filter,
>there's no real need for lambda in the most usual cases.

It is my opinion that this is a natural consequence of infix notation,
deep operator precedence heirarchy, and consequently no macro system.

With Lisp, you have the good, solid, general constructs.  And if you
need syntactic sugar (like WHEN, for example), you can just build
it up using macros.

So with Python 3000, you're going to end up with a language just as big
as CL, but without the most fundamental building blocks.  Ah well, to
each his own.

My Road to Lisp was long and twisty.  For a while it covered some Python
territory.  But I started look into where exactly the interesting bits
of Python came from.  And here I am.  Though I've still got a lot to
learn.

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


Re: Turning String into Numerical Equation

2005-03-15 Thread Steven Bethard
Michael Spencer wrote:
Giovanni Bajo wrote:
I use something along these lines:
def safe_eval(expr, symbols={}):
return eval(expr, dict(__builtins__=None, True=True, False=False), 
symbols)

import math
def calc(expr):
return safe_eval(expr, vars(math))
That offers only notional security:
 >>> calc("acos.__class__.__bases__[0]")
 
Yeah, I was concerned about the same thing, but I realized that I can't 
actually access any of the func_globals attributes:

py> eval('(1).__class__.mro()[-1].__subclasses__()[17]'
...  '.substitute.func_globals', dict(__builtins__=None))
Traceback (most recent call last):
  File "", line 2, in ?
  File "", line 0, in ?
RuntimeError: restricted attribute
AFAIK, you need to get to func_globals to do anything really 
interesting.  (You can get file through object, but you can't get 
__import__ AFAIK.  So you can read and write files which means you can 
create a DOS attack, but I don't know how to do the eqivalent of, say, 
'rm -rf /'.)

Also interesting is that an old exec trick[1] no longer works:
py> exec """\
... global __builtins__
... del __builtins__
... print __builtins__""" in dict(__builtins__=None)
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 3, in ?
NameError: global name '__builtins__' is not defined
(It used to make __builtins__ available.)
STeVe
[1]http://mail.python.org/pipermail/python-list/2004-August/234838.html
--
http://mail.python.org/mailman/listinfo/python-list


(no subject)

2005-03-15 Thread praveen tayal
Hi Guys,

I am having problems in the following C API program where myOtim_system is 
callable from python function. The module is listed below - 

static PyObject *
myOptim_system(PyObject *self, PyObject *args)
{
const char *command;
double u0, v0, u1, v1, u2, v2, u3, v3;
int sts;

/* variables */
PyObject *pstr, *pmod, *pdict, *pfunc, *pargs;
char * cstr;
char *dummy = "Test";
char *x = "x = ";


if (!PyArg_ParseTuple(args, "s", &command))
return NULL;

/* convert them to the doubles */
sscanf(command, "%lf %lf %lf %lf %lf %lf %lf %lf", &u0, &v0,
&u1, &v1, &u2, &v2, &u3, &v3);

sts = (int) (u0+v0+u1+v1+u2+v2+u3+v3);

/* trying to call the python program from C */
/*
The module name is test2_module and the function name is cv_calc_func
- get test2_module.cv_calc_func
*/
pmod = PyImport_ImportModule("test2_module");
pdict = PyModule_GetDict(pmod);

/* convert to the PyObject */
pfunc = PyObject_GetAttrString(pmod, "cv_calc_func");
pargs =  Py_BuildValue("s", dummy);
pstr = PyEval_CallObject(pfunc, pargs);

PyArg_Parse(pstr, "s", &cstr);
printf("%s\n", cstr);

Py_DECREF(pmod);
Py_DECREF(pstr);
Py_DECREF(pfunc);
Py_DECREF(pargs);


return Py_BuildValue("i", sts);

}

In the same module I am trying to call the python program from C API. That 
python program is called test2_module.py. It is listed below - 

import string

message = 'Hi I am here'

def cv_calc_func(dummy):
s = "warning" + `dummy`
return s


-
It contains a method called cv_calc_func(). So now the idea must me clear. I 
would need to communicate bi-directionally, i.e. from python to C and C to 
python. This example is inspired by the fact that we use the C func from 
Numerical recepies in C corresponding to lets say some optimization algorithm. 
So that we don't re-invent the wheel in python. So we call a C API from python. 
But in the optimization the objective function value must be returned from a 
python program, so from C API I should be able to call a python program and 
then integrate it with my optimization algorithm.

In this example I have tried to use "PyEval_CallObject()" within the 
"myOptim_system" C API function but it reports memory error. But when I call it 
from main() it doesn't report any errors.
Just wondering what do I do here?

-regards
Prav 
-- 
___
NEW! Lycos Dating Search. The only place to search multiple dating sites at 
once.
http://datingsearch.lycos.com

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


Re: Jython Phone Interview Advice

2005-03-15 Thread D H
George Jempty wrote:
Also, considering Javascript will be a substantial component of my job,
I'm noticing that Javascript's array/"hash" literal syntax is EXACTLY
the same as that for Python lists/dictionaries.  This could lead to
easily sharing data between the client and server side, though I think
Look up JSON, XML-RPC, XMLHttpRequest and Java (you can use Jython in 
place of Java of course):
http://oss.metaparadigm.com/jsonrpc/
http://developers.slashdot.org/article.pl?sid=05/01/24/125236
http://www.webpasties.com/xmlHttpRequest/

Otherwise, the only thing I can think to tell a manager in a phone
screen is that I'm willing to undergo brainbench.com's Python
certification.
Way out of date.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Turning String into Numerical Equation

2005-03-15 Thread Steven Bethard
Steven Bethard wrote:
Yeah, I was concerned about the same thing, but I realized that I can't 
actually access any of the func_globals attributes:

py> eval('(1).__class__.mro()[-1].__subclasses__()[17]'
...  '.substitute.func_globals', dict(__builtins__=None))
Traceback (most recent call last):
  File "", line 2, in ?
  File "", line 0, in ?
RuntimeError: restricted attribute
AFAIK, you need to get to func_globals to do anything really 
interesting.  (You can get file through object, but you can't get 
__import__ AFAIK.  So you can read and write files which means you can 
create a DOS attack, but I don't know how to do the eqivalent of, say, 
'rm -rf /'.)
Hmm...  I also can't access the file constructor:
py> eval("(1).__class__.mro()[-1].__subclasses__()[16]"
...  "('temp.txt', 'w').write('')", dict(__builtins__=None))
Traceback (most recent call last):
  File "", line 2, in ?
  File "", line 0, in ?
IOError: file() constructor not accessible in restricted mode
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lisp-likeness

2005-03-15 Thread Peter Lewerin
"Kay Schluehr" <[EMAIL PROTECTED]> wrote

> Maybe You can answer my question what this simple LISP function does ?

It obviously returns a function adding n to the function's parameter,
n being bound into the functions's closure during the call to ADDN. 
It's simple and straightforward.

> This is correct LISP-syntax if You bear in mind LISPs powerwull macro
> language...

Actually, this suffices:

(defun addn (n)
  (lambda (x)
(+ x n)))

And Lisp's "macro language" isn't involved at all here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about string.printable and non-printable characters

2005-03-15 Thread Michael Hoffman
Daniel Alexandre wrote:
CheckPrintable(self,message):
printablemessage = ""
for char in message:
if char in string.printable: printablemessage = printablemessage 
+ char
return printablemessage
That would probably be best written (using Python 2.4) as:
def check_printable(self, message, printable=string.printable):
return "".join(char for char in message if char in printable)
It would be much more efficient for one thing. And you can change printable to
be whatever you want. Unfortunately, no one knows what letters you want to
define as printable other than you, or what is printable on your codeset.
string.printable is a least-common denominator ASCII set. You can certainly
make it string.printable + "aeioun" (replacing the ASCII letters with their
accented versions in your codeset of course).
Of course I might be proven totally wrong when the i18n heavies weigh in ;)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lisp-likeness

2005-03-15 Thread Michael Hoffman
Peter Lewerin wrote:
"Kay Schluehr" <[EMAIL PROTECTED]> wrote
>
Maybe You can answer my question what this simple LISP function does ?
It obviously returns a function adding n to the function's parameter,
n being bound into the functions's closure during the call to ADDN. 
It's simple and straightforward.
This is off-topic for comp.lang.python. Follow-ups set.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python becoming less Lisp-like

2005-03-15 Thread Brandon J. Van Every
James Graves wrote:
>
> So with Python 3000, you're going to end up with a language just as
> big as CL, but without the most fundamental building blocks.  Ah
> well, to each his own.

Preventing people from building things from scratch is probably an
industrial advantage.  Look how fragmented the Lisp world is.

-- 
Cheers,   www.indiegamedesign.com
Brandon Van Every Seattle, WA

"witch-hunt" - (noun) (Date: 1885)
1: a searching out for persecution of persons accused
   of witchcraft
2: the searching out and deliberate harassment of
   those (as political opponents) with unpopular views
- witch-hunter (noun)
- witch-hunting (noun or adjective)

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


Why tuple with one item is no tuple

2005-03-15 Thread Gregor Horvath
Hi,
>>>type(['1'])

>>>type(('1'))

I wonder why ('1') is no tuple
Because I have to treat this "special" case differently in my code.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuple with one item is no tuple

2005-03-15 Thread Fuzzyman
('1',) is a tuple... you need the comma to make it a tuple.

regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

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


Re: Jython Phone Interview Advice

2005-03-15 Thread George Jempty
D H wrote:
> George Jempty wrote:
> > Also, considering Javascript will be a substantial component of my
job,
> > I'm noticing that Javascript's array/"hash" literal syntax is
EXACTLY
> > the same as that for Python lists/dictionaries.  This could lead to
> > easily sharing data between the client and server side, though I
think
>
> Look up JSON, XML-RPC, XMLHttpRequest and Java (you can use Jython in

> place of Java of course):
> http://oss.metaparadigm.com/jsonrpc/
> http://developers.slashdot.org/article.pl?sid=05/01/24/125236
> http://www.webpasties.com/xmlHttpRequest/

I like that last URL in particular.  I actually already knew of JSON.
I figure I can eventually leverage this similarity, though again I
think that is a more appropriate discussion to have with technical
leads rather than management.

Thanks for the awesome link(s) though

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


RE: Why tuple with one item is no tuple

2005-03-15 Thread Batista, Facundo
Title: RE: Why tuple with one item is no tuple





[Gregor Horvath]


#-  >>>type(('1'))
#- 
#- 
#- I wonder why ('1') is no tuple


The parentheses don't create the tuple, the comma does:


>>> ('1')
'1'
>>> ('1',)
('1',)
>>> '1',
('1',)



.    Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



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

Re: Why tuple with one item is no tuple

2005-03-15 Thread Bill Mill
On Tue, 15 Mar 2005 16:16:34 GMT, Gregor Horvath <[EMAIL PROTECTED]> wrote:
> Hi,
> 
>  >>>type(['1'])
> 
> 
>  >>>type(('1'))
> 
> 
> I wonder why ('1') is no tuple

because, syntactically, those parens are for grouping, and do not
unambiguously define a tuple. It's a python gotcha. To define a
one-tuple, put a comma after the '1':

>>>type(('1',))


> 
> Because I have to treat this "special" case differently in my code.

you shouldn't have to; post your code if you still think you do.

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


Re: Why tuple with one item is no tuple

2005-03-15 Thread deelan
Gregor Horvath wrote:
Hi,
 >>>type(['1'])

 >>>type(('1'))

I wonder why ('1') is no tuple
Because I have to treat this "special" case differently in my code.
you need to tell python that ('1') isn't a string inside
a couple parens but a tuple, look:
>>> t = ('1', )
>>> type(t)

if there's no ambiguity you can omit the parens:
>>> t = '1',
>>> type(t)

HTH,
deelan
--
@prefix foaf:  .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog  .
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuple with one item is no tuple

2005-03-15 Thread Roy Smith
Gregor Horvath  <[EMAIL PROTECTED]> wrote:
>Hi,
>
> >>>type(['1'])
>
>
> >>>type(('1'))
>
>
>I wonder why ('1') is no tuple

You need to say ('1',).  In just plain ('1'), the parens are
interpreted as grouping, not as tuple creation.  Depending on your
point of view, this is either a "special case", or an "ugly wart" in
the syntax.

a = ()   # tuple of zero elements
a = (1,) # tuple of one element
a = 1,   # tuple of one element
a = (1)  # scalar
a = (1, 2)   # tuple of two elements
a = 1, 2 # tuple of two elements
a = ,# syntax error

The big question is, is it the parens that make it a tuple, or is it
the comma?  If you go along with the parens school of thought, then
(1,) is the special case.  If you believe in commas, then the () is
the special case.  In either case, it's a bit ugly, but we learn to
overlook the occasional cosmetic blemishes of those we love :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


unicode converting

2005-03-15 Thread Maxim Kasimov
there are a few questions i can find answer in manual:
1. how to define which is internal encoding of python unicode strings (UTF-8, 
UTF-16 ...)
2. how to convert string to UCS-2
(Python 2.2.3 on freebsd4)
--
Best regards,
Maxim
--
http://mail.python.org/mailman/listinfo/python-list


Re: __getitem__ method on (meta)classes

2005-03-15 Thread Ron Garret
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Bengt Richter) wrote:

> >Did you mean type(x).__getitem__(x,y)?
> >
> Not if x is a classmethod,

Oh yeah, right.  Duh!

> >And where is this documented?
> Between the lines in my previous post ;-)

I see.  I guess I wasn't asking a stupid question then :-)

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


Re: Convert python to exe

2005-03-15 Thread [EMAIL PROTECTED]
Thanks. I'll try it .

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


Re: __getitem__ method on (meta)classes

2005-03-15 Thread Bengt Richter
On Mon, 14 Mar 2005 23:44:46 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote:

>Ron Garret wrote:
>> What I'm really trying to do is to create enumerated types such that if:
>> 
>> e1 = enum(lst) and v = e1(x)
>> 
>> then
>> 
>> (x in lst) and (e1[v] == x)
>
>Use a class with __call__ and __getitem__:
>
>py> class enum(object):
>... def __init__(self, vals):
>... self.vals = vals
>... def __call__(self, val):
>... return self.vals.index(val)
>... def __getitem__(self, index):
>... return self.vals[index]
>...
>py> lst = 'abcd'
>py> x = 'b'
>py> e1 = enum(lst)
>py> v = e1(x)
>py> (x in lst) and (e1[v] == x)
>True

For that, why not just

 class enum(list):
def __call__(self, val): return self.index(val)

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


Re: __getitem__ method on (meta)classes

2005-03-15 Thread Ron Garret
In article <[EMAIL PROTECTED]>,
 Steven Bethard <[EMAIL PROTECTED]> wrote:

> Ron Garret wrote:
> > What I'm really trying to do is to create enumerated types such that if:
> > 
> > e1 = enum(lst) and v = e1(x)
> > 
> > then
> > 
> > (x in lst) and (e1[v] == x)
> 
> Use a class with __call__ and __getitem__:
> 
> py> class enum(object):
> ... def __init__(self, vals):
> ... self.vals = vals
> ... def __call__(self, val):
> ... return self.vals.index(val)
> ... def __getitem__(self, index):
> ... return self.vals[index]
> ...
> py> lst = 'abcd'
> py> x = 'b'
> py> e1 = enum(lst)
> py> v = e1(x)
> py> (x in lst) and (e1[v] == x)
> True

Yeah, except I actually left out one thing:  I also want type(v)==e1.

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


Re: unicode converting

2005-03-15 Thread Diez B. Roggisch
Maxim Kasimov wrote:

> 
> there are a few questions i can find answer in manual:
> 1. how to define which is internal encoding of python unicode strings
> (UTF-8, UTF-16 ...) 

It shouldn't be your concern - but you can specify it using " ./configure
--enable-unicode=ucs2" or --enable-unicode=ucs4. You can't set it to utf-8
or utf-16.

> 2. how to convert string to UCS-2 

s = ... # some ucs-2 string
s.decode("utf-16")

might give you the right results for most cases:

http://mail.python.org/pipermail/python-dev/2002-May/024193.html


-- 
Regards,

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


Re: distutils setup ignoring scripts

2005-03-15 Thread Raseliarison nirinA
"Jack Orenstein" wrote:

> I'm using Python 2.2 on RH9. I have a set of Python modules
> organized
> into a root package and one other package named foobar. setup.py
> looks
> like this:
>
>  from distutils.core import setup
>
>  setup(
>  name = 'foobar',
>  version = '0.3',
>  description = 'Foo Bar',
>  author = 'Jack Orenstein',
>  author_email = '[EMAIL PROTECTED]',
>  packages = ['', 'xyz'],
>  scripts = ['bin/foobar']
>  )
>
> The resulting package has everything in the specified directories,
> but
> does not include the script. I've tried making the path bin/foobar
> absolute, but that doesn't help. I've googled for known bugs of this
> sort but have come up emtpy. (The first line of bin/foobar is
> #!/usr/bin/python.)
>
> I've also tried using DISTUTIL_DEBUG, which has been uninformative,
> (e.g. no mention of bin/foobar at all).
>
> Can anyone see what I'm doing wrong?

i think there's nothing wrong.
the script (i guess you mean the setup.py file) is not included
into the package because you haven't specified it to be so.
add:
  setup(
...
py_modules=["setup"],
...
)
inside your script to perform inclusion.

another way to include other files not specified by the setup script
is to write a MANIFEST where you indicate those files. then build the
package with the sdist command:

$ cat > MANIFEST
bin/foobar
bin/anotherfoobar
anotherbin/barfoo
setup.py
MANIFEST

ctrl-D
$ python setup.py sdist

>
> Jack Orenstein
>

hope this helps.

--
nirinA












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


  1   2   3   >