Re: dictionary of list from a file

2006-10-04 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi guys,
> this is my first post. my "programming" background is perlish scripting
> and now I am learning python. I need to create a dictionary of list
> from a file. Normally in perl I use to do like:
>
> while(){
>  @info=split(/ +/,$_);
>  push (@{$tmp{$info[0]}},$info[1]);
> }
>
> and then
> foreach $key (keys %tmp){
>   print "$key -> @{$tmp{$key}}\n";
> }
> i get
>
> 2 -> 1  2 3 4
> 7 -> 7 8 9 10
>
> in python I tried:
> b={}
> a=[]
> for line in fl.readlines():
> info=lines.split()
> b[info[0]] = a.append(info[1])
>
> and then
> for i in b:
> print i,b[i]
> i get
> 2 None
> 7 None
>
> data file is:
> 2 1
> 2 2
> 2 3
> 2 4
> 7 7
> 7 8
> 7 9
> 7 10
>
> Any help??
> Thanks in advance
> Best Regards
>
> Andrea
>

I'll see your perlish line noise, and raise you this obfuscapython:  :)

data = """\
2 1  2 3 4
  7 7 8 9 10
5 1 3 5 7 9
2 6 8 10""".split('\n')  # similar to file.readlines(), but easier to paste 
into news post
import operator, itertools
item = operator.itemgetter
b = dict( (k,sum(map(lambda g:g[1:],grps),[]))
 for (k,grps) in itertools.groupby( sorted( 
map(str.split,data) ), item(0) ) )
for item in sorted(b.items()):
print "%s -> %s" % item

prints:
2 -> ['1', '2', '3', '4', '6', '8', '10']
5 -> ['1', '3', '5', '7', '9']
7 -> ['7', '8', '9', '10']

-- Paul


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


Re: How can I correct an error in an old post?

2006-10-04 Thread Steve Holden
Jorgen Grahn wrote:
> On Mon, 02 Oct 2006 16:36:24 +0100, Steve Holden <[EMAIL PROTECTED]> wrote:
> 
>>Jorgen Grahn wrote:
>>
>>>On 1 Oct 2006 10:18:59 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
and I wish to add my findings to the post, to prevent others from
taking the wrong path.
> 
> 
> 
>>>In Usenet terms, make a posting with a References: header which mentions the
>>>Message-ID of the bad posting (just like this posting references yours, if
>>>you look closely at the headers).  That's easier if the posting hasn't
>>>already expired on your server, but by no means impossible if it has.
>>>
>>>/Jorgen
>>>
>>
>>Since this message was never on topic,
> 
> 
> I disagree; it was a technical question on how to handle a discussion in
> this newsgroup, and IMHO that is always on topic -- to a certain point.
> 
> 
>>I'd appreciate it if all 
>>concerned would close this thread now.
> 
> 
> I think you are overreacting. This was a thread with three (3) postings, in
> a high-volume newsgroup, with no indication that it would continue (except
> maybe with a pointer to whatever posting the OP wanted to correct, or to his
> correction).
> 
I probably was. I also missed the (in retrospect, fairly clear) 
implication that it was an old *c.l.py* post that was being discussed.

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

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


Re: sax barfs on unicode filenames

2006-10-04 Thread John Machin

Diez B. Roggisch wrote:
> Edward K. Ream wrote:
>
> > Hi.  Presumably this is a easy question, but anyone who understands the
> > sax docs thinks completely differently than I do :-)
> >
> >
> >
> > Following the usual cookbook examples, my app parses an open file as
> > follows::
> >
> >
> >
> > parser = xml.sax.make_parser()
> >
> > parser.setFeature(xml.sax.handler.feature_external_ges,1)
> >
> > # Hopefully the content handler can figure out the encoding from the
> > # 
> > element.
> >
> > handler = saxContentHandler(c,inputFileName,silent)
> >
> > parser.setContentHandler(handler)
> >
> > parser.parse(theFile)
> >
> >
> >
> > Here 'theFile' is an open file.  Usually this works just fine, but when
>
> Filenames are expected to be bytestrings. So what happens is that the
> unicode string you pass as filename gets implicitly converted using the
> default encoding.
>
> You have to encode the unicode string according to your filesystem
> beforehand.

Not if your filesystem supports Unicode names, as Windows does.
Edward's point is that something is (whether by accident or "design")
trying to coerce it to str, and failing.

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


Re: PEP 358 and operations on bytes

2006-10-04 Thread John Machin

Paul Rubin wrote:
> "John Machin" <[EMAIL PROTECTED]> writes:
> > So why haven't you been campaigning for regular expression support for
> > sequences of int, and for various array.array subtypes?
>
> regexps work on byte arrays.

But not on other integer subtypes. If regexps should not be restricted
to text, they should work on domains whose number of symbols is greater
than 256, shouldn't they?

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


Re: A Universe Set

2006-10-04 Thread MonkeeSage
Jorgen Grahn wrote:
> - infinite xrange()s

Fun. How about in-memory objects which use no memory, and
self-referential anonymous functions, and object states without
objects...

Regards,
Jordan

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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread skip

Giovanni> In fact, are you absolutely positive that you need so much
Giovanni> effort to maintain an existing bugtracker installation?

The development group's experience with SF and I think to a lesser extent,
Roundup in its early days, and more generally with other components of the
development toolchain (source code control) and python.org website
maintenance suggests that some human needs to be responsible for each key
piece of technology.  Maybe when it's mature it needs very little manpower
to maintain, but a substantial investment is required when the technology is
first installed.

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


Re: A Universe Set

2006-10-04 Thread Paul McGuire
"Jorgen Grahn" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> - the black hole function 'def f(*args): pass'
> - the identity function 'def f(x): return x'
>
Also not so farfetched.

See the disable and enable decorators at 
http://wiki.python.org/moin/PythonDecoratorLibrary#head-8298dbf9ac7325d9ef15e7130e676378bbbda572.

-- Paul


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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread skip

Istvan> I think you are missing the point. Switching to a different
Istvan> tracker is not such a big deal. Having a really good tracker is
Istvan> a big deal.

No, actually switching trackers can be one big pain in the ass.  You
probably aren't aware of how hard it's been for the Python development team
(I think Martin v. Loewis, mostly) to get tracker data out of SF.  An
explicit requirement was that any tool chosen as a SF replacement be able to
easily export its database to avoid this sort of "lock-in" in the future.

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


Re: can't open chm files all of a sudden

2006-10-04 Thread John Salerno
John Machin wrote:

> Many things might cause an error dialogue -- further info needed.

Thanks, I will try your suggestions when I get home. As far as I know, 
this only started happening yesterday (although maybe I haven't opened 
the files in a day or two). All I've installed/uninstalled since then 
was HTML Kit. I'm not on a network, it's just me. I redownloaded the chm 
file for Python24 and it does the same thing.

I'll see what else I can find at home, I just hope it doesn't affect 
Python, and I desperately need my docs, especially for wxPython.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python/Tkinter crash.

2006-10-04 Thread Eric Brunel
On Wed, 04 Oct 2006 10:33:55 +0200, Hendrik van Rooyen  
<[EMAIL PROTECTED]> wrote:

> Hi,
>
> I get the following:
>
> [EMAIL PROTECTED]:~/Controller/lib> python display.py
> UpdateStringProc should not be invoked for type font
> Aborted
>
> and I am back at the bash prompt - this is most frustrating, as there is  
> no
> friendly traceback to help me guess where its coming from.
>
> And what is worse, the script runs for a varying time before it simply  
> exits
> like this.
>
> What can I do to dig deeper to try to find a clue? - I don't even know  
> if its
> Python, Tkinter or Linux...

Neither of them: it's a tcl problem. The message you get is in the file  
generic/tclObj.c in the tcl source directory.

I know the problem happens sometimes on one of my Tkinter applications,  
but I never succeeded in reproducing it systematically. I've browsed the  
tcl bugs, but didn't find anything. Maybe you'll be luckier than I... If  
you are, I'm interested in any hint you can find.
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making posts to an ASP.NET webform.

2006-10-04 Thread Bernard

Bernard wrote:
> Gabriel Genellina wrote:
> > At Monday 2/10/2006 13:05, Bernard wrote:
> >
> > > > > Has anyone tried what I'm doing? and if you tried how have you
> > > > > succeeded getting the data back after the post action?
> >
> > Use a packet sniffer or something to look at an actual POST that
> > works, this way you could see what's missing in your code.
> >
> >
> > Gabriel Genellina
> > Softlab SRL
>
> Thanks for that suggestion Gabriel. It's really a great idea to see
> what's going on behind the scene but it still doesn't work even though
> the post made by my function has the same data as a real browser post.
>
> here's the HTTP Header from my sniffer:
> -
> http://www.newportrealty.com/Search/Default.aspx?Area=WC
>
> POST /Search/Default.aspx?Area=WC HTTP/1.1
> Host: www.newportrealty.com
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.6)
> Gecko/20060728 Firefox/1.5.0.6
> Accept:
> text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
> Referer: http://www.newportrealty.com/Search/Default.aspx?Area=WC
> Cookie: ASPSESSIONIDQQBTTDAT=JMBBNNJELLBBNCCDMNCK;
> ASP.NET_SessionId=hzdjizvca2zid3f205s5kd45
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 4649
> __EVENTTARGET=dg_Result%3A_ctl1%3A_ctl1&__EVENTARGUMENT=&__VIEWSTATE=dDw0MD(...)
> HTTP/1.x 200 OK
> Cache-Control: private
> Content-Length: 37519
> Content-Type: text/html; charset=utf-8
> Server: Microsoft-IIS/6.0
> X-Powered-By: ASP.NET
> X-AspNet-Version: 1.1.4322
> Date: Wed, 04 Oct 2006 15:15:37 GMT
> -
>
> and here's the output of the encoded data as well as the cookies in my
> function:
>
> -
> cookies:
>  www.newportrealty.com/>
>  www.newportrealty.com/>
>
> encoded post data:
> __EVENTTARGET=dg_Result%3A_ctl14%3A_ctl2&__EVENTARGUMENT=&__VIEWSTATE=dDw0MDAyOTcw(...)
> -
>
> My function has already worked on other asp.net websites and I'm pretty
> sure this would work out just fine. is there something I'm missing here?


ok my bad I've just found out that I didn't build properly the form
action url!! It works now!

thanks for all the responses!!

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


Re: sax barfs on unicode filenames: workaround

2006-10-04 Thread Edward K. Ream
Happily, the workaround is easy.  Replace theFile with:

# Use cStringIo to avoid a crash in sax when inputFileName has unicode 
characters.
s = theFile.read()
theFile = cStringIO.StringIO(s)

My first attempt at a workaround was to use:

s = theFile.read()
parser.parseString(s)

but the expat parser does not support parseString...

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: A Universe Set

2006-10-04 Thread Peter Otten
Jean-Paul Calderone wrote:

> On Wed, 04 Oct 2006 11:00:28 -0400, Leif K-Brooks <[EMAIL PROTECTED]>
> wrote:
>>Jorgen Grahn wrote:
>>> - infinite xrange()s
>>
>>itertools.count()?
> 
> Not quite:
> 
> >>> import sys, itertools
> >>> c = itertools.count(sys.maxint)
> >>> c.next()
> 2147483647
> >>> c.next()
> -2147483648
> >>> 
> 
> Jean-Paul

>>> import sys
>>> from itertools import count
>>> c = count(sys.maxint)
>>> c.next()
2147483647
>>> c.next()
2147483648L

sys.maxint and then some cheers on Python 2.5 :-)

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


Re: changing numbers to spellings

2006-10-04 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
> You should get some clue about the number conversion (not to menion a
> bunch of code you can lift :) from
> 
>  http://www.python.org/pycon/dc2004/papers/42/ex1-C/num2eng.py

For some reason I felt like writing another one, that doesn't use as
much recursion as the last one I posted.  This one is more like
old-fashioned Python and is shorter, but took several refactorings
and was harder to debug:

def spell(n, d=0):
# spell arbitrary integer n, restricted to |n| < 10**66
assert abs(n) < 10**66
if n == 0: return 'zero'
if n < 0:  return 'minus ' + spell(-n, d)

bigtab = ('thousand', 'million', 'billion', 'trillion',
  'quadrillion', 'quintillion', 'sextillion', 'septillion',
  'octillion', 'nonillion', 'decillion', 'undecillion',
  'duodecillion', 'tredecillion', 'quattuordecillion',
  'quinquadecillion', 'sextemdecillion', 'septemdecillion',
  'octodecillion', 'novemdecillion', 'vigintillion')
smalltab = ('', 'one', 'two', 'three', 'four',
'five', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen',
'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen')
out = []
def maybe(cond,s): return (cond and s) or ''

a,n = divmod(n, 1000)
if a:
out.extend((spell(a,d+1), maybe(a % 1000, bigtab[d])))

a,n = divmod(n, 100)
out.append(maybe(a, '%s hundred'% spell(a)))

a,b = divmod(n, 10)
if a > 1:
out.append(('twenty', 'thirty', 'forty', 'fifty', 'sixty',
'seventy', 'eighty', 'ninety')[a-2] +
   maybe(b, '-' + smalltab[b]))
else:
out.append(smalltab[n])
return (' '.join(filter(bool, out)))

# example
print spell(9**69)
-- 
http://mail.python.org/mailman/listinfo/python-list


item access time: sets v. lists

2006-10-04 Thread David Isaac
Is it expected for access to set elements to be much
slower than access to list elements?  Explanation?
Thanks,
Alan Isaac

>>> t1=timeit.Timer("for i in set(xrange(1)):pass","")
>>> t2=timeit.Timer("for i in list(xrange(1)):pass","")
>>> t1.timeit(1000)
9.806250235714316
>>> t2.timeit(1000)
3.9823075279120701


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


Re: PEP 358 and operations on bytes

2006-10-04 Thread Paul Rubin
"John Machin" <[EMAIL PROTECTED]> writes:
> But not on other integer subtypes. If regexps should not be restricted
> to text, they should work on domains whose number of symbols is greater
> than 256, shouldn't they?

I think the underlying regexp C library isn't written that way.  I can
see reasons to want a higher-level regexp library that works on
arbitrary sequences, calling a user-supplied function to classify
sequence elements, the way current regexps use the character code to
classify characters.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ask sax for the file encoding

2006-10-04 Thread Diez B. Roggisch
Edward K. Ream wrote:

>> [The value of the encoding field] _could_ be retained, but for what
>> purpose?
> 
> I'm asking this question because my app needs it :-)  
> Imo, there is *no* 
> information in any xml file that can be considered irrelvant.  

It sure is! The encoding _is_ irrelevant, in the very moment you get unicode
strings. The order of attributes is irrelevant. There is plenty of
irrelevant whitespace. And so on...

> My app will 
> want to know the original encoding when writing the file.

When your app needs it, whatfor does it need it? If you write out xml again,
use whatever encoding suits you best. If you don't, use the encoding that
the subsequent application or processing step needs.

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


Re: A Universe Set

2006-10-04 Thread Istvan Albert
Jorgen Grahn wrote:

> I have been craving for some similar things for a while, and I'm still not
> sure if they are good ideas, or brain damage caused by studying functional
> programming at Uni.

This is a self correcting situation, as ayone who understands why they
need this  can surely write them using itertools and some simple
classes.

No Child Left Behind.

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


Re: Need help with syntax on inheritance.

2006-10-04 Thread Peter Otten
SpreadTooThin wrote:

> the =() syntax indicates what?

No special syntax, just an empty tuple as a default parameter.
In this case I could have used an empty list, too, but I thought I'd spare
you the dangers of mutable default values as explained here:

http://www.python.org/doc/faq/general/#id53

> Just slightly off topic here but if Array had a bunch of initializers 
> of its own, must all the 'optional' parameters be on the right.. ie the
> last parameters?

Yes.

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


Re: can't open chm files all of a sudden

2006-10-04 Thread Gabriel Genellina

At Wednesday 4/10/2006 01:32, John Salerno wrote:


> I tried opening my Python chm docs just now, as well as the one for
> wxPython, and both are giving me an error dialog when I double-click
> them and I can't open them. This happened apparently for no reason, just
> today. I even reset but that didn't help.
AppName: hh.exe AppVer: 5.2.3790.2453   ModName: itss.dll
ModVer: 5.2.3790.2453   Offset: 6bec


Try this: 


Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: item access time: sets v. lists

2006-10-04 Thread Dennis Benzinger
On Wed, 04 Oct 2006 16:02:56 GMT
"David Isaac" <[EMAIL PROTECTED]> wrote:

> Is it expected for access to set elements to be much
> slower than access to list elements?  Explanation?
> Thanks,
> Alan Isaac
> 
> >>> t1=timeit.Timer("for i in set(xrange(1)):pass","")
> >>> t2=timeit.Timer("for i in list(xrange(1)):pass","")
> [...]

You're measuring the time for creating the xrange and the set/list too.
Create them before you call Timer() and repeat your timing.


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


Re: item access time: sets v. lists

2006-10-04 Thread Paul McGuire
"David Isaac" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Is it expected for access to set elements to be much
> slower than access to list elements?  Explanation?
> Thanks,
> Alan Isaac
>
 t1=timeit.Timer("for i in set(xrange(1)):pass","")
 t2=timeit.Timer("for i in list(xrange(1)):pass","")
 t1.timeit(1000)
> 9.806250235714316
 t2.timeit(1000)
> 3.9823075279120701
>
>
A couple of points:
1. Your use of timeit is a bit flawed.  You are not only timing the access 
into the set or list, but also the construction of the set/list, *every 
time*.  Use the second string arg (the one you are passing as "") for 
one-time initialization, so that you measure only access, which is what you 
say your are interested in.
2. Ooops, it turns out you're not really *accessing* the set/list, you are 
*iterating* over it.  Given that sets are implemented internally using a 
tree structure, I would expect that iterating over a list could be faster, 
although only marginally so.
3. Here are some stats for a little more correct timeits:

Construct list/set
set  -> 1.89524618352
list -> 0.299499796762

Iterate over list/set
set  -> 0.646887523414
list -> 0.552001162159

Random access to first item in list/set
set  -> 0.000189409547861
list -> 0.000160076210804

Random access to item in list/set when item exists
set  -> 0.000241650824337
list -> 0.0245168031132

Random access to item in list/set when item does not exist
set  -> 0.000187733357172
list -> 0.522086186932


The code:
import timeit

print "\nConstruct list/set"
t1=timeit.Timer("z = set(xrange(1))","")
t2=timeit.Timer("z = list(xrange(1))","")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

print "\nIterate over list/set"
t1=timeit.Timer("for i in z: pass","z = set(xrange(1))")
t2=timeit.Timer("for i in z: pass", "z = list(xrange(1))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

print "\nRandom access to first item in list/set"
t1=timeit.Timer("0 in z","z = set(xrange(1))")
t2=timeit.Timer("0 in z", "z = list(xrange(1))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

print "\nRandom access to item in list/set when item exists"
t1=timeit.Timer("500 in z","z = set(xrange(1))")
t2=timeit.Timer("500 in z", "z = list(xrange(1))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

print "\nRandom access to item in list/set when item does not exist"
t1=timeit.Timer("10500 in z","z = set(xrange(1))")
t2=timeit.Timer("10500 in z", "z = list(xrange(1))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)


-- Paul


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


Re: loop beats generator expr creating large dict!?

2006-10-04 Thread David Isaac
> Alan Isaac wrote:
> > The current situation is:  use a loop because the obvious generator
> > approach is not efficient.


"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "not efficient" compared to what ?

I already guess that I've missed your point, but to prove it...
I was referring to the beginning of this thread
where George noted that
palettes = dict((w,set(w)) for w in words)
runs slower than
palettes={}
for w in words:
   palettes[w]=set(w)
The reason seems obvious: the otiose tuple creation,
but there is no "more efficient" syntax to use with 'dict'.

Alan Isaac


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


Re: How to ask sax for the file encoding

2006-10-04 Thread Edward K. Ream
> The encoding _is_ irrelevant, in the very moment you get unicode strings.

We shall have to disagree about this.  My use case is perfectly reasonable, 
imo.

> If you write out xml again, use whatever encoding suits you best.

What suits me best is what the *user* specified, and that got put in the 
first xml line.
I'm going to have to parse this line myself.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


libgmail: attaching files

2006-10-04 Thread wal
 How does one attach files to emails using libgmail?  The following code
http://pramode.net/articles/lfy/fuse/4.txt
works fine when said files are simple text files, but it failes as soon as 
the files are wild binary files, even attaching the source of an email in a 
text file (.eml files) failes.
What am I missing here? Any hints?
 The output I get when attemting to send binary files using the code above 
is pasted below.

have fun,
wal

--
Traceback (most recent call last):
  File "C:\Documents and 
Settings\lucp1735\Desktop\libgmail-0.1.5.1\knujon.py", line 24, in 
if ga.sendMessage(fs):
  File "C:\Documents and 
Settings\lucp1735\Desktop\libgmail-0.1.5.1\libgmail.py", line 582, in 
sendMessage
msgStr = mimeMessage.as_string()
  File "C:\program files\Python25\lib\email\message.py", line 131, in 
as_string
g.flatten(self, unixfrom=unixfrom)
  File "C:\program files\Python25\lib\email\generator.py", line 84, in 
flatten
self._write(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 109, in 
_write
self._dispatch(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 135, in 
_dispatch
meth(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 201, in 
_handle_multipart
g.flatten(part, unixfrom=False)
  File "C:\program files\Python25\lib\email\generator.py", line 84, in 
flatten
self._write(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 109, in 
_write
self._dispatch(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 135, in 
_dispatch
meth(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 266, in 
_handle_message
g.flatten(msg.get_payload(0), unixfrom=False)
  File "C:\program files\Python25\lib\email\message.py", line 185, in 
get_payload
raise TypeError('Expected list, got %s' % type(self._payload))
TypeError: Expected list, got  


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


Re: preemptive OOP?

2006-10-04 Thread Kent Johnson
Mark Elston wrote:
> * Kent Johnson wrote (on 9/30/2006 2:04 PM):
>> John Salerno wrote:
>>> So my question in general is, is it a good idea to default to an OOP 
>>> design like my second example when you aren't even sure you will need 
>>> it? I know it won't hurt, and is probably smart to do sometimes, but 
>>> maybe it also just adds unnecessary code to the program.
>> In general, no. I'm a strong believer in You Aren't Going to Need It 
>> (YAGNI):
>> http://c2.com/xp/YouArentGonnaNeedIt.html
>>
>> because it *does* hurt
>> - you have to write the code in the first place
>> - every time you see a reference to MyNotebook you have to remind 
>> yourself that it's just a wx.Notebook
>> - anyone else looking at the code has to figure out that MyNotebook is 
>> just wx.Notebook, and then wonder if they are missing something subtle 
>> because you must have had a reason to create a new class...
>>
>> and so on...Putting in extra complexity because you think you will need 
>> it later leads to code bloat. It's usually a bad idea.
>>
>> Possible exceptions are
>> - If you are really, really, really sure you are going to need it 
>> really, really soon and it would be much, much easier to add it now then 
>> after the next three features go in, then you might consider adding it 
>> now. But are you really that good at predicting the future?
>> - When you are working in a domain that you are very familiar with and 
>> the last six times you did this job, you needed this code, and you have 
>> no reason to think this time is any different.
>>
>> You struck a nerve here, I have seen so clearly at work the difference 
>> between projects that practice YAGNI and those that are designed to meet 
>> any possible contingency. It's the difference between running with 
>> running shoes on or wet, muddy boots.
>>
>> Kent
> 
> I have only caught the tail of this thread so far so I may have missed
> some important info.  However, Kent's response is, I think, a bit of
> an oversimplification.
> 
> The answer to the original question, as quoted above, is ... it depends.
> On several things, actually.

Of course.

> However, when an application (or library) is designed to provide a more
> 'general purpose' solution to one or more problems and is likely to have
> a lifetime beyond the 'short term' (whatever that may mean to you), then
> OO can start to pay off.  In these kinds of applications you see the
> need for future maintenance and a likely need to expand on the existing
> solution to add new features or cover new ground.  This is made easier
> when the mechanism for this expansion is planned for in advance.

I am a fan of OOP and use it all the time. I was just arguing against 
using it when it is not called for.
> 
> Without this prior planning, any expansion (not to mention bug fixing)
> becomes more difficult and makes the resulting code more brittle.  While
> not all planning for the future requires OO, this is one mechanism that
> can be employed effectively *because* it is generally well understood
> and can be readily grasped *if* it is planned and documented well.

Unfortunately prior planning is an attempt to predict the future.
Correctly planning for future requirements is difficult. It is possible
to expand code without making it brittle.

Robert Martin has a great rule of thumb - first, do the simplest thing
that meets the current requirements. When the requirements change,
change the code so it will accommodate future changes of the same type.
Rather than try to anticipate all future changes, make the code easy to
change.

> 
> There is certainly a *lot* of 'Gratuitous OOP' (GOOP?) out there.  This
> isn't a good thing.  However, that doesn't mean that the use of OOP in
> any given project is bad.  It may be inappropriate.

In my experience a lot of GOOP results exactly from trying to anticipate 
future requirements, thus introducing unneeded interfaces, factories, etc.

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


Re: can't open chm files all of a sudden

2006-10-04 Thread John Salerno
Dennis Lee Bieber wrote:
> On Wed, 04 Oct 2006 15:55:11 GMT, John Salerno
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
> 
>> the files in a day or two). All I've installed/uninstalled since then 
>> was HTML Kit. I'm not on a network, it's just me. I redownloaded the chm 
>> file for Python24 and it does the same thing.
>>
>   Try some other help files... I'd be likely to suspect it was HTML
> Kit that overlayed some DLL in the help system...
> 
> (Yeesh -- Just looked at the HTML Kit home page... In the words of Clara
> Peller "Where's the beef?"...  Lots of glitzy public relations copy, but
> no details on exactly what it does, what tools it competes with, etc.)

::sigh:: I wouldn't be surprised. I didn't even like it and uninstalled 
it right away anyway. If that's the problem, how would I fix it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can't open chm files all of a sudden

2006-10-04 Thread John Salerno
Gabriel Genellina wrote:
> At Wednesday 4/10/2006 01:32, John Salerno wrote:
> 
>> > I tried opening my Python chm docs just now, as well as the one for
>> > wxPython, and both are giving me an error dialog when I double-click
>> > them and I can't open them. This happened apparently for no reason, 
>> just
>> > today. I even reset but that didn't help.
>> AppName: hh.exe AppVer: 5.2.3790.2453   ModName: itss.dll
>> ModVer: 5.2.3790.2453   Offset: 6bec
> 
> Try this: 

I don't know if this is my problem, but maybe I can find more on this site.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tk: filling a frame with a widget

2006-10-04 Thread jmdeschamps

Paolo Pantaleo wrote:
> I have this code
>
> from Tkinter import *
>
> root=Tk()
> Button(root).pack(fill=BOTH)
> root.mainloop()
>
> I would expect the button filling all the client draw area of the
> Frame, but when I resize the root window the button becomes wider, but
> not higher ( I get some empty space under the button). How could set
> the button to fill always all the space available?
>
> Well maybe some other solution exists, since my problem is this:
>
> I have a resizable window and i want to keep it filled with a Canvas
> displaying an image (PhotoImage). Can I get the in some way the size
> of the clien draw area of the window containig the canvas?
>
> Thnx
> PAolo
>
> --
> if you have a minute to spend please visit my photogrphy site:
> http://mypic.co.nr

you also need to expand it as in
from Tkinter import *

root=Tk()
Button(root).pack(expand=1,fill=BOTH)  #HERE use expand=1 as extra
option
root.mainloop()  

jean-marc

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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Giovanni Bajo
[EMAIL PROTECTED] wrote:

> Giovanni> In fact, are you absolutely positive that you need so
> much Giovanni> effort to maintain an existing bugtracker
> installation?
>
> The development group's experience with SF and I think to a lesser
> extent, Roundup in its early days, and more generally with other
> components of the development toolchain (source code control) and
> python.org website maintenance suggests that some human needs to be
> responsible for each key piece of technology.  Maybe when it's mature
> it needs very little manpower to maintain, but a substantial
> investment is required when the technology is first installed.

One thing is asking for a special help during the transition phase and the
"landing" phase (the first few months). Another thing is asking for "roughly
6-10 people" to install and maintain a Roundup installation. This is simply
not going to realistically happen, and I find it incredible for the PSF
committee to ask for such a high request. Damn, we don't have "roughly 6-10
people" in charge of reviewing patches or fixing bugs.

I followed the GNATS -> Bugzilla transition myself closely, and a single
person (Daniel Berlin) was able to setup the Bugzilla server on the
gcc.gnu.org computer, convince everybody that a transition was needed (and
believe me, this was a hard work), patch it as much as needed to face the
needs of the incredibly picky GCC developers (asking for every little
almost-unused-and-obsoleted feature in GNATS to be replicated in Bugzilla),
and later maintain the installation. It took him approximately one year to
do this, and surely it wasn't full time. After that, he maintains and
administer the Bugzilla installation on his own, by providing upgrades when
needed and a few modifications.

I wonder why the PSF infrastructure committee believes that a group of 6-10
people is needed to "install and maintain" Roundup. Let us also consider
that Roundup's lead developer *was* part of the PSF infrastrucutre
committee, and he might be willing to help in the transition (just my very
wild guess), and he obviously knows his stuff. Also, given the requirement
for the selection, there is already a running roundup installation somewhere
(so the whole pipeline export -> import has already been estabilished and
confirmed to work).

My own opinion is that a couple of person can manage the
transition/migration phase to *any* other bug tracking system, and provide
support in the python-dev mailing list. After the whole thing has fully
landed, I'd be really surprised if a single appointed maintainer would not
be enough.

If the PSF committee lowers its requests to a more realistical amount of
effort, I'm sure we will see many more people willing to help. I think many
people (including myself) would be willing to half-half-help with loose
ends, but when faced with an abnormous "6-10 people" request they just shut
up and sit in a corner.
-- 
Giovanni Bajo


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


Re: preemptive OOP?

2006-10-04 Thread John Salerno
Kent Johnson wrote:

>> There is certainly a *lot* of 'Gratuitous OOP' (GOOP?) out there. 
> 
> In my experience a lot of GOOP results

LOL. Good thing we didn't go with the acronym from my phrase "preemptive 
OOP"  ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Giovanni Bajo
Steve Holden wrote:

> No, I'm not on the infrastructure list, but I know that capable people
> *are*: and you know I am quite capable of donating my time to the
> cause, when I have it to spare (and sometimes even when I don't).
>
> Perhaps what I *should* have written was "Sadly *many* people spend
> too much time bitching and moaning about those that roll their
> sleeves up, and not enough rolling their own sleeves up and pitching
> in".
>
> Sniping from the sidelines is far easier than hard work towards a
> goal.
>
> Kindly note that none of the above remarks apply to you.

The current request is: "please, readers of python-dev, setup a team of 6-10
people to handle roundup or we'll go to a non-free software for bug
tracking".  This is something which I cannot cope with, and I'm *speaking*
up against. Were the request lowered to something more reasonable, I'd be
willing to *act*. I have to speak before acting, so that my acting can
produce a result.

And besides the only thing I'm really sniping the PSF against is about
*ever* having thought of non-FLOSS software. This is something I *really* do
not accept. You have not seen a mail from me with random moaning as "Trac is
better", "Bugzilla is better", "why this was chosen". I do respect the fact
that the PSF committee did a thorough and correct evaluation: I just
disagree with their initial requirements (and I have not raised this point
before because, believe me if you can, I really thought it was obvious and
implicit).

So, if your remarks apply to me, I think you are misrepresenting my mails
and my goals.
-- 
Giovanni Bajo


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


Re: item access time: sets v. lists

2006-10-04 Thread David Isaac
Paul M. wrote:
> Random access to item in list/set when item exists
> set  -> 0.000241650824337
> list -> 0.0245168031132
>
> Random access to item in list/set when item does not exist
> set  -> 0.000187733357172
> list -> 0.522086186932


OK, that's a much better set of answers
including to questions I did not
even know I wanted to ask until
I saw your post.  But, how to
explain the above??

Thanks,
Alan Isaac


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


Is there an alternative to os.walk?

2006-10-04 Thread Bruce
Hi all,
I have a question about traversing file systems, and could use some
help. Because of directories with many files in them, os.walk appears
to be rather slow. I`m thinking there is a potential for speed-up since
I don`t need os.walk to report filenames of all the files in every
directory it visits. Is there some clever way to use os.walk or another
tool that would provide functionality like os.walk except for the
listing of the filenames?

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


Re: How to ask sax for the file encoding

2006-10-04 Thread Rob Wolfe
"Edward K. Ream" <[EMAIL PROTECTED]> writes:

> Can anyone tell me how the content handler can determine the encoding of the 
> file?  Can sax provide this info?

Try this:


from xml.parsers import expat

s = """

Title
Chapter 1

"""

class MyParser(object):
def XmlDecl(self, version, encoding, standalone):
print "XmlDecl", version, encoding, standalone

def Parse(self, data):
Parser = expat.ParserCreate()
Parser.XmlDeclHandler = self.XmlDecl
Parser.Parse(data, 1)

parser = MyParser()
parser.Parse(s)
 

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


Re: item access time: sets v. lists

2006-10-04 Thread Neil Cerutti
On 2006-10-04, David Isaac <[EMAIL PROTECTED]> wrote:
> Paul M. wrote:
>> Random access to item in list/set when item exists
>> set  -> 0.000241650824337
>> list -> 0.0245168031132
>>
>> Random access to item in list/set when item does not exist
>> set  -> 0.000187733357172
>> list -> 0.522086186932
>
>
> OK, that's a much better set of answers
> including to questions I did not
> even know I wanted to ask until
> I saw your post.  But, how to
> explain the above??

Look at the code again. It's not testing what it says it's
testing.

print "\nRandom access to first item in list/set"
t1=timeit.Timer("0 in z","z = set(xrange(1))")
t2=timeit.Timer("0 in z", "z = list(xrange(1))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

print "\nRandom access to item in list/set when item exists"
t1=timeit.Timer("500 in z","z = set(xrange(1))")
t2=timeit.Timer("500 in z", "z = list(xrange(1))")
print "set  ->", t1.timeit(1000)
print "list ->", t2.timeit(1000)

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


Re: switching to numpy and failing, a user story

2006-10-04 Thread [EMAIL PROTECTED]

sturlamolden wrote:
> Travis E. Oliphant wrote:
>
> > Definitely not true.  People in Singapore, Japan, Ghana, South Africa,
> > France, Germany, New Zealand, Australia, and many other countries are
> > using NumPy successfully.  Gratefully, a few have contributed by buying
> > the book, but a lot more have downloaded and are successfully using it.
>
> >From the PayPal site for purchasing your book: "Select Payment Type:
> Don't have a PayPal account? You don't need an account. Pay securely
> using your credit card." I bought the book from Norway using my credit
> card, and received the pdf file soon afterwards. Obviously the book can
> be bought without a PayPal account or a us billing address.

ok, my apologies on this one. I was wrong about the paypal option. I
missed the spot (right at the top, where I should have seen it) to
change the country. There is indeed a way to buy the book if you don't
live in the US.

-greg

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


Re: string: __iter__()?

2006-10-04 Thread mrquantum
John Roth:
 
> The iter() builtin creates an iterator for any
> object that obeys the sequence protocol.
> Since strings obey the sequence protocol there
> is no real advantage to adding yet another
> protocol to an already very fat object.

Okay!

> This  does, however, mean that testing
> for the presence of __iter__ is incomplete;
> one also has to test for __getattr__ if the
> object doesn't have an __Iter__ method.

Should be __getitem__ and not __getattr__!?

> Depending on  your program logic, it
> may be easier to just use iter() and
> handle the exception if it fails.

Okay, I'll do it this way - except will then raise a TypeError, as I just
found in the docs!

> See PEP 234 for a discussion of the
> reasons for doing it this way.
> 

Thanks for pointing this out!

Chris

PS: Thanks to all posters in this thread for your illuminative comments!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ask sax for the file encoding

2006-10-04 Thread Irmen de Jong
Edward K. Ream wrote:

> What suits me best is what the *user* specified, and that got put in the 
> first xml line.
> I'm going to have to parse this line myself.

Please consider adding some elements to the document itself that
describe the desired output format, such as:

...

   utf-8

...

This allows the client to specify the encoding it wants to receive
the document in, even if it's different than the encoding it used
to make the first document. More flexibility. Less fooling around.

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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread fuzzylollipop

Giovanni Bajo wrote:
> Hello,
>
> I just read this mail by Brett Cannon:
> http://mail.python.org/pipermail/python-dev/2006-October/069139.html
> where the "PSF infrastracture committee", after weeks of evaluation, 
> recommends
> using a non open source tracker (called JIRA - never heard before of course)
> for Python itself.
>
> Does this smell "Bitkeeper fiasco" to anyone else than me?
> --
> Giovanni Bajo

No just ignorance you your part!

Jira is given away for free to open source projects that want to use
it. And it just happens to be one of the best issue trackers on the
market, free or paid or opens source or not.

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


Re: preemptive OOP?

2006-10-04 Thread Mark Elston
* Kent Johnson wrote (on 10/4/2006 10:04 AM):
> Mark Elston wrote:
>> ...
>> Without this prior planning, any expansion (not to mention bug fixing)
>> becomes more difficult and makes the resulting code more brittle.  While
>> not all planning for the future requires OO, this is one mechanism that
>> can be employed effectively *because* it is generally well understood
>> and can be readily grasped *if* it is planned and documented well.
> 
> Unfortunately prior planning is an attempt to predict the future.
> Correctly planning for future requirements is difficult. It is possible
> to expand code without making it brittle.
> 

Hmmm

I work in an environment where we plan our 'feature' implementation
several revisions in the future.  We know where we are going because
we have a backlog of end user requests for new features and a limited
pool of people to implement them.

Knowing what will have to change in the future makes this kind of
planning *much* simpler.

However, I still find it a lot easier to plan for change even without
explicit requests than you seem to indicate.  I have worked in the
field for over 10 years now and I have a pretty good idea of the
kinds of things our users will need.  I also have a pretty good idea
of the kinds of things we can introduce that users will find useful.
Planning for the introduction of these things is pretty useful when
we have short turn-around time between revisions and have to implement
any number of new features during these iterations.

And adding new features and handling new requests in a well thought
out manner helps us to keep the system from being brittle.

BTW, the kind of SW we develop is for large pieces of test equipment
used in semiconductor test.  This SW covers the range from embedded and
driver level supporting custom hardware to end-user applications.  There
is simply no way we could survive if we tried to develop software in any
kind of an ad hoc manner.

> Robert Martin has a great rule of thumb - first, do the simplest thing
> that meets the current requirements. When the requirements change,
> change the code so it will accommodate future changes of the same type.
> Rather than try to anticipate all future changes, make the code easy to
> change.
> 

In our case the requirements don't really change.  They do get
augmented, however.  That is, the users will want to continue to do the
things they already can - in pretty much the same ways.  However, they
will also want to do additional things.

Robert's rule of thumb is applied here as well.  We may have a pretty
good idea of where we are going, but we can get by for now implementing
a minimal subset.  However, if we don't anticipate where we are going
to be in the next revision or two it is very likely to entail some
substantial rewrite of existing code when we get there.  That results in
an unacceptable cost of development - both in terms of $$ and time.  Not
only is the code obsoleted, but so are all the components that depend on
the rewritten code and all of the tests (unit and integration) for all
the affected components.

>>
>> There is certainly a *lot* of 'Gratuitous OOP' (GOOP?) out there.  This
>> isn't a good thing.  However, that doesn't mean that the use of OOP in
>> any given project is bad.  It may be inappropriate.
> 
> In my experience a lot of GOOP results exactly from trying to anticipate 
> future requirements, thus introducing unneeded interfaces, factories, etc.

While we do our best to avoid this, it *does* sometimes happen.
However, it is not as much of a problem as the reverse.  If an interface
is developed that turns out not to be very useful, we can always remove
it with very little cost.  If we have to *replace* or substantially
modify an existing mechanism to support a new feature the ripple effect
can cripple our schedule for several release iterations.

OTOH, your point is a good one:  If we really didn't know where we
wanted to be in the future then making a wild guess and heading off
in some random direction isn't likely to be very beneficial either.
In fact it is likely to be more costly in the long run.

That strikes me as "Crap Shoot Development" (a relative of POOP? :) ).

Mark

--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."

  -- Brian Kernighan of C
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: preemptive OOP?

2006-10-04 Thread Mark Elston
* John Salerno wrote (on 10/4/2006 10:18 AM):
> Kent Johnson wrote:
> 
>>> There is certainly a *lot* of 'Gratuitous OOP' (GOOP?) out there. 
>>
>> In my experience a lot of GOOP results
> 
> LOL. Good thing we didn't go with the acronym from my phrase "preemptive 
> OOP"  ;)

Oops.  I couldn't resist.  See my previous post.

Mark


--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."

  -- Brian Kernighan of C
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: switching to numpy and failing, a user story

2006-10-04 Thread [EMAIL PROTECTED]

Travis E. Oliphant wrote:
> [EMAIL PROTECTED] wrote:
> > - I guess I should just buy the documentation. I don't like this idea,
> > because I think it's counter-productive to the project to have payware
> > docs (would Python be successful if you had to buy the documentation? I
> > don't think so), but that's the way this project goes.
>
> It's probably better to call it "complete documentation."  Normal
> open-source documentation is available from http://www.scipy.org.  There
> are lots of people who have helped it.  I had to do something to at
> least pretend to justify the time NumPy took me to the people who care
> about how I spend my time (including my family).   This was the best I
> could come up with.

Given the quality of python's (free) documentation and how good it's
been for a very long time, it's bit ironic to be using the phrase
"normal open-source documentation" on this mailing list. Numeric
python, which numpy aspires to be a replacement for, has perfectly
reasonable documentation. It wasn't perfect, but it told you pretty
much everything you needed to know to get started, use the system, and
build extension modules. I guess this set my expectations for NumPy.

> Or just ask on the mailing lists, use the numpy.oldnumeric interface
> (the differences are all documented in the first few pages of my book
> which is available for free now).

"Ask on the mailing lists" is viable for the occasional question or
detail, but it's not really an efficient way to get started with a
system. At least not for me. But that's fine, I have something that
works (numeric), and I can do what I need to do there.

-greg

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


Re: Is there an alternative to os.walk?

2006-10-04 Thread Irmen de Jong
Bruce wrote:
> Hi all,
> I have a question about traversing file systems, and could use some
> help. Because of directories with many files in them, os.walk appears
> to be rather slow. 

Provide more info/code. I suspect it is not os.walk itself that is slow,
but rather the code that processes its result...

> I`m thinking there is a potential for speed-up since
> I don`t need os.walk to report filenames of all the files in every
> directory it visits. Is there some clever way to use os.walk or another
> tool that would provide functionality like os.walk except for the
> listing of the filenames?

You may want to take a look at os.path.walk then.

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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread A.M. Kuchling
On 04 Oct 2006 06:44:24 -0700, 
Paul Rubin <> wrote:
> Right now there is not even agreement on what the goal is.  

The goal is a new tracker for python.org that the developers like
better; the original call lists 3 reasons (bad interface; lack of
reliability; lack of workflow controls).

> The surprise people are expressing is because they thought one of the
> goals of a big open source project would be to avoid reliance on
> closed tools.

I don't think Python has ever had this as a goal.  Python's license
lets it be embedded in closed-source products; Windows binaries are
built using closed-source tools (MS Visual C), and on some platforms
we use a closed-source system compiler; python.org used to be a
Solaris box, and now uses SourceForge which runs on top of DB/2...

IMHO, using Jira presents risks that are manageable:

* A data export is available if we decide to switch.  Writing a script to
  take this export and convert to a new tracker is non-trivial, but the 
  same is true of any other tracker we might choose; switching from 
  Roundup to Trac or Trac to Launchpad is also going to require some
  effort.  Therefore, I don't think our data is locked-in any more 
  than any other tracker.

* The offer of hosting means this won't consume very much
  administrative time. Perhaps the hosting offered will be found to be
  unreliable.  If that's the case, we can reconsider the choice of
  tracker, or (less likely) host Jira ourselves.

* There are no Bitkeeper-like licensing issues like the non-compete
  clause, so that isn't a factor; Roundup and Trac developers can file
  bugs and use the tracker just like anyone else.

* The interface is very flexible and lots of customization can be done
  through the web.  This means we don't have to hack the code at all,
  and upgrades should theoretically go smoothly.

It would be nice to have the additional tick-box feature 'is open
source', but the upsides are large enough that I can let go of 
that issue with only slight regret.

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


Re: item access time: sets v. lists

2006-10-04 Thread Paul McGuire

"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> Look at the code again. It's not testing what it says it's
> testing.
>

It isnt?

The only quibble I can see is that there really is no "first" element in a 
set.  I picked the "0 in set" and "0 in list" to pick the fastest case for 
list, which does a linear search through the list elements.

Where did I go wrong on the test descriptions?

-- Paul


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


Re: item access time: sets v. lists

2006-10-04 Thread Paul McGuire
"David Isaac" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Paul M. wrote:
>> Random access to item in list/set when item exists
>> set  -> 0.000241650824337
>> list -> 0.0245168031132
>>
>> Random access to item in list/set when item does not exist
>> set  -> 0.000187733357172
>> list -> 0.522086186932
>
>
> OK, that's a much better set of answers
> including to questions I did not
> even know I wanted to ask until
> I saw your post.  But, how to
> explain the above??
>
> Thanks,
> Alan Isaac
>
>

Searching for an item in a list is a linear search, and all 1 items must 
be checked before determining that  a non-existent item is not in the list, 
and sure enough, our list takes about 20 times as long to find that 10500 is 
not in the range 1 as it does to find 500 in the range 1.  By 
contrast, a set (and also the keys in a dict) use a tree structure to index 
more quickly into the list of items, so this access (and determination of 
non-existence) will be much faster, especially so for a large list.

-- Paul


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


Re: PEP 358 and operations on bytes

2006-10-04 Thread bearophileHUGS
Paul Rubin:
> I think the underlying regexp C library isn't written that way.  I can
> see reasons to want a higher-level regexp library that works on
> arbitrary sequences, calling a user-supplied function to classify
> sequence elements, the way current regexps use the character code to
> classify characters.

To begin with something concrete some days ago I was starting to write
a simple RE engine that works on lists/tuples/arrays and uses Psyco in
a good way (but then I have stopped developing it). Once and only once
some good uses has being found, later someone can translate the code to
C, if necessary.
It seems an interesting thing, but can you find some uses for it?

Bye,
bearophile

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


Re: Python crash when trying to generate an Excel worksheet with VBA macros

2006-10-04 Thread hg
dan_roman wrote:
> Hi,
> I developed a script with a nice interface in Tkinter that allows me to
> edit some formulas and to generate an Excel worksheet with VBA macros
> within it. The script runs perfectlly in Office 2000, but in Office
> 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)"
> Please help me :-(
> 
> the code of the module that crash is (only in Excel 2003, in 2000 not):
> 
> import os
> import string
> from win32com.client import Dispatch, constants
> 
> str_code="""
> Dim nrfunc As Integer
> Dim cursor As Integer
> Dim i As Integer
> Dim j As Integer
> 
> 
> 
> Sub Fill()
> 
> 
> 'Aflu numaru de functii din XL
> i = 1
> ..
> """
> def createExcelReport(projectName,templateName,saveToPath):
>   # acquire application object, which may start application
>   application = Dispatch("Excel.Application")
> 
>   # create new file ('Workbook' in Excel-vocabulary) using the specified
> template
>   workbook = application.Workbooks.Add("Template1.xls")
> 
>   # store default worksheet object so we can delete it later
>   defaultWorksheet = workbook.Worksheets(1)
> 
>   worksheet1 = workbook.Worksheets(1)
>   worksheet2 = workbook.Worksheets(2)
>   worksheet3 = workbook.Worksheets(3)
> 
> > wbc = workbook.VBProject.VBComponents.Add(1) -- here
> is the problem
> 
>   wbc.Name="Module1"
> 
>   wbc.CodeModule.AddFromString(str_code)
> 
>   path=saveToPath+"\\"+projectName+"_"+templateName+".xls"
> 
>   workbook.SaveAs(path)
> 
>   worksheet1 = workbook.Worksheets(1)
> 
>   # make stuff visible now.
>   worksheet1.Activate()
>   application.Visible = True
> 

Crash as in Office or as a Python exception ?

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


Re: Python/Tkinter crash.

2006-10-04 Thread Hendrik van Rooyen

 "Eric Brunel" <[EMAIL PROTECTED]> wrote:


> On Wed, 04 Oct 2006 10:33:55 +0200, Hendrik van Rooyen
> <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > I get the following:
> >
> > [EMAIL PROTECTED]:~/Controller/lib> python display.py
> > UpdateStringProc should not be invoked for type font
> > Aborted
> >
> > and I am back at the bash prompt - this is most frustrating, as there is
> > no
> > friendly traceback to help me guess where its coming from.
> >
> > And what is worse, the script runs for a varying time before it simply
> > exits
> > like this.
> >
> > What can I do to dig deeper to try to find a clue? - I don't even know
> > if its
> > Python, Tkinter or Linux...
>
> Neither of them: it's a tcl problem. The message you get is in the file
> generic/tclObj.c in the tcl source directory.
>
> I know the problem happens sometimes on one of my Tkinter applications,
> but I never succeeded in reproducing it systematically. I've browsed the
> tcl bugs, but didn't find anything. Maybe you'll be luckier than I... If
> you are, I'm interested in any hint you can find.

Ouch! - this is a bit the wrong answer...

What I have seen, in mucking about today, is that it seems to be related to
threading - I have a silly sort of thread that runs, updating my meters, more or
less continuously, to simulate data from the field - it just adds some values to
the seven display variables and calls the update methods that delete and redraw
the arcs representing the analogue style meters, deleting and replacing the text
objects that show the values, and then it sleeps for a while, and does it all
again.

At the same time, one other thread (other than the main thread), can be created
to move a component on the canvas around by calling its delete and draw
methods. - but this is also done more or less continuously, as a new thread is
created as soon as the previous one dies to move the next object around.

Now these two things are asynchronous with each other, so that given enough
time, they are bound to make calls to Tkinter in a re-entrant fashion, and I
suspect that it is this that is causing the problem - my "evidence" for this is
that I implemented a boolean as a sort of "lock" and had the Meter updating back
down in favour of the other animation to try and avoid any sort of re - entrancy
to the Tkinter canvas object's  delete and draw methods...

Now the Jury is still out on this - it seems to have helped, as the thing has
been running for some hours now without crashing - but maybe I have just applied
a band aid to sword cut - I don't know - if it runs through the night I will
feel much better...

Will update again as soon as I have more data...

- Hendrik


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


Re: Python/Tkinter crash.

2006-10-04 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>,
 "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:

>Hi,
>
>I get the following:
>
>[EMAIL PROTECTED]:~/Controller/lib> python display.py
>UpdateStringProc should not be invoked for type font
>Aborted
>...
>Everything seems to work fine. - there is a thread that runs to move the meter
>values around continuously, and this has been stable for some time now, and I
>can get the various "machine" parts to move around the screen by pushing the
>buttons...

You mention threads several times in your posting. Do you have multiple 
threads talking to Tkinter? If so, try recoding to avoid this (e.g. by 
having the background threads communicate with the main thread via 
Queues).

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


Re: PEP 358 and operations on bytes

2006-10-04 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> > I think the underlying regexp C library isn't written that way.  I can
> > see reasons to want a higher-level regexp library that works on
> > arbitrary sequences, calling a user-supplied function to classify
> > sequence elements, the way current regexps use the character code to
> > classify characters.
> ...It seems an interesting thing, but can you find some uses for it?

Yes, I want something like that all the time for file scanning without
having to resort to parser modules or hand coded automata.
-- 
http://mail.python.org/mailman/listinfo/python-list


Having trouble using CTypes with a custom function

2006-10-04 Thread tkondal
Hi all.

I just started looking at Python's ctypes lib and I am having trouble
using it for a function.

For starters, here's my Python code:


from ctypes import*;
myStringDLL= cdll.LoadLibrary("myStringDLL.dll");

GetMyString = getattr(myStringDLL,
"?GetMyString@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL 
PROTECTED]@2@@std@@@Z")

strString =  create_string_buffer('\000' * 256);
GetMyString.restype = c_int;
GetMyString.argtypes = [c_char_p];

bResult = GetMyString (strSerialNumber);

print (bResult);
print (strSerialNumber);

#C++ Prototype of the function I want to call:
#bool GetMyString (string& stringParam) ;




I do not have access to the source code of this function so don't ask
me to try different things in C++.  This DLL is working fine.

The problem that I have is that print (strSerialNumber) does not seem
to print the correct string.  What I get is some garbage value of
unprintable characters.  Am I using this the correct way?

Thanks.

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


Re: Having trouble using CTypes with a custom function

2006-10-04 Thread Chris Mellon
On 4 Oct 2006 11:18:16 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi all.
>
> I just started looking at Python's ctypes lib and I am having trouble
> using it for a function.
>
> For starters, here's my Python code:
>
>
> from ctypes import*;
> myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
>
> GetMyString = getattr(myStringDLL,
> "?GetMyString@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL 
> PROTECTED]@2@@std@@@Z")
>
> strString =  create_string_buffer('\000' * 256);
> GetMyString.restype = c_int;
> GetMyString.argtypes = [c_char_p];
>
> bResult = GetMyString (strSerialNumber);
>
> print (bResult);
> print (strSerialNumber);
>
> #C++ Prototype of the function I want to call:
> #bool GetMyString (string& stringParam) ;
>
>
>
>
> I do not have access to the source code of this function so don't ask
> me to try different things in C++.  This DLL is working fine.
>
> The problem that I have is that print (strSerialNumber) does not seem
> to print the correct string.  What I get is some garbage value of
> unprintable characters.  Am I using this the correct way?
>




This function is expecting a C++ std::string object, not a regular C
style string. You'll need a wrapper function, and one which uses the
same compiler and STL as the C++ source.

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


Re: Having trouble using CTypes with a custom function

2006-10-04 Thread tkondal
Would you have any example of a wrapper for such data types?

Thanks.

Chris Mellon wrote:
> On 4 Oct 2006 11:18:16 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Hi all.
> >
> > I just started looking at Python's ctypes lib and I am having trouble
> > using it for a function.
> >
> > For starters, here's my Python code:
> >
> >
> > from ctypes import*;
> > myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
> >
> > GetMyString = getattr(myStringDLL,
> > "?GetMyString@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL 
> > PROTECTED]@2@@std@@@Z")
> >
> > strString =  create_string_buffer('\000' * 256);
> > GetMyString.restype = c_int;
> > GetMyString.argtypes = [c_char_p];
> >
> > bResult = GetMyString (strSerialNumber);
> >
> > print (bResult);
> > print (strSerialNumber);
> >
> > #C++ Prototype of the function I want to call:
> > #bool GetMyString (string& stringParam) ;
> >
> >
> >
> >
> > I do not have access to the source code of this function so don't ask
> > me to try different things in C++.  This DLL is working fine.
> >
> > The problem that I have is that print (strSerialNumber) does not seem
> > to print the correct string.  What I get is some garbage value of
> > unprintable characters.  Am I using this the correct way?
> >
>
>
>
>
> This function is expecting a C++ std::string object, not a regular C
> style string. You'll need a wrapper function, and one which uses the
> same compiler and STL as the C++ source.
>
> > Thanks.
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >

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


Re: Having trouble using CTypes with a custom function

2006-10-04 Thread Chris Mellon


On 4 Oct 2006 11:35:11 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Would you have any example of a wrapper for such data types?
>
> Thanks.
>
> Chris Mellon wrote:
> > On 4 Oct 2006 11:18:16 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > Hi all.
> > >
> > > I just started looking at Python's ctypes lib and I am having trouble
> > > using it for a function.
> > >
> > > For starters, here's my Python code:
> > >
> > >
> > > from ctypes import*;
> > > myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
> > >
> > > GetMyString = getattr(myStringDLL,
> > > "?GetMyString@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL 
> > > PROTECTED]@2@@std@@@Z")
> > >
> > > strString =  create_string_buffer('\000' * 256);
> > > GetMyString.restype = c_int;
> > > GetMyString.argtypes = [c_char_p];
> > >
> > > bResult = GetMyString (strSerialNumber);
> > >
> > > print (bResult);
> > > print (strSerialNumber);
> > >
> > > #C++ Prototype of the function I want to call:
> > > #bool GetMyString (string& stringParam) ;
> > >
> > >
> > >
> > >
> > > I do not have access to the source code of this function so don't ask
> > > me to try different things in C++.  This DLL is working fine.
> > >
> > > The problem that I have is that print (strSerialNumber) does not seem
> > > to print the correct string.  What I get is some garbage value of
> > > unprintable characters.  Am I using this the correct way?
> > >
> >
> >
> >
> >
> > This function is expecting a C++ std::string object, not a regular C
> > style string. You'll need a wrapper function, and one which uses the
> > same compiler and STL as the C++ source.
> >
> > > Thanks.
> > >
> > > --
> > > http://mail.python.org/mailman/listinfo/python-list
> > >
>

in this case it'd be very simple:

bool WrapGetMyString(char * c) {
  return GetMyString(c)
}


(Note: This isn't unicode safe).

The C++ compiler will handle converting from the char * to the std::string.





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


Re: Having trouble using CTypes with a custom function

2006-10-04 Thread tkondal
Hi Chris.

I know that it is easy to fix the problem using C++.  However, I do not
want to code a wrapper DLL.  I was wondering if there was a workaround
with Python. Everything has to be done in Python as we do not have the
tools for C++ (and we are not planning on getting any).

Thanks.

Chris Mellon wrote:
> 
>
> On 4 Oct 2006 11:35:11 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Would you have any example of a wrapper for such data types?
> >
> > Thanks.
> >
> > Chris Mellon wrote:
> > > On 4 Oct 2006 11:18:16 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > > Hi all.
> > > >
> > > > I just started looking at Python's ctypes lib and I am having trouble
> > > > using it for a function.
> > > >
> > > > For starters, here's my Python code:
> > > >
> > > >
> > > > from ctypes import*;
> > > > myStringDLL= cdll.LoadLibrary("myStringDLL.dll");
> > > >
> > > > GetMyString = getattr(myStringDLL,
> > > > "?GetMyString@@[EMAIL PROTECTED]@[EMAIL PROTECTED]@@[EMAIL 
> > > > PROTECTED]@2@@std@@@Z")
> > > >
> > > > strString =  create_string_buffer('\000' * 256);
> > > > GetMyString.restype = c_int;
> > > > GetMyString.argtypes = [c_char_p];
> > > >
> > > > bResult = GetMyString (strSerialNumber);
> > > >
> > > > print (bResult);
> > > > print (strSerialNumber);
> > > >
> > > > #C++ Prototype of the function I want to call:
> > > > #bool GetMyString (string& stringParam) ;
> > > >
> > > >
> > > >
> > > >
> > > > I do not have access to the source code of this function so don't ask
> > > > me to try different things in C++.  This DLL is working fine.
> > > >
> > > > The problem that I have is that print (strSerialNumber) does not seem
> > > > to print the correct string.  What I get is some garbage value of
> > > > unprintable characters.  Am I using this the correct way?
> > > >
> > >
> > >
> > >
> > >
> > > This function is expecting a C++ std::string object, not a regular C
> > > style string. You'll need a wrapper function, and one which uses the
> > > same compiler and STL as the C++ source.
> > >
> > > > Thanks.
> > > >
> > > > --
> > > > http://mail.python.org/mailman/listinfo/python-list
> > > >
> >
>
> in this case it'd be very simple:
>
> bool WrapGetMyString(char * c) {
>   return GetMyString(c)
> }
>
>
> (Note: This isn't unicode safe).
>
> The C++ compiler will handle converting from the char * to the std::string.
>
>
>
> 
> 
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >

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


Re: item access time: sets v. lists

2006-10-04 Thread Duncan Booth
"Paul McGuire" <[EMAIL PROTECTED]> wrote:

> By contrast, a set (and also the keys in a dict) use a tree structure
> to index more quickly into the list of items

'dict' and I believe also 'set' use a hash table, not a tree structure.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: item access time: sets v. lists

2006-10-04 Thread Neil Cerutti
On 2006-10-04, Paul McGuire <[EMAIL PROTECTED]> wrote:
> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>
>> Look at the code again. It's not testing what it says it's
>> testing.
>
> It isnt?
>
> The only quibble I can see is that there really is no "first"
> element in a set.  I picked the "0 in set" and "0 in list" to
> pick the fastest case for list, which does a linear search
> through the list elements.
>
> Where did I go wrong on the test descriptions?

It seems to be timing "testing for membership", not "random
access". Random access is just seq[n]; at least, that's the
assumption I made.

Perhaps I read the test description out of context and got
confused.

-- 
Neil Cerutti
8 new choir robes are currently needed, due to the addition of
several new members and to the deterioration of some of the
older ones. --Church Bulletin Blooper 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Paul Boddie
Giovanni Bajo wrote:
>
> The current request is: "please, readers of python-dev, setup a team of 6-10
> people to handle roundup or we'll go to a non-free software for bug
> tracking".

Actually, it would appear that the request goes out to
comp.lang.python/python-list as well (ie. the ungrateful plebs like
myself who supposedly have nothing to contribute to the direction of
the Python project).

[...]

> And besides the only thing I'm really sniping the PSF against is about
> *ever* having thought of non-FLOSS software.

It has already been brought up that Python plays well with everyone and
everything, and thus a closed source tool projects the attitudes of the
core developers. However, in contrast to the use of tools such as
Roundup which have some advocacy value, the adoption of commercial
products often works largely in favour of the vendor: they're seen to
be helpful and charitable (which they may well be), and there's a
certain level of publicity value generated from the transaction (albeit
not as much as if the Bugzilla project switched over to a closed source
issue tracker).

Of course, this message so far probably passes for "being political" in
the eyes of certain people, but I think it's interesting to put such
decisions in the context of the calls to advocacy that people come out
with every now and again. Indeed, I believe that the PSF now have an
advocacy coordinator to lead the onslaught selling Python into
"business" or whatever people regard Python advocacy to be these days.
However, as an open source project it doesn't necessarily send a good
message to "business" that the amazing processes that drive Python
development are powered by closed source software (although they also
have been through the use of SourceForge) and that the developers
passed over a project that they were quite happy to use promotionally
once upon a time.

Indeed, while it was still running, the Software Carpentry competition
(the initiative which led to the development of Roundup) was potent
publicity material showing that Python and open source development
produce great software. The risk is that "business" looks at the level
of self-belief ("don't mention the competition by name" [1], but where
the competition isn't just other languages: it's also other development
methodologies) and wonders whether they wouldn't be better off with
some closed source development environment for their closed source
commercial product instead.

I guess what plebs like myself are supposed to take away from this is
the following: if the core developers are subsequently much more
productive developing the language (which is not exactly the thing
which requires most attention in the Python distribution these days, in
my opinion), then who are we to complain as long as we can still stuff
our bugs into some Web-based interface or other?

Paul

[1]
http://holdenweb.blogspot.com/2006/03/marketing-why-do-you-use-python.html

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


Re: item access time: sets v. lists

2006-10-04 Thread [EMAIL PROTECTED]
David Isaac wrote:
> Paul M. wrote:
> > Random access to item in list/set when item exists
> > set  -> 0.000241650824337
> > list -> 0.0245168031132
> >
> > Random access to item in list/set when item does not exist
> > set  -> 0.000187733357172
> > list -> 0.522086186932
>
>
> OK, that's a much better set of answers
> including to questions I did not
> even know I wanted to ask until
> I saw your post.  But, how to
> explain the above??

The code was flawed, but it illustrates a point.  To find an arbitrary
item in a list takes time proportional to the length of the list--on
average, you have to scan n/2 items in a list of length n to find it.
"x in list" really has to check item 0, item 1, item 2, etc until it
finds x or reaches the end of the list.

Obviously in a sorted list like this, finding 0 will be much faster
than finding  since you have to scan almost the whole list to find
the latter.  Of course, if you know the list is sorted you could use a
binary search (which will find the item in log(n) comparisons on
average).

So really to find a random item that is in the list is going to take
more like 0.250 seconds on average, give or take a little.

When the item doesn't occur in the list, you wind up having to check
every element to see if it's there.  (binary search would work for this
case as well for a sorted list).

A set, on the other hand, uses a hash table so finding an element takes
constant time (it's one hash lookup, independent of the size of the
set)--and determining an item isn't there is likewise constant time.

(if your data is degenerate and you have many things in the set that
all hash to the same value then the lookup could take longer, but
that's pretty unlikely to make a big difference in practice with python
sets and user data).

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


Re: Is there an alternative to os.walk?

2006-10-04 Thread waylan
Bruce wrote:
> Hi all,
> I have a question about traversing file systems, and could use some
> help. Because of directories with many files in them, os.walk appears
> to be rather slow. I`m thinking there is a potential for speed-up since
> I don`t need os.walk to report filenames of all the files in every
> directory it visits. Is there some clever way to use os.walk or another
> tool that would provide functionality like os.walk except for the
> listing of the filenames?

You might want to check out the path module [1] (not os.path). The
following is from the docs:

> The method path.walk() returns an iterator which steps recursively
> through a whole directory tree. path.walkdirs() and path.walkfiles()
> are the same, but they yield only the directories and only the files,
> respectively.

Oh, and you can thank Paul Bissex for pointing me to path [2].

[1]: http://www.jorendorff.com/articles/python/path/
[2]: http://e-scribe.com/news/289

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


Re: How to ask sax for the file encoding

2006-10-04 Thread Fredrik Lundh
Edward K. Ream wrote:

> I'm asking this question because my app needs it :-)  Imo, there is *no* 
> information in any xml file that can be considered irrelvant.

the encoding isn't *in* the XML file, it's an artifact of the 
serialization model used for a specific XML infoset.  the XML
data is pure Unicode.



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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread David Goodger
Giovanni Bajo wrote:
> The current request is: "please, readers of python-dev, setup a team of 6-10
> people to handle roundup or we'll go to a non-free software for bug
> tracking". This is something which I cannot cope with, and I'm *speaking*
> up against. Were the request lowered to something more reasonable, I'd be
> willing to *act*.

No, the announcement stated the situation in a very different way.

Asking for a group of maintainers to commit to an essential piece of
infrastructure is perfectly reasonable. Brett didn't ask for 6-10 full
time developer/sysadmins. He asked for typical commitment, which is up
to a few hours per week. The initial work will probably be significant,
but will undoubtedly taper off over time.

Go back to the original announcement:

"""
After evaluating the trackers on several points (issue creation,
querying, etc.), we reached a tie between JIRA and Roundup in terms of
pure tracker features.
"""

JIRA gets a leg up because of the hosting and administration also being
offered. But...

"""
If enough people step forward we will notify python-dev that Roundup
should be considered the recommendation of the committee and graciously
turn down Atlassian's offer.
"""

That is a perfectly reasonable offer. Put up or shut up.

> And besides the only thing I'm really sniping the PSF against is about
> *ever* having thought of non-FLOSS software. This is something I *really* do
> not accept. ... I just
> disagree with their initial requirements (and I have not raised this point
> before because, believe me if you can, I really thought it was obvious and
> implicit).

That just shows that you were being naïve. The initial requirements
were published openly and clearly.

> I do respect the fact
> that the PSF committee did a thorough and correct evaluation:

Yes, they did, and you should be thanking them instead of complaining.

If you feel so strongly, please volunteer.

-- David Goodger

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


Re: item access time: sets v. lists

2006-10-04 Thread Paul McGuire
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 2006-10-04, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> "Neil Cerutti" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>
>
> It seems to be timing "testing for membership", not "random
> access". Random access is just seq[n]; at least, that's the
> assumption I made.
>
> Perhaps I read the test description out of context and got
> confused.
>

Oh, poor wording on my part, sorry.

You got me wondering what seq[n] would give me in the case of a set:

>>> z = set(range(100))
>>> z[30]
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: unindexable object
>>>

It really doesn't make any sense since sets are unordered.  So we couldn't 
compare lists and sets in this manner anyway.

I *did* learn that dicts and sets use a hash table, not a tree, which also 
helps explain why the initial construction of the 1-element set takes so 
much longer than just simple assembly of the range into a list.

-- Paul


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


Re: How to ask sax for the file encoding

2006-10-04 Thread Fredrik Lundh
Edward K. Ream wrote:

> What suits me best is what the *user* specified, and that got put in the 
> first xml line.

are you expecting your users to write XML by hand?  ouch.



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


Find out the name of a variable passed as an argument

2006-10-04 Thread Andreas Huesgen
Hello everybody,

is there a way to receive the name of an object passed to a function 
from within the function.

something like

def foo(param):
print theNameOfTheVariablePassedToParam

var1 = "hello"
var2 = "world"

 >>> foo(var1)
var1

 >>> foo(var2)
var2

thanks in advance,

greets

Andreas Huesgen

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


Re: item access time: sets v. lists

2006-10-04 Thread Paul McGuire
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Paul McGuire" <[EMAIL PROTECTED]> wrote:
>
>> By contrast, a set (and also the keys in a dict) use a tree structure
>> to index more quickly into the list of items
>
> 'dict' and I believe also 'set' use a hash table, not a tree structure.

Thanks, I stand corrected.  How do they know how big a hash table to use?  I 
think this is an interesting problem.

-- Paul


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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> No, actually switching trackers can be one big pain in the ass.  You
> probably aren't aware of how hard it's been for the Python development team
> (I think Martin v. Loewis, mostly) to get tracker data out of SF.

http://effbot.org/zone/sandbox-sourceforge.htm



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


Re: PEP 358 and operations on bytes

2006-10-04 Thread Fredrik Lundh
John Machin wrote:

> But not on other integer subtypes. If regexps should not be restricted
> to text, they should work on domains whose number of symbols is greater
> than 256, shouldn't they?

they do:

import re, array

data = [0, 1, 1, 2]

array_type = "IH"[re.sre_compile.MAXCODE == 0x]

a = array.array(array_type, data)

m = re.search(r"\x01+", a)

if m:
 print m.span()
 print m.group()



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


CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
I'm just building a Python CGI Tutorial and would appreciate any
feedback from the many experts in this list.

Regards, Clodoaldo Pinto Neto

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


Re: CGI Tutorial

2006-10-04 Thread Tim Chase
> I'm just building a Python CGI Tutorial and would appreciate
> any feedback from the many experts in this list.

First item of feedback...post something on which to give 
feedback, such as a link to the work in progress. :)

-tkc



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


Re: Find out the name of a variable passed as an argument

2006-10-04 Thread Fredrik Lundh
Andreas Huesgen wrote:

> is there a way to receive the name of an object passed to a function 
> from within the function.

objects don't have names, so in general, you cannot do that.  see:

http://pyfaq.infogami.com/how-can-my-code-discover-the-name-of-an-object



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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread skip

>> No, actually switching trackers can be one big pain in the ass.  You
>> probably aren't aware of how hard it's been for the Python
>> development team (I think Martin v. Loewis, mostly) to get tracker
>> data out of SF.

Fredrik> http://effbot.org/zone/sandbox-sourceforge.htm

Thanks for the memory jog.  Before you wrote your scraper/downloader I seem
to recall there were several only-semi-successful attempts to get SF to
themselves dump the tracker data for us.  That was what I was referring to.

Skip


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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Martin v. Löwis
Giovanni Bajo schrieb:
>>> I hope this
>>> recommendation from the "PSF infrastructure committee" is rejected.
>> That is very very unlikely. Who would reject it, and why?
> 
> The community, and I am impressed you do not want to understand the "why".

How would "the community" actually reject it? By not using it? Well,
that won't happen: They use the current SF tracker, despite it being
non-free software.

> It is an extremely bad picture for an open source flag like Python to go to a
> vendor for such an easy requirement as a bug database. 

You fail to recognize that Python is *already* using a non-free software
for bug tracking, as do thousands of other projects. So from that point
of view, the status wouldn't change.

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


Re: CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
Clodoaldo Pinto Neto wrote:
> I'm just building a Python CGI Tutorial and would appreciate any
> feedback from the many experts in this list.

http://webpython.codepoint.net

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


Re: CGI Tutorial

2006-10-04 Thread Clodoaldo Pinto Neto
Clodoaldo Pinto Neto wrote:
> I'm just building a Python CGI Tutorial and would appreciate any
> feedback from the many experts in this list.

http://webpython.codepoint.net

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


Re: How to ask sax for the file encoding

2006-10-04 Thread Edward K. Ream
> are you expecting your users to write XML by hand?

Of course not.  Leo has the following option:

@string new_leo_file_encoding = utf-8

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Martin v. Löwis
Giovanni Bajo schrieb:
> In fact, are you absolutely positive that you need so much effort to
> maintain an existing bugtracker installation? I know for sure that GCC's
> Bugzilla installation is pretty much on its own; Daniel Berlin does some
> maintainance every once in a while (upgrading when new versions are out,
> applying or writing some patches for most requested features in the
> community, or sutff like that), but it's surely not his job, not even
> part-time.

Daniel Berlin has put a tremendous amount of work into it. I know,
because I set up the first bug tracker for gcc (using GNATS), and
have been followed the several years of pondering fairly closely.
It was quite some work to set up GNATS, and it was even more work
to setup bugzilla.

For Python, we don't have any person similar to Daniel Berlin
(actually, we have several who *could* have done similar work,
 but none that ever volunteered to do it). Don't underestimate
the work of somebody else.

I know that I'm currently putting more time into maintaining the
Subversion installation than I'd like to, despite this being a really
small amount of work per month, and despite others also having been
introduced to the infrastructure necessary for administration.
When I go on vacation, people effectively have to wait until
I return before they can get their write access enabled. I
sometimes defer dealing with admin requests for a few days, and
people start complaining.

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


Re: How to ask sax for the file encoding

2006-10-04 Thread Edward K. Ream
> Please consider adding some elements to the document itself that
describe the desired output format,

Well, that's what the encoding field in the xml line was supposed to do. 
Not a bad idea though, except it changes the file format, and I would really 
rather not do that.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: How to ask sax for the file encoding

2006-10-04 Thread Edward K. Ream
> the encoding isn't *in* the XML file, it's an artifact of the 
> serialization model used for a specific XML infoset.  the XML
> data is pure Unicode.

Sorry, but no.  The *file* is what I am talking about, and the way it is 
encoded does, in fact, really make a difference to some users.  They have a 
right, I think, to expect that the original encoding gets preserved when the 
file is rewritten.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Martin v. Löwis
Giovanni Bajo schrieb:
> Frankly, I don't give a damn about the language the application is coded in

That's probably one of the reasons why you aren't a member of the Python
Software Foundation. Its mission includes to publicize, promote the
adoption of, and facilitate the ongoing development of Python-related
technology and educational resources. So the tracker being written in
Python is quite of importance.

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


Re: Find out the name of a variable passed as an argument

2006-10-04 Thread John Henry
Algol, anyone?


Andreas Huesgen wrote:
> Hello everybody,
>
> is there a way to receive the name of an object passed to a function
> from within the function.
>
> something like
>
> def foo(param):
>   print theNameOfTheVariablePassedToParam
>
> var1 = "hello"
> var2 = "world"
>
>  >>> foo(var1)
> var1
>
>  >>> foo(var2)
> var2
> 
> thanks in advance,
> 
> greets
> 
> Andreas Huesgen

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


Re: PEP 358 and operations on bytes

2006-10-04 Thread bearophileHUGS
A simple RE engine written in Python can be short, this is a toy:
http://paste.lisp.org/display/24849
If you can't live without the usual syntax:
http://paste.lisp.org/display/24872

Paul Rubin:
> Yes, I want something like that all the time for file scanning without
> having to resort to parser modules or hand coded automata.

Once read a file is a string or unicode. On them you can use normal
REs. If you need list-REs you probably slit the data in some parts. Can
you show one or more examples where you think simple list-REs can be
useful?

Bye,
bearophile

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


Re: dictionary of list from a file

2006-10-04 Thread [EMAIL PROTECTED]
limodou wrote:
> here is my program
>
> d = {}
> for line in file('test.txt'):
> line = line.strip()
> if line:
> k, v = line.strip().split()
> d.setdefault(k, []).append(v)
> print d

Minor nits: you call strip twice, when you don't need to.  just omit
the second call.
Also, I'm not sure stripping the line is the right thing per the spec;

d = {}
for line in [l[:-1] for l in file('test.txt', 'rU') if len(l)>1]:
k,v = line.split()
d.setdefault(k,[]).append(v)

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


Re: item access time: sets v. lists

2006-10-04 Thread Duncan Booth
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> A set, on the other hand, uses a hash table so finding an element
> takes constant time (it's one hash lookup, independent of the size of
> the set)--and determining an item isn't there is likewise constant
> time. 
> 
One hash calculation, but there could be collisions. Worst case for an n
element dict/set could be that it takes n attempts to find a value, 
although unless you try to do it deliberately by ensuring that the keys 
have identical hash values this won't happen in practice.

Paul McGuire wrote:
> Thanks, I stand corrected.  How do they know how big a hash table to
> use?  I think this is an interesting problem.

If I read the code correctly:

Minimum size is 8. Whenever more than 2/3 of the slots are in use 
(including slots where the element has been deleted) the dictionary is 
resized to the smallest power of 2 (greater than 8) which is greater than 4 
times the number of currently occupied slots (or 2 times the number of 
occupied slots when more than 5 slots are occupied). This can reduce 
the size if a lot of elements have been deleted.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CGI Tutorial

2006-10-04 Thread Tim Chase
>> I'm just building a Python CGI Tutorial and would appreciate any
>> feedback from the many experts in this list.
> 
> http://webpython.codepoint.net


Thanks! :)

My first note would be regarding

http://webpython.codepoint.net/shell_commands

The code is very dangerous...allowing any ol' schmoe to run 
arbitrary code on your server.  At the barest of minimums, I'd 
plaster the code with warnings that this is a Very Dangerous 
Thing(tm) to do.  Preferably, one would want to have fixed sets 
of commands, something like

install_django = 'curl...'
if command=='install_django': sub.Popen(install_django, ...)

so that only trusted code is run, not arbitrary things like

'wget -r http://evil.example.com'

or

'rm -rf /'

which would just be bad.

Similarly, regarding

http://webpython.codepoint.net/debugging

you might want to caution that this will/can display potentially 
sensitive information (passwords, internal file-structure, etc), 
and thus should only be used while debugging, and turned off in 
any sort of production code.

The section on single vs. multiple field names was pretty good at 
giving a nice overview that there are *two* scenarios one might 
encounter.

Just a little feedback, whether from an expert or otherwise. :)

-tkc


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


Where is Python in the scheme of things?

2006-10-04 Thread gord
As a complete novice in the study of Python, I am asking myself where this 
language is superior or better suited than others. For example, all I see in 
the tutorials are lots of examples of list processing, arithmetic 
calculations - all in a DOS-like environment.

What is particularly disappointing is the absence of a Windows IDE, 
components and an event driven paradigm. How does Python stand relative to 
the big 3, namely Visual C++, Visual Basic and Delphi? I realize that these 
programming packages are quite expensive now while Python is free (at least 
for the package I am using - ActivePython).

Please discuss where Python shines.
Gord


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


Re: Python to use a non open source bug tracker? - Trac?

2006-10-04 Thread Martin v. Löwis
Harry George schrieb:
> I'm not on the infrastructure list either.  But I wonder why it is
> "Roundup or else non-python COTS"?  I gave up on Roundup a while ago
> due to too many crashes.  I'm now using Trac:
> 
> a) Open Source
> b) Python
> c) Adequate functionality (for me at least)
> 
> http://trac.edgewall.org/
> 
> I'm not trying to "sell" Trac, but I would like to know what drove the
> developers away from it.

IMO, the biggest concern was that it didn't really "scale". I.e. if you
have a thousand open and several thousand closed reports in the
database, you need excellent support for queries, sorting, and alike.
Trac doesn't quite have the same power that the other tools do.
For example, to save a query/report, you actually have to write it in
SQL. For a complex report (with multiple groups), you cannot change
the order of items returned on the page (for a simple search, clicking
on the headings changes the order).

To see what I mean, please try to find out how many open reports
for the module "report system" are currently entered in the tracker
at

http://trac.edgewall.org/report

How many of these are for 0.9.x?

There is also searching, which doesn't give a tabular view of all
tickets, but instead gives a Web search result page (similar
to what a search engine produces). This makes it difficult to scan
systematically for, say, all titles.

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


Re: Having trouble using CTypes with a custom function

2006-10-04 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
> Hi all.
>
> I just started looking at Python's ctypes lib and I am having trouble
> using it for a function.
[...]
> #C++ Prototype of the function I want to call:

ctypes  provides support for calling functions in C libraries, using C
datatypes.  I don't see any reason to believe it would work with other
languages (e.g. C++).

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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Paul Rubin
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:
> You fail to recognize that Python is *already* using a non-free software
> for bug tracking, as do thousands of other projects. 

I don't think that reflects an explicit decision.  SF started out as
free software and the software became nonfree after people were
already using it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Martin v. Löwis
[EMAIL PROTECTED] schrieb:
> No, actually switching trackers can be one big pain in the ass.  You
> probably aren't aware of how hard it's been for the Python development team
> (I think Martin v. Loewis, mostly) to get tracker data out of SF.  An
> explicit requirement was that any tool chosen as a SF replacement be able to
> easily export its database to avoid this sort of "lock-in" in the future.

While I put quite some effort into getting data out of SF, it was
Fredrik Lundh who eventually implemented the solution that we'll use:
screen scraping. My efforts to get data out of SF "officially"
were futile.

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


Re: How to ask sax for the file encoding

2006-10-04 Thread Edward K. Ream
> Try this:
[snip]
Parser.XmlDeclHandler = self.XmlDecl
[snip]

Excellent!  Thanks so much.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: Where is Python in the scheme of things?

2006-10-04 Thread Fredrik Lundh
gord wrote:

> What is particularly disappointing is the absence of a Windows IDE, 
> components and an event driven paradigm. How does Python stand relative to 
> the big 3, namely Visual C++, Visual Basic and Delphi?

if you think those are the "big 3", you should perhaps start by asking 
yourself where *you* are in the scheme of things.



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


Re: Python to use a non open source bug tracker?

2006-10-04 Thread Martin v. Löwis
Paul Boddie schrieb:
> Out of interest, here are some figures:
> 
>   KDE: 12983 bugs and 11656 wishes
>   GNOME: 23624 reports
>   Python: 7159 bugs, 3843 patches, 477 feature requests
> 
> The Python figures are totals, whereas I can't be sure whether the KDE
> and GNOME figures merely refer to the open issues. Nevertheless, Python
> isn't going to be pushing the envelope.

Right: machine power isn't really an issue (although the snappiness
of response does contribute to usability: the various installations
showed noticable differences in response time).

The issue of scalability is really how a large number of reports
can be managed. How can a submitter easily find out whether a report
for some issue already exists, and how can a maintainer easily find
out what needs most attention (where each developer might apply
her own priority system)? For a small number of issues, you can
scan through a list. If the list contains more than 20 entries,
scanning through it becomes tedious.

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


Re: py2app semi-standalone semi-works

2006-10-04 Thread James Stroud
Dave Opstad wrote:
> In article <[EMAIL PROTECTED]>,
>  James Stroud <[EMAIL PROTECTED]> wrote:
>>I am trying to create a semi-standalone with the vendor python on OS X 
>>10.4 (python 2.3.5). I tried to include some packages with both 
>>--packages from the command and the 'packages' option in setup.py. While 
>>the packages were nicely included in the application bundle in both 
>>cases (at Contents/Resources/lib/python2.3/), they were not found by 
>>python when the program was launched, giving the error:
>>
>> "ImportError: No module named [whatever module]"
> 
> You might want to have a setup.cfg file in addition to the setup.py 
> file. I've found that helps ensure the relevant packages and includes 
> make it into the bundled application.
> 
> For example, say you have a package named fred and also a separate 
> module named george that are needed for your app. Your setup.cfg could 
> look like this:
> 
> #
> # setup.cfg
> #
> 
> [py2app]
> packages=fred
> includes=george
> 
> You can also have a section for [py2exe] if needed; that way, if there 
> are modules that your Windows build needs that the Mac build doesn't (or 
> vice versa), you can just include them where needed.
> 
> Dave

Hi Dave,

Thank your for pointing me to setup.cfg. I make standalones for windows, 
linux, and OS X, so it will definitely help take some of the confusion 
out of my setup.py.

However, when passing trying to build semi-standalone, the module does 
make it into the application bundle, but the python interpreter doesn't 
seem to know where to find it. Is there something I can specify in 
setup.cfg or setup.py that will point the interpreter to the included 
module, or will I need to make another test and programmatically set 
sys.path inside of my python code? If this is solved by setup.cfg, then 
forgive me--I haven't had a chance to try it yet.

Below is the relevant part of my setup.py.

James

=
APP = ['%s.py' % appname]
DATA_FILES = []
OPTIONS = {
  'argv_emulation': True,
  'strip' : True,
  'packages'  : packages,
  'iconfile'  : '%s.icns' % appname,
   }

if not os.path.exists('dist'):
   setup(
   app=APP,
   name=appname,
   data_files=DATA_FILES,
   options={'py2app': OPTIONS},
   setup_requires=['py2app'],
   )
else:
   print 'Directory "dist" exists. Doing nothing.'
=


-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

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


Re: sax barfs on unicode filenames

2006-10-04 Thread Martin v. Löwis
Fredrik Lundh schrieb:
> Diez B. Roggisch wrote:
> 
>> Filenames are expected to be bytestrings. So what happens is that the
>> unicode string you pass as filename gets implicitly converted using the
>> default encoding.
> 
> it is ?

Yes. While you can pass Unicode strings as file names to many Python
functions, you can't pass them to Expat, as Expat requires the file name
as a byte string. Hence the error.

Regards,
Martin

P.S. and just to anticipate nit-picking: yes, you can pass a Unicode
string to Expat, too, as long as the Unicode string only contains
ASCII characters. And yes, it doesn't have to be ASCII, if you change
the system default encoding.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is Python in the scheme of things?

2006-10-04 Thread James Stroud
gord wrote:
> As a complete novice in the study of Python, I am asking myself where this 
> language is superior or better suited than others. For example, all I see in 
> the tutorials are lots of examples of list processing, arithmetic 
> calculations - all in a DOS-like environment.
> 
> What is particularly disappointing is the absence of a Windows IDE

I'm a complete windows novice (as in I've forced myself to forget my 
experiences with it), but does windows not run vim?

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

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


Re: sax barfs on unicode filenames: workaround

2006-10-04 Thread Martin v. Löwis
Edward K. Ream schrieb:
> Happily, the workaround is easy.  Replace theFile with:
> 
> # Use cStringIo to avoid a crash in sax when inputFileName has unicode 
> characters.
> s = theFile.read()
> theFile = cStringIO.StringIO(s)
> 
> My first attempt at a workaround was to use:
> 
> s = theFile.read()
> parser.parseString(s)
> 
> but the expat parser does not support parseString...

Right - you would have to use xml.sax.parseString (which is a global
function, not a method).

Of course, parseString just does what you did: create a cStringIO
object and operate on that.

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


Re: switching to numpy and failing, a user story

2006-10-04 Thread Travis Oliphant
[EMAIL PROTECTED] wrote:
> Travis E. Oliphant wrote:
> 
> 
> Given the quality of python's (free) documentation and how good it's
> been for a very long time, it's bit ironic to be using the phrase
> "normal open-source documentation" on this mailing list. Numeric
> python, which numpy aspires to be a replacement for, has perfectly
> reasonable documentation. 

And it is still perfectly useful.  Only a couple of details have 
changed.  The overall description is still useful.

It wasn't perfect, but it told you pretty
> much everything you needed to know to get started, use the system, and
> build extension modules. I guess this set my expectations for NumPy.
> 

This documentation was written largely due to funding from a national 
laboratory.  I didn't have those resources.  If somebody wanted to step 
up to the plate and make me an offer, the NumPy docs could be free as 
well.  So far, people have been content to buy it a piece at a time.

> 
> "Ask on the mailing lists" is viable for the occasional question or
> detail, but it's not really an efficient way to get started with a
> system. At least not for me. But that's fine, I have something that
> works (numeric), and I can do what I need to do there.


Absolutely,  that's the advantage of open source.  If the world moves a 
head you don't *have* to.  It's entirely your choice. There is no lock-in.


-Travis

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


  1   2   3   4   >