Re: remove child in DOM??

2004-12-12 Thread Fredrik Lundh
Juliano Freitas wrote:

> how can i remove a child in DOM ?

node.removeChild(child)

where both node and child are DOM nodes.

> for example, i have thi xml below:
> 
>  
>  juliano 
>  
> 
>
> and i want to remove the  element:
> 
>  
>  
> 
>
> how can  i do this??

here's a brute force solution:

from xml.dom.minidom import Node, parseString

dom = parseString(xml)

node = dom.getElementsByTagName("user")[0] # get first user
for subnode in node.childNodes:
if subnode.nodeType == Node.ELEMENT_NODE and subnode.tagName == "name":
node.removeChild(subnode)
break # must break if modifying the list we're iterating over

(I'm sure some DOM expert can come up with a better solution)

notes:

1) the [0] will raise an exception if there are no "user" elements in the tree;
for production code, you can either handle the exception, check the length
of the element list before indexing, or use a "one-shot" for-loop:

for node in dom.getElementsByTagName("user"):
...
break # only process the first element

2) the removeChild() method modifies the childNodes list, so you must leave
the loop after the first remove.  to remove multiple children, you have to use a
separate loop counter (and increment it only if you're not removing anything),
or scan the list backwards.

3) the above example leaves surrounding whitespace in the tree.  in other words,
you'll get


  

  


instead of


  


to get rid of the whitespace, you need to add an extra pass that looks for 
unnecessary
text nodes for which len(data.strip()) is zero.

4) obligatory elementtree example:

user = dom.find("root/user")
user.remove(user.find("name"))

 



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


Re: newbie questions

2004-12-12 Thread Fredrik Lundh
John Machin wrote:

>> Of course, in this simple case, I wouldn't be likely to write the clear
>> function since the inline code is simpler and has less overhead:
>>
>> def main()
>>  var1 = []
>>  var1.append('a')
>>  var1[:] = []
>
> Even less overhead: del var1[:]

even less overhead:

var1 = []

(if you rely on having multiple references to the same list, instead of 
referring
to the list by name, you may want to reconsider the design)

 



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


Re: handy stacktrace class

2004-12-12 Thread Fredrik Lundh
Will Ware wrote:

>I was fooling with some Python code, and starting to miss the
> Exception.printStackTrace() feature in Java.

traceback.print_exc()

 



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


subprocess.Popen

2004-12-12 Thread Michele Simionato
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,

class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)

but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?

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


Re: uptime for Win XP?

2004-12-12 Thread Fredrik Lundh
Esmail Bonakdarian wrote:

> Is there a way to display how long a Win XP system has been up?
> Somewhat analogous to the *nix uptime command.

ugly, somewhat slow, and possibly locale dependent:

import os, re

def uptime():
return re.search(
"System Up Time:\s*(.+)", os.popen("systeminfo").read()
).group(1)

print uptime()

 



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


Re: MP3 - VBR - Frame length in time

2004-12-12 Thread Ivo Woltring

"Florian Schulze" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sat, 11 Dec 2004 20:32:30 +0100, Ivo Woltring <[EMAIL PROTECTED]>
> wrote:
>
> > mmpython will help but not always.
> > Lets put it this way. I will ALWAYS read through the whole file. In that
> > order I don't mind evaluating each frame. The thing I don't seem to be
> > able
> > to find is the timelength-constants for frames for the different mp3
> > versions, bitrates and layers. Can anybody help me?
>
>  From http://www.oreilly.com/catalog/mp3/chapter/ch02.html#71109
> "In addition, the number of samples stored in an MP3 frame is constant, at
> 1,152 samples per frame."
>
>
> So you only need the samplerate for each frame to calculate the duration
> of that frame.
>
> 1152 samples / 44100 samples per second ~ 0.026 seconds
>
> I don't exactly know whether you need to include mono/stereo into the
> calculation, you would have to test that out.
>
> Regards,
> Florian Schulze
>
thanks!
will try this out
Greetz,
Ivo.


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


Re: GUIs: wxPython vs. Tkinter (and others)

2004-12-12 Thread [EMAIL PROTECTED]
Hi, I had very bad experience with Tkinter when using input servers(for
CJK languages like scim, xcin...) on Linux (doesn't work), so you might
consider this.

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


PIL : possible ?

2004-12-12 Thread News M Claveau /Hamster-P
PIL
PI = Py (in french, it's the same 'sound')
=> PIL = (Py)L
and Py become P24
=> PIL = (P24)L
however, 'L' Christmas finishes It (in french, Christmas = NoëL)
and '(P24)' can to do readed like "Prepare, 24, for"
=> PIL = (P24)L  =>  Prepare, 24 for NoëL (Christmas)

Therefore, I hope that Fredick Lundh is a reincarnation of Santa Claus, and
that we will have a PIL for Python 2.4 in Christmas.

Do you think that it is probable?


:-)))
-- 
Michel Claveau





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


Re: Graphical box /interactive programme

2004-12-12 Thread nigelstanley
On Friday 03 December 2004 21:42, cm012b5105 wrote:
> Hello i want to put an interactive text programme in to a graphical box
> this is a small section of my text programme
> s = raw_input ("Hello whats your name? ")
> if s=='melvyn':
> print "your my boss's Dad the one they call in indian language DEEP
> THOUGHT LITTLE HORSE"
> if s=='carol':
>
> print "ahhh you are my boss's mom the one they call WREATH WOMAN"
> if s=='rebecca':
> print "you must be the FLORIST WOMAN"
> if s=='gareth':
> print "you must be the one they call the TRUCKER"
> if s=='carmel':
> print "you must be my boss's wife"
>
> s = raw_input ("what do you do for a living? ")
> print "Ahh thats easy you dont do much then",s,"my boss is a Truck driver."
>
>
> these are the instructions for a graphical boxfrom Tkinter import *
>
> root = Tk()
> cv = Canvas(root, width=400, height=300, bg="blue")
> cv.pack()
> cv.create_rectangle(50,30,320,290,outline="yellow",fill="red",width=10)
>
> mainloop()
>
> any way what i would like to do is create a programme that would run my
> text programme from this graphical box i tried to add the code for the box
> to the top of my text programme but when i run it i get the graphical box
> come up and my text   programme will not work untill i kill the box. i
> would be graet full if some body can help me acheive this.
> thanks nige
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Patents 'IsNot'

2004-12-12 Thread szuchymj
[EMAIL PROTECTED] wrote:
> All the VB fans I know have not experienced Delphi. They just don't
> know what they are missing. I am sure there are people who actually
> chose VB, but not any one I know. When I marvelled at VB myself, it
was
> back when I myself was unaware of Delphi/C++ Builder. I used to think
> C++ programming on Windows had to be with VC++ and MFC and VB was the
> only sane choice for most of my apps. When I first tried Delphi, it
> only took me a couple of hours to realize that I will never use VB
> again.

Well, Delphi has its share of problems and unfixed bugs. But it is
still the best  development system for Win32, especially in comparison
to Visual Studio 6.

I've heard some good things about Python too, but haven't had any
reason to try it yet.

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


Re: Overriding properties - Javaesque property rant

2004-12-12 Thread Kay Schluehr

> There are several ways to fix it. The simplest would be to create a
new
> property object in CC's definition:
>
> class CC(C):
>  def set_value(self, val):
>  if val < 0:
>  self.__val = 1
>  else:
>  self.__val = val
>  value = property(C.get_value, set_value)

It won't fix because __val is defined as a class variable in C, but as
an instance variable in CC. The set_value method creates a new __val. A
typical Python pitfall. C.get_value would still return _C__val.

> But an easier, more flexible method would be to use a metaclass which

> automatically adds properties for specially-named methods. One
example
> of such a metaclass is autoprop from Guido van Rossum's descrintro
> essay; see http://www.python.org/2.2.3/descrintro.html>.

Yes, but i dislike it either. This powerfull metaclass approach
obscures the property creation right in the place. And it supports the
tendency to create fat frameworks. A few weeks ago i talked to someone
who avoided propertys completely because they seemed to Javaesque to
him. I first agreed and understood his ranting about this awkward
get_bla, set_blubb stuff. Then I rembebered that the property()
function is just a descriptor-creator and one can easily wrap around it
for simplification.

So i defined defprop()

def defprop(name, default = None, modify=None, check=None, types=[]):

name  = "__"+name
def get(obj):
if not hasattr(obj,name):
setattr(obj,name, default)
return getattr(obj,name)

def set(obj,value):
if types:
if not True in [isinstance(value,t) for t in types]:
raise TypeError, "Can't assign %s to property
%s."%(value,name[2:])
if check:
if not check(value):
raise TypeError, "Can't assign %s to property
%s."%(value,name[2:])
if modify:
setattr(obj,name,modify(value))
else:
setattr(obj,name,value)

return property(get,set,None)


I left out to define delete. It was for demonstration purposes only.
Now define Your own classes:

class X(object):
a = defprop("a")
b = defprop("b",types=(tuple,list))
c = defprop("c",check = lambda x:hasattr(x,"__len__"))
d = defprop("d",default=0)

class XX(X):
def set_d(val):
if val<0:
return 1
return val

d = defprop("d",default=0,modify=set_d)  # overwrite d

It would be nice also to refuse the redundant naming a = defprop("a")
and write
a = defprop() instead. But it's actually not possible at the moment (
or only with deep introspection ).

Session on:

>>> x = X()
>>> x.d
0
>>> xx = XX()
>>> xx.d
0
>>> xx.d = -1
>>> xx.d
1

Ciao
 Kay

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


Re: uptime for Win XP?

2004-12-12 Thread Andrey Ivanov
>> I believe that "uptime" works from the console, but don't have a machine
>> to check it with...

> Doesn't work for me, but if you have win32all installed, you can get it
> from Python:
> >>> import win32api
> >>> print "Uptime:", win32api.GetTickCount(), "Milliseconds"
> Uptime: 148699875 Milliseconds

MSDN  recommends  another approach. They say, that you should retrieve
the  value  of "System Up Time" counter from HKEY_PERFORMANCE_DATA. In
theory,  you  can do it without win32all, by using _winreg module. All
you  need  is  to  know  a  counter  index,  which can be fetched from
registry.  On  my  system "System Up Time" counter has index "674", so
Python code should look like this:

>>> import _winreg
>>> value, type_code = _winreg.QueryValueEx(_winreg.HKEY_PERFORMANCE_DATA, 
>>> "674")
>>> print "Uptime: %s miliseconds" % (value,)

But in current implementation of _winreg it doesn't work. I've checked
the  sources  and  found  that  current  implementation doesn't handle
ERROR_MORE_DATA,  which  prevents  it  from retrieving any performance
counters. I'm thinking of bug/patch submission.


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


Re: Persistent objects

2004-12-12 Thread Max M
Paul Rubin wrote:
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one.  So you could have a
persistent dictionary d, and if you say 
   d[x] = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d[x].  Then if you
exit the app and restart it later, there'd be a way to bring d back
into the process and have that Frob instance be there.
Have you considdered using the standalone ZODB from Zope?
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Paul Rubin
Max M <[EMAIL PROTECTED]> writes:
> > Basically I wish there was a way to have persistent in-memory objects
> > in a Python app, maybe a multi-process one.  So you could have a
> > persistent dictionary d, and if you sayd[x] = Frob(foo=9, bar=23)
> > that creates a Frob instance and stores it in d[x].  Then if you
> > exit the app and restart it later, there'd be a way to bring d back
> > into the process and have that Frob instance be there.
> 
> Have you considdered using the standalone ZODB from Zope?

No.  I've heard that it's quite slow, and works sort of the way shelve
does.  Am I mistaken?  I want the objects to never leave memory except
through mmap.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Paul Rubin
Duncan Booth <[EMAIL PROTECTED]> writes:
> Have you looked at ZODB and ZEO? It does most of what you ask for,
> although not necessarily in the way you suggest.

You're the second person to mention these, so maybe I should check into
them more.  But I thought they were garden-variety persistent object
schemes that wrote pickles into disk files.  That's orders of magnitude
slower than what I had in mind.

> It doesn't attempt to hold everything in memory, but so long as most of 
> your objects are cache hits this shouldn't matter. Nor does it use shared 
> memory: using ZEO you can have a client server approach so you aren't 
> restricted to a single machine.

Well, if it doesn't use shared memory, what does it do instead?  If
every access has to go through the TCP stack, you're going to get
creamed speed-wise.  The mmap scheme should be able to do millions of
operations per second.  Are there any measurements of how many
ops/second you can get through ZODB?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: from vb6 to Python

2004-12-12 Thread Nigel Rowe
MarcoL wrote:

> MarcoL wrote:
<>
> Can anybody tell me anything about the IDE Spe?
> 
> Thanks
> 
> Marco

http://projects.blender.org/projects/spe/ 
and 
http://projects.blender.org/mailman/listinfo/spe-user

should cover most questions

-- 
Nigel Rowe
A pox upon the spammers that make me write my address like..
rho (snail) swiftdsl (stop) com (stop) au
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Nigel Rowe
Paul Rubin wrote:

> I've had this recurring half-baked desire for long enough that I
> thought I'd post about it, even though I don't have any concrete
> proposals and the whole idea is fraught with hazards.
> 
> Basically I wish there was a way to have persistent in-memory objects
> in a Python app, maybe a multi-process one.
<>

Maybe POSH (http://poshmodule.sourceforge.net/) is what you want.

>From the "About POSH"

Python Object Sharing, or POSH for short, is an extension module to Python
that allows objects to be placed in shared memory. Objects in shared memory
can be accessed transparently, and most types of objects, including
instances of user-defined classes, can be shared. POSH allows concurrent
processes to communicate simply by assigning objects to shared container
objects.

-- 
Nigel Rowe
A pox upon the spammers that make me write my address like..
rho (snail) swiftdsl (stop) com (stop) au
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Duncan Booth
Paul Rubin wrote:

> Well, as you can see, this idea leaves a lot of details not yet
> thought out.  But it's alluring enough that I thought I'd ask if
> anyone else sees something to pursue here.
> 

Have you looked at ZODB and ZEO? It does most of what you ask for, although 
not necessarily in the way you suggest.

It doesn't attempt to hold everything in memory, but so long as most of 
your objects are cache hits this shouldn't matter. Nor does it use shared 
memory: using ZEO you can have a client server approach so you aren't 
restricted to a single machine.

Instead of a locking scheme each thread works within a transaction, and 
only when the transaction is committed do you find out whether your changes 
are accepted or rejected. If they are rejected then you simply try again.
So long as most of your accesses are read-only, and transactions are 
committed quickly this scheme can work better than locking.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Alan Kennedy
Hi Paul,
[Paul Rubin]
> Basically I wish there was a way to have persistent in-memory objects
> in a Python app, maybe a multi-process one.  So you could have a
> persistent dictionary d, and if you say
>d[x] = Frob(foo=9, bar=23)
> that creates a Frob instance and stores it in d[x].  Then if you
> exit the app and restart it later, there'd be a way to bring d back
> into the process and have that Frob instance be there.
Have you looked at Ian Bicking's SQLObject?
http://sqlobject.org/
To define a class
class MyPersistentObj(SQLObject):
foo = IntCol()
bar = IntCol()
To instantiate a new object
my_new_object = MyPersistentObj(foo=9, bar=23)
Once the new object has been created, it has already been persisted into 
a RDBMS table automatically. To reload it from the table/database, e.g. 
after a system restart, simply supply its id.

my_existing_object = MyPersistentObj.get(id=42)
Select a subset of your persistent objects using SQL-style queries
my_foo_9_objects = MyPersistentObj.select(MyPersistentObj.q.foo == 9)
for o in my_foo_nine_objects:
process(o)
SQLObject also takes care of caching, in that objects are optionally 
cached, associated with a specific connection to the database. (this 
means that it is possible to have different versions of the same object 
cached with different connections, but that's easy to solve with good 
application architecture). So in your case, if your (web?) app is 
persistent/long-running, then you can simply have SQLObject cache all 
your objects, assuming you've got enough memory. (Hmm, I wonder if 
SQLObject could be made to work with weak-references?). Lastly, caching 
can be disabled.

I've found performance of SQLObject to be pretty good, but since you 
haven't specified particular requirements for performance, it's not 
possible to say if it meets your criteria. Although I feel comfortable 
in saying that SQLObject combined with an SQLite in-memory database 
should give pretty good performance, if you've got the memory to spare 
for the large databases you describe.

Other nice features include
1. RDBMS independent: currently supported are PostGres, FireBird, MySQL, 
SQLite, Oracle, Sybase, DBM. SQLServer support is in the pipepline. 
SQLObject code should be completely portable between such backend stores.

2. Full support for ACID transactional updates to data.
3. A nice facility for building SQL queries using python syntax.
4. Automated creation of tables and databases. Table structure 
modification supported on most databases.

5. Full support for one-to-one, one-to-many and many-to-many 
relationships between objects.

All in all, a great little package. I recommend that you take a close look.
Regards,
--
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
--
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Paul Rubin
Alan Kennedy <[EMAIL PROTECTED]> writes:
> Have you looked at Ian Bicking's SQLObject?
> 
> http://sqlobject.org/

That sounds like Python object wrappers around SQL transactions.
That's the opposite of what I want.  I'm imagining a future version of
Python with native compilation.  A snippet like

   user_history[username].append(time())

where user_history is an ordinary Python dict, would take a few dozen
machine instructions.  If user_history is a shared memory object of
the type I'm imagining, there might be a few dozen additional
instructions of overhead dealing with the proxy objects.  But if SQL
databases are involved, that's thousands of instructions, context
switches, TCP messages, and whatever.  That's orders of magnitude
difference.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Paul Rubin
Nigel Rowe <[EMAIL PROTECTED]> writes:
> Maybe POSH (http://poshmodule.sourceforge.net/) is what you want.

Thanks, that is great.  The motivation was somewhat different but it's
clear that the authors faced and dealt with most of the same issues
that were bugging me.  I had hoped to avoid the use of those proxy
objects but I guess there's no decent way around them in a
multi-process setting.  The authors similarly had to reimplement the
basic Python container types, which I'd also hoped could be avoided,
but I guess what they did was straightforward if messier than I'd like.

POSH also makes no attempt to implement persistence, but maybe that's
a fairly simple matter of mmap'ing the shared memory region and
storing some serialized representation of the proxy objects.  If I
correctly understand how POSH works, the number of proxies active at
any moment should be fairly low.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen

2004-12-12 Thread Peter Hansen
Michele Simionato wrote:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,
class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)
but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?
Likely this is at least part of the answer:
c:\>python
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on 
win32
>>> import os
>>> os.kill
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute 'kill'

Note the "on win32" part above...
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: uptime for Win XP?

2004-12-12 Thread Peter Hansen
Bengt Richter wrote:
 >>> import os
 >>> [x for x in os.popen('pstat') if 'uptime' in x.lower()]
 ['Pstat version 0.3:  memory: 327080 kb  uptime:  4 15:44:16.696 \n']
[...]
There's got to be something leaner though.
I believe there is, though I can't guarantee this is a
valid approach:
>>> import datetime
>>> import os
>>> def uptime():
...   t = os.stat('c:/pagefile.sys').st_mtime
...   td = datetime.datetime.now() - datetime.datetime.fromtimestamp(t)
...   return td
...
>>> print uptime()
12 days, 20:21:17.491000
(matches results of Bengt's and Fredrik's two approaches
two within a minute or so)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


usage of __import__ across two files

2004-12-12 Thread bwobbones
Hi,
 I'm having trouble making __import__ work with the two classes 
attached. The PrintHello() method can't be seen in the BMTest2 class - 
what am I doing wrong here?


class one - BMTest - in BMTest.py:

import wx
from traceback import print_exc
class ImportTest(wx.Frame):
   def __init__(self):
   wx.Frame.__init__(self, None, -1, "ImportTest",
 size = (666,480), style = wx.DEFAULT_FRAME_STYLE)
   #tb = BMToolBar(self) # works just fine!
   tb = __import__('BMTest2')
   tb2.PrintHello()
class MyApp(wx.App):
   def __init__(self, flag):
   wx.App.__init__(self, flag)
   def OnInit(self):
   frame = ImportTest()
   self.SetTopWindow(frame)
   return True
  
if __name__ == '__main__':
  try:
  app = MyApp(False)
  app.MainLoop()
  except:
  print print_exc()

**
class 2 BMTest2 - in BMTest2.py:
**
import wx
class BMToolBar(wx.ToolBar):
   def __init__(self, parentFrame):
   wx.ToolBar.__init__(self, parentFrame, -1, 
style=wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT|wx.TB_TEXT)
   print "*** gday ***"
   self.Realize()
  
   def PrintHello(self):
   print "Hello"

Any help will be much appreciated!
Bones
--
http://mail.python.org/mailman/listinfo/python-list


Re: usage of __import__ across two files

2004-12-12 Thread John Roth
"bwobbones" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Hi,
 I'm having trouble making __import__ work with the two classes attached. 
The PrintHello() method can't be seen in the BMTest2 class - what am I 
doing wrong here?

[snip]
   tb = __import__('BMTest2')
   tb2.PrintHello()
Shouldn't this be tb.PrintHello() ?
[snip]
Any help will be much appreciated!
Bones
John Roth 

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


Skinnable/Stylable windows in wxPython?

2004-12-12 Thread Daniel Bickett
I'm very near finishing a medium to large scale application, so I'm
getting a head start on the GUI side of things. Part of the concept is
to give as much attention to presentation as functionality, and
something I really wanted to do was transcend the basic window and
style it to an extent,

To be honest, the wxPopupWindow was basically what I was looking for,
but it isn't available on Mac, eliminating that possibility.
wxShapedWindow would have sufficed, but it uses a more recent version
wxPython that I've chosen not to install for various dependency
issues, so I really can't use that.

I've combed through the demo countless times, but I really can't find
any answers. So, the question: what is the best way (or is there one,
rather) to achieve an end comparable to skinning my wx windows?

Thanks for your help,
Daniel Bickett
-- 
http://mail.python.org/mailman/listinfo/python-list


Any books on PyQt

2004-12-12 Thread Michael McGarry
Hi,
Do any books cover PyQt?
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: Any books on PyQt

2004-12-12 Thread Phil Thompson
On Sunday 12 December 2004 4:11 pm, Michael McGarry wrote:
> Hi,
>
> Do any books cover PyQt?
>
> Michael

http://www.opendocs.org/pyqt/

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


Re: New versions breaking extensions, etc.

2004-12-12 Thread "Martin v. Löwis"
Jive wrote:
I don't even know how to do that! :-)  What's the difference between VC++
.net Standard and Visual Studio .net Pro?  (Besides $370?)  Is the former
C++ only, but with the IDE, and the later the whole shebang with SourceSafe,
VBASIC, and all that?
According to
http://msdn.microsoft.com/howtobuy/vstudio/
there is, for VS.NET, "Academic", "Professional", "Enterprise
Developer", and "Enterprise Architect". For Python extensions, all
these releases will work; see
http://msdn.microsoft.com/howtobuy/vstudio/features/
for a checkmark list. For VC++ .NET 2003 Standard, it appears that
you get just the C++ compiler, and the IDE, see
http://msdn.microsoft.com/howtobuy/visualc/features/default.aspx
OH NO!  I've gone seriously off-topic.  Please don't call the Spanish
Inquisiton.  Allow me to re-phrase the question:  What do I need to build
(on-topic) Python extensions?
Either VS.NET 2003 or VC++ .NET 2003 should do (although I don't know
anybody who owns the latter to be sure). The core issue is that it needs
a "native" C++ compiler (ie. not just managed C++), and that it needs
mscvcr71.dll.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: newbie questions

2004-12-12 Thread Steven Bethard
Fredrik Lundh wrote:
John Machin wrote:

Of course, in this simple case, I wouldn't be likely to write the clear
function since the inline code is simpler and has less overhead:
def main()
var1 = []
var1.append('a')
var1[:] = []
Even less overhead: del var1[:]

even less overhead:
var1 = []
(if you rely on having multiple references to the same list, instead of 
referring
to the list by name, you may want to reconsider the design)
Yes, that's what the next 4 lines of my message said. ;)
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Named pipes in threads

2004-12-12 Thread Philippe C. Martin
HI,

I currently have a "working" script that uses sockets to handle threads 
communications - the problem is that it gives me obvious problems in handling 
free ports (launching the script more than once ).

Is thread named pipes communication allowed ?

Regards,

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


Re: Skinnable/Stylable windows in wxPython?

2004-12-12 Thread mefjr75
Hello Daniel,
The wxPopupWindow is also missing several things that would make it
suitable for a frame, like accelerator events. I built a 'chromeless'
picture viewer once using wxPopupWindow and it worked , but it was
missing things I needed because of missing functionality in
wxPopupWindow. IMHO is isn't intended to be used as a full featured
frame.
The only way *I* know how to skin an app in wxWindows is using
wxShapedWindow .wxShapedWindow just changes the frame shape, you then
need to render a background picture and then place elements on that
background for buttons and other controls, you also will have to
implement functionality for those elements so they work like normal
controls, plus a hundred other gotchas.
Skinning is a pain ,and to do it right you probably need to use a
'DoubleBufferedDc' so your elements won't flicker when you click or
move them. I started writing a generic skinner class that does the hard
stuff but when I tested found that it needed to be rewritten using a
DoubleBefferedDC. Maybe someday...
Hope any of this helps maybe others have diffrent ideas.
M.E.Farmer

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


for loop

2004-12-12 Thread houbahop
Hello,
I have seen a lot of way to use the for statement, but I still don't know 
how to do:

for i=morethanzero to n
or
for i= 5 to len(var)

of course I kno wthat I can use a while loop to achieve that but if this is 
possible whith a for one, my preference goes to the for.

regards,
Dominique. 


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


Re: possible ?

2004-12-12 Thread Fredrik Lundh

> PIL
> PI = Py (in french, it's the same 'sound')
> => PIL = (Py)L
> and Py become P24
> => PIL = (P24)L
> however, 'L' Christmas finishes It (in french, Christmas = NoëL)
> and '(P24)' can to do readed like "Prepare, 24, for"
> => PIL = (P24)L  =>  Prepare, 24 for NoëL (Christmas)
>
> Therefore, I hope that Fredick Lundh is a reincarnation of Santa Claus, and
> that we will have a PIL for Python 2.4 in Christmas.

"Wo ist mein paket?"
"Was für ein paket?"
"Mein paket?!"
"Kein paket! Hohoho!"

http://effbot.org/downloads/#PIL

 



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


Re: character encoding conversion

2004-12-12 Thread "Martin v. Löwis"
Dylan wrote:
Things I have tried include encode()/decode()
This should work. If you somehow manage to guess the encoding,
e.g. guess it as cp1252, then
  htmlstring.decode("cp1252").encode("us-ascii", "xmlcharrefreplace")
will give you a file that contains only ASCII characters, and
character references for everything else.
Now, how should you guess the encoding? Here is a strategy:
1. use the encoding that was sent through the HTTP header. Be
   absolutely certain to not ignore this encoding.
2. use the encoding in the XML declaration (if any).
3. use the encoding in the http-equiv meta element (if any)
4. use UTF-8
5. use Latin-1, and check that there are no characters in the
   range(128,160)
6. use cp1252
7. use Latin-1
In the order from 1 to 6, check whether you manage to decode
the input. Notice that in step 5, you will definitely get successful
decoding; consider this a failure if you have get any control
characters (from range(128, 160)); then try in step 7 latin-1
again.
When you find the first encoding that decodes correctly, encode
it with ascii and xmlcharrefreplace, and you won't need to worry
about the encoding, anymore.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Named pipes in threads

2004-12-12 Thread Jive

"Philippe C. Martin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> HI,
>
> I currently have a "working" script that uses sockets to handle threads
> communications - the problem is that it gives me obvious problems in
handling
> free ports (launching the script more than once ).
>
> Is thread named pipes communication allowed ?
>
> Regards,
>

Replace the sockets with a queue of strings.
http://docs.python.org/lib/module-Queue.html

Write your Send and Recv functions in terms of Queue.get() and Queue.put();
> Philippe


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


Dr. Dobb's Python-URL! - weekly Python news and links (Dec 10)

2004-12-12 Thread Josiah Carlson
QOTW:  "I still think this is a silly idea, but at least it doesn't track mud
all over Python's nice clean rugs." -- Michael J. Fromberger

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/dde861393aa5a68/eb3a5e53f9743413

"Basically, in tk, canvases are for vector drawing; in other toolkits, they're
more for bitmap drawing. And this makes quite a difference..." -- Eric Brunel


Lovers of the eric3 editor get a new 3.5.1 release.
http://mail.python.org/pipermail/python-list/2004-November/252450.html

Lovers of the Wing IDE editor get a new 2.0.1 release.
http://mail.python.org/pipermail/python-list/2004-December/253698.html

Sometimes the `struct` module's use and structure aren't obvious to the
new user.  Tim Peters and Peter Hanson help clarify.
http://mail.python.org/pipermail/python-list/2004-November/252741.html

A company in New York is looking for a Python deveoper for Zope work.
I know there has to be someone in NYC with that kind of experience.
http://mail.python.org/pipermail/python-list/2004-December/252840.html

Locks, mutexes, Semaphores - Oh My!  Discussion of when to use what.
Hint: they are basically the same, only speed and internal implementation
really set them apart.  RLock, Condition, Event, etc., add functionality.
http://mail.python.org/pipermail/python-list/2004-December/252869.html

Gordon Williams asks about set intersections.  Raymond Hettinger
confirms that set intersection with the `set` module does the right
thing.
http://mail.python.org/pipermail/python-list/2004-December/253142.html

A nice one-liner for DNA recombinations.  Be careful with the size of
your input, you don't want to go and segfault with a 512M element list...
http://mail.python.org/pipermail/python-list/2004-December/252970.html

Armin Ringo releases Psyco 1.3, for those of us who like our Python to
execute faster.  Support for Python 2.1-2.4 is included, as well as more
support for local variables.
http://mail.python.org/pipermail/python-list/2004-December/253234.html

Alia Khouri asks "why no python setup.py uninstall?" and gets basically
no response.  It brings up the topic of Python package management, which
has been discussed before.
http://mail.python.org/pipermail/python-list/2004-December/253316.html
http://python.org/peps/pep-0301.html

Andre Roberge asks for advice on naming a new (claimed better) version
of "Guido van Robot", which is an instructional tool for new programmers.
http://mail.python.org/pipermail/python-list/2004-December/253453.html



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

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

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

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

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

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

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

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

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

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

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

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways y

Re: New versions breaking extensions, etc.

2004-12-12 Thread Jive

"Martin v. Löwis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Either VS.NET 2003 or VC++ .NET 2003 should do (although I don't know
> anybody who owns the latter to be sure). The core issue is that it needs
> a "native" C++ compiler (ie. not just managed C++), and that it needs
> mscvcr71.dll.
>

Sorry if I'm being dense.   If I had that DLL, why couldn't I use VC++ 6.0?

It's still not clear to me exactly what's in each package.  One would think
there would be a more technical description on the MS web pages.


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


Web form validators for Python (RequiredFieldValidator anyone?)

2004-12-12 Thread Lorenzo Bolognini
Hi all,
just trying to do some web development with Python. At the moment I'm 
keeping an eye on these projects: Nevow, JotWeb, Albatross, Snakeskin 
and my favorite, CherryPy, soon coming with a version 2!

But, even though there's something I like in all of these frameworks, I 
can't find in the Python world anything similar to the .NET 
RequiredFieldValidator class (which I believe is the only thing I really 
like about .NET 
http://www.w3schools.com/aspnet/control_reqfieldvalidator.asp) even 
without the client side capabilities which I wouldn't rely upon anyway.

Can you point me to some code/class/module that implements what I'm 
looking for?

Thanks a lot,
Lorenzo
--
Get my PGP Public Key @ http://www.bolognini.net/LBolognini.txt
--
http://mail.python.org/mailman/listinfo/python-list


Re: for loop

2004-12-12 Thread Diez B. Roggisch
> for i in range(morethanzero, n):
>  ...
> 
>> for i= 5 to len(var)
> 
> for i in range(5, len(var)):
>  ...

Better use xrange - it doesn't create an actual list, but instead an
iterator enumerating the elements. That way more memory and cpu efficient.
-- 
Regards,

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


Re: for loop

2004-12-12 Thread Steven Bethard
houbahop wrote:
for i=morethanzero to n
for i in range(morethanzero, n):
...
for i= 5 to len(var)
for i in range(5, len(var)):
...
although range(len(var)) is usually not what you want, because you can 
just do:

for item in itertools.islice(var, 5, None):
...
or if you really do need the index too:
for i, item in itertools.islice(enumerate(var), 5, None):
...
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: Named pipes in threads

2004-12-12 Thread Michael Fuhr
"Philippe C. Martin" <[EMAIL PROTECTED]> writes:

> I currently have a "working" script that uses sockets to handle threads 
> communications - the problem is that it gives me obvious problems in handling 
> free ports (launching the script more than once ).

Who is communicating with whom?  Threads communicating with other
threads in the same process?  Threads communicating with a peer
external to the process?  What "obvious problems" are you having?

> Is thread named pipes communication allowed ?

What happened when you tried it?

What are you trying to do?  Perhaps if you backed up and described
the "what" we could make better recommendations about the "how."

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with embbed boost.python in multi-interpreter andmulti-thread HELP please

2004-12-12 Thread Donnie Leen
All right, I found the answer in boost.python test example embedding.cpp,
not to call initmodulename() in every sub-interpreter, just call
PyImport_AppendInittab("modulename", initmodulename) before call to
Py_Initialize(), this will add the module to the interpreter's builtin
modules, then I can call "import modulenmame" in each sub-interpeter.

Donnie Leen


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


Yahoo! Auto Response

2004-12-12 Thread bustamam98
This email address is no longer valid.




Original Message:


X-YahooFilteredBulk: 82.226.229.7
Authentication-Results: mta127.mail.re2.yahoo.com
  from=python.org; domainkeys=neutral (no sig)
X-Originating-IP: [82.226.229.7]
Return-Path: <[EMAIL PROTECTED]>
Received: from 82.226.229.7  (EHLO yahoo.com) (82.226.229.7)
  by mta127.mail.re2.yahoo.com with SMTP; Sun, 12 Dec 2004 10:08:02 -0800
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Mail Delivery (failure [EMAIL PROTECTED])
Date: Sun, 12 Dec 2004 19:08:14 +0100
MIME-Version: 1.0
Content-Type: multipart/related;
type="multipart/alternative";
boundary="=_NextPart_000_001B_01C0CA80.6B015D10"
X-Priority: 3
X-MSMail-Priority: Normal

This is a multi-part message in MIME format.

--=_NextPart_000_001B_01C0CA80.6B015D10
Content-Type: multipart/alternative;
boundary="=_NextPart_001_001C_01C0CA80.6B015D10"

--=_NextPart_001_
_
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

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


Re: Persistent objects

2004-12-12 Thread Irmen de Jong
Paul Rubin wrote:
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one.  So you could have a
persistent dictionary d, and if you say 
   d[x] = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d[x].  Then if you
exit the app and restart it later, there'd be a way to bring d back
into the process and have that Frob instance be there.
If I'm not mistaken, PyPersist (http://www.pypersyst.org/) is
something like this. Haven't used it though...
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: for loop

2004-12-12 Thread loritsch
houbahop wrote:
> Hello,
> I have seen a lot of way to use the for statement, but I still don't
know
> how to do:
>
> for i=morethanzero to n
> or
> for i= 5 to len(var)
>
> of course I kno wthat I can use a while loop to achieve that but if
this is
> possible whith a for one, my preference goes to the for.
>
> regards,
> Dominique.

I think the key point that hasn't been made here is what a for
statement is really doing in python...

>From the online documentation:

"The for statement is used to iterate over the elements of a sequence
(such as a string, tuple or list) or other iterable object"

Neither of the statements:
> for i=morethanzero to n
> for i= 5 to len(var)
create a sequence or iterable object, and that is why they don't work.

That is why previous posts in this thread have suggested using range(),
xrange(), etc.  Because they create a sequence or iterable object.
When first using python, I recall that this distinction was not clear
to me, as I was used  to a more traditional for statement (as in
C/C++):

for ( initialise ; test ; update )

Essentially, python's for statement is more like a foreach statement in
many other languages (Perl, C#, etc).  These statements essentially
reduce the traditional form above to what many consider a more readable
form:

foreach item in collection:

In order to transform the tradition for statement into this more
readable form, each language requires that their collections being
iterated over satisfy a precondition defined by the language (in python
this precondition is that the collection is iterable).

While this restriction may seem a little strange to people who are used
to the more traditional for statement form, the result of this approach
is often a more readable and clear statement.
Regards,

Michael Loritsch

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


Re: for loop

2004-12-12 Thread Steven Bethard
Diez B. Roggisch wrote:
for i in range(5, len(var)):
...
Better use xrange - it doesn't create an actual list, but instead an
iterator enumerating the elements. That way more memory and cpu efficient.
I could've sworn I read somewhere in the past that xrange was supposed 
to be slower than range in some situation, but at least for some simple 
cases in Python 2.4, it seems to be about as fast or faster:

> python -m timeit "for i in range(100): a = i*2"
1 loops, best of 3: 21.8 usec per loop
> python -m timeit "for i in xrange(100): a = i*2"
1 loops, best of 3: 19.4 usec per loop
> python -m timeit "for i in range(1): a = i*2"
100 loops, best of 3: 2.18 msec per loop
> python -m timeit "for i in xrange(1): a = i*2"
100 loops, best of 3: 2.29 msec per loop
> python -m timeit "for i in range(10): a = i*2"
10 loops, best of 3: 25.5 msec per loop
> python -m timeit "for i in xrange(10): a = i*2"
10 loops, best of 3: 20.7 msec per loop
I hardly ever use (x)range for anything (because you can almost always 
use a for loop to loop over items instead), but I'll file this info away 
mentally for the next time I do.  Thanks!

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


Re: Python + Newspipe

2004-12-12 Thread kael
Peter Hansen wrote:
you should probably contact the author(s) for assistance since this is not a Python issue.
I contact the author and there is a bug in the version I'm using.
Now it works by running
$ cd /newspipe
$ python ./newspipe.py
Instead of
$ python /newspipe/newspipe.py
Thanks for your help.
--
kael
--
http://mail.python.org/mailman/listinfo/python-list


newsgroups

2004-12-12 Thread Francis Lavoie
Do we need a special account or something to use the newsgroup instead 
of the mailling list?
--
http://mail.python.org/mailman/listinfo/python-list


Re: newbie questions

2004-12-12 Thread John Machin
Fredrik Lundh wrote:
> John Machin wrote:
>
> >> Of course, in this simple case, I wouldn't be likely to write the
clear
> >> function since the inline code is simpler and has less overhead:
> >>
> >> def main()
> >>  var1 = []
> >>  var1.append('a')
> >>  var1[:] = []
> >
> > Even less overhead: del var1[:]
>
> even less overhead:
>
> var1 = []

Firstly, your replacement is not functionally equivalent. Secondly, it
appears *NOT* to have less overhead:

>python -m timeit "a=range(100); del a[:]"
10 loops, best of 3: 3.56 usec per loop
>python -m timeit "a=range(100); a=[]"
10 loops, best of 3: 3.95 usec per loop
>python -m timeit "a=range(1000); del a[:]"
1 loops, best of 3: 25.3 usec per loop
>python -m timeit "a=range(1000); a=[]"
1 loops, best of 3: 33.1 usec per loop
[Python 2.4; Windows 2000; Athlon 1.4Ghz chip]
>
> (if you rely on having multiple references to the same list, instead
of referring
> to the list by name, you may want to reconsider the design)
>

Indeed. The OP's insistence on emptying the container instead of
trashing it along with its contents -- which is my interpretation of
"it doesn't emty my var (i don't want to destroy the var, just make it
like if it just have been created" -- was intriguing but not explained
...

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


Re: Fun with Outlook and MAPI

2004-12-12 Thread Steve Holden
Chris wrote:
Alas, I dont think that there is much you can do to prevent the 
confirmation dialogs with Outlook's MAPI dll. MS added them in a 
service pack as an anti-virus measure, so no work-around. Not all 
clients show these anoying dialogs though. Thunderbird definately 
doesn't.
There is actually a workaround. You're using Simple MAPI which has a 
nice easy interface. The confirmation dialogs are only for Simple 
MAPI. Using Extended MAPI can work around the problem but its a lot 
more tricky.
See the initial discussion here: 
http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646

This code has now been included in pywin32 somehow but I can't 
remember where and its late. Should also be a cookbook entry. Maybe 
Google can help :-)

Cool.  I'll take a look an' see if I can get it to work.  MAPI has 
turned out to be a major PITA.  Especially when trying to learn it and 
Python at the same time. :)

Chris
There's recently been some discussion of this topic on the python-win32 
list, most lately to accommodate moving sent messages to the Sent 
folder. I've personally sent several hundred messages using the 
techniques outlined there.

http://mail.python.org/pipermail/python-win32/2004-August/002239.html is 
a good starting point.

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


Re: character encoding conversion

2004-12-12 Thread Christian Ergh
Martin v. Löwis wrote:
Dylan wrote:
Things I have tried include encode()/decode()

This should work. If you somehow manage to guess the encoding,
e.g. guess it as cp1252, then
  htmlstring.decode("cp1252").encode("us-ascii", "xmlcharrefreplace")
will give you a file that contains only ASCII characters, and
character references for everything else.
Now, how should you guess the encoding? Here is a strategy:
1. use the encoding that was sent through the HTTP header. Be
   absolutely certain to not ignore this encoding.
2. use the encoding in the XML declaration (if any).
3. use the encoding in the http-equiv meta element (if any)
4. use UTF-8
5. use Latin-1, and check that there are no characters in the
   range(128,160)
6. use cp1252
7. use Latin-1
In the order from 1 to 6, check whether you manage to decode
the input. Notice that in step 5, you will definitely get successful
decoding; consider this a failure if you have get any control
characters (from range(128, 160)); then try in step 7 latin-1
again.
When you find the first encoding that decodes correctly, encode
it with ascii and xmlcharrefreplace, and you won't need to worry
about the encoding, anymore.
Regards,
Martin
I have a similar problem, with characters like äöüAÖÜß and so on. I am 
extracting some content out of webpages, and they deliver whatever, 
sometimes not even giving any encoding information in the header. But 
your solution sounds quite good, i just do not know if
- it works with the characters i mentioned
- what encoding do you have in the end
- and how exactly are you doing all this? All with somestring.decode() 
or... Can you please give an example for these 7 steps?
Thanx in advance for the help
Chris
--
http://mail.python.org/mailman/listinfo/python-list


Best book on Python?

2004-12-12 Thread Michael McGarry
Hi,
What is the best book covering Python?
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: for loop

2004-12-12 Thread houbahop
thank you,
Whith python, It seems that all that I have learn in other languages is not 
directly usable :) but looks like python is more efficient.
dominique.

<[EMAIL PROTECTED]> a écrit dans le message de news: 
[EMAIL PROTECTED]
> houbahop wrote:
>> Hello,
>> I have seen a lot of way to use the for statement, but I still don't
> know
>> how to do:
>>
>> for i=morethanzero to n
>> or
>> for i= 5 to len(var)
>>
>> of course I kno wthat I can use a while loop to achieve that but if
> this is
>> possible whith a for one, my preference goes to the for.
>>
>> regards,
>> Dominique.
>
> I think the key point that hasn't been made here is what a for
> statement is really doing in python...
>
>>From the online documentation:
>
> "The for statement is used to iterate over the elements of a sequence
> (such as a string, tuple or list) or other iterable object"
>
> Neither of the statements:
>> for i=morethanzero to n
>> for i= 5 to len(var)
> create a sequence or iterable object, and that is why they don't work.
>
> That is why previous posts in this thread have suggested using range(),
> xrange(), etc.  Because they create a sequence or iterable object.
> When first using python, I recall that this distinction was not clear
> to me, as I was used  to a more traditional for statement (as in
> C/C++):
>
> for ( initialise ; test ; update )
>
> Essentially, python's for statement is more like a foreach statement in
> many other languages (Perl, C#, etc).  These statements essentially
> reduce the traditional form above to what many consider a more readable
> form:
>
> foreach item in collection:
>
> In order to transform the tradition for statement into this more
> readable form, each language requires that their collections being
> iterated over satisfy a precondition defined by the language (in python
> this precondition is that the collection is iterable).
>
> While this restriction may seem a little strange to people who are used
> to the more traditional for statement form, the result of this approach
> is often a more readable and clear statement.
> Regards,
>
> Michael Loritsch
> 


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


Re: Named pipes in threads

2004-12-12 Thread Philippe C. Martin

>>Replace the sockets with a queue of strings.
>>http://docs.python.org/lib/module-Queue.html

>>Write your Send and Recv functions in terms of Queue.get() and Queue.put();



And those entry points seem to reentrant too !!!


Thanks a lot, you made my day (I say that a lot on this mailing list :-))


Regards,

Philippe

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


Re: Best book on Python?

2004-12-12 Thread Peter Hansen
Michael McGarry wrote:
What is the best book covering Python?
For what purpose?
Are you a complete newbie to Python?  To programming?
Are you looking for a technical reference, a tutorial,
information about a specific area (e.g. networking, GUIs),
or something else?
Please help the poor non-mindreaders amongst us to help you...
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python mascot proposal

2004-12-12 Thread Dimitri Tcaciuc
Jeremy Bowers wrote:
On Sun, 12 Dec 2004 20:54:38 +, Dimitri Tcaciuc wrote:
I haven't came up with the name for that guy yet, so I'm leaving that 
for public suggestions :). It is time Python gets an official face in 
the Net! *cough* Anyway, I would like to hear your thoughts and suggestions.

I mean no offense, this was just my initial reaction: I like the drawing
itself, but the first thing that coloration brings to mind is the word
"diseased". Sorry, I don't know how to make this sound less brutal without
getting that across. But I do like the drawing.
Heh, well, I tried to pick the actual snake colors, but I agree that it 
looks rather plagued. I shall remove the colouring for now, and think on 
a more lively colour scheme.
--
http://mail.python.org/mailman/listinfo/python-list


Re: newbie questions

2004-12-12 Thread Fredrik Lundh
John Machin wrote:

>> > Even less overhead: del var1[:]
>>
>> even less overhead:
>>
>> var1 = []
>
> Firstly, your replacement is not functionally equivalent.

do you really have to tell me that?  (as I said, if you rely on the difference,
your design is probably flawed)

> Secondly, it appears *NOT* to have less overhead:

did you ask your fingers ;-)

my benchmark told me it was faster, but that doesn't make sense, and I cannot
repeat that test; I suspect I compared plain assignent to the assign-to-slice 
variant.
or maybe I used a pre-Raymond version of Python...

 



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


Re: newsgroups

2004-12-12 Thread Steve Holden
Francis Lavoie wrote:
Do we need a special account or something to use the newsgroup instead 
of the mailling list?
Yes, you have to find an NNTP server that carries comp.lang.python. It's 
possible your Internet service provider runs such a news server and will 
let you access it as a part of your subscription (this is the case for 
me). If not then you'll have to contract with a third party news service 
(some of htese are available for free).

Alternatively, take a look at http://www.gmane.com/, a mailing 
list/newsgroup interface service which I believe offers an NNTP service.

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


Re: Named pipes in threads

2004-12-12 Thread Philippe C. Martin

>>What are you trying to do?  Perhaps if you backed up and described
>>the "what" we could make better recommendations about the "ho

Just trying to have a GUI thread (tkinter) talk back and forth with a debugger 
derived object threaded (bdb).

No I have not tried yet as sometimes things seem to work until 


Regards,

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


Re: thread/queue bug

2004-12-12 Thread Steve Holden
phil wrote:
[...]
 > 5. Sorry I can't be more help.  You don't give anyone much
 > to go on.  All that stuff about "Queue(0)" and "listenq"
 > is pretty much meaningless to us, you know...
You know, I get this all the time on language support groups.
This might be a clue.
All of my Linux support groups, if they don't understand, say
why and ask for elaboration.  I tried to explain what was going on,
without incuding the source.  I have about 200 man hours in the source
and I bet it would take longer to understand it.
If my explanation was insufficient, I'm sorry.
It *was* pretty sketchy. Basically you shouldn't expect people to debug 
code they can't see. There are some very able programmers active on this 
newsgroup, but their psychic abilities are limited :-)

ALSO, you did not respond to my email, so I didn't know how to reply.
There is nothing on the archives page which gives me a clue as to
how to respond.
Once yo post in the newsgroup (or mailing list) then use of the same 
channel is advisable.

SO, if there is ZERO chance there is some sort of inadvertent lock
occuring in saved byte code, I just kludge around and move on.
Maybe 2.4
If you suspect the problem is a bug in Python then you might consider 
searching the bugs database on sourceforge. If nobody's reported a bug 
then you are being very optimistic assuming that migrating to 2.4 will 
fix the problem.

Thanks.

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


Re: uptime for Win XP?

2004-12-12 Thread Brad Tilley
Esmail Bonakdarian wrote:
Hi,
Is there a way to display how long a Win XP system has been up?
Somewhat analogous to the *nix uptime command.
Thanks,
Esmail
Just run the built-in Windows utility 'systeminfo' from a cmd prompt. 
Python can call 'systeminfo' like this:

import os
uptime = os.popen('systeminfo', 'r')
data = uptime.readlines()
uptime.close
for line in data:
   if line contains "System Up Time":
  print line
Please note that 'systeminfo' is only present on Windows XP PRO and 
Windows Server 2003... Windows XP HOME does not have this command.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python mascot proposal

2004-12-12 Thread richard
Dimitri Tcaciuc wrote:
> While I'm not absolutely positive, it looks like Python still doesn't
> have any official mascot or logo.

As already mentioned, there is a snake that gets used in a number of icons
around the place - the windows installer, for example.


> Hence, here's something I came up with 
> yesterday. Its by no means a final version, but rather just a draft to
> show an idea. Here's a link to png file.
> 
> http://www.sfu.ca/~dtcaciuc/art/pymascot.png

Very cute :)

Having said that, don't forget that Python's name has *nothing to do with
snakes*. Please consider sticking to the original roots of the language's
name: Monty Python's Flying Circus. IIRC, Guido has said a number of times
that he's not fond of using a snake for logos. Hence the MacPython stuff
uses a 16 ton weight in its icons.


Richard

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


Re: character encoding conversion

2004-12-12 Thread "Martin v. Löwis"
Christian Ergh wrote:
- it works with the characters i mentioned
It does.
- what encoding do you have in the end
US-ASCII
- and how exactly are you doing all this? All with somestring.decode() 
or... Can you please give an example for these 7 steps?
I could, but I don't have the time - just try to come up with some
code, and I try to comment on it.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best book on Python?

2004-12-12 Thread Maurice LING

Google for Dive Into Python. Its a free online publication, see if is 
any good for you.

Cheers,
I like "Dive into Python" for the fact that it tends to explain examples 
line by line in an annotated form but it may just be my personal 
preference.

If the focus is only on printed books and there is some experience with 
programming, "programming python" by Lutz from O'Reilly might be a good 
one.

Personally, I learn with "Python: the complete reference" by Martin C. 
Brown from Osborne/McGraw-Hill. There is no reason as to why I chose 
this book to start except that it is on discount in my university's 
bookshop. Although I must confess that I do not start from zero ground 
as I've read the official "Python tutorial" and "Learning Python" before 
hand. I must say that the mindset is important. I had almost hit a "I 
have to learn python" situation, rather than "it is nice to know" situation.

If the focus includes online materials, then there is a mountain of free 
online tutorials to wade through. Although somehow the materials seems 
fragmented but it is a nice source as well, it can help you piece out 
what is essential about python.

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


Re: PEP 338: Executing modules inside packages with '-m'

2004-12-12 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> This will definitely allow me and other python programmers to package
> our scripts better

puzzling.

I'd say that for a typical user,

$ python -m foo.bar arg

is a marginal improvement over

$ python -c "import foo.bar" arg

compared to

$ bar arg

 



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


Re: Best book on Python?

2004-12-12 Thread Michael McGarry
I have many years of programming experience and know a little bit of 
Tcl. I am looking for a book to detail on the features including GUI in 
a reference style.

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


Re: newbie questions

2004-12-12 Thread Steve Holden
houbahop wrote:
Thank you everyone, but I still not understand why such a comon feature like 
passing parameters byref that is present in most serious programming
languages is not possible in a clean way,here in python.

I have the habit to never use globals as far as possible and this involve 
that my main function is passing some parameters by reference to subs to 
allow them to modify the vars.

I would be sad to break my structured programming scheme because a lack of 
feature.

In others languages you can use things like pointers to strings or 
Mysub(byref MyVar) 

and it does the trick :) 


The Python language allows complex objects to be returned, so there are 
two techniques you should be aware of.

1. If an argument is mutable (such as a list or a dictionary) then its 
contents can be modified using the reference passed in as an argument.

2. If an argument is immutable then it can be modified by returning the 
new value as a tuple element, in this way:

a, b, c = someFunc(a, b, c)
regards
 Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: possible ?

2004-12-12 Thread Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
(set font to : courier) :

 __  __  __
/\__  _\/\ \/\ \
\/_/\ \/\ \ \___   __   ___ \ \ \/'\  
   \ \ \ \ \  _ `\   /'__`\   /' _ `\\ \ , < /',__\
\ \ \ \ \ \ \ \ /\ \L\.\_ /\ \/\ \\ \ \\`\  /\__, `\
 \ \_\ \ \_\ \_\\ \__/.\_\\ \_\ \_\\ \_\ \_\\/\/
  \/_/  \/_/\/_/ \/__/\/_/ \/_/\/_/ \/_/\/_/ \/___/

 ____
/\ \  /\ \
\ `\`\\/'/  _____  __
 `\ `\ /'  / __`\ /\ \/\ \
   `\ \ \ /\ \L\ \\ \ \_\ \
 \ \_\\ \/ \ \/
  \/_/ \/___/   \/___/

 __  __ __   _ __   __  __
/\ \/\ \  /'__`\/\`'__\/\ \/\ \
\ \ \_/ |/\  __/\ \ \/ \ \ \_\ \
 \ \___/ \ \\\ \_\  \/` \
  \/__/   \// \/_/   `/___/> \
/\___/
\/__/

__
   /\ \
  ___ _____  _____ \ \ \___
/' __` __`\ /\ \/\ \  /'___\\ \  _ `\
/\ \/\ \/\ \\ \ \_\ \/\ \__/ \ \ \ \ \  __
\ \_\ \_\ \_\\ \/\ \\ \ \_\ \_\/\ \
 \/_/\/_/\/_/ \/___/  \//  \/_/\/_/\ \/
\/
 ____ __
/\  _`\ /\ \   __ /\ \   /\ \
\ \ \L\_\ _ ____\_\ \   _ __  /\_\\ \ \/'\   \ \ \
 \ \  _\//\`'__\/'__`\  /'_` \ /\`'__\\/\ \\ \ , <\ \ \
  \ \ \/ \ \ \//\  __/ /\ \L\ \\ \ \/  \ \ \\ \ \\`\   \ \_\
   \ \_\  \ \_\\ \\\ \___,_\\ \_\   \ \_\\ \_\ \_\  \/\_\
\/_/   \/_/ \// \/__,_ / \/_/\/_/ \/_/\/_/   \/_/











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


Re: Web form validators for Python (RequiredFieldValidator anyone?)

2004-12-12 Thread Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
Sorry, I had bad read the question...

Michel Claveau



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


Re: Python mascot proposal

2004-12-12 Thread Michael Sparks
On Sun, 12 Dec 2004, Dimitri Tcaciuc wrote:

> Hey everybody,
>
> While I'm not absolutely positive, it looks like Python still doesn't
> have any official mascot or logo.

Hmm... I thought it did - indeed it's in every character set (?):

  @

For those who can't see the detail, it's an eel curled round, grinning.

> It is time Python gets an official face in the Net!

Ahh.. But it does - indeed by having the official logo above, it proves
that Python's advertising is so insidious that it's in every email. After
all it Sun with their JVM claimed the dot in dot com, it makes sense for
Python with the Python VM to claim the other important piece of
punctuation as a logo.

I believe that Apple will be adopting the double slash //, with go faster
stripes colouration, in the new year, and that unfortunately leaves
Microsoft with the colon.


Michael.

(Nice piccy BTW ;)

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


Re: Best book on Python?

2004-12-12 Thread Paul Rubin
Michael McGarry <[EMAIL PROTECTED]> writes:
> I have many years of programming experience and know a little bit of
> Tcl. I am looking for a book to detail on the features including GUI
> in a reference style.

Why not just use the online documentation?

There's also an excellent Tkinter manual at:

http://infohost.nmt.edu/tcc/help/pubs/lang.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw Sockets vs. What?

2004-12-12 Thread Matt
Thanks for the responses--they were very helpful. I've looked at IDLE
and pyro and I think I'll try using pyro for this first version.

--Matt

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


Re: Python mascot proposal

2004-12-12 Thread Dimitri Tcaciuc
richard wrote:
Dimitri Tcaciuc wrote:
While I'm not absolutely positive, it looks like Python still doesn't
have any official mascot or logo.

As already mentioned, there is a snake that gets used in a number of icons
around the place - the windows installer, for example.

Hence, here's something I came up with 
yesterday. Its by no means a final version, but rather just a draft to
show an idea. Here's a link to png file.

http://www.sfu.ca/~dtcaciuc/art/pymascot.png

Very cute :)
Having said that, don't forget that Python's name has *nothing to do with
snakes*. Please consider sticking to the original roots of the language's
name: Monty Python's Flying Circus. IIRC, Guido has said a number of times
that he's not fond of using a snake for logos. Hence the MacPython stuff
uses a 16 ton weight in its icons.
Richard
Yup, I was aware of the fact of Monty Python roots of the language name. 
However, you will probably agree that a snake is more associative.

Plus, if to use some characteristic MP feature like a giant foot, I'm 
not positive that it won't trigger any copyright issues.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Persistent objects

2004-12-12 Thread Bengt Richter
On 12 Dec 2004 01:54:28 -0800, Paul Rubin  wrote:

>I've had this recurring half-baked desire for long enough that I
>thought I'd post about it, even though I don't have any concrete
>proposals and the whole idea is fraught with hazards.
>
>Basically I wish there was a way to have persistent in-memory objects
>in a Python app, maybe a multi-process one.  So you could have a
>persistent dictionary d, and if you say 
>   d[x] = Frob(foo=9, bar=23)
>that creates a Frob instance and stores it in d[x].  Then if you
>exit the app and restart it later, there'd be a way to bring d back
>into the process and have that Frob instance be there.
I've had similar thoughts. Various related topics have come up on clp.
I speculated on getting a fast start capability via putting the entire
heap etc state of python in an mmap-ed region and having a checkpoint
function you could call sort of like a yield to goes under the hood
and writes the state to a file. Then you would restart it via
python -resume savedstate and instead of loading normally, python would
load its state from savedstate and appear to continue from the "yeild"
that caused the checkpointing.

Of course that has a lot of handwaving content, but the idea of image-wise
saving state is similar to what you want to do I think.

But I think you have to think about what id(Frob(foo=9, bar=23)) means,
because that is basically what you are passing to d (along with id(x) above).

For speed you really don't want d to be copying Frob immutable representations
from heap memory to mmap memory, you want Frob to be created in mmap memory
to start with (as I think you were saying). But this requires specifying that
Frob should behave that way, one way or another. If we get class decorators,
maybe we could write

@persistent(mmapname)
class Frob(object):
...

but in the mean while we could write
class Frob(object):
...
Frob = persistent(mmapname)(Frob)

The other way is to modify the Frob code to inherit from Persistent(mmapname)
or such. BTW, mmapname IMO should not name a file directly, or you get horrible
coupling of the code to a particular site. I think there should be a standard
place to store the mapping from names to files, similar to sys.modules, so that
mmapnames can be used as abstract mmap space specifiers. In fact, the mapping
could use sys.modules by being in a standard module for registering mmapnames,
backed by a persistent config file (or we get recursion ?;-)

Thinking out loud here ...

So what could Frob = persistent(mmapnmame)(Frob) do with Frob to make Frob
objects persist and what will foo = Frob(...) mean?
foo is an ordinary name bound to the Frob instance.
But the binding here is between a transient name in the local name space
and a persistent Frob instance. So I think we need a Frob instance proxy
that implements an indirect reference to the persistent data using a persistent
data id, which could be an offset into the mmap file where the representation
is stored, analogous to id's being memory addresses. But the persistent 
representation
has to include type info also, which can't have RAM memory references in it, if 
it's
to be shared -- unless maybe if you do extreme magic for sharing, like debugger 
code
and relocating loaders etc.

Now if you wrote

@persistent(mmapname)
class PD(dict): pass
...
d = PD()
d[x] = frobinst

then if persistent was smart enough to recognize some useful basic types like 
dict,
then d would be a transient binding to a persistent dict proxy which could 
recognize
persistent object proxies as values and just get the persistent id and use that 
instead
of creating a new persistent representation, or if the value was a reference to 
an ordinary
immutable, a persistent copy could be made in mmap space, and the offset/id or 
_that_ would
be used as the value ref in the persistent representation of d. Similarly with 
the key.

d.__setitem__(key, value) would not accept a reference to an ordinary mutable 
value object
unless maybe it had a single reference count, indicating that it was only 
constructed to
pass as an argument. In that case, if persistent(mmapname)type(themutable)) 
succeeded, then
a representation could be created in the mmapname space and the mmap offset/id 
could be
used as the value ref in the d hash association with the key done again 
similarly.

I feel like this is doable, if you don't get too ambitious to start ;-)
The tricky parts will be getting performace with proxies checking in-RAM cached
representations vs in-mmap-RAM representations, and designing representations 
to make
that happen.

If it's worth it ;-) Don't good os file systems already have lru caching of hot 
info,
so how much is there to gain over a light weight data base's performance?


>
>Please don't suggest using a pickle or shelve; I know about those
>already.  I'm after something higher-performance.  Basically d would
>live in a region of memory that could 

Re: Python mascot proposal

2004-12-12 Thread Bud Rogers
richard wrote:

> Having said that, don't forget that Python's name has *nothing to do
> with snakes*. Please consider sticking to the original roots of the
> language's name: Monty Python's Flying Circus. IIRC, Guido has said a
> number of times that he's not fond of using a snake for logos.

Some time ago while cruising a Barnes & Noble I found a Python book I
hadn't seen before.  I don't remember the title at the moment, and I
don't have the book at hand, but the cover had a large python staring
down at a small frightened rodent.  When I went to check out, the
person at the counter was a kind of frumpy librarian type.  She looked
at the cover and made some snide remark about frightening small
children.   I thought for a moment about trying to explain to her that
the cover art was an inside joke on an inside joke.  When I realized
how far back I would have to go to unwind all the references, it just
didn't seem worth the trouble. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New versions breaking extensions, etc.

2004-12-12 Thread "Martin v. Löwis"
Jive wrote:
Either VS.NET 2003 or VC++ .NET 2003 should do (although I don't know
anybody who owns the latter to be sure). The core issue is that it needs
a "native" C++ compiler (ie. not just managed C++), and that it needs
mscvcr71.dll.

Sorry if I'm being dense.   If I had that DLL, why couldn't I use VC++ 6.0?
Sorry for being imprecise. You don't need just msvcr71.dll, you need an
import library for it, and you need to cause link.exe to use that import
library. VC6 will continue to link your extension modules with
msvcrt40.dll - regardless of what other DLLs you have on your system.
It might be that you also need the header files for msvcr71.dll,
although I believe you could get away with using the "wrong" (i.e.
VC6) header files.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: from vb6 to Python

2004-12-12 Thread Luis M. Gonzalez

Martijn Faassen wrote:
> Unfortunately this is currently not near production use, and whether
> Microsoft is funding IronPython development is up in the air:

It's true that he Ironpython's mailing list is a little bit innactive,
but this is just because there's only one person in charge of
Ironpython at this moment (although Microsoft was looking to hire a new
developer to help on this). However, the innactivity is due to the fact
that Jim Hugunin, its developer, has begun working for MS just a couple
of months ago, and as he says, there are tons of new CLR features to
learn that are applicable to dynamic languages.

You should also give credit to Jim: he's the man who developed Jython,
which is a complete inplementation of Python written in Java.
He also created Numeric and co-authored Aspect, another programming
language.
So I'm sure that Ironpython will be a reality soon, and a very good
one...

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


Re: uptime for Win XP?

2004-12-12 Thread Fredrik Lundh
Brad Tilley wrote

> Just run the built-in Windows utility 'systeminfo' from a cmd prompt.

you're a bit late, aren't you?

> for line in data:
>if line contains "System Up Time":
>   print line

what Python version is this?

 



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


Re: PEP 338: Executing modules inside packages with '-m'

2004-12-12 Thread richard
[EMAIL PROTECTED] wrote:
> A useful feature that is a logical extension of current '-m' behaviour.
> (I'm actually surprised it was left out in the first place)
> 
> This will definitely allow me and other python programmers to package
> our scripts better
> 
> Sounds Good to me. (-;

/me too :)


Richard

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


Re: Persistent objects

2004-12-12 Thread Dan Perl

"Paul Rubin"  wrote in message 
news:[EMAIL PROTECTED]
> I've had this recurring half-baked desire for long enough that I
> thought I'd post about it, even though I don't have any concrete
> proposals and the whole idea is fraught with hazards.
>
> Basically I wish there was a way to have persistent in-memory objects
> in a Python app, maybe a multi-process one.  So you could have a
> persistent dictionary d, and if you say
>   d[x] = Frob(foo=9, bar=23)
> that creates a Frob instance and stores it in d[x].  Then if you
> exit the app and restart it later, there'd be a way to bring d back
> into the process and have that Frob instance be there.

I haven't used it myself, but this sounds to me a lot like metakit 
(http://www.equi4.com/metakit.html).  Have you considered that and does it 
fit your needs?

Dan 


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


Re: for loop

2004-12-12 Thread Diez B. Roggisch
> I hardly ever use (x)range for anything (because you can almost always
> use a for loop to loop over items instead), but I'll file this info away
> mentally for the next time I do.  Thanks!

Thats true for me too - and since enumerate was introduced, the number of
applications of xrange have decreased further.


-- 
Regards,

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


Re: Python mascot proposal

2004-12-12 Thread Luis M. Gonzalez
Hey Dimitri,

I completely agree with you in that Python needs once for all a cool
logo.
I like your design very much, but I have a few thoughts about it:

1) I think that Python's logo should reflect its power.
If we use a mascot as its image, we would be giving the wrong idea:
that Python is a "toy" language, instead of a very good alternative to
other mainstream languages.

2) We should also bear in mind Guido's oppinion about using a snake for
identifying Python.

3) And finally, we should consider it very seriously. Image is not
everything, but it is very important for "marketing" a product. I'm
sure that if Java didn't have a cool name and a cool logo, it wouldn't
have been that succesfull.

I don't mean to sound like I'm rejecting your idea. I really like it
alot, and it is an excellent mascot.
It's just that I wouldn't use a mascot... I'd rather use a more
"killer" image.
Something that reflects power and excellence.

What do you think?

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


Re: Problem with Qt

2004-12-12 Thread Diez B. Roggisch
I think you have to introduce a layout on the group. The best thing is to
use qdesigner, it will do that for you. If you really need code, this is
cut'n'paste from a generate py-file:

self.buttonGroup4 = QButtonGroup(self,"buttonGroup4")
self.buttonGroup4.setColumnLayout(0,Qt.Vertical)
self.buttonGroup4.layout().setSpacing(6)
self.buttonGroup4.layout().setMargin(11)
buttonGroup4Layout = QHBoxLayout(self.buttonGroup4.layout())
buttonGroup4Layout.setAlignment(Qt.AlignTop)

self.radioButton3 = QRadioButton(self.buttonGroup4,"radioButton3")
buttonGroup4Layout.addWidget(self.radioButton3)
self.radioButton3_2 = QRadioButton(self.buttonGroup4,"radioButton3_2")
buttonGroup4Layout.addWidget(self.radioButton3_2)

-- 
Regards,

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


Re: subprocess.Popen

2004-12-12 Thread Keith Dart
Michele Simionato wrote:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via subclassing,
class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)
but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?
Probably because it is not entirely portable. If you want a more 
complete, but Posix-only (at least Linux and FreeBSD), process 
management and spawning then you can use the proctools module in pyNMS.

http://sourceforge.net/projects/pynms/


--
   \/ \/
   (O O)
-- oOOo~(_)~oOOo
Keith Dart <[EMAIL PROTECTED]>
vcard: 
public key: ID: F3D288E4   URL: 

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


Re: Best book on Python?

2004-12-12 Thread Maurice LING
Michael McGarry wrote:
I have many years of programming experience and know a little bit of 
Tcl. I am looking for a book to detail on the features including GUI in 
a reference style.

Thanks,
Michael
I am assuming that you do not want to venture pass the standard 
libraries at this moment, so in terms of GUI, Tkinter is about the only 
choice within the standard libraries.

"Programming Python, 2nd Ed." has a good section of Tkinter and GUI 
development.

You might want to search thru Amazon for Tkinter and find something to 
your satisfaction.

Pass the standard libraries, there are other GUI kits like wxPython etc 
etc., each carries a set of online documentations.

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


Re: Best book on Python?

2004-12-12 Thread Daniel Bickett
> If the focus is only on printed books and there is some experience with
> programming, "programming python" by Lutz from O'Reilly might be a good
> one.

I saw that book today at Barnes and Noble, and found it curiously
ironic that it had a very large mouse on the cover :) But maybe that's
just me.

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


Re: Best book on Python?

2004-12-12 Thread Maurice Ling
Daniel Bickett wrote:
If the focus is only on printed books and there is some experience with
programming, "programming python" by Lutz from O'Reilly might be a good
one.
   

I saw that book today at Barnes and Noble, and found it curiously
ironic that it had a very large mouse on the cover :) But maybe that's
just me.
Daniel Bickett
 

Yes it is somewhat ironic. I do think that a snake or something closer 
to a long, tube-like, legless animal will be more suitable. I have 
absolutely no idea how animals are chosen in O'Reilly.

maurice
begin:vcard
fn:Maurice Ling
n:Ling;Maurice
org:The University of Melbourne;Department of Zoology
adr:;;Gate 12, Genetics Lane;Parkville;Victoria;3010;Australia
email;internet:[EMAIL PROTECTED]
title:Probatory Ph.D. Candidate
tel;cell:+61 4 22781753
x-mozilla-html:FALSE
url:http://www.geocities.com/beldin79/
version:2.1
end:vcard

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

Re: handy stacktrace class

2004-12-12 Thread will . ware
Oh. Never mind, then.

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


Re: Persistent objects

2004-12-12 Thread Keith Dart
Paul Rubin wrote:
I've had this recurring half-baked desire for long enough that I
thought I'd post about it, even though I don't have any concrete
proposals and the whole idea is fraught with hazards.
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one.  So you could have a
persistent dictionary d, and if you say 
   d[x] = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d[x].  Then if you
exit the app and restart it later, there'd be a way to bring d back
into the process and have that Frob instance be there.
Check out the Durus project.
http://www.mems-exchange.org/software/durus/

--
   \/ \/
   (O O)
-- oOOo~(_)~oOOo
Keith Dart <[EMAIL PROTECTED]>
vcard: 
public key: ID: F3D288E4   URL: 

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


Re: Persistent objects

2004-12-12 Thread Keith Dart
Paul Rubin wrote:
I've had this recurring half-baked desire for long enough that I
thought I'd post about it, even though I don't have any concrete
proposals and the whole idea is fraught with hazards.
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one.  So you could have a
persistent dictionary d, and if you say 
   d[x] = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d[x].  Then if you
exit the app and restart it later, there'd be a way to bring d back
into the process and have that Frob instance be there.
Check out the Durus project.
http://www.mems-exchange.org/software/durus/

--
   \/ \/
   (O O)
-- oOOo~(_)~oOOo
Keith Dart <[EMAIL PROTECTED]>
vcard: 
public key: ID: F3D288E4   URL: 

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


Re: Persistent objects

2004-12-12 Thread Keith Dart
Paul Rubin wrote:
I've had this recurring half-baked desire for long enough that I
thought I'd post about it, even though I don't have any concrete
proposals and the whole idea is fraught with hazards.
Basically I wish there was a way to have persistent in-memory objects
in a Python app, maybe a multi-process one.  So you could have a
persistent dictionary d, and if you say 
   d[x] = Frob(foo=9, bar=23)
that creates a Frob instance and stores it in d[x].  Then if you
exit the app and restart it later, there'd be a way to bring d back
into the process and have that Frob instance be there.
Check out the Durus project.
http://www.mems-exchange.org/software/durus/

--
   \/ \/
   (O O)
-- oOOo~(_)~oOOo
Keith Dart <[EMAIL PROTECTED]>
vcard: 
public key: ID: F3D288E4   URL: 

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


Problem with Qt

2004-12-12 Thread Michael McGarry
Hi,
I am trying to show a radio button group on a window, but only the last 
radio button shows up. Anyone know why?

Here is the code:
from qt import *
import sys
a = QApplication(sys.argv)
widget = QWidget()
trafftype = QButtonGroup("Traffic Type", widget)
poisson = QRadioButton("Poisson", trafftype)
selfsimilar = QRadioButton("Self-Similar", trafftype)
a.setMainWidget(widget)
widget.show()
a.exec_loop()
Any help is greatly appreciated.
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best book on Python?

2004-12-12 Thread BJörn Lindqvist
I haven't read any Python paper books myself but as Christmas is
coming up, I've checked up on what Python books other people
recommend. Everyone who has reviewed Python books seem to like these
books:

* Python Essential Reference
* Python Cookbook
* Python in a Nutshell

The last two are both written by Alex Martelli and the cookbook is
IMHO really awesome.

-- 
mvh Björn
--
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen

2004-12-12 Thread Keith Dart
Keith Dart wrote:
Michele Simionato wrote:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via 
subclassing,

class Popen(subprocess.Popen):
def kill(self, signal = SIGTERM):
os.kill(self.pid, signal)
but I would prefer to have it in the standard Popen class. I am surprised
it is not there. Any comments?

Probably because it is not entirely portable. If you want a more 
complete, but Posix-only (at least Linux and FreeBSD), process 
management and spawning then you can use the proctools module in pyNMS.

http://sourceforge.net/projects/pynms/
I forgot to mention that the pyNMS package also has a module called 
"expect" that works like the Expect language. You can interact and 
control interactive processes and external CLIs with it.


--
   \/ \/
   (O O)
-- oOOo~(_)~oOOo
Keith Dart <[EMAIL PROTECTED]>
vcard: 
public key: ID: F3D288E4   URL: 

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


Re: Best book on Python?

2004-12-12 Thread Rod Haper
Michael McGarry wrote:
I have many years of programming experience and know a little bit of 
Tcl. I am looking for a book to detail on the features including GUI in 
a reference style.
Given that you have some acquaintance with Tcl, if you want a reference 
that caters toward GUI programming in Python using Tk, you might find 
this book of interest: "Python and Tkinter Programming" by John Grayson. 
 Manning Publications, 2000, 658p

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


Re: newsgroups

2004-12-12 Thread Francis Lavoie
Egor Bolonev wrote:
On Sun, 12 Dec 2004 14:57:50 -0500, Francis Lavoie <[EMAIL PROTECTED]> 
wrote:

Do we need a special account or something to use the newsgroup 
instead  of the mailling list?

why we use newsgroup instead of mailing list?
1. to keep my mail separated from the python discussion.
   And this mailinglist/newsgroup is quite big, 150 messages a day, is 
a lot of mail to go trough.
   It is easier to delete all mail without deleting my own one when I 
want to. Sometime there's subject I dont have answer or dont interest 
me. Othertime I'm tired or I didn't check my mail for a couple of day 
and it has become huge.
2. Better and faster search. Has I said, I dont want to keep all these 
mail in my mail box
3. I don't want to be notice 2 time per minute for mail. I prefer using 
it like a forum

>Yes, you have to find an NNTP server that carries comp.lang.python. 
It's possible your Internet service provider runs such a news server and 
will let you access it as a part of your subscription (this is the case 
for me). If not then you'll have to contract with a third party news 
service (some of htese are available for free).

>Alternatively, take a look at http://www.gmane.com/, a mailing 
list/newsgroup interface service which I believe offers an NNTP service.
>regards
> Steve

thank you, I was not well informed on how it does work. I though it was 
like a mailinglist or jabber like, just add it in your news section and 
it will connect directly on a news server. But it work now.

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


Re: subprocess.Popen

2004-12-12 Thread Peter Hansen
Peter Hansen wrote:
Michele Simionato wrote:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I
wonder why a "kill" method is missing. I am just adding it via 
subclassing,
> [Peter, noting os.kill is absent in win32]
Note, for the record, however, Jimmy Retzlaff's excellent recipe
for Win32 process termination, which can work with ctypes or
pywin32, and with either the PID such as popen returns and
subprocess.Popen stores, or the "handle" that spawn returns
(and which subprocess.Popen stores in its _handle attribute):
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347462
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Qt

2004-12-12 Thread Michael McGarry
Thanks, I had just discovered Qt Designer. I will probably use this. It 
seems to work well.

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


Re: Best book on Python?

2004-12-12 Thread Peter Hansen
Maurice Ling wrote:
Yes it is somewhat ironic. I do think that a snake or something closer 
to a long, tube-like, legless animal will be more suitable. I have 
absolutely no idea how animals are chosen in O'Reilly.
Generally, with both subtlety and humour, judging by how often the
O'Reilly Python books appear with tasty little rabbits and rodents
on them...
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >