Re: Semaphore or what should I use?

2004-12-06 Thread Pierre Barbier de Reuille
Sergei Organov a ecrit :
Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes:

Ville Vainio a ecrit :
"Bastian" == Bastian Hammer <[EMAIL PROTECTED]> writes:
   Bastian> Now I have to make sure, that both threads are

   Bastian> synchronal, 1 thread edits something and the other is
   Bastian> blocked until the first thread is ready.
   Bastian> Isn't it a good idea to do this with a semaphore?

Semaphore will do, but this is a classical use case for
threading.Lock.
There should be lots of stuff regarding locks (or more googleably,
"mutexes") on the net.

I don't agree. Mutexes (or locks) are best suited for critical sections (ie.
sections that cannot be run by many thread at the same time).

Please don't add even more confusion to the issue. Mutex conceptually is
designed to be used for MUTual EXclusion of access to a resource (e.g.,
a peace of data). While critical section could be implemented using
mutex, the mutex itself is more general concept. Besides, the rule of
thumb using mutexes is: "protect data, not program code."
My answer to OP's question is: use either lock (mutex) or semaphore.
I'd probably use semaphore as mutexes are usually optimized for the case
when contention probability is low (i.e., they usually shouldn't be locked
for a long time).
My point is : semaphore is more complex than what he needs. Event are 
simpler and just do what he needs : block one thread until another one 
finished some jobs and launchs the event (have a look at my example).

Afterward, I agree that the concept of mutex is the most general : you 
can implement every other kind of lock using just mutexes.

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


Re: convert string to raw string?

2004-12-06 Thread Terry Reedy

"Phd" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> I'm writing a regex related program that lets the user supplies the regex 
> definition. Is there an easy way to convert a string into a raw string?

There ain't no such thing as raw strings.  Just 'raw' string *literals*, 
where 'raw' denotes a mode for converting the literal in the code (which is 
*not* a Python string) into a Python string.

Perhaps what you want is something like eval("r'%s'" % (raw_input(),)), 
assuming no ' or " in user input.

Terry J. Reedy



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


[pywin32] windows shares, was os.listdir("\\\\delta\\public")

2004-12-06 Thread Egor Bolonev
Try grabbing the output of os.popen(r"net view \\delta") and
parse it to get a list of the shares:
c:\>net view \\monolith
Shared resources at \\monolith
Share name  Type   Used as  Comment
---
Printer Print   Microsoft Office Document Image Writer
Printer2Print   hp psc 1310 series
Printer3Print   HP LaserJet 4
shared  Disk   I:
SharedDocs  Disk
The command completed successfully.
No doubt you can also do this much more easily with the pywin32
package, or via COM (using pywin32 or ctypes), but I'll leave
that response to someone else.  Or you could figure it out yourself
if you are motivated enough.
how to get list of shares using pywin32? 

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


Re: convert string to raw string?

2004-12-06 Thread Duncan Booth
Phd wrote:
> I'm writing a regex related program that lets the user supplies the 
> regex definition. Is there an easy way to convert a string into a raw 
> string?

A raw string is a feature of the syntax of Python. Python gives you several 
ways to write strings: single quoted, double quoted, triple single, triple 
double, and raw versions of these. Once parsed from the source all of these 
simply become objects of type 'str'.

The unicode modifier on a string does produce a different type of object 
internally (type 'unicode'), but the raw modifier does not.

So, perhaps you would like to clarify what you really want to do? Perhaps 
give an example?

If you are getting input from the user, then unless you are doing some 
processing on it to interpret escape sequences the chances are you already 
have what you need to use as a regular expression. If you *are* 
interpreting escape sequences then the answer is you need to not do that 
since the operation isn't really reversible.

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


Re: teaching OO

2004-12-06 Thread Alan Gauld
On 24 Nov 2004 18:31:13 GMT, Gabriel Zachmann
<[EMAIL PROTECTED]> wrote:

> You know, I keep wondering exactly what we will be teaching as programming
> languages become easier and easier to learn.
> 
> Programming itself? -- won't be enough for a whole semester.

Oh no way. You could teach a whole semester just using flow chart
stule diagrams. The concepts of programming stay the same
regardless of language. You just won't need to spend so much time
on syntax, you can focus on the real issues like jump tables,
data types - and how the data structure shapes the code
structure! Issues of locking, error handling strategies,
threading, event-handling etc etc... All of these stop being
advanced features and move into mainstream. Someday :-)

> Another question is: can you teach effectively the inner workings, if you
> teach only a dynamic language?

Yes, its just different inner workings. :-)

But to be serious. I've never quite understood the sense in
universities teaching students about how C++ VMTs etc work.
They are only relevant to one language - and possibly one
implementation of one language since they aren't part of the
standard - and languages change on a ~10 yearly cycle. (Which
means Java should soon be making way for the Next Big Thing -
BEPL maybe?...)

Concepts like hashes and jump tables and generic compiler
techniques are universal but how a particular language is
implemented is only of marginal value IMHO. It would be 
like an Electronics professor spending a lecture dismantling 
an oscilloscope and discussing the circuit diagram - mildy
interesting, but ultimately pointless!

Alan G.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
-- 
http://mail.python.org/mailman/listinfo/python-list


PDF count pages

2004-12-06 Thread Jose Benito Gonzalez Lopez
Hi there,
  Does anyone know how I could do in order
to get/count the number of pages of a PDF file? (from
python of course ;) )
Thanks beforehand.
Cheers,
Jose
--
Jose Benito Gonzalez Lopez
CERN Document Server **  ** 
InDiCo Project   **  ** 
CDSconv  ** 
Room: Bldg 513-R-027 ** Voice: +41 22 76 78893 

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


Re: installing wxPython on Linux and Windows

2004-12-06 Thread rido dodol
Install ubuntu linuxget wxpython with synaptic...is easy!!!


On Thu, 02 Dec 2004 10:19:12 +0100, Peter Maas <[EMAIL PROTECTED]> wrote:
> Recently I replaced Win2k with Linux on my desktop computer. Using mostly
> multi-platform software I thought this would be easy. It was not as
> easy as expected getting wxPython to work. There seemed to be no SuSE RPM
> so I installed from source. Here are my steps (gtk 2.4 was already
> installed):
> 
> - Built wxWidgets (.configure --enable-unicode)
> - Built wxPython (python setup.py install)
>error: "you should use wx-config program for compilation"
> - Tried wx-config with various options
> - Examined (huge) error output more closely: There was a message
>"Usage: wx-config [options]" right at the beginning
> - Debugged setup.py: message was caused by wx-config option unicode=no
> - Debugged config.py: wx-config option unicode=no was caused by UNICODE=0
> - Set UNICODE=1, next build, error: compiler couldn't find stc.h
> - Set BUILD_STC = 0 and some other BUILD_s as well
> - I worked! started demo.py, splash screen started up and - error in
>demo's Main.py 'DemoCodeEditor' object has no attribute 'editor'
> - Ah, STC is for StyledTextControl! set BUILD_STC = 1 again but how can
>I get styledTextControl?
> - Downloaded/built scintilla, but where's the slot for scintilla.a?
> - Realized that I had to build STC (wxWidgets' contribs) separately.
> - Built wxPython, start demo.py - it worked FINALLY!
> 
> Took me with all tries and dead ends approx. 8 hours.
> 
> Same task on Win2k: download wxPython-setup.exe, double-click, done.
> Took me approx. 1 minute. This strikes me. Why are some tasks so hard
> on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
> are made by the same developers. My guess: the software deployment
> infrastructure on Linux needs to be improved.
> 
> Disclaimer: I don't want to blame anyone here. wxPython is a fine
> piece of software otherwise I wouldn't have tried so hard to get
> it working.
> 
> --
> ---
> 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
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-06 Thread Jacek Generowicz
Jp Calderone <[EMAIL PROTECTED]> writes:

> When the class object is created, the namespace is scanned for
> instances of .  For those and only those, a
> descriptor is created which will produce bound and unbound methods.

This isn't quite correct. A descriptior is any object which has
callable attributes called "__get__", "__set__" or "__delete__". Pure
Python functions *are* descriptors:

>>> import types
>>> for name in '__get__', '__set__', '__delete__':
... print name, name in dir(types.FunctionType)
... 
__get__ True
__set__ False
__delete__ False


because they have a __get__ attribute. Builtin functions are not
descriptors:

>>> for name in '__get__', '__set__', '__delete__':
... print name, name in dir(types.BuiltinFunctionType)
... 
__get__ False
__set__ False
__delete__ False

because they do not have any of these.


It is the FunctionType.__get__ which is responsible for the binding of
methods. You can see this for yourself by calling it directly:

>>> class Foo(object):
... pass
... 
>>> def bar():
... pass
... 
>>> bar.__get__(None, Foo)

>>> bar.__get__(Foo(), Foo)
>

Note that if FunctionType.__get__ is passed both an instance and a
class, then it returns a bound method. If it is only passed a class,
then it returns an unbound method.

So, let's write a little descriptior which merely reports what
arguments it's __get__ method receives:

>>> class Test__get__(object):
... def __get__(*args):
... return args
... 

Let's add an instance of this as a class attribute to Foo:

>>> Foo.test = Test__get__()

... and see what happens when you access it through the class:

>>> Foo.test
(<__main__.Test__get__ object at 0x40171b8c>, None, )

... and what happens when you access it via an instance of the class:

>>> Foo().test
(<__main__.Test__get__ object at 0x40171b8c>, <__main__.Foo object at 
0x40171a4c>, )

Observe that when accessing the attribute through the class, __get__
is not passed any instance, which tells __get__ to return an unbound
method (as we saw above). If it is accessed through an instance,
__get__ is passed both an instance and its class, which tells __get__
to return a bound method.

The question remains "Why is __get__ called when an attribute is
looked up?" The answer is "Because that's what __getattribute__
does". Which __getattribute__? That depends. If you access via the
class, then it's type.__getattribute__, if you access through an
instance of the class, then it's object.__getattribute__. More
generally, an attribute access such as

X.Y

is equivalent to

   type(X).__getattribute__('Y')

So, the type of object whose attribute you are looking up, determines
(via it's __getattribute__ method) the arguments that the attribute's
__get__ will be passed.

Note that __getattribute__ of ModuleType, does *not* invoke this
descriptor protocol of functions at all ... otherwise, all
module-level functions would be turned into methods !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Quixote+Nevow+LivePage

2004-12-06 Thread mirnazim
I m still without any helpful answers.

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


Recursive list comprehension

2004-12-06 Thread Timothy Babytch
Hi all.
I have a list that looks like [['N', 'F'], ['E'], ['D']]
I try to make it flat one: ['N', 'F', 'E', 'D']
How can I archieve such an effect with list comprehension?
Two cycles did the job, but that way did not look pythonic..
I tried
print [x for x in y for y in c_vars]
and got NameError: name 'y' is not defined.
--
Timothy Babytch
--
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive list comprehension

2004-12-06 Thread Peter Otten
Timothy Babytch wrote:

> Hi all.
> 
> I have a list that looks like [['N', 'F'], ['E'], ['D']]
> I try to make it flat one: ['N', 'F', 'E', 'D']
> 
> How can I archieve such an effect with list comprehension?
> Two cycles did the job, but that way did not look pythonic..
> 
> I tried
> print [x for x in y for y in c_vars]
> and got NameError: name 'y' is not defined.
> 

The order of the for expressions is as it would be for nested loops:

>>> items = [['N', 'F'], ['E'], ['D']]
>>> [y for x in items for y in x]
['N', 'F', 'E', 'D']

I would still prefer a for loop because it spares you from iterating over
the sublist items in python:

>>> data = []
>>> for sub in [['N', 'F'], ['E'], ['D']]:
... data.extend(sub)
...
>>> data
['N', 'F', 'E', 'D']

Peter

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


Re: Recursive list comprehension

2004-12-06 Thread Timothy Babytch
Peter Otten wrote:
The order of the for expressions is as it would be for nested loops:
items = [['N', 'F'], ['E'], ['D']]
[y for x in items for y in x]

I would still prefer a for loop because it spares you from iterating over
the sublist items in python:

data = []
for sub in [['N', 'F'], ['E'], ['D']]:
... data.extend(sub)
...
Thanks. Both tips were helpful.
--
Timothy Babytch
--
http://mail.python.org/mailman/listinfo/python-list


RE: [pywin32] windows shares, was os.listdir("\\\\delta\\public")

2004-12-06 Thread Tim Golden
[Egor Bolonev]
| how to get list of shares using pywin32? 

You want to be looking at the NetShareEnum function
in the win32net module.

TJG


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

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


suffix .py in IDLE

2004-12-06 Thread p.kosina
Its just for my convienience:
When saving new file in IDLE I HAVE to always manually add suffix .py, 
otherwise it is saved without ANY suffix.
Can it be set somewhere?

Thank you
Pavel
--
http://mail.python.org/mailman/listinfo/python-list


Re: PDF count pages

2004-12-06 Thread Andreas Lobinger
Aloha,
Jose Benito Gonzalez Lopez wrote:
Does anyone know how I could do in order
to get/count the number of pages of a PDF file? 
Like this ?
Python 2.2.2 (#3, Apr 10 2003, 17:06:52)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import pdffile
>>> pf = pdffile.pdffile('../rfc1950.pdf')
>>> import pages
>>> pp = pages.pages(pf)
>>> len(pp.pagelist)
10
>>>
This is an example of the usage of pdfplayground. pdfplayground
is available via sourceforge. There is no package at the
moment, but you should be able to check out via anon-cvs.
Wishing a happy day
LOBI
--
http://mail.python.org/mailman/listinfo/python-list


RE: notification for cd insertion

2004-12-06 Thread Tim Golden
[Qiangning Hong]

| I want one of my function to execute when a cdrom is 
| inserted.  How can I achieve that?

1) Go to http://groups.google.com
2) Search for python cd insert notification
3) Pick the first result, which is a post by
   me responding to the same question about a
   year ago.

TJG


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

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


Re: python-mode question

2004-12-06 Thread Thomas Heller
Skip Montanaro <[EMAIL PROTECTED]> writes:

> Thomas> When I edit a Python script with XEmacs, then hit C-c C-c, the
> Thomas> script is executed, the output is shown in a *Python Output*
> Thomas> buffer, and the cursor is moved into this buffer.
>
> Thomas> How can I change the behaviour so that the cursor stays where it
> Thomas> was before?  I'm using Revision 4.29, if it matters.
>
> I'd class this behavior as a bug.  It's not fixed in the latest version.
> Can you file a bug report on SF ?

I assume you meant the python-mode project?

http://sourceforge.net/tracker/index.php?func=detail&aid=1079878&group_id=86916&atid=581349

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


xmlrpclib or twisted?

2004-12-06 Thread flupke
Hi,
previously i made an application that used sockets to
do some network based processing.
My next app is again going to be a client/server app
and i wanted to see if i can't find an easier way to
make the networking going.
I bumped into xmlrpclib and also twisted (pb).
I'm not sure which on of these would suit my needs better.
I am planning to build a web GUI for the client so if i
use twisted, i would already have the components in there
to do so, so this could be a plus for twisted.
The client will connect to the server to receive data.
The data is the result of one of several queries and these raw
results would then be displayed in the client via a webgui or
wxPython. (leaning towards webgui)
Any other ideas?
Thanks
Benedict
--
http://mail.python.org/mailman/listinfo/python-list


PIL + Zope + resizing images

2004-12-06 Thread KK
Hallo.

I have Zope 2-7-0 on Linux platform and the following problem :)
I'm sending an image through form on the pythonScript. I want script to
resize image and save on the zope folder in 3 different size. OK, I use
ExternalMethod which uses PIL library to resize these images.

External method:
def xImageScale(img_file, maxx, maxy):
from PIL import Image
from cStringIO import StringIO
im = Image.open(img_file)
im.thumbnail((maxx, maxy), Image.ANTIALIAS)
out_file_str = StringIO()
im.save(out_file_str, im.format)
out_file_str.seek(0)
tmp=out_file_str.read()
out_file_str.close()
return tmp


pyrthonScript:
cAnimation = form.get('cAnimation','') # image from the form
if cAnimation:
 o.invokeFactory(id='cAnimationS.'+timeStamp, type_name='Image',
file=context.xImageScale(cAnimation, 100, 100)
 o.invokeFactory(id='cAnimationM.'+timeStamp, type_name='Image',
file=context.xImageScale(cAnimation, 200, 200)
 o.invokeFactory(id='cAnimationB.'+timeStamp, type_name='Image',
file=context.xImageScale(cAnimation, 300,300)


The result is "IOError,  cannot identify image file". So, when I want to
resize and save only one image it works properly.


Thanks in advance for any help
KK


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


Re: Recursive list comprehension

2004-12-06 Thread Peter Nuttall
On Monday 06 Dec 2004 09:26, Timothy Babytch wrote:
> Hi all.
>
> I have a list that looks like [['N', 'F'], ['E'], ['D']]
> I try to make it flat one: ['N', 'F', 'E', 'D']
>
> How can I archieve such an effect with list comprehension?
> Two cycles did the job, but that way did not look pythonic..
>
> I tried
> print [x for x in y for y in c_vars]
> and got NameError: name 'y' is not defined.
>
> --
> Timothy Babytch

Hi,

I think you do it with a generator like this:

def flatten(nested):
  for sublist in nested:
for element in sublist:
  yield element

n=[['N', 'F'], ['E'], ['D']]
output=[]

for value in flatten(n):
  output.append(value)

print output

Have a merry Christmas

Peter Nuttall

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


Re: New to Python: Features

2004-12-06 Thread dautjics
http://www.ardice.com/Computers/Programming/Graphics/Libraries/OpenGL/Add-on_Libraries/

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


Re: Curses programming, threads?

2004-12-06 Thread Bartlomiej Rymarski
Michele Simionato <[EMAIL PROTECTED]> wrote:
> You don't need curses. Some time ago somebody (I forgot the name)
> posted this spinner class:
> 
> class Spinner( threading.Thread ): # a google search should find the author
> [...]

Great, thanks a lot.

-- 
Bartek Rymarski <[EMAIL PROTECTED]>
$ %blow
bash: fg: %blow: no such job
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Curses programming, threads?

2004-12-06 Thread Bartlomiej Rymarski
Carl Banks <[EMAIL PROTECTED]> wrote:

> (...)
> But I recommend threads for this.  It's one of the easiest possible
> uses of threads.  There's no complex communication involved; locks and
> semaphores and stuff aren't required.  Just connect to the database in
> a subthread, and have it set a global flag just before it exits. 
> Animate in a loop in the main thread, checking the flag every
> iteration, and when it's true, you're done.
> (...)

I'll try to do this with threads then. Thanks for the answer.

-- 
Bartek Rymarski <[EMAIL PROTECTED]>
$ %blow
bash: fg: %blow: no such job
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive list comprehension

2004-12-06 Thread Nick Coghlan
Peter Nuttall wrote:
I think you do it with a generator like this:
def flatten(nested):
  for sublist in nested:
for element in sublist:
  yield element
n=[['N', 'F'], ['E'], ['D']]
output=[]
for value in flatten(n):
  output.append(value)
print output
I highly recommend learning about the stdlib module "itertools" (I only really 
looked into it recently). The above can be done in 3 lines (counting imports):

  from itertools import chain
  n = [['N', 'F'], ['E'], ['D']]
  print [chain(*n)]
Documentation:
  http://www.python.org/doc/2.3.4/lib/itertools-functions.html
Cheers,
Nick.
--
http://mail.python.org/mailman/listinfo/python-list


CTYPE 0.9.2 porting problems

2004-12-06 Thread Armin Steinhoff

Hi all,
I ported ctypes 0.9.2 to QNX6.3 ... 99.9 % is working but only the 
unittest test_functions.py makes some problem. Here is the code:

p = pointer(c_int(99))
result = f(p)
self.failUnlessEqual(result.contents.value, 99) #---> works!!
# We need to keep the pointer alive, otherwise the contents change:
result = f(pointer(c_int(99)))
print result.contents.value
self.failIfEqual(result.contents.value, 99)
Error message:
# python test_functions.py
..99
F.
==
FAIL: test_pointers (__main__.FunctionTestCase)
--
Traceback (most recent call last):
  File "test_functions.py", line 194, in test_pointers
self.failIfEqual(result.contents.value, 99)
  File "/usr/local/lib/python2.3/unittest.py", line 310, in failIfEqual
raise self.failureException, \
AssertionError: 99 == 99
What's the problem here? 99 isn't equal 99 :)
--
Ran 16 tests in 0.053s
FAILED (failures=1)
#

# XXX But this not! WHY on earth?  >> BUT this IS working!!
arg = byref(v)
result = f(arg)
self.failIfEqual(result.contents, v.value)
I see always a crash of Python if the library call time() is used ... 
but it happens only with this call.

What could be in general the reasons??
Regards
   Armin
--
http://mail.python.org/mailman/listinfo/python-list


Deadlock detection

2004-12-06 Thread Duncan Grisby
Hi,

Does anyone know of a deadlock detector for Python?  I don't think it
would be too hard to hook into the threading module and instrument
mutexes so they can be tested for deadlocks. I've googled around but I
haven't found anything.

Cheers,

Duncan.

-- 
 -- Duncan Grisby --
  -- [EMAIL PROTECTED] --
   -- http://www.grisby.org --
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: long number multiplication

2004-12-06 Thread Nick Craig-Wood
I.V. Aprameya Rao <[EMAIL PROTECTED]> wrote:
>  i have been wondering, how does python store its very long integers and 
>  perform aritmetic on it.
> 
>  i needed to implement this myself and was thinking of storing the digits 
>  of an integer in a list.
> 
>  however this would be very slow for operations like division etc.
> 
>  so if anyone can point me to some links or some method on how to do this i 
>  would appreciate it

Anyone interested in this subject should read

  SemiNumerical Algorithms D.E.Knuth, Addison-Wesley

Its the bible for this area of computer science!  Its also rather big
and expensive so you'll probably want to look at in the library...

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


Re: Recursive list comprehension

2004-12-06 Thread Peter Otten
Nick Coghlan wrote:

> from itertools import chain
> n = [['N', 'F'], ['E'], ['D']]
> print [chain(*n)]

However, [generator] is not the same as list(generator):

>>> from itertools import chain
>>> n = [['N', 'F'], ['E'], ['D']]
>>> print [chain(*n)]
[]
>>> print list(chain(*n))
['N', 'F', 'E', 'D']

And with the star operator you are foregoing some laziness, usually an
important selling point for the iterator approach. Therefore:

>>> n = [['N', 'F'], ['E'], ['D']]
>>> lazyItems = (x for y in n for x in y)
>>> lazyItems.next()
'N'
>>> list(lazyItems)
['F', 'E', 'D']
>>>

Of course this makes most sense when you want to keep the original n anyway
_and_ can be sure it will not be mutated while you are still drawing items
from the lazyItems generator.

Peter

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


Re: Recursive list comprehension

2004-12-06 Thread Nick Coghlan
Peter Otten wrote:
Nick Coghlan wrote:

from itertools import chain
n = [['N', 'F'], ['E'], ['D']]
print [chain(*n)]

However, [generator] is not the same as list(generator):
Heh - good point. As you say, replacing with list() gives the intended 
answer.
With regards to laziness, my main point was that itertools is handy for 
manipulating sequences, even if you aren't exploiting its capacity for lazy 
evaluation.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Quixote+Nevow+LivePage

2004-12-06 Thread Carlos Ribeiro
On 6 Dec 2004 01:15:35 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I m still without any helpful answers.

I'm sorry to hear that. There were some answers (including mine) that
may have not solved your problem, but at least we did try. That's the
best one can ask far while posting on a public forum.

My last attempt at answering your question is: LivePage was designed
to work with Nevow+Twisted. I never tried to used it myself. There are
some indications that it uses non-http transport for the "live"
stream. If this is true, then it will only work with Twisted. I know
that a similar trick can be implemented in other systems but that it
requires a lot of clever Javascript & XMLRPC code. I'm studying this
problem because I want to implement a solution for CherryPy, but
there's not any guarantee about it, because it's something that I'm
doing on my "copius" free time. Please don't hold your breath for it.

If that's not helpful to you, I'm sorry.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Float to int conversions (was: int(float(sys.maxint)) buglet)

2004-12-06 Thread Nick Coghlan


A quick check of the source code reveals that this behaviour is deliberate. 
There is apparently an issue with the corner case breaking badly (potentially 
raising an exception) on some platforms. So, Python plays it safe and converts 
the two boundary cases to Python longs instead of Python ints.

See the code for the gory details (the relevant function is 'float_int'):
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/floatobject.c?rev=2.134&view=markup
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


MySQL-python-1.0.0.win32-...

2004-12-06 Thread Henning Hanusa
Could anybody please provide me with a "compiled" version of the above

(MySQLdb 1.0.0 for Python on Win 2000 / XP)

for Python version 2.4, as I do not have any possibility of compiling??

Many thanks in advance

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


Problems with calendar products in Plone

2004-12-06 Thread Espen Willersrud
I have a installation with plone-2.0.4-1 and zope-2.7.2-1. I have to use 
this version, for the reason that the server this will be exportet to 
have the same installation.

I have tested a lot of calendar products with plone, to find one that 
fitt our needs betther then the standard one. And everyone I have tested 
was not good enough. But there was one i did not get to run, it just 
crashed the site.

I installed this one:
http://www.contentmanagementsoftware.info/plone/Calendaring
But I understands that you need ZopeTestCase to have it to run properly, 
but it had noe affect on the installation.

Does anyone have any experience with this?
- Espen
--
http://mail.python.org/mailman/listinfo/python-list


exec and thread.start_new

2004-12-06 Thread Nick Coghlan


Andr? Roberge wrote:
I don't understand why I need to use the global statement within the
definition of c() in order for it to know what a() is.  If I define
exec_code() within test.py and use it there, I do not get any error,
with or without the use of a global statement.
I get the same behaviour (Windows XP, Python 2.4c1)
It seems exec is having trouble retrieving a sane locals dictionary in the 
context provided by thread.start_new().

The global statement forces it to use the globals dictionary, which works 
correctly.
Similarly, using "exec co in dict()" (instead of "exec co") works fine (the 
newly created dict is used instead of the broken one exec is currently finding).

It looks like a real bug to me (in thread.start_new_thread()), but a low 
priority one, as:

1. In general, the higher-level threading module is recommended over the thread 
module.
2. The 'in dict()' workaround is simple and effective

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive list comprehension

2004-12-06 Thread Serhiy Storchaka
Timothy Babytch wrote:
I have a list that looks like [['N', 'F'], ['E'], ['D']]
I try to make it flat one: ['N', 'F', 'E', 'D']
How can I archieve such an effect with list comprehension?
Two cycles did the job, but that way did not look pythonic..
I tried
print [x for x in y for y in c_vars]
and got NameError: name 'y' is not defined.
sum(c_vars, [])
--
Serhiy Storchaka
--
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL-python-1.0.0.win32-...

2004-12-06 Thread Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
+1



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


Re: help asap

2004-12-06 Thread Steve Holden
the_proud_family wrote:
HELP ME PLEASE!! my email is [EMAIL PROTECTED]
I can't get the ball to go up right side and then I need it to turn
around and keep turning until velocity=0 I have been at it for the
past 2 weeks now i give up and call for help. Please if anyone can
gide me through i will be so grateful!! I have pasted my code below


from cmath import *
from visual import *
floor1 = box(length=10, height=0.5, width=4, color=color.blue)
floor1.pos = (-6,4,0)
floor1.axis= (5,-5,0)
floor2 = box(length=10, height=0.5, width=4, color=color.blue)
floor2.pos = (6,4,0)
floor2.axis= (-5,-5,0)
floor3 = box(length=7, height=0.5, width=4, color=color.blue)
floor3.pos = (0,1.25,0)
ball= sphere(radius=0.5, color=color.red)
ball.pos=(-8.6,7.5,0)
m=3. #kg
angle=asin(3.6/5.)#radians
g=-9.8
mu=.2
N=mgcos(angle)
F=mgsin(angle)
f=mu*N
lax=(-Nsin(angle)+fcos(angle))/m
lay=(-Ncos(angle)-fsin(angle)+m*g)/m
rax=(+Nsin(angle)+fcos(angle))/m
ray=(-Ncos(angle)-fsin(angle)+m*g)/m
ds=0.01
dt=0.01
vx=lax*dt
vy=lay*dt
ball.velocity=vector(vx,vy,0)
#print a
while 1:
rate(100)
ball.velocity.x=ball.velocity.x+lax*dt
ball.velocity.y=ball.velocity.y+lay*dt
ball.pos=ball.pos+ball.velocity*dt
if ball.x>-3.5 and ball.x<=3.5:
vx=sqrt(2(-gball.y+0.5(vx2+vy2)-fds))
ball.velocity.x=ball.velocity.x+mugdt
ball.velocity.y=0
ball.pos=ball.pos+ball.velocity*dt
if ball.x>3.5 and ball.x<8.6:
vx=vx*cos(angle)
vy=sqrt(2/m(m-gball.y-fds))
#print vy
vy=vy*sin(angle)
#print vy
ball.velocity.x=ball.velocity.x+rax*dt
ball.velocity.y=ball.velocity.y+ray*dt
ball.pos=ball.pos+ball.velocity*dt
#print ball.pos


Let me open by saying I'm sorry of this response appears superficially 
unhelpful. Please read it to the end, as it really is intended to help 
despite its obstinate refusal to directly address your question.

This appears to be your third attempt to recruit help, which shows 
rather poor learning behavior. You have presented what appears 
(superficially, most people who contribute to this newsgroup don't have 
the time to read random chunks of code and I'm usually the same) to be 
the same program each time.

Might I suggest that you:
  1. Explain what the program is intended to
 do. If we can't know what problem you
 are trying to solve we are unlikely to
 be able to help.
  2. Reformat your code to use leading spaces
 rather than tabs (many newsreaders
 handle tabs badly)
  3. Add copious comments explaining what each
 section of your program is supposed
 to do.
With luck, those activities alone will help you to solve your own 
problem. One valid debugging technique is to explain to somebody else 
exactly why there can't possibly be anything wrong with your program. 
Quite often you will smack your head in the middle of this activity, 
having realized exactly what your mistaken assumption has been. If there 
is no human available a stuffed toy can work almost as well.

Finally, please take the time to read
http://www.catb.org/~esr/faqs/smart-questions.html
as this will give you some useful clues on how to increase your chances 
of getting a rely that will *actually solve your problem* rather than 
just pointing out that your current behavior is unlikely to do so.

It's just occurred to me that in the time it's taken me to write this I 
probably could have run your code (had it been properly formatted) and 
attempted to find out what was wrong with it. So please take this advice 
in the spirit of "if you give a man a fish you feed him for a day*, if 
you teach him to fish you feed him for a lifetime" -- I am trying to 
help you help yourself, as several others have already.

Finally, one crucial lesson for any would-be programmer is to persevere 
(and you do at least score high marks there). The longer your problem 
goes unsolved the better you'll feel about eventually arriving at a 
solution.

regards
 Steve
--
* alternative ending: if you teach him to fish, for the rest of his life 
he'll bore you with stories about the one that got away.

http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Win32 Libs for 2.4

2004-12-06 Thread Robin Becker
Does anyone know if it is feasible to have static libraries for both 2.3 and 2.4 
compatible extensions. I'm worrying about libjpeg etc in a win32 environment.

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


Re: Seeking Python + Subversion hosting.

2004-12-06 Thread Roy Smith
[EMAIL PROTECTED] (Tom Locke) wrote:
> Anyone know of a good hosting company that offers both server-side
> Python and a subversion repository?

Panix (www.panix.com) has svn and python installed on their unix hosts.  
You could certainly do CGI in python.  Don't know if they have 
mod_python available or not.

Support and customer care couldn't be better.  These guys started as a 
BBS in the founder's apartment 20 years ago, and haven't lost that 
personal touch while growing the business into a serious commercial 
venture.

I don't know how their pricing works out for serious web hosting.  I pay 
$100/year for my unix shell account, mostly to get mail and news, but it 
includes some low-limit web hosting which I only play around with once 
in a while.  A higher-quota web hosting arrangement with your own domain 
name, etc, would certainly cost you more than $100/year.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ptyon 2.3.5 probably coming in January; get your bugs/patches reported!

2004-12-06 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 "Brett C." <[EMAIL PROTECTED]> wrote:

> Anthony Baxter, our ever-diligent release manager, mentioned this past week 
> that Python 2.3.5 will most likely come to fruition some time in January 
> (this is not guaranteed date).

Interesting.  Does that mean that 2.3 and 2.4 will be maintained in 
parallel for a while?  That would be awesome.
-- 
http://mail.python.org/mailman/listinfo/python-list


I need to create the table and I want to edit its content from www level.

2004-12-06 Thread Rootshell
Yo, thanks for help

Yeap, wikipedia is one of examples, the wikipedia script includes
'action=edit' command and it edits the file called 'wiki.phtml'.

I want to edit the content of casual table. Have no idea how to give
the password to a few users, so they can edit this small table. That's
all.

Cheers

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


Re: exec and global puzzle

2004-12-06 Thread Steve Holden
Andr? Roberge wrote:
I have the following two files:
#--testexec.py--
def exec_code(co):
try:
exec co
except:
print "error"
#-- test.py--
import thread
import testexec
import time
code = "def a():\n print 'a'\n\n" +\
   "def c():\n a()\n\nc()"
code2 = "def a():\n print 'a'\n\n" +\
   "def c():\n global a\n a()\n\nc()"
print " exec code - no global"
exec code
print " exec from thread - no global"
thread.start_new(testexec.exec_code, (code,))
time.sleep(1)
print "\n exec code2 - with global"
exec code2
print " exec from thread - with global"
thread.start_new(testexec.exec_code, (code2,))
#---
Here's the output when I execute test.py:
 exec code - no global
a
 exec from thread - no global
error
 exec code2 - with global
a
 exec from thread - with global
a
#-
Without the global statement, I get an error when trying to execute
the code.
I don't understand why I need to use the global statement within the
definition of c() in order for it to know what a() is.  If I define
exec_code() within test.py and use it there, I do not get any error,
with or without the use of a global statement.
Andre
I have taken the liberty of restructuring your program slightly, by 
using a "from" to explicitly import the function you need, and by using 
extended string literals (""" ... """) to make the code easier to read. 
I have also included print statements to show the contents of the local 
and global namespaces after the definition of function a(). After these 
transformations it looks like this:

import thread
from  testexec import exec_code
import time
code = """\
def a():
  print 'a'
def c():
  a()
c()
"""
code2 = """\
def a():
  print 'a'
def c():
 global a
 a()
c()
"""
print " exec code - no global"
exec code
print " exec from thread - no global"
thread.start_new(exec_code, (code,))
time.sleep(1)
print "\n exec code2 - with global"
exec code2
print " exec from thread - with global"
thread.start_new(exec_code, (code2,))
time.sleep(1)
(OK, I added a final sleep so I saw the output from the second thread).
The reason you are seeing this behavior lies in the behavior of the exec 
statement. The full syntax for that statement is

exec_stmt  ::=  "exec" expression ["in" expression ["," expression]]
The second and third expressions are mappings that will be used as 
namespaces. Since you don't provide either, the interpreter uses the 
current scope (whose contents can be determined using the locals() 
function) for both namespaces, so it doesn't matter whether the function 
is added to the local or the global namespace.

When using threads, however (and, by the way, the usual advice is to use 
the threading module, which has a more convenient API), the namespaces 
are clearly different. The a() function is being added to the local 
namespace for the exec.

So ultimately it's to do with namespaces, as many of the more perplexing 
problems in Python are. I hope this helps establish exactly *why* you 
see what you do.

regards
 Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


byte code generated under linux ==> bad magic number under windows

2004-12-06 Thread Philippe C. Martin
Hi,

I understand from my reading that a .pyc generated by python anywhere should 
run anywhere else - is that true ?

If I generate 'compile.all' a pyc with python 2.3.3 under Linux, I get a 'bad 
magic number' trying to execute it under windows (2.4).


What am I doing wrong ?

are the pyc plateform dependant ? and if so must I generate one version for 
each version of Linux, windows .. ?

Regards,


Philippe




-- 
*
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Win32 Libs for 2.4

2004-12-06 Thread Daniel Dittmar
Robin Becker wrote:
Does anyone know if it is feasible to have static libraries for both 2.3 
and 2.4 compatible extensions. I'm worrying about libjpeg etc in a win32 
environment.
Could you be a bit more specific:
do you want to create a binary python extension that is compatible with 
both Python 2.3 and Python 2.4.

Or do you want to create a static lib containing both the original C lib 
and the code for your extension? This Lib should then be linked with the 
proper python2*.lib to create a version specific binary extension.

Or something else?
The first one is not possible as far as I know because python2*.lib 
tries to load a specific python2*.dll. You could try to replace static 
DLL import with dynamic DLL import (loading the DLL explizit and getting 
the function pointers by name). That would be a lot of work and I don't 
know how well it works for global variables (like all the type objects). 
On the other hand, many people find it annoying that you have to build 
new exte8ensions for every Python version, so this could be something a 
lot of people have an interest in.

I solved this problem by putting .pyd for several versions into the 
download. The right one is picked at runtime by checking sys.version.

Creating one lib which is then linked to python2*.lib works most of the 
time, but you'll probably get a warning during loading of the module 
that the extension has been compiled for a different version of the API.

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


Re: [pywin32] windows shares, was os.listdir("\\\\delta\\public")

2004-12-06 Thread Peter Hansen
Egor Bolonev wrote:
Try grabbing the output of os.popen(r"net view \\delta") and
parse it to get a list of the shares:
c:\>net view \\monolith
No doubt you can also do this much more easily with the pywin32
package, or via COM (using pywin32 or ctypes), but I'll leave
that response to someone else.  Or you could figure it out yourself
if you are motivated enough.
how to get list of shares using pywin32?
Apparently you weren't motivated enough...
This is not a Python question.  It's a Windows API question.
Go find the appropriate Windows API and you'll pretty much
have your answer.  There are tools called Google and
comp.os.windows* and such that would be of great help (in
conjunction with a little initiative).
*Then*, and only then, if you can't get it working but have
tried, is it really appropriate to ask here in the Python
forum how to do it.  Your question at the time would say something
like "I'm trying to use the WinGetNetworkSharesA() call to
retrieve a list of shares but this isn't working... see the
following traceback for details.  Thanks in advance for your help."
Or you can still just ask here for someone to do the work
for you.  That does often work, strangely enough.
(It's possible that the problem stems from a language issue.
If your English is such that you are finding it very difficult
to understand our responses, or to ask a more detailed question,
then my apologies for thinking you were rude.  It might help
you to say that this is the problem and then you might get
more direct help.)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: I need to create the table and I want to edit its content from www level.

2004-12-06 Thread Fred Pacquier
[EMAIL PROTECTED] (Rootshell) said :

> I need to create the table and I want to edit its content from www
> level.
> 
> Here is some example:
> 
> http://www.rootshell.be/~flash44
> 
> There is a table.
> Is there possibilty to edit the content using  command?
> 
> Could you show me the way how to do it?
> 
> My vision is:
> User has its login and password. When he logs in the table space opens
> and he can edit the content.
> 
> I need a few lines of code for example or url with similar idea.
> 
> Best regards.
> 
> Rootshell.

This may give you some ideas :
http://www.cwareco.com/download/tabla.html

-- 
YAFAP : http://www.multimania.com/fredp/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I need to create the table and I want to edit its content from www level.

2004-12-06 Thread Peter Hansen
Rootshell wrote:
Yo, thanks for help
Yeap, wikipedia is one of examples, the wikipedia script includes
'action=edit' command and it edits the file called 'wiki.phtml'.
I want to edit the content of casual table. Have no idea how to give
the password to a few users, so they can edit this small table. That's
all.
Maybe just emailing it to them would be enough?
(I doubt this is the sort of answer you wanted, but given that
it's a perfectly valid answer to your implied question, I hope
you can see that you need to be more detailed and specific
if you want decent help.  I really don't know what you're asking,
unless it's to have a solution handed to you on a platter.  That's
fair enough, but since nobody can really guess what your needs
are, it's unlikely to happen.)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


RPC with Python - Comparison?

2004-12-06 Thread Wolfgang Keller
Hello,

has anyone done a comparison of the different RPC protocols &
implementations available for Python that is more extensive and exhaustive
than the one on
http://www-106.ibm.com/developerworks/webservices/library/ws-pyth9/?

Topics would be:

- Runtime efficiency
- Development efficiency
- Design concepts & features (security...)

Candidates could be:

- Pyro
- Twisted.spread
- OSE (XML-RPC)
- ICE
- ...others?

TIA,

Best regards

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


Re: Deadlock detection

2004-12-06 Thread Stephen Kellett
>Does anyone know of a deadlock detector for Python?  I don't think it
>would be too hard to hook into the threading module and instrument
>mutexes so they can be tested for deadlocks. I've googled around but I
>haven't found anything.

Software Verification have Python Thread Validator. Its not publicly
advertised on the beta part of the website, but it is available.

http://www.softwareverify.com/publicBeta.html

Take a look at Thread Validator or Java Thread Validator to see what the
tool looks like (the Python tool is similar). If you are interested send
an email to support asking about the Python port.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk
RSI Information:http://www.objmedia.demon.co.uk/rsi.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: byte code generated under linux ==> bad magic number under windows

2004-12-06 Thread Aaron Bingham
Philippe C. Martin wrote:
I understand from my reading that a .pyc generated by python anywhere should 
run anywhere else - is that true ?

If I generate 'compile.all' a pyc with python 2.3.3 under Linux, I get a 'bad 
magic number' trying to execute it under windows (2.4).

What am I doing wrong ?
are the pyc plateform dependant ? and if so must I generate one version for 
each version of Linux, windows .. ?
 

.pyc files are platform-independant but are incompatible between major 
Python versions.  You can not use a .pyc file generated with Python 2.3 
with Python 2.4 or vice versa.

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


Re: byte code generated under linux ==> bad magic number under windows

2004-12-06 Thread Laszlo Zsolt Nagy
> I understand from my reading that a .pyc generated by python anywhere should
> run anywhere else - is that true ?
> If I generate 'compile.all' a pyc with python 2.3.3 under Linux, I get a 'bad
> magic number' trying to execute it under windows (2.4).
> What am I doing wrong ?

You should use the same python versions.

> are the pyc plateform dependant ? and if so must I generate one version for
> each version of Linux, windows .. ?

No, it is not platform dependent, but it is version dependent.


Best,

   Laci 2.0

mailto:[EMAIL PROTECTED]
web:http://designasign.biz


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


Python parsers for C/C++/Java

2004-12-06 Thread shivaram.upadhyayula
Title: Python parsers for C/C++/Java






Hi,

I am looking for a parser generator to parse C, C++ and Java (including popular extensions from various compilers) source code; I have come across PLY, SPARK, D-parser (there seems to be a all-python version itself for this one), etc. and am wondering which one would be the most appropriate one for our use -- which is to do a bit of static code analysis (in python) on the sources.

The support for the various language  dialects cannot be compromised; for instance if it's C, it will have to support all popular variants, like GCC's, Microsoft's, etc.

If there are free pre-built python parsers that handle any of these languages, it would really help to start off.

Thanks in Advance,

Best Regards,
Shivram U

(Please CC me as i am not subscribed to the list)





Confidentiality Notice 

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Book Recommendations

2004-12-06 Thread elbows

Manuzhai wrote:
> Check this thread currently going on:
>
http://groups.google.com/groups?hl=en&lr=&c2coff=1&safe=off&threadm=coqd91%246m2%241%40news.doit.wisc.edu&prev=/groups%3Fhl%3Den%26lr%3D%26c2coff%3D1%26safe%3Doff%26group%3Dcomp.lang.python
>

The link doesn't work -- maybe because of the new google groups
interface?
Can you repost with a working link?

Thanks,
Nathan

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


Re: Recursive list comprehension

2004-12-06 Thread Timothy Babytch
Serhiy Storchaka wrote:
>>>sum([['N', 'F'], ['E'], ['D']], [])
['N', 'F', 'E', 'D']
THE BEST!
--
Timothy Babytch, PHP-dev Teamleader
--
http://mail.python.org/mailman/listinfo/python-list


Re: Win32 Libs for 2.4

2004-12-06 Thread Robin Becker
Daniel Dittmar wrote:
Robin Becker wrote:
Does anyone know if it is feasible to have static libraries for both 
2.3 and 2.4 compatible extensions. I'm worrying about libjpeg etc in a 
win32 environment.

Could you be a bit more specific:
do you want to create a binary python extension that is compatible with 
both Python 2.3 and Python 2.4.

not this one
Or do you want to create a static lib containing both the original C lib 
and the code for your extension? This Lib should then be linked with the 
proper python2*.lib to create a version specific binary extension.

not this one either
Or something else?
actually I want to build the PIL extension for 2.4 as pyd and include various 
libraries eg zlib and jpeg. To avoid the missing dlls issue we have done this in 
the past by incorporating the zlib/jpeg code using static libraries for both 
zlib and jpeg.

It seems I can use the static lib built with MSC 6 with the extension code 
compiled with MSC 7.1. At least the extnsion build doesn't complain. Whether 
this is really allowed is another matter.

Daniel

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


Re: xmlrpclib or twisted?

2004-12-06 Thread Istvan Albert
flupke wrote:

I am planning to build a web GUI for the client so if i
If you are planning to build a browser based interface
then use an available webserver and don't build
your own.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [BUG] IMO, but no opinions? Uncle Tim? was: int(float(sys.maxint)) buglet ?

2004-12-06 Thread jepler
Python 2.2.2:
>>> int(float(sys.maxint))
2147483647

Python 2.3.2:
>>> int(float(sys.maxint))
2147483647L

If you're looking for a suspicious change, this should narrow it down.

Jeff


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

Re: long number multiplication

2004-12-06 Thread Michael Hudson
"Terry Reedy" <[EMAIL PROTECTED]> writes:

> "I.V. Aprameya Rao" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > i have been wondering, how does python store its very long integers and
> > perform aritmetic on it.

Well, up until fair recently it used "high school" arithmetic in base
2**15.  Now it uses Karatsuba multiplication and some very mild tricks
for exponentiation, I believe.

> The only real documention for stuff like this, other than random posts on 
> c.l.p., is the source code itself.  It is generally pretty readable.

Unfortunately, longobject.c is not one of the most readable bits :-(
It's not too bad, but it's no work of art.

Cheers,
mwh

-- 
   Jokes around here tend to get followed by implementations.
-- from Twisted.Quotes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help With Hiring Python Developers

2004-12-06 Thread Aahz
In article <[EMAIL PROTECTED]>,
Paul Rubin   wrote:
>[EMAIL PROTECTED] (Michael Fuhr) writes:
>>
>> Indeed.  An acquaintance of mine advocates writing code that only
>> skilled programmers can maintain (he favors a language that shall
>> remain nameless but that has been known to resemble modem noise or
>> cartoon swearing).
>
>TECO?  Some of the best programmers I know used it, but I hadn't heard
>of anything being done in it in quite a while.

APL.  I've heard programmers making similar comments (including possibly
Michael's nameless acquaintance).
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

WiFi is the SCSI of the 21st Century -- there are fundamental technical
reasons for sacrificing a goat.  (with no apologies to John Woods)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ptyon 2.3.5 probably coming in January; get your bugs/patches reported!

2004-12-06 Thread Aahz
In article <[EMAIL PROTECTED]>,
Roy Smith  <[EMAIL PROTECTED]> wrote:
>In article <[EMAIL PROTECTED]>,
> "Brett C." <[EMAIL PROTECTED]> wrote:
>>
>> Anthony Baxter, our ever-diligent release manager, mentioned this
>> past week that Python 2.3.5 will most likely come to fruition some
>> time in January (this is not guaranteed date).
>
>Interesting.  Does that mean that 2.3 and 2.4 will be maintained in
>parallel for a while?  That would be awesome.

Depends what you mean by "in parallel".  This is no different from what
occurred during the transition from 2.1 to 2.2 and 2.2 to 2.3; we're
just getting steadily more methodical about it.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

WiFi is the SCSI of the 21st Century -- there are fundamental technical
reasons for sacrificing a goat.  (with no apologies to John Woods)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [BUG] IMO, but no opinions? Uncle Tim? was: int(float(sys.maxint)) buglet ?

2004-12-06 Thread Tim Peters
[Bengt Richter]
> Peculiar boundary cases:
> 
> >>> 2.0**31-1.0
> 2147483647.0
> >>> int(2147483647.0)
> 2147483647L
> >>> int(2147483647L )
> 2147483647
> >>>
> >>> -2.0**31
> -2147483648.0
> >>> int(-2147483648.0)
> -2147483648L
> >>> int(-2147483648L )
> -2147483648
> 
> some kind of one-off error?

It would help if you were explicit about what you think "the error"
is.  I see a correct result in all cases there.

Is it just that sometimes

int(a_float)

returns a Python long when

int(a_long_with_the_same_value_as_that_float)

returns a Python int?  If so, that's not a bug -- there's no promise
anywhere, e.g., that Python will return an int whenever it's
physically possible to do so.

Python used to return a (short) int in all cases above, but that lead
to problems on some oddball systems.  See the comments for float_int()
in floatobject.c for more detail.  Slowing float_int() to avoid those
problems while returning a short int whenever physically possible is a
tradeoff I would oppose.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ptyon 2.3.5 probably coming in January; get your bugs/patches reported!

2004-12-06 Thread Tim Peters
[Brett C]
>> Anthony Baxter, our ever-diligent release manager, mentioned this past week
>> that Python 2.3.5 will most likely come to fruition some time in January
>> (this is not guaranteed date).

[Roy Smith]
> Interesting.  Does that mean that 2.3 and 2.4 will be maintained in
> parallel for a while?  That would be awesome.

They'll be maintained in parallel through 2.3.5 in January, which is
all Brett said.  If history is a guide, after 2.3.5 nobody will
volunteer to work on a 2.3.6, and 2.3.5 will be the last release in
the 2.3 line.  It's *possible* that volunteers for 2.3.6 will appear. 
That would be unprecedented, but not impossible ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help With Hiring Python Developers

2004-12-06 Thread Andrew Koenig
"Aahz" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> APL.  I've heard programmers making similar comments (including possibly
> Michael's nameless acquaintance).

Especially programmers who've never used it.

To me, grousing about APL's unusual character set sounds a lot like grousing 
about Python's unusual lexical structure.  Both language aspects seem weird 
at first, but the weirdness rapidly goes away with experience.


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


Re: long number multiplication

2004-12-06 Thread Christopher A. Craig
"I.V. Aprameya Rao" <[EMAIL PROTECTED]> writes:

> i have been wondering, how does python store its very long integers and 
> perform aritmetic on it.

In CPython, A long integer is a combination of a signed word
indicating the sign and the size and an unsigned array of N words
where N is the absolute value of the size which contain the value of
the integer in base 32768.

Most operations are done in their simplest fashion (see Knuth's
SemiNumerical Algorithms chapter 4.3) with the exception of multiply,
which uses Karatsuba math for inputs greater than 35 base 15 bit
digits.

> i needed to implement this myself and was thinking of storing the digits 
> of an integer in a list.

That's sort of what Python does except the "digits" are 15 bits,
not base 10.  Doing it in base 10 would be a huge pain because of the
problems with base 10->base 2 conversion.

-- 
Christopher A. Craig <[EMAIL PROTECTED]>
"When all else fails, read the instructions."

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


Re: Seeking Python + Subversion hosting.

2004-12-06 Thread Gregory (Grisha) Trubetskoy
On Sun, 5 Dec 2004, Tom Locke wrote:
Anyone know of a good hosting company that offers both server-side
Python and a subversion repository?
This is probably a good opportunity for me to plug OpenHosting.com. It's a 
virtual server, so you can compile/install/run just about anything. We do 
have Python, mod_python and subversion installed by default, so you don't 
even need to bother installing them.

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


Re: How is Python designed?

2004-12-06 Thread Diez B. Roggisch
Hi,

> 
> Not really. You think in this way, maybe because you
> know more about AST and less about that technique I
> mentioned. I thinked in the opposite
> way because I know different things better.
> Hehe.

So I guess you don't use classic parser techniques then?

> Sorry maybe I didn't understand that part correctly
> and took grant that it would be implemented in
> recursive way. I just wondered if the following can be
> extended for arbitrary length arithmetic expressions:
> Assignment("foo", BinaryOp("+", Get("a"),
> BinaryOp("*", Get("b"), Get("c"

I'm still not sure what you mean by "recursive" - to me, recursion is the
act of a function calling itself until some condition is met that markes
the end (or actually begin I think) of the recursion, like this:

def fac(n):
if n == 1:
return 1
return n * fac(n-1)

Thats recursion.

The AST on the other hand has as much nodes as the expression denotes - each
subexpression is its own node. But that's true for your approach too -
after all, it has to be that way, otherwise you'd miss some part of the
expression :)

If you mean by recursion that the top-node is called for evaluation which
then delegates the evaluation to its children - well, that's unavoidable -
but also in both cases. As I mentioned before, the only difference I see is
the order of evaluation  - but that is invariant, as long as for all
expression's their respective sub-expressions are evaluated beforehand.

> If I upseted you or anybody here by un-properly used
> words, please forgive me. I always feel my english
> must be improved :)

I'm not upset - I feared you were :) And I perceive your english at beeing
pretty good. 

English isn't my native tongue either, so sometimes it might be that my
answers are shorter (and thus more likely percieved unfriendly) because its
difficult to express one's opininon.

-- 
Regards,

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


Re: RPC with Python - Comparison?

2004-12-06 Thread has
Wolfgang Keller wrote:

> Candidates could be:
>
> - Pyro
> - Twisted.spread
> - OSE (XML-RPC)
> - ICE
> - ...others?

MacPython also supports Apple events (high-level bridge:
)

HTH

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


Re: byte code generated under linux ==> bad magic number underwindows

2004-12-06 Thread Fredrik Lundh
Aaron Bingham wrote:

> .pyc files are platform-independant but are incompatible between major Python 
> versions.

"are incompatible" should be "may be incompatible"

you can use imp.get_magic() to get a string that identifies the bytecode version
supported by the current interpreter; any interpreter with the same string can 
run
your bytecode.

 



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


Re: efficient intersection of lists with rounding

2004-12-06 Thread Gordon Williams


> Hi,
>
> I have to lists that I need to find the common numbers (2nd rounded to
> nearest integral) and I am wondering if there is a more efficient way of
> doing it.
>
> >>> a= [(123,1.3),(123,2.4),(123,7.8),(123,10.2)]
> >>> b= [(123, 0.9), (123, 1.9), (123, 8.0)]
> >>> [ (i,round(j)) for i,j in a for l,m in b if (i,round(j)) ==
> (l,round(m))]
> [(123, 1.0), (123, 2.0), (123, 8.0)]

Thanks for all your suggestions.  I've tried each one with lists of 1K, 10K
and 30K long and tabulated the results below.  Run with profile on W2K,
python 2.3.2, 1GHz Athlon.

1K, 10K and 30K long (seconds per call)
t1= 0.009, 0.148, 0.563
t2= 0.015, 0.217, 0.777
t3= 0.008, 0.108, 0.487
t4= 0.016, 0.190, 0.749
t5= 0.015, 0.224, 0.773

The non-set algorithims (t1,t3) came out the winners (maybe due to the
conversion of the set to a sorted list.  I didn't look into it any farther.)

Regards,

Gordon Williams




from sets import Set
import random


size = 1000

a = [(123,i+random.choice([-.2,-.1,.1,.2])) for i in range(size)]
b = [(123, 1+i+random.choice([-.2,-.1,.1,.2])) for i in range(size)]

def t1():
#Diez B. Roggisch <[EMAIL PROTECTED]>
ra =  [ (i,round(j)) for i,j in a]
rb =  [ (i,round(j)) for i,j in b]


res = []
pos_b = 0

try:
for i, pivot in ra:
while rb[pos_b][1] < pivot:
pos_b += 1
while rb[pos_b][1] == pivot:
res.append(rb[pos_b])
pos_b += 1
except IndexError:
# If b gets exhausted somewhere
pass
return res


def t2():
#Steven Bethard <[EMAIL PROTECTED]>
def roundedj(pairs_iterable):
return [(i, round(j)) for i, j in pairs_iterable]

l=list(Set(roundedj(a)).intersection(Set(roundedj(b
l.sort()
return l


def t3():
#Greg Ewing <[EMAIL PROTECTED]>
d = {}
for (l, m) in b:
   d[l, round(m)] = 1

result = []
for (i, j) in a:
   t = (i, round(j))
   if t in d:
 result.append(t)
return result


def t4():
#Adam DePrince <[EMAIL PROTECTED]>
set_a = Set( [(i,round(j)) for i,j in a] )
set_b = Set( [(i,round(j)) for i,j in b] )
l= list(set_a.intersection( set_b ))
l.sort()
return l

def t5():
#Raymond Hettinger <[EMAIL PROTECTED]>
l= list(Set([(x,round(y)) for x,y in a]) & Set([(x,round(y)) for x,y in
b]))
l.sort()
return l

def test():
r1= t1()
r2= t2()
r3= t3()
r4= t4()
r5= t5()


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


Re: The python2.4 IDLE can't be lanuched.

2004-12-06 Thread Brian Beck
AnkyHe wrote:
  I downloaded the python 2.4 final from the offical website and installed it on the WindowsXP+SP2 (Chinese version).
There was not any problem in this process, but the IDLE can't be lanuched without any warnning.  Is there anybody else 
encount this problem and how to resolve it?  Thanks!  

I have the exact same problem.  The IDLE window just never opens, and 
checking the process list shows that is was never even launched.  So I 
can't make much use of Python 2.4 since I use IDLE as my IDE...

--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list


Re: The python2.4 IDLE can't be lanuched.

2004-12-06 Thread Brian Beck
Brian Beck wrote:
I have the exact same problem.  The IDLE window just never opens, and 
checking the process list shows that is was never even launched.  So I 
can't make much use of Python 2.4 since I use IDLE as my IDE...
I forgot to note that I am also using Windows XP SP2 and this happens on 
two completely different machines of mine.

--
Brian Beck
Adventurer  of the First Order
--
http://mail.python.org/mailman/listinfo/python-list


Re: convert string to raw string?

2004-12-06 Thread Steven Bethard
Duncan Booth wrote:
If you are getting input from the user, then unless you are doing some 
processing on it to interpret escape sequences the chances are you already 
have what you need to use as a regular expression. If you *are* 
interpreting escape sequences then the answer is you need to not do that 
since the operation isn't really reversible.
If you are interpreting escape sequences, you probably want 
string.decode or string.encode:

>>> '\\n\\r'.decode('string_escape')
'\n\r'
>>> '\n\r'.encode('string_escape')
'\\n\\r'
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: The python2.4 IDLE can't be lanuched.

2004-12-06 Thread Abe Mathews
Don't know if this would help or not, but on my Linux 2.3 IDLE, I get
the following warning on startup:



Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


I'm not running SP 2 on any machines, so I can't test it for you, but
it may be that the personal firewall being activated on SP 2 is
blocking IDLE from starting up.  You might try turning that off and
seeing if that helps.  IIRC, part of SP 2 was port disabling.

I have to install SP 2 on a machine later today.  If I get the chance
I'll test it  and see if I can make the same failure occur.

Abe Mathews


On Mon, 06 Dec 2004 11:28:56 -0500, Brian Beck <[EMAIL PROTECTED]> wrote:
> Brian Beck wrote:
> > I have the exact same problem.  The IDLE window just never opens, and
> > checking the process list shows that is was never even launched.  So I
> > can't make much use of Python 2.4 since I use IDLE as my IDE...
> 
> I forgot to note that I am also using Windows XP SP2 and this happens on
> two completely different machines of mine.
> 
> 
> 
> --
> Brian Beck
> Adventurer  of the First Order
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Win32 Libs for 2.4

2004-12-06 Thread Daniel Dittmar
Robin Becker wrote:
actually I want to build the PIL extension for 2.4 as pyd and include 
various libraries eg zlib and jpeg. To avoid the missing dlls issue we 
have done this in the past by incorporating the zlib/jpeg code using 
static libraries for both zlib and jpeg.

It seems I can use the static lib built with MSC 6 with the extension 
code compiled with MSC 7.1. At least the extnsion build doesn't 
complain. Whether this is really allowed is another matter.
I guess that it won't work if something malloc'ed from the MSC 6 runtime 
is free'd by the MSC 7.1 runtime.

zlib is also part of the Python sources on Windows, so it shouldn't be a 
problem to build it for PIL.

I'm not sure what effort would be needed to build jpeg lib using MSC 
7.1. My guess would be that there is hardly any effort if an nmake file 
exists and a bit more work if you only have MS VC project file.

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


Re: help using sockets, and OOP?

2004-12-06 Thread Dfenestr8
On Sun, 05 Dec 2004 22:29:26 +, Jp Calderone wrote:

>> >   Your problem doesn't seem to have anything to do with "OOP"
>> >   (whatever that is).  Rather, you are trying to use two blocking
>> >   sockets at once.
>> > 
>> >   socket.connect() and socket.recv() are both "blocking" operations by
>> >   default - they can take an arbitrary amount of time to return.
>> >   Additionally, Botling.receiveData, one of your own functions, is
>> >   also blocking: it will actually loop forever, never returning (until
>> >   an exception blows it up).  So execution of your program never even
>> >   _gets_ to the "bert2 = ..." line.  It's stuck running
>> >   bert1.receiveData().
>> 
>> 
>> Ok, so what if I remove the while loop from the Botling class, and
>> include it in the __main__ ? Might this work as a solution then?
> 
>   No.

Ok, so are there other types of sockets that aren't "blocking" ?

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


Re: any good, free web hosts supporting python cgi scripts?

2004-12-06 Thread araspus
please come to my website www.arasp.net You may be qualified. for my
hosting plans.

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


Re: Win32 Libs for 2.4

2004-12-06 Thread Robin Becker
Daniel Dittmar wrote:
Robin Becker wrote:
actually I want to build the PIL extension for 2.4 as pyd and include 
various libraries eg zlib and jpeg. To avoid the missing dlls issue we 
have done this in the past by incorporating the zlib/jpeg code using 
static libraries for both zlib and jpeg.

It seems I can use the static lib built with MSC 6 with the extension 
code compiled with MSC 7.1. At least the extnsion build doesn't 
complain. Whether this is really allowed is another matter.

I guess that it won't work if something malloc'ed from the MSC 6 runtime 
is free'd by the MSC 7.1 runtime.
..
I thought that static .libs didn't make reference to the dll's they need; isn't 
that done at load time?

As for rebuilding that's easy; the hard part is having all the versions 
available at once. I prefer to keep common code in one place so would prefer to 
have only one static lib for these non version dependant things.


Daniel

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


Re: The python2.4 IDLE can't be lanuched.

2004-12-06 Thread Brian Beck
Abe Mathews wrote:
I'm not running SP 2 on any machines, so I can't test it for you, but
it may be that the personal firewall being activated on SP 2 is
blocking IDLE from starting up.  You might try turning that off and
seeing if that helps.  IIRC, part of SP 2 was port disabling.
I do remember seeing that message but thought "no way" since the Windows 
firewall is pretty forgiving in my experience.  But after a bit of 
tweaking and even disabling the firewall completely, the problem persists.

--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list


Re: The python2.4 IDLE can't be lanuched.

2004-12-06 Thread Jean Brouwers

This is a known problem.  More details at




/Jean Brouwers


In article <[EMAIL PROTECTED]>,
AnkyHe <[EMAIL PROTECTED]> wrote:

>   I downloaded the python 2.4 final from the offical website and installed it
> on the WindowsXP+SP2 (Chinese version).
> There was not any problem in this process, but the IDLE can't be lanuched
> without any warnning.  Is there anybody else 
> encount this problem and how to resolve it?  Thanks!  
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help using sockets, and OOP?

2004-12-06 Thread Grant Edwards
On 2004-12-06, Dfenestr8 <[EMAIL PROTECTED]> wrote:

>>> Ok, so what if I remove the while loop from the Botling class, and
>>> include it in the __main__ ? Might this work as a solution then?
>> 
>>   No.
>
> Ok, so are there other types of sockets that aren't "blocking" ?

Yes, non-blocking ones.

-- 
Grant Edwards   grante Yow!  My ELBOW is a remote
  at   FRENCH OUTPOST!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help using sockets, and OOP?

2004-12-06 Thread Diez B. Roggisch
> Ok, so are there other types of sockets that aren't "blocking" ?

You don' want other types of sockets (they are pretty good the way the are)
but other ways of using them. The topics you might need to delve into are
threading, the select module and twisted.  Which at least in part Jp
already suggested...

With threading you can have one thread blocked while others still run. With
select (which is made use of in twisted) you can wait for file-descriptors
(sockets _are_ filedescriptors) to actually have data, so that a call to
them won't block. That allows for scenarios such as yours.



-- 
Regards,

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


Re: Mean, median, and mode

2004-12-06 Thread Josiah Carlson

[EMAIL PROTECTED] (Sean McIlroy) wrote:
> 
> >>> median = lambda x: (max(x)-min(x))/2

That is /not/ the median in the general case.

median = lambda x: x.sort() or x[len(x)//2]

 - Josiah

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


RE: Mean, median, and mode

2004-12-06 Thread Robert Brewer
Josiah Carlson wrote:
> [EMAIL PROTECTED] (Sean McIlroy) wrote:
> > 
> > >>> median = lambda x: (max(x)-min(x))/2
> 
> That is /not/ the median in the general case.
> 
> median = lambda x: x.sort() or x[len(x)//2]

That...is a really sneaky use of null return values. I like. :)


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: using cmd.exe as a telnet client

2004-12-06 Thread Donnal Walter
Grant Edwards wrote:
You don't have to start from scratch. The telnet module has
hooks built-into it1 so that you can have it call your routines
to handle option negotiation.  I did it once to impliment some
extra Telnet protocol features, and it wasn't difficult.
Ok, you've inspired me to give it a try. First, I am assuming that you 
mean writing a custom callback function to send to 
Telnet.set_option_negotiation_callback(callback). Or did you mean 
writing a subclass of Telnet? Can someone provide an example of a 
callback function that I might use as a template for writing mine?

This is unfamiliar territory for me, but I tried to snoop a bit using 
ethereal (also new to me) and as near as I can tell, the options in 
question are:
0, binary transmission
1, echo
3, suppress go ahead
23, send location

And it may be that not all of these are critical, but if so, I don't 
know how to tell which is which.

Eyal Lotem wrote:
I think I have a much simpler solution for you guys..
Assuming you can run arbitrary code on the proprietary
server.
Actually I cannot. The server runs a second-party information system, 
the primary access to which is third-party terminal emulator software 
that uses telnet connections. What I am trying to do is emulate this 
emulator. :-)

  cmd.exe is not a command line program.  It's a terminal (emulator).  
You might be able to use the telnet program, though.
Yes, I see that now. Thanks.
 Before doing this, 
I'd recommend looking at Twisted's telnet support (both
the version in 1.3 and the version that will be in 2.0),
which actually supports option negotiation in a
reasonable way.
I've been wanting to get acquainted with Twisted for awhile now, so this 
might be a good time to do so. I think I will give Grant's idea a whirl, 
but if I get bogged down there, I will definitely look at Twisted's 
telnet support. BTW, do you know if Twisted's option negotiation uses a 
callback function? I might download it just to take a look, even if I 
don't use it directly.

Thanks,
Donnal Walter
Arkansas Children's Hospital
--
http://mail.python.org/mailman/listinfo/python-list


Re: Deadlock detection

2004-12-06 Thread Josiah Carlson

Duncan Grisby <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
> Does anyone know of a deadlock detector for Python?  I don't think it
> would be too hard to hook into the threading module and instrument
> mutexes so they can be tested for deadlocks. I've googled around but I
> haven't found anything.

I'm not aware of a deadlock dector for any language.  I propose that a
completely working deadlock detector is NP-Complete, as it would, I
believe, necessitate solving the halting problem.


 - Josiah

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


Re: help using sockets, and OOP?

2004-12-06 Thread Andy Gross
On Dec 6, 2004, at 12:04 PM, Dfenestr8 wrote:
Ok, so are there other types of sockets that aren't "blocking" ?
Yes, sockets can be either blocking or non-blocking.  An I/O operation 
on a 'blocking' socket will not return until the operation is complete. 
 If you try to read more bytes than are currently available, the call 
will block, possibly forever.  Operations on non-blocking sockets 
return "immediately", but are not guaranteed to have completed.  For 
example, a write() of 1024 bytes may only succeed in writing 10 bytes.  
It's up to your application to keep track of this state.  Google around 
for socket programming tutorials for complete information.

WRT Python, you'll quickly find that asynchronous programming becomes 
tedious without a framework.  As JP suggested, check out 
http://www.twistedmatrix.com.  Twisted does a good job of abstracting 
away a lot of the low-level details and allows you to focus on 
implementing the functionality of your program.

Good luck,
/arg
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL and antialiasing problem

2004-12-06 Thread Fredrik Lundh
Laszlo Zsolt Nagy wrote:

> Statement: Sometimes PIL is better than Adobe Photoshop. :-)
>
> I also found these with the aid of the wonderful dir() function:
>
> MinFilter, MaxFilter, MedianFilter, ModeFilter, RankFilter, BuiltInFilter
>
> They do not have a docstring and they are not documented in the
> handbook. I'm curious what they do exactly. The others (like BLUR, EMBOSS,
> CONTOUR etc.) are documented very well. I wonder why is that.

they were experimental (and some of them were slightly broken, iirc)
in 1.1.4.  they're all officially supported in 1.1.5:

http://www.pythonware.com/library/pil/handbook/imagefilter.htm






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


Re: using cmd.exe as a telnet client

2004-12-06 Thread Donnal Walter
Grant Edwards wrote:
> You don't have to start from scratch. The telnet module has
> hooks built-into it1 so that you can have it call your routines
> to handle option negotiation.  I did it once to impliment some
> extra Telnet protocol features, and it wasn't difficult.
Ok, you've inspired me to give it a try. First, I am assuming that you 
mean writing a custom callback function to send to 
Telnet.set_option_negotiation_callback(callback). Or did you mean 
writing a subclass of Telnet? Can someone provide an example of a 
callback function that I might use as a template for writing mine?

This is unfamiliar territory for me, but as near as I can tell, the 
options in question are:
0, binary transmission
1, echo
3, suppress go ahead
23, send location

And it may be that not all of these are critical, but if so, I don't 
know how to tell which is which.

Eyal Lotem wrote:
> I think I have a much simpler solution for you guys..
> Assuming you can run arbitrary code on the proprietary
> server.
Actually I cannot. The server runs a second-party information system, 
the primary access to which is third-party terminal emulator software 
that uses telnet connections. What I am trying to do is emulate this 
emulator. :-)

Jp Calderone wrote:
>   cmd.exe is not a command line program.  It's a terminal (emulator).
> You might be able to use the telnet program, though.
Yes, I see that now. Thanks.
>  Before doing this,
> I'd recommend looking at Twisted's telnet support (both
> the version in 1.3 and the version that will be in 2.0),
> which actually supports option negotiation in a
> reasonable way.
I've been wanting to get acquainted with Twisted for awhile now, so this 
might be a good time to do so. I think I will give Grant's idea a whirl, 
but if I get bogged down there, I will definitely look at Twisted's 
telnet support. BTW, do you know if Twisted's option negotiation uses a 
callback function? I might download it just to take a look, even if I 
don't use it directly.

Thanks,
Donnal Walter
Arkansas Children's Hospital
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mean, median, and mode

2004-12-06 Thread Paul McGuire
This median expression is incorrect.  median is *not* the midpoint between
max and min values.  It is the middle value when all values are sorted (for
an odd number of values), or the average of the two middle values when all
values are sorted (for an even number of values).

In Python 2.4 (needed to use sorted() built-in), this can be one-lined as:
median = lambda x: ((x % 2) and (sorted(x)[len(x)>>1]) or
(sum(sorted(x)[(len(x)>>1):(len(x)>>1)+1])/2))

(not yet tested, as I've not installed v2.4 yet)
With boolean short-circuiting, this should only sort the list once.

-- Paul


"Sean McIlroy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> >>> mean = lambda x: sum(x)/len(x)
> >>> median = lambda x: (max(x)-min(x))/2
> >>> mode = lambda x: max([(x.count(y),y) for y in x])[1]
>
> "Robert Brewer" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
> > (now that we have a meaningful subject line)
> >
> > Alfred Canoy wrote:
> > > >>  I'm just new to programming and would like to ask for help..
> > > >>
> > > >> Build a module that contains three functions that do the following:
> > > >>
> > > >>   a.. Compute the average of a list of numbers
> > > >>   b.. Finds the statistical median value of a list of numbers
> > > >>   c.. Finds the mode of a list of numbers
> > > >>
> > > >> Can you please give me clue how I should start solving the
> > > >> following problem
> > > >> below? Here's the source code that I did so far:
> > > >>
> > > >> # compute the average of a list of numbers:
> > > >> # Keeps asking for numbers until 0 is entered
> > > >> # Prints the average value
> > > >>
> > > >> count = 0
> > > >> sum = 0
> > > >> number = 1
> > > >>
> > > >> print 'Enter 0 to exit the loop'
> > > >> while number != 0:
> > > >> number = input ('Enter a number: ')
> > > >> count = count + 1
> > > >> sum = sum + number
> > > >> count = count -1
> > > >> print ' The average is:', sum/count
> >
> > For the mode, you might build a dictionary:
> >
> > freq = {}
> > while number != 0:
> > number = input ('Enter a number: ')
> > count = count + 1
> > sum = sum + number
> > try:
> > freq[number] += 1
> > except KeyError:
> > freq[number] = 1
> >
> > ...then you can check for the largest value in that dictionary:
> >
> > max = 0
> > mode = None
> > for k, v in freq.iteritems():
> > if v > max:
> > max = v
> > mode = k
> >
> > I leave the rest in your capable hands... ;) Including the case where
> > two numbers occur in equal frequencies. ;;)
> >
> >
> > Robert Brewer
> > MIS
> > Amor Ministries
> > [EMAIL PROTECTED]


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


Re: asynchat and threading

2004-12-06 Thread Fredrik Lundh
Anthony Baxter wrote:

> > AFAICT, the main complaint is that it is tied to the TCP transport,
> > the sockets API, and the select/poll API. IOW, it cannot easily:
> > - integrate TLS on top of TCP (because TLS might involve no-data
> >communications, e.g. when TLS negotation happens in the middle
> >of a TLS session),
> > - integrate other transports, such as serial ports on Windows,
> > - integrate other multi-endpoint wait APIs, such as IO completion
> >ports on Windows NT+, or kqueue on BSD.
>
> - work with other event loops, such as GUI toolkits

sure can.

but sure, if you don't want it to work, nothing stops you from writing
crappy code.  we've been using asyncore/medusa on high-performance
servers for nearly 10 years; I think we'd noticed by now if the library
was seriously broken.

 



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


Re: xmlrpclib or twisted?

2004-12-06 Thread Andy Gross
If you're not concerned about interoperability with other languages and 
are already using Twisted, I'd go with PB.  Especially if you are using 
complicated datatypes that have to be serialized and sent over the wire 
- PB has a nice Cacheable type that doesn't serialize the whole object. 
 XMLRPC on the other hand is a little simpler and will work with 
third-party stuff.

/arg
On Dec 6, 2004, at 5:11 AM, flupke wrote:
Hi,
previously i made an application that used sockets to
do some network based processing.
My next app is again going to be a client/server app
and i wanted to see if i can't find an easier way to
make the networking going.
I bumped into xmlrpclib and also twisted (pb).
I'm not sure which on of these would suit my needs better.
I am planning to build a web GUI for the client so if i
use twisted, i would already have the components in there
to do so, so this could be a plus for twisted.
The client will connect to the server to receive data.
The data is the result of one of several queries and these raw
results would then be displayed in the client via a webgui or
wxPython. (leaning towards webgui)
Any other ideas?
Thanks
Benedict
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mean, median, and mode

2004-12-06 Thread Josiah Carlson

"Robert Brewer" <[EMAIL PROTECTED]> wrote:
> 
> Josiah Carlson wrote:
> > [EMAIL PROTECTED] (Sean McIlroy) wrote:
> > > 
> > > >>> median = lambda x: (max(x)-min(x))/2
> > 
> > That is /not/ the median in the general case.
> > 
> > median = lambda x: x.sort() or x[len(x)//2]
> 
> That...is a really sneaky use of null return values. I like. :)

Thank you, I'm just using a paradigm (exploiting lambdas) that I picked
up while going through various functional programming modules.

If you're really good, you can do crazy stuff with list comprehensions.
I'll leave that exercise up to the reader, as many of my examples are
in for-pay code.


 - Josiah

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


Re: using cmd.exe as a telnet client

2004-12-06 Thread Donnal Walter
Grant Edwards wrote:
> You don't have to start from scratch. The telnet module has
> hooks built-into it1 so that you can have it call your routines
> to handle option negotiation.  I did it once to impliment some
> extra Telnet protocol features, and it wasn't difficult.
Ok, you've inspired me to give it a try. First, I am assuming that you 
mean writing a custom callback function to send to 
Telnet.set_option_negotiation_callback(callback). Or did you mean 
writing a subclass of Telnet? Can someone provide an example of a 
callback function that I might use as a template for writing mine?

This is unfamiliar territory for me, but as I can tell, the options in 
question are:
0, binary transmission
1, echo
3, suppress go ahead
23, send location

And it may be that not all of these are critical, but if so, I don't 
know how to tell which is which.

Eyal Lotem wrote:
> I think I have a much simpler solution for you guys..
> Assuming you can run arbitrary code on the proprietary
> server.
Actually I cannot. The server runs a second-party information system, 
the primary access to which is third-party terminal emulator software 
that uses telnet connections. What I am trying to do is emulate this 
emulator. :-)

Jp Calderone wrote:
>   cmd.exe is not a command line program.  It's a terminal (emulator).
> You might be able to use the telnet program, though.
Yes, I see that now. Thanks.
>  Before doing this,
> I'd recommend looking at Twisted's telnet support (both
> the version in 1.3 and the version that will be in 2.0),
> which actually supports option negotiation in a
> reasonable way.
I've been wanting to get acquainted with Twisted for awhile now, so this 
might be a good time to do so. I think I will give Grant's idea a whirl, 
but if I get bogged down there, I will definitely look at Twisted's 
telnet support. BTW, do you know if Twisted's option negotiation uses a 
callback function? I might download it just to take a look, even if I 
don't use it directly.

Thanks,
Donnal Walter
Arkansas Children's Hospital
--
http://mail.python.org/mailman/listinfo/python-list


Re: using cmd.exe as a telnet client

2004-12-06 Thread Grant Edwards
On 2004-12-06, Donnal Walter <[EMAIL PROTECTED]> wrote:
> Grant Edwards wrote:
> > You don't have to start from scratch. The telnet module has
> > hooks built-into it1 so that you can have it call your routines
> > to handle option negotiation.  I did it once to impliment some
> > extra Telnet protocol features, and it wasn't difficult.
>
> Ok, you've inspired me to give it a try. First, I am assuming
> that you mean writing a custom callback function to send to 
> Telnet.set_option_negotiation_callback(callback).

Yes.

> Or did you mean writing a subclass of Telnet?

That depends.  If you need to _impliment_ a feature in addition
to doing the negotiation, then you may want to define a
subclass -- though it may easier to just grab the source for
telnetlib and add the feature.

> Can someone provide an example of a callback function that I
> might use as a template for writing mine?

I've got a negotiation function at home I'll try to remember to
post.

> This is unfamiliar territory for me, but as near as I can tell, the 
> options in question are:
> 0, binary transmission
> 1, echo
> 3, suppress go ahead
> 23, send location
>
> And it may be that not all of these are critical, but if so, I
> don't know how to tell which is which.

That's the tricky part. :)

I guess I'd "enable" negotiation of each of the features one at
a time, and see what happens.

-- 
Grant Edwards   grante Yow!  Hey, I LIKE that
  at   POINT!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive list comprehension

2004-12-06 Thread Peter Hansen
Timothy Babytch wrote:
Serhiy Storchaka wrote:
 >>>sum([['N', 'F'], ['E'], ['D']], [])
['N', 'F', 'E', 'D']
THE BEST!
Hmmm.  Maybe, unless readability as in "self-documenting code"
is important to you...
Preceding the above with "flatten = sum" would perhaps be
an adequate improvement.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: RPC with Python - Comparison?

2004-12-06 Thread Wolfgang Keller
>> Candidates could be:
>>
>> - Pyro

I forgot to mention Corba here:

- Omniorb
- Orbit
- Fnorb

BTW: It seems to me that none of these provides an AMI implementation...?

>> - Twisted.spread
>> - OSE (XML-RPC)
>> - ICE
>> - ...others?

> MacPython also supports Apple events (high-level bridge:
> )

I know, but I was thinking of OS-independent RPC protocols. :-)

Best regards,

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


ANN: eGenix mx Base Package 2.0.6 (mxDateTime, mxTextTools, etc.)

2004-12-06 Thread M.-A. Lemburg

ANNOUNCING
eGenix.com mx Base Extension Package
Version 2.0.6
  Open Source Python extensions providing important and useful
  services for Python programmers.

ABOUT
The eGenix.com mx Base Extensions for Python are a collection of
professional quality software tools which enhance Python's usability
in many important areas such as fast text searching, date/time
processing and high speed data types.
The tools have a proven record of being portable across many Unix and
Windows platforms. You can write applications which use the tools on
Windows and then run them on Unix platforms without change due to the
consistent platform independent interfaces.
All available packages have proven their stability and usefulness in
many mission critical applications and various commercial settings all
around the world.
* About Python:
Python is an object-oriented Open Source programming language which
runs on all modern platforms (http://www.python.org/). By integrating
ease-of-use, clarity in coding, enterprise application connectivity
and rapid application design, Python establishes an ideal programming
platform for todays IT challenges.
* About eGenix:
eGenix is a consulting and software product company focused on
providing professional quality services and products to Python
users and developers (http://www.egenix.com/).

NEWS
The new version includes patches needed to compile the package
for Python 2.4. It now supports all Python versions 1.5.2 - 2.4.
As always we are providing pre-compiled versions of the package for
Windows and Linux as well as sources which allow you to install the
package on all other supported platforms.

EGENIX MX BASE PACKAGE OVERVIEW
mxDateTime - Generic Date/Time Types
 mxDateTime is an extension package that provides three new object
 types, DateTime, DateTimeDelta and RelativeDateTime, which let
 you store and handle date/time values in a very convenient way.
 You can add, subtract and even multiply instances, pickle and
 copy them and convert the results to strings, COM dates, ticks
 and some other more esoteric values. In addition, there are
 several convenient constructors and formatters at hand to greatly
 simplify dealing with dates and times in real-world applications.
 In addition to providing an easy-to-use Python interface the
 package also exports a comfortable C API interface for other
 extensions to build upon. This is especially interesting for
 database applications which often have to deal with date/time
 values (the mxODBC package is one example of an extension using
 this interface).
mxTextTools - Fast Text Processing Tools
 mxTextTools is an extension package for Python that provides
 several useful functions and types that implement
 high-performance text manipulation and searching algorithms in
 addition to a very flexible and extendable state machine, the
 Tagging Engine, that allows scanning and processing text based on
 low-level byte-code "programs" written using Python tuples. It
 gives you access to the speed of C without the need to do any
 compile and link steps every time you change the parsing
 description.
 Applications include parsing structured text, finding and
 extracting text (either exact or using translation tables) and
 recombining strings to form new text.
mxStack - Fast and Memory-Efficient Stack Type
 mxStack is an extension package that provides a new object type
 called Stack. It works much like what you would expect from such
 a type, having .push() and .pop() methods and focuses on
 obtaining maximum speed at low memory costs.
mxTools - Collection of Additional Built-Ins
 mxTools is an extension package that includes a collection of
 handy functions and objects giving additional functionality in
 form of new built-ins to the Python programmer.
 The package auto-installs the new functions and objects as
 built-ins upon first import. This means that they become
 instantly available to all other modules without any further
 action on your part. Add the line import NewBuiltins to your
 site.py script and they will be available to all users at your
 site as if they were installed in the Python interpreter itself.
mxProxy - Generic Proxy Wrapper Type
 mxProxy is an extension package that provides a new type that is
 suitable to implement Bastion like features without the need to
 use restricted execution environments.
 The type's main features are secure data encapsulation (the
 hidden objects are not accessible from Python since the

ANN: eGenix mxODBC Python Database Interface Version 2.0.7

2004-12-06 Thread M.-A. Lemburg

ANNOUNCING
   eGenix.com mxODBC Database Interface
  Version 2.0.7
 Full Source Python extension providing ODBC database connectivity
 to Python applications on Windows and Unix platforms

ABOUT
The mxODBC Database Interface allows users to easily connect
Python applications to just about any database on the market
today - on both Windows and Unix platforms in a highly portable
and convenient way.  This makes mxODBC the ideal basis for writing
cross-platform database programs and utilities in Python.
mxODBC is included in the eGenix.com mx Commercial Extension Package
for Python, the commercial part of the eGenix.com mx Extension Series,
a collection of professional quality software tools which enhance
Python's usability in many important areas such as ODBC database
connectivity, fast text processing, date/time processing and
web site programming.
The package has proven its stability and usefulness in many mission
critical applications and various commercial settings all around
the world.
* About Python:
Python is an object-oriented Open Source programming language which
runs on all modern platforms (http://www.python.org/). By integrating
ease-of-use, clarity in coding, enterprise application connectivity
and rapid application design, Python establishes an ideal programming
platform for todays IT challenges.
* About eGenix:
eGenix is a consulting and software product company focused on
providing professional quality services and products to Python
users and developers (http://www.egenix.com/).

NEWS
The new version includes patches needed to compile the package
for Python 2.4. It now supports all Python versions 1.5.2 - 2.4.
As always we are providing pre-compiled versions of the package for
Windows and Linux as well as sources which allow you to install the
package on all other supported platforms.

EGENIX MX COMMERCIAL PACKAGE OVERVIEW
mxODBC - High-Performance ODBC 3.5 Interface for Python
 mxODBC is an extension package that provides a Python Database
 API compliant interface to ODBC capable database drivers and
 managers.
 In addition to the capabilities provided through the standard DB
 API it also gives access to a rich set of catalog methods which
 allow you to scan the database for tables, procedures,
 etc. Furthermore, it uses the mxDateTime package for date/time
 value interfacing eliminating most of the problems these types
 normally introduce (other in/output formats are available too).
 mxODBC allows you to interface to more than one database from one
 process, making inter-database interfacing very flexible and
 reliable.
 The source version includes a variety of pre-configured setups for
 many commonly used databases such as MySQL, Oracle, Informix,
 Solid, SAP DB, Sybase ASA and ASE, DBMaker and many more. The
 pre-compiled versions for Windows and Linux include the interfaces
 to the standard ODBC manager on these platforms to allow for a
 more easily configurable setup.
 More details are available at:
  http://www.egenix.com/files/python/mxODBC.html

DOWNLOADS
The download archives and instructions for installing the package can
be found at:
http://www.egenix.com/files/python/eGenix-mx-Extensions.html#Packages
IMPORTANT:
In order to use the eGenix mx Commercial package you will first
need to install the eGenix mx Base package which can be downloaded
from the same location.

LICENSES & COSTS
mxODBC is distributed under the terms and conditions of the
eGenix.com Commercial License. mxODBC is free for use in non-commercial
environments.
Commercial users may evaluate the product for 30 days following the
initial installation. For continued use, commercial users can purchase
installation licenses for mxODBC through our secure online shop.
We also provide special licensing setups for commercial product
developers that want to integrate mxODBC into their products.
For full details, please see
http://www.egenix.com/files/python/eGenix-mx-Extensions.html#BuyLicenses
or write to [EMAIL PROTECTED]
The package comes with full source code

SUPPORT
Commercial quality support for these packages is available from
eGenix.com. Please see
http://www.egenix.com/files/python/eGenix-mx-Extensions.html#Support
for details about our support offerings.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source  (#1, Dec 06 2004)
Python/Zope Consulting and Support ...

ANN: eGenix mx Experimental Package 0.9.0 (mxNumber, mxTidy, mxURL, etc.)

2004-12-06 Thread M.-A. Lemburg

ANNOUNCING
 eGenix.com mx Experimental Extension Package
Version 0.9.0
 Experimental Python extensions providing important and useful
services for Python programmers.

ABOUT
The eGenix.com mx Experimental Extensions for Python are a collection
of beta quality software tools for Python which will be integrated
into the other mx Extension Packages after they have matured to
professional quality tools.
* About Python:
Python is an object-oriented Open Source programming language which
runs on all modern platforms (http://www.python.org/). By integrating
ease-of-use, clarity in coding, enterprise application connectivity
and rapid application design, Python establishes an ideal programming
platform for todays IT challenges.
* About eGenix:
eGenix is a consulting and software product company focused on
providing professional quality services and products to Python
users and developers (http://www.egenix.com/).

NEWS
The new version includes patches needed to compile the package
for Python 2.4. It now supports all Python versions 1.5.2 - 2.4.
As always we are providing pre-compiled versions of the package for
Windows and Linux as well as sources which allow you to install the
package on all other supported platforms.

EGENIX MX EXPERIMENTAL PACKAGE OVERVIEW
mxNumber - Python Interface to GNU MP Number Types
 mxNumber provides direct access to the high performance numeric
 types available in the GNU Multi-Precision Lib (GMP).  This
 library is licensed under the LGPL and runs on practically all
 Unix platforms. eGenix.com has ported the GMP lib to Windows, to
 also provide our Windows users with the added benefit of being
 able to do arbitrary precision calculations and to easily port
 applications based on mxNumber from Unix to Windows or vice-versa.
 The package currently provide theses numerical types:
 1. Integer(value)  -- arbitrary precision integers much like
   Python longs only faster
 2. Rational(nom,denom) -- rational numbers with Integers as
   numerator and denominator
 3. Float(value[,prec]) -- floating point number with at least
   prec bits precision
 4. FareyRational(value, maxden)
-- calculate the best rational
   representation n/d of value
   such that d < maxden
mxTidy - Interface to HTML Tidy (HTML/XML cleanup tool)
 mxTidy provides a Python interface to a thread-safe, library
 version of the HTML Tidy. command line tool.
 HTML Tidy helps you to cleanup coding errors in HTML and XML
 files and produce well-formed HTML, XHTML or XML as output. This
 allows you to pre-process web-page for inclusion in XML
 repositories, prepare broken XML files for validation and also
 makes it possible to write converters from well-known word
 processing applications such as MS Word to other structured data
 representations by using XML as intermediate format.
mxURL - A fast URL Data-Type
 mxURL provides a new data-type for storing and manipulating URL
 values as well as a few helpers related to URL building, encoding
 and decoding.
 The main intention of the package is to provide an easy to use,
 fast and lightweight data-type for Universal Resource Locators
 (note the W3C now calls these URIs).
mxUID - A fast UID Data-Type
 mxUID provides a fast mechanism for generating universal
 identification strings (UIDs). The intent is to make these UIDs
 unique with high probability in order to serve as object or data
 set identifiers.
 A typical use lies in generating session IDs. Other areas where
 unique IDs play an important role are RPC-implementations,
 ORBs, etc.

DOWNLOADS
The download archives and instructions for installing the packages can
be found at:
 http://www.egenix.com/
Note that in order to use the eGenix mx Experimental package you
will first need to install the eGenix mx Base package which can
be downloaded from the same location.

LICENSES & COSTS
The mx-Experimental packages uses different licenses in its sub-packages.
Please refer to the sub-package documentation for details. Some of them
may be integrated into the eGenix mx Base package, others will be
integrated into the eGenix mx Commercial package.
The package comes with full source code

Re: using cmd.exe as a telnet client

2004-12-06 Thread Donnal Walter
I wrote:
I've been wanting to get acquainted with Twisted for awhile
now, ... BTW, do you know if Twisted's option negotiation
uses a callback function? I might download it to take a look, ...
Sorry I did not do this earlier, before I posted. It is obvious (now 
that I have downloaded it) that Twisted's Telnet implementation is based 
on its own Protocol base class (nice design). The only documentation I 
have been able to find, however, is in the protocols/telnet module 
itself. It is still not immediately obvious (to me) how to use the iac* 
methods to negotiate these options. Any help is much appreciated.

(I've not given up on writing my own funtion for Python's telnetlib, but 
I'm trying to keep all my options open. Besides, I will probably have 
other uses for Twisted later.)

Donnal Walter
Arkansas Children's Hospital


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


  1   2   >