Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Do Re Mi chel La Si Do
Hi !

>>> ...Usenet to transmit it properly

newsgroups (NNTP) : yes, it does it
usenet : perhaps (that depends on the newsgroups)
clp : no





Michel Claveau


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


Re: Accessing MDB files on Windows

2005-01-20 Thread David Fraser
Jorge Luiz Godoy Filho wrote:
Jorge Luiz Godoy Filho, Quarta 19 Janeiro 2005 14:25, wrote:

Thanks!  I'm looking at it.

Worked like a charm!  And just now I noticed who's the author of the
recipe ;-)
You may also be interested in using a DB-API compatible driver for ADO - 
 see for example http://adodbapi.sourceforge.net/
That way if you want to switch to a different database you can more 
easily...

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


Re: Zen of Python

2005-01-20 Thread Antoon Pardon
Op 2005-01-19, Steve Holden schreef <[EMAIL PROTECTED]>:
> Peter Hansen wrote:
>
>> Timothy Fitz wrote:
>> 
>>> While I agree that the Zen of Python is an amazingly concise list of
>>> truisms, I do not see any meaning in:
>>>
>>> Flat is better than nested.
>>>
> [incrdeibly secret PSU facts blurted out]
>> 
>> And with that out of the way, one is left with "there's a balance
>> along the flat/nested dimension which is appropriate to any
>> given situation, so nest with moderation and only when necessary".
>> 
> They'd probably been talking to Antoon Pardon :-)

Just what I thought: They'll be accusing me of this :-)

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


Re: list item's position

2005-01-20 Thread Petr Prikryl
> On Wed, 19 Jan 2005 22:04:44 -0500, Bob Smith wrote:
> > [...] how to find an element's numeric value (0,1,2,3...)
> > in the list. Here's an example of what I'm doing:
> > 
> > for bar in bars:
> > if 'str_1' in bar and 'str_2' in bar:
> >print bar
> > 
> > This finds the right bar, but not its list position. The reason I
need
> > to find its value is so I can remove every element in the list
before it
> > so that the bar I found somewhere in the list becomes element 0...
does
> > that make sense?

I have borrowed the bars list example from 
"Bill Mill"s solutions and here are
the two solutions...

bars = ['str', 'foobaz', 'barbaz', 'foobar']


# Solution 1: The enumerate().

for idx, bar in enumerate(bars):
if 'bar' in bar and 'baz' in bar:
break

bars_sliced = bars[idx:]
print bars_sliced


# Solution 2: Low level approach, testing and removing combined. In
situ.

while bars: # some prefer len(bars) > 0, which is less magical, IMHO
bar = bars.pop(0)   # get and remove the first
element
if 'bar' in bar and 'baz' in bar:
bars.insert(0, bar) # insert the tested back
break   # and finish

print bars
 

The result is ['barbaz', 'foobar'] in both cases.   

Petr
-- 
Petr Prikryl (prikrylp at skil dot cz) 
--
http://mail.python.org/mailman/listinfo/python-list


RE: Solutions for data storage?

2005-01-20 Thread Robert Brewer
Leif K-Brooks wrote:
> Robert Brewer wrote:
> > Try svn://casadeamor.com/dejavu/trunk if you want a truly 
> Pythonic query
> > syntax. Wait a couple of days, and I'll have version 1.3 ready and
> > online at http://www.aminus.org/rbre/python -- lots of changes from
> > 1.2.6 which is there now, but at least you can read old 
> docs online now
> > without svn.
> 
> Thanks a lot for the reply. I've skimmed the documentation (very 
> well-written, by the well), and I really like the looks of what I've 
> seen so far. I'm a bit confused about where sandboxes get created, 
> though; in a Web application, would I give each request a 
> sandbox of its 
> own, or create one for the entire application, or what?

Correct; in a Web application, each request should get its own sandbox.
Here's a sample mod_python request.py script, where "cation" is my
webapp framework, and "mcontrol" is the name of the app itself, which
possesses a Dejavu arena object.



from cation.html.uimodpython import UserInterfaceModPython
import mcontrol

def handler(req):
ui = UserInterfaceModPython(mcontrol.application)
ui.sandbox = mcontrol.arena.new_sandbox()
ui.request(req)
ui.sandbox.flush_all()
return ui.status_code




Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]

P.S. I've finally tested postgres, mysql, and sqlite on both Debian
Linux and Windows 2k, and made the final updates. So the 1.3 release
should be _very_ soon.
--
http://mail.python.org/mailman/listinfo/python-list


Re: rotor replacement

2005-01-20 Thread Peter Maas
Paul Rubin schrieb:
Wasn't there a default 40-bit version that was ok (weak), but you had
to declare yourself US resident to download 128-bit support?

That was years ago.  The regulations changed since then, so they all
have 128 bits now.
Perhaps the NSA has found a way to handle 128bit in the meantime.
But this is unlikely because there is no export regulation to ban
512bit as far as I know :)
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: rotor replacement

2005-01-20 Thread Robin Becker
Peter Maas wrote:
Paul Rubin schrieb:
Wasn't there a default 40-bit version that was ok (weak), but you had
to declare yourself US resident to download 128-bit support?

That was years ago.  The regulations changed since then, so they all
have 128 bits now.

Perhaps the NSA has found a way to handle 128bit in the meantime.
But this is unlikely because there is no export regulation to ban
512bit as far as I know :)
Apparently factorization based crypto is on the way out anyhow (as an 
article in Scientific American is reported to claim).

http://www.sciam.com/article.cfm?chanID=sa006&articleID=000479CD-F58C-11BE-AD0683414B7F&ref=rdf
-can't wait to get my quantum computer-ly yrs-
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list


RE: Print to Windows default Printer

2005-01-20 Thread Tim Golden
[Samantha]
| Thanks Tim. I didn't realize it would be so difficult.
| S

Strictly, if all you want to do is print text and you
have mapped LPTx: to some printer (local or network)
then the venerable "PRINT " or "COPY  LPTx:"
may well be what you want. You can issue these via
an os.system call from within Python, and if that serves
the purpose, well...



import os

f = open ("temp.txt", "w")
f.write ("""I must go down to the sea again,
To the lonely sea and the sky.
And all I ask is a tall ship
And a star to steer her by.
""")
f.close ()

os.system ("print temp.txt")



TJG


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

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


Re: Dictionary keys (again) (was Re: lambda)

2005-01-20 Thread Nick Coghlan
David Eppstein wrote:
Yes, and what should the following do?
lst1 = [1]
lst2 = [2]
dct = {lst1: "1", lst2: "2"}
lst2[0]=1
lst1[0]=2
print dct[[1]]
print dct[[2]]
Provide yet another example for why mutable keys are almost guaranteed to result 
in suprising semantics :)

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


Re: [OT] Good C++ book for a Python programmer

2005-01-20 Thread Petr Prikryl
Try also the Bruce Eckel's "Thinking in C++".
It is also available on-line for free at
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html

I like the book because it explains the things
very clearly. After reading it, one will stop 
to think and say that C++ is "only C with 
strange OO things on the top".

Petr

"Paul Rubin" wrote in message
news:<[EMAIL PROTECTED]>...
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > I was wondering whether anyone could recommend a good C++ book, with
> > "good" being defined from the perspective of a Python programmer. I
> > realize that there isn't a book titled "C++ for Python Programmers",
> > but has anyone found one that they think goes particularly well with
> > the Python way?
> 
> I think it's not possible to really grok C++ without having worked on
> large multi-person C projects and understood what problems C++ tried
> to solve.  The only good book I know about C++ is by Stroustrup, "The
> C++ Programming Language" or something like that; it's not an easy
> book though.
--
http://mail.python.org/mailman/listinfo/python-list


RE: Automatic Windows printer creation?

2005-01-20 Thread Tim Golden
[Roger Upole]
| 
| You can probably do it through WMI.  (class is Win32_Printer)
| WMI works well with win32com, and there's also a wrapper module
| 
| http://tgolden.sc.sabren.com/python/wmi.html
| 
| for simplified access.
| I imagine getting all the device parameters and port
| configuration right will be messy, though.
| 

And here's a handy link (warning: long URL):

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
wmi_tasks__printers_and_printing.asp

(I got that by googling for Win32_Printer and
then for AddPrinterConnection).

But... you'd better be using XP or 2K3 because,
almost comically, each of the examples is prefixed
by a " does not work on Windows 2000,
Windows NT, Windows 98, Windows 95".

TJG


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

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


why are these not the same?

2005-01-20 Thread Lowell Kirsh
On a webpage (see link below) I read that the following 2 forms are not 
the same and that the second should be avoided. They look the same to 
me. What's the difference?

Lowell

def functionF(argString="abc", argList = None):
if argList is None: argList = []
...
def functionF(argString="abc", argList=None):
argList = argList or []
...
http://www.ferg.org/projects/python_gotchas.html (number 5)
--
http://mail.python.org/mailman/listinfo/python-list


Re: why are these not the same?

2005-01-20 Thread Fredrik Lundh
Lowell Kirsh wrote:
> On a webpage (see link below) I read that the following 2 forms are not the 
> same and that the 
> second should be avoided. They look the same to me. What's the difference?

> def functionF(argString="abc", argList = None):
> if argList is None: argList = []
> ...
>
> def functionF(argString="abc", argList=None):
> argList = argList or []
> ...

"is None" tests for None, "argList or" tests for a false value.  None is
false, but many non-None objects are also false.

"should be avoided" sounds like overly zealous advice to me; use the
latter form if you understand it.

 



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


Oddity is shutil.copyfileobj

2005-01-20 Thread Neil Benn
Hello,
 I'm running a program which is using shutil.copyfileobj on a 
Win2K Pro, python 2.3 box.  The source and dest file are both opened in 
textual mode as 'w', the source file on the local hard drive and the 
dest file is on a file server (transmitted through a samba server), the 
block size for copying is not entered - so the default setting is used 
(whatever that is). 

   The files are copied across perfectly (diffing them shows they are 
identical), however I have one small problem, the destination filename 
has .read appended to the end.  I've checked my code again and again and 
I'm definatly not apeending this.

   I'm also copying files across, in the same program but the source 
and dest are binary - this doesn't have the same problem, the filenames 
are not changed.

   My question is - has anyone else seen this behaviour?
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionary keys (again) (was Re: lambda)

2005-01-20 Thread Nick Coghlan
Antoon Pardon wrote:
As you said yourself, people use shortcuts when they express themselves.
With 'mutable key' I mean a mutable object that is used as a key.
That doesn't contradict that the key itself can't change because
it is inaccessible.
Yeah - this was the point of terminology that was getting confused, I think. And 
your interpretation was closer to the strict sense of the words.

Well, the Zen of Python states "In the face of ambiguity, refuse the temptation 
to guess".
But python does guess in the case of the value. If I want to establish a
relationship between "foo" and [3, 5, 8] then I can be in big trouble
if that list gets mutated in something else.
However, the actual promise a Python dict makes is that it maps from keys by 
value to values by identity.

That is, "k1 == k2" implies "d[k1] is d[k2]". An identity test on mutable 
objects is entirely unambiguous (hence they can be values), but comparison is 
not (hence they cannot be keys). Restricting keys to immutable objects 
eliminates the ambiguity. Copying keys would also prevent mutation and eliminate 
the ambiguity. The restriction approach is a *definite* performance enhancement 
over the copying approach, though (this is probably the origin of the mantra 
"the restriction to mutable keys is a performance enhancement"). The resulting 
semantics of the restriction to immutable objects are also significantly less 
surprising than those of the copying approach.

An identity dict would make the promise that "k1 is k2" implies "d[k1] is 
d[k2]". In this case, the mutability of the key is irrelevant, so the behaviour 
is unambiguous without any additional restrictions.

But they don't have to be immutable within the dictionary itself, that
is just an implementation detail. The only thing that matters is that
the dictionary can reproduce the relationship. How that is done is
immaterial. 
Given the Python interpreter's current definition of "immutable" as "defines 
__hash__", it's a little hard to have an unhashable object as a key :)

In short, sane hash tables require immutable keys, and how mutable keys acquire 
the requisite immutability is going to be application dependent.

No they don't, that is just the most easy implementation. If some
implementation would constantly change the internal objects but 
consulting the dictionary wouldn't show any different effect then
that would be fine too. And even in this case a mutation
from the outside would probably cause havoc because it would ruin
the sanity of the internal structure.
If you insist: s/immutable/effectively immutable/
And no data type can be expected to tolerate having their invariants violated by 
external code messing with internal data structures.

Provision of a safe_dict or identity_dict would merely allow a programmer to 
state their intent at the time the container is created, rather than having to 
state it whenever keys are generated or referenced.
Well that would be a good thing IMO.
True - I'm not sure how that 'merely' snuck in there :)
Good enough in any case for me to
spend some time analyzing the requirements. Whether I'll actually
implement something depends on how much time I have and how often I
need it.
My preference is for the identity dict - its performance would actually be 
*better* than that of a standard dict in the domains where it applies 
(annotation and classification of objects are the two main uses I can see for 
such a data structure). This aligns quite well with the stated goal of the 
collections module (providing data structures that are less general purpose than 
the standard builtins, but deliver better performance for their particular use 
cases)

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


Re: why are these not the same?

2005-01-20 Thread Lowell Kirsh
D'oh I should've caught that myself.
Thanks.
Fredrik Lundh wrote:
Lowell Kirsh wrote:
On a webpage (see link below) I read that the following 2 forms are not the same and that the 
second should be avoided. They look the same to me. What's the difference?

def functionF(argString="abc", argList = None):
   if argList is None: argList = []
   ...
def functionF(argString="abc", argList=None):
   argList = argList or []
   ...

"is None" tests for None, "argList or" tests for a false value.  None is
false, but many non-None objects are also false.
"should be avoided" sounds like overly zealous advice to me; use the
latter form if you understand it.
 


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


Re: rotor replacement

2005-01-20 Thread Paul Rubin
Robin Becker <[EMAIL PROTECTED]> writes:
> Apparently factorization based crypto is on the way out anyhow (as an
> article in Scientific American is reported to claim).

I haven't seen that SA article but I saw the Slashdot blurb.  They
have confused "quantum cryptography" with quantum computation, when
they are entirely different things.  Quantum cryptography (basically
communicating a message over an optical fiber in such a way that any
attempt to eavesdrop is supposed destroy the readability of the
message) has been done over quite long distances, 10's of km or even
more.  Quantum computation is mostly a theoretical speculation.  The
largest quantum computer ever built held seven bits, and factored the
number 15 into its factors 3 and 5.  Building larger ones seems to
have complexity exponential in the number of bits, which is not too
much better than using an exponential-time algorithm on a conventional
computer.  It's not even known in theory whether quantum computing is
possible on a significant scale.  There are just some theorems about
what properties such a computer would have, if it can exist.  One of
them, however, is being able to factor in P-time, and that caused
lots of excitement.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list item's position

2005-01-20 Thread Bengt Richter
On Wed, 19 Jan 2005 22:04:44 -0500, Bob Smith <[EMAIL PROTECTED]> wrote:

>Hi,
>
>I have a Python list. I can't figure out how to find an element's 
>numeric value (0,1,2,3...) in the list. Here's an example of what I'm doing:
>
>for bar in bars:
>if 'str_1' in bar and 'str_2' in bar:
>   print bar
>
>This finds the right bar, but not its list position. The reason I need 
>to find its value is so I can remove every element in the list before it 
>so that the bar I found somewhere in the list becomes element 0... does 
>that make sense?
>
sneaky (python 2.4) one-liner (not tested beyond what you see, and not 
recommended
as the best self-documenting version ;-)

 >>> bars = [
 ... 'zero',
 ... 'one',
 ... 'str_1 and str_2 both in line two',
 ... 'three',
 ... 'four',
 ... 'str_1 and str_2 both in line five',
 ... 'last line']

 >>> newbar=bars[sum(iter(('str_1' not in bar or 'str_2' not in bar for bar in 
 >>> bars).next, 0)):]
 >>> for s in newbar: print repr(s)
 ...
 'str_1 and str_2 both in line two'
 'three'
 'four'
 'str_1 and str_2 both in line five'
 'last line'

Alternatively:

 >>> newbar=bars[[i for i,v in enumerate(bars) if 'str_1' in v and 'str_2' in 
 >>> v][0]:]
 >>> for s in newbar: print repr(s)
 ...
 'str_1 and str_2 both in line two'
 'three'
 'four'
 'str_1 and str_2 both in line five'
 'last line'

Alternatively:

 >>> newbar = list(dropwhile(lambda x: 'str_1' not in x or 'str_2' not in x, 
 >>> bars))
 >>> for s in newbar: print repr(s)
 ...
 'str_1 and str_2 both in line two'
 'three'
 'four'
 'str_1 and str_2 both in line five'
 'last line'

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


RE: Oddity is shutil.copyfileobj

2005-01-20 Thread Tim Golden
[Neil Benn]
| I'm running a program which is using 
| shutil.copyfileobj on a Win2K Pro, python 2.3 box.  

Just for (possible) reassurance, I've just
run the following code snippet on my Win2k
Python 2.3.4 box and it seemed to work
without adding any oddities to the file name. 
I'm copying to a "real" Windows file share, not
a Samba box, so it may make a difference.


import shutil

f = open ("test.py", "rt")
g = open (r"\\tdi_nt4a\user\goldent\temp\test.py", "wt")
try:
  shutil.copyfileobj (f, g)
finally:
  f.close ()
  g.close ()



| The source and dest file are both opened in 
| textual mode as 'w'

Well my first question (which may or may not be relevant)
is: what do you mean by this? Are they both opened for
*writing*, which is what the "w" implies? Or was that
merely a typo for "t", meaning that you had explcitly
selected text mode as opposed to binary mode?

| The files are copied across perfectly (diffing them shows
| they are identical), however I have one small problem, 
| the destination filename has .read appended to the end.  
| I've checked my code again and again and I'm definatly 
| not apeending this.

Any chance you could *post* the code (at least the
section in question)? The source for copyfileobj, which
was the first place I looked is this:


def copyfileobj(fsrc, fdst, length=16*1024):
"""copy data from file-like object fsrc to file-like object fdst"""
while 1:
buf = fsrc.read(length)
if not buf:
break
fdst.write(buf)


And unless there's something *really* subtle going on,
I'm not sure I could spot any filename changing there.
I'm afraid that, short of some obscure bug in Samba,
which should show up regardless of what you're copying
across, your own code is the most likely culprit.

TJG


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

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


Freezing a mutable (was Re: lambda)

2005-01-20 Thread Nick Coghlan
Antoon Pardon wrote:
Interesting idea. But I think you are wrong when you say that two lists
that compare equal at the time they are frozen, will get the same
dictionary entry. The problem is an object must compare equal to
the key in the dictionary to get at the same entry. So if you freeze
a list and its copy but then mutate them differently, they no longer
are equal and so wont get you at the same entry.
The trick is that the result of the freezing operation is cached until such time 
as you explicitly unfreeze the object.

Output:
x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
y: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Write via x, read via y: Hi there!
x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y: [0, 1, 2, 3, 4, 5, 6, 7, 8]
Read via mutated x: Hi there!
Read via mutated y: Hi there!
x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y: [0, 1, 2, 3, 4, 5, 6, 7, 8]
Found unfrozen x: False
Found unfrozen y: False
Produced by:
class mylist(list):
  def __init__(self, arg):
super(mylist, self).__init__(arg)
self._tuple = None
  def frozen(self):
if self._tuple is None:
  self._tuple = tuple(self)
return self._tuple
  def unfreeze(self):
self._tuple = None
x = mylist(range(10))
y = mylist(range(10))
dct = {}
dct[x.frozen()] = "Hi there!"
print "x:", x
print "y:", y
print "Write via x, read via y:", dct[y.frozen()]
x.append(10)
del y[-1]
print "x:", x
print "y:", y
print "Read via mutated x:", dct[x.frozen()]
print "Read via mutated y:", dct[y.frozen()]
x.unfreeze()
y.unfreeze()
print "x:", x
print "y:", y
print "Found unfrozen x:", x.frozen() in dct
print "Found unfrozen y:", y.frozen() in dct
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: why are these not the same?

2005-01-20 Thread Duncan Booth
Lowell Kirsh wrote:

> On a webpage (see link below) I read that the following 2 forms are not 
> the same and that the second should be avoided. They look the same to 
> me. What's the difference?
> 
> Lowell
> 
> 
> 
> def functionF(argString="abc", argList = None):
>  if argList is None: argList = []
>  ...
> 
> def functionF(argString="abc", argList=None):
>  argList = argList or []
>  ...
> 
> http://www.ferg.org/projects/python_gotchas.html (number 5)

If functionF mutates its argument then these two will give different and 
possibly unexpected results. I suspect this is what they are hinting at:

>>> def f1(s="abc", l=None):
if l is None: l = []
l.append(s)
return '*'.join(l)

>>> def f2(s="abc", l=None):
l = l or []
l.append(s)
return '*'.join(l)

>>> f1('foo', ['bar'])
'bar*foo'
>>> f2('foo', ['bar'])
'bar*foo'
>>> f1('foo', [])
'foo'
>>> f2('foo', [])
'foo'

So far the functions appear to operate identically. But:

>>> myList = []
>>> f1('foo', myList)
'foo'
>>> myList
['foo']
>>> myList = []
>>> f2('foo', myList)
'foo'
>>> myList
[]

It looks as though f1 mutates its argument but f2 doesn't, until you try:

>>> f2('foo', myList)
'bar*foo'
>>> myList
['bar', 'foo']
>>> 
>>> 

So f2 mutates a non-empty list but leaves an empty list unchanged which is 
probably not what you intend and certainly confusing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Zen of Python

2005-01-20 Thread Nick Coghlan
Paul Rubin wrote:
>  But it's often predictable at the
beginning what the final destination is going to be.  So once we can
see where it's going, why not proceed to the finish line immediately
instead of bothering with the intermediate steps?
Because getting there incrementally helps to make sure you end up with the 
features you need, without the irrelevant baggage an overengineered solution may 
bring with it.

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


[Fwd: Re: Oddity is shutil.copyfileobj]

2005-01-20 Thread Neil Benn

--- Begin Message ---
Tim Golden wrote:
[Neil Benn]
| I'm running a program which is using 
| shutil.copyfileobj on a Win2K Pro, python 2.3 box.  

Just for (possible) reassurance, I've just
run the following code snippet on my Win2k
Python 2.3.4 box and it seemed to work
without adding any oddities to the file name. 
I'm copying to a "real" Windows file share, not
a Samba box, so it may make a difference.


import shutil
f = open ("test.py", "rt")
g = open (r"\\tdi_nt4a\user\goldent\temp\test.py", "wt")
try:
 shutil.copyfileobj (f, g)
finally:
 f.close ()
 g.close ()

 


Hello,
 Sorry for the typo, the source was opened as 'w+' and the dest 
was opened as 'w'.  I was going from a source on the local hard drive to 
a samba server and getting a .read at the end.  When I do this on the 
local hard drive, the files are copied.  I was doing something like

OPEN SOURCE IN WRITE
OPEN DEST IN WRITE
WRITE TO SOURCE
FLUSH SOURCE
SEEK SOURCE to BYTE 0
COPY SOURCE TO DEST
CLOSE SOURCE
CLOSE DEST
   This works on a local hard drives with no problems, therefore I have 
a feeling that it is something to do do with my setup here.  However I'm 
working on a test example that I can post, currently my server is 
slapping me so I'll get the test code when it calms down!

   Thanks for the reply.
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com

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

[ANN] MarkupToMarkup 0.2

2005-01-20 Thread François Granger
Description:
http://wiki.fgranger.com/Development/MarkupToMarkup

Test:
http://fgranger.net1.nerim.net/mtom/

MarkupToMarkup is a project to create tools for translating from various
markup to various markup.

There are a lot of syntax to markup texts prior to publishing them. From
HTML to Markdown, and from reStructuredText to the various wiki formats.
When using a tool to publish, you are tied to the particular syntax of this
tool. And transferring between them is a problem, not only at the storage
level, but also at the text markup level.

MarkupToMarkup is built in a modular way. It use the various existing
filters to transfer the input to a almost XHTML format. It then use a parser
and filters to generate the various wiki like syntax formats. As demand
arise, it may be extended in number of filters, in input and output methods.

Dues to the number of scripts (Python, Perl, soon some PHP) and
dependencies, the current version is implemented as a web service on a web
page. There are plans to make it an XML-RPC service, or package it when
things evolves.

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


[ANN] tconfpy 2.112 Released And Available

2005-01-20 Thread Tim Daneliuk
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
'tconfpy' Version 2.112 is now released and available for download at:
~ http://www.tundraware.com/Software/tconfpy
The last public release was 1.185 (5-2-2004)
This is a significant bugfix and feature upgrade release.  Existing
users are strongly encouraged to upgrade.  Be aware that the passed
and returned API parameters have changed, as have some of the
semantics of the configuration language, so existing code and/or
configuration files may need to be edited accordingly.
Complete details can be found in the WHATSNEW.txt file included in the
distribution.
Users are strongly encouraged to join the tconfpy-users mailing list as
described in the documentation.
What Is 'tconfpy'?
- --
'tconfpy' is an advanced configuration file parser and validator for
Python programs.  By using 'tconfpy', Python programmers can provide
their users with an external configuration file for setting program
options, defining defaults, and so on.  'tconfpy' offloads the
responsibility for parsing and validating a configuration file from
the main application. The Python programmer need only deal
with the results and any errors or warnings generated during the
parsing process.
'tconfpy' recognizes a rich configuration language and provides a
number of sophisticated programming features including:
~- The ability to breakup large configurations into smaller pieces
~  via the '.include' directive.
~- Support for string substitution and concatenation throughout the
~  configuration file via string variables.  Variables may be
~  locally declared, a reference to a symbol already in the
~  symbol table, or a reference to an environment variable.
~- A complete set of conditional directives for selective
~  processing of configuration options. Both existential ("If
~  variable exists ...") and comparison ("if string equals/does not
~  equal string ...") forms are provided, as is an '.else'
~  directive.
~- The ability to instantiate program options prior to reading a
~  configuration file and make them mandatory by declaring those
~  options as Read-Only.
~- Optional type validation to ensure that a user enters a value
~  appropriate for boolean, integer, floating point, string, or
~  complex data.
~- Optional value validation to ensure that a configuration option
~  is either within a specified range or one of an enumerated set
~  of possible values.  For configuration options which are string
~  types, 'tconfpy', can optionally specify min/max string lengths
~  and enumerate a set of legitimate regular expressions that the
~  string must match.
~- The ability to define an arbitrary number of lexical namespaces.
~- The ability to use the various features of 'tconfpy' as a pre-
~  processor for any other text (including source code for other
~  programming languages and Python itself) via the '.literal'
~  directive.
~- The ability to "template" classes of variables, thereby predefining
~  the type and value restrictions for such variables.  This makes
~  'tconfpy' useful as a building block for data validation tools.
~- An optional debug capability which returns detailed information
~  about each line parsed.
~- Includes a test driver program for learning how to program with
~  'tconfpy' and for debugging and testing your own configuration
~  files.
~- Comes with approximately 40 pages of documentation including a
~  Programmer's API Reference and a User's Guide to the 'tconfpy'
~  configuration language.  Documentation is provided in several
~  formats including Unix 'man', Plain Text, html, pdf, and
~  Postscript.
'tconfpy' is a Pure Python module and is platform-independent.
It should work identically on any platform on which Python runs.
- --
Tim Daneliuk
[EMAIL PROTECTED]






-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.6 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFB744ayjgA+Mact+YRAopHAJ952scQ/LVBz5ye+VARvuhsKk+9cgCfYNSQ
LLuefsso1mXxdh38EEovuCo=
=ojco
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-list


Class introspection and dynamically determining function arguments

2005-01-20 Thread Mark English
I'd like to write a Tkinter app which, given a class, pops up a
window(s) with fields for each "attribute" of that class. The user could
enter values for the attributes and on closing the window would be
returned an instance of the class. The actual application I'm interested
in writing would either have simple type attributes (int, string, etc.),
or attributes using types already defined in a c-extension, although I'd
prefer not to restrict the functionality to these requirements.

The only way I can imagine to do this is to create an instance of the
class in question, and then start poking around in its attributes
dictionary (initially just using dir). So firstly, if there is instead a
way to do this without creating an instance I'd be interested.

Secondly, the code won't know exactly how to initialise the class
instance used to determinte the attributes. Do I need to make it a
prerequesite that all instances can be created with no arguments ?
Should I force/allow the user to pass an instance instead of a class ?
Should I be using inspect.getargspec on the class __init__ method and
then a loop with a try and a lot of except clauses, or is there a nicer
way to do this ? Presumably the pickling code knows how do
serialise/deserialise class instances but I'm not sure how I'd use this
without already having a class instance to hand.

Lastly, does such an app already exist ?

Thanks for any help.


---
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary 
companies.
---

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


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Jorge Luiz Godoy Filho
Fredrik Lundh, Quinta 20 Janeiro 2005 05:17, wrote:

> what does it give you on your machine?  (looks like wxPython cannot handle
> Unicode strings, but can that really be true?)

It does support Unicode if it was built to do so... 

-- 
Godoy. <[EMAIL PROTECTED]>

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


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Fredrik Lundh
Jorge Luiz Godoy Filho wrote:

>> what does it give you on your machine?  (looks like wxPython cannot handle
>> Unicode strings, but can that really be true?)
>
> It does support Unicode if it was built to do so...

Python has supported Unicode in release 1.6, 2.0, 2.1, 2.2, 2.3 and 2.4, so
you might think that Unicode should be enabled by default in a UI toolkit for
Python...

 



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


Re: Class introspection and dynamically determining function arguments

2005-01-20 Thread Diez B. Roggisch
Mark English wrote:

> The only way I can imagine to do this is to create an instance of the
> class in question, and then start poking around in its attributes
> dictionary (initially just using dir). So firstly, if there is instead a
> way to do this without creating an instance I'd be interested.

This is the only way to go, as python has no attribute declarations as
static compiled languages have. But of course not all classes may feature
default constructors so that creating an instance is impossible. Or you
create unwanted sideeffects - think of the notorious class
DeleteMyHarddisk

As youself already mentioned that maybe you have to impose certain
prerequisites, you maybe want to extend this to the point where for each
class you want to make dynamically instantiatable you need some
declaration. This of course depends on your desired application - whatfor
is it planned? 

-- 
Regards,

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


Re: Freezing a mutable (was Re: lambda)

2005-01-20 Thread Antoon Pardon
Op 2005-01-20, Nick Coghlan schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> Interesting idea. But I think you are wrong when you say that two lists
>> that compare equal at the time they are frozen, will get the same
>> dictionary entry. The problem is an object must compare equal to
>> the key in the dictionary to get at the same entry. So if you freeze
>> a list and its copy but then mutate them differently, they no longer
>> are equal and so wont get you at the same entry.
>
> The trick is that the result of the freezing operation is cached until such 
> time 
> as you explicitly unfreeze the object.

I missed that you would use it with the idiom: dct[x.frozen()]

I have two problems with this approach.

1) It doesn't work when you get your keys via the keys/items
   methods.

2) This is rather minor, but a user could still unfreeze
   untimely 

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


Re: Class introspection and dynamically determining function arguments

2005-01-20 Thread Nick Coghlan
Diez B. Roggisch wrote:
Mark English wrote:
As youself already mentioned that maybe you have to impose certain
prerequisites, you maybe want to extend this to the point where for each
class you want to make dynamically instantiatable you need some
declaration. This of course depends on your desired application - whatfor
is it planned? 
If this only has to work for classes created for the purpose (rather than for an 
arbitrary class):

Py> class Buildable(object):
...   __slots__ = ["x", "y"]
...   def __init__(self, **kwds):
... super(Buildable, self).__init__(self, **kwds)
... for attr in Buildable.__slots__:
...   setattr(self, attr, kwds[attr])
...
Py> b = Buildable(x = 1 , y = 2)
Py> b.x
1
Py> b.y
2
(Note that you don't *have* to use slots, you can use a non-special class 
attribute if you don't want the other side effects)

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


RE: RuntimeError: dictionary changed size during iteration

2005-01-20 Thread Batista, Facundo
Title: RE: RuntimeError: dictionary changed size during iteration





[Robert Brewer]


#- > >>> [e for e in vars()]
#- > Traceback (most recent call last):
#- >   File "", line 1, in ?
#- > RuntimeError: dictionary changed size during iteration
#- > >>> e = None
#- > >>> [e for e in vars()]
#- > ['e', '__builtins__', 'rlcompleter', '__file__', '_[1]', 
#- > 'atexit', '__name__',
#- > 'readline', '__doc__']
#- 
#- But not unexpected, since vars() returns a dictionary, and 
#- binding 'e'
#- changes that dictionary while you are iterating over it. Try either:


For me, the point is: vars() returns the local variables as a list or is a generator?


In the docs don't say nothing about this.


If it returns a list, it should NOT raise an error; if it's a generator, the error is fine.


.    Facundo


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



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Re: Freezing a mutable (was Re: lambda)

2005-01-20 Thread Nick Coghlan
Antoon Pardon wrote:
I missed that you would use it with the idiom: dct[x.frozen()]
The list itself isn't hashable with this approach, so you don't have much 
choice. I wasn't particularly clear about that point, though.

I have two problems with this approach.
1) It doesn't work when you get your keys via the keys/items
   methods.
True - the frozen object has no link back to the original object. That could be 
added though (by returning a tuple subtype with the extra attribute)

2) This is rather minor, but a user could still unfreeze
   untimely 
True - doing that is less likely than mutating a hashable list though :)
I'm just noting this as a way to avoid copying data more than once when storing 
immutable copies of mutable data in a dictionary. You're quite right that there 
isn't a really clean idiom for doing that in Python (aside from moving to a 
different data structure that works natively as a dict key, naturally).

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


Re: Class introspection and dynamically determining function arguments

2005-01-20 Thread Diez B. Roggisch
Nick Coghlan wrote:
> 
> If this only has to work for classes created for the purpose (rather than
> for an arbitrary class):
> 

Certainly a step into the direction I meant - but still missing type
declarations. And that's what at least I'd like to see - as otherwise you
don't know what kind of editing widget to use for a property.
-- 
Regards,

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


Re: xml parsing escape characters

2005-01-20 Thread Luis P. Mendes
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
this is the xml document:

http://www..";>
~   
~ 439
(... others ...)
~   

When I do:
print xmldoc.toxml()
it prints:

http://www...";>
~  
~439
~  

__
with:   stringNode = xmldoc.childNodes[0]
print stringNode.toxml()
I get:
http://www...";>
~  
~439
~  

__
with:   DataSetNode = stringNode.childNodes[0]
print DataSetNode.toxml()
I get:

~  
~439
~  

___-
so far so good, but when I issue the command:
print DataSetNode.childNodes[0]
I get:
IndexError: tuple index out of range
Why the error, and why does it return a tuple?
Why doesn't it return:

439

??
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFB76y3Hn4UHCY8rB8RAvQsAKCFD/hps8ybQli8HAs3iSCvRjwqjACfS/12
5gctpB91S5cy299e/TVLGQk=
=XR2a
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-list


Problem in importing MySQLdb

2005-01-20 Thread Gurpreet Sachdeva
I am using Mysql version 5.0.2-alpha on RedHat 9.0 (python2.2)

When I try to import MySQldb

I get:
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.2/site-packages/MySQLdb/__init__.py", line 27, in ?
import _mysql
ImportError: /usr/lib/libmysqlclient.so.10: symbol errno, version
GLIBC_2.0 not defined in file libc.so.6 with link time reference

Is there any problem in library files?? Do I need to install anything
I have installed MySQL-shared-3.23.54a-1.i386.rpm,
MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm,
MySQL-server-5.0.2-0.i386.rpm

Please help,
Garry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem in importing MySQLdb

2005-01-20 Thread deelan
Gurpreet Sachdeva wrote:
I am using Mysql version 5.0.2-alpha on RedHat 9.0 (python2.2)
When I try to import MySQldb
i' not completely sure mysqldb works with mysql 5.0 and its
bundled client libraries.
to be more precise:
'' MySQL-5.0 and newer are not currently supported,
but might work.''
from:


Is there any problem in library files?? Do I need to install anything
I have installed MySQL-shared-3.23.54a-1.i386.rpm,
MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm,
MySQL-server-5.0.2-0.i386.rpm
are u sure you have compiled mysqldb against 5.0
client libs?
you may want to post on the mysqldb forum of ask
for help there:

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


Re: mod_python friendly isps in europe

2005-01-20 Thread Daniel Bowett
[EMAIL PROTECTED] wrote:
Hello everybody
I'm thinking about improving my web site scripts
and would like to use Python instead of PHP/Perl.
Does anyone know of mod_python friendly ISPs in
europe? With prices around 10€ ?
Thanks in advance,
Paulo
I would doubt you will find any commercial python ISP's out there. If 
you do could you post them here?

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


Re: xml parsing escape characters

2005-01-20 Thread Kent Johnson
Luis P. Mendes wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
this is the xml document:

http://www..";>
~   
~ 439
(... others ...)
~   

This is an XML document containing a single tag, , whose content is text containing 
entity-escaped XML.

This is *not* an XML document containing tags , , , 
etc.
All the behaviour you are seeing is a consequence of this. You need to unescape the contents of the 
 tag to be able to treat it as structured XML.

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


Re: Zen of Python

2005-01-20 Thread Steve Holden
Paul Rubin wrote:
Tim Peters <[EMAIL PROTECTED]> writes:
Huh?  [1,2,[3,4,5],[6,7]],8 is a perfectly valid Python list.
You're claiming not to know any relevant difference between Python
lists and Lisp lists?  Heh.

Python doesn't provide syntactic sugar for [1,[2,[3,[4,[] if
that's what you mean.  In Lisp you'd say (1 2 3 4).  It's still
a perfectly valid list in Python.  Python by convention uses
multi-element arrays instead of lists of conses.
But how, in Lisp, would you transliterate the Python list [1, 2, 3, 4]? 
Clearly the Python list *is* different, and the tradeoff was to obtain 
speed of random access, presumably (I wasn't taking an interest in 
Python in its early days) anticipating that non-recursive algorithms 
would be the norm.

And you can break out of a containing loop from a nested loop
with try/raise.
Heh heh.  Yes, you can.  I've never seen a real Python program that
did, but there's nothing to stop you.  
 >
I do that on a fairly routine basis.  I won't say "often", but it's a
standard technique that finds a use now and then.
Well, I blush to say I have done that (once, if my memory serves me 
correctly), but it was an ugly program, and I did eventually refactor 
the code so that the loops were in separate scopes, which made it much 
cleaner.

[...]
There's a technique in numerical analysis called Richardson
extrapolation, where you compute an integral by  [...]
Wow. Anyone who feels the need to explain numerical analysis techniques 
to Tim Peters is wasting keystrokes big-time. Anyway, Richardson 
extrapolation is merely one of many successive approximation techniques, 
which is what you are talking about, no?

I see the same thing happening in Python.  It's going through
successively better approximations to get closer to a limit.  Python
has it harder than some other languages, because it tries to serve the
needs of both throwaway scripts and large-scale development projects.
The result is that feature after feature starts out with an
implementation sufficient for small scripts, and then edges towards
the needs of large-scale projects.  But it's often predictable at the
beginning what the final destination is going to be.  So once we can
see where it's going, why not proceed to the finish line immediately
instead of bothering with the intermediate steps?
Perhaps because we don't all have your psychic powers?
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Freezing a mutable (was Re: lambda)

2005-01-20 Thread Antoon Pardon
Op 2005-01-20, Nick Coghlan schreef <[EMAIL PROTECTED]>:
> Antoon Pardon wrote:
>> I missed that you would use it with the idiom: dct[x.frozen()]
>
> The list itself isn't hashable with this approach, so you don't have much 
> choice. I wasn't particularly clear about that point, though.
>
>> I have two problems with this approach.
>> 
>> 1) It doesn't work when you get your keys via the keys/items
>>methods.
>
> True - the frozen object has no link back to the original object. That could 
> be 
> added though (by returning a tuple subtype with the extra attribute)
>
>> 2) This is rather minor, but a user could still unfreeze
>>untimely 
>
> True - doing that is less likely than mutating a hashable list though :)
>
> I'm just noting this as a way to avoid copying data more than once when 
> storing 
> immutable copies of mutable data in a dictionary. You're quite right that 
> there 
> isn't a really clean idiom for doing that in Python (aside from moving to a 
> different data structure that works natively as a dict key, naturally).

The problem here is IMO is the, we are all consenting adults (which we
are not but I wont start on this now), approach.

I have been thinking a bit in your freeze direction, but more thorough.
The idea i had was that freeze would replace all mutating methods
with methods that would throw an exception. a thaw method would inverse
the proces. It would then be the responsibilty of the dictionary to
freeze an object on entry and thaw it when removed. However this
wouldn't work with ordinary python objects, since there is no easy way
to have readonly or private variables.

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


Re: iteritems() and enumerate()

2005-01-20 Thread Steve Holden
Xah Lee wrote:
Python has iteritems() and enumerate() to be used in for loops.
can anyone tell me what these are by themselves, if anything?
are they just for idiom?
No, anyone can use them, not just idioms like you.
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Erik Bethke
There is something wrong with the physical file... I d/l a trial
version of XML Spy home edition and built an equivalent of the korean
test file, and tried it and it got past the element tree error and now
I am stuck with the wxEditCtrl error.

To build the xml file in the first place I had code that looked like
this:

d=wxFileDialog( self, message="Choose a file",
defaultDir=os.getcwd(), defaultFile="", wildcard="*.xml", style=wx.SAVE
| wxOVERWRITE_PROMPT | wx.CHANGE_DIR)
if d.ShowModal() == wx.ID_OK:
# This returns a Python list of files that were selected.
paths = d.GetPaths()
layout = '\n'
L1Word = self.t1.GetValue()
L2Word = 'undefined'

layout += '\n'
layout += '\n'
layout += ''
open( paths[0], 'w' ).write(layout)
d.Destroy()

So apprantly there is something wrong with physically constructing the
file in this manner?

Thank you,
-Erik

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


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Fredrik Lundh
Erik Bethke wrote:

> layout += '\n'
> layout += '\n'

what does "print repr(L1Word)" print (that is, what does wxPython return?).
it should be a Unicode string, but that would give you an error when you write
it out:

>>> f = open("file.txt", "w")
>>> f.write(u'\uc5b4\ub155\ud558\uc138\uc694!')
Traceback (most recent call last):
  File "", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode characters
in position 0-4: ordinal not in range(128)

have you hacked the default encoding in site/sitecustomize?

what happens if you replace the L1Word term with L1Word.encode("utf-8")

can you post the repr() (either of what's in your file or of the thing, whatever
it is, that wxPython returns...)

 



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


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Erik Bethke
That was a great clue.  I am an idiot and tapped on the wrong download
link... now I can read and parse the xml file fine - as long as I
create it in XML spy - if I create it by this method:

d=wxFileDialog( self, message="Choose a file",
defaultDir=os.getcwd(), defaultFile="", wildcard="*.xml", style=wx.SAVE
| wxOVERWRITE_PROMPT | wx.CHANGE_DIR)
if d.ShowModal() == wx.ID_OK:
# This returns a Python list of files that were selected.
paths = d.GetPaths()
layout = '\n'
L1Word = self.t1.GetValue()
L2Word = 'undefined'

layout += '\n'
layout += '\n'
layout += ''
open( paths[0], 'w' ).write(layout)

I get hung up on the write statement, I am off to look for a a Unicode
capable file write I think...

-Erik

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


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Erik Bethke
Woo-hoo!  Everything is working now!

Thank you everyone!

The TWO problems I had:

1) I needed to save my XML file in the first place with this code:
f = codecs.open(paths[0], 'w', 'utf8')
2) I needed to download the UNICODE version of wxPython, duh.

So why are there non-UNICODE versions of wxPython??? To save memory or
something???

Thank you all!

Best!
-Erik

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


Re: Zen of Python

2005-01-20 Thread Skip Montanaro

>> The gist of "Flat is better than nested" is "be as nested as you have
>> to be, no more," because being too nested is just a mess.

Tim> Which I agree with, and which makes sense. However your "gist" is a
Tim> different meaning.

Not if you conflate "Flat is better than nested" with "Namespaces are one
honking great idea -- let's do more of those!".

seek-balance-in-all-things-my-son-ly, y'rs,

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


why no time() + timedelta() ?

2005-01-20 Thread josh
Why can't timedelta arithmetic be done on time objects?

(e.g. datetime.time(5)-datetime.timedelta(microseconds=3)

Nonzero "days" of the timedelta could either be ignored, or trigger an 
exception.



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


Re: Python-list Digest, Vol 16, Issue 324

2005-01-20 Thread Eduardo Henriquez A.
On Thu, 20 Jan 2005 15:41:43 +0100 (CET),
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Send Python-list mailing list submissions to
>[email protected]
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>[EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>[EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: Class introspection and dynamically determining   function
>  arguments (Diez B. Roggisch)
>   2. Re: xml parsing escape characters (Luis P. Mendes)
>   3. Problem in importing MySQLdb (Gurpreet Sachdeva)
>   4. Re: Problem in importing MySQLdb (deelan)
>   5. Re: mod_python friendly isps in europe (Daniel Bowett)
>   6. Re: xml parsing escape characters (Kent Johnson)
>   7. Re: Zen of Python (Steve Holden)
>   8. Re: Freezing a mutable (was Re: lambda) (Antoon Pardon)
>   9. Re: iteritems() and enumerate() (Steve Holden)
>  10. Re: ElementTree cannot parse UTF-8 Unicode? (Erik  Bethke)
>  11. Re: ElementTree cannot parse UTF-8 Unicode? (Fredrik Lundh)
> 
> 
> 
> -- Forwarded message --
> From: "Diez B. Roggisch" <[EMAIL PROTECTED]>
> To: [email protected]
> Date: Thu, 20 Jan 2005 13:50:37 +0100
> Subject: Re: Class introspection and dynamically determining function 
> arguments
> Nick Coghlan wrote:
> >
> > If this only has to work for classes created for the purpose (rather than
> > for an arbitrary class):
> >
> 
> Certainly a step into the direction I meant - but still missing type
> declarations. And that's what at least I'd like to see - as otherwise you
> don't know what kind of editing widget to use for a property.
> --
> Regards,
> 
> Diez B. Roggisch
> 
> 
> 
> -- Forwarded message --
> From: "Luis P. Mendes" <[EMAIL PROTECTED]>
> To: [email protected]
> Date: Thu, 20 Jan 2005 13:05:59 +
> Subject: Re: xml parsing escape characters
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> this is the xml document:
> 
> 
> http://www..";>
> ~   
> ~ 439
>(... others ...)
> ~   
> 
> 
> When I do:
> 
> print xmldoc.toxml()
> 
> it prints:
> 
> http://www...";>
> ~  
> ~439
> 
> ~  
> 
> 
> __
> with:   stringNode = xmldoc.childNodes[0]
>print stringNode.toxml()
> I get:
> http://www...";>
> ~  
> ~439
> 
> ~  
> 
> __
> 
> with:   DataSetNode = stringNode.childNodes[0]
>print DataSetNode.toxml()
> 
> I get:
> 
> 
> ~  
> ~439
> 
> ~  
> 
> ___-
> 
> so far so good, but when I issue the command:
> 
> print DataSetNode.childNodes[0]
> 
> I get:
> IndexError: tuple index out of range
> 
> Why the error, and why does it return a tuple?
> Why doesn't it return:
>
>439
> 
>
> ??
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.2.4 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD8DBQFB76y3Hn4UHCY8rB8RAvQsAKCFD/hps8ybQli8HAs3iSCvRjwqjACfS/12
> 5gctpB91S5cy299e/TVLGQk=
> =XR2a
> -END PGP SIGNATURE-
> 
> 
> 
> -- Forwarded message --
> From: Gurpreet Sachdeva <[EMAIL PROTECTED]>
> To: [email protected]
> Date: Thu, 20 Jan 2005 18:53:06 +0530
> Subject: Problem in importing MySQLdb
> I am using Mysql version 5.0.2-alpha on RedHat 9.0 (python2.2)
> 
> When I try to import MySQldb
> 
> I get:
> Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
> [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import MySQLdb
> Traceback (most recent call last):
>  File "", line 1, in ?
>  File "/usr/lib/python2.2/site-packages/MySQLdb/__init__.py", line 27, in ?
>import _mysql
> ImportError: /usr/lib/libmysqlclient.so.10: symbol errno, version
> GLIBC_2.0 not defined in file libc.so.6 with link time reference
> 
> Is there any problem in library files?? Do I need to install anything
> I have installed MySQL-shared-3.23.54a-1.i386.rpm,
> MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm,
> MySQL-server-5.0.2-0.i386.rpm
> 
> Please help,
> Garry
> 
> 
> 
> -- Forwarded message --
> From: deelan <[EMAIL PROTECTED]>
> To: [email protected]
> Date: Thu, 20 Jan 2005 14:43:01 +0100
> Subject: Re: Problem in importing MySQLdb
> Gurpreet Sachdeva wrote:
> > I am using Mysql version 5.0.2-alpha on

Re: Print to Windows default Printer

2005-01-20 Thread Scott David Daniels
Tim Golden wrote:
[Samantha]
| I am new to Python and I am having considerable trouble 
| trying to print 
| (using a simple script) to the default printer rather than the screen.
| Thanks for any help.
| S 

It may be that something here will help you:
http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html
Specifically, I think that the section print raw text is
closest to what you're asking (although not necessarily
to what you'll eventually want):
http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html#win32print
You might be interested in using PDFCreator to save paper during
your tests.  It is a windows printer driver that creates a PDF file:
http://sourceforge.net/projects/pdfcreator/
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


sys.stdin and idle bug?

2005-01-20 Thread Jason B Burke

Greetings All,

I apologize if this has been brought up before, but
I'm having a small issue with the handling of sys.stdin
in Idle.

I'm using a routine to mimic the c library function 
getch(), to get a single character from the keyboard.
The function works in the standard python shell, but
in Idle I get an error when I try to reference sys.stdin.fileno().

Within the standard shell sys.stdin is a file object with
a mode of 'r'. Looks like this in the interpreter:

', mode 'r' at 0xSome_address>

However, in Idle the object is quite different:



and typing sys.stdin.fileno() returns an AttributeError: fileno.

Is this a bug in idle, or is this normal? If it's normal is
there a work around for it?

Thanks for any replies and references to more info
on this issue.

Sincerely,

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

QOTW from Ryan Tomayko

2005-01-20 Thread Robert Brewer
http://naeblis.cx/rtomayko/2005/01/20/getters-setters-fuxors

"...Many people coming to Python can't believe no one uses IDEs. The
automatic assumption is that Python is for old grey beards who are
comfortable with vi and Emacs and refuse to accept breakthroughs in
programming productivity like IDEs. Then they write a little Python code
and realize that an IDE would just get in their way."


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


Re: why no time() + timedelta() ?

2005-01-20 Thread Tim Peters
[josh]
> Why can't timedelta arithmetic be done on time objects?

Obviously, because it's not implemented .

> (e.g. datetime.time(5)-datetime.timedelta(microseconds=3)
>
> Nonzero "days" of the timedelta could either be ignored, or
> trigger an exception.

And if the result is less than 0, or >= 24 hours, it could raise
OverflowError, or wrap around mod 24*60*60*100 microseconds, and
so on.  There are so many arbitrary endcases that no agreement could
be reached on what they "should" do.  So it's not supported at all. 
In contrast, it was much easier to reach consensus on what datetime
arithmetic should do, so that was supported.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Print to Windows default Printer

2005-01-20 Thread Samantha
Thanks Tim,
That is exactly what I want to do.
How do I map the printer to LPT1?
S
"Tim Golden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> [Samantha]
> | Thanks Tim. I didn't realize it would be so difficult.
> | S
>
> Strictly, if all you want to do is print text and you
> have mapped LPTx: to some printer (local or network)
> then the venerable "PRINT " or "COPY  LPTx:"
> may well be what you want. You can issue these via
> an os.system call from within Python, and if that serves
> the purpose, well...
>
> 
>
> import os
>
> f = open ("temp.txt", "w")
> f.write ("""I must go down to the sea again,
> To the lonely sea and the sky.
> And all I ask is a tall ship
> And a star to steer her by.
> """)
> f.close ()
>
> os.system ("print temp.txt")
>
> 
>
> TJG
>
> 
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
>  


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


RE: Print to Windows default Printer

2005-01-20 Thread Tim Golden
[Samantha]

[... snip my explanation of PRINT / COPY LPTx: ...]

| Thanks Tim,
| That is exactly what I want to do.
| How do I map the printer to LPT1?
| S

Depends on a lot of things: whether the printer is
local or networked; what version of Windows you're
running, &. 

As a very basic starting point: if it's a local printer 
(ie plugged into the back of your machine) it's probably 
on LPT1: already, or you could go to the Add Printer 
wizard and tell it to configure it for LPT1: there.

If it's networked, then something like:

NET USE LPT1: \\servername\printerqueue

should achieve the right effect.

TJG


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

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


Re: delay and force in Python

2005-01-20 Thread infidel
Of course I meant to put a break out of the loop after the print
statement.  Duh on me.

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


Re: xml parsing escape characters

2005-01-20 Thread Irmen de Jong
Kent Johnson wrote:
[...]
This is an XML document containing a single tag, , whose content 
is text containing entity-escaped XML.

This is *not* an XML document containing tags , , 
, etc.

All the behaviour you are seeing is a consequence of this. You need to 
unescape the contents of the  tag to be able to treat it as 
structured XML.
The unescaping is usually done for you by the xml parser that you use.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


What YAML engine do you use?

2005-01-20 Thread Reinhold Birkenfeld
Hello,

I know that there are different YAML engines for Python out there (Syck,
PyYaml, more?).

Which one do you use, and why?

For those of you who don't know what YAML is: visit http://yaml.org/!
You will be amazed, and never think of XML again. Well, almost.

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


Re: What YAML engine do you use?

2005-01-20 Thread Diez B. Roggisch
> I know that there are different YAML engines for Python out there (Syck,
> PyYaml, more?).
> 
> Which one do you use, and why?

I first used yaml, tried to migrate to syck. What I like about syck is that
it is faster and doesn't try to create objects but only dicts - but it
crashed if the number of yaml objects grew larger. So I still use yaml.

> 
> For those of you who don't know what YAML is: visit http://yaml.org/!
> You will be amazed, and never think of XML again. Well, almost.

It is certainly nice.

-- 
Regards,

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


Re: What YAML engine do you use?

2005-01-20 Thread Jonas Galvez
Diez B. Roggisch wrote:
> I first used yaml, tried to migrate to syck. What I like about 
> syck is that it is faster and doesn't try to create objects but 
> only dicts - but it crashed if the number of yaml objects grew 
> larger. So I still use yaml.

Hmm.. I've never had any problems with syck. In fact, I'm using it in 
a small project now where I store a helluva of data in yaml files...

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


Re: rotor replacement

2005-01-20 Thread "Martin v. Löwis"
Paul Rubin wrote:
Some countries have laws about cryptography software (against some
combination of export, import, or use).  The Python maintainers didn't
want to deal with imagined legal hassles that might develop from
including good crypto functions in the distribution.  Then it became
obvious that the same imagined hassles could also befall the rotor
module, so that was removed.
Do you know this for a fact? The PSF does comply with the U.S. American
export procedures for crypto code, and reports the crypto code in
Python appropriately to BXA.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: xml parsing escape characters

2005-01-20 Thread Kent Johnson
Irmen de Jong wrote:
Kent Johnson wrote:
[...]
This is an XML document containing a single tag, , whose 
content is text containing entity-escaped XML.

This is *not* an XML document containing tags , , 
, etc.

All the behaviour you are seeing is a consequence of this. You need to 
unescape the contents of the  tag to be able to treat it as 
structured XML.

The unescaping is usually done for you by the xml parser that you use.
Yes, so if your XML contains for example

and you parse this and ask for the *text* content of the  tag, you will 
get the string
""
but it's still *not* a tag. If you try to get child elements of the  
element there will be none.
This is exactly the confusion the OP has.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: What YAML engine do you use?

2005-01-20 Thread Istvan Albert
Reinhold Birkenfeld wrote:
You will be amazed, and never think of XML again.
XML with elementtree is what makes me never have think about XML again.
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: xml parsing escape characters

2005-01-20 Thread "Martin v. Löwis"
Luis P. Mendes wrote:
with:DataSetNode = stringNode.childNodes[0]
print DataSetNode.toxml()
I get:

~  
~439
~  

___-
so far so good, but when I issue the command:
print DataSetNode.childNodes[0]
I get:
IndexError: tuple index out of range
Why the error, and why does it return a tuple?
The DataSetNode has no children, because it is not
an Element node, but a Text node. In XML, an element
is denoted by
  ...
and *not* by
  ...
The latter is just a single string, represented
in XML as a Text node. It does not give you any
hierarchy whatsoever.
As a text node does not have any children, its
childNode members is a empty tuple; accessing
that tuple gives you an IndexError.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: xml parsing escape characters

2005-01-20 Thread "Martin v. Löwis"
Irmen de Jong wrote:
The unescaping is usually done for you by the xml parser that you use.
Usually, but not in this case. If you have a text that looks like
XML, and you want to put it into an XML element, the XML file uses
< and >. The XML parser unescapes that as < and >. However, it
does not then consider the < and > as markup, and it shouldn't.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: QOTW from Ryan Tomayko

2005-01-20 Thread John Roth
"Robert Brewer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
http://naeblis.cx/rtomayko/2005/01/20/getters-setters-fuxors

"...Many people coming to Python can't believe no one uses IDEs. The
automatic assumption is that Python is for old grey beards who are
comfortable with vi and Emacs and refuse to accept breakthroughs in
programming productivity like IDEs. Then they write a little Python code
and realize that an IDE would just get in their way."
FuManChu
[response]
It's also not true. Lots of people use IDEs - look at the
number of Python IDEs out there, and the number of
attempts (some of them reasonable) to add Python
support to Eclipse.
The thing is, there are relatively fewer programming
tools needed to work with Python than there are
for Java, for example, so the available IDEs are much
simpler.
Line oriented editors are an acquired taste, and they
are one I've never acquired regardless of the environment.
I've used both edit under TSO and vi on a timesharing
arrangement with an AIX system, and both of them suck
compared to the screen editors available.
John Roth 

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


Re: xml parsing escape characters

2005-01-20 Thread Irmen de Jong
Martin v. Löwis wrote:
Irmen de Jong wrote:
The unescaping is usually done for you by the xml parser that you use.

Usually, but not in this case. If you have a text that looks like
XML, and you want to put it into an XML element, the XML file uses
< and >. The XML parser unescapes that as < and >. However, it
does not then consider the < and > as markup, and it shouldn't.
That's also what I said?
The unescaping of the XML entities in the contents of the OP's
 element is done for you by the parser,
so you will get a text node with the <,>,&,whatever in there.
The OP probably wants to feed that to a new xml parser instance
to process it as markup.
Or perhaps the way the original XML document is constructed is
flawed.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: What YAML engine do you use?

2005-01-20 Thread Irmen de Jong
Istvan Albert wrote:
XML with elementtree is what makes me never have think about XML again.
+1 QOTW
-Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Overloading ctor doesn't work?

2005-01-20 Thread Martin Häcker
Hi there,
I just tried to run this code and failed miserably - though I dunno why. 
Could any of you please enlighten me why this doesn't work?

Thanks a bunch.
--- snip ---
import unittest
from datetime import datetime
class time (datetime):
  def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
print "blah"
datetime.__init__(self, 1, 1, 1, hours, \
minutes, seconds, microseconds)
class Test (unittest.TestCase):
  def testSmoke(self):
# print time() # bombs, and complains that
# the time ctor needs at least 3 arguments
self.assertEquals(datetime(1,1,1,1,2,3,4),time(1,2,3,4))
if __name__ == '__main__':
  unittest.main()
--- snap ---
The reason I want to do this is that I want to work with times but I 
want to do arithmetic with them. Therefore I cannot use the provided 
time directly.

Now I thought, just overide the ctor of datetime so that year, month and 
 day are static and everything should work as far as I need it.

That is, it could work - though I seem to be unable to overide the ctor. :(
Why is that?
cu Martin
--
Reach me at spamfaenger (at) gmx (dot) net
--
http://mail.python.org/mailman/listinfo/python-list


RE: RuntimeError: dictionary changed size during iteration

2005-01-20 Thread Roman Suzi
On Thu, 20 Jan 2005, Batista, Facundo wrote:

>For me, the point is: vars() returns the local variables as a list or is a
>generator?
>
>In the docs don't say nothing about this.
>
>If it returns a list, it should NOT raise an error; if it's a generator, the
>error is fine.

>
>.Facundo
>

Probably, e need not appear in vars() at all... This is why
generator closure works fine.


Sincerely yours, Roman Suzi
-- 
[EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3

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


Re: xml parsing escape characters

2005-01-20 Thread "Martin v. Löwis"
Irmen de Jong wrote:
Usually, but not in this case. If you have a text that looks like
XML, and you want to put it into an XML element, the XML file uses
< and >. The XML parser unescapes that as < and >. However, it
does not then consider the < and > as markup, and it shouldn't.

That's also what I said?
You said it in response to
>>> All the behaviour you are seeing is a consequence of this. You need
>>> to unescape the contents of the  tag to be able to treat it 
>>> as structured XML.

In that context, I interpreted
>> The unescaping is usually done for you by the xml parser that you
>> use.
as "The parser should have done what you want; if the parser didn't,
that is is bug in the parser".
The OP probably wants to feed that to a new xml parser instance
to process it as markup.
Or perhaps the way the original XML document is constructed is
flawed.
Either of these, indeed - probably the latter.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: RuntimeError: dictionary changed size during iteration

2005-01-20 Thread Terry Reedy
RE: RuntimeError: dictionary changed size during iteration
"Batista, Facundo" <[EMAIL PROTECTED]> wrote

[Robert Brewer]
#- But not unexpected, since vars() returns a dictionary, and
#- binding 'e'
#- changes that dictionary while you are iterating over it.

>For me, the point is: vars() returns the local variables
> as a list or is a generator?

As the OP said, it returns a *dictionary*.  In particular:

>>> help(vars)
Help on built-in function vars:

vars(...)
vars([object]) -> dictionary

Without arguments, equivalent to locals().
With an argument, equivalent to object.__dict__.

>In the docs don't say nothing about this.

You must be having a bad day ;-).  From Lib Ref 2.1 Built-in Functions:

  vars( [object])

Without arguments, return a dictionary corresponding to the current local 
symbol table. With a module, class or class instance object as argument (or 
anything else that has a __dict__ attribute), returns a dictionary 
corresponding to the object's symbol table. The returned dictionary should 
not be modified: the effects on the corresponding symbol table are 
undefined

Terry J. Reedy



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


What's the best python web-developer's editor

2005-01-20 Thread andy
Anybody like to comment on which editor they use for python web app 
development - for both discrete and mixed python and html code,  and why?

I'm comfortable with IDLE (used it for years) but of course it lacks ftp 
or webDAV abilities, obviously because it's not intended for that type 
of use.

I've had a look at Screem - and that seems to do python syntax 
highlighting, but it dosn't seem to be python syntax aware (unless 
there's a hidden option somewhere).  Although I can live without auto 
indent, I'd rather not...

I'm sure emacs, xemacs, vi, elvis and so on can do the same, but I have 
no experience with them for  heavy python or html coding, nor the time 
to trip off down a blind-alley to find out!  I know Enough Vi To Get 
By(tm) but it's by no means my favourite editor.  Emacs is a complete 
mystery to me.

I guess I *could* use IDLE and Screem together, but that's a clunky 
solution!

all opinions greatfully received,
-andyj
--
http://mail.python.org/mailman/listinfo/python-list


Re: Print to Windows default Printer

2005-01-20 Thread Samantha
The printer is on LPT1, but I sure can't get the temp file to print for some 
reason.
I am using Windows XP SP2.
S
"Tim Golden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> [Samantha]
>
> [... snip my explanation of PRINT / COPY LPTx: ...]
>
> | Thanks Tim,
> | That is exactly what I want to do.
> | How do I map the printer to LPT1?
> | S
>
> Depends on a lot of things: whether the printer is
> local or networked; what version of Windows you're
> running, &.
>
> As a very basic starting point: if it's a local printer
> (ie plugged into the back of your machine) it's probably
> on LPT1: already, or you could go to the Add Printer
> wizard and tell it to configure it for LPT1: there.
>
> If it's networked, then something like:
>
> NET USE LPT1: \\servername\printerqueue
>
> should achieve the right effect.
>
> TJG
>
> 
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
>  


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


RE: RuntimeError: dictionary changed size during iteration

2005-01-20 Thread Batista, Facundo
Title: RE: RuntimeError: dictionary changed size during iteration





[Terry Reedy]


#- You must be having a bad day ;-).  From Lib Ref 2.1 Built-in 


Well, that's actually true, :(



#- corresponding to the object's symbol table. The returned 
#- dictionary should 
#- not be modified: the effects on the corresponding symbol table are 
#- undefined


I actually read that, but didn't understood that it returns THE dictionary (well, that another name binding for the same object was happening). Whatever, I don't get divorced every week, so forgive me.

I think that, as it's normal to do...


  l = list(...)
  for e in l[:]:
  l.remove(e)


...insted of...


  l = list(...)
  for e in l:
  l.remove(e)


..., in this case we should do...


>>> [e for e in vars().copy()]
['_[1]', 'e', 'v', '__builtins__', '__name__', '__doc__']


.    Facundo


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




  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Re: What's the best python web-developer's editor

2005-01-20 Thread fla liu
Try to use Eclipse + pydev


On Thu, 20 Jan 2005 18:47:53 +, andy <[EMAIL PROTECTED]> wrote:
> Anybody like to comment on which editor they use for python web app
> development - for both discrete and mixed python and html code,  and why?
> 
> I'm comfortable with IDLE (used it for years) but of course it lacks ftp
> or webDAV abilities, obviously because it's not intended for that type
> of use.
> 
> I've had a look at Screem - and that seems to do python syntax
> highlighting, but it dosn't seem to be python syntax aware (unless
> there's a hidden option somewhere).  Although I can live without auto
> indent, I'd rather not...
> 
> I'm sure emacs, xemacs, vi, elvis and so on can do the same, but I have
> no experience with them for  heavy python or html coding, nor the time
> to trip off down a blind-alley to find out!  I know Enough Vi To Get
> By(tm) but it's by no means my favourite editor.  Emacs is a complete
> mystery to me.
> 
> I guess I *could* use IDLE and Screem together, but that's a clunky
> solution!
> 
> all opinions greatfully received,
> -andyj
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the best python web-developer's editor

2005-01-20 Thread Jay Loden
You didn't mention platform, but I'm guessing from the mention of Screem that 
you're using a Linux platform.  On Linux I like kwrite and kate (both 
similar, kate includes some other features like a built in terminal where you 
can run some commands, ability to support projects, open multiple files tiled 
to read all the code at once, etc).  They both use the same editing portion, 
which has syntax highlighting for Python and html both.  Because of KDE 
network transparency, you can edit files over ftp/save to an ftp site. 

Just in case, I'll recommend my favorite Windows editor for those times when 
I'm stuck on Windows - Crimson Editor, http://www.crimsoneditor.com Has 
syntax highlights, and just about every feature I could possibly ask for in 
an editor.  I actually missed this app the most when moving to Linux. 

-Jay

On Thursday 20 January 2005 1:47, andy wrote:
> Anybody like to comment on which editor they use for python web app
> development - for both discrete and mixed python and html code,  and why?
>
> I'm comfortable with IDLE (used it for years) but of course it lacks ftp
> or webDAV abilities, obviously because it's not intended for that type
> of use.
>
> I've had a look at Screem - and that seems to do python syntax
> highlighting, but it dosn't seem to be python syntax aware (unless
> there's a hidden option somewhere).  Although I can live without auto
> indent, I'd rather not...
>
> I'm sure emacs, xemacs, vi, elvis and so on can do the same, but I have
> no experience with them for  heavy python or html coding, nor the time
> to trip off down a blind-alley to find out!  I know Enough Vi To Get
> By(tm) but it's by no means my favourite editor.  Emacs is a complete
> mystery to me.
>
> I guess I *could* use IDLE and Screem together, but that's a clunky
> solution!
>
> all opinions greatfully received,
> -andyj
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Overloading ctor doesn't work?

2005-01-20 Thread Steve Holden
Martin Häcker wrote:
Hi there,
I just tried to run this code and failed miserably - though I dunno why. 
Could any of you please enlighten me why this doesn't work?

Thanks a bunch.
--- snip ---
import unittest
from datetime import datetime
class time (datetime):
  def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
print "blah"
datetime.__init__(self, 1, 1, 1, hours, \
minutes, seconds, microseconds)
class Test (unittest.TestCase):
  def testSmoke(self):
# print time() # bombs, and complains that
# the time ctor needs at least 3 arguments
self.assertEquals(datetime(1,1,1,1,2,3,4),time(1,2,3,4))
if __name__ == '__main__':
  unittest.main()
--- snap ---
The reason I want to do this is that I want to work with times but I 
want to do arithmetic with them. Therefore I cannot use the provided 
time directly.

Now I thought, just overide the ctor of datetime so that year, month and 
 day are static and everything should work as far as I need it.

That is, it could work - though I seem to be unable to overide the ctor. :(
Why is that?
Perhpas the error message or output, which you don't provide, would 
avoid our having to use our psychic powers? ;-)

In other words: what's wrong? How do you *know* you can't override it?
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's the best python web-developer's editor

2005-01-20 Thread Jay Loden
You didn't mention platform, but I'm guessing from the mention of Screem that 
you're using a Linux platform.  On Linux I like kwrite and kate (both 
similar, kate includes some other features like a built in terminal where you 
can run some commands, ability to support projects, open multiple files tiled 
to read all the code at once, etc).  They both use the same editing portion, 
which has syntax highlighting for Python and html both.  Because of KDE 
network transparency, you can edit files over ftp/save to an ftp site. 

Just in case, I'll recommend my favorite Windows editor for those times when 
I'm stuck on Windows - Crimson Editor, http://www.crimsoneditor.com Has 
syntax highlights, and just about every feature I could possibly ask for in 
an editor.  I actually missed this app the most when moving to Linux. 

-Jay

On Thursday 20 January 2005 1:47, andy wrote:
> Anybody like to comment on which editor they use for python web app
> development - for both discrete and mixed python and html code,  and why?
>
> I'm comfortable with IDLE (used it for years) but of course it lacks ftp
> or webDAV abilities, obviously because it's not intended for that type
> of use.
>
> I've had a look at Screem - and that seems to do python syntax
> highlighting, but it dosn't seem to be python syntax aware (unless
> there's a hidden option somewhere).  Although I can live without auto
> indent, I'd rather not...
>
> I'm sure emacs, xemacs, vi, elvis and so on can do the same, but I have
> no experience with them for  heavy python or html coding, nor the time
> to trip off down a blind-alley to find out!  I know Enough Vi To Get
> By(tm) but it's by no means my favourite editor.  Emacs is a complete
> mystery to me.
>
> I guess I *could* use IDLE and Screem together, but that's a clunky
> solution!
>
> all opinions greatfully received,
> -andyj
--
http://mail.python.org/mailman/listinfo/python-list


RE: Print to Windows default Printer

2005-01-20 Thread Tim Golden
[Samantha]
| The printer is on LPT1, but I sure can't get the temp file to 
| print for some 
| reason.
| I am using Windows XP SP2.
| S

i'm afraid I have to step out here (metaphorically speaking):
I'm using Win2K and have no access to XP boxes. The technique
works fine here; it may be that either they've removed the
functionality under XP, or that there's some security 
context which is preventing you from accessing the port.

Can anyone else try a "PRINT blah" or a "COPY blah LPT1:"
on XP SP2?

TJG


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

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


Re: Overloading ctor doesn't work?

2005-01-20 Thread Kent Johnson
Martin Häcker wrote:
Hi there,
I just tried to run this code and failed miserably - though I dunno 
why. Could any of you please enlighten me why this doesn't work?
Here is a simpler test case. I'm mystified too:
from datetime import datetime
class time (datetime):
  def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
datetime.__init__(self, 2001, 10, 31, hours, minutes, seconds, microseconds)
print time(1,2,3,4) # => 0001-02-03 04:00:00
print time()# => TypeError: function takes at least 3 arguments (0 
given)
What happens to the default arguments to time.__init__? What happens to the 2001, 10, 31 arguments 
to datetime.__init__?

I would expect the output to be
2001-10-31 01:02:03.04
2001-10-31 00:00:00.00
Kent
--
http://mail.python.org/mailman/listinfo/python-list


Re: Overloading ctor doesn't work?

2005-01-20 Thread Francis Girard
Hi,

It looks like the assertEquals use the != operator which had not been defined 
to compare instances of your time class and instances of the datetime class.
In such a case, the operator ends up in comparing the references to instances,
i.e. the "id" of the objects, i.e. their physical memory addresses, which of 
course can't be the same. And that is why your test fails.

Consider defining the __cmp__ method (see 2.3.3 Comparisons  of the library 
reference). Sess also the operator module.

Francis Girard
LANNILIS
Breizh
FRANCE

Le jeudi 20 Janvier 2005 19:23, Martin Häcker a écrit :
> Hi there,
>
> I just tried to run this code and failed miserably - though I dunno why.
> Could any of you please enlighten me why this doesn't work?
>
> Thanks a bunch.
>
> --- snip ---
> import unittest
> from datetime import datetime
>
> class time (datetime):
>def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
>  print "blah"
>  datetime.__init__(self, 1, 1, 1, hours, \
>   minutes, seconds, microseconds)
>
>
> class Test (unittest.TestCase):
>def testSmoke(self):
>  # print time() # bombs, and complains that
>  # the time ctor needs at least 3 arguments
>  self.assertEquals(datetime(1,1,1,1,2,3,4),time(1,2,3,4))
>
>
> if __name__ == '__main__':
>unittest.main()
> --- snap ---
>
> The reason I want to do this is that I want to work with times but I
> want to do arithmetic with them. Therefore I cannot use the provided
> time directly.
>
> Now I thought, just overide the ctor of datetime so that year, month and
>   day are static and everything should work as far as I need it.
>
> That is, it could work - though I seem to be unable to overide the ctor. :(
>
> Why is that?
>
> cu Martin
>
> --
> Reach me at spamfaenger (at) gmx (dot) net

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


Re: xml parsing escape characters

2005-01-20 Thread Luis P. Mendes
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I would like to thank everyone for your answers, but I'm not seeing the
light yet!
When I access the url via the Firefox browser and look into the source
code, I also get:


~  
~439
~  

should I take the contents of the string tag that is text and replace
all '<' with '<' and '>' with '>' and then read it with xml.minidom?
how to do it?
or should I use another parser that accomplishes the task with no need
to replace the escaped characters?
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFB8AIQHn4UHCY8rB8RAuw8AJ9ZMQ8P3c7wXD1zVLd2fe7MktMQwwCfXAND
EPpY1w2a3ix2s2vWRlzZ43U=
=bJQV
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem in importing MySQLdb

2005-01-20 Thread Andy Dustman
Gurpreet Sachdeva wrote:

> Is there any problem in library files?? Do I need to install anything
> I have installed MySQL-shared-3.23.54a-1.i386.rpm,
> MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm,
> MySQL-server-5.0.2-0.i386.rpm

You should recheck those version numbers carefully. One of these things
is not like the other...

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


Re: Print to Windows default Printer

2005-01-20 Thread Kristian Zoerhoff
On Thu, 20 Jan 2005 19:14:10 -, Tim Golden
<[EMAIL PROTECTED]> wrote:
> [Kristian Zoerhoff]
> |
> | On Thu, 20 Jan 2005 18:58:25 -, Tim Golden
> | <[EMAIL PROTECTED]> wrote:
> | >
> | > Can anyone else try a "PRINT blah" or a "COPY blah LPT1:"
> | > on XP SP2?
> |
> | The printer is probably connected via USB, not the parallel port
> | (LPT1), so the above won't work. I googled, and found some sage advice
> | here:
> |
> | http://www.winnetmag.com/Article/ArticleID/39674/39674.html
> |
> | that may assist the OP.
> 
> Ah. I'm so old-fashioned, the idea of a USB printer had
> never occurred to me (I've never used one, in fact).
> 
> Thanks for the info. Did you post back to the list as well?
> 

Whoops. I am now :-)

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FTPLIB & FTPS or SFTP?

2005-01-20 Thread Peter A.Schott
Can't seem to hit the site right now.  I'll have to try back later.  From what I
can tell, there aren't any mirrors set up, either.  Two quick recommendations is
promising, though.

Thanks for the recommendations.

-Pete

"Roger Binns" <[EMAIL PROTECTED]> wrote:

> 
> "Peter A. Schott" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> > have a handful of partners who use FTPS or SFTP and I need to pull/push 
> > files
> > to/from them.
> 
> For SFTP, run don't walk, over to http://www.lag.net/paramiko/
> 
> Paramiko is a pure Python(*) implementation of SSH and all the
> sub-protocols such as SFTP.  Works on all platforms, very responsive
> author, works reliably and LGPL license.
> 
> (*) It does require PyCrypto which is a native code package available
> for all platforms.
> 
> Roger 
> 

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


Re: Overloading ctor doesn't work?

2005-01-20 Thread Francis Girard
Wow !
Now, this is serious. I tried all sort of things but can't solve the problem.
I'm mystified too and forget my last reply.
I'm curious to see the answers.
Francis Girard
Le jeudi 20 Janvier 2005 19:59, Kent Johnson a écrit :
> > Martin Häcker wrote:
> >> Hi there,
> >>
> >> I just tried to run this code and failed miserably - though I dunno
> >> why. Could any of you please enlighten me why this doesn't work?
>
> Here is a simpler test case. I'm mystified too:
>
> from datetime import datetime
>
> class time (datetime):
>def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
>  datetime.__init__(self, 2001, 10, 31, hours, minutes, seconds,
> microseconds)
>
> print time(1,2,3,4) # => 0001-02-03 04:00:00
> print time()# => TypeError: function takes at least 3 arguments (0
> given)
>
>
> What happens to the default arguments to time.__init__? What happens to the
> 2001, 10, 31 arguments to datetime.__init__?
>
> I would expect the output to be
> 2001-10-31 01:02:03.04
> 2001-10-31 00:00:00.00
>
> Kent

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


building extensions: ming & python mathlink for win32

2005-01-20 Thread Jelle Feringa // EZCT / Paris








Have been trying to build python extensions from the C libs ming
& mathlink.

I have been able to produce a .pyd
object after studying Mike Fletchers excellent: 

http://www.vrplumber.com/programming/mstoolkit/

 

which is a
terrific tutorial for anyone trying to compile .pyd
on win32!

 

Building mathlink (communicating with mathematica from python!) was semi successful in
the sense that it did build a .pyd, Semi, since
importing it gave: >>> import mathlink

Fatal Python error: Error initializing mathlink
extension module

 

This application has requested the Runtime to terminate it
in an unusual way.

Please contact the application's support team for more information.

 

Has anyone been able to compile this extension for python?

Same thing goes for Ming (c lib for compiling flas .swf files), such a pity no disutils script is included in this very powerful library!

##if you succeeded to build this, please consider sharing it
with me! (2.3 is fine as well!)

 

What struck me while trying to compile is that instead of
the Active Python 2.4 version I was running I downloaded and installed the
python.org version (as recommended by Fletcher), and while launching it, I stated


 

ActivePython 2.4 Build
243 (ActiveState Corp.) based on Python 2.4

 

HUH! WHAT! No actual difference between the python.org &
activestate version???

 

Cheers,

 

Jelle.






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

Re: What's the best python web-developer's editor

2005-01-20 Thread Daniel Bowett
I only use Windows and I only ever use Textpad. It gives nice syntax 
highlighting, indentation and you can run your script with it too.

andy wrote:
Anybody like to comment on which editor they use for python web app 
development - for both discrete and mixed python and html code,  and why?

I'm comfortable with IDLE (used it for years) but of course it lacks ftp 
or webDAV abilities, obviously because it's not intended for that type 
of use.

I've had a look at Screem - and that seems to do python syntax 
highlighting, but it dosn't seem to be python syntax aware (unless 
there's a hidden option somewhere).  Although I can live without auto 
indent, I'd rather not...

I'm sure emacs, xemacs, vi, elvis and so on can do the same, but I have 
no experience with them for  heavy python or html coding, nor the time 
to trip off down a blind-alley to find out!  I know Enough Vi To Get 
By(tm) but it's by no means my favourite editor.  Emacs is a complete 
mystery to me.

I guess I *could* use IDLE and Screem together, but that's a clunky 
solution!

all opinions greatfully received,
-andyj
--
http://mail.python.org/mailman/listinfo/python-list


Re: Print to Windows default Printer

2005-01-20 Thread Samantha
Thanks Scott,
Not wasting any paper yet. I can't seem to get the file to print at all yet.
S
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Tim Golden wrote:
>> [Samantha]
>> | I am new to Python and I am having considerable trouble | trying to 
>> print | (using a simple script) to the default printer rather than the 
>> screen.
>> | Thanks for any help.
>> | S It may be that something here will help you:
>>
>> http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html
>>
>> Specifically, I think that the section print raw text is
>> closest to what you're asking (although not necessarily
>> to what you'll eventually want):
>>
>> http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html#win32print
>>
> You might be interested in using PDFCreator to save paper during
> your tests.  It is a windows printer driver that creates a PDF file:
>
> http://sourceforge.net/projects/pdfcreator/
>
> --Scott David Daniels
> [EMAIL PROTECTED] 


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


Re: building extensions: ming & python mathlink for win32

2005-01-20 Thread Fredrik Lundh
Jelle Feringa wrote:

> What struck me while trying to compile is that instead of the Active Python
> 2.4 version I was running I downloaded and installed the python.org version
> (as recommended by Fletcher), and while launching it, I stated
>
> ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4
>
> HUH! WHAT! No actual difference between the python.org & activestate
> version???

the python.org version I have says:

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32

 



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


Re: Overloading ctor doesn't work?

2005-01-20 Thread Paul McGuire
"Kent Johnson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Martin Häcker wrote:
> >
> >> Hi there,
> >>
> >> I just tried to run this code and failed miserably - though I dunno
> >> why. Could any of you please enlighten me why this doesn't work?
>
> Here is a simpler test case. I'm mystified too:
>
> from datetime import datetime
>
> class time (datetime):
>def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
>  datetime.__init__(self, 2001, 10, 31, hours, minutes, seconds,
microseconds)
>
> print time(1,2,3,4) # => 0001-02-03 04:00:00
> print time()# => TypeError: function takes at least 3 arguments (0
given)
>
>
> What happens to the default arguments to time.__init__? What happens to
the 2001, 10, 31 arguments
> to datetime.__init__?
>
> I would expect the output to be
> 2001-10-31 01:02:03.04
> 2001-10-31 00:00:00.00
>
> Kent

I can't explain this behavior, but this version does work (uses
datetime.combine instead of ctor)

-- Paul


from datetime import datetime, date as dt_date, time as dt_time

class time_d (datetime):
def __new__(cls, *args):
# default to no microseconds
if len(args)==3:
args = args + (0,)
if len(args)==4:
tmpdate = datetime.today()
h, mi, s, ms = args
return datetime.combine(tmpdate, dt_time(h,mi,s,ms))
elif len(args)==7:
y,m,d,h,mi,s,ms = args
return datetime.combine(dt_date(y,m,d), dt_time(h,mi,s,ms))
else:
raise TypeError, "wrong number of args"

print time_d(2001,10,31,1,2,3,4)
print time_d(1,2,3,4)
print time_d(1,2,3)



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


Re: building extensions: ming & python mathlink for win32

2005-01-20 Thread Jack Diederich
On Thu, Jan 20, 2005 at 08:38:35PM +0100, Jelle Feringa // EZCT / Paris wrote:
> Have been trying to build python extensions from the C libs ming & mathlink.
> Same thing goes for Ming (c lib for compiling flas .swf files), such a pity
> no disutils script is included in this very powerful library!
> ##if you succeeded to build this, please consider sharing it with me! (2.3
> is fine as well!)
>  
This was asked last month (Dec 7th) so I'll just point to my answer then (I
don't know if it worked out for the OP or not).

Ming seems unmaintained (and the wiki is usually hosed with spam).  The setup.py
I mention works for me on linux but it still requires copying files around.
If you discover how to do it on windows please reply so there won't be a thread
in February too *wink*

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/47c878e2d7688324/18a97ab639d034cf

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


Re: How to lanch a webbrowser

2005-01-20 Thread python

Steve Holden wrote:
> Ola Natvig wrote:
>
> > [EMAIL PROTECTED] wrote:
> >
> >> Does anyone know
> >> how to lanch a webbrowser ( from Python) without menu and
toolbars?
> >> Thanks for help
> >> Lad
> >>
> >
> > You've got the webbrowser module which lauches the OS's standard
browser
> >
> > from webbrowser import get
> > get("www.example.org")
> >
> > launches the webbrowser, but how to launch it without menu and
toolbar I
> > don't know. You could launch a small HTML page containing a
javascript
> > that launches your wanted page.
> >
> This would indeed be the best way. The page you launched should
contain
> a script that creates another window. Since this would be
browser-based
> javascript, it could specify the appropriate browser window
attributes
> (see, for example
>
>http://www.javascripter.net/faq/openinga.htm
>
> which shows you how to specify the appropriate window
characteristics).
>
> The onload attribute of the first page's body could then specify
closing
> the window you opened from Python.
>
> You may find that this close operation generates a warning from the
> browser about scripts doing naughty things, however.
>
> regards
>   Steve
> --
> Steve Holden   http://www.holdenweb.com/
> Python Web Programming  http://pydish.holdenweb.com/
> Holden Web LLC  +1 703 861 4237  +1 800 494 3119

Thank you Steve for the http link( was good) and to you all others as
well who helped me.
Lad

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


Re: ElementTree cannot parse UTF-8 Unicode?

2005-01-20 Thread Jarek Zgoda
Erik Bethke wrote:
So why are there non-UNICODE versions of wxPython??? To save memory or
something???
Win95, Win98, WinME have problems with unicode. GTK1 does not support 
unicode at all.

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


Re: Overloading ctor doesn't work?

2005-01-20 Thread Kent Johnson
Paul McGuire wrote:
"Kent Johnson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Martin Häcker wrote:

Hi there,
I just tried to run this code and failed miserably - though I dunno
why. Could any of you please enlighten me why this doesn't work?
Here is a simpler test case. I'm mystified too:
from datetime import datetime
class time (datetime):
  def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
datetime.__init__(self, 2001, 10, 31, hours, minutes, seconds,
microseconds)
print time(1,2,3,4) # => 0001-02-03 04:00:00
print time()# => TypeError: function takes at least 3 arguments (0
given)
What happens to the default arguments to time.__init__? What happens to
the 2001, 10, 31 arguments
to datetime.__init__?
I would expect the output to be
2001-10-31 01:02:03.04
2001-10-31 00:00:00.00
Kent

I can't explain this behavior, but this version does work (uses
datetime.combine instead of ctor)
-- Paul
from datetime import datetime, date as dt_date, time as dt_time
class time_d (datetime):
def __new__(cls, *args):
# default to no microseconds
if len(args)==3:
args = args + (0,)
if len(args)==4:
tmpdate = datetime.today()
h, mi, s, ms = args
return datetime.combine(tmpdate, dt_time(h,mi,s,ms))
elif len(args)==7:
y,m,d,h,mi,s,ms = args
return datetime.combine(dt_date(y,m,d), dt_time(h,mi,s,ms))
else:
raise TypeError, "wrong number of args"
print time_d(2001,10,31,1,2,3,4)
print time_d(1,2,3,4)
print time_d(1,2,3)

Ah, right. The light turns on...
datetime is immutable so overriding the constructor doesn't change the constructed object. You have 
to override __new__ instead.
http://www.python.org/2.2.1/descrintro.html#__new__

This works:
from datetime import datetime
class time (datetime):
def __new__(cls, hours=0, minutes=0, seconds=0, microseconds=0):
return datetime.__new__(cls, 2001, 10, 31, hours, minutes, seconds, 
microseconds)
print time(1,2,3,4) # => 2001-10-31 01:02:03.04
print time()# => 2001-10-31 00:00:00
Kent


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


Re: video analysis with python

2005-01-20 Thread Matthias Baas
On Mon, 17 Jan 2005 08:08:46 +0100, "Alexander 'boesi' Bösecke"
<[EMAIL PROTECTED]> wrote:
>> 1. There is PyMedia (http://pymedia.org/)
>
>Is this library able to extract single images from a video? AFAICS it
>can only convert videos from one format to another. But I didn't try it,
>I've looked only in the docu.

Yes, you can extract single images from a video. The package uses the
avformat and avcodec libraries from ffmpeg and it provides rather low
level access to video/audio files. You can access the individual
streams in a file, obtain the stream data and decode the data therein.
What you do with the data is up to your application. Converting the
file into another format is just one such application. 

- Matthias -

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


Re: problem with import pylab from a website

2005-01-20 Thread John Hunter
> "jean" == jean rossier <[EMAIL PROTECTED]> writes:

jean> Hello All, I am facing a problem while importing pylab
jean> library(in a .py program file) via web browser however the
jean> same program works when I execute it from the command
jean> prompt.

jean> Error message we get:


   Permission denied: '/usr/share/matplotlib/.ttffont.cache', referer:

One solution is to give yourself write permission to
/usr/share/matplotlib.  If this is not possible or in unpalatable for
sysadmin reasons, you have a couple of options.

matplotlib creates a font cache .ttffont.cache of the ttf files it
finds on your system.  If the HOME environment variable is set, it
places the cache file in the HOME dir.  So if setting HOME is a viable
option for you, simply set this to a writable directory on your system
and you are good to go.  This is the approach I recommend.

If HOME does not exist, matplotlib falls back on its data path: this
is where fonts, icons and other goodies live.  You can also customize
this directory by setting the MATPLOTLIBDATA environment variable.  If
you go this route, more all the files currently in
/usr/share/matplotlib to some other directory, say /my/dir, and make
sure it is writable, and then set MATPLOTLIBDATA to point to it.

Note matplotlib has a configuration file that controls all of the
default settings for the plot.  If you want to edit these, the edited
file can also be placed in the HOME directory.  See
http://matplotlib.sf.net/.matplotlibrc .

Hope this helps,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Python Computer Graphics Kit v2.0.0alpha2

2005-01-20 Thread Matthias Baas
The second alpha release of version 2 of the Python Computer Graphics
Kit is available at http://cgkit.sourceforge.net


What is it?
---

The Python Computer Graphics Kit is a generic 3D package written in
C++ and Python that can be used for a variety of domains such as
scientific visualization, photorealistic rendering, Virtual Reality or
even games. The package contains a number of generic modules that can
be useful for any application that processes 3D data. This includes
new types such as vectors, matrices and quaternions. Furthermore, the
package can read and store 3D models in memory where they can be
manipulated by Python programs. The kit comes with tools that can be
used to display the scene either interactively or by rendering it
offline via a RenderMan renderer.


What's new?
---

- New module "glove" that wraps the 5DT Data Glove SDK
- New module "wintab" that wraps the Wintab API to receive data from
tablets (Windows only)
- New module "spacedevice" that wraps the 3Dconnexion 3DXWare SDK
(currently Windows only)
- New class: FreeCamera
- STL importer added (ASCII and binary)
- some bugfixes and minor enhancements (see changelog)

Windows binary versions are available for Python 2.3 and Python 2.4.


For more information, visit:

http://cgkit.sourceforge.net


- Matthias -


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


Re: xml parsing escape characters

2005-01-20 Thread "Martin v. Löwis"
Luis P. Mendes wrote:
When I access the url via the Firefox browser and look into the source
code, I also get:


~  
~439
~  

Please do try to understand what you are seeing. This is crucial for
understanding what happens.
You may have the understanding that XML can be represented as a tree.
This would be good - if not, please read a book that explains why
XML can be considered as a tree.
In the tree, you have inner nodes, and leaf nodes. For example,
the document

  Hello
  World

has 5 nodes (ignoring whitespace content):
Element:a  Element:b  Text:"Hello"
   |
   \-- Element:c  Text:"World"
So the leaf nodes are typically Text nodes (unless you
have an empty element). Your document has this structure:
Element:string  Text:"""
   
  439
  
"""
So the ***TEXT*** contains the letter "<", just like it contains
the letters "O" and "r". There IS no element Order in your document,
no matter how hard you look.
If you want a DataSet *element* in your document, it should
read

 
  
   439
  

As this is the document you apparently want to process, complain
to whoever gave you that other document.
should I take the contents of the string tag that is text and replace
all '<' with '<' and '>' with '>' and then read it with xml.minidom?
No. We still don't know what you want to achieve, so it is difficult to
advise you what to do. My best advise is that whoever generates the XML
document should fix it.
or should I use another parser that accomplishes the task with no need
to replace the escaped characters?
No. The parser is working correctly.
The document you got can also be interpreted as containing another
XML document as a text. This is evil, but apparently people are doing
it, anyway. If you really want that embedded document, you need
first to extract it.
To see what I mean, do
print DataSetNode.data
The .data attribute gives you the string contents of
a text node. You could use this as an XML document, and
parse it again to an XML parser. This would be ugly,
but might be your only choice if the producer of the
document is unwilling to adjust.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >