Re: csv format to DBase III format

2006-01-03 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 I need to transfer csv format file to DBase III format file.
 How do i do it in Python language?

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362715

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


Re: PyHtmlGUI Project is looking for developers

2006-01-03 Thread phoenixathell

John J. Lee schrieb:

 Sybren Stuvel [EMAIL PROTECTED] writes:

  [EMAIL PROTECTED] enlightened us with:
   At the moment we don't work with javascript. But it should not be to
   hard to create a JavaScript Renderer similar to the css one we already
   have.
 
  Isn't CSS for rendering, and JavaScript for client-side scripting?

 I guess this is 'rendering' in a more general/abstract sense than
 'graphical rendering'.


 John

Exactly. In these case rendering means that you traverse a tree with
widget objects and every is rendered to a text representation of
itself. So if you traverse the object tree in the right order you will
get a complet text representation of such a object tree.

If you familiar with GUI programming then you can compare it to the
graphical rendering where you get a pixel representation of your form
elements (again a tree of widget objects).

Bottom line, PyHtmlGUI generates on the fly one or more text
representations from a object tree (e.g. Html, CSS, XML and maybe also
JavaScript).

Ingo

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


Re: Hypergeometric distribution

2006-01-03 Thread Raven

Travis E. Oliphant wrote:

 Notice the keyword for the comb function (in scipy) lets you use it to
 compute exact values.   SciPy does not just automatically use the long
 integer because this will always slow you down.

 comb(N, k, exact=0)

 Combinations of N things taken k at a time.

 If exact==0, then floating point precision is used, otherwise
 exact long integer is computed.

 Notes:
- Array arguments accepted only for exact=0 case.
- If k  N, N  0, or k  0, then a 0 is returned.
 
 -Travis Oliphant

Great, thanks Travis.
Ale

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Ilias Lazaridis
Alex Martelli wrote:
 Ilias Lazaridis [EMAIL PROTECTED] wrote:
...
 
... or equivalent (I do believe all I named have at least a Bachelor
degree, but with the undisputable results they've shown afterwards, I
think they'd all meet the or equivalent clause anyway).

   * BS or MS in Computer Science or equivalent (PhD a plus). 

This referes to an _academic_ degree.
 
 Ah, I see.  It depends on the job; for example,
 http://www.google.com/support/jobs/bin/answer.py?answer=23641 phrases
 the requirement in a more explicit way:
 
 * BS in Computer Science or equivalent experience.
[...]

 http://www.google.com/support/jobs/bin/answer.py?answer=23604 which is
 very specific about requiring:
 
 * A BS degree in mechanical, electrical or industrial technology.
 
Very few companies make an explicit statement about non-academic applicants.

It seems Google does not.
 
 It seems we do, for some but not all of our job openings -- that or
[...] - (comments, examples, elaborations)

I understand.

Ok, thus Google is flexible in this.

[sidenote: some jobs _require_ a degree by law]

So, I like Google again (in this context).

-

What about external independents ?

Does Google cooperate with them?

And how can one contact such a giant?

Mr. Martinelli, you seem to know python.

Sorry, that's a brand of sparking apple cider.  I get my name mispelled
that way often enough, since I moved to the US, to have become quite
sensitive about it!-)  In MY name, there is no in...

Mr. Martelli, I apologize for naming you like an soft-drink.
 
 Thanks: if I have to get mis-spelled, I prefer the alternate
 mis-spelling Martel, which at least refers to a potable cognac!-)

hicc!

-

Python vs. jamLang follows:

re: #LIMITATION: automated get/set methods via var-name not available
see the 'property' built-in.

Can you (or some reader) sent (or fill in) the relevant code?
[...] - (code, explanations)

thanks, I've changed this:

http://lazaridis.com/case/lang/python.html#simple_variable_access

this leads to a new limitation:

#LIMITATION: large amount of repetitive code

prints Class Definition (methods, fields), without code
LIMITATION: no direct access on object-model-level
not sure what you mean, but maybe see the 'inspect' module.

= Clas Definition is not accessible via MetaClasses
(possible workaround: inspect module)
 
 You can surely define a custom metaclass with methods that call
 inspect.whatever, or directly perform whatever introspection you
 require; it just seems strange to me to put this functionality in the
 metaclass.  At any rate, SOME code will need to execute to perform this
 task, so without code cannot be accomplished.  (Looking at your

I meant: reproduce the definition of the class (but without reproducing 
the source-code of the class)

I have removed the without code remark, which was missleading.

 evaluation of Ruby I note there's a LOT of code for this corresponding
 case, indeed through inspect, despite the 'without code' specification).
[...] - (code-level elaborations, implementation suggestions)

ok

#LIMITATION: attribute is not available systemwide in every object
#LIMITATION: attribute is not on object-model-level
#LIMITATION: Operation is not Object Oriented
[...]

I assure you: the level is totally appropriate.
 
 My point is that whether you call:
 
   setattr(zap, zip, zop)
 
 or
 
   zap.__setattr__(zip, zop)
 
 is a syntax trifle.  The semantics are the same (setattr is defined to
[...] - (elaborations)

I've understood this.

[...]
= Object.meta = Some meta information
= can be used instead of setattr(Object, meta, Some metainformation)
 
 I'd put it the other way 'round, since assigning to Object.meta is the
 simpler and most common approach (for an attribute name that's fixed).
 setattr is generally used only when the attribute name is computed at
 runtime (a variable or expression), because in that case there is no
 more direct syntax for the task.  getattr, in addition, has another use
 case: you can provide a default value so that, if the attribute is
 absent in the object, you get the default value rather than having to
 field an exception (AttributeError).  IOW, instead of:
 
   try:
 mymeta = Object.meta
   except AttributeError:
 mymeta = No metainfo available
 
 you can code the simpler:
 
   mymeta = getattr(Object, 'meta', No metainfo available)
 
 This is a reasonably frequent use case, since nobody particularly likes
 using four atomic actions (try, etc) to express the unitary concept
 give me the 'meta' attribute, IF available, otherwise a default.

I understand now.

It IS true that in Python you cannot set arbitrary attributes on

= #LIMITATION: Cannot add arbitrary attributes to arbitrary objects.
 
 Correct.  In particular, Python has a concept of IMMUTABLE objects:
 objects which, once created, cannot be altered in any way.  In
 particular, you cannot add attributes (or change existing ones, etc) in
 such immutable, aka constant, objects.

= Python: immutable 

Re: indentation preservation/restoration

2006-01-03 Thread smichr
I can't believe I forgot that trick :-| Thanks for the helpful
reminder.

/c

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


Re: Tkinter Scrollbar not working

2006-01-03 Thread Martin Franklin
Dustan wrote:
 I'm trying to get a scrollbar bound with a Frame, and I keep on getting
 a scrollbar, but it doesn't actually scroll. Some help, please?
 

It can be tricky getting an empty frame to scroll, can you post your 
example code so that we might be more helpful.  Here is an example of
binding a scroll bar to a Text widget (not exactly the same thing)


## import all names from Tkinter
## bit naughty but I don't mind
from Tkinter import *


# root window
root=Tk()


# text area
text=Text()
text.pack(side=left, expand=yes, fill=both)

# scrolbar for above textarea
sb = Scrollbar(root)
sb.pack(side=right, fill=y)



## bind them both together...

# this line binds the yscrollcommand
# of the text area to the scrollbar set method
text['yscrollcommand'] = sb.set

# this line binds the scrollbars command to
# the yview method of the text area
sb['command'] = text.yview



# mainloop entry
root.mainloop()


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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Duncan Booth
Alex Martelli wrote:

 It IS true that in Python you cannot set arbitrary attributes on
 arbitrary objects.  The workaround is to use a dict, indexed by the id
 of the object you want to set arbitrary attributes on; this has the
 helpful consequence that separate namespaces are used, so your arbitrary
 setting of metadata cannot interfere with the `true' attributes of the
 object in question.
 
That's a horrible suggestion (using id's, not the bit about separate 
namespaces). If you use the id then attributes will persist beyond the 
lifetime of the object and may suddenly reappear on other unrelated objects 
later.

A better suggestion here would be to use weak references. Unfortunately, 
not every Python object can be the target of a weak reference, so there is 
a limitation here preventing a useful implementation for many builtin 
types. I can't actually think of a use case for what Ilias wants, and if 
there isn't a use case it isn't a big problem, but if anyone can come up 
with a usecase please say.

BTW, I don't know Ruby enough to understand the example at 
http://lazaridis.com/case/lang/ruby/base.html:

class Object
  def meta # adds variable meta to all objects in the system
end

Talker.meta = Class meta information
john.meta = Instance meta information
1234.meta = 'any Instance meta information

puts Talker.meta
puts john.meta
puts 1234.meta  # an integer object

With the above code what would 'puts someexpressionresultingin1234.meta' 
output? i.e. is the attribute being set on all integers with the value 
1234, or just on a specific instance of an integer.

I don't know if the question even makes sense for Ruby, but it obviously 
needs to be answered before similar code could be implemented for Python.

Anyway, subject to the restriction that it doesn't work for int, list, 
tuple, etc. here is some code which lets you assign attributes the way I 
think Ilias wants. Unlike the Ruby code it doesn't just dump them all in 
the same namespace as other attributes, instead you have to create one or 
more meta namespaces which then don't interfere at all with other 
attributes on the objects, but which in other ways work just like 
attributes (e.g. for the purposes of inheritance you can set an attribute 
or a method on a base class and it works fine in instances of derived 
classes.)

BTW, If anyone does actually want to use this, the attribute lookup code is 
incomplete: completing it is left as a exercise.

- metaspace.py ---
from weakref import WeakKeyDictionary

class _Metanamespacewrapper(object):
def __init__(self, namespace, target):
self.__dict__['_namespace'] = namespace
self.__dict__['_target'] = target
d = namespace.d
if target not in d:
d[target] = {}
self.__dict__['_dict'] = d[target]

def __getattribute__(self, name):
if name.startswith('_'):
return object.__getattribute__(self,name)

if name in self._dict:
return self._dict[name]

t = type(self._target)
for klass in (t,)+t.__mro__:
try:
d = self._namespace.d[klass]
v = d[name]
except KeyError:
continue
break
else:
raise AttributeError, meta namespace has no attribute '%s' on 
object '%r' % (name, self._target)

if hasattr(v, '__get__'):
return v.__get__(self._target)
return v

def __setattr__(self, name, value):
self._dict[name] = value

def __delattr__(self, name):
del self._dict[name]

class Metanamespace(object):
def __init__(self):
self.d = WeakKeyDictionary()

def __call__(self, target):
return _Metanamespacewrapper(self, target)

meta = Metanamespace()

# Example of use...

class Talker(object):
def sayHello(self):
print Hello world

john = Talker()

# Check simple access to attributes
meta(Talker).name = 'test'
print meta(Talker).name, meta(john).name

meta(john).name = 'a name'
john.name = 'real attribute' # Does not interfere with meta namespace
print meta(john).name, john.name

meta(object).arg = 5
print arg=, meta(john).arg
meta(john).arg = 2
print arg=, meta(john).arg
del meta(john).arg
print arg=, meta(john).arg

def fn1(self, arg):
print fn1, self, arg
def fn2(self, arg):
print fn2, self, arg

# Check that methods work properly
meta(object).fn = fn1
meta(john).fn(1)
meta(Talker).fn = fn2
meta(john).fn(2)

-
The output is:

test test
a name real attribute
arg= 5
arg= 2
arg= 5
fn1 __main__.Talker object at 0x009D9670 1
fn2 __main__.Talker object at 0x009D9670 2

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


Re: python concurrency proposal

2006-01-03 Thread Peter Tillotson
I'd really like to see a concurrency system come into python based on 
theories such as Communicating Sequential Processes (CSP) or its 
derivatives lambda or pi calculus. These provide an analytic framework 
for developing multi thread / process apps. CSP like concurrency is one 
of the hidden gems in the Java Tiger release (java.util.concurrency). 
The advantages of the analytic framework is that they minimise livelock, 
deadlock and facilitate debugging.

I'm no expert on the theory but i've developed under these frameworks 
and found them a more reliable way of developing distributed agent systems.

You may also be interested in looking at 
http://sourceforge.net/projects/pympi

p
[EMAIL PROTECTED] wrote:
 Alright, so I've been following some of the arguments about enhancing
 parallelism in python, and I've kind of been struck by how hard things
 still are.  It seems like what we really need is a more pythonic
 approach.  One thing I've been seeing suggested a lot lately is that
 running jobs in separate processes, to make it easy to use the latest
 multiprocessor machines.  Makes a lot of sense to me, those processors
 are going to be more and more popular as time goes on. But it would
 also be nice if it could also turn into a way to make standard
 threading a little easier and trouble free.  But I'm not seeing an easy
 way to make it possible with the current constraints of the language,
 so it seems like we're going to need some kind of language improvement.
   Thinking of it from that perspective, I started thinking about how it
 would be easy to deal with in a more idealized sense.  It would be nice
 to abstract out the concept of running something in parallel to
 something that can be easily customized, is flexible enough to use in a
 variety of concepts, and is resonably hard to screw up and fairly easy
 to use.  Perhaps a new built-in type might be just the trick.  Consider
 a new suite:
 
 pardef Name(self, par type, arguments...):
   self.send(dest pardef, tag, arguments)
   self.receive(tag, arguments)
   return arguments
   yield arguments
 
 so the object would then be something you can create an instance of,
 and set up like a normal object, and it would have other interface
 functions as well.  Consider your basic vector add operation:
 
 import concurrent
 import array
 
 pardef vecadd(self, concurrent.subprocess, veca, vecb, arrtype):
   import array
   output = array.array(arrtype)
   for a,b in zip(veca, vecb):
   output.append( a + b)
   return output
 
 a = array.array('d')
 b = array.array('d')
 for i in range(1000):
   a.append(float(i))
   b.append(float(i))
 
 h1 = vecadd(a[:500], b[:500], 'd')
 h2 = vecadd()
 h2.veca = a[500:]
 h2.vecb = b[500:]
 h2.arrtype = 'd'
 
 h1.run()
 h2.run()
 c = h1.result + h2.result
 
 You can see a few things in this example.  First off, you'll notice
 that vecadd has the import for array inside it.  One of the most
 important things about the pardef is that it must not inherit anything
 from the global scope, all variable passing must occur through either
 the arguments or .receive statements.  You'll also notice that it's
 possible to set the arguments like instance values.  This isn't as
 important in this case, but it could be very useful for setting
 arguments for other pardefs.  Take this example of your basic SIMD-ish
 diffusion simulation:
 
 import concurrent
 
 pardef vecadd(self, concurrent.subprocess, right, left, up, down,
 initval):
   current = initval
   maxruns = 100
   updef = not (isinstance(up, int) or isintance(up, float))
   downdef = not (isinstance(down, int) or isintance(down, float))
   rightdef = not (isinstance(right, int) or isintance(right, float))
   leftdef = not (isinstance(left, int) or isintance(left, float))
   for i in range(maxruns):
   if updef:
   upval = self.receive(up, 'up')
   else:
   upval = up
   if downdef:
   downval = self.receive(down, 'down')
   else:
   downval = down
   if rightdef:
   rightval = self.receive(right, 'right')
   else:
   rightval = right
   if leftdef:
   leftval = self.receive(left, 'left')
   else:
   leftval = left
   current = (upval + downval + leftval + rightval) / 4
   if updef:
   up.send('down', current)
   if downdef:
   down.send('up', current)
   if rightdef:
   right.send('left', current)
   if leftdef:
   left.send('right', current)
   return current
 
 diffgrid = {}
 for x, y in zip(range(10), range(10)):
   diffgrid[(x, y)] = vecadd()
 for x, y in zip(range(10), range(10)):
   

RE: Work with Windows workgroups under Python?

2006-01-03 Thread Tim Golden
[Karlo Lozovina]
| I'm running Python 2.4 under WinXP Pro, and I would like to 
| do some basis 
| operations on my LAN - get list of workgroups, list the 
| computers in each 
| workgroup and possibly connect to specific computer and get 
| share/directory list? Is there some Pythonic way of doing 
| this? Or any 
| other less Pythonic way?

If you search this mailing list / newsgroup on Google
Groups (or however else you want) looking for, say,
windows shares, you will find quite a few people who
have already asked and/or answered this question in
various ways.

If their answers don't seem to meet your need, perhaps
you might then come back and ask something more specific.

Hopefully helpfully
Tim Golden


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

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


Re: Work with Windows workgroups under Python?

2006-01-03 Thread Heiko Wundram
Karlo Lozovina wrote:
 Is there some Pythonic way of doing this?

If you need to query for workgroups from pure Python (because you're running
under Linux, for example), search the web for the source package of PySMB.
That's a pure Python implementation of (parts of) the SMB protocol. It has
been abandoned by it's author, as it seems, but IIRC the last version I
used worked like a charm for exactly what you're trying to do with it.

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


RE: WMI - invalid syntax error?

2006-01-03 Thread Tim Golden
[py]
| Sent: 30 December 2005 16:15
| To: python-list@python.org
| Subject: Re: WMI - invalid syntax error?
| 
| py wrote:
| Something must be happening somewhere causing it
|  to get fouled up.  I'm gonna try on a different PC.
| 
| I tried on another PC, same problem.
| 
| Also, I added reload(wmi) before I create an instance of 
| wmi.WMI just
| to see what happens, so I hve...
| 
| import wmi
| 
| def ppn(machine=None):
| try:
| reload(wmi)
| wmiObj = wmi.WMI(machine)
| except Exception, e:
| print Error:  + str(e)
| 
| ...now I get this as the error message..
| Error: (-2147221020, 'Invalid syntax', None, None)
| 
| Slightly different than before...but same message.

Hmmm. I think I'm now in the unusual situation of having
*too much* information to solve the problem. The thing I'm
straining for is the minimum reproducible situation. At
first it looked as though it was down to running the code
from a file rather than at the interpreter. Is that still
the case? Your previous post about the monikers suggests
that running the code twice -- in any way -- triggered
the problem. Is that true? The code above introduces the 
extra complication of a reload which I'm afraid just muddies 
the waters.

To confirm, your code above runs from a file any number
of times without issue on my (WinXP Python 2.4.2) box
using wmi 0.6b.

Behind the scenes, the wmi module is doing something
like this:

code
import win32com.client
x = win32com.client.GetObject (winmgmts:)
/code

Now if I deliberately fudge that moniker, I'll
get the error message you show above, which is
what I expected with an ill-formed moniker.

code
import win32com.client
x = win32com.client.GetObject (winmgmtxx:)
# pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
/code

Googling for your original error code (-0x7ffbfe1c) which 
is 800401E4 in top-bit-set hex, most of the hits suggest 
that WMI is not installed on the box in question (typically 
because it's a Win98 or WinNT install without the WMI download). 
But you're on WinXP, so that can't be it.

I'm afraid I'm still mystified; it's frustrating because
I can't even reproduce the situation.

TJG


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

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


itertools.izip brokeness

2006-01-03 Thread rurpy
The code below should be pretty self-explanatory.
I want to read two files in parallel, so that I
can print corresponding lines from each, side by
side.  itertools.izip() seems the obvious way
to do this.

izip() will stop interating when it reaches the
end of the shortest file.  I don't know how to
tell which file was exhausted so I just try printing
them both.  The exhausted one will generate a
StopInteration, the other will continue to be
iterable.

The problem is that sometimes, depending on which
file is the shorter, a line ends up missing,
appearing neither in the izip() output, or in
the subsequent direct file iteration.  I would
guess that it was in izip's buffer when izip
terminates due to the exception on the other file.

This behavior seems plain out broken, especially
because it is dependent on order of izip's
arguments, and not documented anywhere I saw.
It makes using izip() for iterating files in
parallel essentially useless (unless you are
lucky enough to have files of the same length).

Also, it seems to me that this is likely a problem
with any iterables with different lengths.
I am hoping I am missing something...

#-
# Task: print contents of file1 in column 1, and
# contents of file2 in column two.  iterators and
# izip() are the obvious way to do it.

from itertools import izip
import cStringIO, pdb

def prt_files (file1, file2):

for line1, line2 in izip (file1, file2):
print line1.rstrip(), \t, line2.rstrip()

try:
for line1 in file1:
print line1,
except StopIteration: pass

try:
for line2 in file2:
print \t,line2,
except StopIteration: pass

if __name__ == __main__:
# Use StringIO to simulate files.  Real files
# show the same behavior.
f = cStringIO.StringIO

print Two files with same number of lines work ok.
prt_files (f(abc\nde\nfgh\n), f(xyz\nwv\nstu\n))

print \nFirst file shorter is also ok.
prt_files (f(abc\nde\n), f(xyz\nwv\nstu\n))

print \nSecond file shorter is a problem.
prt_files (f(abc\nde\nfgh\n), f(xyz\nwv\n))
print What happened to \fgh\ line that should be in column
1?

print \nBut only a problem for one line.
prt_files (f(abc\nde\nfgh\nijk\nlm\n), f(xyz\nwv\n))
print The line \fgh\ is still missing, but following\n \
line(s) are ok!  Looks like izip() ate a line.

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


Re: Regex anomaly

2006-01-03 Thread Sam Pointon
Would this particular inconsistency be candidate for change in Py3k?
Seems to me the pos and endpos arguments are redundant with slicing,
and the re.match function would benefit from having the same arguments
as pattern.match. Of course, this is a backwards-incompatible change;
that's why I suggested Py3k.

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Ilias Lazaridis
Alex Martelli wrote:
 Anton Vredegoor [EMAIL PROTECTED] wrote:
[...]

No insider information is necessary, the job requirements make it
absolutely clear (at least to me) that Google is a company with an
elitist culture,
 
 Absolutely yes, in terms of who we want to work at Google:  we DO want
 GREAT people.  And we don't keep this a secret, either: right up there
 at http://www.google.com/jobs/, we say our strategy is simple: we
 hire great people.  Rather than hiring a LOT of people, we prefer to be
 extremely, obsessively selective, and try to hire ONLY a few people,
 ones who we can convince ourselves do deserve that adjective, great.
 
 This does mean that we definitely tend err on the side of caution, and
 FAIL to hire some people who are also great, just because we can't
 determine with sufficient certainty that they indeed are -- I've seen
 this happen more than once, and deeply regret it (for both Google and
 the person), but I have no idea how we could do better without relaxing
 our extremely elitist standards (we do debate these issues internally
 all of the time, trying to do better, but have found no magic wand yet).

[...]
 students), but I've met many people with advanced degrees from even the
 best/most elitist universities, such as Stanford or MIT, where it sure
 looked to me as if the university's attempts to only graduate the very
 best have definitely failed.

[...]
 Requiring a certain title for a job is mostly a desperate attempt to
 reduce the huge amount of work and effort it takes to hire great people,
 whittling down the number of resumes to be considered divided by the
 number of hires from the high thousands to the low hundreds.  If there
 were available infinite resources for the job of hiring/selection, we
 could easily interview, say, 6000 candidates for a post, giving each a
 week or so of concentrated attention to probe their abilities; alas,
 this would require about 120 person-years from our people for the
 selection process.  So, if nobody at Google did ANYTHING BUT interview
 candidates, given that we have a bit over 5000 employees now, we could
 hire in the course of 2006 another 40 or so, without doing anything
 else.  (The numbers are all off the top of my head, but I think they may
 be roughly the right orders of magnitude).
 
 This is just impractical: we need to hire many more than 40, AND cannot
 afford to have all existing employees do nothing but select new ones.
 So, we need to shrink the ratio drastically, on both factors: say 10
 instead of 40 hours of selection per candidate, and 50 rather than 6000
 candidates being considered per post.  So we perform selection in
 stages, and most candidates out of those many thousands-per-job are
 weeded out at the very first stage, e.g. by failing to meet specific
 qualifications.
 
 I wish that, as you say, titles were indeed strong indications of
 excellence.  Unfortunately, they aren't, but in some cases they're
 better than nothing.  Many of our job descriptions, as I pointed out in
 another post on this thread, say BS or equivalent experience or words
 to that effect; if you can show the or equivalent, and can get past
 the first hurdle, then that title is the least of the issues.  For
 example, if we advertised a job requiring PhD or equivalent, and among
 the candidates were Bill Gates, Larry Page, and Sergey Brin, none of
 whom has obtained a PhD to the best of my knowledge, they would surely
 be able to display the or equivalent based on their accomplishments
 and experience, and thus get past that first hurdle.
[...]

-

TAG.google.evolution.talent.detection

.


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


Re: itertools.izip brokeness

2006-01-03 Thread Paul Rubin
[EMAIL PROTECTED] writes:
 The problem is that sometimes, depending on which file is the
 shorter, a line ends up missing, appearing neither in the izip()
 output, or in the subsequent direct file iteration.  I would guess
 that it was in izip's buffer when izip terminates due to the
 exception on the other file.

Oh man, this is ugly.  The problem is there's no way to tell whether
an iterator is empty, other than by reading from it.  

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413614

has a kludge that you can use inside a function but that's no good
for something like izip.  

For a temporary hack you could make a wrapped iterator that allows
pushing items back onto the iterator (sort of like ungetc) and a
version of izip that uses it, or a version of izip that tests the
iterators you pass it using the above recipe.

It's probably not reasonable to ask that an emptiness test be added to
the iterator interface, since the zillion iterator implementations now
existing won't support it.  

A different possible long term fix: change StopIteration so that it
takes an optional arg that the program can use to figure out what
happened.  Then change izip so that when one of its iterator args runs
out, it wraps up the remaining ones in a new tuple and passes that
to the StopIteration it raises.  Untested:

   def izip(*iterlist):
  while True:
z = []
finished = []  # iterators that have run out
still_alive = []   # iterators that are still alive
  for i in iterlist:
 try:
z.append(i.next())
still_alive.append(i)
 except StopIteration:
finished.append(i)
  if not finished:
 yield tuple(z)
  else:  
 raise StopIteration, (still_alive, finished)

You would want some kind of extended for-loop syntax (maybe involving
the new with statement) with a clean way to capture the exception info.
You'd then use it to continue the izip where it left off, with the
new (smaller) list of iterators.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Productivity and Quality of IDE

2006-01-03 Thread James
It depends on a number of factors including yourself. I am a very
visual person. I consider visual design as the native language of
expression and representation (at least from a human stand point) for
objects that have visual end presentation. I know I am productive this
way. Your mileage may wary on how you prefer to think.

It also depends on how good the tool chain is designed. Delphi, Visual
Studio.NET, Dreamweaver for example are a sheer pleasure for me to
design interfaces with. In my Delphi days, I used to feel that thhe IDE
was critical to my productivity. But the old VB6 and FrontPage and even
recent Java IDEs get in my way often. I tend to think most people find
seamless integration more productive. If you are an outlier, good for
you.

As for simple language IDEs, some languages benefit more than others.
Even though I like more integrated solutions like PyDev, SPE etc and
have a long history of IDE usage, I keep coming back to SciTE when it
comes to Python. But I would not dream using Java/C# without an IDE.

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


Re: Python or Java or maybe PHP?

2006-01-03 Thread James
While on topic of custom contructs, the topic of syntactic macros has
come up in the past. Does anyone know if the dev team ever considered
for or against them? My interest in them was renewed when I came across
Logix
http://www.livelogix.net/logix/
It does not seem very active at the moment nor do they see Python as a
long tem platform for their project. Although it already seemed usable
in the little programs I tested it with.

I keep asking myself why isn't this more popular especially when many
prominent Python devs seem to be well aware of Lisp where macros are
done right. But then again, Gosling's great Lisp prowess did not seem
to transfer into Java at all :-). Won't macros and type inference make
Python a Lisp with a syntax that I can stand and libraries that I could
use :-) ? Unfortunately there doesn't seem to be a peep from Mike Salib
on StarKiller either. Did he move on to other pursuits?

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


Re: itertools.izip brokeness

2006-01-03 Thread bonono
But that is exactly the behaviour of python iterator, I don't see what
is broken.

izip/zip just read from the respectives streams and give back a tuple,
if it can get one from each, otherwise stop. And because python
iterator can only go in one direction, those consumed do lose in the
zip/izip calls.

I think you need to use map(None,...) which would not drop anything,
just None filled. Though you don't have a relatively lazy version as
imap(None,...) doesn't behave like map but a bit like zip.

[EMAIL PROTECTED] wrote:
 The code below should be pretty self-explanatory.
 I want to read two files in parallel, so that I
 can print corresponding lines from each, side by
 side.  itertools.izip() seems the obvious way
 to do this.

 izip() will stop interating when it reaches the
 end of the shortest file.  I don't know how to
 tell which file was exhausted so I just try printing
 them both.  The exhausted one will generate a
 StopInteration, the other will continue to be
 iterable.

 The problem is that sometimes, depending on which
 file is the shorter, a line ends up missing,
 appearing neither in the izip() output, or in
 the subsequent direct file iteration.  I would
 guess that it was in izip's buffer when izip
 terminates due to the exception on the other file.

 This behavior seems plain out broken, especially
 because it is dependent on order of izip's
 arguments, and not documented anywhere I saw.
 It makes using izip() for iterating files in
 parallel essentially useless (unless you are
 lucky enough to have files of the same length).

 Also, it seems to me that this is likely a problem
 with any iterables with different lengths.
 I am hoping I am missing something...

 #-
 # Task: print contents of file1 in column 1, and
 # contents of file2 in column two.  iterators and
 # izip() are the obvious way to do it.

 from itertools import izip
 import cStringIO, pdb

 def prt_files (file1, file2):

 for line1, line2 in izip (file1, file2):
 print line1.rstrip(), \t, line2.rstrip()

 try:
 for line1 in file1:
 print line1,
 except StopIteration: pass

 try:
 for line2 in file2:
 print \t,line2,
 except StopIteration: pass

 if __name__ == __main__:
 # Use StringIO to simulate files.  Real files
 # show the same behavior.
 f = cStringIO.StringIO

 print Two files with same number of lines work ok.
 prt_files (f(abc\nde\nfgh\n), f(xyz\nwv\nstu\n))

 print \nFirst file shorter is also ok.
 prt_files (f(abc\nde\n), f(xyz\nwv\nstu\n))

 print \nSecond file shorter is a problem.
 prt_files (f(abc\nde\nfgh\n), f(xyz\nwv\n))
 print What happened to \fgh\ line that should be in column
 1?

 print \nBut only a problem for one line.
 prt_files (f(abc\nde\nfgh\nijk\nlm\n), f(xyz\nwv\n))
 print The line \fgh\ is still missing, but following\n \
 line(s) are ok!  Looks like izip() ate a line.

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


Re: Regex anomaly

2006-01-03 Thread Andrew Durdin
On 3 Jan 2006 02:20:52 -0800, Sam Pointon [EMAIL PROTECTED] wrote:
 Would this particular inconsistency be candidate for change in Py3k?
 Seems to me the pos and endpos arguments are redundant with slicing,

Being able to specify the start and end indices for a search is
important when working with very large strings (multimegabyte) --
where slicing would create a copy, specifying pos and endpos allows
for memory-efficient searching in limited areas of a string.

 and the re.match function would benefit from having the same arguments
 as pattern.match.

Not at all; the flags need to be specified when the regex is compiled,
as they affect the compiled representation (finite state automaton I
expect) of the regex. If the flags were given in pattern.match(), then
there'd be no performance benefit gained from precompiling the regex.

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


Re: itertools.izip brokeness

2006-01-03 Thread David Murmann
[EMAIL PROTECTED] schrieb:
 [izip() eats one line]

as far as i can see the current implementation cannot be changed
to do the Right Thing in your case. pythons iterators don't allow
to look ahead, so izip can only get the next element. if this
fails for an iterator, everything up to that point is lost.

maybe the documentation for izip should note that the given
iterators are not necessarily in a sane state afterwards.

for your problem you can do something like:

def izipall(*args):
iters = [iter(it) for it in args]
while iters:
result = []
for it in iters:
try:
x = it.next()
except StopIteration:
iters.remove(it)
else:
result.append(x)
yield tuple(result)

note that this does not yield tuples that are always the same
length, so for x, y in izipall() won't work. instead, do something
like for seq in izipall(): print '\t'.join(seq).

hope i was clear enough, David.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: itertools.izip brokeness

2006-01-03 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 The problem is that sometimes, depending on which
 file is the shorter, a line ends up missing,
 appearing neither in the izip() output, or in
 the subsequent direct file iteration.  I would
 guess that it was in izip's buffer when izip
 terminates due to the exception on the other file.

With the current iterator protocol you cannot feed an item that you've read
from an iterator by calling its next() method back into it; but invoking
next() is the only way to see whether the iterator is exhausted. Therefore
the behaviour that breaks your prt_files() function has nothing to do with
the itertools. 
I think of itertools more as of a toolbox instead of a set of ready-made
solutions and came up with

from itertools import izip, chain, repeat

def prt_files (file1, file2):
file1 = chain(file1, repeat())
file2 = chain(file2, repeat())
for line1, line2 in iter(izip(file1, file2).next, (, )):
print line1.rstrip(), \t, line2.rstrip()
 
which can easily be generalized for an arbitrary number of files.

Peter

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


Re: compare dictionary values

2006-01-03 Thread Tim Williams (gmail)
On 30/12/05, rbt [EMAIL PROTECTED] wrote:
What's a good way to compare values in dictionaries? I want to find[snip]My key-values pairs are filepaths and their modify times. I want toidentify files that have been updated or added since the script last ran.

You don't need to store each file's updated time, you only need to
store the last time you ran the script and to compare each file's
modified time against that last-run time. Dictionaries
aren't required

eg:

# to get files changed (added/modified) since a given date
import time, os
last_run = time.time() - (60*60*24*30*12) # for testing, set to one year ago
changed = [x for x in os.listdir('c:/python24') if os.path.getmtime(os.path.join('c:/python24' , x))  last_run]
# script end

>From your previous posts, I believe you are storing details of *every*
file within a dictionary that is pickled to your hard disk,
then periodically creating a new dict of *every* file and
comparing it against the original dict. Then you must be
updating the original dict with the new times and storing it back to
disk. The above list comprehension will give the same
result for files/dirs in a single directory, you just need to
store the time of the last script run to disk instead.

if you are walking several directories, the principle is the same,

 last_run = time.time() - (60*60*24*30) # 1 month ago
 for root, dirs, files in os.walk('c:/python24'):
...  for name in files:
...   if os.path.getmtime(os.path.join(root , name))  last_run:
...print os.path.join(root , name)
...
c:/python24\Lib\asynchat.pyc
c:/python24\Lib\calendar.pyc
c:/python24\Lib\gzip.pyc
c:/python24\Lib\imghdr.pyc
c:/python24\Lib\SimpleHTTPServer.pyc
c:/python24\Lib\sndhdr.pyc
c:/python24\Lib\webbrowser.pyc
c:/python24\Lib\_strptime.pyc
c:/python24\Lib\email\MIMEAudio.pyc
c:/python24\Lib\email\MIMEImage.pyc
c:/python24\Lib\email\MIMEMessage.pyc
c:/python24\Lib\email\MIMEMultipart.pyc





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

Re: itertools.izip brokeness

2006-01-03 Thread Paul Rubin
[EMAIL PROTECTED] writes:
 But that is exactly the behaviour of python iterator, I don't see what
 is broken.

What's broken is the iterator interface is insufficient to deal with
this cleanly.

 And because python iterator can only go in one direction, those
 consumed do lose in the zip/izip calls.

Yes, that's the problem.  It's proven useful for i/o streams to support
a pushback operation like ungetc.  Maybe something like it can be done
for iterators.

 I think you need to use map(None,...) which would not drop anything,
 just None filled. Though you don't have a relatively lazy version as
 imap(None,...) doesn't behave like map but a bit like zip.

I don't understand what you mean by this?  None is not callable.

How about this (untested):

  def myzip(iterlist):
return zip of smaller and smaller list of iterables as the
individual iterators run out
sentinel = object()  # unique sentinel
def sentinel_append(iterable):
   return itertools.chain(iterable, itertools.repeat(sentinel))
for i in itertools.izip(map(sentinel_append, iterlist)):
   r = [x for x in i.next() if x is not sentinel]
   if r: yield r
   else: break
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: itertools.izip brokeness

2006-01-03 Thread bonono

Paul Rubin wrote:
  I think you need to use map(None,...) which would not drop anything,
  just None filled. Though you don't have a relatively lazy version as
  imap(None,...) doesn't behave like map but a bit like zip.

 I don't understand what you mean by this?  None is not callable.

zip([1,2,3],[4,5])  gives [(1,4),(2,5)]

map(None,[1,2,3],[4,5]) gives [(1,4),(2,5),(3,None)]

So the result of map() can be filtered out for special processing. Of
course, your empty/sentinel filled version is doing more or less the
same thing.


 How about this (untested):

   def myzip(iterlist):
 return zip of smaller and smaller list of iterables as the
 individual iterators run out
 sentinel = object()  # unique sentinel
 def sentinel_append(iterable):
return itertools.chain(iterable, itertools.repeat(sentinel))
 for i in itertools.izip(map(sentinel_append, iterlist)):
r = [x for x in i.next() if x is not sentinel]
if r: yield r
else: break

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


Re: itertools.izip brokeness

2006-01-03 Thread Paul Rubin
[EMAIL PROTECTED] writes:
 map(None,[1,2,3],[4,5]) gives [(1,4),(2,5),(3,None)]

I didn't know that until checking the docs just now.  Oh man, what a
hack!  I always thought Python should have a built-in identity
function for situations like that.  I guess it does the above instead.
Thanks.  Jeez ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP: method overriding works in mysterious ways?

2006-01-03 Thread Christophe
John M. Gabriele a écrit :
 Consider the following:
 
 #!/usr/bin/python
 
 #-
 class Grand_parent( object ):
 
 def speak( self ):
 print 'Grand_parent.speak()'
 self.advise()
 
 def advise( self ):
 print 'Grand_parent.advise()'
 self.critique()
 
 def critique( self ):
 print 'Grand_parent.critique()'
 
 
 #-
 class Parent( Grand_parent ):
 
 def speak( self ):
 print '\tParent.speak()'
 self.advise()
 
 def advise( self ):
 print '\tParent.advise()'
 self.critique()
 
 # ATM, the Parent is at a loss for words, and has no critique.
 
 
 #-
 class Child( Parent ):
 
 def speak( self ):
 print '\t\tChild.speak()'
 self.advise()
 
 # Currently, the Child has no really useful advice to give.
 
 def critique( self ):
 print '\t\tChild.critique()'
 
 
 #-
 print 'speak() calls advise(), then advise() calls critique().'
 print
 
 people = [ Grand_parent(), Parent(), Child() ]
 for person in people:
 person.speak()
 print
 
 
 
 
 The output is:
 
 speak() calls advise(), then advise() calls critique().
 
 Grand_parent.speak()
 Grand_parent.advise()
 Grand_parent.critique()
 
 Parent.speak()
 Parent.advise()
 Grand_parent.critique()
 
 Child.speak()
 Parent.advise()
 Child.critique()
 
 
 What's going on here with that last Child.critique()? The
 Parent called self.critique(), and since it *had* no critique()
 method, it should've deferred to it's parent's critique()
 method, right? But instead, somehow Child.critique() got called.
 Why?
 
 ---J
 
Because that's the way virtual methods are supposed to work. When you 
can a methon foo on an object, you always start your search from the 
current object class and not the class of the current function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: itertools.izip brokeness

2006-01-03 Thread bonono

Paul Rubin wrote:
 [EMAIL PROTECTED] writes:
  map(None,[1,2,3],[4,5]) gives [(1,4),(2,5),(3,None)]

 I didn't know that until checking the docs just now.  Oh man, what a
 hack!  I always thought Python should have a built-in identity
 function for situations like that.  I guess it does the above instead.
 Thanks.  Jeez ;-)
Of course, for OP's particular case, I think a specialized func() is
even better, as the None are turned into  in the process which is
needed for string operation.

map(lambda *arg: tuple(map(lambda x: x is not None and x or , arg)),
[a,b,c],[d,e])

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


Re: WMI - invalid syntax error?

2006-01-03 Thread py
The problem only seems to occur when importing the file and using it
that way.  It works the first time, but not the second, third, etc.  If
I run the same commands via the interpreter I have no problem.

I may end up looking into some other way of getting the list of
processesthis is real screwy.

I am going to try typing up that simple function into a new py file and
put it on a diff. PC and try it.  I tried my current code on another
computer and had the same issue...but I am wondering if I start anew if
it will help.

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


Re: Distributions, RE-verb and the like

2006-01-03 Thread bearophileHUGS
Paul McGuire wrote:

 I don't find 'Interval' to be very easy on the eyes.  In this case, I
 stole^H^H^H^H^H borrowed the re form of [A-Za-z0-9], providing a
 method named srange (s is for string) such that srange(a-fA-F)
 would return the string abcdefABCDEF.

Thank you for your answers Paul. Just a note: I have called it
interval-something (like cinterval or Interval) instead of
range-something because it returns a closed interval (all letters
inclusive of both endpoints), to show its difference from the Python
range that returns a right open interval. Calling a srange(a,z) in
Python lets me think that it generates the [a,...,y] range.

Bye,
bearophile

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


Re: Tkinter Scrollbar not working

2006-01-03 Thread Dustan

Martin Franklin wrote:
 Dustan wrote:
  I'm trying to get a scrollbar bound with a Frame, and I keep on getting
  a scrollbar, but it doesn't actually scroll. Some help, please?
 

 It can be tricky getting an empty frame to scroll, can you post your
 example code so that we might be more helpful.  Here is an example of
 binding a scroll bar to a Text widget (not exactly the same thing)


It's not an empty frame. It has a label. I was trying to do it with
just the label, but it didn't work, and I figured it might be a better
idea to try doing it with a frame instead.


 ## import all names from Tkinter
 ## bit naughty but I don't mind
 from Tkinter import *


 # root window
 root=Tk()


 # text area
 text=Text()
 text.pack(side=left, expand=yes, fill=both)

 # scrolbar for above textarea
 sb = Scrollbar(root)
 sb.pack(side=right, fill=y)



 ## bind them both together...

 # this line binds the yscrollcommand
 # of the text area to the scrollbar set method
 text['yscrollcommand'] = sb.set

 # this line binds the scrollbars command to
 # the yview method of the text area
 sb['command'] = text.yview



 # mainloop entry
 root.mainloop()

That doesn't help. I need to be able to do it either with a frame (has
content!) or a Text widget.

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


Re: Tkinter Scrollbar not working

2006-01-03 Thread Dustan
Label Widget, sorry

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


regular expression or parser ?

2006-01-03 Thread Forced_Ambitions
Hi,

I m a novice to python..I m stuck in a problem and need some help.

i m trying to extract data  between the line start operation and the
line stop operation
from a txt file. and then to fill it under different columns of an
excel sheet.

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


Re: regular expression or parser ?

2006-01-03 Thread Kent Johnson
Forced_Ambitions wrote:
 Hi,
 
 I m a novice to python..I m stuck in a problem and need some help.
 
 i m trying to extract data  between the line start operation and the
 line stop operation
 from a txt file. and then to fill it under different columns of an
 excel sheet.
 

A simple stateful loop may be enough for the parsing part. Something 
like this:

f= open('data.txt')

try:
   while True:
 # Skip to the next start
 while f.next().strip() != 'start operation':
   continue

 # process lines
 while True:
   line = f.next().strip()
   if line == 'stop operation':
 break
   # process line

except StopIteration:
   pass


If you only have one block to process and you are confident it will 
always be present then the try / except and outer while loop are not needed.

If you can live with CSV output instead of XLS then see the csv module 
for the processing part.

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


Red Hat Enterprise Edition and Python 2.4 sources

2006-01-03 Thread Kai Strempel
Hello Python Folks,

I have a big problem with the red hat enterprise server. The 2.4 sources
build without any big problem. But after installation I can't import
datetime. I didn't understand how that can be happend. Datetime is a build
in package since python 2.3. 

Can anybody give me some tips how to install the 2.4 sources perfectly that
everything is running on a red hat enterprise system??

Best regards

Kai Strempel

-- 
DSL-Aktion wegen großer Nachfrage bis 28.2.2006 verlängert:
GMX DSL-Flatrate 1 Jahr kostenlos* http://www.gmx.net/de/go/dsl
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: itertools.izip brokeness

2006-01-03 Thread Diez B. Roggisch
 What's broken is the iterator interface is insufficient to deal with
 this cleanly.

I don't consider it broken. You just think too much in terms of the OPs
problems or probably other fields where the actual data is available for
rewinding.

But as iterators serve as abstraction for lots of things - especially
generatiors - you can't enhance the interface.

 
 Yes, that's the problem.  It's proven useful for i/o streams to support
 a pushback operation like ungetc.  Maybe something like it can be done
 for iterators.

No. If you want that, use

list(iterable)

Then you have random access. If you _know_ there will be only so much data
needed to unget, write yourself a buffered iterator like this:

buffered(iterable, size)

Maybe something like that _could_ go in the itertools. But I'm not really
convinced, as it is too tied to special cases - and besides that very
easily done.


 How about this (untested):
 
   def myzip(iterlist):
 return zip of smaller and smaller list of iterables as the
 individual iterators run out
 sentinel = object()  # unique sentinel
 def sentinel_append(iterable):
return itertools.chain(iterable, itertools.repeat(sentinel))
 for i in itertools.izip(map(sentinel_append, iterlist)):
r = [x for x in i.next() if x is not sentinel]
if r: yield r
else: break

If that fits your semantics - of course. But the general zip shouldn't
behave that way.

Regards,

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


Re: Python or Java or maybe PHP?

2006-01-03 Thread Aahz
In article [EMAIL PROTECTED],
James [EMAIL PROTECTED] wrote:

I keep asking myself why isn't this more popular especially when many
prominent Python devs seem to be well aware of Lisp where macros are
done right. 

You have confused many Python devs with Guido.  ;-)  Guido hates
macros.  Oddly enough, my impression is that macros are popular only in
the Lisp community, and they may well be part of the reason Lisp has
never become popular.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Given that C++ has pointers and typecasts, it's really hard to have a
serious conversation about type safety with a C++ programmer and keep a
straight face.  It's kind of like having a guy who juggles chainsaws
wearing body armor arguing with a guy who juggles rubber chickens wearing
a T-shirt about who's in more danger.  --Roy Smith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter Scrollbar not working

2006-01-03 Thread Martin Franklin
Dustan wrote:
 Martin Franklin wrote:
 
Dustan wrote:

I'm trying to get a scrollbar bound with a Frame, and I keep on getting
a scrollbar, but it doesn't actually scroll. Some help, please?


It can be tricky getting an empty frame to scroll, can you post your
example code so that we might be more helpful.  Here is an example of
binding a scroll bar to a Text widget (not exactly the same thing)

 
 
 It's not an empty frame. It has a label. I was trying to do it with
 just the label, but it didn't work, and I figured it might be a better
 idea to try doing it with a frame instead.
 
 
## import all names from Tkinter
## bit naughty but I don't mind
from Tkinter import *


# root window
root=Tk()


# text area
text=Text()
text.pack(side=left, expand=yes, fill=both)

# scrolbar for above textarea
sb = Scrollbar(root)
sb.pack(side=right, fill=y)



## bind them both together...

# this line binds the yscrollcommand
# of the text area to the scrollbar set method
text['yscrollcommand'] = sb.set

# this line binds the scrollbars command to
# the yview method of the text area
sb['command'] = text.yview



# mainloop entry
root.mainloop()
 
 
 That doesn't help. I need to be able to do it either with a frame (has
 content!) or a Text widget.
 

Perhaps I am not understanding something... can you please show me an 
example of what is not working. I consider the above a good recipe that
can be applied to any scrollable widget in Tkinter.

hmm, a single change to my example (Text to Frame) produces this
traceback:-


 C:/python24/python -u quicksb.py
Traceback (most recent call last):
   File quicksb.py, line 17, in ?
 text['yscrollcommand'] = sb.set
   File C:\python24\lib\lib-tk\Tkinter.py, line 1146, in __setitem__
 self.configure({key: value})
   File C:\python24\lib\lib-tk\Tkinter.py, line 1139, in configure
 return self._configure('configure', cnf, kw)
   File C:\python24\lib\lib-tk\Tkinter.py, line 1130, in _configure
 self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option -yscrollcommand
 Exit code: 1

and another change (Frame to Label) produces this traceback:-


 C:/python24/python -u quicksb.py
Traceback (most recent call last):
   File quicksb.py, line 17, in ?
 text['yscrollcommand'] = sb.set
   File C:\python24\lib\lib-tk\Tkinter.py, line 1146, in __setitem__
 self.configure({key: value})
   File C:\python24\lib\lib-tk\Tkinter.py, line 1139, in configure
 return self._configure('configure', cnf, kw)
   File C:\python24\lib\lib-tk\Tkinter.py, line 1130, in _configure
 self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option -yscrollcommand
 Exit code: 1


This would suggest that the Frame and Label widgets are not scrollable
(at least not in the 'y' direction)


Cheers
Martin

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


Re: itertools.izip brokeness

2006-01-03 Thread Paul Rubin
Diez B. Roggisch [EMAIL PROTECTED] writes:
 No. If you want that, use
 
 list(iterable)
 
 Then you have random access. If you _know_ there will be only so much data
 needed to unget, write yourself a buffered iterator like this:

You can't use list(iterable) in general because the iterable may be
infinite.

 buffered(iterable, size)
 
 Maybe something like that _could_ go in the itertools. But I'm not really
 convinced, as it is too tied to special cases -

The usual pushback depth needed is just one item and it would solve
various situations like this.  The ASPN recipe I cited for detecting
an empty iterable shows that such problems come up in more than one
place.

Note that besides the buffered iterable, there would also have to be a
version of izip that pushed unused items back onto its iterables.

 and besides that very easily done.

Just about everything in itertools is very easily done, so that's not
a valid argument against it.  

  How about this (untested):
  
def myzip(iterlist):
  return zip of smaller and smaller list of iterables as the
  individual iterators run out
 
 If that fits your semantics - of course. But the general zip shouldn't
 behave that way.

Of course it shouldn't.  In another post I suggested a way to extend
the general izip, to throw a list of the remaining non-empty iterables
once it hit an empty one.  Maybe there's some problem with that too,
but if so, it's more subtle.

Any idea how Haskell would deal with this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regex anomaly

2006-01-03 Thread Roy Smith
In article [EMAIL PROTECTED],
 Sam Pointon [EMAIL PROTECTED] wrote:

 Would this particular inconsistency be candidate for change in Py3k?
 Seems to me the pos and endpos arguments are redundant with slicing,
 and the re.match function would benefit from having the same arguments
 as pattern.match. Of course, this is a backwards-incompatible change;
 that's why I suggested Py3k.

I don't see any way to implement re.I at match time; it's something that 
needs to get done at regex compile time.  It's available in the 
module-level match() call, because that one is really compile-then-match().
-- 
http://mail.python.org/mailman/listinfo/python-list


Filename case-insensitivity on OS X

2006-01-03 Thread Tom Anderson
Afternoon all,

MacOS X seems to have some heretical ideas about the value of case in 
paths - it seems to believe that it doesn't exist, more or less, so touch 
foo FOO touches just one file, you can't have both 'makefile' and 
'Makefile' in the same directory, 
os.path.exists(some_valid_path.upper()) returns True even when 
os.path.split(some_valid_path.upper())[1] in 
os.listdir(os.path.split(some_valid_path)[0]) returns False, etc 
(although, of course, ls *.txt doesn't mention any of those .TXT files 
lying around).

Just to prove it, here's what unix (specifically, linux) does:

[EMAIL PROTECTED]:~$ uname
Linux
[EMAIL PROTECTED]:~$ python
Python 2.3.5 (#2, Sep  4 2005, 22:01:42)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type help, copyright, credits or license for more information.
 import os
 filenames = os.listdir(.)
 first = filenames[0]
 first in filenames
True
 first.upper() in filenames
False
 os.path.exists(os.path.join(., first))
True
 os.path.exists(os.path.join(., first.upper()))
False


And here's what OS X does:

Hooke:~ tom$ uname
Darwin
Hooke:~ tom$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type help, copyright, credits or license for more information.
 import os
 filenames = os.listdir(.)
 first = filenames[0]
 first in filenames
True
 first.upper() in filenames
False
 os.path.exists(os.path.join(., first))
True
 os.path.exists(os.path.join(., first.upper()))
True


Sigh. Anyone got any bright ideas for working around this, specifically 
for os.path.exists? I was hoping there was some os.path.actualpath, so i 
could say:

def exists_dontignorecase(path):
return os.path.exists(path) and (path == os.path.actualpath(path))

Java has a java.io.File.getCanonicalPath method that does this, but i 
can't find an equivalent in python - is there one?

I can emulate it like this:

def _canonicalise(s, l):
s = s.lower()
for t in l:
if s == t.lower():
return t
raise ValueError, (could not canonicalise string, s)

def canonicalpath(path):
if (path in (/, )):
return path
parent, child = os.path.split(path)
cparent = canonicalpath(parent)
cchild = _canonicalise(child, os.listdir(cparent))
return os.path.join(cparent, cchild)

Or, more crudely, do something like this:

def exists_dontignorecase(path):
dir, f = os.path.split(path)
return f in os.listdir(dir)

But better solutions are welcome.

Thanks,
tom

-- 
Infantry err, infantry die. Artillery err, infantry die. -- IDF proverb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: itertools.izip brokeness

2006-01-03 Thread Duncan Booth
Peter Otten wrote:

 from itertools import izip, chain, repeat
 
 def prt_files (file1, file2):
 file1 = chain(file1, repeat())
 file2 = chain(file2, repeat())
 for line1, line2 in iter(izip(file1, file2).next, (, )):
 print line1.rstrip(), \t, line2.rstrip()
  
 which can easily be generalized for an arbitrary number of files.

Generalizing for an arbitrary number of files and for an arbitrary value to 
pad out the shorter sequences:

def paddedizip(pad, *args):
terminator = [pad] * (len(args)-1)
def padder():
if not terminator:
return
t = terminator.pop()
while 1:
yield t
return izip(*(chain(a, padder()) for a in args))

 for (p,q) in paddedizip(0,[1,2,3],[4,5]):
print repr(p), repr(q)


1 4
2 5
3 0
 for (p,q) in paddedizip(0,[1,2,3],[4,5,6,7,8]):
print repr(p), repr(q)


1 4
2 5
3 6
0 7
0 8
 for (p,q) in paddedizip(,[1,2,3],[4,5,6,7,8]):
print repr(p), repr(q)


1 4
2 5
3 6
'' 7
'' 8
 for (p,q,r) in paddedizip(None,[1,2,3],[4,5,6,7,8],[9]):
print repr(p), repr(q), repr(r)


1 4 9
2 5 None
3 6 None
None 7 None
None 8 None
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spiritual Programming (OT, but Python-inspired)

2006-01-03 Thread Tom Anderson
On Mon, 2 Jan 2006 [EMAIL PROTECTED] wrote:

 In this sense, we are like the ghost in the machine of a computer
 system running a computer program, or programs, written in a procedural
 language and style.

Makes sense - i heard that Steve Russell invented continuations after 
reading the Tibetan Book of the Dead.

tom

-- 
Chance? Or sinister scientific conspiracy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OOP: method overriding works in mysterious ways?

2006-01-03 Thread Chris Mellon
On 1/2/06, Mike Meyer [EMAIL PROTECTED] wrote:
 John M. Gabriele [EMAIL PROTECTED] writes:

  Consider the following:
 
  #!/usr/bin/python
 
  #-
  class Grand_parent( object ):
 
   def speak( self ):
   print 'Grand_parent.speak()'
   self.advise()
 
   def advise( self ):
   print 'Grand_parent.advise()'
   self.critique()
 
   def critique( self ):
   print 'Grand_parent.critique()'
 
 
  #-
  class Parent( Grand_parent ):
 
   def speak( self ):
   print '\tParent.speak()'
   self.advise()
 
   def advise( self ):
   print '\tParent.advise()'
   self.critique()
 
   # ATM, the Parent is at a loss for words, and has no critique.
 
 
  #-
  class Child( Parent ):
 
   def speak( self ):
   print '\t\tChild.speak()'
   self.advise()
 
   # Currently, the Child has no really useful advice to give.
 
   def critique( self ):
   print '\t\tChild.critique()'
 
 
  #-
  print 'speak() calls advise(), then advise() calls critique().'
  print
 
  people = [ Grand_parent(), Parent(), Child() ]
  for person in people:
   person.speak()
   print
 
 
 
  
  The output is:
 
  speak() calls advise(), then advise() calls critique().
 
  Grand_parent.speak()
  Grand_parent.advise()
  Grand_parent.critique()
 
   Parent.speak()
   Parent.advise()
  Grand_parent.critique()
 
   Child.speak()
   Parent.advise()
   Child.critique()
 
 
  What's going on here with that last Child.critique()? The
  Parent called self.critique(), and since it *had* no critique()
  method, it should've deferred to it's parent's critique()
  method, right? But instead, somehow Child.critique() got called.
  Why?

 Because that's the way Python searchs for object attributes. Nobody
 made it explicit, so I will. This is simplified, ignoring various
 complications:

 When looking up a value for self.foo, you first look for
 attribute foo of self. You then check the class of self for
 attribute foo. You then check the parent class of the last
 class you checked for attribute foo. You repeat that last step
 until there is no parent class.

 Like I said, that's simplified. But it's sufficent to explain what
 you're seeing.

If your interested in the non-simplified complicated rules for exactly
how methods are looked up (only different than the simple case when
you get into multiple inheritence), see
http://www.python.org/2.3/mro.html


mike
 --
 Mike Meyer [EMAIL PROTECTED]  
 http://www.mired.org/home/mwm/
 Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: itertools.izip brokeness

2006-01-03 Thread bonono

Paul Rubin wrote:
 Any idea how Haskell would deal with this?
I don't recall haskell has the map(None,...) behaviour in the standard
Prelude. But then, I don't see how the iterator concept would fit into
haskell as well.

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


New to Python, WxPython etc, etc

2006-01-03 Thread rodmc
I am totally new to Python and WxPython and need to write an
application which can open up an external windows from a plug-in within
GAIM (using pyGAIM). I have managed to hack some code together from
what little I have covered so far, however GAIM refuses to open until I
have closed the extra window. I appreciate this is probably a simple
point but I would be grateful for any advice people can offer on how I
can make them both appear so that people can interact with either GAIM
and/or the contents of the window. I am using Python 2.3.5, and GAIM 2
(beta).

I have attached the hacked code below which is based on a merging some
samples from WxPython and pyGaim. I have tried moving the  bit below to
within  def plug_in load but to no avail.

app = MyApp(0)
app.MainLoop()

Thanks in advance,

Rod




import _gaim
import wx

from wxPython.wx import *

ID_ABOUT = 101
ID_EXIT  = 102

class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
 wxDefaultPosition, wxSize(200, 150))

self.CreateStatusBar()
self.SetStatusText(This is the statusbar)
menu = wxMenu()
menu.Append(ID_ABOUT, About,
More information about this program)
menu.AppendSeparator()
menu.Append(ID_EXIT, Exit, Terminate the program)
menuBar = wxMenuBar()
menuBar.Append(menu, File);
self.SetMenuBar(menuBar)

EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT,  self.TimeToQuit)

def OnAbout(self, event):
dlg = wxMessageDialog(self, This sample program shows off\n
  frames, menus, statusbars, and this\n
  message dialog.,
  About Me, wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()


def TimeToQuit(self, event):
self.Close(true)



class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, Hello from wxPython)
frame.Show(true)
self.SetTopWindow(frame)
return true


PLUGIN_INFO = {
'python_api_version' : 2,
'name' : A Simple Test Plug-in,
'version'  : 0.3,
'summary'  : This simply does nothing,
'description'  : Cheese,
'author'   : [EMAIL PROTECTED],
'url'  : http://www.xxx.com/;,
'load' : plugin_load,
'unload'   : plugin_unload
}


def timeout0(anObject):
print 'py:timeout0',anObject
return False

def timeout1(anObject):
print 'py:timeout1',anObject
##return True
return False

def signed_on_cb1(data,account,conv,msgText):
print 'p2:signed_on_cb1'
print 'Data',data
print 'account',account
print 'conversation',conv
print 'msgText',msgText
print 'account.gc',account.gc

blist = gaim.gaim_get_blist()
print blist.root

print conv.name,conv.title,conv.history

buddy = gaim.gaim_find_buddy(account,conv.name)
print buddy,buddy.name,buddy.alias

group = gaim.gaim_find_buddys_group(buddy)
print group,group.name,group.totalsize

return {'r':True,'a3':'this is my text:'+msgText}

def menu_item_activate_cb(node,data):
pass

def blist_node_extended_menu_cb(data,node,menu):
print 'node',node
print 'menu',menu

##  if (!GAIM_BLIST_NODE_IS_BUDDY(node))
##  return;

##  buddy = (GaimBuddy *)node;
##act = gaim.gaim_blist_node_action_new(Send message,
##  menu_item_activate_cb,None)
##print act
##*menu = g_list_append(*menu,act);

def plugin_load(plugin):

print 'py:plugin_load'
accs = gaim.gaim_accounts_get_all()
print accs
for account in accs:
print account
if account:
print account.username,account.alias
print 'New:',gaim._GaimAccount()
gaim.gaim_python_timeout_add(plugin,2000,timeout0,this is timeout
0)
gaim.gaim_python_timeout_add(plugin,1000,timeout1,this is timeout
1)

handle = gaim.gaim_conversations_get_handle()
gaim.gaim_python_signal_connect(plugin,handle,writing-im-msg,
signed_on_cb1,abc)


gaim.gaim_python_signal_connect(plugin,gaim.gaim_blist_get_handle(),
blist-node-extended-menu,
blist_node_extended_menu_cb,None);
print 'py:after plugin load'

def plugin_unload(plugin):
print 'py:plugin_unload'

app = MyApp(0)
app.MainLoop()

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


Re: Python or Java or maybe PHP?

2006-01-03 Thread James
Guido's concerns about preserving simplicity resonate well with me.
Maybe I am just a kid excited with his new toy. I have always admired
macros. Quite a few functional languages have them now. But they have
always been in languages with sub-optimal community code base, which
meant I never went too deep into any of those languages. So I never
used any macro supported language for long to have strong opinions
about any one implementation.

However, Logix's implementation looks rather interesting. By creating
sub languages that are close to but isolated from Python, it does not
really mess with the existing language but creates nice oppurtunities
to encapsulate boiler-plate code structures when the need arises.

I would not necessarily expect such functionality to be in the standard
distribution but language oriented programming could just be another
jewel in Python's multi-paradigm crown and set it distinctly apart from
competitors like Ruby.

Do you have any specific comments towards Logix's implementation?

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


Re: Filename case-insensitivity on OS X

2006-01-03 Thread Scott David Daniels
Tom Anderson wrote:
 Java has a java.io.File.getCanonicalPath method that does this, but i 
 can't find an equivalent in python - is there one?

What's wrong with: os.path.normcase(path) ?

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Visualisation Engine for Python

2006-01-03 Thread rodmc
I am looking for a 2D data visualisation or graphics library for
Python. Can anyone point me in the right direction?


Thanks in advance,

rod

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


Re: python concurrency proposal

2006-01-03 Thread Cameron Laird
In article [EMAIL PROTECTED],
Peter Tillotson  [EMAIL PROTECTED] wrote:
I'd really like to see a concurrency system come into python based on 
theories such as Communicating Sequential Processes (CSP) or its 
derivatives lambda or pi calculus. These provide an analytic framework 
for developing multi thread / process apps. CSP like concurrency is one 
of the hidden gems in the Java Tiger release (java.util.concurrency). 
The advantages of the analytic framework is that they minimise livelock, 
deadlock and facilitate debugging.

I'm no expert on the theory but i've developed under these frameworks 
and found them a more reliable way of developing distributed agent systems.

You may also be interested in looking at 
http://sourceforge.net/projects/pympi
.
.
.
Yes.  Parallelism certainly deserves attention, and I believe
amateurs are likely to help in the breakthroughs to come.  I
further suspect, though, that they'll be amateurs who benefit
from knowledge of existing research into the range of documented
concurrency concepts, including CSPs, tasks, guarded methods, 
microthreads, weightless threads, chords, co-routines, and so on.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter Scrollbar not working

2006-01-03 Thread Cameron Laird
In article [EMAIL PROTECTED],
Dustan [EMAIL PROTECTED] wrote:
BTW, experience tells me it is necessary for me to explicitly state
that I'm a newbie (otherwise I get rude people saying I should already
know such-and-such).


That experience generalize poorly to comp.lang.python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Getting the encoding of sys.stdout and sys.stdin, and changing it properly

2006-01-03 Thread velle
My headache is growing while playing arround with unicode in Python,
please help this novice. I have chosen to divide my problem into a few
questions.

Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2

1)
Does  print 'hello'  simply write to sys.stdout?

2)
Exactly what does the following line return?

 sys.stdout.encoding
'ISO-8859-1'

Is it the encoding of the terminal? I think not, because when I change
the encoding in my terminal the result is still the same.

Is it the encoding of the string python hands over to the terminal? I
think not. In the following code i am pretty confident that the second
command changes that, and still sys.stdout.encoding is the same value.

 import sys,codecs
 sys.stdout.encoding
'ISO-8859-1'
 sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
 sys.stdout.encoding
'ISO-8859-1'

Then what?

3)
Does raw_input() come from sys.stdin?

4)
The following script is not working, can you please tell me how to do
it right.

 import codecs,sys
 sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
 sys.stdin = codecs.getreader('utf-8')(sys.stdin)
 x = raw_input('write this unicode letter, Turkish che, unicode 0x00E7\t')
write this unicode letter, Turkish che, unicode 0x00E7  ç
Traceback (most recent call last):
  File stdin, line 1, in ?
  File /usr/lib/python2.3/codecs.py, line 295, in readline
return self.decode(line, self.errors)[0]
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1:
unexpected end of data

When prompted, I simply enter the che with my Turkish keyboard layout.

velle, Denmark

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


[OT] - Requesting Comments for Process Definition and Presentation

2006-01-03 Thread Ilias Lazaridis
comp.lang.python / comp.lang.ruby

-

I would like to ask for feedback on the Process Definition and Presentation.

Essentially this is exactly what I've myself specialized to do.

But I cannot apply the process to my own system.

I ask here, as I have criticized those 2 groups publically - and would 
like to give the possibility to reverse the criticism - again publically.

-

Please simply visit

http//:lazaridis.com

what do you like?

what do you dislike?

are there points that you do not understand?

do you have any suggestions for terminology changes?

do you have any other suggestion (marketing, presentation, etc.)?

-

You can use private email, the anonymous contact-form on the website and 
  of course this medium here (c.l.p / c.l.r).

Your feedback is _very_ important to me.

Greetings!

.

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


Re: itertools.izip brokeness

2006-01-03 Thread Tom Anderson
On Tue, 3 Jan 2006, it was written:

 [EMAIL PROTECTED] writes:

 The problem is that sometimes, depending on which file is the shorter, 
 a line ends up missing, appearing neither in the izip() output, or in 
 the subsequent direct file iteration.  I would guess that it was in 
 izip's buffer when izip terminates due to the exception on the other 
 file.

 A different possible long term fix: change StopIteration so that it
 takes an optional arg that the program can use to figure out what
 happened.  Then change izip so that when one of its iterator args runs
 out, it wraps up the remaining ones in a new tuple and passes that
 to the StopIteration it raises.

+1

I think you also want to send back the items you read out of the iterators 
which are still alive, which otherwise would be lost. Here's a somewhat 
minimalist (but tested!) implementation:

def izip(*iters):
while True:
z = []
try:
for i in iters:
z.append(i.next())
yield tuple(z)
except StopIteration:
raise StopIteration, z

The argument you get back with the exception is z, the list of items read 
before the first empty iterator was encountered; if you still have your 
array iters hanging about, you can find the iterator which stopped with 
iters[len(z)], the ones which are still going with iters[:len(z)], and the 
ones which are in an uncertain state, since they were never tried, with 
iters[(len(z) + 1):]. This code could easily be extended to return more 
information explicitly, of course, but simple, sparse, etc.

 You would want some kind of extended for-loop syntax (maybe involving 
 the new with statement) with a clean way to capture the exception 
 info.

How about for ... except?

for z in izip(a, b):
lovingly_fondle(z)
except StopIteration, leftovers:
angrily_discard(leftovers)

This has the advantage of not giving entirely new meaning to an existing 
keyword. It does, however, afford the somewhat dubious use:

for z in izip(a, b):
lovingly_fondle(z)
except ValueError, leftovers:
pass # execution should almost certainly never get here

Perhaps that form should be taken as meaning:

try:
for z in izip(a, b):
lovingly_fondle(z)
except ValueError, leftovers:
pass # execution could well get here if the fondling goes wrong

Although i think it would be more strictly correct if, more generally, it 
made:

for LOOP_VARIABLE in ITERATOR:
SUITE
except EXCEPTION:
HANDLER

Work like:

try:
while True:
try:
LOOP_VARIABLE = ITERATOR.next()
except EXCEPTION:
raise __StopIteration__, sys.exc_info()
except StopIteration:
break
SUITE
except __StopIteration__, exc_info:
somehow_set_sys_exc_info(exc_info)
HANDLER

As it stands, throwing a StopIteration in the suite inside a for loop 
doesn't terminate the loop - the exception escapes; by analogy, the 
for-except construct shouldn't trap exceptions from the loop body, only 
those raised by the iterator.

tom

-- 
Chance? Or sinister scientific conspiracy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Filename case-insensitivity on OS X

2006-01-03 Thread Doug Schwarz
In article [EMAIL PROTECTED],
 Tom Anderson [EMAIL PROTECTED] wrote:

 Afternoon all,
 
 MacOS X seems to have some heretical ideas about the value of case in 
 paths - it seems to believe that it doesn't exist, more or less, so touch 
 foo FOO touches just one file, you can't have both 'makefile' and 
 'Makefile' in the same directory, 
 os.path.exists(some_valid_path.upper()) returns True even when 
 os.path.split(some_valid_path.upper())[1] in 
 os.listdir(os.path.split(some_valid_path)[0]) returns False, etc 
 (although, of course, ls *.txt doesn't mention any of those .TXT files 
 lying around).


Strictly speaking, it's not OS X, but the HFS file system that is case 
insensitive.  You can use other file systems, such as UNIX File 
System.  Use Disk Utility to create a disk image and then erase it 
(again, using Disk Utility) and put UFS on it.  You'll find that touch 
foo FOO will create two files.

-- 
Doug Schwarz
dmschwarzurgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


gdesklets __import__ problem

2006-01-03 Thread Thomas Dybdahl Ahle
Hi, I'm writing a gdesklets control, that dynamicly uses __import__ and
getattr to get the right classes based on userinput. The problem is, that
my control is somehow being run from somewhere unknown. This means that
__import__ can't find the modules. I tried putting an
os.chdir(~/.gdesklets/Controls/1136298021.06/...) just before the
__import__ call, and that worked, but ofcource isn't very smart in the run.

Is there any way to find out where the control is put on the disk, so that
I can change to the correct folder? Or is there some hack, that allows me
to import the modules without knowing there location?

-- 
Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks of
Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the scripture of this age.

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


Re: indentation preservation/restoration

2006-01-03 Thread Claudio Grondi
[EMAIL PROTECTED] wrote:
 Steven D'Aprano wrote:
 
 
With a little bit of work, this could be expanded to add redundancy for
not just indentation and numeric literals, but also string literals,
keywords, operators, and anything else.
 
 
 When I copy and assign to variable 'post' the reply posted here on
 c.l.p. starting with On Mon, 02 and ending with - \nSteven. and run
 it through the hidden() function below with the indices indicated, I
 can see what you were really thinking.
 
 The point is well taken: one must consider leading space as an
 important part of the code.  This is just one of those things that's so
 easy to shift around, however. You don't have to work very hard with an
 editor's text manipulations to lose it.
 
 That's life. I know.
 /c
 
 ###
 def hidden(t,indx):
 msg=[]
 for i in indx:
 msg.append(t[i])
 return ''.join(msg)
 thought=[40, 47, 51, 106, 179, 180, 181, 182, 395, 396, 399,
 1129, 1143, 1194, 1224, 1225, 1226]
 print hidden(post,thought)
 ###
 

The subject of spaces in Python has been discussed over and over here in 
a manner which reminds sometimes of threads caused by simple trolling.

It is so easy to mix different things into one when not beeing able to 
see clearly what is what. Writing code is one thing, data security is 
another and compression also another thing. From the point of view of 
programming it is a origin of additional efforts required when all the 
aspects are mixed together into a data format which is to be processed. 
It would be much cleaner and easy to understand when staying separate, 
i.e. format first, than a compression scheme for it, than secure storage 
media system.

The conclusion out of it?

 From my point of view adding redundancy already at the level of source 
code is the wrong way to go and not worth to consider.
Such efforts belong to the design of a secure storage media system or 
are covered by usage of a versioning system.

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


Re: Python 2.4.2 gcc 3.4.4 Solaris 8 build issues [solved]

2006-01-03 Thread Holger Joukl
Martin v. Löwis wrote:

 2. We have some stuff in non-standard locations here. To build
 properly, I need to tell this to configure (using CXX, CPPFLAGS,
 LD_LIBRARY_PATH). Unfortunately, none of this  gets communicated to
 the setup.py step with its find_library_file() stuff, so it is also
 necessary to either modify setup.py or add a setup.cfg file.

Why do you say that? If you set CC before invoking configure,
it will get into Makefile, and from there into setup.py.
More generally: setup.py will take everything from Makefile,
so just check whether Makefile looks right.

Hmm, I just got it wrong. I did not see that settings like LDFLAGS are
noticed by distutils.
After quite some tries I can now happily build with
- LD_LIBRARY_PATH set (needed to find libstdc++ during configure step)
- LDFLAGS set to find the lib dirs
- CPPFLAGS set to find the include dirs
Then distutils adds the appropriate -Wl,-R stuff; I don´t even need
LD_RUN_PATH.
Before, I seem to always have left out LDFLAGS.

As for LD_LIBRARY_PATH: If it is set when setup.py is running,
it will certainly apply. However, I really recommend to use
crle(8) instead:

 crle -u -l /opt/sfw/lib

Then, your users will never have to set LD_LIBRARY_PATH
for /opt/sfw/lib.

Nice. I didn´t even know that feature. Reminds me of the possibilty to use
relative RPATHs with $ORIGIN, which is (also) little under-documented. But
then again I´m no compiler wizard.

 Der Inhalt dieser E-Mail ist vertraulich.

So ein Quatsch. Selbst Google hat jetzt eine Kopie dieser Mail:
Wie wahr. Schon mal gegen Windmühlen gekämpft? ;-)

Thanks a lot,
Holger

Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this  e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail.  Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.


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


Re: application and web app technologies

2006-01-03 Thread ccc
Thanks for your post. I see from the tone of the replies that I may
have made a 'huge' mistake in using the ngs for research.

 From your post, it is not clear what these applications do. That may
 hugely influence any advice you can get.

Just about everything. For two cases in point: (1) We have a web
enabled application for faculty members to do things like posts
attencence, print rosters, etc., which is updated four times a day from
the big DB. The big DB uses a product named Datatel, and our webapp
runs on SQL Server. Our Perl script queries Datatel, runs a number of
queries, downloads the data, shakes it a bakes it, and then shoves it
into SQL Server with DTS. This is one of our most important
applications and it is an absolute monster to do manually. (2) We also
run a little app to generate email accounts for new employees, which is
not a big deal unless you happen to be a new employee who doesn't have
an email address. Our applications run the gamut from the large,
critical apps to the convenience ones.

 Never dismiss anything because it 'seems' bad. Your 'seems
 old-fashioned' is someone else's 'proven technology'. You should work on
 objectifying this statement (because I am not a Perl fan, I expect that
 this will be possible).

I *am* a Perl fan, but after having looked at scripts someone else
wrote (who is no longer with us) with a view toward updating them, I
have concluded that a quick and dirty scripting language in someone
else's idiom isn't a very good choice institutionally. Which is why I'm
looking at OO Perl.

 Moreover, you do not tell who will do the maintenance on these systems.

The database people will maintain the programs, and as you can imagine
these skills are quite varied, which is one reason we want to settle on
one technology we can all use.

 If your 'deciding to' does not imply commitment, you have larger
 problems then choosing a technology.

Our 'deciding to' was like this: 'Java seems to be hot, so let's all
use it.' Yes, we may have bigger problems, but we still want to commit
to one technology that will do the job.

 Never trust an advocate who knows nothing about the thing (s)he
 advocates.

I mispoke ... the advocate know a little about Ruby, but none of the
others do, and we don't want to take his word without satisfying
ourselves that what he says is true.

 Why would you? programming languages all have their strengths and
 weaknesses. Good programmers will be able to choose a midway path
 between standardisation on a single language and using the best language
 for every task.

We really have a hodgepodge. We have snippets written in ColdFusion,
Perl, VB6, VB7, a little C, a couple of Java apps, and some other
miscellanous stuff. We don't have any 'programmers' on staff. People
have tended to focus on the problem at hand and have used whatever
language they were familier with. We want to move beyond this, and do
some real SW engineering.

From what I have gathered, our first impulse to use Java was probably
the right one, even though it wasn't really based on any kind of
investigation. I just hate to commit to something that I have doubts
about.

CC

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


Re: IRC sockets and queries

2006-01-03 Thread Thomas Wouters
On Fri, 30 Dec 2005 16:17:01 -0800, Jay wrote:

 LMFAO! those were jokes for my friends. lol.and btw the dccpoper and
 bot and crap were jokes that i made up for my friends on the #python
 channel in freenode... It was a joke.

Yet no one on the channel thought it was funny. It got you kicked and
banned for a while too, but you probably were AFK at the time. Since you
obviously didn't get the message that way, let me try here: stop doing
it, thanks.

-- 
Thomas Wouters [EMAIL PROTECTED]

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

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


Re: [OT] - Requesting Comments for Process Definition and Presentation

2006-01-03 Thread Claudio Grondi
Ilias Lazaridis wrote:
 comp.lang.python / comp.lang.ruby
 
 -
 
 I would like to ask for feedback on the Process Definition and 
 Presentation.
 
 Essentially this is exactly what I've myself specialized to do.
 
 But I cannot apply the process to my own system.
 
 I ask here, as I have criticized those 2 groups publically - and would 
 like to give the possibility to reverse the criticism - again publically.
 
 -
 
 Please simply visit
 
 http//:lazaridis.com
 
 what do you like?
 
 what do you dislike?
 
 are there points that you do not understand?

What is the goal of your posting and the intended purpose of
http://lazaridis.com ???
I can't see anything at this site what would make sense to me.

Claudio

 
 do you have any suggestions for terminology changes?
 
 do you have any other suggestion (marketing, presentation, etc.)?
 
 -
 
 You can use private email, the anonymous contact-form on the website and 
  of course this medium here (c.l.p / c.l.r).
 
 Your feedback is _very_ important to me.
 
 Greetings!
 
 ..
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any wing2.0 users here?

2006-01-03 Thread Cameron Laird
In article [EMAIL PROTECTED],
Alvin A. Delagon [EMAIL PROTECTED] wrote:
.
.
.
A little bit OT, I too have been programming python without a debugger, 
I got used to php's lack of debugger. Thanks again guys!

?!  With NuSphere, Gubed, Komodo, DBG, APD, PhpED, Zend Studio,
..., in what sense does PHP lack a debugger?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Alex Martelli
Ilias Lazaridis [EMAIL PROTECTED] wrote:
   ...
 Ok, thus Google is flexible in this.
 
 [sidenote: some jobs _require_ a degree by law]

Or some even more stringent qualification, such as the state's Bar exam
for lawyers -- you may not be able to sit for that exam w/o the
appropriate degree, but the degree by itself is not enough, you still
have to pass the exam.  It is that way for Engineers in Italy (I passed
my State Exam in the early '80s), although you only need the certificate
for some specific professional undertakings (e.g. design a ship, or a
large building, or technically supervise building operations beyond a
certain size -- not to write software or to design chips).

Personally, I agree with the theory, first expressed by Adam Smith, that
such barriers to entry are mostly useful to grant practitioners of a
certain profession the scarcity value that lets them charge higher
prices, although of course they're always presented as good for
society.  Note that in Europe in the Middle Ages you needed strict
qualifications of that kind for just about anything -- you could not
make hats unless you belonged to the Hatters' Guild, etc; most of those
restrictions have since been lifted, but a few groups (doctors, lawyers,
accountants, ...) have managed to keep them in place.

 What about external independents ?
 Does Google cooperate with them?

Hardly ever... I, too, was at first trying to see if I could establish
some kind of consulting relationship with Google, in order to keep my
existing freelance practice alive as well, but in the end I found no way
to do so.  I believe Google's external consultants are very few -- e.g.,
some lawyers (Google employs some, but also has some external ones on
retainer), the members of our Board of Directors, Hal Varian.

 And how can one contact such a giant?

I believe that starting at http://www.google.com/about.html and
navigating from it will show you all the various avenues of contact
depending on your purpose for the contact; except that, for questions
about the Google Foundation, it might be better to start at
http://google.org/ instead.  Since the number of people wanting to
establish such contact for all sort of purposes is very large, and only
a few of Google's 5000 employees spend their time dealing with such
contact attempts, I have unfortunately heard of many cases in which such
attempts prove unfruitful.


 http://lazaridis.com/case/lang/python.html#simple_variable_access
 
 this leads to a new limitation:
 
 #LIMITATION: large amount of repetitive code

One normally does not define large numbers of identical accessors (there
would be no purpose served in so doing), so the boilerplate
(repetitive code) does not truly occur.  If for whatever reason one DOES
want a bazillion identical accessors, a simple custom metaclass (if one
has many classes with such needs), or simpler code still (if just one or
two classes require such bundles of accessors), avoid the repetitions.

For example (untested code, but should work):

class Talker(object):
  def __init__(self):
self._name = ''
self._age = 0
for attr in '_name _age'.split():
  def getter(self, attr=attr): return getattr(self, attr)
  def setter(self, value, attr=attr): return setattr(self, attr, value)
  setattr(Talker, attr[1:], property(getter, setter))

This is probably not worth the bother for just 2 attributes, but it
trivially generalizes to a bazillion attributes, if that's what you
want.  A custom metaclass could also more easily define an __init__
based simply on attribute names and default values desired (it's quite
possible this way, too, of course); alternative approaches include
wrapping the 'class' statement and the following loop in a factory
function which builds and returns the desired class (this gives roughly
the same power as a custom metaclass for this specialized task, though a
custom metaclass is more flexible and general); and the use of lexical
closures in preference to the simple getter and setter functions shown
here (or, factory functions for properties, embedding such closures).
E.g., change the loop to:

def makeprop(attr):
  def getter(self): return getattr(self, attr)
  def setter(self, value): return setattr(self, attr, value)
  return property(getter, setter)
for attr in '_name _age'.split():
  setattr(Talker, attr[1:], makeprop(attr))

Some would consider this more elegant (better factored).


The reason you don't see this kind of thing emphasized in Python
literature is that this style of programming is very rarely needed --
mostly when you're building a framework, or the Python modest equivalent
of a domain-specific minilanguage, or some kind of automated code
generator.  For 99% of the normal, everyday application programming one
does in Python, this introspective metaprogramming would be overkill,
although that may not be obvious to one who does not know Python -- for
example, it remains true that the addition of all of those trivial
getters and setters by 

Re: application and web app technologies

2006-01-03 Thread cartercc
 It might help if you elaborated on what these doubts are. It doesn't sound
 like you know any of the languages you've listed and are hoping that somehow
 you'll find one magical beast by cross-posting to a bunch of groups. I don't
 expect you're going to have much luck.

No, we don't know any of these languages. I'm reasonably competent in
Perl, and I have used some Java and Python (and taught C++ a lng
time ago but have never actually written any C++). The problem is that
none of us can compare apples to apples, even though we more or less
can do what needs to be done with the tools we know.

I don't expect the 'magical beast.' What I do expect is several posts
along the following lines: 'We faced a similar situation, and used X,
Y, and Z. X proved the best choice because of reasons A, B, and C. The
problem with Y was D and the problem with Z was E.'

 That said, Perl is still one of the best choices for both Web and admin
 scripting, and I don't see that you'd gain anything by rewriting all of your
 existing code to Ruby or Python just for the sake of saying you now use Ruby
 or Python (not that there's anything wrong with either, but why rewrite code
 for the sake of rewriting it?).

I agree with you about Perl, and CPAN is a fab resource, but the reason
we need to rewrite the code is because (1) it doesn't work (due to
external changes) and (2) it takes us less time to write new routines
that it does to decypher the old ones and modify them. Besides, I work
in an academic setting, and when people ask you what you use, I have
learned to cringe when I reply, 'Perl.'

CC

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Alex Martelli
Duncan Booth [EMAIL PROTECTED] wrote:

 Alex Martelli wrote:
 
  It IS true that in Python you cannot set arbitrary attributes on
  arbitrary objects.  The workaround is to use a dict, indexed by the id
  of the object you want to set arbitrary attributes on; this has the
  helpful consequence that separate namespaces are used, so your arbitrary
  setting of metadata cannot interfere with the `true' attributes of the
  object in question.
  
 That's a horrible suggestion (using id's, not the bit about separate 
 namespaces). If you use the id then attributes will persist beyond the
 lifetime of the object and may suddenly reappear on other unrelated objects
 later.

The second sentence is true, but does not imply the first: just add a
strong reference to the object you're imposing extra attributes on
(e.g., pile such objects into an auxiliary list).

 A better suggestion here would be to use weak references. Unfortunately,
 not every Python object can be the target of a weak reference, so there is
 a limitation here preventing a useful implementation for many builtin

...which is why I didn't suggest that;-).

 types. I can't actually think of a use case for what Ilias wants, and if
 there isn't a use case it isn't a big problem, but if anyone can come up
 with a usecase please say.

Many usecases of Lisp's property-lists might apply to Python just as
well, assuming one could associate properties/attributes to all objects
(as you can have property-lists anywhere in Lisp).

For example, you could associate to each of a lot of strings in some set
of data structures (but not necessarily all of them) the codec to be
used with that string.  This is typical metainformation: a string of
bytes as such does not tell you how to make it back into Unicode, and in
the cases where you have obtained that metainformation it would be nice
to store it somewhere (falling back to heuristics if you ever need to
deal with strings for which you haven't yet obtained the metainfo).

Similarly, some numbers (but again not necessarily all of them, for
whatever complex datastructures set they're used in) might usefully be
associated with the unit of measure they're in (again falling back to
heuristics if needed).

In Python you just know you can't easily do that so you typically turn
the whole program around to use, not strings or numbers with optional
metainfo associated to each, but instances of more complicated datatypes
which carry the information and the optional metainformation.  But if
you're used to the extremely handy idiom of just associating interesting
metainfo with any object whatsoever, that's quite a bother.

If you know that all you're decorating with propertylist is hashable,
you can use a simple dictionary -- but then one day you want to add some
metainformation to a file instance, and OUCH, that just fails... so
you're back to workarounds of various sorts, the most popular being no
doubt superstructures (subclasses or wrappers) holding the real data
and optional metainformation separately.

The ability of having attributes on functions is relatively recent in
Python and basically spoke to the same kind of needs (in that case,
there were also enough abuses of functions' docstrings to hold what was
in fact metainformation that nobody could really doubt the usecase for a
better approach;-).


 With the above code what would 'puts someexpressionresultingin1234.meta'
 output? i.e. is the attribute being set on all integers with the value
 1234, or just on a specific instance of an integer.

Good question, presumably answerable with a small Ruby test (which
however I have no time to perform right now;-).


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


Re: New to Python, WxPython etc, etc

2006-01-03 Thread Heiko Wundram
rodmc wrote:

 I am totally new to Python and WxPython and need to write an
 application which can open up an external windows from a plug-in within
 GAIM (using pyGAIM).

 snip
 
 app = MyApp(0)
 app.MainLoop()

You're trying to merge to event loops. GAIM uses the GTK2+ based loop,
whereas WxPython uses its own event loop. As you're starting the WxPython
main loop to service your program, no GUI events (such as displaying a
window) can get processed for GAIM. This is exactly what you're seeing.

I don't know how to patch into GAIM's event loop, but you should look for
some place where integration of pygtk and pygaim is discussed. wxPython
won't get you very far here.

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


Re: Filename case-insensitivity on OS X

2006-01-03 Thread Dan Sommers
On Tue, 03 Jan 2006 15:21:19 GMT,
Doug Schwarz [EMAIL PROTECTED] wrote:

 Strictly speaking, it's not OS X, but the HFS file system that is case
 insensitive.  You can use other file systems, such as UNIX File
 System.  Use Disk Utility to create a disk image and then erase it
 (again, using Disk Utility) and put UFS on it.  You'll find that
 touch foo FOO will create two files.

You may also find some native Mac OS X applications failing in strange
ways.

Regards,
Dan

-- 
Dan Sommers
http://www.tombstonezero.net/dan/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or Java or maybe PHP?

2006-01-03 Thread Aahz
In article [EMAIL PROTECTED],
James [EMAIL PROTECTED] wrote:

Do you have any specific comments towards Logix's implementation?

Nope.  I do know that Guido is generally in favor of Python-like
languages, and one of the goals of the AST project was to make that
easier.  Ditto PyPy.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Given that C++ has pointers and typecasts, it's really hard to have a
serious conversation about type safety with a C++ programmer and keep a
straight face.  It's kind of like having a guy who juggles chainsaws
wearing body armor arguing with a guy who juggles rubber chickens wearing
a T-shirt about who's in more danger.  --Roy Smith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to Python, WxPython etc, etc

2006-01-03 Thread Max Erickson
rodmc [EMAIL PROTECTED] wrote in news:1136299565.613252.202670
@g44g2000cwa.googlegroups.com:


 import _gaim
 import wx
 
 from wxPython.wx import *
 
 ID_ABOUT = 101
 ID_EXIT  = 102
 
 class MyFrame(wxFrame):
 def __init__(self, parent, ID, title):

I don't have an answer to your question, but as an aside, you should 
think about using the wx namespace if you move forward with wxPython. 
Basically, you would just eliminate 'from wxPython.wx import *' as you 
are already importing wx. Then, instead of referring to wxFrame, you 
would refer to wx.Frame.

See:
http://www.wxpython.org/MigrationGuide.html#the-wx-namespace

for more information about this.

Max

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


Re: Hypergeometric distribution

2006-01-03 Thread Cameron Laird
In article [EMAIL PROTECTED],
Raven [EMAIL PROTECTED] wrote:
Well, what to say? I am very happy for all the solutions you guys have
posted :-)
For Paul:
I would prefer not to use Stirling's approximation


The problem with long integers is that to calculate the hypergeometric
I need to do float division and multiplication because integer division
returns 0. A solution could be to calculate log(Long_Factorial_Integer)
.
.
.
This thread confuses me.

I've lost track of the real goal.  If it's an exact calculation of
binomial coefficients--or even one of several other potential
targets mentioned--I echo Steven D'Aprano, and ask, are you *sure*
the suggestions already offered aren't adequate?  Also, I think you
might not realize how accurate Stirling's approximation (perhaps to
second order) is in the range of interest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Application architecture (long post - sorry)

2006-01-03 Thread Cameron Laird
In article [EMAIL PROTECTED], Mike Meyer  [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] writes:

 In response to Mike's post...

 I know exactly where you're coming from and you are right a web based
 solution is the simplest and would be the fastest to develop and
 rollout etc. but..

 The cost is in the data, in the uk you get charged for the amount of
 data you send/receive  by GPRS and this data you are paying for would
 ideally be useful data and not the HTML to present it.

I'll take your word for it that you don't have GPRS providers in the
UK that have an all-you-can eat plan. They all do in the US.
.
.
.
Also, in at least some parts of Europe, carriers nominally charge
for the Web, but it's possible to browse effectively--to reach
nearly all the same pages--with an alternative protocol to http:
(the list of which I've now utterly, if perhaps temporarily,
forgotten).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WMI - invalid syntax error?

2006-01-03 Thread py
py wrote:
 I am going to try typing up that simple function into a new py file and
 put it on a diff. PC and try it.  I tried my current code on another
 computer and had the same issue...but I am wondering if I start anew if
 it will help.

ok, i am not sure whats going on.  I created a simple file with a
function which creates the WMI object, and I can use it, no problem.
Must be something weird, non-wmi related happening.

thanks.

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


REQUEST:Jobs available for python developers on linux/unix for immediate hire

2006-01-03 Thread sathya
ZeOmega is looking for experienced python developers.  Zope experience 
would be nice  and we will be happy to train you on Zope.
We use Zope in our products for the health care management industry and 
other consulting gigs. The domain is  medical  informatics and we are 
doing some exciting
work in the area of disease , chronic care management for public and 
commercial health populations and also injury management in workers 
compensation .
We also provide and manage the web crm and event registration systems 
for Gartner channel events in the US and EU.
We offer a good salary package that includes health benefits.
The positions are  in Dallas ,Texas.
Please forward your resume to  [EMAIL PROTECTED]
You can find out all about us at www.zeomega.com

Best Regards
Sathya Rangaswamy
-- 
=
CEO
ZeOmega
Open Minds' Open Solutions
#2591 Dallas Parkway
Suite 408
Frisco TX, 75034
214-618-9880 (O)
214-975-1258 (F)
214-733-3467 (M)
http://www.zeomega.com
==
-- 
http://mail.python.org/mailman/listinfo/python-list


Komodo IDE: '__file__' is not defined when debugging

2006-01-03 Thread fortepianissimo
This is a question to all of you who use Komodo IDE for development:
when I tried to debug my script which uses __file__ to get the absolute
path to the file, Komodo complained that the variable is not defined.

Anyway to work around this? (without changing the code)

Or if I need to change the code, how do I achieve the same thing I
wanted? Thanks in advance!

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


Re: Regex anomaly

2006-01-03 Thread Ron Garret
In article [EMAIL PROTECTED],
 Roy Smith [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
  Sam Pointon [EMAIL PROTECTED] wrote:
 
  Would this particular inconsistency be candidate for change in Py3k?
  Seems to me the pos and endpos arguments are redundant with slicing,
  and the re.match function would benefit from having the same arguments
  as pattern.match. Of course, this is a backwards-incompatible change;
  that's why I suggested Py3k.
 
 I don't see any way to implement re.I at match time;

It's easy: just compile two machines, one with re.I and one without and 
package them as if they were one.  Then use the flag to pick a compiled 
machine at run time.

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


Re: [OT] - Requesting Comments for Process Definition and Presentation

2006-01-03 Thread Ilias Lazaridis
Claudio Grondi wrote:
 Ilias Lazaridis wrote:
 
 comp.lang.python / comp.lang.ruby

 -

 I would like to ask for feedback on the Process Definition and 
 Presentation.

 Essentially this is exactly what I've myself specialized to do.

 But I cannot apply the process to my own system.

 I ask here, as I have criticized those 2 groups publically - and would 
 like to give the possibility to reverse the criticism - again publically.

 -

 Please simply visit

 http//:lazaridis.com

 what do you like?

 what do you dislike?

 are there points that you do not understand?
 
 What is the goal of your posting 

a) to retrieve feedback subjecting the website in general

b) to retrieve feedback subjecting the Process Definition itself 
(content of diagramms, clarity, terminology etc.)

http://lazaridis.com/efficiency/graph/index.html

 and the intended purpose of http://lazaridis.com ???

The purpose of the website is:

a) to present the company
b) to present the reengineering services
c) to present the process which is used to reengineer systems.
d) to present some of the results (e.g. public evaluations, evaluation 
cases etc.)
e) to present the research work (how the process has been developed)
f) to attract inital customers (no reference customers available yet)

 I can't see anything at this site what would make sense to me.

you mean, you don't understand _anything_?

so, we have no starting point.

And it seems I've many work to do.

...

.

 Claudio
 
 do you have any suggestions for terminology changes?

 do you have any other suggestion (marketing, presentation, etc.)?

 -

 You can use private email, the anonymous contact-form on the website 
 and  of course this medium here (c.l.p / c.l.r).

 Your feedback is _very_ important to me.

 Greetings!

.

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


Re: how to show Chinese Characters in the value set of a dictionary

2006-01-03 Thread Donn Cave
In article [EMAIL PROTECTED],
 Diez B. Roggisch [EMAIL PROTECTED] wrote:
...
 What put you off probably is the fact that in the interpreter, strings 
 are printed using their __repr__-method, that puts out those funny 
 hex-characters. But no need to worry there.

Moreover, the print statement also uses repr to convert lists
to strings.

If this generally suits your purposes, and you'd just prefer to avoid
the escape translation in strings, then I guess you either have to
write your own repr function for the lists, or for the strings.  The
first option should be fairly straightforward.  For the second, I'm
thinking of something like this -

   class Xtring(types.StringType):
  def __init__(self, a):
 self.value = a
  def __repr__(self):
 return '¥'%s¥'' % self.value

   dict['c1'] = Xtring('...')

   print dict.values()

(Of course you should use unicode instead of string - if you can
figure out how to require the default encoding that supports
your character set.  Python has an unfortunate preference for
ascii as a default encoding, and that's not likely to be the one
you want if you have any reason to use unicode.

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

One-step multiples list generation?

2006-01-03 Thread Efrat Regev
   Hello,

   Suppose I have some non-numerical Foo and would like to create a list 
of 20 Foo-s. Is there a one-step method (not a loop) of doing so? E.g., 
something like [Foo * 20] (which is obviously not the right way) that 
would create [Foo, Foo, Foo, ...,Foo].
   I tried looking through the docs, FAQs and help, but couldn't find 
anything (the closest is range, but it seems it's only for numerics) - I 
very much appreciate your time in answering. Also, please excuse me if I 
used some wrong terminology.

   Thanks,

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


Re: One-step multiples list generation?

2006-01-03 Thread Damien Wyart
* Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
 Suppose I have some non-numerical Foo and would like to create a list
 of 20 Foo-s. Is there a one-step method (not a loop) of doing so?

Maybe :

[ Foo ] * 20

or, more verbose,

[ Foo for _ in range(20) ]

?

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


Dr. Dobb's Python-URL! - weekly Python news and links (Jan 3)

2006-01-03 Thread Cameron Laird
QOTW:  People who are smart and care about correctness -- the
'reality-based community' -- often don't realise just how many
decisions are made on the basis of unfacts ... - Steven D'Aprano

QOTW:  [PyPy will not bring about the Singularity.]  But if it did,
imagine how cool that would look on the developers' rÃsumÃ. - Skip
Montanaro


Subversion, rather than CVS, now has the privilege of hosting
the reference Python sources:

http://groups.google.com/group/comp.lang.python.announce/msg/c0d2c6d7634fc685
The same post further reports on aspects of a couple of the few
issues truly significant for Python's long term:  rationalization
of the AST, profiling at the level of Python source, an unsolved
problem in memory-management of a multiply-inheriting type, style
in maintenance of ports, and blemishes in StringIO.

Armed only with a Web browser, you can Try Python:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/66e659942f95b1a0/
Thank Mike Meyer and idiom.com.

Mike Meyer, idiosyncratically backed by Frithiof Andreas Jensen,
also provides consummately level-headed advice on architectures
for mobile applications:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/17ed53a636d55cf1/

Andreas Kostyrka usefully details the performance and related
advantages high-level languages such as Python can boast:
http://groups.google.com/group/comp.lang.python/msg/223bb5636fee03c2

sjdevnull calmly and accurately describes the advantages and
disadvantages of Apache in comparison to pure-Python solutions:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4be8398f690c57d7/

Memoization is more interesting, and potentially global-free,
than might first appear:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b36ea6b290b8a902/



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.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

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

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon 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/

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

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

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

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

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

Among several Python-oriented RSS/RDF feeds available are

Re: One-step multiples list generation?

2006-01-03 Thread Rocco Moretti
Rocco Moretti wrote:
 Damien Wyart wrote:
 
 * Efrat Regev [EMAIL PROTECTED] in comp.lang.python:

 Suppose I have some non-numerical Foo and would like to create a list
 of 20 Foo-s. Is there a one-step method (not a loop) of doing so?



 Maybe :

 [ Foo ] * 20

 or, more verbose,

 [ Foo for _ in range(20) ]

 
 If Foo is mutable, keep this in mind:
 
   a = [ [] ]*20 # A list of 20 empty lists
   print id(a[0]) == id(a[1])
 True
   a[0].append(1)
   print a
 [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], 
 [1], [1], [1], [1], [1], [1]]
  
   b = [ [] for _ in range(20) ] # A list of 20 empty lists
   print id(b[0]) == id(b[1])
 False
   b[0].append(1)
   print b
 [[1], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], 
 [], [], []]
 

Oh, but also:

  Foo = []
  c = [ Foo for _ in range(20) ] # A list of 20 empty lists
  print id(c[0]) == id(c[1])
True
  c[0].append(1)
  print c
[[1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], 
[1], [1], [1], [1], [1], [1]]

(The difference with the 'b' case is that a new list is created each 
time around, in the other cases, the same list is reused.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: One-step multiples list generation?

2006-01-03 Thread Rocco Moretti
Damien Wyart wrote:
 * Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
 
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
 
 
 Maybe :
 
 [ Foo ] * 20
 
 or, more verbose,
 
 [ Foo for _ in range(20) ]
 

If Foo is mutable, keep this in mind:

  a = [ [] ]*20 # A list of 20 empty lists
  print id(a[0]) == id(a[1])
True
  a[0].append(1)
  print a
[[1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], 
[1], [1], [1], [1], [1], [1]]
 
  b = [ [] for _ in range(20) ] # A list of 20 empty lists
  print id(b[0]) == id(b[1])
False
  b[0].append(1)
  print b
[[1], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], 
[], [], []]

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


Re: One-step multiples list generation?

2006-01-03 Thread Damien Wyart
Thanks for these important and useful additions, they are very welcome !

In writing my answer I had immutables in mind, but mutables are a bit
more dangerous, here...

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


Re: application and web app technologies

2006-01-03 Thread Matt Garrish

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 It might help if you elaborated on what these doubts are. It doesn't 
 sound
 like you know any of the languages you've listed and are hoping that 
 somehow
 you'll find one magical beast by cross-posting to a bunch of groups. I 
 don't
 expect you're going to have much luck.

 No, we don't know any of these languages. I'm reasonably competent in
 Perl, and I have used some Java and Python (and taught C++ a lng
 time ago but have never actually written any C++). The problem is that
 none of us can compare apples to apples, even though we more or less
 can do what needs to be done with the tools we know.

 I don't expect the 'magical beast.' What I do expect is several posts
 along the following lines: 'We faced a similar situation, and used X,
 Y, and Z. X proved the best choice because of reasons A, B, and C. The
 problem with Y was D and the problem with Z was E.'


But that's what makes it impossible to give you any meaningful advice: every 
situation is different. Without being intimate with your architecture and 
what exactly web scripting and admin scripting means to you, it's nearly 
impossible to give vanilla advice about what language to use. You also need 
to bear in mind the skill set at your disposal. If no one knows the language 
you want to use, do you have time to account for the learning curve? Do you 
really want to try and replace all your programmers?

In Perl's defence, bad programmers write bad Perl code. There is nothing 
about the language that makes for unreadable code, only how you choose to 
write it. Going OO should be a no-brainer if you stay with Perl (just for 
the maintenance savings alone), but regardless of which language you choose 
you should have your programmers develop an accepted style (everything from 
how to name functions to how to structure your code library). If you let 
programmers build their own little universes they will!

 That said, Perl is still one of the best choices for both Web and admin
 scripting, and I don't see that you'd gain anything by rewriting all of 
 your
 existing code to Ruby or Python just for the sake of saying you now use 
 Ruby
 or Python (not that there's anything wrong with either, but why rewrite 
 code
 for the sake of rewriting it?).

 I agree with you about Perl, and CPAN is a fab resource, but the reason
 we need to rewrite the code is because (1) it doesn't work (due to
 external changes) and (2) it takes us less time to write new routines
 that it does to decypher the old ones and modify them.

That's again a sign of poor documentation coupled with bad style. It will 
always take a while to get back into your code, no matter what language you 
use. If you maintain consistency as you go, however, it eases a lot of the 
curve when you have to go back. You should probably look at other measures 
that involve your programmers more in making the coding a collective 
practice (peer review, for example). So long as the focus is constructive, 
it will help the group better understand what they should all be striving 
for and what they should all be doing. That more than anything will help 
prevent you from winding up in the same mess in a few years when you 
discover each person has their own coding ideas for whatever language you 
opt for.

Matt 


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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 3)

2006-01-03 Thread Robin Becker
Cameron Laird wrote:
..
 
 QOTW:  [PyPy will not bring about the Singularity.]  But if it did,
 imagine how cool that would look on the developers' rÃsumÃ. - Skip
 Montanaro
 

so when we're being eaten by super intelligent, quantum dot filled, grey goo we 
get to say so you're a derivate of C. Tismer, how cool :)

-fleeingly yrs-
Robin Becker

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


Re: - Requesting Comments for Process Definition and Presentation

2006-01-03 Thread simonh
i too am none the wiser after looking at your site:


Status

The services are available for initial Reference Customers.
Preferred Domains: Software-Development-Systems.
Preferred Projects: Open Source.

Profile

Lazaridis ReEngineering is a lightweight startup which has developed a
System Reengineering Method, based on the pragmatically defined
Independent Efficiency Management Process.

The provided services apply the Method remotely to different Systems,
with a specialization on Software Production Systems like e.g. Large
Scale Open-Source Projects or Software Companies.

The flowchart reveals nothing either.

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


Re: Spiritual Programming (OT, but Python-inspired)

2006-01-03 Thread [EMAIL PROTECTED]
 Apart from wishful thinking of course. That's always the major component
 in any reasoning about the afterlife. Life is a process, not a thing --
 when a clock runs down and stops ticking, there is no essence of ticking
 that keeps going, the gears just stop. When I stop walking, there is no
 spirit of walk that survives me coming to a halt. I just stop walking.

QOTYear!

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


Re: New Python.org website ?

2006-01-03 Thread Bugs
Aahz wrote:
 Dunno about in time for the new year, but there is a new design that is
 supposedly in final stages of getting implemented.  What's your hurry?

No hurry:
http://tinyurl.com/8d9ar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: One-step multiples list generation?

2006-01-03 Thread Efrat Regev
Damien Wyart wrote:
 * Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
 
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
 
 
 Maybe :
 
 [ Foo ] * 20
 
 or, more verbose,
 
 [ Foo for _ in range(20) ]
 
 ?
 

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Hans Nowak
Duncan Booth wrote:

 BTW, I don't know Ruby enough to understand the example at 
 http://lazaridis.com/case/lang/ruby/base.html:
 
 class Object
   def meta # adds variable meta to all objects in the system
 end

I don't think this is valid Ruby code, by the way...  It should probably 
be something like this:

   class Object
 attr_accessor :meta
   end

 Talker.meta = Class meta information
 john.meta = Instance meta information
 1234.meta = 'any Instance meta information
 
 puts Talker.meta
 puts john.meta
 puts 1234.meta  # an integer object
 
 With the above code what would 'puts someexpressionresultingin1234.meta' 
 output? i.e. is the attribute being set on all integers with the value 
 1234, or just on a specific instance of an integer.

At first glance, it seems the former is true:

irb(main):021:0 class Object
irb(main):022:1   attr_accessor :meta
irb(main):023:1 end
= nil
irb(main):026:0 1234.meta = fred
= fred
irb(main):027:0 (1000+234).meta
= fred
irb(main):028:0 x = 617
= 617
irb(main):029:0 x *= 2
= 1234
irb(main):031:0 x.meta
= fred
irb(main):032:0 3.meta
= nil

However, inspecting the object_id (comparable to Python's id()) shows 
that all these refer to the same object:

irb(main):035:0 1234.object_id
= 2469
irb(main):036:0 x.object_id
= 2469
irb(main):041:0 y = 1000
= 1000
irb(main):042:0 y.object_id
= 2001
irb(main):043:0 y += 234
= 1234
irb(main):044:0 y.object_id
= 2469

I am not an expert on Ruby internals, but it looks like these integers 
are cached.  As with Python, I don't know if one can count on this 
behavior to happen always.

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any wing2.0 users here?

2006-01-03 Thread Russell E. Owen
In article [EMAIL PROTECTED],
 Alvin A. Delagon [EMAIL PROTECTED] wrote:

Thanks for all the recommendations! I took a look on wingide2.0 on my 
linux box and it seems pretty good and has a lot of nifty features 
(which is pretty daunting to use since I've been programming with no IDE 
at all) and it debugger work pretty well but for a price tag of $179 I 
think it not worth it.

I've tried various IDEs and like WingIDE by far the best. It is easy to 
use, robust and has great support. The improved productivity is well 
worth the price (especially if your work is buying it for you). I 
qualified for a free license, but would certainly have had my job pay 
for it otherwise. I was tempted to buy it anyway, but felt it would be 
unethical to my employer.

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


Re: Tkinter Scrollbar not working

2006-01-03 Thread jmdeschamps

Dustan a écrit :

 I'm trying to get a scrollbar bound with a Frame, and I keep on getting
 a scrollbar, but it doesn't actually scroll. Some help, please?

Frames are NOT scrollable objects for scrollbars in Tkinter: Listbox,
Canvas and Text widget are.

I f you want/need to scroll something else, I think you are going to
have to do it yourself, meaning you can use the scrollbars to get user
input by binding an event to it, and then moving things around your
Frame to give the scrolling appearance.

OR you can take a look at a third-party such as PythonMegaWidgets (PMW)
who have them I believe...

Happy New Year anyhow...

Jean-Marc

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


Re: Komodo IDE: '__file__' is not defined when debugging

2006-01-03 Thread Trent Mick
[fortepianissimo wrote]
 This is a question to all of you who use Komodo IDE for development:
 when I tried to debug my script which uses __file__ to get the absolute
 path to the file, Komodo complained that the variable is not defined.
 
 Anyway to work around this? (without changing the code)
 
 Or if I need to change the code, how do I achieve the same thing I
 wanted? Thanks in advance!

The problem is that when you run your script under the debugger (same
thing with pdb.py) __file__ isn't set automatically because running a
Python script with Python's execfile() (which is what Komodo debugger
does) works slightly differently that what Python's main() does to run a
Python script. One of the differences is the setting of __file__.

(Side note: I'm not sure if this should be a Python bug or not. The
intention of under what conditions  __file__ should be set are not clear
from the Python docs. From a quick poke I think it may be possible that
__file__ not getting set via execfile() is a bug that was introduced
with pythonrun.c changes when nested scopes were added a while back).

We've started a bug for this on Komodo:
http://bugs.activestate.com/Komodo/show_bug.cgi?id=43703

...and Shane just fixed it. I.e. Subsequent releases of Komodo will have
this fixed: __file__ will be set in the main module.

Until that release, workarounds:
1. get the main script path from sys.argv[0]; or
2. apply the patch (to .../dbgp/client.py in your Komodo install) that
   Shane attached to that bug to your Komodo installation.

Thanks for mentioning the bug.

Cheers,
Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Visualisation Engine for Python

2006-01-03 Thread Andrea Gavana
 I am looking for a 2D data visualisation or graphics library for
 Python. Can anyone point me in the right direction?

You could try out matplotlib:

http://matplotlib.sourceforge.net/

HTH.

Andrea.

Imagination Is The Only Weapon In The War Against Reality.
http://xoomer.virgilio.it/infinity77


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


Re: Spiritual Programming (OT, but Python-inspired)

2006-01-03 Thread Kay Schluehr
[EMAIL PROTECTED] wrote:
 While preparing a Python411 podcast about classes and OOP, my mind
 wondered far afield. I found myself constructing an extended metaphor
 or analogy between the way programs are organized and certain
 philosophical ideas. So, going where my better angels dare not, here is
 the forbidden fruit of my noodling:

 Spiritual Programming:

 It seems to me that, if anything of a person survives death in any way,
 it must do so in some way very different from that way in which we
 exist now.

 For now, we live in a  temporal world, and once our body and brain
 ceases to function, then our mind can no longer function in this
 temporal world, and we cease to exist in this temporal world

 So, our current consciousness and awareness is a temporal one. We
 experience the one way flow of time. We are not actually conscious of
 any permanent thing, only of the changing world as time flows forward.

 In this sense, we are like the ghost in the machine of a computer
 system running a computer program, or programs, written in a procedural
 language and style. That is, the instructions in our program flow in a
 linear sequence, with each instruction impacting and giving way to the
 next instruction. Oh, there are the occasional looping structures, and
 even the occasional out-of-left-field chaos causing go-to; but we
 nevertheless experience all these things as linear and procedural.

 It seems apparent to me that , if anything of us survives it must do so
 outside time, and any surviving consciousness could not experience the
 same sort of temporal, linear, procedural existence of which we are now
 aware. Oh, I can imagine a timeless essence of our being existing
 timelessly but statically, observing the remnant of our informational
 holes evolving and dissolving away in the temporal universe; but this
 would be a cold survival after all, hardly worthy of the name.

 But perhaps there is a non-temporal world of eternity, that has
 structures more reminiscent of higher order programming structures. So,
 for instance, functional programming takes and builds upon its
 procedural predecessors. So maybe our better, more re-useable parts,
 that we develop in this temporal existence, are recycled into
 functional units in a non-temporal world. There would still be a
 direction of logic flow, but it would be a higher order reality than a
 linear, procedural one.

 But beyond this perhaps we can imagine an object oriented world, one in
 which the more functional, re-useable parts of people and things from
 this lower, temporal world are re-packaged into objects containing both
 functional methods and also parameters of state. These higher order
 objects, and the relationships they form amongst themselves, can be
 imagined to exist in a more timeless state than mere procedural
 programs, or even functional ones, in that the complex object oriented
 structures of such a timeless world would hold meaning even when viewed
 as a whole, and not just when played linearly like a phonograph record.


 There must be some higher order cognate of time, in this object
 oriented world, but we are not able to conceive of it at this time. Our
 awareness of existence in this higher order world would be very
 different than our current awareness of linearly flowing time, but must
 be more in the way of sensing the movements of meaning and
 relationships amongst the informational matrices of this higher order,
 object oriented universe.

 One can visualize a universe in which there are are an infinite number
 of infinite dimensions, but these dimensions also keep expanding at an
 infinite rate forever. This expansion could be thought of as the
 cognate of time. Entities in this world could freely move back and
 forth in any dimension, and could experience the totality of reality
 all at once, but still experience the novelty of time.

 I do not know how Aspect Oriented Programming fits into this picture,
 if at all. But one can imagine higher orders of programming logic and
 structure than  OOP, whether AOP qualifies or some other, yet
 undescribed programing paradigm.  And, we do not know how many higher
 layers of programming structure exist  beyond our current technical
 understanding.

 Perhaps this is one reason why programmers are so passionate, and even
 religious, about their programming tools; because they intuitively
 sense that we are dealing with ideas that, however crudely, mirror
 eternal realities of immense significance.

 Ron Stephens
 a href=http://www.awaretek.com/python/index.html;Python411 Podcast
 Series/a

AOP corresponds to a holographic worldview where each single object is
in fact a composition and we obtain nonlocal correspondences between
parts of the whole pattern. The aspects in an AOP program are the
implicite order of a program that is weaved by aspects. The spiritual
meaning is that of the gnostic believe in a transcentendal order that
pervades existing being but is nevertheless hidden. Its 

Re: Try Python update

2006-01-03 Thread [EMAIL PROTECTED]
Very nice :)

I found this online Ruby tutorial:
  http://tryruby.hobix.com/

I think it would be cool to have something similar for Python. Want to
go further and make a nice tutorial to accompany this :) 

wy

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Duncan Booth
Alex Martelli wrote:

 Duncan Booth [EMAIL PROTECTED] wrote:
 That's a horrible suggestion (using id's, not the bit about separate 
 namespaces). If you use the id then attributes will persist beyond
 the lifetime of the object and may suddenly reappear on other
 unrelated objects later.
 
 The second sentence is true, but does not imply the first: just add a
 strong reference to the object you're imposing extra attributes on
 (e.g., pile such objects into an auxiliary list).
 
Except that would lead to fairly massive memory leaks, so isn't really
of practical use. I guess you could combine an auxiliary list with a
periodic scan of the list releasing those objects which are referenced
only from the list, which would reduce the problem to objects
participating in cycles. Combine that with the weak reference approach
wherever it works and you might be able to cover most situations. 

 
 With the above code what would 'puts
 someexpressionresultingin1234.meta' output? i.e. is the attribute
 being set on all integers with the value 1234, or just on a specific
 instance of an integer. 
 
 Good question, presumably answerable with a small Ruby test (which
 however I have no time to perform right now;-).

Hans Nowak seems to have partly answered that. It looks as though the id
of a Ruby integer is one more than twice the integer's value so I guess
that ruby packs the integer value in place of the object reference. A
quick search reveals: 

 A Fixnum holds Integer values that can be represented in a native
 machine word (minus 1 bit). If any operation on a Fixnum exceeds this
 range, the value is automatically converted to a Bignum. 
 
 Fixnum objects have immediate value. This means that when they are
 assigned or passed as parameters, the actual object is passed, rather
 than a reference to that object. Assignment does not alias Fixnum
 objects. There is effectively only one Fixnum object instance for any
 given integer value, so, for example, you cannot add a singleton
 method to a Fixnum. 

So it looks like the Ruby example will work as observed for integers which 
fit in one bit smaller than a machine word and then work differently for 
larger integers.


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


Re: Visualisation Engine for Python

2006-01-03 Thread Gerard Flanagan
rodmc wrote:

 I am looking for a 2D data visualisation or graphics library for
 Python. Can anyone point me in the right direction?


 Thanks in advance,

 rod


I can't help with Python code but there are C++ programs here:

http://www-rocq1.inria.fr/gamma/cdrom/www/emc2/eng.htm

and here:

http://www-rocq1.inria.fr/gamma/cdrom/www/bamg/eng.htm

Institut National de Recherche en Informatique et en Automatique
(INRIA)

It's free for non-commercial use,  permission from INRIA for commercial
use.

As I understand it, there are a number of programs (eg. SWIG, ctypes )
which allow you to   call C++ from Python.  I've never done that sort
of thing myself, but Lutz  Ascher (Learning Python, O'Reilly) say it's
simple even for nonexperts pp525, 2nd ed.

hth

Gerard

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


Re: Spiritual Programming (OT, but Python-inspired)

2006-01-03 Thread Shane Hathaway
[EMAIL PROTECTED] wrote:
 Perhaps this is one reason why programmers are so passionate, and even
 religious, about their programming tools; because they intuitively
 sense that we are dealing with ideas that, however crudely, mirror
 eternal realities of immense significance.

While I don't associate any spiritual significance with programming, I 
do think that the choices we've made in the field of programming reflect 
deeply upon human cognition.

A modern computer is a thoroughly abstract mathematical machine, so 
programmers can choose almost any abstraction to solve a problem.  But 
it turns out that some abstractions fit our minds better than others, so 
programmers usually apply a small set of abstractions many times.  So if 
we could categorize and chart the space of all programming abstractions 
that we have found most useful, we might learn a little about how our 
minds work.  The research could be valuable for AI.

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Ilias Lazaridis
Alex Martelli wrote:
 Ilias Lazaridis [EMAIL PROTECTED] wrote:
[...] - google stuff

http://lazaridis.com/case/lang/python.html#simple_variable_access

this leads to a new limitation:

#LIMITATION: large amount of repetitive code
 
 One normally does not define large numbers of identical accessors (there
[...] - (extensive elaboration)

possibly one can provide the code for something similar to the ruby 
attr_accessor:

class Talker
   def sayHello
 puts Hello world
   end

   attr_accessor :name, :age

end

thus they can later be accessed this way

john.age = 19

print john.age


I meant: reproduce the definition of the class (but without reproducing
the source-code of the class)

I have removed the without code remark, which was missleading.
 
 Aha!  I see now, and it does make more sense.  Yes, using inspect you
 could surely emit for example skeletons for the various methods, with
 e.g. a 'pass' in lieu of their code.  However, since instance attributes
 are determined by code that gets executed (in __init__, and maybe in
 __new__ and even elsewhere), it's not really practical to find out what
 attributes an instance would have without in fact creating such an
 instance and introspecting on it.  Would such instantiation be OK here?

If I understand you right, it would be ok.

The requirements are given by the template:

john.sayYourClassDefinition()

john is instantiated, when asked for his class definition.

 In some cases instantiating a class might have externally visible
 effects, say opening a network connection, or a database, etc, so you
 might well want to forbid that for purely introspective purposes.

see above.

yes, you are right.

= {New Requirement: ability to declare objects as mutable/immutable.}
 
...
 
I estimate that there is a unfreeze operation, too - which would lead
to flexibity.
 
 Yes, but also mean that immutable objects are not really immutable, only
 immutable until further notice.  For example, the immutability of
[...] - (elaborations)

I understand now.

= {New Requirement: ability to declare objects as immmutable or 
mutable/immutable}

There's no need to define this 'meta' attribute anywhere, it just
springs into existence when you assign to it.

?

assign to it with:

setattr(Talker, 'meta', Class meta information)

but _not_ with this:

Talker.meta = Class meta information

correct?
 
 Nope: both forms have IDENTICAL semantics.  They both work in just the
 SAME way.
 
 Try it out...!

But this means that assignment of metadata works fine.

class Talker(object): pass
 
 ... 
 
Talker.meta = 'class metainfo'
print Talker.meta
 
 class metainfo

thus if I make a typo, I create a new attribute?

.

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


Microsoft IronPython?

2006-01-03 Thread Nainto
I came across this link today. http://tinyurl.com/9c7ta It seems
Microsoft is getting involved with Python. What do you think of it? Is
it any good? Anything to worry about?
--
Zach

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


  1   2   3   >