calculate with date

2005-02-14 Thread Detlef Jockheck
Hi,
I have a date-string given in format "dd.mm.". Now I would like to add  
100 days. How can this be solved in python?

ciao
Detlef
--
are you ready - attention - go
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression question

2005-02-14 Thread Fredrik Lundh
Bruno Desthuilliers wrote:

>> match = STX + '(.*)' + ETX
>>
>> # Example 1
>> # This appears to work, but I'm not sure if the '+' is being used in
>> the regular expression, or if it's just joining STX, '(.*)', and ETX.
>>
>> if re.search(STX + '(.*)' + ETX,data):
>>   print "Matches"
>>
>> # Example 2
>> # This also appears to work
>> if re.search(match,data):
>>   print "Matches"

> You may want something like:
> if re.search('%s(.*)%s' % (STX, ETX), data):
>   ...

that's of course the same thing as examples 1 and 2.

a tip to the original poster: if you're not sure what an expression does,
try printing the result.  use "print repr(v)" if the value may contain odd
characters.  try adding this to your test script:

print repr(match)
print repr(STX + '(.*)' + ETX)
print repr('%s(.*)%s' % (STX, ETX))

 



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


Re: gui scripting

2005-02-14 Thread Follower
> >Second phase will have this done on a Windows platform... but that is
> >second priority ...




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


Re: gui scripting

2005-02-14 Thread Tonino
hmm - there is a problem - Android uses Xtest extensions - this is BAD
;)

I Need to be able to get values from the form that is returned ... and
the Xtest stuff does not allow you to access the values of a returned
form in the GUI ...

example :

if the GUI has a form that is returned and in this form it has columns
on the left expressing names for values on the right - you cannot get
the text for the columns on the left or the associated values ...

Thanks

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


[perl-python] problem: reducing comparison

2005-02-14 Thread Xah Lee
here's a interesting real-world algoritm to have fun with.

attached below is the Perl documentation that i wrote for a function
called "reduce", which is really the heart of a larger software.

The implementation is really simple, but the key is to understand what
the function should be. I'll post Perl and Python codes tomorrow for
those interested. If you are a perl programer, try to code it in
Python. (it's easy.)

This is brought to you by the Perl-Python a-day community. To
subscribe, see
http://xahlee.org/perl-python/python.html

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

---

=pod

e.g. reduce( $pairings, $a_pair) retured the first argument with some
pairs deleted.

Detail:

we have n things, represented by numbers 1 to n. Some of these are
identical. We want to partition the range of numbers 1 to n so that
identical ones are grouped together.

To begin comparison, we generate a list of pairings that's all
possible parings of numbers 1 to n. (of course order does not matter,
and the pairing does not contain repeations) This is the first
argument to reduce.

We'll go thru this pairings list one by one and do comparisons, remove
the pair once it has been compared. However, more pairs can be removed
if a we find a pair identical.

For example, suppose we know that 2 and 4 are identical, and if the
pairing list contains (2,3) and (4,3), one of them can be deleted
because now 2 and 4 are the same thing.

(We do this because we expect the comparison operation will be
expensive.)

reduce( $pairings, $a_pair) returns a reduced $pairings knowing that
$a_pair are identical.

The first argument $pairings must be in the form of a hash. e.g.

 {'1,5' => [1,5],'3,5' => [3,5],'2,4' => [2,4],'4,5' => [4,5],'1,3' =>
 [1,3],'2,5' => [2,5],'1,2' => [1,2],'3,4' => [3,4],'2,3' =>
 [2,3],'1,4' => [1,4]}

(Note that keys are strings of the pairs separated by a comma.)

$a_pair is a reference to a list of the form [$a,$b].

(different pairs may be deleted if the hash's pairs are given in
different order. i.e. 3,4 instead of 4,3)

The return value is a reference to a hash.

The program is deterministic but exactly which pairs are deleted is
unspecified. If the input is all possible pairs of 2 things out of n,
maximum reduction is guaranteed. 

=cut

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


Re: image fourier transform

2005-02-14 Thread Tim Roberts
Johannes Ahl-mann <[EMAIL PROTECTED]> wrote:
>
>i've been looking all around the net (google is my friend ;-) for a
>module to apply fourier transformations on images. the different ones in
>numerical python and scientific python seem all to be operating on
>sequences and therefore seem to be 1D fourier transform.
>
>anyone know a library/module to do 2D image FFT in a simple manner.
>
>or am i just too dumb to see how this is supposed to work with the 1D
>fourier transforms??

To do a 2D FFT on a matrix X, you do 1D FFTs on all the rows, producing X',
then you do 1D FFTs on all the columns of X'.

So, for a 32x32 2D FFT, you'll end up doing 64 1D FFTs.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Feb 15)

2005-02-14 Thread Cameron Laird
QOTW:  "I've forgotten what we are arguing about, but I'm sure I'm
right." -- Jive Dadson

"I believe the best strategy against Identity theft is bad
credit." -- Tom Willis

"You can't live without unit tests.  And once you have unit tests, the
added value of declarations is tiny, and their cost remains." -- martellibot


Make history, instead of having it happen to you:  the 
upcoming PyPy Sprint promises to be singular:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/6f0458c61169eff1/

Brian van den Broek, Roy Smith, BJ=F6rn_Lindqvist, Jason
Diamond, and Grig Gheorghiu introduce the crucial subject
of unit-testing in Python for those new to test-driven
development:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/bbda0385fa4e1de7/
http://www.onlamp.com/pub/a/python/2004/12/02/tdd_pyunit.html

How do you know that Python has "arrived"?  When its use is
the least interesting part of a project.  Notice that, once
again, Python is handy in "process control", traditionally
a domain for assembler, C, and Basic:
http://www.linuxjournal.com/article/7403

Philip dives deeply into Python optimization issues:
http://dirtsimple.org/2005/02/optimization-surprises.html
http://dirtsimple.org/2005/02/from-nine-to-five.html

Not only does Martin Franklin provide a new TableList widget
for Tkinter, but he clearly describes how he did so, apparently
in the belief that such knowledge might be useful to others:

http://mail.python.org/pipermail/tkinter-discuss/2005-February/000320.html
Stewart Midwinter answers with a "poor-man's table widget":

http://mail.python.org/pipermail/tkinter-discuss/2005-February/000325.html

Philip Schoenborn explores RAII and related Python deli-
cacies related to resource management--in print!
http://ddj.com/articles/2005/0503/



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

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

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

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

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

Brett Cannon continues the marvelous tradition established by 
Andrew Kuchling and Michael Hudson of intelligently summarizing
action on the python-dev mailing list once every other week.
http://www.python.org/dev/summary/

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

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

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

The Python Business Forum "further[s] the interests of companies
that base their business on ... Python."
http://www.python-in-business.org

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

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

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http:/

Re: os.rename() doesn't work w/unicode??

2005-02-14 Thread Serge Orlov
fanbanlo wrote:
> C:\MP3\001.txt -> 0.txt
> C:\MP3\01. ??? - (???).mp3 -> 1.mp3
>
> Traceback (most recent call last):
>   File
> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
> exec codeObject in __main__.__dict__
>   File "C:\MP3\!RenameNum.py", line 40, in ?
> renameFiles(os.path.dirname(sys.argv[0]))
>   File "C:\MP3\!RenameNum.py", line 26, in renameFiles
> os.rename(os.path.join(path, filenames), new_filename)
> OSError: [Errno 22] Invalid argument

os.rename works with unicode, you're getting this error because
question marks are not allowed in file names on Windows.

  Serge.


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


Re: wxPython OGL future

2005-02-14 Thread D H
PD wrote:
I don't think I want that much out of it necessarily. I just feel
really weird writing new software with deprecated libraries. By the
time Im done with my project, I have to put all these disclaimers on
how the new versions of wxWidgets might not work. The thing I am really
concerened about is if wxPython decides to drop OGL because it is
deprecated... anyhow thats my 2 cents.
Actually, I think the information on the wxpython wiki is now out of 
date.  OGL was implemented in C and wxpython provided a wrapper.  That 
version is now dead.  But they rewrote OGL in pure python.  So it isn't 
obsolete yet I believe.  Since it is written in python you can easily 
extend it or whatever.

Instead of saying "import wx.ogl as ogl", say
"import wx.lib.ogl as ogl".
--
http://mail.python.org/mailman/listinfo/python-list


Re: gui scripting

2005-02-14 Thread Tonino
thanks - this helps ;))

will play with android ...

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


Re: Commerical graphing packages?

2005-02-14 Thread Robert Kern
John Hunter wrote:
Although it is a free and open source package, I think that the image
quality and support is on par with if not superior to what you find in
many commercial solutions.
Amen to that. The ChartDirector demos looked very ugly to my eye. 
matplotlib plots usually look quite good without any tweaking.

--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: invalid literal for int(): 1.0000000000e+00

2005-02-14 Thread Terry Reedy

"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Terry Reedy wrote:
>> int(somestring) without a radix argument requires that somestring be an 
>> decimal integer literal and nothing more and nothing else.
>
> but specifying a radix won't help you, though:

My statement as intended to be read, in its totality, is exactly true. 
Remove 'without a radix argument', which is the case under discussion, and 
it becomes false unless 'decimal' is also removed.  But then one must 
specify that the radix match the literal.  If somestring is a non-decimal 
integer literal (something else), then radix is necessary, and not just 
helpful, for correct execution.

>>> int('033')
33
>>> int('033', 8)
27

>>> int('1a3')
Traceback (most recent call last):
  File "", line 1, in ?
ValueError: invalid literal for int(): 1a3
>>> int('1a3',16)
419

>>> int('4',3)
Traceback (most recent call last):
  File "", line 1, in ?
ValueError: invalid literal for int(): 4

I presume you know this.  I also would have thought that you would know 
better than to think that I am so ignorant and foolish as to think that 
explicitly giving a default parameter value (which is a no-op of no effect) 
would somehow magically fix an invalid input.

The essential point of my post was to clarify for the OP that the reason 
int(1.0) does not work is not because 1.0 is a float literal (which is 
irrelevant to int) but because it is something more (and not 'nothing 
more') than a decimal integer literal.  And so I gave the additional 
example of int(1x) not working.

Knowing that int stops scanning at the first invalid-for-the-radix 'digit' 
explains why it cannot autoconvert a string whose unseen continuation makes 
it float literal.  If one mistakingly assumes that int uses the same lexer 
as Python itself, then one will mistakenly conclude the int will be 
informed that the string constitutes a float literal.  If this were true, 
then expecting the int of the corresponding float value would be 
reasonable.

Even when people know that scanning stops, they often are surprised by the 
exception being raised.  (Indeed, the design could have been otherwise.) 
Clp periodically gets posts like "My string s equal to '123abc' starts with 
a valid decimal integer literal, so why does int(s) fail?" and "You mean I 
really have slice the int away from the rest?"  So I thought it worthwhile 
to reiterate 'nothing more'.

Terry J.Reedy



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


Re: wxPython OGL future

2005-02-14 Thread PD
Hi Peter,

I did look at the code, and did run several examples on it. It _is_
pretty well organized and easy to read through, and youre right, I
think i might be able to add missing functionality if need be.

I don't think I want that much out of it necessarily. I just feel
really weird writing new software with deprecated libraries. By the
time Im done with my project, I have to put all these disclaimers on
how the new versions of wxWidgets might not work. The thing I am really
concerened about is if wxPython decides to drop OGL because it is
deprecated... anyhow thats my 2 cents.

I actually saw several other discussions on OGL and think its such a
shame its been abandoned. It seems like a lot of people are interested
in having this kind of functionality present in the library. Who
knows... maybe if i decide to use it and get good at it, I should do my
share and contribute something back to the open-source community :)

Thank you,
Pouya

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


Re: wxPython OGL future

2005-02-14 Thread PD
Hi D H,

Thank you for the suggestions. I would be interested in Jython but I
had some rough runs with it and I think I would kind of want to stick
to wxWidgets since I think the GUI is kind of cleaner. Im trying to
avoid reinventing the wheel so pyxel is a too little of a framework for
me.

I looked at piccollo though, and that is very appealing to me. What has
your experience been with Jython? I personally had a bad run in with
jython when I tried to run some example code with Swing and got all
sorts of weird behaviour (this was in their demos by the way...) Have
you ever seen some serious projects written with jython that I could
look at maybe?

I greatly appreciate your help, Thank you
Pouya

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


os.rename() doesn't work w/unicode??

2005-02-14 Thread fanbanlo
C:\MP3\001.txt -> 0.txt
C:\MP3\01. ??? - (???).mp3 -> 1.mp3
Traceback (most recent call last):
  File 
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", 
line 310, in RunScript
exec codeObject in __main__.__dict__
  File "C:\MP3\!RenameNum.py", line 40, in ?
renameFiles(os.path.dirname(sys.argv[0]))
  File "C:\MP3\!RenameNum.py", line 26, in renameFiles
os.rename(os.path.join(path, filenames), new_filename)
OSError: [Errno 22] Invalid argument

-
def renameFiles(folder):
"""
The function called for each directory visited.
We'll rename all the files in consecutive number except
files with filename begins with '!'
"""
file_num_counter = 0
for path, dirs, files in os.walk(folder):
for filenames in files:
if filenames.startswith('!'):
print 'file: ' + filenames + ' is ignored!'
else:
file_extension  = filenames.split('.')[-1]
new_filename = str(file_num_counter) + '.' \
+ file_extension
file_num_counter += 1
print os.path.join(path, filenames), "->", new_filename
os.rename(os.path.join(path, filenames), new_filename)
--
http://mail.python.org/mailman/listinfo/python-list


Re: image fourier transform

2005-02-14 Thread Robert Kern
Johannes Ahl-mann wrote:
hi,
i've been looking all around the net (google is my friend ;-) for a
module to apply fourier transformations on images. the different ones in
numerical python and scientific python seem all to be operating on
sequences and therefore seem to be 1D fourier transform.
Huh? From the FFT module which comes with Numeric:
In [1]: import FFT
In [2]: FFT.fft2d?
Type:   function
Base Class: 
String Form:
Namespace:  Interactive
File:   /platlib/Numeric/FFT/FFT.py
Definition: FFT.fft2d(a, s=None, axes=(-2, -1))
Docstring:
fft2d(a, s=None, axes=(-2,-1))
The 2d fft of a. This is really just fftnd with different default
behavior.
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


image fourier transform

2005-02-14 Thread Johannes Ahl-mann
hi,

i've been looking all around the net (google is my friend ;-) for a
module to apply fourier transformations on images. the different ones in
numerical python and scientific python seem all to be operating on
sequences and therefore seem to be 1D fourier transform.

anyone know a library/module to do 2D image FFT in a simple manner.

or am i just too dumb to see how this is supposed to work with the 1D
fourier transforms??

thx,

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


Re: newbie question convert C to python

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> How do i handle this piece of code in python:
> 
> # define vZero 15
> # define vOne  20
> 
> unsigned int vTable[Zero][One]
> 
> if(vGroup[vZero][vOne] == 0)
> {
>  vGroup[vZero][vOne]--
>  .
>  .
> }

Simplest might be with a dictionary:

vGroup = {}# I assume you meant vGroup not vTable
if vGroup[(vZero, vOne)] == 0:
   vGroup[(vZero, vOne)] -= 1
   .
   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iterator / Iteratable confusion

2005-02-14 Thread Terry Reedy

"Michael Spencer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Terry Reedy wrote:
>> iter(iterator) is iterator is part of the iterater protocol

> But, notwithstanding the docs, it is not essential that
> iter(iterator) is iterator

If a program depends on that invariant, then it is essential for that 
program.  Leaving such programs aside, I interpret this and your example 
together as saying three things:

1. "There is more than one possible definition of 'iterator'."

Yes.  Python could have defined many things differently.  But I think it 
important to have a clear definition of iterator (and other things) so one 
can reason about program behavior.

2. "It is not essential to not do something wasteful as long as it is 
otherwise inconsequential."

Usually true, but I don't see this as clarifying the relationship between 
iterables and iterators in Python.  (I am assuming that your example is 
only meant to illustrate possibilities rather than usefulness.)

3. "You can substitute a copy of an object that is never mutated for the 
object itself."

True, as long as you do not look at the id.  But in practice, change of 
state is essential to the function of nearly all iterators.  For mutated 
objects, one has to add the proviso that the copy is current and the 
substitution total, so that there are no references left to the original. 
But again, this has nothing in particular to do with iteration.

>  >>> class A(object):
>  ... def __iter__(self):
>  ... return AnIterator()
>  ...
>  >>> class AnIterator(object): # an iterator that copies itself

By the narrower definition of iterator that I used, this is not an 
iterator.  Also, the replacement is only a copy if the instance has not 
been mutated.  Is your broader definition limited to return of initialized 
copies or would it allow other things also?

>  ... def next(self):
>  ... return "Something"
>  ... def __iter__(self):
>  ... return AnIterator()

The second def statement is equivalent (except for identity) to
__iter__ = A.__iter__

To illustrate the point about mutation with a simple toy example:

a = A()
a.doc = 'My iterator'
b = iter(a)

b is not a copy of a as it is, but only as it was initially.

Terry J. Reedy



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


newbie question convert C to python

2005-02-14 Thread doodle4
How do i handle this piece of code in python:

# define vZero 15
# define vOne  20

unsigned int vTable[Zero][One]

if(vGroup[vZero][vOne] == 0)
{
 vGroup[vZero][vOne]--
 .
 .
}

Thanks,
-d4

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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Tim Peters  <[EMAIL PROTECTED]> wrote:
>[Ilias Lazaridis]
>...
.
.
.
>That leaves volunteers, or a company that wants what you want enough
>to pay for it on their own (which has happened, but not often -- I
>don't think it's happened since Zope Corp funded development of the
>datetime module).
.
.
.
'Depending how you categorize things, there have been a few others 
since then--IBM, for example, has paid non-IBM people for Python
stuff IBM open-sourced.

Well, maybe more than a few, now that I think about it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython OGL future

2005-02-14 Thread Peter Hansen
PD wrote:
I am sort of a new developer to python and working in an academic
environment. I climbed the learning curve on wxPython far enough to get
the functionality I want out of it so far... Now Im in need of a
diagramming library (something visio-like) to use for my software and
the only option I have seen is OGL. Yet I read that OGL is dead, no
longer maintained, obsucure and lacking documentation. 
Not actually having used it, I can't help much, but the code
is all there, runs fine in the latest demo, and looks pretty
clean.  Maybe you should examine it before you decide against
it.  If it does what you need, or if you can easily add the
missing functionality, what else would you want out of it?
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance error in python 2.3.4???

2005-02-14 Thread [EMAIL PROTECTED]
Thanks guys for all your input!  I really appreciate the prompt
replies!

As you can tell I'm having a bit of trouble throwing out old habits...
I'm not new to loosely typed languages (I'm a big PHP fan) but learning
a new object model has been a little tough... I'm trying to make my old
ideas fit a new language (which is a bad idea in general).

So thanks for setting me straight.  I hadn't yet heard of "properties"
it looks like it does what I want... so I will check them out further.
But if they don't do what I want I will probably just use a single
underscore and u trust my users ;-)(In general, C++ people
aren't a trusting bunch Auto Garbage collection!!?!???!
What!?!???!  ;-)

Thanks again for the replies,
Friedmud

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


Re: wxPython OGL future

2005-02-14 Thread D H
PD wrote:
Hi Everyone,
I am sort of a new developer to python and working in an academic
environment. I climbed the learning curve on wxPython far enough to get
the functionality I want out of it so far... Now Im in need of a
diagramming library (something visio-like) to use for my software and
the only option I have seen is OGL. Yet I read that OGL is dead, no
longer maintained, obsucure and lacking documentation. Instead of
taking a leap of faith and walking off a cliff, Ide appreciate if some
people out there who have come across a similar problem have any
solutions or suggestions for me...
Well OGL still works as far as I know.
Check out also pyxel.  It hasn't been updated in almost a year though:
http://bellsouthpwp.net/p/r/prochak/pyxel.html

I am so disappointed at the moment I think Im about ready to throw in
the towel and crawl back to java. I love python, but it has some real
difficulties when it comes to making library choices on what _to_ and
_not to_ get yourself into.
Python baby, you broke my heart :)
You can still use python in java, see jython.
There is a similar tool that works in Java or .NET called Piccolo:
http://www.cs.umd.edu/hcil/piccolo/
I'm using it with boo, a python-like language for .NET and Mono: 
http://boo.codehaus.org/ but you can also use it with IronPython or 
Jython.  On the Linux side, see DiaCanvas (can use from CPython with 
pygtk) and DiaCanvas-Sharp (can use from boo or ironpython):
http://diacanvas.sourceforge.net/
http://diacanvas.sourceforge.net/csharp.php
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython OGL future

2005-02-14 Thread PD
Hi Tom,

OGL is a library that is part of wxPython (wx.lib.ogl). I am trying to
put together some kind of schematic editor. It would be a block diagram
of modules and sometimes a statemachine type of figure. Similar to
something Visio does, but about a gazillion times simpler.

Thanks
Pouya

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


SONO A PRIX DISCOUNT

2005-02-14 Thread YANOF




  

Gagnez 5% du montant des 
commandes, devenez affilié...


  

  Double DERBY
  69 €

  Activ 212
  229 €

  PR-80
  85 €


  

  Arm Laser
  109 €

  PA-2400
  189 €

Faites comme moi, affiliez 
vous et gagner de l'argent.

This message was sent with NNTP Scribbler (www.e-advertize.com).
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Newbie help

2005-02-14 Thread Kent Johnson
Kent Johnson wrote:
You might be interested in the Python tutor mailing list which is 
specifically intended for beginners.
http://mail.python.org/mailman/listinfo/tutor
Ah, I don't mean to imply that this list is unfriendly to beginners, or that you are not welcome 
here! Just pointing out another resource.

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


Re: Newbie help

2005-02-14 Thread Kent Johnson
Chad Everett wrote:
Nope,  I am trying to learn it on my own.  I am using the book by Michael 
Dawson.
You might be interested in the Python tutor mailing list which is 
specifically intended for beginners.
http://mail.python.org/mailman/listinfo/tutor
Kent
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression question

2005-02-14 Thread snacktime
> You may want something like:
> if re.search('%s(.*)%s' % (STX, ETX), data):
>

Ah I didn't even think about that...

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


Re: Write Unicode str as utf-8

2005-02-14 Thread Erik Max Francis
kent sin wrote:
Python support unicode, but some library don't. Write
is one of them. 

When writing a csv file, The rows contains numbers and
unicode str. It is a little pain to first convert all
unicode str to utf-8 before writing the row.
Why?
S = U.encode('utf-8')
Are there anyway I can patch python such that It will
convert the unicode string to utf-8 before the write?
Where should I start?
codecs.open
--
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
  Describe a circle, stroke its back and it turns vicious.
  -- Ionesco
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression question

2005-02-14 Thread Bruno Desthuilliers
snacktime a écrit :
The primary question is how do I perform a match when the regular
expression contains string variables?  For example, in the following
code I want to match a line that starts with STX, then has any number
of characters, then ends with STX.
Example 2 I'm pretty sure works as I expect, but I'm not sure about
Example 1, and I'm pretty sure about example 3.
import re
from curses.ascii import STX,ETX,FS
STX =  chr(STX)
ETX =  chr(ETX)
FS =  chr(FS)
data = STX + "ONE" + FS + "TWO" + FS + "THREE" + ETX
match = STX + '(.*)' + ETX
# Example 1
# This appears to work, but I'm not sure if the '+' is being used in
the regular expression, or if it's just joining STX, '(.*)', and ETX.
if re.search(STX + '(.*)' + ETX,data):
  print "Matches"
# Example 2
# This also appears to work
if re.search(match,data):
  print "Matches"
# Example 3
# Doesn't work, as STX and ETX are evaluated as the literal strings
'STX' and 'ETX'
if re.search('STX(.*)ETX', data):
  print "Matches"
You may want something like:
if re.search('%s(.*)%s' % (STX, ETX), data):
  ...
BTW, given your requirements, I'd write this:
if re.search('^%s(.*)%s$' % (STX, ETX), data):
  ...

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


Re: wxPython OGL future

2005-02-14 Thread Tom Willis
What are you looking to do exactly? I don't know what OGL is.



On Mon, 14 Feb 2005 16:50:51 -0800 (PST), PD <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
> 
> I am sort of a new developer to python and working in an academic
> environment. I climbed the learning curve on wxPython far enough to get
> the functionality I want out of it so far... Now Im in need of a
> diagramming library (something visio-like) to use for my software and
> the only option I have seen is OGL. Yet I read that OGL is dead, no
> longer maintained, obsucure and lacking documentation. Instead of
> taking a leap of faith and walking off a cliff, Ide appreciate if some
> people out there who have come across a similar problem have any
> solutions or suggestions for me...
> 
> I am so disappointed at the moment I think Im about ready to throw in
> the towel and crawl back to java. I love python, but it has some real
> difficulties when it comes to making library choices on what _to_ and
> _not to_ get yourself into.
> 
> I appreciate your guidance,
> Pouya
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
Thomas G. Willis
http://paperbackmusic.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Iterator / Iteratable confusion

2005-02-14 Thread Terry Reedy

"Francis Girard" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

(Note for oldtimer nitpickers: except where relevant, I intentionally 
ignore the old and now mostly obsolete pseudo-__getitem__-based iteration 
protocol here and in other posts.)

Le dimanche 13 Février 2005 23:58, Terry Reedy a écrit :
>> Iterators are a subgroup of iterables. Being able to say iter(it) 
>> without
>> having to worry about whether 'it' is just an iterable or already an
>> iterator is one of the nice features of the new iteration design.

>I have difficulties to represent an iterator as a subspecie of an 
>iteratable

You are not the only one.  That is why I say it in plain English.

You are perhaps thinking of 'iterable' as a collection of things.  But in 
Python, an 'iterable' is a broader and more abstract concept: anything with 
an __iter__ method that returns an iterator.

To make iterators a separate, disjoint species then requires that they not 
have an __iter__ method.  Some problems:
A. This would mean either
1) We could not iterate with iterators, such as generators, which are 
*not* derived from iterables, or, less severely
2) We would, usually, have to 'protect'  iter() calls with either 
hasattr(it, '__iter__') or try: iter(it)...except: pass with probably no 
net average time savings.
B. This would prohibit self-reiterable objects, which require .__iter__ to 
(re)set the iteration/cursor variable(s) used by .next().
C. There are compatibility issues not just just with classes using the old 
iteration protocol but also with classes with .next methods that do *not* 
raise StopIteration.  The presence of .__iter__ cleanly marks an object as 
one following the new iterable/iterator protocol.  Another language might 
accomplish the same flagging with inheritance from a base object, but that 
is not Python.

> [snip]...C++ STL where there is a clear (I resist to
> say "clean") distinction between iteratable and iterator.

leaves out self-iterating iterables -- collection objects with a .next 
method.  I am sure that this is a general, standard OO idiom and not a 
Python-specific construct.  Perhaps, ignoring these, you would prefer the 
following nomenclature:
iterob   = object with .__iter__
iterable= iterob without .next
iterator = iterob with .next

Does STL allow/have iterators that are *not* tied to an iterable?

>One of the result of not distinguishing them is that, at some point in 
>your
>programming, you are not sure anymore if you have an iterator or an
>iteratable ; and you might very well end up calling "iter()" or
> "__iter__()" everywhere.

If you iterate with a while loop just after creating a new iterable or 
iterator, then you probably do know which it is and can make the iter() 
call only if needed.  If you while-iterate with a function argument, then 
iter() is a simpler way to be generic than the alternatives in A2 above.

>I am not concerned with the small performance issue involved here

Good.  I think there are small.  The number and time for iterations is far 
more important.

> (as I very seldom am) but with clarity. After all, why should you have to 
>  > call __iter__ on an iterator you just constructed

As I said above, you don't, and most people wouldn't.  The function 
implementing for loops does because *it*, unlike you, only sees the object 
passed and not the code that created the object!

>I have a strong feeling that the problem arises from the difficulty to
> marry the familiar ""for ... in ..."" construct with iterators. [snip]

What difficulty?  For loops accept an iterable and iterate with the derived 
iterator.

Would you really prohibit the use of for loops with generators and other 
non-iterable-derived iterators?  See A1 above.

>To have iterators act as iteratables might very well had been a 
> >compromise to solve the problem.

I think it elegant.  See below.

>I am not sure at all that this is a "nice feature" to consider an iterator 
>at
>the same level that an iteratable.

I think you are too stuck in the STL model.

> It makes it a bit more akward to have the
>"mind impulse", so to speak, to build iterators on top of other iterators 
>to > slightly modify the way iteration is done.

On the contrary, what could be more elegant than
def itermodifier(it):
  for i in it: # where it is often an iterator
 yield modification-of-i
See the itertools module and docs and the examples of chaining iterators.

Terry J. Reedy



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


Re: DHTML control from Python?

2005-02-14 Thread Bruno Desthuilliers
Kenneth McDonald a écrit :
In article <[EMAIL PROTECTED]>, aurora <[EMAIL PROTECTED]> wrote:
What are the win 32 modules? Searching "OS X win 32" on Google gave me a bit
too much...
I guess Aurora did not took time to read your whole post. Win32 modules 
are for Windows, of course...
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Jeff Shannon
Pat wrote:
I think the same applies to developers.  Not every programmer is
willing to go through a lot of pain and effort just to get something
simple to work.  
True... but given I.L.'s insistence on a rather stringent set of 
requirements (fully open-source toolchain to produce closed-source 
software on proprietary OS), and his attitude ("Why haven't all of you 
done this for me already? WHY WHY WHY?"), he comes across as someone 
who's *insisting* that *someone else* should go to a lot of pain and 
effort on *his* behalf.  Indeed, he's insisting that the Python 
community should provide volunteer effort because it will (supposedly) 
assist him in his commercial endeavor.

Notably, when you've commented in a reasonable manner about having 
apparently similar needs, several people have offered suggestions as 
to how to solve your problems.  People have also offered I.L. 
suggestions, but he derides them as not being exactly what he wants 
and continues to insist that others should perform volunteer work for 
his benefit.

Now, there's nothing wrong with asking (politely) why certain things 
are the way they are, or suggesting that it'd be nice if someone 
changed a few things.  But the insistence that he's being horribly 
wronged because people aren't jumping at the chance to assist him is 
more than a little bit offensive -- especially when he's turning up 
his nose at solutions that are close (but not exact) matches to his 
"requirements".  Instead of saying "Hey, someone's done half my work 
for me -- great!", he's saying "Hey, why haven't you done the rest of 
my work!"

Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list


Re: [long] nested lists as arrays

2005-02-14 Thread bruno modulix
[EMAIL PROTECTED] a écrit :
Thanks for the code.
What I want to do is this:
I want to solve the block puzzle problem.  The problem is as follows:
You have a nxn Array of Numbers and one empty space. Now you there are
up to four possible moves: up, right, down and left, so that each
neighbour of the empty slot can be moved there.
The method getEmptySlot is for getting the empty slot. The method
getPossibleMoves returns the possible moves. Perfoming a move is
swaping one element with the empty slot marked as -1.
The full executable code is appended.
s/executable/source/ !-)
The expected behaviour is that when the move is performed the
appropiate elements should be swaped. But for some reason every now and
then it swaps the wrong elements.
So the problem is not that you "can't" swap 2 elements, but that there 
seems to be some logical bug(s) in your code.

# Puzzle.py
# class for a sliding block puzzle
(snip)
import random
import copy
class Puzzle:
def __init__(self, dim):
   self.dim = dim
   self.elements = [[0 for column in range(dim)] for row in
range(dim) ]
So at this stage you've got 3 rows of 3 colums:
[
  ['row 0 - col 0', 'row 0 - col 1', 'row 0 - col 2'],
  ['row 1 - col 0', 'row 1 - col 1', 'row 1 - col 2'],
  ['row 2 - col 0', 'row 2 - col 1', 'row 2 - col 2']
]
Is that right ?
def __str__(self):
s = ""
i = 0
j = 0
while i  <= self.dim-1:
ok, looping on rows
while j  <= self.dim-1:
and now looping on columns in current row...
s = s + str(self.elements[j][i])
oops ! Looks like you're addressing row[j] column[i] instead of row[i] 
column[j] !-)

j=j+1
s = s + "\t"
i=i+1
j = 0
s = s + "\n"
return s
(snip the rest of the code)
Ok, let's try with a slightly more pythonic (and thus more readable) 
version of this code (I used another method name so we can compare both 
versions):

def to_string(self):
  s = []
  for row in self.elements:
for col in row:
   s.append('%d\t' % col)
s.append('\n')
  return ''.join(s)
For testing purpose, let's modify the __init__ a bit (this will break 
the code but what, it's just to check something, we can get back to 
original code later):

def __init__(self, dim):
  self.dim = dim
  self.range = range(self.dim)
  #self.elements = [[0 for column in self.range] for row in self.range]
  self.elements = [[int('%d%d' % (row, column)) for column in 
self.range] for row in self.range]
  # check we have a correct layout, remove me when fixed:
  print "%s" % self.elements

and now let's try:
>>> p = Puzzle(3)
[[0, 1, 2], [10, 11, 12], [20, 21, 22]]
so far, so good, we have 3 rows of 3 columns each.
let's continue:
>>> print p.to_string()
0   1   2   
10  11  12  
20  21  22  
Ok, so our new to_string() method is ok. Now the real test:
>>> print p
0   10  20  
1   11  21  
2   12  22  
Remember ?
"""
oops ! Looks like you're addressing row[j] column[i] instead of row[i] 
column[j]
"""

Looks like we found one bug...
Let's continue and rewrite some more code:
def compare(self, other):
  if (self.dim != other.dim):
return False
  for self_row, other_row in zip(self.elements, other.elements):
for self_col, other_col in zip(self_row, other_row):
  if self_col != other_col:
return False
  return True
Ok, that one was easy. Let's try with another one
def getEmptySlot(self):
  for row in self.elements:
for cell in row:
  if cell == -1:
 return ???
Mmmm... won't work. Seems we need indices here, let's try again:
def getEmptySlot(self):
  for row in self.range:
for col in self.range:
  if self.elements[row][col] == -1:
return (row, col)
Ok, not so clean but still readable (notice how using explicit names 
like 'row' and 'col' helps understanding the code...).

Now let's do the swap:
def swapElements(self, from_cell, to_cell):
  from_row, from_col = from_cell
  to_row, to_col = to_cell
  elts = self.elements
 elts[to_row][to_col], elts[from_row][from_col] = 
elements[from_row][from_col], elts[to_row][to_col]

Mmmm... this begins to smell. I don't like having to split the coords 
like this. I'd prefer something like:

def swapElements(self, from_cell, to_cell):
  self.elements[from_cell], self.elements[to_cell] \
  = self.elements[to_cell], self.elements[from_cell]
This could be possible if we used another data structure. Something like 
 a dict of coords:value pairs. We could build it like this:

def __init__(self, dim):
  self.dim = dim
  self.range = range(self.dim)
  self.elements = {}
  for row in self.range:
for col in self.range:
  self.elements[(row,col)] = 0
and then the search for the empty slot:
def getEmptySlot(self):
  for coords, value in self.elements.items():
if value == -1:
  return coords
  assert(False)   # shouldn't be here anyway !
Hey, that looks nicer, isn't it ? But wh

Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong <[EMAIL PROTECTED]> writes:
> I know a bit about this stuff, but not nearly enough to come
> up with a water tight design by myself, so it's much easier
> and safer to rely on trusted work by others.

Yeah, at this point I think it's safest to just use SSL.  If I use
Pyro for anything I'll probably do it that way.

> DCOM: as it is based on DCE/RPC, I would say: no. There's this MIDL
> thing sitting in between and stuff like that. There's no such thing
> as a specific class id and/or method name and/or parameter list that
> directly maps onto an object.method in the programming environment.

Hmm, ok, maybe we need something like that for Python, perhaps as a
Pyro extension.

> Precisely. There is this tunneling thing, but I never got it to work.
> In the end, using a SSH tunnel may prove to be even easier :-D
> (just let sshd listen on port 80 and you're set)

I think if you want to get serious about authentication, SSL has more
of a developed infrastructure.  Frankly I've never understood why ssh
caught on instead of telnet over SSL.  See stunnel.org for a simple
SSL tunnel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Write Unicode str as utf-8

2005-02-14 Thread kent sin
Python support unicode, but some library don't. Write
is one of them. 

When writing a csv file, The rows contains numbers and
unicode str. It is a little pain to first convert all
unicode str to utf-8 before writing the row.

Are there anyway I can patch python such that It will
convert the unicode string to utf-8 before the write?
Where should I start?


Best rgs,

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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Tim Peters
[Ilias Lazaridis]
...
> Let's see:
>
> The process would be:
>
> a) A Python Foundation official states: "of course we accept diversity
> and of course we are intrested that our source-code-base compiles
> directly with MinGW (and other compilers)".

Well, I'm a Director of the Python Software Foundation, and my view is
"the more platforms the merrier".  But I'm not paid to work on Python,
and I don't have time to volunteer to help MinGW along, so I don't
anticipate that I'll do anything here beyond writing this reply.

I think you're mistaken about the role the PSF plays here.  For
example, the PSF does no development work on Python -- all work on
Python comes from volunteers, and the PSF can't tell anyone what to
do.  The PSF did start a grant program last year, and a proposal to
fund MinGW-for-Python development would certainly be considered.  But
that too requires that someone volunteer to write such a proposal, and
take their chances on getting a grant.  Those chances are,
unfortunately, not good, since even in the program's first year we got
proposals requesting funding vastly exceeding the US$40K we could
afford to spend.

That leaves volunteers, or a company that wants what you want enough
to pay for it on their own (which has happened, but not often -- I
don't think it's happened since Zope Corp funded development of the
datetime module).

> b) the pyMinGW developer states: "I am intrested that my patches are
> included within the main python source code base" [of course this
> contribution would deserve to be mentioned somewhere]
>
> c) One part of the Python Community states: "look those loosers, like to
> use MinGW toolkit - pah! I'll continue to use my super-optimizing, xx%
> faster results, less hassle Microsoft-Compiler"
>
> d) One part of the Python Community states: "I'm very happy that my
> toolset of choice gets official support, to which I can contribute as a
> community member"
>
> e) there is no point e. People start simply to cooperate, thus python's
> evolution is ensured.

Sorry, I didn't grasp the point of b thru e.

> ... 
> Good night to all.

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


Re: is there a safe marshaler?

2005-02-14 Thread Irmen de Jong
Paul Rubin wrote:
Hmm, you also want a random blob in each packet (including the session
start) included in the authentication of the next packet, so the
attacker can't cut and paste messages from old sessions into the
current ones.  You know, by the time you're through designing this you
may be better off just using SSL and getting it over with.  It's very
easy to make mistakes designing these types of protocols.  There are
some reasonable examples in "Applied Cryptography", but maybe you
don't want to deal with this stuff.
Heh, indeed I rather don't.
I know a bit about this stuff, but not nearly enough to come
up with a water tight design by myself, so it's much easier
and safer to rely on trusted work by others.

I label things like SOAP and XML-RPC much different than RMI or Pyro,
because they (SOAP) are much more "distant" from the actual
programming language and environment beneath them. I don't know if
this is good thinking or not but the fact that RMI and Pyro expose
language features directly, and SOAP not, makes that I reason about them
differently.

Hmm, I sort of understand this, but not completely.  Does DCOM or .NET
expose language features directly?
.NET: no idea
DCOM: as it is based on DCE/RPC, I would say: no. There's this MIDL
thing sitting in between and stuff like that. There's no such thing
as a specific class id and/or method name and/or parameter list that
directly maps onto an object.method in the programming environment.
I must confess, this stuff is getting all rather messy and probably not
worth to try to make such a distinction between all the RPC protocols :-)
I've been meaning to look at Pyro and will certainly let you know if I
spot any problems, but of course there might be some that I don't find.
I would appreciate it.

Furthermore there are practical issues such as having to
open a buch of new ports in your firewall. In my experience
this is very hard to get done, sadly, in contrast to just
exposing a "web-service" (in whatever form) on port 80 HTTP.

Yes, though RMI requires the same.
Precisely. There is this tunneling thing, but I never got it to work.
In the end, using a SSH tunnel may prove to be even easier :-D
(just let sshd listen on port 80 and you're set)
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


regular expression question

2005-02-14 Thread snacktime
The primary question is how do I perform a match when the regular
expression contains string variables?  For example, in the following
code I want to match a line that starts with STX, then has any number
of characters, then ends with STX.
Example 2 I'm pretty sure works as I expect, but I'm not sure about
Example 1, and I'm pretty sure about example 3.

import re
from curses.ascii import STX,ETX,FS
STX =  chr(STX)
ETX =  chr(ETX)
FS =  chr(FS)
data = STX + "ONE" + FS + "TWO" + FS + "THREE" + ETX
match = STX + '(.*)' + ETX

# Example 1
# This appears to work, but I'm not sure if the '+' is being used in
the regular expression, or if it's just joining STX, '(.*)', and ETX.

if re.search(STX + '(.*)' + ETX,data):
  print "Matches"

# Example 2
# This also appears to work
if re.search(match,data):
  print "Matches"

# Example 3
# Doesn't work, as STX and ETX are evaluated as the literal strings
'STX' and 'ETX'
if re.search('STX(.*)ETX', data):
  print "Matches"

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


Re: Kill GIL

2005-02-14 Thread Aahz
In article <[EMAIL PROTECTED]>,
Donn Cave  <[EMAIL PROTECTED]> wrote:
>In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Aahz) 
>wrote:
>>
>> Yes.  I just get a bit irritated with some of the standard lines that
>> people use.
>
>Hey, stop me if you've heard this one:  "I used threads to solve
>my problem - and now I have two problems!"

Point to you.  ;-)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


wxPython OGL future

2005-02-14 Thread PD
Hi Everyone,

I am sort of a new developer to python and working in an academic
environment. I climbed the learning curve on wxPython far enough to get
the functionality I want out of it so far... Now Im in need of a
diagramming library (something visio-like) to use for my software and
the only option I have seen is OGL. Yet I read that OGL is dead, no
longer maintained, obsucure and lacking documentation. Instead of
taking a leap of faith and walking off a cliff, Ide appreciate if some
people out there who have come across a similar problem have any
solutions or suggestions for me...

I am so disappointed at the moment I think Im about ready to throw in
the towel and crawl back to java. I love python, but it has some real
difficulties when it comes to making library choices on what _to_ and
_not to_ get yourself into.

I appreciate your guidance,
Pouya

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


Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong <[EMAIL PROTECTED]> writes:
> > Note you should also put sequence numbers in the messages, to stop
> > the attacker from fooling you by selectively deleting or replaying
> > messages.
> 
> Thanks for the tip. I'll think about this.

Hmm, you also want a random blob in each packet (including the session
start) included in the authentication of the next packet, so the
attacker can't cut and paste messages from old sessions into the
current ones.  You know, by the time you're through designing this you
may be better off just using SSL and getting it over with.  It's very
easy to make mistakes designing these types of protocols.  There are
some reasonable examples in "Applied Cryptography", but maybe you
don't want to deal with this stuff.

> Well, my experience with RMI is very limited (and from a few years ago)
> but I remember that you are required to set a security manager on your
> RMI objects. I always used Java's default rmi security manager but I
> honestly don't know what it actually does :-D

Thanks, I should try to find out more about this.  I'm about to be
doing some stuff with an existing RMI app and I better make sure it's
not already vulnerable.

> I label things like SOAP and XML-RPC much different than RMI or Pyro,
> because they (SOAP) are much more "distant" from the actual
> programming language and environment beneath them. I don't know if
> this is good thinking or not but the fact that RMI and Pyro expose
> language features directly, and SOAP not, makes that I reason about them
> differently.

Hmm, I sort of understand this, but not completely.  Does DCOM or .NET
expose language features directly?

> Then again, Pyro allows you to use two forms of XML serialization
> on the wire (instead of pickle), which may or may not move it much closer
> to SOAP and the likes. But there are other reasons for not wanting
> a Pyro server exposed on the internet. Such as the lack of a good
> security analisys of Pyro. Perhaps it suffers from similar holes
> as XMLRPC until recently...

I've been meaning to look at Pyro and will certainly let you know if I
spot any problems, but of course there might be some that I don't find.

> Furthermore there are practical issues such as having to
> open a buch of new ports in your firewall. In my experience
> this is very hard to get done, sadly, in contrast to just
> exposing a "web-service" (in whatever form) on port 80 HTTP.

Yes, though RMI requires the same.
-- 
http://mail.python.org/mailman/listinfo/python-list


Ann: PyPy Sprint before PYCON 2005 in Washington

2005-02-14 Thread Christian Tismer
PyPy Sprint before PYCON 2005 in Washington
---
In the four days from 19th March till 22th March (inclusive)
the PyPy team will host a sprint on their new Python-in-Python
implementation.   The PyPy project was granted funding by the
European Union as part of its Sixth Framework Program,
and is now on track to produce a stackless Python-in-Python
Just-in-Time Compiler by December 2006.  Our Python
implementation, released under the MIT/BSD license, already
provides new levels of flexibility and extensibility at the
core interpreter and object implementation level.
Armin Rigo and Holger Krekel will also give talks about PyPy
and the separate  py.test tool (used to perform various kinds
of testing in PyPy) during the conference.
Naturally, we are eager to see how the other re-implementation
of Python, namely IronPython, is doing and to explore
collaboration possibilities.  Of course, that will depend on
the degree of openness that Microsoft wants to employ.
The Pycon2005 sprint is going to focus on reaching
compatibility with CPython (currently we target version 2.3.4)
for our PyPy version running on top of CPython. One goal of
the sprint is to pass 60% or more of the unmodified regression
tests of mainline CPython.  It will thus be a great way to get
to know CPython and PyPy better at the same time!  Other
possible work areas include:
- translation to C to get a first working lower-level representation
  of the interpreter "specified in Python"
- integrating and implementing a full parser/compiler chain
  written in Python maybe already targetting the new
  AST-branch of mainline CPython
- fixing various remaining issues that will come up while
  trying to reach the compatibility goal
- integrate or code pure python implementations of some Python modules
  currently written in C.
- whatever issues you come up with! (please tell us
  before hand so we can better plan introductions etc.pp.)
Besides core developers, Bea Düring will be present to help
improving and document our sprint and agile development
process.
We are going to give tutorials about PyPy's basic concepts and
provide help to newcomers usually by pairing them with
experienced pypythonistas. However, we kindly ask newcomers to
be present on the first day's morning (19th of March) of the
sprint to be able to get everyone a smooth start into the
sprint. So far most newcomers had few problems in getting a
good start into our codebase.  However, it is good to have the
following preparational points in mind:
- some experience with programming in the Python language and
  interest to dive deeper
- subscription to  pypy-dev and  pypy-sprint at
http://codespeak.net/pypy/index.cgi?lists
- have a subversion-client, Pygame and graphviz installed on
  the machine you bring to the sprint.
- have a look at our current  documentation, especially the
  architecture and  getting-started documents under
http://codespeak.net/pypy/index.cgi?doc
The pypy-dev and pypy-sprint lists are also the contact points
for raising questions and suggesting and discussing sprint
topics beforehand. We are on #pypy on irc.freenode.net most
of the time. Please don't hesitate to contact us or introduce
yourself and your interests!
Logistics
-
Organizational details will be posted to pypy-sprint and are
or will be available in the Pycon2005-Sprint wiki here:
http://www.python.org/moin/PyConDC2005/Sprints
Registration

send mail to [EMAIL PROTECTED], stating the days
you can be present and any specific interests if applicable.
Registered Participants
---
all days:
 Jacob Hallén
 Armin Rigo
 Holger Krekel
 Samuele Pedroni
 Anders Chrigström
 Bea Düring
 Christian Tismer
 Richard Emslie
--
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
 whom do you want to sponsor today?   http://www.stackless.com/

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


Re: is there a safe marshaler?

2005-02-14 Thread Irmen de Jong
Fredrik Lundh wrote:
the bug had nothing to do with the XML-RPC protocol itself;
True, sorry for the confusion. I should have written it more precisely.
it was a
weakness in the SimpleXMLRPCServer framework which used reflection
to automatically publish instance methods (if you use getattr repeatedly on
an instance, you can access a lot more than just attributes and methods...)
how do you publish "RPC endpoints" in Pyro?
By reflection :-)   return getattr(self,method) (*args,**keywords)
But Pyro currently treats attribute lookups differently.
It either ignores them completely (you have to enable remote-attribute
access explicitly) or returns attributes as 'local' objects.
What I mean is that you can access a remote attribute of a Pyro object,
but only one level deep. There is no repeated (nested) remote attribute
lookup. It's quite difficult to explain, if you want more details please
read the relevant section in the Pyro manual:
http://pyro.sourceforge.net/manual/7-features.html#nestedattrs
As far as I can see, Pyro is safe from the XMLRPCServer weakness.
Interestingly, I have been thinking for a long time to add nested
remote attribute lookup to Pyro. I know know that this is perhaps
not a really good idea :)
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if my host supports Python?

2005-02-14 Thread Jeff Epler
If you have a shell, it's as simple as typing "python" and seeing if the
interactive interpreter appears:
$ python
Python 2.3.3 (#1, May  7 2004, 10:31:40) 
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
If you've done this, you can find out the path to this Python
interpreter:
>>> import sys; print sys.executable
/usr/bin/python

Otherwise, the documentation for the 'cgi' module has a buried
suggestion with the simplest Python CGI program.
http://docs.python.org/lib/node462.html
that program would look something like
#!/usr/bin/python
import cgi; cgi.test()
though you must know the correct path to the Python interpreter for this
to work.

Your best bet may be to ask your webhost for help---only they know how
they've (mis)configured your system.

Jeff


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

Re: [Errno 18] Invalid cross-device link using os.rename

2005-02-14 Thread Jeff Epler
mv is a surprisingly complex program, while os.rename is a wrapper
around rename(2) which is probably documented on your system to return
EXDEV under these circumstanes.

os.xxx is generally a fairly thin wrapper around what your OS provides,
and inherits all the "gotchas".  For some activities, os.shutil provides
something that is between os.xxx and os.system("xxx") in complexity and
capability.

Jeff


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

Re: 64 bit Python

2005-02-14 Thread Jeff Epler
There's not enough information to guess the "real problem", but it could
be this:

"variable size" objects (declared with PyObject_VAR_HEAD) are limited to
INT_MAX items since the ob_size field is declared as 'int'.

This means that a Python string, tuple, or list (among other types) may
be limited to about 2 billion items on ILP32 and LP64 architectures.

Dicts and probably sets are also limited to INT_MAX elements, because
the "ma_fill" and "ma_used" fields are ints.

If you don't mind recompiling all your extensions, you could change the
type of ob_size to long in the "#define PyObject_VAR_HEAD".  I don't
know what breaks when you do this, but maybe a few google or google
groups searches could help you find others who have tried this.

Jeff
PS the limit of 500MB of "real data" in the 32-bit system may be because
a realloc may temporarily require (old size + new size) storage when it
does the equivalent of
new_ptr = malloc(new_size)
memcpy(new_ptr, old_ptr, old_size)
free(old_size)
which will temporarily use >900MB of data when resizing a ~450MB object.
Python frequently uses realloc() to grow structures like lists.  If you
are working with strings, then
s = s + t
doesn't ever use realloc (in 2.3.x anyway) but always allocates and
fills the result 's+t', only freeing the old value of s later when it is
no longer reacahable (which could be as soon as the assignment statement
completes)


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

How can I tell if my host supports Python?

2005-02-14 Thread Charles Stricklin
I'd like to use Planet (http://planetplanet.org/) to aggregate my members
blogs into one big blog, and my host (http://www.bodhost.com) says they
support Python, but I see nothing anywhere on their web site including my
control panel that leads me to believe they do.

Is there any way to determine if they do?
-- 
Charles Stricklin


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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Robert Kern
Ilias Lazaridis wrote:
Robert Kern wrote:
Ilias Lazaridis wrote:
Robert Kern wrote:
[snip]
The answer to most of your questions is, "Because no one has yet 
volunteered their time and effort to get the job done."

this answer do not fit in most questions.
please review them again.

Against my better judgement, I have.
It certainly fits a, b, and c. It also fits d if you place an implicit 
"Yes, " in front of the answer. 4/6. I stick with my assessment.

see below.
[...]
I ask some questions and suggest some things.
Voluntarlily and without beeing paid.

Questions and suggestions are don't count for much in this community. 
Code and well-written patches do.

Stop wasting time on c.l.py and get to work! If you can't do that, 
then this is not the community you are looking for.

Please speak for yourself.
I think that my participation in the community for the past six years 
and a rational examination of the responses you have received so far 
qualify me, just a little bit, to conclude that this community does not 
tolerate your kind of behaviour well.

If you want one that does so tolerate your behaviour, you need to keep 
looking.

There are many commercial systems around python.

And yet there is not one company that has someone devoted full-time to 
developing Python. Not even Guido. 

Who's "Guido"?
The guy who wrote Python originally and is still the head developer.
Most of core-Python development happens in people's spare, unpaid time.
Volunteerism is the core of this community. Trust me.

even if:
Volunteerism does not exclude Professionalism.
Volunteerism does not, indeed, exclude professionalism. However, being 
professional does not entail satisfying the desires of everyone who 
asks. Being professional does not mean that volunteerism is not the 
driving force of this community.

If this does not appeal to you, then this is not the community that you 
are looking for.

So please stop this volunteerism-stuff.

No. You are asking others to volunteer their time, or perhaps, 
alternately, the PSF and other businesses to volunteer their money to 
fund people's time to satisfy *your* wants. I am asking you to 
volunteer *your* time to satisfy *your* wants, 

I'm already doing this.
Okay, let me clarify: I am asking you to volunteer your time with 
something that is going to be productive. Continuing here on c.l.py as 
you have been will not be productive. I've seen dozens of people who act 
like you do come in to this newsgroup and leave again unsatisfied.

or alternately, stop writing questionnaires and bothering us.

Feel free to ignore the threads.
I would have been more than happy to until my web page was used. Now I 
feel some obligation to correct some things.

And please speak for yourself.
I am speaking as a member of this community, not necessarily for this 
community. But I do have some experience with how this community behaves 
and how it responds to people who behave like you do. I know that they 
do not mix well at all.

If you want a community that does tolerate this behaviour, you need to 
keep looking.

Note that this reaction is pretty specific to you and not to other 
newcomers. Most newcomers do not carry around a sense of entitlement 
that could flatten a small village. Thus, they are treated with 
respect and helpfulness. We would appreciate it if you would emulate 
these people. On a purely pragmatic note, you have to admit that they 
are getting much better help than you are.

I get the help that I want.
You could do it much more efficiently. And in a way that does not 
generate the obvious ill-will that you have generated. This thread 
*could* have been completely technical and addressed your real concerns 
quite quickly. However, you have acted in a way that *invites* the 
accusation of trolling, that immediately disinclines people to help you, 
that ruins your credibility here.

You *can* act differently, and we *will* respond better.
If you don't want to act differently, then your interaction with this 
community will continue to be counterproductive, and I would advise you 
to look for some other community that is more responsive.

If you like to help me and other newcomers, please give me simple 
some answers on the initial questions.

I did provide some answers. Please review them again.

Please have the gentleness [against me and the current/future readers] 
to answer within the context of the original writings.
I will be more careful in the future.
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance error in python 2.3.4???

2005-02-14 Thread Jack Diederich
On Tue, Feb 15, 2005 at 10:56:23AM +1100, Delaney, Timothy C (Timothy) wrote:
> [EMAIL PROTECTED] wrote:
> 
> > I guess I could just use one underscore but that means it is
> > easier for other people to get at my implementation details (which,
> > coming from a C++ background really bothers me).
> 
> This is the correct solution, and getting over being bothered about it
> is the correct thing to do.
> 
> Getting at private members is simple in C++ too if anyone wants to do
> that.

As a long time C++ guy that switched over to python (via a perl detour) my 
advice is to do things the python way even if they feel strange at first.  
In this case forget about "private" and "protected."  If it helps you can 
consider them conventions that have some compiler support.  The 20th 
commandment of python is "we're all adults here."  To see the first 19, type 
"import this" at the python prompt.

I also discovered - to my shock and horror - that many of the GoF's "Design
Patterns" were actually C++ centric and not universals.  The sting of seeing
canon reduced to a HOWTO fades quickly, just jump in with both feet.

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


Re: Kill GIL

2005-02-14 Thread Donn Cave
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Aahz) 
wrote:

> Yes.  I just get a bit irritated with some of the standard lines that
> people use.

Hey, stop me if you've heard this one:  "I used threads to solve
my problem - and now I have two problems!"

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


Re: is there a safe marshaler?

2005-02-14 Thread Fredrik Lundh
Irmen de Jong wrote:

>> I haven't looked at that bug carefully yet but yes, anything exposed
>> to the internet has to be done very carefully, and XML-RPC missed
>> something.
>
> What I know of it is that you had the possibility to arbitrarily follow
> attribute paths, including attributes that should rather be kept hidden.

the bug had nothing to do with the XML-RPC protocol itself; it was a
weakness in the SimpleXMLRPCServer framework which used reflection
to automatically publish instance methods (if you use getattr repeatedly on
an instance, you can access a lot more than just attributes and methods...)

how do you publish "RPC endpoints" in Pyro?

 



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


Re: parsing IMAP responses?

2005-02-14 Thread Grant Edwards
On 2005-02-14, Tony Meyer <[EMAIL PROTECTED]> wrote:
>> Is there a library somewhere that impliments the IMAP protocol 
>> syntax?
>
> Twisted has pretty good IMAP support (particularly client), and it's much
> higher level than imaplib.  It probably does what you're after.

I'll take a look.

> Of course, the catch is that you have to use twisted <0.5 wink>.

There's always a catch...

-- 
Grant Edwards   grante Yow!  I'm thinking about
  at   DIGITAL READ-OUT systems
   visi.comand computer-generated
   IMAGE FORMATIONS...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DHTML control from Python?

2005-02-14 Thread Kenneth McDonald
In article <[EMAIL PROTECTED]>, aurora <[EMAIL PROTECTED]> wrote:

What are the win 32 modules? Searching "OS X win 32" on Google gave me a bit
too much...

Thanks,
Ken

> IE should be able to do that. Install the win32 modules. Then you should  
> simply embed Python using 

Re: is there a safe marshaler?

2005-02-14 Thread Irmen de Jong
Paul Rubin wrote:
Yes, that's what I meant, using hmac to authenticate using a shared secret,
sending the rest in the clear.  Note you should also put sequence numbers
in the messages, to stop the attacker from fooling you by selectively
deleting or replaying messages.
Thanks for the tip. I'll think about this.

You should not want to expose a Pyro service to the internet because
Python doesn't have Java's security model and sandboxing, that are
used with RMI. Pyro has a few features that are very powerful
but also require the use of intrinsic insecure Python code (namely,
pickle, and marshal).

Can you say some more about this?  Does RMI really rely on sandboxes,
if you don't send code around, but just expose operations on server
side objects?
Well, my experience with RMI is very limited (and from a few years ago)
but I remember that you are required to set a security manager on your
RMI objects. I always used Java's default rmi security manager but I
honestly don't know what it actually does :-D
Other than that, it would be interesting to know if the RMP or IIOP
protocols have any problems with malicious packets? I don't know
them well enough to say anything about this.
I don't think marshal is inherently insecure, since the unmarshaller
doesn't itself execute any marshalled code.  It apparently has some
bugs that can confuse it if you send it a malformed marshalled string,
but those can be fixed.  Pickle is inherently insecure because of how
it calls class constructors.
Yep, that's what I now know too from the other replies in this thread.

Just look at the recent security advisory about the XMLRPC server
that comes with Python it's much more primitive than Pyro is,
but even that one was insecure.

I haven't looked at that bug carefully yet but yes, anything exposed
to the internet has to be done very carefully, and XMLRPC missed something.
What I know of it is that you had the possibility to arbitrarily follow
attribute paths, including attributes that should rather be kept hidden.

I wouldn't put a Java RMI server or xyz CORBA server or whatever
kind of unrestricted API open on the internet anyway.
Am I rational or paranoid?

I haven't used Java enough to advise you on this, but I thought they
were supposed to be ok to expose to the internet.  Certainly the whole
idea of .NET is to let you securely provide RPC services (excuse me
for a moment while I try to stop laughing for mentioning security and
Microsoft in the same sentence).  And lots of people use things like
SOAP for that.
I label things like SOAP and XML-RPC much different than RMI or Pyro,
because they (SOAP) are much more "distant" from the actual
programming language and environment beneath them. I don't know if
this is good thinking or not but the fact that RMI and Pyro expose
language features directly, and SOAP not, makes that I reason about them
differently.
Then again, Pyro allows you to use two forms of XML serialization
on the wire (instead of pickle), which may or may not move it much closer
to SOAP and the likes. But there are other reasons for not wanting
a Pyro server exposed on the internet. Such as the lack of a good
security analisys of Pyro. Perhaps it suffers from similar holes
as XMLRPC until recently...
Furthermore there are practical issues such as having to
open a buch of new ports in your firewall. In my experience
this is very hard to get done, sadly, in contrast to just
exposing a "web-service" (in whatever form) on port 80 HTTP.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: graphing

2005-02-14 Thread Fernando Perez
Jan Rienyer Gadil wrote:

> i'm currently using python 2.3(enthought edition) on win 2000/xp.
> i'm using boa constructor on the GUI part and matplotlib 0.71 on
> plotting the graph.

You should post this on the matplotlib list directly, where your chances of a
reply are much better.  I use matplotlib, but not in the context of GUI
embedding, so I can't help.

best,

f

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


RE: Inheritance error in python 2.3.4???

2005-02-14 Thread Delaney, Timothy C (Timothy)
[EMAIL PROTECTED] wrote:

> I guess I could just use one underscore but that means it is
> easier for other people to get at my implementation details (which,
> coming from a C++ background really bothers me).

This is the correct solution, and getting over being bothered about it
is the correct thing to do.

Getting at private members is simple in C++ too if anyone wants to do
that.

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


Re: Inheritance error in python 2.3.4???

2005-02-14 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> The problem is that I actually do need them to be private to the
> outside world... but not to subclasses.  I guess what I actually need
> is something like "protected" in C++ but I don't think I'm going to
> get that luxury.

The only way to make instance variables really private is to put them
in a separate process and use IPC to reach the accessors.  The __xyz
convention results in deterministic name mangling that other parts of
the program can undo if they wish to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Robert Kern
Ilias Lazaridis wrote:
Duncan Booth wrote:
Ilias Lazaridis wrote:
There is a OS-tool-chain supported on windows, cygwin. 

this depends on cygwin.dll, which is GPL licensed
[or am I wrong?]

It is GPL licensed with an amendment which prevents the GPL spreading 
to other open source software with which it is linked.

"In accordance with section 10 of the GPL, Red Hat, Inc. permits 
programs whose sources are distributed under a license that complies 
with the Open Source definition to be linked with libcygwin.a without 
libcygwin.a itself causing the resulting program to be covered by the 
GNU GPL."

If I understand this right, I cannot produce commercial software with 
the cygwin toolset.
Wait, you demand a completely open source toolchain on a proprietary 
operating system to develop proprietary software?

The mind *boggles*.
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance error in python 2.3.4???

2005-02-14 Thread [EMAIL PROTECTED]
The problem is that I actually do need them to be private to the
outside world... but not to subclasses.  I guess what I actually need
is something like "protected" in C++ but I don't think I'm going to
get that luxury.

I think what's happening in my example is that the name mangling is
looking at the defining class instead of looking at "self"... which is
not what I expected.  Which means it is accessing two different
variables (_subclass_something on the set and _baseclass__something on
the get)

Anyone know of a workaround for that?? (other than renaming the
variable so it doesn't have the two underscores?)

I guess I could just use one underscore but that means it is easier
for other people to get at my implementation details (which, coming
from a C++ background really bothers me).

Friedmud

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


Re: nested lists as arrays

2005-02-14 Thread Michael Spencer
Terry Reedy wrote:
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

  def setRandomState(self):
 # container for the elements to pick from
 container = [1,2,3,4,5,6,7,8,-1]
 # create elements of puzzle randomly
 i = 0
 j = 0
 while i <= self.dim-1:
 while j <= self.dim-1:
 if len(container) > 0:
 randomindex = random.randint(0,len(container)-1)
 self.elements[j][i] = container[randomindex]
 del container[randomindex]
 j=j+1
 else:
 break
 j=0
 i=i+1

Without reading closely, I believe that the above can generate any possible 
position.  Are you aware that half are unsolvable?  If that matters, you 
need to either find a book or site that explains the parity test for 
solvability or generate the start position from the goal position by a 
series of random moves.

Terry J. Reedy
This covers the test for solvability - enjoy ;-): 
http://www.cs.tcd.ie/publications/tech-reports/reports.01/TCD-CS-2001-24.pdf

BTW, just because your puzzle looks like a grid doesn't neceesarily mean that 
representing the data as nested arrays is easiest.  A flat list might be just as 
good here.  It simplifies some of the operations (creating a random ordering 
becomes a one-liner), at the expense of a little more complexity in some others:

import random
class n2grid(object):
"""A grid for the n squared puzzle"""
def __init__(self,dim = 4):
   self.cells = range(dim*dim)
   self.dim = dim
   self.pos = (0,0)
def shuffle(self):
random.shuffle(self.cells)
self.pos = divmod(self.cells.index(0),self.dim)
def show(self):
for row in self._asarray():
print "".join("[%2s]" % (cell or "") for cell in row)
def _move(self,dy,dx):
dim = self.dim
cells = self.cells
oldy, oldx = self.pos
newy, newx = oldy + dy, oldx + dx
if 0 <= newx < dim and 0 <= newy < dim:
ix = newy * dim + newx
ox = oldy * dim + oldx
cells[ix], cells[ox] = cells[ox], cells[ix]
self.pos = newy,newx
else:
raise Exception, "Illegal move to: (%s,%s)" % (newy, newx)
def move(self, dx, dy):
try:
self._move(dx,dy)
self.show()
except:
pass
def _asarray(self): #create the array representation when needed
cells = iter(self.cells)
dim = self.dim
return [[cells.next() for j in range(dim)] for i in range(dim)]
def __repr__(self):
return repr(self._asarray())

 >>> p = n2grid()
 >>> p.show()
 ...
[  ][ 1][ 2][ 3]
[ 4][ 5][ 6][ 7]
[ 8][ 9][10][11]
[12][13][14][15]
 >>> p.shuffle()
 >>> p.show()
[ 3][15][ 6][ 7]
[10][  ][12][ 5]
[ 4][ 1][14][ 8]
[ 2][11][13][ 9]
 >>> p.move(1,1)
[ 3][15][ 6][ 7]
[10][14][12][ 5]
[ 4][ 1][  ][ 8]
[ 2][11][13][ 9]
 >>> p.move(1,0)
[ 3][15][ 6][ 7]
[10][14][12][ 5]
[ 4][ 1][13][ 8]
[ 2][11][  ][ 9]
 >>> p.move(1,0) # illegal (does nothing)
 >>>
Cheers
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong <[EMAIL PROTECTED]> writes:
> > Well, ok, if you trust then other end then I think it's enough to just
> > authenticate all the pickles (say using hmac.py) without needing
> > something as heavyweight as SSL.
> 
> An interesting idea that hadn't crossed my mind yet.  Pyro *does*
> already have connection authentication that uses md5 (and hmac since
> 3.5beta) with a shared secret, but after that, the communication is
> done in plaintext so to speak.

Yes, that's what I meant, using hmac to authenticate using a shared secret,
sending the rest in the clear.  Note you should also put sequence numbers
in the messages, to stop the attacker from fooling you by selectively
deleting or replaying messages.
> 
> You should not want to expose a Pyro service to the internet because
> Python doesn't have Java's security model and sandboxing, that are
> used with RMI. Pyro has a few features that are very powerful
> but also require the use of intrinsic insecure Python code (namely,
> pickle, and marshal).

Can you say some more about this?  Does RMI really rely on sandboxes,
if you don't send code around, but just expose operations on server
side objects?

I don't think marshal is inherently insecure, since the unmarshaller
doesn't itself execute any marshalled code.  It apparently has some
bugs that can confuse it if you send it a malformed marshalled string,
but those can be fixed.  Pickle is inherently insecure because of how
it calls class constructors.

> Just look at the recent security advisory about the XMLRPC server
> that comes with Python it's much more primitive than Pyro is,
> but even that one was insecure.

I haven't looked at that bug carefully yet but yes, anything exposed
to the internet has to be done very carefully, and XMLRPC missed something.

> I wouldn't put a Java RMI server or xyz CORBA server or whatever
> kind of unrestricted API open on the internet anyway.
> Am I rational or paranoid?

I haven't used Java enough to advise you on this, but I thought they
were supposed to be ok to expose to the internet.  Certainly the whole
idea of .NET is to let you securely provide RPC services (excuse me
for a moment while I try to stop laughing for mentioning security and
Microsoft in the same sentence).  And lots of people use things like
SOAP for that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance error in python 2.3.4???

2005-02-14 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
class baseClass(object):
__Something = "Dumb!"
def getSomething( self ):
return self.__Something
class subClass(baseClass):
def setSomething( self , aSomething ):
self.__Something = aSomething
anObject = subClass()
anObject.setSomething("Cool!")
print anObject.getSomething()
Your mistake is using '__' names when they aren't necessary.  '__' names 
are mangled with the class name:

py> class B(object):
... __x = False
... def __init__(self):
... self.__x = 1
... def getx(self):
... return self.__x
...
py> class C(object):
... def setx(self, x):
... self.__x = x
...
py> vars(B())
{'_B__x': 1}
py> vars(C())
{}
Note that C instances don't get __x variables because of the mangling.
Someone please show me the pythonish way to do this!
A number of suggestions:
(1) Generally, you don't need getters and setters.  If you think you do, 
you probably want property instead.

(2) Don't use __ names.  They're a hack that doesn't really make things 
private, and doesn't even avoid name collisions all the time.  There are 
probably a few cases where they're useful, but this is not one of them. 
 If you don't want attributes to show up in automatically generated 
documentation, simply prefix them with a single underscore.

(3) Don't use class-level attributes as defaults for instance-level 
attributes.  If it's part of the instance, set it on the instance.  If 
it's part of the class, set it on the class.  Hiding a class-level 
attribute with an instance-level attribute will most likely lead to 
confusion unless you *really* know what you're doing in Python.

Something like this would probably be best:
py> class BaseClass(object):
... def __init__(self, something='Dumb!'):
... self._something = something
... def _getsomething(self):
... return self._something
... something = property(_getsomething)
...
py> class SubClass(BaseClass):
... def _setsomething(self, something):
... self._something = something
... something = property(BaseClass._getsomething, _setsomething)
...
py> b = BaseClass()
py> b.something
'Dumb!'
py> b.something = 1
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: can't set attribute
py> s = SubClass()
py> s.something
'Dumb!'
py> s.something = 'Cool!'
py> s.something
'Cool!'
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multidimensional arrays - howto?

2005-02-14 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote:

> I am trying to convert some C code into python. Since i am new to
> python, i would like to know how to deal with multidimensional arrays?

http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list

might be helpful.

 



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


Re: Multidimensional arrays - howto?

2005-02-14 Thread Daniel Yoo
[EMAIL PROTECTED] wrote:
: Hello all,

: I am trying to convert some C code into python. Since i am new to
: python, i would like to know how to deal with multidimensional arrays?


Here you go:


http://python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list


Also, if your table is relatively sparse, you might even be able to
use a dictionary, because a 2-d array can be considered as a mapping
between (index1, index2) keys and its values.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multi threading in multi processor (computer)

2005-02-14 Thread Irmen de Jong
Leif K-Brooks wrote:
Irmen de Jong wrote:
the GIL must die.
I couldn't resist:
http://www.razorvine.net/img/GIL.jpg

Neither could I:
http://ecritters.biz/diegil.png
(In case it's not entirely obvious, the stick figure just slices the GIL 
into two pieces with his sword, causing its blood to splatter on the wall.)
Naah.
What about:
http://www.razorvine.net/img/killGIL.jpg
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance error in python 2.3.4???

2005-02-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> In trying to construct a good object model in a recent project of mine,
> I ran across the following peculiarity in python 2.3.4 (haven't tried
> any newer versions):
>
> Say you have a base class that has an attribute and an accessor
> function for that attribute (just a simple get).

(don't use getters and setters methods in Python; use bare attributes where
you can, and properties when you need to add logic)

> BUT!  If you implement the get function in the derived class it works
> fine
>
> This, to me, is completely wrong.

it works exactly as documented.

> I have worked up the following example to illustrate my point:
>
> First is the way I want to do it:
> ##
> bash-2.05b$ cat main.py
> class baseClass(object):
>__Something = "Dumb!"
>
>def getSomething( self ):
>return self.__Something
>
> class subClass(baseClass):
>def setSomething( self , aSomething ):
>self.__Something = aSomething
>
> anObject = subClass()
> anObject.setSomething("Cool!")
> print anObject.getSomething()
>
> bash-2.05b$ python main.py
> Dumb!
> ###
>
> Note that it prints "Dumb!" instead of "Cool!".

members that start with __ (two underscores) are private to the class, so
you're in fact working with two different attributes here.

see section 9.6 in the tutorial for more on this:

http://docs.python.org/tut/node11.html#SECTION001160

to fix your problem, rename the attribute.

 



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


Re: Python UPS / FedEx Shipping Module

2005-02-14 Thread Brad Clements
_
"Gabriel Cooper" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> >Are the modules just accessing the published apis for their webservices?

> Yes, they use the free API's that have always been freely available.
> They're just *Impossible* to find on either of UPS's OR FedEx's
> websites. It took me no less than an hour and likely more just to find
> the documentation pages on each site. As for putting them up on the web,
> I should be able to get them up by the end of the week.
>

If you downloaded  the documentation from UPS, please re-check your license
agreement for the documentation before posting the code. You might be in
violation of some terms and conditions. I say might, I do not know for
certain and am not hinting that you are violating anything.


I've been tracking through UPS for 4 years using their old crappy interface,
and a newer one, and now we've moved to the XML version. All of their
documents come with a click - through license agreement that probably
restricts you in some way. I haven't read them too closely, since I'm under
contract I say "yes" on behalf of my client. ;-)



-- 
Novell DeveloperNet Sysop #5



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


Re: [NewBie] Tut0r Thing

2005-02-14 Thread Daniel Yoo

: if you're talking about the "tutor at python.org" mailing list, it's a 
mailing list
: that you send mail to and get mails from, as explained on the tutor mailing
: list page:

:http://mail.python.org/mailman/listinfo/tutor


Hello,

Also, from the odd spelling of the subject line, I suspect that the
original poster thinks that we're some kind of cracking group.


I hope not, but just to make sure it's clear: when we in the Python
community talk about "hacking", we usually mean it in the constructive
sense: we like building software systems and helping people learn how
to program.

ESR has a good summary here:

http://www.catb.org/~esr/faqs/hacker-howto.html#what_is

I always feel silly about bringing this up, but it has to be said,
just to avoid any misunderstanding.


Best of wishes to you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Multidimensional arrays - howto?

2005-02-14 Thread doodle4
Hello all,

I am trying to convert some C code into python. Since i am new to
python, i would like to know how to deal with multidimensional arrays?

Thanks,
-Joe

Here's a snippet of what i am trying to convert:

# define table0 15
# define table1 20

unsigned int Table[table0][table1]

if(Table[table0][table1] != 0)
{
 Table[table0][table1]--
}

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


RE: parsing IMAP responses?

2005-02-14 Thread Tony Meyer
> Is there a library somewhere that impliments the IMAP protocol 
> syntax?

Twisted has pretty good IMAP support (particularly client), and it's much
higher level than imaplib.  It probably does what you're after.

Of course, the catch is that you have to use twisted <0.5 wink>.

=Tony.Meyer

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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, Steve Horsley 
<[EMAIL PROTECTED]> writes
Stephen Kellett wrote:
Who's "Guido"?
  LOL Falling off my chair!!
I think the expression you are looking for is ROFL!
:-) Yes, but with that I could've been standing up before ending up on 
the floor. I wrote it as I felt it!. Its a really good demonstration as 
to the depth of the research performed by Illias.

I'm waiting for the "Who's Matz?" comment in comp.lang.ruby
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


Inheritance error in python 2.3.4???

2005-02-14 Thread [EMAIL PROTECTED]
In trying to construct a good object model in a recent project of mine,
I ran across the following peculiarity in python 2.3.4 (haven't tried
any newer versions):

Say you have a base class that has an attribute and an accessor
function for that attribute (just a simple get).  Then you inherit that
base class to make a sub class and the subclass contains a "set"
function on that same attribute.  If you call the set function and give
it a value and then call the get function. it doesn't do what
you would expect instead of returning the value that was "set" it
instead returns the default value of the variable in the base class!!!

BUT!  If you implement the get function in the derived class it works
fine

This, to me, is completely wrong.

I have worked up the following example to illustrate my point:

First is the way I want to do it:
##
bash-2.05b$ cat main.py
class baseClass(object):
__Something = "Dumb!"

def getSomething( self ):
return self.__Something

class subClass(baseClass):
def setSomething( self , aSomething ):
self.__Something = aSomething


anObject = subClass()
anObject.setSomething("Cool!")
print anObject.getSomething()

bash-2.05b$ python main.py
Dumb!
###

Note that it prints "Dumb!" instead of "Cool!".

Now if I re-implement getSomething in the subclass it does this:

bash-2.05b$ cat main.py
class baseClass(object):
__Something = "Dumb!"

def getSomething( self ):
return self.__Something

class subClass(baseClass):
def setSomething( self , aSomething ):
self.__Something = aSomething

def getSomething( self ):
return self.__Something


anObject = subClass()
anObject.setSomething("Cool!")
print anObject.getSomething()

bash-2.05b$ python main.py
Cool!
###

Note that it now prints "Cool!" like it was supposed to in the first
place...

Hello?  Am I just being retarded?  To me the call to self.__Something =
aSomething should change THE ONLY instance of __Something to "Cool!".
Calling an inherited function shouldn't create a new instance of
__Something (which is what it has to be doing) and return that instead.

This is really going to cripple my object model if I have to
reimplement each one of these functions everytime!  The whole point was
to have a stable "implementation base" that captures a lot of the
common functionality between the different inherited classes... and
provides a "one stop shop" for modifying a lot of the behavior.  Also I
would have a lot less code because I would inherit functionality.

FYI - I am coming from a C++ background... where I do this kind of
thing often.

Someone please show me the pythonish way to do this!

Thanks!
Friedmud

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


Re: is there a safe marshaler?

2005-02-14 Thread Irmen de Jong
Well, ok, if you trust then other end then I think it's enough to just
authenticate all the pickles (say using hmac.py) without needing
something as heavyweight as SSL. 
An interesting idea that hadn't crossed my mind yet.
Pyro *does* already have connection authentication that uses md5
(and hmac since 3.5beta) with a shared secret, but after that,
the communication is done in plaintext so to speak.
If you use SSL you need something
like m2crypto since the SSL option in the socket module doesn't check
certificates, IIRC.
I'm using m2crypto for this kind of SSL, yes.
(sadly it has a bug in its API that is triggerd by the current
Pyro version on some platforms like Linux).
In fact, this is the reason why I started this thread.
I wanted to discover some possibilities to replace pickle
by another thing, so that Pyro becomes 'safe' at the wire
protocol level.
But further discussion on the Pyro mailing list sort of
made it clear that this is not desirable.

Why do you say it's not desirable?  Don't competing protocols like RMI
try to stay safe from malicious peers?  Why should I not want to
expose a Pyro service to the internet?  It's a natural thing to want
to do.
You should not want to expose a Pyro service to the internet because
Python doesn't have Java's security model and sandboxing, that are
used with RMI. Pyro has a few features that are very powerful
but also require the use of intrinsic insecure Python code (namely,
pickle, and marshal).
Just look at the recent security advisory about the XMLRPC server
that comes with Python it's much more primitive than Pyro is,
but even that one was insecure.
I wouldn't put a Java RMI server or xyz CORBA server or whatever
kind of unrestricted API open on the internet anyway.
Am I rational or paranoid?
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Ilias Lazaridis
[Sorry, I'm to tired to read more posts today. I'll try to answer to 
each message adressed to me tomorrow. Thank you for your time.]

-
I find this thread facinating.
I don't know wich of the posters in this thread belong to the python team.
Nearly no one community member gives simply some answers to this very 
simple questions.

Please summarize all the efforts the community has taken to write within 
this thread.

This sum of efforts should be enouth to setup a basic official MinGW 
compilation.

I have the strange feeling, that some people within the community and 
the team are not intrested in this.

-
copied from another answer:
"The Python Foundation could create an official sub-project to create an 
automated build target based on the MinGW toolchain. I am sure that many 
community members would be more than happy to contribute."

-
Let's see:
The process would be:
a) A Python Foundation official states: "of course we accept diversity 
and of course we are intrested that our source-code-base compiles 
directly with MinGW (and other compilers)".

b) the pyMinGW developer states: "I am intrested that my patches are 
included within the main python source code base" [of course this 
contribution would deserve to be mentioned somewhere]

c) One part of the Python Community states: "look those loosers, like to 
use MinGW toolkit - pah! I'll continue to use my super-optimizing, xx% 
faster results, less hassle Microsoft-Compiler"

d) One part of the Python Community states: "I'm very happy that my 
toolset of choice gets official support, to which I can contribute as a 
community member"

e) there is no point e. People start simply to cooperate, thus python's 
evolution is ensured.

-
I try to sleep after this communicational desaster here.
Good night to all.
.
--
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Ilias Lazaridis
Duncan Booth wrote:
Ilias Lazaridis wrote:
There is a OS-tool-chain supported on windows, cygwin. 
this depends on cygwin.dll, which is GPL licensed
[or am I wrong?]
It is GPL licensed with an amendment which prevents the GPL spreading to 
other open source software with which it is linked.

"In accordance with section 10 of the GPL, Red Hat, Inc. permits programs 
whose sources are distributed under a license that complies with the Open 
Source definition to be linked with libcygwin.a without libcygwin.a itself 
causing the resulting program to be covered by the GNU GPL."
If I understand this right, I cannot produce commercial software with 
the cygwin toolset.

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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Ilias Lazaridis
Stephen Kellett wrote:
In message <[EMAIL PROTECTED]>, Ilias Lazaridis 
<[EMAIL PROTECTED]> writes

I like to synchronize any efforts with the existing ones.
I assume the reason for doing that would be to avoid duplicating effort? 
[...] - (off-topic suggestions processing model)
Your suggestions were irrelevant to me.
Please avoid further off-topic posts.
.
--
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: parsing IMAP responses?

2005-02-14 Thread Grant Edwards
On 2005-02-14, Damien Wyart <[EMAIL PROTECTED]> wrote:
> * Grant Edwards <[EMAIL PROTECTED]> in comp.lang.python:
>> Is there a library somewhere that impliments the IMAP protocol syntax?
>
> Maybe the "core" part of getmail could be reused, it seems
> cleanly written.
> http://www.qcc.ca/~charlesc/software/getmail-4/

Thanks -- I'll take a look.

-- 
Grant Edwards   grante Yow!  Mary Tyler Moore's
  at   SEVENTH HUSBAND is wearing
   visi.commy DACRON TANK TOP in a
   cheap hotel in HONOLULU!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: nested lists as arrays

2005-02-14 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>def setRandomState(self):
>   # container for the elements to pick from
>   container = [1,2,3,4,5,6,7,8,-1]
>
>   # create elements of puzzle randomly
>   i = 0
>   j = 0
>   while i <= self.dim-1:
>   while j <= self.dim-1:
>   if len(container) > 0:
>   randomindex = random.randint(0,len(container)-1)
>   self.elements[j][i] = container[randomindex]
>   del container[randomindex]
>   j=j+1
>   else:
>   break
>   j=0
>   i=i+1

Without reading closely, I believe that the above can generate any possible 
position.  Are you aware that half are unsolvable?  If that matters, you 
need to either find a book or site that explains the parity test for 
solvability or generate the start position from the goal position by a 
series of random moves.

Terry J. Reedy




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


Re: array of bits?

2005-02-14 Thread MM
Thanks people. List it is. matthew.
--
http://mail.python.org/mailman/listinfo/python-list


Re: is there a safe marshaler?

2005-02-14 Thread Paul Rubin
Irmen de Jong <[EMAIL PROTECTED]> writes:
> > What do you do about the security issue if you're using pickle?  Do
> > you have to trust the other end to not send you malicious pickles?
> 
> I do nothing about it.
> Yes, you have to trust the other end.
> So you have to use your own -or Pyro's- authentication/authorization
> logic to make sure that the other end can be trusted.
> You could use SSL with certificates for instance.

Well, ok, if you trust then other end then I think it's enough to just
authenticate all the pickles (say using hmac.py) without needing
something as heavyweight as SSL.  If you use SSL you need something
like m2crypto since the SSL option in the socket module doesn't check
certificates, IIRC.

> In fact, this is the reason why I started this thread.
> I wanted to discover some possibilities to replace pickle
> by another thing, so that Pyro becomes 'safe' at the wire
> protocol level.
> But further discussion on the Pyro mailing list sort of
> made it clear that this is not desirable.

Why do you say it's not desirable?  Don't competing protocols like RMI
try to stay safe from malicious peers?  Why should I not want to
expose a Pyro service to the internet?  It's a natural thing to want
to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Delaney, Timothy C (Timothy)
Stephen Kellett wrote:

> In message <[EMAIL PROTECTED]>, Ilias Lazaridis
> <[EMAIL PROTECTED]> writes
>>>  And yet there is not one company that has someone devoted full-time
>>> to  developing Python. Not even Guido.
>> 
>> Who's "Guido"?
> 
> LOL Falling off my chair!!

See, the problem is that you have to go all the way to the second FAQ in
order to find out who Guido is. Obviously it needs to be more prominent
on the Python web site.

Oh - you mean Ilias didn't actually *read* anything on the Python web
site? My bad.

Illias - I'm assuming you are not a troll (despite the contrary
evidence) and am going to direct you to a site with all the answers you
need.

http://www.catb.org/~esr/faqs/smart-questions.html

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


Re: parsing IMAP responses?

2005-02-14 Thread Damien Wyart
* Grant Edwards <[EMAIL PROTECTED]> in comp.lang.python:
> Is there a library somewhere that impliments the IMAP protocol syntax?

Maybe the "core" part of getmail could be reused, it seems cleanly
written.
http://www.qcc.ca/~charlesc/software/getmail-4/

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


Re: Kill GIL (was Re: multi threading in multi processor (computer))

2005-02-14 Thread Paul Rubin
[EMAIL PROTECTED] (Aahz) writes:
> >[phr] The day is coming when even cheap computers have multiple cpu's.
> >See hyperthreading and the coming multi-core P4's, and the finally
> >announced Cell processor.
> >
> >Conclusion: the GIL must die.
> 
> It's not clear to what extent these processors will perform well with
> shared memory space.  One of the things I remember most about Bruce
> Eckel's discussions of Java and threading is just how broken Java's
> threading model is in certain respects when it comes to CPU caches
> failing to maintain cache coherency.

Um???  I'm not experienced with multiprocessors but I thought that
maintaining cache coherency was a requirement.  What's the deal?  If
coherency isn't maintained, is it really multiprocessing?

> It's always going to be true that getting fully scaled performance
> will require more CPUs with non-shared memory -- that's going to
> mean IPC with multiple processes instead of threads.

But unless you use shared memory, the context switch overhead from
IPC becomes a bad bottleneck.

See http://poshmodule.sourceforge.net/posh/html/node1.html
for an interesting scheme of working around the GIL by spreading
naturally multi-threaded applications into multiple processes
(using shared memory).  It would simplify things a lot if you could
just use threads.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there a safe marshaler?

2005-02-14 Thread Irmen de Jong
Paul Rubin wrote:
Yes, however, you can at least set the protocol level.  Marshal doesn't
give you that option.
That's right. So good for Pyro then :)
It works most of the time, even across different Python versions,
unless using mobile code.
What do you do about the security issue if you're using pickle?  Do
you have to trust the other end to not send you malicious pickles?
I do nothing about it.
Yes, you have to trust the other end.
So you have to use your own -or Pyro's- authentication/authorization
logic to make sure that the other end can be trusted.
You could use SSL with certificates for instance.
In fact, this is the reason why I started this thread.
I wanted to discover some possibilities to replace pickle
by another thing, so that Pyro becomes 'safe' at the wire
protocol level.
But further discussion on the Pyro mailing list sort of
made it clear that this is not desirable.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: Kill GIL

2005-02-14 Thread Aahz
In article <[EMAIL PROTECTED]>, Mike Meyer  <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] (Aahz) writes:
>>
>> (Have you
>> actually written any threaded applications in Python?)
>
>Yes. Have you ever asked a polite question?

Yes.  I just get a bit irritated with some of the standard lines that
people use.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Mike Meyer
Ilias Lazaridis <[EMAIL PROTECTED]> writes:
> If it is a programming language, the requirement "using an open-source
> toolchain" is a rational and valid one.

It is. However, mingW has nothing to do with "using an open-sourcer
toolchain".

Python runs in an environment with a full, open-source tool chain. You
can use it on Linux or any of the various BSDs. It also runs in an
environment where you can't have an open-source toolchain: Windows.

Once you've given up on an open-source environment, arguing about
trivia like which free compiler you are going to use is a waste of
time. Either use a real open-source environment, or live with the
closed-source tools/environment that someone is willing to support.

Or, of course, support the environment you want yourself.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing IMAP responses?

2005-02-14 Thread Fredrik Lundh
Grant Edwards wrote:

>>> Is there a library somewhere that impliments the IMAP protocol
>>> syntax?
>>
>> It's very messy.
>
> It sure is.  You'd think something intended to be machine-readable
> would be easier to parse.

nobody knows what the IMAP protocol designers intended...

(it's not quite as bad as Netscape's Mork format, but it's pretty close)

 



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


Re: tk resource file for geometry?

2005-02-14 Thread Fredrik Lundh
Gabriel B. wrote:

> i'm using almost every widget property from my pyTk programs in the
> form of resources, like:
>  self.tk.option_add ( "*InputClass*background", "White" )
>
> In the widget creation i have only the Class and the Command
> attribute, but i'm having to add some tk options to the geometry
> method, in the case, pack. Is there a way to overcome this?
>
> For example, every single Frame i pack i use
>  self.pack(fill='both', expand=1)
> I'd love to have something like:
>  self.tk.option_add ( "*Frame*fill", 'both' )
>  self.tk.option_add ( "*Frame*expand", 'yes' )
>
> Is there anything like it?

not that I'm aware of, but I might be missing something.  you might wish
to repost your question to the tkinter discuss mailing list:

http://mail.python.org/mailman/listinfo/tkinter-discuss
http://dir.gmane.org/gmane.comp.python.tkinter

 



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


Re: parsing IMAP responses?

2005-02-14 Thread Grant Edwards
On 2005-02-14, Paul Rubin  wrote:

>> Is there a library somewhere that impliments the IMAP protocol
>> syntax?
>
> It's very messy.

It sure is.  You'd think something intended to be
machine-readable would be easier to parse.

> I don't know of one that's in distribution.

That's what I thought based on my Google results, but I thought
I'd ask.

> I think there's one buried inside a certain commercial
> product.  I wrote one a while back that is currently
> inaccessible (disk crash, need to get it recovered) but it's
> not really useable.  IMAP syntax is very very messy. Are you
> trying to write an IMAP server?

No, I'm writing a client, and I was a bit surprised to find out
that imaplib doesn't really parse the responses at all. Since
I'm writing a client I only have to parse the responses to the
commands that I actually send, but it still a bit messy.

-- 
Grant Edwards   grante Yow!  I'm an East Side
  at   TYPE...
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Kill GIL

2005-02-14 Thread Mike Meyer
[EMAIL PROTECTED] (Aahz) writes:

> (Have you
> actually written any threaded applications in Python?)

Yes. Have you ever asked a polite question?

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Steve Horsley
Stephen Kellett wrote:
In message <[EMAIL PROTECTED]>, Ilias Lazaridis 
<[EMAIL PROTECTED]> writes

 And yet there is not one company that has someone devoted full-time 
to  developing Python. Not even Guido.

Who's "Guido"?

LOL Falling off my chair!!
I think the expression you are looking for is ROFL!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 unable to find module.

2005-02-14 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote:

> Python built and installed fine.  PyXML built and installed with no
> complaining but, when I give the commands below it cannot find the
> module.
>
> Obviously Iam missing somehting.  Do you have any suggestions where to
> look for "pathing", Security or permissions problems?

did you use the Python you just built when installing PyXML?  (if you used
a different version, PyXML was probably installed somewhere else)

try running

$ python -v -v -c "from xml.dom.ext.reader import Sax2"

and check that Python looks for the ext.reader where you expect it to be
(if you're not sure where PyXML installed itself, run the installation script
again and check the output carefully)

 



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


Re: [NewBie] Tut0r Thing

2005-02-14 Thread Fredrik Lundh
"administrata" wrote:

>I logged in.
>
> But, don't know how to use it.
>
> and What the hell is digest thing?
>
> Is Tutor Thing like i send questions to someone by e-mailing
>
> and get answers?

without any further details, your post makes very little sense.

if you're talking about the "tutor at python.org" mailing list, it's a mailing 
list
that you send mail to and get mails from, as explained on the tutor mailing
list page:

http://mail.python.org/mailman/listinfo/tutor

if you prefer alternative interfaces, use gmane:

http://dir.gmane.org/gmane.comp.python.tutor

 



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


Re: Iterator / Iteratable confusion

2005-02-14 Thread Scott David Daniels
Francis Girard wrote:
Le dimanche 13 FÃvrier 2005 23:58, Terry Reedy a Ãcrit :
Iterators are a subgroup of iterables.  Being able to say iter(it) without
having to worry about whether 'it' is just an iterable or already an
iterator is one of the nice features of the new iteration design.
I have difficulties to represent an iterator as a subspecie of an iteratable 
... One of the result of not distinguishing them is that, at some point in
your programming, you are not sure anymore if you have an iterator or an 
iteratable ; and you might very well end up calling "iter()" or "__iter__()" 
everywhere.
The point is _almost_, but not exactly unlike that.
Because the "for ... in ..." construct calls iter itself, you seldom
need (as a code user) to distinguish between iterators and iterables.
However, there will come a day when you see some code like:
first = True
for blunge in whatever:
if first:
first = False
else:
print 'and',
print blunge
And you think, "I can make that clearer," so you write:
source = iter(whatever)
print source.next()
for blunge in source:
print 'and', blunge
Because of how iterables work, you know you can do this locally
without looking all around to see what "whatever" is.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Python 2.4 unable to find module.

2005-02-14 Thread mfjacobs

Hello,
I was hoping someone here can help me with a problem I am having with
the PyXML extension ( ver 0.8.4) and Python 2.4
Thsi is a brand new build of Python.  Build with default .configre
options.

Python built and installed fine.  PyXML built and installed with no
complaining but, when I give the commands below it cannot find the
module.
Obviously Iam missing somehting.  Do you have any suggestions where to
look for "pathing", Security or permissions problems?

Thanks!

Python 2.4 (#1, Feb 14 2005, 12:27:33)
[GCC 3.2.2] on irix6
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> from xml.dom.ext.reader import Sax2
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named ext.reader
>>> ^D

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


Re: array of bits?

2005-02-14 Thread Fredrik Lundh
"MM" wrote:

> What is the best structure/way to create an array of bits (actually 
> true/false flags) of an 
> arbitrary length ranging from about 20 upto about 500. Speed of access more 
> of an issue than 
> compactness.
>
> eg:
> [0] 0
> [1] 0
> [2] 1
> [3] 0
> [4] 1
> ...
> [n] 0
> etc.

if you need a list of flags, use a list of flags:

[False] * 500

(compared to a bit array, you'll waste a whopping 31 bits per flag, but
unless you plan to use tens of thousands of lists, that shouldn't be much
of a problem)

 



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


Re: array of bits?

2005-02-14 Thread Paul Rubin
MM <[EMAIL PROTECTED]> writes:
> What is the best structure/way to create an array of bits (actually
> true/false flags) of an arbitrary length ranging from about 20 upto
> about 500. Speed of access more of an issue than compactness.

Use a normal list: [False, False, True, False, True, ... ] .
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >