Re: urllib2 on Windows Vista

2006-07-10 Thread Martin v. Löwis
Sriram Krishnan wrote:
> I'm running Python 2.4.3 on Windows Vista June CTP. I'm not able to
> open any site using the urllib2 and related family of modules

I think you need to break the error further down. Try httplib instead
of urllib, and see what connect does. Then break this down into socket
calls (reading the source of httplib.connect, and executing it manually
in single-stepping), so that you know what the precise arguments passed
to getaddrinfo are.

FWIW, 11001 is WSAHOST_NOT_FOUND, which suggests that you have
DNS configured incorrectly.

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


Re: threading troubles

2006-07-10 Thread [EMAIL PROTECTED]
sreekant wrote:
> Hi folks
>
> What am I doing wrong in the following? I just want to run fluidsynth in
> the background.

Others have pointed you at os.popen.  In non-crippled languages, use
processes (e.g. popen) when you wish to preserve the years of hard work
that OS designers put into protected memory.  Use threads only when you
know why you want to abandon such and share all memory.   95% or more
of the time when you're making the multiprocessing decision, threads
are the wrong choice.  5% (or less) of the time they're indispensable.
But if you're just looking for asychronous processing and don't know
why you need to abandon memory protection, go with processes.

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


Re: Accessors in Python (getters and setters)

2006-07-10 Thread ZeD
Bruno Desthuilliers wrote:

>> I decided to change the name of an attribute. Problem is I've used the
>> attribute in several places spanning thousands of lines of code. If I
>> had encapsulated the attribute via an accessor, I wouldn't need to do
>> an unreliable and tedious search and replace
> find and grep are usually mostly reliable for this kind of tasks.

you mean sed :)

sed 's/oldName/newName/g' oldFile > newFile

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


Re: What is a type error?

2006-07-10 Thread Marshall
Joachim Durchholz wrote:
> Marshall schrieb:
> > Joachim Durchholz wrote:
> >> Chris Smith schrieb:
> >>> For example, I wrote that example using variables of type int.  If we
> >>> were to suppose that we were actually working with variables of type
> >>> Person, then things get a little more complicated.  We would need a few
> >>> (infinite classes of) derived subtypes of Person that further constrain
> >>> the possible values for state.  For example, we'd need types like:
> >>>
> >>> Person{age:{18..29}}
> >>>
> >>> But this starts to look bad, because we used to have this nice
> >>> property called encapsulation.  To work around that, we'd need to
> >>> make one of a few choices: [...] (c) invent some kind of generic
> >>> constraint language so that constraints like this could be expressed
> >>> without exposing field names. [...] Choice (c), though, looks a
> >>> little daunting.
> >> That's not too difficult.
> >> Start with boolean expressions.
> >> If you need to check everything statically, add enough constraints that
> >> they become decidable.
> >
> > I'm not sure I understand. Could you elaborate?
>
> Preconditions/postconditions can express anything you want, and they are
> an absolutely natural extensions of what's commonly called a type
> (actually the more powerful type systems have quite a broad overlap with
> assertions).
> I'd essentially want to have an assertion language, with primitives for
> type expressions.

Now, I'm not fully up to speed on DBC. The contract specifications,
these are specified statically, but checked dynamically, is that
right? In other words, we can consider contracts in light of
inheritance, but the actual verification and checking happens
at runtime, yes?

Wouldn't it be possible to do them at compile time? (Although
this raises decidability issues.) Mightn't it also be possible to
leave it up to the programmer whether a given contract
was compile-time or runtime?

I've been wondering about this for a while.


Marshall

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


Python WSDL Generation Tools

2006-07-10 Thread Vedanta Barooah
Hello All,I am using Zolera SOAP Infrastructure (ZSI) to create SOAP services and I know to bind it with a WSDL proxy. Are there any wsdl generation tools avaible in python?
Thanks for any links and pointersRegards,
Vedanta
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: language design question

2006-07-10 Thread Bryan
Fredrik Lundh wrote:
> Bryan wrote:
> 
>> could you get the same result by putting these methods in base
>  > class object that everything subclasses?
> 
> and how do you make sure that everything subclasses this base class ?
> 
> 
> 

in this hypothetical case, i was assuming len() would be put in object and 
every 
class subclasses object implicitly or explicitly (ie, new style classes only). 
if it was done that way, would len(obj) == obj.len() in all cases?


bryn


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


Re: how to match u'\uff00' - u'\uff0f' in re module?

2006-07-10 Thread yichao.zhang
MacDonald
Thanks!

John
Now I know how silly a question that is !
However I'll be not so silly thanks to your help !
I'll follow your suggestions! That's very nice.

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


Re: What is a type error?

2006-07-10 Thread Chris Smith
David Hopwood <[EMAIL PROTECTED]> wrote:
> Maybe I'm not understanding what you mean by "complete". Of course any
> type system of this expressive power will be incomplete (whether or not
> it can express conditions 3 to 5), in the sense that it cannot prove all
> true assertions about the types of expressions.

Ah.  I meant complete enough to accomplish the goal in this subthread, 
which was to ensure that the compiler knows when a particular int 
variable is guaranteed to be greater than 18, and when it is not.

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is a type error?

2006-07-10 Thread Marshall
David Hopwood wrote:
> Jürgen Exner wrote:
> > David Hopwood wrote:
> > [...]
> >
> > There is no such error message listed in 'perldoc perldiag'.
> > Please quote the actual text of your error message and include the program
> > that produced this error.
> > Then people here in CLPM may be able to assist you.
>
> Yes, I'm well aware that most of this thread has been off-topic for c.l.p.m,
> but it is no less off-topic for the other groups (except possibly 
> c.l.functional),
> and I can't trim the Newsgroups line down to nothing.
>
> Don't you have a newsreader that can mark whole threads that you don't want
> to read?

Sure, or he could just skip over it. Or he could make a simple
request, such as "please trim comp.lang.whatever because it's
off-topic here." But he hasn't done any of these, choosing instead
to drop in with his occasional pointless snarky comments.


Marshall

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


Re: 3d simulation

2006-07-10 Thread placid

Erik Max Francis wrote:
> alimoe wrote:
>
> >> Genetic Programming or Genetic Algorithms?
> >
> > whats the difference?
>
> Genetic algorithms usually involve the manipulation of bit strings.

Where bit strings is the the "dna" and each bit in the string
represents some value

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


Re: 3d simulation

2006-07-10 Thread Erik Max Francis
alimoe wrote:

>> Genetic Programming or Genetic Algorithms?
> 
> whats the difference?

Genetic algorithms usually involve the manipulation of bit strings. 
Genetic programming usually involves more program-like constructs, such 
as Lisp s-expressions.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Most men do not mature, they simply grow taller.
-- Leo Rosten
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to match u'\uff00' - u'\uff0f' in re module?

2006-07-10 Thread John Machin
On 11/07/2006 12:32 PM, yichao.zhang wrote:
> I'm trying to match the characters from u'\uff00' to u'\uff0f'.
> the code below and get a TypeError.
> p = re.compile(u'\uff00'-u'\uff0f')

That is not a valid regex. It is an attempt to subtract one unicode char 
from another, but this is (correctly) not supported, as the error 
message says. re.compile expects a string (8-bit or Unicode).

If you wanted to match ASCII characters from 'A' to 'Z', you wouldn't 
put re.compile('A'-'Z'), would you? Well I hope not, I hope you would 
use re.compile('[A-Z]') -- does that give you a clue?

> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: unsupported operand type(s) for -: 'unicode' and 'unicode'
> 
> 
> so re module does NOT support this operation

Incorrect conclusion. The argument that you attempted to supply is not a 
valid expression and thus not a valid argument for *any* function. It 
was intercepted before it got to re.compile. re.compile is innocent.

> however, is there any alternative way to solve my problem?
> 
> Any comments/suggestions much appreciated!

1. Read the fantastic manual.
2. Learn to understand error messages.
3. Assume the most plausible cause (you stuffed up, not the people who 
worked on the re module).

HTH,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to match u'\uff00' - u'\uff0f' in re module?

2006-07-10 Thread MacDonald

yichao.zhang wrote:
> I'm trying to match the characters from u'\uff00' to u'\uff0f'.
> the code below and get a TypeError.
> p = re.compile(u'\uff00'-u'\uff0f')
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: unsupported operand type(s) for -: 'unicode' and 'unicode'
>
>
> so re module does NOT support this operation
> however, is there any alternative way to solve my problem?
>
> Any comments/suggestions much appreciated!

re DOES work with unicode, you're just subtracting two unicode stings
as the agrument, which is not defined. Try this:

p = re.compile(u'[\uff00-\uff0f]')

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


Re: 3d simulation

2006-07-10 Thread Carl Banks
alimoe wrote:
> I am interested in coding an app which uses physics and 3d and neural
> nets and genetics. Any pointers?

PyODE for the physics part.


Carl Banks

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


how to match u'\uff00' - u'\uff0f' in re module?

2006-07-10 Thread yichao.zhang
I'm trying to match the characters from u'\uff00' to u'\uff0f'.
the code below and get a TypeError.
p = re.compile(u'\uff00'-u'\uff0f')
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: unsupported operand type(s) for -: 'unicode' and 'unicode'


so re module does NOT support this operation
however, is there any alternative way to solve my problem?

Any comments/suggestions much appreciated!

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


Re: What is a type error?

2006-07-10 Thread David Hopwood
Jürgen Exner wrote:
> David Hopwood wrote:
> [...]
> 
> There is no such error message listed in 'perldoc perldiag'.
> Please quote the actual text of your error message and include the program 
> that produced this error.
> Then people here in CLPM may be able to assist you.

Yes, I'm well aware that most of this thread has been off-topic for c.l.p.m,
but it is no less off-topic for the other groups (except possibly 
c.l.functional),
and I can't trim the Newsgroups line down to nothing.

Don't you have a newsreader that can mark whole threads that you don't want
to read?

-- 
David Hopwood <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is a type error?

2006-07-10 Thread David Hopwood
Chris Smith wrote:
> David Hopwood <[EMAIL PROTECTED]> wrote:
> 
>>1 and 2 are easy enough. 3 to 5 are best expressed as assertions rather
>>than types.
> 
> One of us is missing the other's meaning here.  If 3 to 5 were expressed 
> as assertions rather than types, then the type system would become 
> incomplete, requiring frequent runtime-checked type ascriptions to 
> prevent it from becoming impossible to write software.  That's not my 
> idea of a usable language.

Maybe I'm not understanding what you mean by "complete". Of course any
type system of this expressive power will be incomplete (whether or not
it can express conditions 3 to 5), in the sense that it cannot prove all
true assertions about the types of expressions.

So yes, some assertions would need to be checked at runtime (others could be
proven to always hold by a theorem prover).

Why is this a problem? The goal is not to check everything at compile time;
the goal is just to support writing correct programs.

-- 
David Hopwood <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 3d simulation

2006-07-10 Thread placid

alimoe wrote:
> I will create a "robot" that crawls over terrain that looks like the
> picture here:
>
> http://pygp.sourceforge.net/index.php3?name=runs

is this a real robot or a computer simulation?

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


Re: 3d simulation

2006-07-10 Thread placid

alimoe wrote:
> > Genetic Programming or Genetic Algorithms?
>
> whats the difference?


Genetic Programming:
is an automated methodology inspired by biological evolution to find
computer programs that best perform a user-defined task.

http://en.wikipedia.org/wiki/Genetic_Programming

Genetic Algorithms: search technique used in computer science to find
approximate solutions to optimization and search problems.

http://en.wikipedia.org/wiki/Genetic_algorithms

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


Re: What is a type error?

2006-07-10 Thread Chris Smith
David Hopwood <[EMAIL PROTECTED]> wrote:
> 1 and 2 are easy enough. 3 to 5 are best expressed as assertions rather
> than types.

One of us is missing the other's meaning here.  If 3 to 5 were expressed 
as assertions rather than types, then the type system would become 
incomplete, requiring frequent runtime-checked type ascriptions to 
prevent it from becoming impossible to write software.  That's not my 
idea of a usable language.

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is a type error?

2006-07-10 Thread J�rgen Exner
David Hopwood wrote:
[...]

There is no such error message listed in 'perldoc perldiag'.
Please quote the actual text of your error message and include the program 
that produced this error.
Then people here in CLPM may be able to assist you.

jue 


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


Re: 3d simulation

2006-07-10 Thread alimoe
I will create a "robot" that crawls over terrain that looks like the
picture here:

http://pygp.sourceforge.net/index.php3?name=runs

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


Re: 3d simulation

2006-07-10 Thread alimoe

> Genetic Programming or Genetic Algorithms?

whats the difference?

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


Re: What is a type error?

2006-07-10 Thread David Hopwood
Chris Smith wrote:
> At the same time, though, maybe I do want 
> the compiler to infer that tax cannot be negative (or maybe it can; I'm 
> not an accountant; I know my tax has never been negative), [...]

Tax can be negative, e.g. when a business is claiming back VAT (sales tax)
on its purchases, but the things it is selling have lower-rated or zero
VAT (or it is making a loss).

> Note that even without encapsulation, the kind of typing information 
> we're looking at can be very non-trivial in an imperative language.  For 
> example, I may need to express a method signature that is kind of like 
> this:
> 
> 1. The first parameter is an int, which is either between 4 and 8, or 
> between 11 and 17.
> 
> 2. The second parameter is a pointer to an object, whose 'foo' field is 
> an int between 0 and 5, and whose 'bar' field is a pointer to another 
> object with three fields 'a', 'b', and 'c', each of which has the full 
> range of an unconstrained IEEE double precision floating point number.
> 
> 3. After the method returns, it will be known that if this object 
> previously had its 'baz' field in the range m .. n, it is now in the 
> range (m - 5) .. (n + 1).
> 
> 4. After the method returns, it will be known that the object reached by 
> following the 'bar' field of the second parameter will be modified so 
> that the first two of its floating point numbers are guaranteed to be of 
> the opposite sign as they were before, and that if they were infinity, 
> they are now finite.
> 
> 5. After the method returns, the object referred to by the global 
> variable 'zab' has 0 as the value of its 'c' field.
> 
> Just expressing all of that in a method signature looks interesting 
> enough.  If we start adding abstraction to the type constraints on 
> objects to support encapsulation (as I think you'd have to do), then 
> things get even more interesting.

1 and 2 are easy enough. 3 to 5 are best expressed as assertions rather
than types.

-- 
David Hopwood <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is a type error?

2006-07-10 Thread David Hopwood
Chris Smith wrote:
> I <[EMAIL PROTECTED]> wrote:
> 
>>Incidentally, I'm not saying that such a feature would be a good idea.

I don't think it would be a bad idea. Silently giving incorrect results
on arithmetic overflow, as C-family languages do, is certainly a bad idea.
A type system that supported range type arithmetic as you've described would
have considerable advantages, especially in areas such as safety-critical
software. It would be a possible improvement to Ada, which UUIC currently
has a more restrictive range typing system that cannot infer different
ranges for a variable at different points in the program.

I find that regardless of programming language, relatively few of my
integer variables are dimensionless -- most are associated with some
specific unit. Currently, I find variable naming conventions helpful in
documenting this, but the result is probably more verbose than it would
be to drop this information from the names, and instead use more
precise types that indicate the unit and the range.

When prototyping, you could alias all of these to bignum types (with
range [0..+infinity) or (-infinity..+infinity)) to avoid needing to deal
with any type errors, and then constrain them where necessary later.

>>It generally isn't provided in languages specifically because it gets to 
>>be a big pain to maintain all of the type specifications for this kind 
>>of stuff.

It would take a little more work to write a program, but it would be no
more difficult to read (easier if you're also trying to verify its correctness).
Ease of reading programs is more important than writing.

> There are other good reasons, too, as it turns out.  I don't want to 
> overstate the "possible" until it starts to sound like "easy, even if 
> it's a pain".  This kind of stuff is rarely done in mainstream 
> programming languages because it has serious negative consequences.
> 
> For example, I wrote that example using variables of type int.  If we 
> were to suppose that we were actually working with variables of type 
> Person, then things get a little more complicated.  We would need a few 
> (infinite classes of) derived subtypes of Person that further constrain 
> the possible values for state.  For example, we'd need types like:
> 
> Person{age:{18..29}}
> 
> But this starts to look bad, because we used to have this nice property 
> called encapsulation.

I think you're assuming that 'age' would have to refer to a concrete field.
If it refers to a type parameter, something like:

  class Person{age:Age} is
 Age getAge()
  end

then I don't see how this breaks encapsulation.

-- 
David Hopwood <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Full splitting of a file's pathname

2006-07-10 Thread Simon Forman
BartlebyScrivener wrote:
> I don't know if it's "standard," but why not just:
>
> dir = './foo/bar/moo/lar/myfile.txt'
> dir.split('/')
>
> ['.', 'foo', 'bar', 'moo', 'lar', 'myfile.txt']
>
> rd

There's also os.path.sep, from the docs: "The character used by the
operating system to separate pathname components."
But a recursive function like the one Iain King posted is likely the
best way to go.

~Simon

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


Re: 3d simulation

2006-07-10 Thread placid

alimoe wrote:
> I am interested in coding an app which uses physics and 3d and neural
> nets and genetics. Any pointers?


Open GL Python programming

http://www.google.com/search?hl=en&rls=GGGL,GGGL:2006-22,GGGL:en&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=opengl+python&spell=1
http://pyopengl.sourceforge.net/

Neural Nets

http://www.google.com/search?hl=en&lr=&rls=GGGL%2CGGGL%3A2006-22%2CGGGL%3Aen&q=neural+nets+python&btnG=Search

Genetic Programming or Genetic Algorithms?

http://sourceforge.net/projects/pygp/


--Cheers

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


Re: help a newbie with a IDE/book combination

2006-07-10 Thread Don Taylor
kilnhead wrote:

> I have used spe and pyscripter on windows. I currently use Eclipse and
> this it is the best of the lot in terms of functionality. However, it
> does take some effort to get comfortable with. I only wish it had a GUI
> builder for python.
>
I have found that wxGlade plays nicely with Eclipse/Pydev extensions. 
Eclipse recognizes when wxGlade modifies a .py file and reloads it if 
you have it open for editing.  The Pydev debugger works (for me) with 
wxGlade (wxPython) applications.

wxGlade does not try to impose a project file structure so Eclipse can 
manage all of the files, just create wxGlade's files in the Eclipse 
project folder and refresh the project to get Eclipse to recognise them.

I have not tried it but I think that you can launch wxGlade from within 
Eclipse as an 'External Tool'.  I find it easy enough just to have both 
Eclipse and wxGlade running at the same time.


Don.


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


3d simulation

2006-07-10 Thread alimoe
I am interested in coding an app which uses physics and 3d and neural
nets and genetics. Any pointers?

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


Re: Global "except" condition

2006-07-10 Thread Simon Forman
Ernesto wrote:
> Within the scope of one Python file (say myFile.py), I'd like to print
> a message on ANY exception that occurs in THAT file, dependent on a
> condition.
>
> Here's the pseudocode:
>
> if anyExceptionOccurs():
>   if myCondition:
> print "Here's my global exception message"
>
>
> Is this functionality possible in python?  If so, how?

Either wrap all your module level code in a try:.. except:.. statement,
or you can replace the sys.excepthook() function with your own custom
function (see http://docs.python.org/lib/module-sys.html)  but that
would then be called for all uncaught exceptions, even those that were
raised from modules other than your myFile.py.

HTH,
~Simon

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


Re: mod_python fails to load under wamp

2006-07-10 Thread Luis M. González
Gaurav Agarwal wrote:
> Hi,
>
> Am using WAMP5 and python 2.4.3. I tried to install mod_python 3.2.5
> for python2.4. When i tried starting wamp, Firstly there was no error
> message in the apache error log. I saw error message in windows event
> viewer :
>
> "The Apache service named Apache.exe reported the following error:
> >>> Syntax error on line 194 of c:/wamp/apache/conf/httpd.conf: <<<
>  before the error.log file could be opened.
>
> "The Apache service named Apache.exe reported the following error:
> >>> Cannot load c:/wamp/apache/modules/mod_python.so into server: (126) The 
> >>> specified module could not be found: <<<
>  before the error.log file could be opened."
>
> I tried searching the net and found this
> http://www.modpython.org/FAQ/faqw.py?req=all#2.10 but i don't have
> depends.exe. if somebody has faced this problem before, can you please
> assist in fixing this bug..

I'm not an expert in the subject, but I have experienced many troubles
in the past while installing and configuring apache and mod_python...
It is important to know that each version of apache may match or not a
given version of mod_python, so make sure to install the correct
versions of each component.
Right now, I'm running on windows the following versions:

Apache/2.0.55 (Win32)
mod_python/3.2.8
Python/2.4.2

I installed "xampp" which is a single application that installs all at
once (Apache, php, mysql, etc...) except mod_python, which should be
installed separately.

I suggest you search the download files on Xampp's sourceforge site and
look for an older version with Apache 2.0.55 . I'm not sure, but I
think xampp version 1.5.1 will be ok
(http://sourceforge.net/project/showfiles.php?group_id=61776)

Then, get the mod_python installer (version 3.2.8)
http://www.apache.org/dist/httpd/modpython/win/3.2.8/

After that, all you have to do is a few modifications in Apache
httpd.config file.
Uncomment (or add) the following line:

LoadModule python_module modules/mod_python.so

And finally, if you want, you can set the configurations of the
handler's you want to use with mod_python (they can be publisher, psp,
or any other custom one).
These configurations can be set on this file, or separately on each web
folder as .htaccess files.

Hope it helps...
Luis

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


Global "except" condition

2006-07-10 Thread Ernesto
Within the scope of one Python file (say myFile.py), I'd like to print
a message on ANY exception that occurs in THAT file, dependent on a
condition.

Here's the pseudocode:

if anyExceptionOccurs():
  if myCondition:
print "Here's my global exception message"


Is this functionality possible in python?  If so, how?

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


Re: simulate enumerate in python 2.1

2006-07-10 Thread John Machin
On 11/07/2006 2:30 AM, [EMAIL PROTECTED] wrote:
> hi,
> i am using python 2.1. Can i use the code below to simulate the
> enumerate() function in 2.3?

I'm bemused, boggled and bamboozled -- and that's just *one* letter of 
the alphabet ...

You are using Python 2.1, and you felt it necessary to ask on the 
newsgroup if it could be done instead of trying it out??? You would have 
found out after typing only one line that you were barking up the wrong 
  tree:

Python 2.1.3 (#35, Apr  8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
 >>> from __future__ import generators
   File "", line 1
SyntaxError: future feature generators is not defined

> If not, how to simulate in 2.1?
> thanks
> 
> from __future__ import generators
> def enumerate(sequence):
> index = 0
> for item in sequence:
> yield index, item
> index += 1
> 

Something like this:

 >>> class enumerate:
... def __init__(self, seq):
... self.seq = seq
... def __getitem__(self, inx):
... return inx, self.seq[inx]
...
 >>> alist = [9,8,7]
 >>> for i, item in enumerate(alist):
...print i, item
...
0 9
1 8
2 7
# lookin' good
 >>> list(enumerate('qwerty'))
Traceback (most recent call last):
   File "", line 1, in ?
AttributeError: enumerate instance has no attribute '__len__'
# uh-oh
 >>> def patchit(self):
... return len(self.seq)
...
 >>> enumerate.__len__ = patchit
 >>> list(enumerate('qwerty'))
[(0, 'q'), (1, 'w'), (2, 'e'), (3, 'r'), (4, 't'), (5, 'y')]
# lookin' better

There may be other details needed to complete the fake-up job, ... over 
to you.

HTH,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: function that modifies a string

2006-07-10 Thread Steven D'Aprano
On Mon, 10 Jul 2006 19:30:09 +0200, Diez B. Roggisch wrote:

[snip]
 
> So: Yes, mutable strings are dangerous. 

I'm sorry, perhaps I'm being slow today, but just why are they dangerous?
More dangerous than, say, mutable lists and mutable dicts? Unless I'm
missing something, the worst that can happen is that people will write
inefficient code, and they'll be caught out by the same sort of things
that surprise newbies about lists. E.g. using a list as a default value
in function definitions.


> Use them only when their benefits outweigh their risks.

That goes without saying :)


-- 
Steven.

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


Re: About __files

2006-07-10 Thread Fredrik Lundh
venkat pathy wrote:

>   I came across a series of functions starting with "__". For 
> example, __fun() . May I know what are all these functions ?
>  I came across __init__ like functions starting and ending with "__".
> Whether they are constructors which are overloaded ?

reading the documentation might be helpful:

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



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


Re: Tkinter binding and keyboard hardware settings (WinXP)

2006-07-10 Thread Claudio Grondi
[EMAIL PROTECTED] wrote:
> Hello,
> 
> I have created a simple canvas in Tkinter to display a number of
> PhotoImages, I then bind a key (in my case, ) to start a loop that
> plays through a list of PhotoImages to make it an animation of sorts.
> What I noticed is, after holding down the key for a certain time, it
> would not loop through all 6 animations, instead it would just go
> through the first 2 and reset it self. I changed the key bind to
> Button-1 and did not encounter this problem. I then went into my
> keyboard hardware settings and changed the repeat rate to the longest
> delay and the repeat delay to the longest delay. This improved it some
> what, but I don't think it is practical to do this everytime I start up
> the program. My question is, is there a way to bind a key so as to make
> it ignore the keyboard's delay and repeat rate settings? Here's the
> code just so you can get an idea:
> 
> # GIF Animation Test
> 
> from Tkinter import *
> from time import sleep
> 
> class GIF:
> def __init__(self, root):
> self.root = root
> self.canvas = Canvas(root, bg="white", width=225, height=200)
> self.canvas.pack()
> self.cronoUpImageList =[
>  "cronoup1.gif", "cronoup2.gif", "cronoup3.gif",
>  "cronoup4.gif", "cronoup5.gif", "cronoup6.gif"]
> self.gifImage = PhotoImage(file=self.cronoUpImageList[0])
> self.cronoDefUp = PhotoImage(file="cronodefup.gif")
> self.drawImage = self.canvas.create_image(112.5, 100, image=
>   self.cronoDefUp)
> self.canvas.bind("", self.keyboardPrsUp)
> self.canvas.bind("", self.keyboardRlsUp)
> 
> def keyboardPrsUp(self, event):

   currentTime = ...
   if( currentTime - self.timeOfLastKeyPush < self.minDelay):
 pass
   else:
 self.timeOfLastKeyPush = currentTime
 ...

> self.canvas.delete(self.drawImage)
> self.counter = 0
> self.killEvent = False
> while self.killEvent != True:
> print self.cronoUpImageList[self.counter]
> self.gifImage =
> PhotoImage(file=self.cronoUpImageList[self.counter])
> self.drawImage = self.canvas.create_image(112.5, 100,
> image=
>   self.gifImage)
> self.counter = self.counter + 1
> if self.counter > 5:
> self.counter = 0
> self.canvas.update()
> sleep(.05)
> 
> 
> def keyboardRlsUp(self, event):
> self.counter = 0
> self.killEvent = True
> self.canvas.delete(self.drawImage)
> self.drawImage = self.canvas.create_image(112.5, 100, image=
>   self.cronoDefUp)
> 
> 
> root = Tk()
> root.title("GIF Animation Test")
> app = GIF(root)
> root.mainloop()
> 

What about simple tracking of time (see above NOT tested rough draft) in 
the keyboardPrsUp and keyboardRlsUp functions, so, that events raised 
earlier than after a specified delay period will just become ignored?

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


Python setup script problem

2006-07-10 Thread John Ling
Hello, I have been trying to install an application which requires Python:
http://chip.dfci.harvard.edu/~wli/MAT/

My environment is AIX 5.2.  Below is the section of the setup that has 
failed, which BTW works fine on Fedora 5.
I suspect it has to do with Python on AIX and/or the setup.py script. 
Has anyone experienced this before?

MAT-2.04182006> python setup.py install
Found make and swig.
make -C AffyFileParser clean
make[1]: Entering directory 
`/flash/home/jling/dl/MAT-2.04182006/src/AffyFileParser'
rm -f extension/*
make[1]: Leaving directory 
`/flash/home/jling/dl/MAT-2.04182006/src/AffyFileParser'
make -C gaussian clean
make[1]: Entering directory 
`/flash/home/jling/dl/MAT-2.04182006/src/gaussian'
rm -f extension/*
make[1]: Leaving directory 
`/flash/home/jling/dl/MAT-2.04182006/src/gaussian'
make -C AffyFileParser all
make[1]: Entering directory 
`/flash/home/jling/dl/MAT-2.04182006/src/AffyFileParser'
swig -c++ -python -Iaffymetrix -Iswig -o 
extension/AffyFileParser_wrap.cpp swig/AffyFileParser.i
affymetrix/TagValuePair.h:45: Warning(362): operator= ignored
affymetrix/CHPFileData.h:72: Warning(362): operator= ignored
affymetrix/CHPFileData.h:406: Warning(362): operator= ignored
affymetrix/CHPFileData.h:466: Warning(362): operator= ignored
affymetrix/CHPFileData.h:499: Warning(362): operator= ignored
cp python/* extension
make[1]: Leaving directory 
`/flash/home/jling/dl/MAT-2.04182006/src/AffyFileParser'
make -C gaussian all
make[1]: Entering directory 
`/flash/home/jling/dl/MAT-2.04182006/src/gaussian'
swig -c++ -python -Igsl -Iswig -o extension/gaussian_wrap.cpp 
swig/gaussian.i
cp python/* extension
make[1]: Leaving directory 
`/flash/home/jling/dl/MAT-2.04182006/src/gaussian'
running install
running build
running build_py
copying src/MAT/AffyFileParser.py -> build/lib.aix-5.2-2.4/MAT
copying src/MAT/gaussian.py -> build/lib.aix-5.2-2.4/MAT
running build_ext
building '_gaussian' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall 
-Wstrict-prototypes -Isrc/gaussian/gsl -I/usr/local/include/python2.4 -c 
src/gaussian/extension/gaussian_wrap.cpp -o 
build/temp.aix-5.2-2.4/src/gaussian/extension/gaussian_wrap.o
In file included from /usr/local/include/python2.4/Python.h:8,
  from src/gaussian/extension/gaussian_wrap.cpp:129:
/usr/local/include/python2.4/pyconfig.h:844:1: warning: "_XOPEN_SOURCE" 
redefined
:4:1: warning: this is the location of the previous definition
c++ gcc -pthread -bI:/usr/local/lib/python2.4/config/python.exp 
build/temp.aix-5.2-2.4/src/gaussian/gsl/gauss.o 
build/temp.aix-5.2-2.4/src/gaussian/gsl/gaussinv.o 
build/temp.aix-5.2-2.4/src/gaussian/extension/gaussian_wrap.o -o 
build/lib.aix-5.2-2.4/MAT/_gaussian.so
c++: `-b' must come at the start of the command line
error: command 'c++' failed with exit status 1


Much Appreciated,

-- 
John Ling
Software developer, UBC Bioinformatics Centre & UBC Proteomics Centre
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto or Tutorial for tokenize module for a newbie?

2006-07-10 Thread John J. Lee
"TY" <[EMAIL PROTECTED]> writes:

> Can someone point me to a Howto or Tutorial for tokenize module for a
> newbie?  I read the documentation but it doesn't have a lot of info...

Here's a simple example:

http://groups.google.com/group/comp.lang.python/msg/e84e36ad10d78303


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


syslog best practices -- when to call closelog?

2006-07-10 Thread J Rice

I have a question:

When should syslog.closelog() be called?  I have a daemon that spends
most of its time asleep and quiet, but writes messages to the mail log
when active.  Should I open the log at the start and keep it open until
the program closes?  This seems much simpler than issuing three
commands everytime I want to write to the log.

The program will essentially be running constantly.  Is having the log
constantly "open" a problem?  What happens if the program crashes or is
killed without a closelog()?  

Jeff

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


Tkinter binding and keyboard hardware settings (WinXP)

2006-07-10 Thread apriebe47
Hello,

I have created a simple canvas in Tkinter to display a number of
PhotoImages, I then bind a key (in my case, ) to start a loop that
plays through a list of PhotoImages to make it an animation of sorts.
What I noticed is, after holding down the key for a certain time, it
would not loop through all 6 animations, instead it would just go
through the first 2 and reset it self. I changed the key bind to
Button-1 and did not encounter this problem. I then went into my
keyboard hardware settings and changed the repeat rate to the longest
delay and the repeat delay to the longest delay. This improved it some
what, but I don't think it is practical to do this everytime I start up
the program. My question is, is there a way to bind a key so as to make
it ignore the keyboard's delay and repeat rate settings? Here's the
code just so you can get an idea:

# GIF Animation Test

from Tkinter import *
from time import sleep

class GIF:
def __init__(self, root):
self.root = root
self.canvas = Canvas(root, bg="white", width=225, height=200)
self.canvas.pack()
self.cronoUpImageList =[
 "cronoup1.gif", "cronoup2.gif", "cronoup3.gif",
 "cronoup4.gif", "cronoup5.gif", "cronoup6.gif"]
self.gifImage = PhotoImage(file=self.cronoUpImageList[0])
self.cronoDefUp = PhotoImage(file="cronodefup.gif")
self.drawImage = self.canvas.create_image(112.5, 100, image=
  self.cronoDefUp)
self.canvas.bind("", self.keyboardPrsUp)
self.canvas.bind("", self.keyboardRlsUp)

def keyboardPrsUp(self, event):
self.canvas.delete(self.drawImage)
self.counter = 0
self.killEvent = False
while self.killEvent != True:
print self.cronoUpImageList[self.counter]
self.gifImage =
PhotoImage(file=self.cronoUpImageList[self.counter])
self.drawImage = self.canvas.create_image(112.5, 100,
image=
  self.gifImage)
self.counter = self.counter + 1
if self.counter > 5:
self.counter = 0
self.canvas.update()
sleep(.05)


def keyboardRlsUp(self, event):
self.counter = 0
self.killEvent = True
self.canvas.delete(self.drawImage)
self.drawImage = self.canvas.create_image(112.5, 100, image=
  self.cronoDefUp)


root = Tk()
root.title("GIF Animation Test")
app = GIF(root)
root.mainloop()

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


Re: Restricted Access

2006-07-10 Thread iapain
Tim Chase wrote:
> If you're prepared for the massive breakage that will ensue, you can
>
>   chmod go-rwx /usr/lib/python2.3/os.*

No, I cant change permission or delete the module, the best would be
something to detect 'import os' in user code .. but If i go with chroot
jail approch then everything will be like what i want. But chroot jail
approch would take much space on webserver, what would happen if number
of users are large.

> Another alternative might just be to copy the python
> libraries to some place in the user's homedir (whatever their
> original library path was), revoke execute non-user execute privs
> from the python executable ("chmod go-x `which python`), and then
> change python to be a script that runs something like "chroot
> $HOME/ python $@".  Allow per-user access to this script via sudo.

Its having the same problem. The idea on which i am working is a
webide(which i already created) and a user file system(on which i am
working now) so that each user can access python globally and files
from his own folder, without adding them in unix user list. 

Best!

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


Re: xml aggregator

2006-07-10 Thread Fredrik Lundh
kepioo wrote:
> Hi all,
> 
> I am trying to write an xml aggregator, but so far, i've been failing
> miserably.
> 
> what i want to do :
> 
> i have entries, in a list format :[[key1,value],[key2,value],[
> key3,value]], value]
> 
> example :
> [["route","23"],["equip","jr2"],["time","3pm"]],"my first value"]
>  [["route","23"],["equip","jr1"],["time","3pm"]],"my second value"]
>  [["route","23"],["equip","jr2"],["time","3pm"]],"my third value"]
>  [["route","24"],["equip","jr2"],["time","3pm"]],"my fourth value"]
>  [["route","25"],["equip","jr2"],["time","3pm"]],'"my fifth value"]
> 
>   the tree i want in the end would be :

assuming that the actual order of the subelements doesn't matter, you 
could simply sort the array, and use groupby to group related tags:

import elementtree.ElementTree as ET
import itertools, operator

data = [
 ([["route","23"],["equip","jr2"],["time","3pm"]],"my first value"),
 ([["route","23"],["equip","jr1"],["time","3pm"]],"my second value"),
 ([["route","23"],["equip","jr2"],["time","3pm"]],"my third value"),
 ([["route","24"],["equip","jr2"],["time","3pm"]],"my fourth value"),
 ([["route","25"],["equip","jr2"],["time","3pm"]],"my fifth value")
 ]


def group(data, index):
 return itertools.groupby(sorted(data), lambda x: x[0][index])

root = ET.Element("result")

for key, items in group(data, 0):
 route = ET.SubElement(root, key[0], id=key[1])
 for key, items in group(items, 1):
equip = ET.SubElement(route, key[0], id=key[1])
for key, items in group(items, 2):
time = ET.SubElement(equip, key[0], id=key[1])
for data in items:
ET.SubElement(time, "data").text = data[1]

ET.dump(root)

if you want prettyprinted output, use this function

 http://effbot.org/zone/element-lib.htm#prettyprint

on the resulting tree.



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


Re: How properly manage memory of this PyObject* array?? (C extension)

2006-07-10 Thread John Machin
On 11/07/2006 4:39 AM, [EMAIL PROTECTED] wrote:
>>> Q2: Must I do free(my_array); at end of function??
>> unless some other part of your program holds on to it
> 
> F.
> 
> Thanks!  If I understand you correctly then I never have
> to do free(my_array); because all the elements
> of my_array are still being used and appended to other
> structures elsewhere right?

*WRONG* -- reread /F's response:
"""
unless some other part of your program holds on to it, of course you 
have to release it.  it's a bit surprising that you have to ask this, 
really -- any C tutorial should explain how malloc/free works.
"""

> 
> As long as each element of my_array is managed
> properly and freed properly there is  NEVER any
> reason to worry about fact that free(my_array)
> will never get run right?

*WRONG* -- the reason to worry is that the memory occupied by the 
my_array itself is never handed back. If you don't free it, repeated 
calls to your function will cause your app to run out of memory.

It's quite simple, really: You malloc it, you free it. I share the 
effbot's surprise: If you (or the taxpayers!) paid money for a 
course/book/tutorial that didn't include that advice, a claim for a 
refund is definitely indicated.

HTH,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Restricted Access

2006-07-10 Thread Tim Chase
> 1. How can i disable some of the modules without deleting. e.g I wish
> to disable "os" module.

If you're prepared for the massive breakage that will ensue, you can

chmod go-rwx /usr/lib/python2.3/os.*

(assuming *nix as you later detail).

> 2. How can i force user code to access only his particular folder, I
> dont want to create uses in unix, e.g

Well, you can create a chroot jail for each user that contains a 
clone of your /usr/{lib/python2.3/,bin/,usr/bin/} directories. 
You'd have to include any other executables that the user would 
need (important stuff like ls, cp, mv, mkdir, rmdir, 
cvs/ci/co/rcs/svn, etc)  This would ensure that each user doesn't 
access anything that you haven't explicitly copied in to their 
jail.  Another alternative might just be to copy the python 
libraries to some place in the user's homedir (whatever their 
original library path was), revoke execute non-user execute privs 
from the python executable ("chmod go-x `which python`), and then 
change python to be a script that runs something like "chroot 
$HOME/ python $@".  Allow per-user access to this script via sudo.

Just a couple ideas you might try.

-tkc



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


Re: Python-2.5beta1 crash

2006-07-10 Thread Robin Becker
Terry Reedy wrote:
.
> Your choice, of course, but if the import succeeded, I personally would 
> have runAll verbosely print testfile names before running them and then do 
> a binary or trinary search to pin down the offending statement.

good points and a good idea. I'll try and pin down first the test file 
and then the statement; then try and figure out whether it's worth doing 
a debug build.
-- 
Robin Becker
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython: how does EVT_IDLE work?

2006-07-10 Thread Rob Williscroft
John Salerno wrote in news:[EMAIL PROTECTED] in 
comp.lang.python:

> Quick question about the code below: I understand why the progress bar 
> fills up at a steady pace when the mouse is idle over the frame; but 
> why, when you move the mouse, does the progress bar speed up? Shouldn't 
> it stop completely until the mouse is idle again?

wxWidgets is sending the idle event after it has processed all 
other events, but it just sends it once not in a loop.

see the documentation (help) for wxIdleEvent::RequestMore.


> 
>  def OnIdle(self, event):

event.RequestMore(True)

>  self.count += 1
>  if self.count >= 50:
>  self.count = 0

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cheetah.

2006-07-10 Thread Tavis . Rudd
Hi Chun,
you should post this to the cheetah mailing list rather than here.

https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Cheers,
Tavis

chun ping wang wrote:
> I am having trouble using cheetah and getting it to work the way i want
> (mvc)
>
> I have the following file.
>
> index.py : # imports BibleController and setting.
>
>
> BibleController.py that includes the Bible.py model to database (those
> works). At the end of it i have.
> print Template ( file = "BibleView.Tmpl", searchList = templateValue )
>
> BibleView.tmpl.
>
> I generated something call BibleView.py using cheetah template. But when i
> run BibleView.py i get this error.
>
> File "BibleView.py", line 97, in respond
>__v = VFFSL(SL,"ver",True)
> ameMapper.NotFound: cannot find 'ver'
>
> Whats wrong?
>
> _
> On the road to retirement? Check out MSN Life Events for advice on how to
> get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

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


Re: Py_NewInterpreter(), is this a bug in the python core?

2006-07-10 Thread freesteel
Yes, I see that now in the documentation, which to me is quite
confusing.
So, how do you use python in a multithreaded environment, where for
example you want to run some embeded python code from a number of
different C threads?

This article: http://www.linuxjournal.com/article/3641 is quite good,
but must have been written before these PyGILState_* functions.

I only used Py_NewInterpreter to have a fresh 'import sys'.

Somebody enlighten me, please.

Martin

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


Re: free python hosting !

2006-07-10 Thread Luis M. González

John Salerno wrote:
> John Salerno wrote:
> > Bayazee wrote:
> >
> >> i want a free hosting for python .
> >> so i can make my scripts and upload to server .
> >> i want to use mod_python ...
> >
> > good luck with that...
>
> p.s. you might look into http://dollar-hosting.org/
>
> it's very cheap and supposedly supports mod_python, although i could
> never get it to work, so some effort and communication with them might
> be required...

I'm curious, why it didn't work?
I sent them an email recently, asking about mod_python support, and
they replied afirmatively, and very quickly. They also said that they
can install other scripts on demand.
But I never tried them though...
I'd like to know more about your experience with this hosting, if
possible.

Thanks!
Luis

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


Re: unistall python mechanize

2006-07-10 Thread John J. Lee
"bruce" <[EMAIL PROTECTED]> writes:

> hi..
> 
> i'm trying to figure out how to uninstall "mechanize". i don't see an
> "unistall" from the "python --help-commands" function...
> 
> i'm looking to rebuild/reinstall mechanize from the svn repos to try to see
> if an apparent parsing issue that i mentioned is fixed...

http://peak.telecommunity.com/DevCenter/EasyInstall#uninstalling-packages


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


Re: wxpython: how does EVT_IDLE work?

2006-07-10 Thread John Salerno
John Salerno wrote:

> Ok, now I'm really confused. I just ran the code again and this time it 
> *doesn't* increase the progress bar when the mouse is idle, and it only 
> increases when I move it. This wasn't the behavior just a few minutes 
> ago, and I didn't change anything! What's going on?

Ok, this helps explain why moving the mouse causes the idle event:

"Note that, unless you do something specifically, the idle events are 
not sent if the system remains idle once it has become it, e.g. only a 
single idle event will be generated until something else resulting in 
more normal events happens and only then is the next idle event sent again."

But I'm still confused about why *not* moving the mouse still allowed 
the progress bar to increase (although that behavior has stopped now for 
some reason).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxpython: how does EVT_IDLE work?

2006-07-10 Thread John Salerno
John Salerno wrote:
> Quick question about the code below: I understand why the progress bar 
> fills up at a steady pace when the mouse is idle over the frame; but 
> why, when you move the mouse, does the progress bar speed up? Shouldn't 
> it stop completely until the mouse is idle again?

Ok, now I'm really confused. I just ran the code again and this time it 
*doesn't* increase the progress bar when the mouse is idle, and it only 
increases when I move it. This wasn't the behavior just a few minutes 
ago, and I didn't change anything! What's going on?



> self.gauge.SetBevelFace(3)

Should be 'Bezel'.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re question

2006-07-10 Thread Jim Segrave
In article <[EMAIL PROTECTED]>,
Schüle Daniel  <[EMAIL PROTECTED]> wrote:
>Hello,
>
>consider the following code
>
> >>> re.search("[a-z](?i)[a-z]","AA")
><_sre.SRE_Match object at 0x40177e20>
>
>this gives a match
>if we provide an extra group for the first character it still works
>
> >>> re.search("([a-z])(?i)[a-z]","AA").group(1)
>'A'
> >>>
>
>it doesn't matter where (?i) is placed, right?
>the re engine would glance at once on the entire pattern string
>analize it (complain if pattern doesn't make sense, eg invalid)
>and it would be the same as if the option was given expicitely
>as re.IGNORECASE.
>
>Is there a way to switch-off the option resp.
>switch-on the option in the middle of the pattern?

The docs say:

(?iLmsux)
(One or more letters from the set "i", "L", "m", "s", "u", "x".)
The group matches the empty string; the letters set the
corresponding flags (re.I, re.L, re.M, re.S, re.U, re.X) for the
 ^^^  
entire regular expression. This is useful if you wish to include
^

the flags as part of the regular expression, instead of passing a
flag argument to the compile() function.


Some regex packages, but not Python's, support (?-) and this
allows turning the flag off and on for parts of the regex.



-- 
Jim Segrave   ([EMAIL PROTECTED])

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

Restricted Access

2006-07-10 Thread iapain
I'm developing a webIDE for python and I've 2 questions regarding it.

1. How can i disable some of the modules without deleting. e.g I wish
to disable "os" module.
2. How can i force user code to access only his particular folder, I
dont want to create uses in unix, e.g

fp = open(PATH, 'w') # If this PATH is defined then use can access
files else he cant .. is there is any way?

Regards!
iapain

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


Re: Web Browser Pygame Plug-in?

2006-07-10 Thread Ravi Teja
Gregory Piñero wrote:
> That's interesting, Ben.  So we'd be better off making a new library
> similiar to Pygame in functionality but designed from the ground up to
> work in a browser.

In open source community, that would be YOU since you are the one with
the need :-). Maybe you can make "Python WebStart".

Running foreign native code from a browser has long been abandoned as a
bad idea since ActiveX spyware proliferation (which BTW, is another way
to package your game as. Although that would effectively restrict it to
IE just like XPCOM would restrict it to Mozilla family). Plus your
users will have to download Python somehow (Python is not as widespread
as Java or Flash on consumer desktops), either as part of the game or
independently. And finally, if PyGame was written in pure Python
without taking advantage of SDL to be fully cross-platform, it would
likely not be fast anymore. It better be a REALLY great game to go with
all these issues :-).

> I guess that XPCOM technology that someone
> mentioned might be the way to go?

It is far simpler to just use Jython and some Java Game library instead
of PyGame if browser delivery is that important to you.

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


Re: threading troubles

2006-07-10 Thread sreekant
Hi there

I tried as advised. Now the function gets called only after I hit quit 
button which calls gtk.main_quit() at which point, the ui stays on but 
not responsive, while the fluidsynth runs in the fg, then ui disappears 
as the fluidsynth finishes and presumably the thread dies.


xc = threading.Thread(target=player,args=(midicmd,fmidi,addlog))
xc.start()

def player(mp,fm,callback):
 res=os.system(mp+' '+fm)
 os.remove(fm)
 return

I tried in the player, both os.popen3 and os.system and os.popen3 with 
cmd+' &' and the same with os.system . But all do the same thing.

Any ideas!
Ta
sree
> 
> you can use threads, but try doing it the python way instead of the
> java way. ;-)
> def func(cmd, callback):
> os.system(cmd)
> callback()
> xc = threading.Thread(target=func, args=(cmd, callback))
> xc.start()
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mechanize/Browser question

2006-07-10 Thread John J. Lee
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:

> bruce schrieb:
> > hi...
> > i can do the following
> >   br = Browser
> >   br.open("www.yahoo.com")
> >   br.open("file:///foo")
> >  but can i do
> >   s = "..."  qualified html text
> >   br.open(s)
> >  i'm curious, if i have html from someother source, is there a way
> > to simply
> > get it into the "Browser" so i can modify it...
> 
> Use the tempfile-module to create a temporary file, write your HTML in
> there and point the browser to it. Alternatively, you could fire up a
> SimpleHTTPServer and serve the content. For HTML-only this would be
> overkill, but if you need images as well it might be worth it.

There are better/other ways which I've already pointed bruce to on the
mailing list that covers module mechanize
([EMAIL PROTECTED]).

I've asked Bruce not to cross-post all this stuff -- partly since he's
not likely to get a good answer from anybody but me and the others on
that list, but also to avoid irritating everybody on c.l.py ;-)


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


Re: [wwwsearch-general] ClientForm request re ParseErrors

2006-07-10 Thread John J. Lee
"bruce" <[EMAIL PROTECTED]> writes:

> hi john...
[...]

I'll be answering all these posts of bruce's on
[EMAIL PROTECTED] -- I don't think c.l.py is the
right place.


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


wxpython: how does EVT_IDLE work?

2006-07-10 Thread John Salerno
Quick question about the code below: I understand why the progress bar 
fills up at a steady pace when the mouse is idle over the frame; but 
why, when you move the mouse, does the progress bar speed up? Shouldn't 
it stop completely until the mouse is idle again?

Also, on a side note, I'm confused by the use of the word "bevel" and 
"bezel". The methods seem to use "bezel", but according to wxPython in 
Action, it's referring to the bevel of the border of the widget. Also, 
the book refers to a method called SetBevelWidth(), but the code shows 
it as SetBezelWidth() -- and only the latter works -- so what's the deal 
with these words?

Thanks!

--

import wx

class GaugeFrame(wx.Frame):

 def __init__(self):
 wx.Frame.__init__(self, None, -1, 'Gauge Example')
 panel = wx.Panel(self)
 self.count = 0
 self.gauge = wx.Gauge(panel, -1, 50, (20, 50), (250, 25))
 self.gauge.SetBevelFace(3)
 self.gauge.SetShadowWidth(3)
 self.Bind(wx.EVT_IDLE, self.OnIdle)

 def OnIdle(self, event):
 self.count += 1
 if self.count >= 50:
 self.count = 0
 self.gauge.SetValue(self.count)

if __name__ == '__main__':
 app = wx.App(redirect=False)
 GaugeFrame().Show()
 app.MainLoop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: free python hosting !

2006-07-10 Thread John Salerno
John Salerno wrote:
> Bayazee wrote:
> 
>> i want a free hosting for python .
>> so i can make my scripts and upload to server .
>> i want to use mod_python ...
> 
> good luck with that...

p.s. you might look into http://dollar-hosting.org/

it's very cheap and supposedly supports mod_python, although i could 
never get it to work, so some effort and communication with them might 
be required...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto or Tutorial for tokenize module for a newbie?

2006-07-10 Thread sreekant
TY wrote:
> Hi,
> 
> Can someone point me to a Howto or Tutorial for tokenize module for a
> newbie?  I read the documentation but it doesn't have a lot of info...
>  Thanks!
> 
Hi there

I don't know if I got your requirement. But I used a own version of 
tokenizer which can use more than one delimiters. It is below. Hopefully 
of some use to you.




def gettokens(dat):
 delims={'=':'',';':',','=':'','(':'',')':'',':':'','[':'',']':''}
 wlist=[]
 appended=0
 for n in string.split(dat,'\n'):
 word=''
 for m in n:
 appended=0
 if delims.has_key(m):
 wlist.append(word)
 wlist.append(m)
 word=''
 appended=1
 else:
 word=word+m
 if appended==0:
 wlist.append(word)
 appended=1
 wlist.append("\n")
 return wlist

I am sure there are plenty of ways to write it better than that.

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


Re: free python hosting!

2006-07-10 Thread Bayazee
Thanx  !!

-
www.python.ir --> Persian Python Community !

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


Re: numeric/numpy/numarray

2006-07-10 Thread Robert Kern
Terry Reedy wrote:
> "Alex Martelli" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> I'll voice a heretic thought: me, I'm sticking with good old Numeric
>> until the situation with the newer packages settles down.
> 
> Not much of a heresy, I think.  The numpy site recommends that *new* users 
> start with numpy but I don't remember the numeric/numpy folks recommending 
> that happy, experienced numeric users dump it yet.  The current development 
> version of numpy is still labelled as a development version (0.9.8, I 
> believe) and besides bug fixes, it still made a few tweeks in the user 
> interface and C-API from the previous version.  They are aiming to release 
> a stable NumPy 1.0 by the end of the summer.  Then maybe they will start 
> pushing it, along with a compatible array interface for Python.

My tactic in answering Numeric questions on this list has been to give the 
numpy 
answer if the asker seems new to the field and give the Numeric answer *and* 
the 
(obviously superior) numpy answer otherwise.

But that's mostly my natural politeness and tact (quit laughing. I can hear you 
sniggering back there!). We definitely *do* want old hands at Numeric to give 
numpy a try now. It's difficult to find the bugs, work out the transition 
headaches, and make the right design decisions without feedback from you.

We are trying to get out a 1.0b1 in a couple of weeks. Hopefully, we can get to 
1.0b2 by the SciPy conference in mid-August. If you've been holding off on 
trying numpy, the 1.0 betas will be the perfect time to jump in. It will also 
be 
your last chance to get your 2 cents in.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

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


PKCS7 padding implementation in Python

2006-07-10 Thread Satchidanand Haridas
Hi,Do any of the cryptographic modules for Python support PKCS7 padding scheme? I would like to use this scheme with block cipher encryption algorithms to pad text whose length is less than a proper block size.  thanks in advance,Satchit -- 
http://mail.python.org/mailman/listinfo/python-list

Re: numeric/numpy/numarray

2006-07-10 Thread Terry Reedy

"Alex Martelli" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'll voice a heretic thought: me, I'm sticking with good old Numeric
> until the situation with the newer packages settles down.

Not much of a heresy, I think.  The numpy site recommends that *new* users 
start with numpy but I don't remember the numeric/numpy folks recommending 
that happy, experienced numeric users dump it yet.  The current development 
version of numpy is still labelled as a development version (0.9.8, I 
believe) and besides bug fixes, it still made a few tweeks in the user 
interface and C-API from the previous version.  They are aiming to release 
a stable NumPy 1.0 by the end of the summer.  Then maybe they will start 
pushing it, along with a compatible array interface for Python.

Terry Jan Reedy



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


Re: free python hosting!

2006-07-10 Thread tac-tics
I provide the link below with the conditions that you don't put spaces
between your sentences and the periods which terminate them.

http://wiki.python.org/moin/PythonHosting

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


Re: xml aggregator

2006-07-10 Thread Gerard Flanagan

kepioo wrote:
> Thank you so much, it works and it rocks !
>

Great! Glad I could help.

> bad thing i need ot figure out is why mozilla cannot parse my xsl
> sheet, but it works in IE ( most of my users are using IE)
>

you could try transforming the xml on the server and send straight HTML
to the client - if you were to use CherryPy (http://www.cherrypy.org),
there is a filter which does this called picket:

http://www.cherrypy.org/wiki/Picket

you would also need to install 4Suite (http://4suite.org)

> so the module u wrote is to top up element tree with Xpath
> capabilities, is it?

it minimally extends the functionality of elementtree's existing
'findall' function - and it hasn't been put to much use, so let me know
if you run into problems.

the idea came from reading about the 'Specification Pattern':

pdf - http://www.martinfowler.com/apsupp/spec.pdf


good luck!

Gerard

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


Re: Py_NewInterpreter(), is this a bug in the python core?

2006-07-10 Thread Thomas Heller
freesteel schrieb:
> /*
> Is this a bug in Py_NewInterpreter?
> 
> The function below "MyThread" is instantiated from a windows worker
> thread, but I don't
> think that is relevant.
> (I can try this on a linux box, but I would have to compile a python
> library with debugging
> enabled.)
> 
> The following code fragment throws an exception in a debug version of
> python:
> */
> 
> UINT MyThread(LPVOID lpParam)
> {
>   {
>   cs.Lock(); // this is a CCriticalSection lock
>   if (!Py_IsInitialized())
>   {
>   Py_Initialize();
>   PyEval_InitThreads();
> 
>   // global pointer to the main PyThreadState object
>   mainThreadState = PyThreadState_Get();
>   PyEval_ReleaseLock();
>   }
>   cs.Unlock();
>   }
> 
>   ASSERT(Py_IsInitialized());
>   ASSERT(PyEval_ThreadsInitialized());
>   ASSERT(mainThreadState);
>   threadnum++;
> 
>   // get the global lock
>   PyEval_AcquireLock();
> PyGILState_STATE gstate;
> gstate = PyGILState_Ensure(); // Is tis necessary?
> 
> 
>   PyThreadState_Swap(mainThreadState);
>   PyThreadState* nts = Py_NewInterpreter();
> 
> /*
> 
> The exception is thrown inside the above function call:
> This statement tries to swap the new threadstate 'tstate' with the
> current one
>   save_tstate = PyThreadState_Swap(tstate);
> 
> Inside PyThreadState_Swap the code uses another way
> 'PyGILState_GetThisThreadState()' to find the current thread state and
> compares this with the newly set thread state.
> Naturally you would expect the two to be equal but that test fails:
> #if defined(Py_DEBUG) && defined(WITH_THREAD)
>   if (new) {
>   PyThreadState *check = PyGILState_GetThisThreadState();
>   if (check && check != new)
>   Py_FatalError("Invalid thread state for this thread");
>   }
> #endif
> 
> The variable 'check' looks as if it is the 'previous' thread state, as
> if changing the thread state
> is not been done properly. Py_FatalError is called and that's the end.
> 
> Is there a mistake in my code, or is there something wrong in how
> Py_NewInterpreter is implemented?

As far as I know, the PyGILState_... functions are incompatible with multiple
Python interpreters.

Thomas

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


Re: How properly manage memory of this PyObject* array?? (C extension)

2006-07-10 Thread [EMAIL PROTECTED]

> > Q2: Must I do free(my_array); at end of function??
> unless some other part of your program holds on to it

F.

Thanks!  If I understand you correctly then I never have
to do free(my_array); because all the elements
of my_array are still being used and appended to other
structures elsewhere right?

As long as each element of my_array is managed
properly and freed properly there is  NEVER any
reason to worry about fact that free(my_array)
will never get run right?


cs

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


About __files

2006-07-10 Thread venkat pathy
Hi all,  I came across a series of functions starting with "__". For example, __fun() . May I know what are all these functions ? I came across __init__ like functions starting and ending with "__".
Whether they are constructors which are overloaded ?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Running multiple versions of Python on the same host..

2006-07-10 Thread olsongt

Cowmix wrote:
> For my day job I am forced to run RHEL3 (and Centos3 on my desktop). I
> want to be able to use a few applications that require Python 2.4.X but
> RHEL3 ships with Python 2.2.3. I have tried to install and upgrade
> Python 2.4.X many ways like using PyVault and doing a source based
> install but each way has been fraught with problems from weird
> dependency issues to screwing up 'yum'.
>
> What is the best way to run multiple version of Python on the same
> system?
>
> thanks!

If installing from source, 'make altinstall' will do everything but
link python to (for example python2.4.  You can then run 'python2.4'
'python2.3',etc to use a particular version.

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


Re: simulate enumerate in python 2.1

2006-07-10 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> hi,
> i am using python 2.1. Can i use the code below to simulate the
> enumerate() function in 2.3? If not, how to simulate in 2.1?
> thanks
>
> from __future__ import generators
> def enumerate(sequence):
>index = 0
>for item in sequence:
>yield index, item
>index += 1

Didn't generators and the new iterator protocol arrived in 2.2?
If so you have to write an iterator in the older __getitem__ protocol, 
which should be in the 2.1 docs.

tjr



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


Re: Python-2.5beta1 crash

2006-07-10 Thread Terry Reedy

"Robin Becker" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'm testing ReportLab against Python-2.5beta1 and am getting some kind of
> problem as below

No kidding;-).
Based on incomplete knowledge, I will try to make some helpful comments.

> ===
> C:\Python24\reportlab\test>\python25\python runAll.py

In a Windows command window, you run \Python24\reportlab\test\runAll.py 
with python 2.5.

> .C:\Python24\reportlab\test\test_docstrings.py:54: ImportWarning: Not 
> importing
> directory 'C:\python25\reportlab\tools\utils': missing __init__.py
>   module = __import__(mName)
> C:\Python24\reportlab\test\test_docstrings.py:54: ImportWarning: Not 
> importing d
> irectory 'C:\python25\reportlab\tools\pythonpoint\demos': missing 
> __init__.py
>   module = __import__(mName)
> C:\Python24\reportlab\test\test_docstrings.py:54: ImportWarning: Not 
> importing d
> irectory 'C:\python25\reportlab\docs': missing __init__.py
>   module = __import__(mName)
> C:\Python24\reportlab\test\test_docstrings.py:54: ImportWarning: Not 
> importing d
> irectory 'C:\python25\reportlab\demos': missing __init__.py
>   module = __import__(mName)

These ImportWarnings come from a controversial new feature in 2.5 which 
warns when project directories added to sys.path have non-package 
directories with files whose names match the name you are trying to import. 
Or something like that.  Read What's New for details and the last few 
months of PyDev summaries and/or archives (threads with warning in subject 
line) for rationale and controversy.

The new warnings are sometimes useless and sometimes come in blizzards. 
They can be turned off and I believe they will be by default in the pending 
beta2.  I would 'print mName' before the import and 'print module.__file__' 
to see if the import eventually succeeded and if so, from where you expect.

> Fatal Python error: non-string found in code slot

Fatel errors are rarely reported here and, as far as I know, undocumented 
except in the C code.  I believe it could come from anywhere during or 
after the import.  The first thing I would do is determine which by the 
suggested print insertion and if the latter, whether test_docstrings 
finished.

> This application has requested the Runtime to terminate it in an unusual 
> way.
> Please contact the application's support team for more information.

I suspect this is from Windows

> ===
>
> First off there may be a bunch of other C extensions involved including 
> PIL, but
> I built them all against this beta. What should I do to refine the error? 
> Do I
> start with trying to establish which of the tests is guilty or build from 
> source
> in debug mode and attempt to find the problem from below.

Your choice, of course, but if the import succeeded, I personally would 
have runAll verbosely print testfile names before running them and then do 
a binary or trinary search to pin down the offending statement.




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


Howto or Tutorial for tokenize module for a newbie?

2006-07-10 Thread TY
Hi,

Can someone point me to a Howto or Tutorial for tokenize module for a
newbie?  I read the documentation but it doesn't have a lot of info...
 Thanks!

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


Re: function that modifies a string

2006-07-10 Thread Diez B. Roggisch
>>> Arrays of chars are dangerous. If you insist, use Python lists of
>>> Python "chars" (strings of length 1).
>> Why are they more dangerous than a self-written mutable string?
> 
> I didn't say that. I meant that arrays in the C++ sense are dangerous.

So what? Python's arrays are backed by arrays of the type they have, 
whereas lists are represented by arrays of python objects. Both arrays 
of some kind. Both hide this behind a convenient API whcih don't put any 
responsibility on the programmer's shoulder. Now I ask again: where is 
that dangerous, or more dangerous than writing your own mutable string?

> C++ offers pass by value options. That makes it so you never need to
> worry about messing up data that doesn't belong to you unless you
> explicitly pass by reference. Python doesn't do this for you. Thus, a
> mutable string class in Python requires a great deal more care since
> you need to make copies of every string in every function in order to
> prevent changes in one object's string from affecting another.

While you are technically correct, it strikes me odd that someone uses 
mutable strings in a scenario where he also wants copy-semantics for 
pass-by-value. That is plain stupid: create O(n) complexity to achieve 
what immutable strings buy you for O(1).

So: Yes, mutable strings are dangerous. Use them only when their 
benefits outweigh their risks. But you argumentation regarding C++ is 
odd to say the least. Especially since the cited call-by-value semantics 
doesn't come for free - designing and implementing assignment operators 
and copy-constructors is a daunting task in itself.

And if you WANT to use mutable strings with a call-by-value semantic in 
python, a simple decorator that scans arguments for mutable strings 
could help you there.

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


Python for modem App

2006-07-10 Thread Bayazee
hi
i want to write a program with python that can listen to modem and
accept a dial in connection then i can play a sound or send voice to
caller & can assess user enterd keys 
how i can send a voice format via modem that caller can hear it .. !?

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


Re: free python hosting !

2006-07-10 Thread John Salerno
Bayazee wrote:

> i want a free hosting for python .
> so i can make my scripts and upload to server .
> i want to use mod_python ...

good luck with that...
-- 
http://mail.python.org/mailman/listinfo/python-list


free python hosting !

2006-07-10 Thread Bayazee
hi
i want a free hosting for python .
so i can make my scripts and upload to server .
i want to use mod_python ...

-
www.python.ir --> Persian Python Community !

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


Re: Mechanize/Browser question

2006-07-10 Thread Diez B. Roggisch
bruce schrieb:
> hi...
> 
> i can do the following
>   br = Browser
>   br.open("www.yahoo.com")
>   br.open("file:///foo")
> 
>  but can i do
>   s = "..."  qualified html text
>   br.open(s)
> 
>  i'm curious, if i have html from someother source, is there a way to simply
> get it into the "Browser" so i can modify it...

Use the tempfile-module to create a temporary file, write your HTML in 
there and point the browser to it. Alternatively, you could fire up a 
SimpleHTTPServer and serve the content. For HTML-only this would be 
overkill, but if you need images as well it might be worth it.


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


Re: prompt auto complete and history

2006-07-10 Thread Matt Good
Deepan Chakravarthy wrote:
> Hi,
>  I am using fedora core 5. I would like to have auto complete in python
> prompt and  history. How do i get it enabled ?

The standard Python commandline does not support auto complete.
IPython is a very nice alternative commandline that does suport auto
complete and other more advanced features:
http://ipython.scipy.org/

-- Matt Good

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


Re: What is a type error?

2006-07-10 Thread Darren New
Chris Smith wrote:
> If you wish to say "typestate" to mean this, be my guest.  It is also 
> correct to say "type".

Sure. I just wasn't sure everyone here was aware of the term, is all. It 
makes it easier to google if you have a more specific term.

> I'm not aware of a widely used language that implements stuff like this.  

I've only used Hermes with extensive support for this sort of thing. 
Hermes is process-oriented, rather than object-oriented, so it's a 
little easier to deal with the "encapsulation" part of the equation 
there. Sadly, Hermes went the way of the dodo.

-- 
   Darren New / San Diego, CA, USA (PST)
 This octopus isn't tasty. Too many
 tentacles, not enough chops.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is a type error?

2006-07-10 Thread Chris Smith
Darren New <[EMAIL PROTECTED]> wrote:
> Chris Smith wrote:
> > // Inside this block, a has type int{17..21} and b has type
> > // int{18..22}
> 
> No what happens if right here you code
>b := 16;
> 
> Does that again change the type of "b"? Or is that an illegal 
> instruction, because "b" has the "local type" of (18..22)?

It arranges that the expression "b" after that line (barring further 
changes) has type int{16..16}, which would make the later call to 
signContract illegal.

> If the former (i.e., if reassigning to "b" changes the "static type" of 
> b, then the term you're looking for is not type, but "typestate".

We're back into discussion terminology, then.  How fun.  Yes, the word 
"typestate" is used to describe this in a good bit of literature.  
Nevertheless, a good number of authors -- including all of them that I'm 
aware of in programming language type theory -- would agree that "type" 
is a perfectly fine word.

When I said b has a type of int{18..22}, I meant that the type that will 
be inferred for the expression "b" when it occurs inside this block as 
an rvalue will be int{18..22}.  The type of the variable didn't change, 
because variables don't *have* types.  Expressions (or, depending on 
your terminology preference, terms) have types.  An expression "b" that 
occurs after your assignment is a different expression from the one that 
occurs before your assignment, so it's entirely expected that in the 
general case, it may have a different type.

It's also the case (and I didn't really acknowledge this before) that 
the expression "b" when used as an lvalue has a different type, which is 
determined according to different rules.  As such, the assignment to b 
was not at all influenced by the new type that was arranged for the 
expression "b" as an rvalue.

(I'm using lvalue and rvalue intuitively; in practice, these would be 
assigned on a case-by-case basis along the lines of actual operators or 
language syntax.)

> In other words, this is the same sort of test that disallows using an 
> unassigned variable in a value-returning expression.

Yes, it is.

> When
>{ int a; int b; b := a; }
> returns a compile-time error because "a" is uninitialized at the 
> assignment, that's not the "type" of a, but the typestate. Just FYI.

If you wish to say "typestate" to mean this, be my guest.  It is also 
correct to say "type".

> It actually works quite well if the language takes advantage of it 
> consistantly and allows you to designate your expected typestates and such.

I'm not aware of a widely used language that implements stuff like this.  
Are you?

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
-- 
http://mail.python.org/mailman/listinfo/python-list


prompt auto complete and history

2006-07-10 Thread Deepan Chakravarthy
Hi,
 I am using fedora core 5. I would like to have auto complete in python
prompt and  history. How do i get it enabled ? i have .pystart file
and .pyhist file setup.
thanks
Deepan 
www.sudoku-solver.net/sudokusolver.html 
www.codeshepherd.com 



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


Re: function that modifies a string

2006-07-10 Thread Fredrik Lundh
tac-tics wrote:

> I didn't say that. I meant that arrays in the C++ sense are dangerous.

so what do you think Python's string type uses on the inside ?

> C++ offers pass by value options. That makes it so you never need to
> worry about messing up data that doesn't belong to you unless you
> explicitly pass by reference. Python doesn't do this for you. Thus, a
> mutable string class in Python requires a great deal more care since
> you need to make copies of every string in every function in order to
> prevent changes in one object's string from affecting another.

and that would be different from any other mutable Python type in 
exactly what way ?



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


Re: language design question

2006-07-10 Thread Steve Holden
Terry Reedy wrote:
> "OKB (not okblacke)" <[EMAIL PROTECTED]> wrote in message 
[...]
> 
> The underlying answer to the original question is that while Pyt;hon is 
> object-based, it is not strictly OO but is intentionally multiparadigmatic 
> and will remain so.  For instance, no one will be forced to replace the 
> procedural expression 'a+b' with the strict OO equivalent 'a .__add__(b)'. 
> But anyone is free to do so in their own code, just as with ob.__len__() 
> for len(ob).

In other words: "because it is".

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: What is a type error?

2006-07-10 Thread Chris Smith
Marshall <[EMAIL PROTECTED]> wrote:
> It's never been a strong point. Made worse now that my daughter
> is one of those up-at-the-crack-of-dawn types, and not old enough
> to understand why it's not nice to jump on mommy and daddy's
> bed while they're still asleep. But aren't you actually a time zone
> or two east of me?

Yes, I confess I'm one time zone to your east, and I was posting later 
than you.  So perhaps it wasn't really past your bedtime.

> The fields of an object/struct/what have you are often hidden behind
> a method-based interface (sometimes callled "encapsulated") only
> because we can't control their values otherwise.

I believe there are actually two kinds of encapsulation.  The kind of 
encapsulation that best fits your statement there is the getter/setter 
sort, which says: "logically, I want an object with some set of fields, 
but I can't make them fields because I lose control over their values".  
That part can definitely be replaced, in a suitably powerful language, 
with static constraints.

The other half of encapsulation, though, is of the sort thatI mentioned 
in my post.  I am intentionally choosing to encapsulate something 
because I don't actually know how it should end up being implemented 
yet, or because it changes often, or something like that.  I may 
encapsulate the implementation of current tax code specifically because 
I know that tax code changes on a year-to-year basis, and I want to 
ensure that the rest of my program works no matter how the tax code is 
modified.  There may be huge structural changes in the tax code, and I 
only want to commit to leaving a minimal interface.

In practice, the two purposes are not cleanly separated from each other.  
Most people, if asked why they write getters and setters, would respond 
not only that they want to validate against assignments to the field, 
but also that it helps isolate changes should they change the internal 
representation of the class.  A publicly visible static constraint 
language that allows the programmer to change the internal 
representation of a class obviously can't make reference to any field, 
since it may cease to exist with a change in representation.

> However for a function, the "fields" are the in and out parameters.
> The specific values in the relation that the function is aren't known
> until runtime either, (and then only the subset for which we actually
> perform computation.)
> 
> Did that make sense?

I didn't understand that last bit.

> There are certainly syntactic issues, but I believe these are amenable
> to the usual approaches. The runtime/compile time question, and
> decidability seem bigger issues to me.

Well, the point of static typing is to do what's possible without 
reaching the point of undecidability.  Runtime support for checking the 
correctness of type ascriptions certainly comes in handy when you run 
into those limits.

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
-- 
http://mail.python.org/mailman/listinfo/python-list


mechanize select_form issue..

2006-07-10 Thread bruce
hi...

update to an ongoing issue i've been having regarding html/Browser and
selecting forms.

i've created a basic test app, and created a stripped down page of html. the
html has a single form.

i get the following error:
fname =  main   the app can find the frame from the XPath...

Traceback (most recent call last):
  File "./axess.py", line 90, in ?
br.select_form(name = "main")  < app is dying!!!
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 354, in
select_form
mechanize._mechanize.BrowserStateError: not viewing HTML


any thoughts/ideas/comments will be useful!!


thanks

-bruce


test code
---
import re
import libxml2dom
import urllib
import urllib2
import sys, string
#import numarray
import httplib
from  mechanize import Browser, RobustFactory
import mechanize
from BeautifulSoup import *


#
# Parsing App Information





# datafile
tfile = open("stanford.dat", 'wr+')

cj = mechanize.CookieJar()
br = Browser()


if __name__ == "__main__":
# main app


#
# start trying to get the stanford pages
  cj = mechanize.CookieJar()
#  br = Browser(factory=RobustFactory())
  br = Browser()

  fh = open('axess1.dat')
  s = fh.read()
  fh.close()


  br.open("file:///home/test/axess1.dat")
#  br.open(s)

  print "foo"

  # particular cookiejar)
  br.set_cookiejar(cj)

  response = br.response()  # this is a copy of response

  fnamepath = "/html/[EMAIL PROTECTED]'PSPAGE']/form[1]/attribute::name"

  s = response.read()
  print response.read()
  d = libxml2dom.parseString(s, html=1)


  ff = d.xpath(fnamepath)
  fname = ff[0].nodeValue
  print "fname = ",fname
  br.select_form(name = "main")

  print "ss"
  sys.exit()



test html
---


View Schedule of Classes








hi john...

this is in regards to the web/parsing/factory/beautifulsoup

to reiterate, i have python 2.4, mechanize, browser, beatifulsoup installed.
i have the latest mech from svn.

i'm getting the same err as reported by john t. the code/err follows.. (i
can resend the test html if you need)


any thoughts/pointers/etc would be helpful...

thanks

-bruce



test code
#! /usr/bin/env python


#test python script
import re
import libxml2dom
import urllib
import urllib2
import sys, string
#import numarray
import httplib
from  mechanize import Browser, RobustFactory
import mechanize
import BeautifulSoup


#
# Parsing App Information





# datafile
tfile = open("stanford.dat", 'wr+')

cj = mechanize.CookieJar()
br = Browser()


if __name__ == "__main__":
# main app


#
# start trying to get the stanford pages
  cj = mechanize.CookieJar()
  br = Browser(factory=RobustFactory())

  fh = open('axess.dat')
  s = fh.read()
  fh.close()


  br.open("file:///home/test/axess.dat")
  .
  .
  .
  .



err/output
Traceback (most recent call last):
  File "./axess.py", line 45, in ?
br.open("file:///home/test/axess.dat")
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 130, in
open
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 170, in
_mech_open
  File "build/bdist.linux-i686/egg/mechanize/_mechanize.py", line 213, in
set_response
  File "build/bdist.linux-i686/egg/mechanize/_html.py", line 577, in
set_response
  File "build/bdist.linux-i686/egg/mechanize/_html.py", line 316, in
__init__
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 1326, in
__init__
BeautifulStoneSoup.__init__(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 973, in
__init__
self._feed()
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 987, in
_feed
smartQuotesTo=self.smartQuotesTo)
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 1580, in
__init__
u = self._convertFrom(proposedEncoding)
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 1614, in
_convertFrom
proposed = self.find_codec(proposed)
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 1731, in
find_codec
return self._codec(self.CHARSET_ALIASES.get(charset, charset)) \
  File "/usr/lib/python2.4/site-packages/BeautifulSoup.py", line 1740, in
_codec
codecs.lookup(charset)
TypeError: lookup() argument 1 must be string, not bool




is this where i've seen references to integrating Beautifulsoup in the wb
browsing app?

-bruce


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of John J Lee
Sent: Monday, July 10, 2006 2:29 AM
To: [EMAIL PROTECTED]
Cc: python-list@python.org
Subject: RE: [wwwsearch-general] ClientForm request re ParseErrors


On Sun, 9 Jul 2006, bruce wrote:
[...]
> sgmllib.SGMLParseError: expected name token at '
>
> partial html
> ---
> 
> 
> 
Action="/servlets/iclientservlet/a2k_prd/?ICType=Panel&Menu=SA_LEARNER_SERVI
> CES&Market=

Re: Augument assignment versus regular assignment

2006-07-10 Thread Terry Reedy

"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I disagree. The += version only evaluates the index once, but still has
> to find the object twice.

No it does not *have* to find the object twice and no it does *not* find 
the object twice.  From the viewpoint of the interpreter, the purpose of 
abbreviating 'objectexpression = objectexpression op arg' as 
'objectexpression op=arg' is to avoid unnecessary recalculation

> But as far as I can interpret what is happening from the printed lines

Your print get/set examples from your black-box testing miss the following 
key point.  While the interpreter still has to *use* the object(s) twice, 
once to get and once to set, it no longer has to *calculate* the objects 
twice.  If we open the box and look at the compiled pycode, we get, for 
example:

>>> dis(compile('x[i][j+k]=x[i][j+k]+1', '', 'single'))
  1   0 LOAD_NAME0 (x)
  3 LOAD_NAME1 (i)
  6 BINARY_SUBSCR
  7 LOAD_NAME2 (j)
 10 LOAD_NAME3 (k)
 13 BINARY_ADD

 14 BINARY_SUBSCR
 15 LOAD_CONST   0 (1)
 18 BINARY_ADD

 19 LOAD_NAME0 (x)
 22 LOAD_NAME1 (i)
 25 BINARY_SUBSCR
 26 LOAD_NAME2 (j)
 29 LOAD_NAME3 (k)
 32 BINARY_ADD

 33 STORE_SUBSCR

>>> dis(compile('x[i][j+k]+=1', '', 'single'))
  1   0 LOAD_NAME0 (x)
  3 LOAD_NAME1 (i)
  6 BINARY_SUBSCR
  7 LOAD_NAME2 (j)
 10 LOAD_NAME3 (k)
 13 BINARY_ADD

 14 DUP_TOPX 2

 17 BINARY_SUBSCR
 18 LOAD_CONST   0 (1)
 21 INPLACE_ADD

 22 ROT_THREE

 23 STORE_SUBSCR

[blank lines added for clarity]

Both forms call binary_subscr to get the number to add to 1 and both call 
store_subscr to set the result back in the list.  But in the first case, 
the expressions for both the source-target list and the index of the value 
for the addition are duplicated and re-evaluated.  In the second, the 
*results* of the first evaluation are duplicated (on the stack) and saved 
for the storage operation.

For understanding the detailed operation of CPython, dis is a great help

Terry Jan Reedy



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


Re: function that modifies a string

2006-07-10 Thread tac-tics
> >> What's wrong about arrays of chars?
> >
> > Arrays of chars are dangerous. If you insist, use Python lists of
> > Python "chars" (strings of length 1).
>
> Why are they more dangerous than a self-written mutable string?

I didn't say that. I meant that arrays in the C++ sense are dangerous.


> > If you really want a mutable string type, there's nothing in python
> > that keeps you from writting one yourself. You just have to be more
> > careful than you would be in C++, because your MutableString type would
> > always be passed by reference to functions, and so you'd have to be
> > very careful to copy it unless you want weird, unfindable bugs to crop
> > up in your program.
>
> I don't buy that. You are right about the dangers - but I fail to see where
> C++ gives you any protection from these pitfalls. And what disqualifies an
> array of characters in python that exists and has  all the methods I can
> think of for a  mutable string.

C++ offers pass by value options. That makes it so you never need to
worry about messing up data that doesn't belong to you unless you
explicitly pass by reference. Python doesn't do this for you. Thus, a
mutable string class in Python requires a great deal more care since
you need to make copies of every string in every function in order to
prevent changes in one object's string from affecting another.

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


simulate enumerate in python 2.1

2006-07-10 Thread eight02645999
hi,
i am using python 2.1. Can i use the code below to simulate the
enumerate() function in 2.3? If not, how to simulate in 2.1?
thanks

from __future__ import generators
def enumerate(sequence):
index = 0
for item in sequence:
yield index, item
index += 1

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


Re: language design question

2006-07-10 Thread Steven Bethard
Paul Rubin wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
>> If len() were a method of string objects, you could try using the
>> unbound method and writing this as::
>>
>>  >>> sorted(['aaa', 'bb', 'c'], key=str.len)
>>  ['c', 'bb', 'aaa']
>>
>> But then your code would break on lists that weren't strings.
> 
> sorted(['aaa', 'bb', 'c'], key=lambda x: x.len())

Of course, but all you're doing with the lambda is creating the len() 
function.

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


Re: language design question

2006-07-10 Thread Steven Bethard
Bryan wrote:
> Steven Bethard wrote:
> 
>> The advantage of a functional form over a method shows up when you 
>> write a function that works on a variety of different types. Below are 
>> implementations of "list()", "sorted()" and "join()" that work on any 
>> iterable and only need to be defined once::
>>
>>  def list(iterable):
>>  result = []
>>  for item in iterable:
>>  result.append(item)
>>  return result
>>
>>  def sorted(iterable):
>>  result = list(iterable)
>>  result.sort()
>>  return result
>>
>>  def join(iterable):
>>  # this is more efficient in C, where the string's buffer can be
>>  # pre-allocated before iterating through the loop.
>>  result = ''
>>  for item in iterable:
>>  result += item
>>  return result
>>
>> Now, by providing these as functions, I only have to write them once, 
>> and they work on *any* iterable, including some container object that 
>> you invent tomorrow.
>>
>> If everything were methods, when you invented your container object 
>> tomorrow, you'd have to reimplement these methods on your class. (Or 
>> we'd have to introduce a Container class to provide them, and everyone 
>> would have to inherit from that if they wanted to define a container.)
> 
> could you get the same result by putting these methods in base class 
> object that everything subclasses?  then you wouldn't have to 
> reimplement these methods on your class either, right?

Well, you don't want to put them on object, because not everything is a 
container (e.g. you don't want the sorted() method on ints).  So you 
have to put them on some subclass of object and then require everyone 
who every creates a container class to inherit from that object.  Python 
generally frowns upon required inheritance from a particular type, but 
at the same time, it does provide things like UserDict.DictMixin for 
something very much along these lines.  But I don't think too many folks 
want to *require* that every dict-like object inherit from DictMixin.

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


Re: What is a type error?

2006-07-10 Thread Darren New
Chris Smith wrote:
> // Inside this block, a has type int{17..21} and b has type
> // int{18..22}

No what happens if right here you code
   b := 16;

Does that again change the type of "b"? Or is that an illegal 
instruction, because "b" has the "local type" of (18..22)?

> signContract(a); // error, because a might be 17
> signContract(b); // no error, because even though the declared
>  // type of b is int{14..22}, it has a local
>  // type of int{18..22}.


If the former (i.e., if reassigning to "b" changes the "static type" of 
b, then the term you're looking for is not type, but "typestate".

In other words, this is the same sort of test that disallows using an 
unassigned variable in a value-returning expression.  When
   { int a; int b; b := a; }
returns a compile-time error because "a" is uninitialized at the 
assignment, that's not the "type" of a, but the typestate. Just FYI.

> Incidentally, I'm not saying that such a feature would be a good idea.  

It actually works quite well if the language takes advantage of it 
consistantly and allows you to designate your expected typestates and such.

-- 
   Darren New / San Diego, CA, USA (PST)
 This octopus isn't tasty. Too many
 tentacles, not enough chops.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multithreading windows and embedding python

2006-07-10 Thread freesteel

freesteel wrote:
...
>   pThread[ih] = AfxBeginThread(MyThread, mainThreadState,
> THREAD_PRIORITY_NORMAL, CREATE_SUSPENDED);

...

Here the call to AfxBeginThread is wrong, there is one argument
missing, it should be:

pThread[ih] = AfxBeginThread(MyThread, mainThreadState,
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);

Because there are so many default arguments of similar types the
compiler did not notice that I passed 'CREATE_SUSPENDED' as a stack
size, and use the default 'creation' state of 'start right away' for
the thread.

Don't you love default args and types like 'void*' ?

Martin

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


Re: eval to dict problems NEWB going crazy !

2006-07-10 Thread Fredrik Lundh
Ant wrote:

> So how do python app's typically embed python? For example things like
> Zope and idle are scripted using Python - presumably they restrict the
> execution of the scripts to a restricted set of modules/objects - but
> how is this done?

why?  anyone capable of adding code to idle already has access to 
everything that code can access...

> Perhaps idle doesn't require safety from untrusted code, but surely
> Zope does. So there must be some way of executing arbitrary untrusted
> code in an app within some kind of sandbox...

afaik, zope uses a custom parser.



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


Py_NewInterpreter(), is this a bug in the python core?

2006-07-10 Thread freesteel
/*
Is this a bug in Py_NewInterpreter?

The function below "MyThread" is instantiated from a windows worker
thread, but I don't
think that is relevant.
(I can try this on a linux box, but I would have to compile a python
library with debugging
enabled.)

The following code fragment throws an exception in a debug version of
python:
*/

UINT MyThread(LPVOID lpParam)
{
{
cs.Lock(); // this is a CCriticalSection lock
if (!Py_IsInitialized())
{
Py_Initialize();
PyEval_InitThreads();

// global pointer to the main PyThreadState object
mainThreadState = PyThreadState_Get();
PyEval_ReleaseLock();
}
cs.Unlock();
}

ASSERT(Py_IsInitialized());
ASSERT(PyEval_ThreadsInitialized());
ASSERT(mainThreadState);
threadnum++;

// get the global lock
PyEval_AcquireLock();
PyGILState_STATE gstate;
gstate = PyGILState_Ensure(); // Is tis necessary?


PyThreadState_Swap(mainThreadState);
PyThreadState* nts = Py_NewInterpreter();

/*

The exception is thrown inside the above function call:
This statement tries to swap the new threadstate 'tstate' with the
current one
save_tstate = PyThreadState_Swap(tstate);

Inside PyThreadState_Swap the code uses another way
'PyGILState_GetThisThreadState()' to find the current thread state and
compares this with the newly set thread state.
Naturally you would expect the two to be equal but that test fails:
#if defined(Py_DEBUG) && defined(WITH_THREAD)
if (new) {
PyThreadState *check = PyGILState_GetThisThreadState();
if (check && check != new)
Py_FatalError("Invalid thread state for this thread");
}
#endif

The variable 'check' looks as if it is the 'previous' thread state, as
if changing the thread state
is not been done properly. Py_FatalError is called and that's the end.

Is there a mistake in my code, or is there something wrong in how
Py_NewInterpreter is implemented?


Thanks

Martin

PS: Below the rest of my simple test worker thread function.
*/




ASSERT(nts == PyThreadState_Get());

// lock (already locked) - swap in thread state - swap out thread
state - unlock

init_testclass();


int ret = 0;

ret = PyRun_SimpleString("import sys");
ret = PyRun_SimpleString("class redir:\n  def __init__(self, id):\n
self.id = id\n  def write(self, s):\nf = open('stdoutputs_%s.txt' %
self.id, 'a')\nf.write('%s: %s' % (self.id, s))\nf.close()\n");
char str[100];
sprintf(str,"r = redir('0x%x')", &nts);
ret = PyRun_SimpleString(str);
ret = PyRun_SimpleString("sys.stderr = r");
sprintf(str,"s = redir('0x%x')", &nts);
ret = PyRun_SimpleString(str);
ret = PyRun_SimpleString("sys.stdout = s");

ret = PyRun_SimpleString("import testclass");
ret = PyRun_SimpleString("t = testclass.testclass()");
sprintf(str,"print 't = ', t ");
ret = PyRun_SimpleString(str);
ret = PyRun_SimpleString("print t.run(10)");


Py_EndInterpreter(nts);
PyGILState_Release(gstate);
PyEval_ReleaseLock();

return 0;
}

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


Re: Running multiple versions of Python on the same host..

2006-07-10 Thread jeff . pitman
Cowmix wrote:
> For my day job I am forced to run RHEL3 (and Centos3 on my desktop). I
> want to be able to use a few applications that require Python 2.4.X but
> RHEL3 ships with Python 2.2.3. I have tried to install and upgrade
> Python 2.4.X many ways like using PyVault and doing a source based
> install but each way has been fraught with problems from weird
> dependency issues to screwing up 'yum'.

Did you use the bootstrap RPM?

http://www.python.org/pyvault/centos-3-i386/pyvault-release-bootstrap-3-3.el3.pyv.noarch.rpm

If you want to try again, you can ping the pyvault-users mailing list
for specific answers to error messages you are seeing during
installation.

> What is the best way to run multiple version of Python on the same
> system?
> 
> thanks!

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


Re: language design question

2006-07-10 Thread Fredrik Lundh
Bryan wrote:

> could you get the same result by putting these methods in base
 > class object that everything subclasses?

and how do you make sure that everything subclasses this base class ?



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


Re: Need help in xml

2006-07-10 Thread uche . ogbuji
Kirt wrote:
> i have two xml documemts of type
>
> 
>  test
>  2006-12-12
>  12:12:12
>  
>   /home/
>   
> test2
> 12:12:12
>
>   
>  
>   /home/test
>
> test3
> 12:12:12
>
> 
>  
>
> i have to compare 2 similar xml document and get the add, changed and
> deleted files.and write it into acd.xml file.
> can u help me with the python code for this. I am using SAX.

Use the right tool and such problems tend to become much simpler.

http://www.logilab.org/projects/xmldiff

--
Uche Ogbuji   Fourthought, Inc.
http://uche.ogbuji.nethttp://fourthought.com
http://copia.ogbuji.net   http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

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


Re: Web Browser Pygame Plug-in?

2006-07-10 Thread Ben Sizer
Gregory Piñero wrote:
> That's interesting, Ben.  So we'd be better off making a new library
> similiar to Pygame in functionality but designed from the ground up to
> work in a browser.

I think it depends on what is most important to you. Options available
include going with Java or Flash instead (ie. dropping Python), or
using a Jython applet (which I know nothing about), or perhaps
abandoning the browser and sticking with PyGame, etc. What are your
requirements?

> I guess that XPCOM technology that someone
> mentioned might be the way to go?

I was under the impression that XPCOM was a Mozilla-only technology; if
so, maybe that won't fit your requirements either.

-- 
Ben Sizer

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


  1   2   3   >