Re: Tkinter or wxpython?

2007-08-05 Thread Raúl Gómez C.
Well, for a newbie I think the best choice is
PythonCard,
is a framework based on wxPython but much more simple, check it out!

On 8/3/07, Glenn Hutchings <[EMAIL PROTECTED]> wrote:
>
> On Aug 3, 1:00 am, "wang frank" <[EMAIL PROTECTED]> wrote:
> > I want to build a GUI to execut python script. I found TKinter and
> > wxpython. Which one is easier for a newbie? and which one is better?
>
> Well, Tkinter comes with Python, so newbies can get up and running
> straight away without having to download and install anything else.
> And there are probably lots more examples out there that a newbie can
> look at and learn from.  As for *better*, wxPython has a lot more
> kinds of widgets in it, which will make writing GUIs less tedious in
> the long run, and the widgets look a lot nicer too.
>
> Glenn
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Pyscripter

2007-08-05 Thread RichSaneSwindler
I think that pyscripter is the most promising Python IDE around and I
am exciting about its possibilities. However, I find a few issues with
it annoying enough that I don't use it. They seem easily fixed in
which case I think it would be superior to most IDEs. I am wondering
if any users out there would like to add to/debate this list of
benefits and issues (for reference I am using Pyscripter

Pyscripter Benefits:

- very fast, stable GUI (compare this with Wing IDE which is
horrendously slow)
- screen lay it clean and uncluttered
- source completion is lightning fast and I like the option to search
files for selected modules
- source completion searches submodules (as in "os.path.")
- function search, etc.

Pyscripter Issues:

1. smart tabbing:
a. If I place the cursor anywhere in a, hitting the tab should
properly indent the line to (most often) the unique correct place or
(less often) to its best guess as to where to tab. Right now the
editor inserts a tab, which I never want to do.
a  Smart tabbing for multiline expressions (eg expressions broken
within parens) does not work well.

2. there is no source completion for local variables (or at least I
cannot figure out how to use it). This is a major difference between
it and Wing IDE.

3. source completion is easily fooled. If I type "os.path.join(fnam"
and then backspace to "os.path.jo", the completion menu does not come
back up. The same statement goes for the tooltips for functions.

4. lack of emacs key bindings as an option: yes you can add them, but
adding shortcuts is very difficult due to the fact that key bindings
are listed in both the IDE and Editor options section.

5. poor module handling in debugger mode/within the editor. I have not
fully figured out what is going on, but a modules behavior during
debugging or execution within the editor does not fully match behavior
outside of it. E.g., when you run a module in debugger mode its
behavior is not the same as if you run it from the command prompt. I
think that the module is not loaded. To see this, create a module and
type "print __file__" in some function. This will work from the
command prompt but not from the module. If you add "from module-name
import __file__" this solves it, but you should not have to do that.

6. No "Doc String" list. It would be nice if when you put the cursor
over a function a window would display the full docstrings of the
function.

7. The function tool tips (ie what you see when you hover over a
function or open parens) are primitive looking and could show more of
the functions docstrings.
- poor module re-loading. If I import moduleA into moduleB and then
change moduleA, when I debug, the change is not reloaded (as far as I
can tell). This is aggravating.

8. lack of "IPython" like interface in the shell. Would be nice if
emacs keybindings were available.

9. (would be nice) Refactoring capabilities (ala Eclipse's
capabilities, especially for Python)

10. The web page http://pyscripter.googlepages.com/  has a much newer
build than http://mmm-experts.com/Products.aspx?ProductId=4.

I want to emphasize again that despite this lists length I think the
core aspects of the system (speed and stability) are far and away
better than anything else I have used.

Thank you,

Neil Chriss

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


Re: Pyscripter

2007-08-05 Thread Stef Mientki
RichSaneSwindler wrote:
> I think that pyscripter is the most promising Python IDE around
but for windows only !
  and I
> am exciting about its possibilities. However, I find a few issues with
> it annoying enough that I don't use it. They seem easily fixed in
> which case I think it would be superior to most IDEs. I am wondering
> if any users out there would like to add to/debate this list of
> benefits and issues (for reference I am using Pyscripter
> 

Neil,
PyScripter has it's own discussion list
   http://groups.google.com/group/PyScripter/topics?hl=en
and from my own experiences,
I know that Kiriakos (the designer) is very willing to listen to good ideas,
and if they are good he'll implement them in no time !

cheers,
Stef
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [pyconuk] pyweek is happening august 02 - august 09

2007-08-05 Thread John Pinner
Hello All,

On 04/08/07, Laura Creighton <[EMAIL PROTECTED]> wrote:
> 00:00 UTC 2007-09-02 to 00:00 UTC 2007-09-09 exactly.  See
> www.pyweek.org
>
> PyconUK is happening.  http://www.pyconuk.org/ 8th and 9th September.
>
> This means that those of us who generally do not see each other but are
> going to PyconUK could put together an entry and then sprint together
> on it before PyCon UK.  There would be this terrible torment -- do
> I attend the con or get my game to work -- but it is still the
> best chance some of us have to work together yet.
>
> Talk to me if you are interested in maybe making a PyconUK pygame
> team.  I think that this could be a lot of fun.  Sign up on
> www.pyweek.org if you think so, as well.  But mail me.
>
> John -- assuming we want to meet up _before_ PyConUK -- can that
> work?

Yes, we'd really like to see you at PyCon UK, and the games!

We have sprint facilities available for two days before and two days
after PyCon UK. They are at 95 Broad Street, about ten minutes walk
from the Conference venue. There is a fat pipe internet connection.
There are three rooms available, one has 10 high spec workstations
which can be pre-installed with the o/s of your choice, for the other
rooms you'd need your own laptops. There are places nearby to buy
cheap food (a local supermarket and the usual fast food and sandwich
shops).

> Can you point us at a cheap hostel for a few days?

Looking at http://www.pyconuk.org/accommodation.html :

The budget buys are the Etap (conference hotel) and Birmingham
Backpackers, they are also furthest from the sprint location, say 25
and 30 minutes walk respectively (I haven't timed these). Basically,
you can stay at either of these for less than £20 if you share.

Also worth considering are the Comfort Zone serviced apartments, the
ones in Townsend Street are about ten minutes walk from the sprint
venue, less to the conference.

The nearest hotel is the Novotel (where we're holding the conference
dinner) at 70 Broad Street, 2 minutes from the sprint and 10 from the
Conference. You should be able to get an online deal for about £69 for
a double room. Just behind the Novotel is the Premier Travel Inn,
slightly less at say £65 for a double. There are two Travel Inns in
the area, sprinters would want the Birmingham Broad Street (Brindley
Place) one.

A good compromise between cost and convenience for the sprinters would
be the Travelodge, just across the road from the sprint at 230 Broad
Street, where you can get a family room (sleeps 3 adults plus one
child, 4 adults at a push) for £66.

One of the PyCon UK delegates has been finding cheap accommodation in
the area, and I'll ask him to contact you directly, Laura.

Best wishes,

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


Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.

2007-08-05 Thread SMERSH009
On Aug 4, 8:25 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Aug 4, 9:21?pm, "Jim Langston" <[EMAIL PROTECTED]> wrote:
>
>
>
> > <[EMAIL PROTECTED]> wrote in message
>
> >news:[EMAIL PROTECTED]
>
> > > On Aug 4, 6:35?pm, SMERSH009 <[EMAIL PROTECTED]> wrote:
> > >> Hi All.
> > >> Let's say I have some badly formatted text called doc:
>
> > >> doc=
> > >> """
> > >> friendid
> > >> Female
>
> > >> 23 years old
>
> > >> Los Gatos
>
> > >> United States
> > >> friendid
> > >> Male
>
> > >> 24 years old
>
> > >> San Francisco, California
>
> > >> United States
> > >> """
>
> > >> How would I get these results to be displayed in a format similar to:
> > >> friendid;Female;23 years old;Los Gatos;United States
> > >> friendid;Male; 24 years old;San Francisco, California;United States
>
> > >> The latter is a lot easier to organize and can be quickly imported
> > >> into Excel's column format.
>
> > >> Thanks Much,
> > >> Sam
>
> > > d = doc.split('\n')
>
> > > f = [i.split() for i in d if i]
>
> > > g = [' '.join(i) for i in f]
>
> > > rec = []
> > > temprec = []
> > > for i in g:
> > >if i:
> > >if i == 'friendid':
> > >rec.append(temprec)
> > >temprec = [i]
> > >else:
> > >temprec.append(i)
> > > rec.append(temprec)
>
> > > output = [';'.join(i) for i in rec if i]
>
> > > for i in output: print i
>
> > > ##friendid;Female;23 years old;Los Gatos;United States
> > > ##friendid;Male;24 years old;San Francisco, California;United States
>
> > also, I would suggest you use CSV format.
>
> Well, the OP asked for a specific format. One is not
> always at liberty to change it.
>
> > CSV stands for "Comma Seperated
> > Variable" and Excel can load such a sheet directly.
>
> And Excel can load the shown format directly also,
> just specify the delimiter.
>
>
>
> > Instead of seperating using ; seperate using ,  Of course, this provides a
> > problem when there is a , in a string.
>
> Which explains the popularity of using tabs as delimiters.
> The data deliverable specification I use at work
> uses the pipe character | which never appears as data
> in this particular application.
>
> > Resolution is to quote the string.
>
> Which makes the file bigger and isn't necessary
> when tabs and pipes are used as delimiters.
>
> > Being such, you can just go ahead and quote all strings.  So you would want
> > the output to be:
>
> > "friendid","Female","23 years old","Los Gatos","United States"
> > "friendid","Male","24 years old","San Francisco, California","United States"
>
> Which I would do if I had a specification that
> demanded it or was making files for others. For my
> own use, I wouldn't bother as it's unnecessary work.
>
>
>
> > Numbers should not be quoted if you wish to treat them as numeric and not
> > text.
>
> A good reason not to use quotes at all. Besides which,
> Excel can handle that also.

Thanks for all your posts guys.
mensanator's was the most helpful, and I only ended up needing to use
a few lines from that code.
The only question that remains for me--and this is just for my
knowledge-- what does the "if i" mean in this code snippet?
f = [i.split() for i in d if i]
How is it helpful to leave a dangling "if i"? Why not just f =
[i.split() for i in d]?

And yes John, this was indeed a "homework question." It was for my
daughter's preschool. You are going to help her ace her beginner
Python class! (No, this was not a homework question).

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


Re: xlrd question

2007-08-05 Thread has
On Aug 4, 1:48 am, [EMAIL PROTECTED] wrote:

> I ran your code which gave me this:
>
> >>> import sys, xlrd; print sys.version; print xlrd.__file__
>
> 2.3.5 (#1, Jan 30 2006, 13:30:29)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)]
> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site 
> -packages/
> xlrd/__init__.pyc

Note that:

/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/
site-packages

is actually just a symlink to:

/Library/Python/2.3/site-packages

While third-party modules do usually go in python2.x/site-packages,
Apple don't like users messing about in /System so their stock Python
installation keeps third-party modules under /Library instead.

The exact location varies depending on OS version: on 10.3 it's /
Library/Python/2.3; on 10.4 it's /Library/Python/2.3/site-packages.
Modules installed via DistUtils/EasyInstall will be placed in the
appropriate location automatically.

For more information on installing DistUtils packages, see:

http://docs.python.org/inst/inst.html


> and as far as I can tell, the runxlrd.py file is located here (where I had 
> drug this folder
> originally):
>
> Macintosh HD/xlrd-0.6.1/scripts/runxlrd.py

Nope,  DistUtils will copy all modules to site-packages as part of the
installation procedure. If you're a developer you'll probably want to
keep the original distribution around as it'll contain documentation,
examples, etc. which you'll want to refer to when writing your own
scripts. End-users of your scripts won't need it though.

([OT] Tip: dumping user files under / is poor etiquette; that's what
your home directory under /Users is for.)


> While I'm talking about Excel, is there any other program (for Python) that 
> can edit Excel files?

You can script Excel directly from Python via appscript which talks to
scriptable Mac apps via the same API as AppleScript:

http://appscript.sourceforge.net

I don't do any Excel scripting myself, but Matt Neuburg includes a
nice example in this article on the Ruby version of appscript (which
has a similar syntax):

http://www.oreillynet.com/pub/a/mac/2007/02/27/replacing-applescript-with-ruby.html

If you need more info just ask.

HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

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


Re: Best way to capture output from an exec'ed (or such) script?

2007-08-05 Thread Gabriel Genellina
En Sat, 04 Aug 2007 18:52:16 -0300, [EMAIL PROTECTED]  
<[EMAIL PROTECTED]> escribió:

>> On Aug 2, 7:32 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:>  
>> If your web server is multithreaded (or you use some other way to  
>> process
>> > many simultaneous requests) you have to be more careful - remember  
>> that
>> > sys.stdout is global, you must find a way to distinguish between  
>> output
>> >  from different processes all going into the same collector.
>
> I'm actually worried about this now.  Does anyone know of any
> potential solutions?  Anything to at least get me started?

You can use threading.currentThread() to distinguish between threads, and  
a Lock (or RLock) to ensure the output doesn't get mixed:

def write(msg):
 t = time.strftime("%x %X", time.localtime())
 who = threading.currentThread().getName()
 line = "%s (%-15.15s) %s\n" % (t, who, msg)
 OutputDebugString("%s (%-15.15s) %s\n" % (t, who, msg))
 loglock.acquire()
 try:
 with logfile() as f:
 f.write(line)
 finally:
 loglock.release()

-- 
Gabriel Genellina

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


Re: (no) fast boolean evaluation ? missing NOT

2007-08-05 Thread Gabriel Genellina
En Fri, 03 Aug 2007 11:56:07 -0300, Roel Schroeven  
<[EMAIL PROTECTED]> escribió:

> Paul Boddie schreef:
>> On 3 Aug, 11:45, Stef Mientki <[EMAIL PROTECTED]> wrote:
>>> Sorry, my question missed the essential "NOT",
>>> here is an example, that behaves different in Delphi,
>>> (so I guess Delphi is not a real language ;-)
>>
>> Delphi is based on Pascal, and from what I can recall from my
>> university textbook, there isn't any mandatory short-circuit
>> evaluation in Pascal: it's an implementation-dependent feature.
>> Consequently, an expression involving boolean operators in such
>> languages may well evaluate each term (potentially causing side-
>> effects) before determining the final result.
>
> I even thought Pascal never uses short-circuit evaluation, and always
> evaluates all terms. I might be wrong about that though; it's been quite
> a long time since I've used Pascal.

Delphi defaults to short-circuit, but there is a compiler switch to make  
it evaluate all the arguments.
But most people rely on this, and write code like:

if (MyObject <> nil) and (MyObject.Event <> nil) then MyObject.Event(Self);

and that would break if not short-circuited.

-- 
Gabriel Genellina

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


Best programs written completly in Python

2007-08-05 Thread Franz Steinh�usler
Hello NG,

wWhat are the best programs in your opinion, written entirly
in pyhton, divided into categories like:
a) Games
b) Utilities/System
c) Office
d) Web/Newsreader/Mail/Browser
...

I don't want to start a long thread, if a site of such
an discussion already exists, a link will be enough.

Many thanks in advance!

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


Re: File Handling & TRY/EXCEPT

2007-08-05 Thread Gabriel Genellina
En Fri, 03 Aug 2007 10:38:17 -0300, Robert Rawlins - Think Blue  
<[EMAIL PROTECTED]> escribió:

> Thanks for your ideas guys,
>
> I'm unfortunately tied to 2.4 so don't have the full try except status,  
> but
> I'm now working with the following code:
>
>   def addApp(self, event):
>   try:
>   logfile =
> open('/pblue/new/Logs/Application.csv','a')
>
>   now = datetime.datetime.now()
>   logstring = '%s,%s \n' % (event, str(now))
>   
>   try:
>   logfile.write(logstring)
>   finally:
>   logfile.close()
>   except:
>   self.addApp(event)
>
> I'm trying to slowly debug my app and get rid of all the memory leaks,  
> but
> its pain staking work, any help you can offer on that stuff would be a  
> god
> send, I'm a little reluctant about posting all my app code on the lists  
> as
> I'd like to keep some of it private.
>
> How does that new version look? A little tidier?

If the logging error is rather permanent (disk full) or a programming  
error (e.g. you forget to import datetime) this will cause an infinite  
recursion. Don't try to log again, at least not the same way.
The version below writes to the console when a logging error happens. And  
note the reordered open/try/finally: you want to ensure that after a call  
to open, no matter what happens, the file will be closed.

def addApp(self, event):
 try:
 now = datetime.datetime.now()
 logstring = '%s,%s \n' % (event, str(now))
 logfile = open('/pblue/new/Logs/Application.csv','a')
 try:
 logfile.write(logstring)
 finally:
 logfile.close()
 except:
 print >>sys.stderr, "%s: %s while attempting to log event '%s'" % (
 sys.exc_info()[0], sys.exc_info()[1], event)


-- 
Gabriel Genellina

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


Re: Submit web form only client-side with Python? COM?

2007-08-05 Thread Gabriel Genellina
En Sat, 04 Aug 2007 19:17:35 -0300, Jay Loden <[EMAIL PROTECTED]>  
escribió:

> Paul Rubin wrote:
>> goldtech <[EMAIL PROTECTED]> writes:
>>> So I can present the user with an HTML form in it - but how can I
>>> write the form data to a local file on my work station?
>>
>> The simplest way is with the cgi and CGIHTTPServer modules.  You'd
>> write your form in an html file, with the target set to a Python
>
> CGIHTTPServer is not available on Windows (OP said they are on Win XP)

CGIHTTPServer does work on Windows (even on Python 2.1, as far as I can  
go) and using it might be simple enough.

> due to
> use of fork and exec to execute the CGI.

CGIHTTPServer uses popen2 or popen3 if available.

> I suggested a few other options in my
> reply, but unfortunately CGIHTTPServer is not an option for this task.

I can't see any other reply from you on this thread... (I'm using the  
gmane newsgroup interfase)

-- 
Gabriel Genellina

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


A question on plugin design

2007-08-05 Thread Grzegorz Słodkowicz
I'm working on my little project (an IM client) which I wanted to 
support plugins. My idea was that the core program would by itself do 
virtually nothing but manage plugins and all functionality would be 
provided by the plugins themselves (including protocol handling and UI. 
My first attempt was to check a directory for *.py files, execfile() 
them and rely on them to call a method to register a plugin object. This 
approach led to some conundrums and I discarded the it as bad design. My 
second take was to __import__() from each plugin file the plugin object 
and append it to a list of all plugins. But, this way I have to put 
imports into the __init__() of the plugin object or else they have no 
effect. Is this a valid approach? I'm starting to think that such 
problems are again symptoms of poor design.

I'd also be grateful for pointers to a well designed Pythonic plugin 
architecture but I'd much prefer a small project with a simple API.

TIA,
Greg Slodkowicz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best programs written completly in Python

2007-08-05 Thread O.R.Senthil Kumaran
* Franz Steinh?usler <[EMAIL PROTECTED]> [2007-08-05 12:14:38]:

> wWhat are the best programs in your opinion, written entirly
> in pyhton, divided into categories like:
> a) Games
> b) Utilities/System
> c) Office
> d) Web/Newsreader/Mail/Browser

Its a difficult question to answer as the software are aplenty and there is no
judgement basis as this one is the best.

Head on to www.python.org and see for yourself for programs under each
category.

And moreover, "written entirely in python" is a constrain to find the
programs. Why do you need such a list for?

-- 
O.R.Senthil Kumaran
http://uthcode.sarovar.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best programs written completly in Python

2007-08-05 Thread BJörn Lindqvist
On 8/5/07, Franz Steinhäusler <[EMAIL PROTECTED]> wrote:
> Hello NG,
>
> wWhat are the best programs in your opinion, written entirly
> in pyhton, divided into categories like:
> a) Games
> b) Utilities/System
> c) Office
> d) Web/Newsreader/Mail/Browser

For b; trac: http://trac.edgewall.org/ There actually isn't that many
widespread programs written in Python.

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


Re: Best programs written completly in Python

2007-08-05 Thread Campbell Barton
O.R.Senthil Kumaran wrote:
> * Franz Steinh?usler <[EMAIL PROTECTED]> [2007-08-05 12:14:38]:
> 
>> wWhat are the best programs in your opinion, written entirly
>> in pyhton, divided into categories like:
>> a) Games
>> b) Utilities/System
>> c) Office
>> d) Web/Newsreader/Mail/Browser
> 
> Its a difficult question to answer as the software are aplenty and there is no
> judgement basis as this one is the best.
> 
> Head on to www.python.org and see for yourself for programs under each
> category.
> 
> And moreover, "written entirely in python" is a constrain to find the
> programs. Why do you need such a list for?

Of course this is totally objective, but that dosnt mean its not a valid 
question.

If you were starting out a project were thinking of writing it in 
python, you might want to look at whats out there - maybe python has 
limitations which stops it being a good choice in some situations (for 
instance?)- on the other hand you might want to see some shining 
examples that prove the capabilities of python ;)

'Being written entirely in python' - is a bit tricky, often these 
applications rely on some specific extension or make heavy use of a 
backend that dosnt come with python (like pygame, pygtk, or py-gstreamer).

Games - See Pygame http://www.pygame.org/projects/6


Utilities/System

* meld is a really nice diffing tool for linux - http://meld.sourceforge.net
* ubuntu have some of their install tools in python.
* txt2tags - a great markup language for doc writing. - 
http://txt2tags.sourceforge.net/
* sound recording/editing - http://www.jokosher.org

Office?? - no idea, openoffice can be scripted in python.

Web - * isnt bit torrent python?, probably lots of stuff but I dont know 
of them ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best programs written completly in Python

2007-08-05 Thread Franz Steinh�usler
On Sun, 05 Aug 2007 12:14:38 +0200, Franz Steinhäusler
<[EMAIL PROTECTED]> wrote:

>Hello NG,
>
>wWhat are the best programs in your opinion, written entirly
>in pyhton, divided into categories like:

Many thanks,

The restriction, I want, is to comply the programs written in pygame, 
pygtk, wxPython, tkinter or console programs.

There are really "high sophisticated" programs, if you don't mind my
naming it so, as:

XPN newsreader, Boa Constructor, many pygame programs, 
gtkrawgallery, cornice graphics viewer, ...

I'm only interested to have a list, or even help to 
extend an existing one.

On wxPython, there also exist such a list:

http://wiki.wxpython.org/wxPythonPit_Apps
-- 
Franz Steinhaeusler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the "functional" way of doing this?

2007-08-05 Thread Arnau Sanchez
> On Jul 30, 5:48 pm, beginner  wrote:
> 
>> def f(n):
>>  l=[]
>>  while n>0:
>>  l.append(n%26)
>>  n /=26
>> return l
>>
>> I am wondering what is the 'functional' way to do the same.
>>

  > I see. It is interesting (and not surprisingly) that recursion or
> yield are required. Thanks for everyone's help.

Why not use both recursion and generators?

def f2(n):
 if n > 0:
 n2, x = divmod(n, 26)
 yield x
 for next in f2(n2):
 yield next

Could this be considered functional?

Anyway, I wonder if there is a more elegant way to do the "yield x... yield 
next" part. Any ideas?

arnau

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


Re: Best programs written completly in Python

2007-08-05 Thread David Boddie
On Sun Aug 5 14:44:55 CEST 2007, Franz Steinhäusler wrote:

> I'm only interested to have a list, or even help to 
> extend an existing one.

If the main criterion is that the programs are written in Python then
surely the PythonInfo Wiki is the place for such a list:

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

May I suggest that you extend this one?

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


Re: Comparing RFC1123 based Dates

2007-08-05 Thread Douglas Wells
In article <[EMAIL PROTECTED]>,
  Phoe6 <[EMAIL PROTECTED]> writes:
> Phoe6 wrote:
> > I would like to parse RFC 1123 date format and compare two dates. I
> > find that
> > datetime module does not specifically confirms to any RFC. Any
> > suggestions as how I can handle the RFC 1123 date format using
> > standard libraries before I go to re based parsing?
> 
> Well,
> >>> import time
> >>> timeobj = time.strptime("Thu, 01 Dec 1994 16:00:00 GMT","%a, %d %b %Y 
> >>> %H:%M:%S %Z")
> 
> was easy.

Well, it might have been easy, but it's got several gotchas (in
both Python and C), including:

  - The zone field (%Z) only corresponds for the GMT and UT timezones,
which are obsolete (see RFC 2822).  There is no support for
the recommended +/-time-offset form.

  - The day-of-week (%a) and month (%b) fields in strptime and
strftime are subject to the process's locale, whereas the RFC
time forms are not.  Those are hardwired to names that happen
to correspond to the C, POSIX, and probably most of the en_*
locales, but not to others that would be used by billions of
people.  Thus anyone using your program who doesn't happen to
reside in one of the English-speaking countries (or does and
is using a native locale) is likely to encounter problems when
using your program.

  - The day-of-week field is optional.

  - Comments are allowed (but deprecated) in the whitespace fields
of the time format.  (On the other hand, I've never seen this
is normal e-mail.)

I find the use of strptime and strftime difficult enough to manage
with Internet date/times that I restrict my use of them to programs
that are limited to processing date/times.  Even then, I then
explicitly set the locale (LC_TIME) to the "C" locale.  Otherwise,
I use ad hoc code that explicitly recognizes the RFC-defined forms.

-- 
.   Douglas Wells .  Connection Technologies  .
.   Internet:  -sp9804- -at - contek.com- .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (no) fast boolean evaluation ?

2007-08-05 Thread Paddy
On Aug 4, 5:33 pm, Paddy <[EMAIL PROTECTED]> wrote:
> On Aug 4, 4:18 pm, Paddy <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 2, 10:47 pm, Stef Mientki <[EMAIL PROTECTED]>
> > wrote:
>
> > > hello,
>
> > > I discovered that boolean evaluation in Python is done "fast"
> > > (as soon as the condition is ok, the rest of the expression is ignored).
>
> > > Is this standard behavior or is there a compiler switch to turn it on/off 
> > > ?
>
> > > thanks,
> > > Stef Mientki
>
> > The following program shows a(clumsy)? way to defeat the short-
> > circuiting:
>
> > def f(x):
> >   print "f(%s)=%s" % ('x',x),
> >   return x
> > def g(x):
> >   print "g(%s)=%s" % ('x',x),
> >   return x
>
> > print "\nShort circuit"
> > for i in (True, False):
> >   for j in (True, False):
> > print i,j,":", f(i) and g(j)
>
> > print "\nShort circuit defeated"
> > for i in (True, False):
> >   for j in (True, False):
> > print i,j,":", g(j) if f(i) else (g(j) and False)
>
> > The output is:
>
> > Short circuit
> > True True : f(x)=True g(x)=True True
> > True False : f(x)=True g(x)=False False
> > False True : f(x)=False False
> > False False : f(x)=False False
>
> > Short circuit defeated
> > True True : f(x)=True g(x)=True True
> > True False : f(x)=True g(x)=False False
> > False True : f(x)=False g(x)=True False
> > False False : f(x)=False g(x)=False False
>
> > - Paddy.
>
> And here are the bits for boolean OR:
>
> print "\n\nShort circuit: OR"
> for i in (True, False):
>   for j in (True, False):
> print i,j,":", f(i) or g(j)
>
> print "\nShort circuit defeated: OR"
> for i in (True, False):
>   for j in (True, False):
> print i,j,":", (g(j) or True) if f(i) else g(j)
>
> - Paddy.

Dumb!
 Use & and |
Gosh That port last night was good ;-)

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


Re: Comparing RFC1123 based Dates

2007-08-05 Thread Steve Holden
Phoe6 wrote:
> I would like to parse RFC 1123 date format and compare two dates. I
> find that
> datetime module does not specifically confirms to any RFC. Any
> suggestions as how I can handle the RFC 1123 date format using
> standard libraries before I go to re based parsing?
> 
I realise you want to stick to the standard library. If you decide you 
can't however, you should definitely take a look at mx.DateTime, as the 
mx.DateTime.ARPA submodule provides exactly what you require.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: the one python book

2007-08-05 Thread Thorsten Kampe
* dhr (Sat, 4 Aug 2007 16:23:49 +0300)
> Is there a 'K&R" type of Python book? The book that you'd better have on 
> your shelf if you are going into Python? 

For Tutorials STFW but the one and only book is definitely "Python in 
a Nutshell" from Alex "Python" Martelli. Get the second edition.

The other book I would go for is the "Python Cookbook" from Martelli 
and others.

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


Re: Best programs written completly in Python

2007-08-05 Thread Franz Steinh�usler
On Sun, 05 Aug 2007 15:35:53 +0200, David Boddie <[EMAIL PROTECTED]>
wrote:

>On Sun Aug 5 14:44:55 CEST 2007, Franz Steinhäusler wrote:
>
>> I'm only interested to have a list, or even help to 
>> extend an existing one.
>
>If the main criterion is that the programs are written in Python then
>surely the PythonInfo Wiki is the place for such a list:
>
>  http://wiki.python.org/moin/Applications
>
>May I suggest that you extend this one?
>
>David

David, thank you very much, perfect! :)
-- 
Franz Steinhaeusler
-- 
http://mail.python.org/mailman/listinfo/python-list


RDF Library / Py 2.5

2007-08-05 Thread Justin Donato
Hello,

 

Can I install the win32 binaries for the Redland RDF library if I have
Python 2.5 installed? The latest .exe that I can find is for Python 2.4.

HYPERLINK "http://librdf.org/"http://librdf.org/

 

(I’m new to Python and this list.)

 

-Justin


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.4/936 - Release Date: 8/4/2007
2:42 PM
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Best programs written completly in Python

2007-08-05 Thread Franz Steinh�usler
On Sun, 05 Aug 2007 21:31:23 +1000, Campbell Barton
<[EMAIL PROTECTED]> wrote:

>O.R.Senthil Kumaran wrote:
>> * Franz Steinh?usler <[EMAIL PROTECTED]> [2007-08-05 12:14:38]:
>> 
>>> wWhat are the best programs in your opinion, written entirly
>>> in pyhton, divided into categories like:
>>> a) Games
>>> b) Utilities/System
>>> c) Office
>>> d) Web/Newsreader/Mail/Browser
>> 
>> Its a difficult question to answer as the software are aplenty and there is 
>> no
>> judgement basis as this one is the best.
>> 
>> Head on to www.python.org and see for yourself for programs under each
>> category.
>> 
>> And moreover, "written entirely in python" is a constrain to find the
>> programs. Why do you need such a list for?
>
>Of course this is totally objective, but that dosnt mean its not a valid 
>question.
>
>If you were starting out a project were thinking of writing it in 
>python, you might want to look at whats out there - maybe python has 
>limitations which stops it being a good choice in some situations (for 
>instance?)- on the other hand you might want to see some shining 
>examples that prove the capabilities of python ;)
>
>'Being written entirely in python' - is a bit tricky, often these 
>applications rely on some specific extension or make heavy use of a 
>backend that dosnt come with python (like pygame, pygtk, or py-gstreamer).
>
>Games - See Pygame http://www.pygame.org/projects/6
>
>
>Utilities/System
>
>* meld is a really nice diffing tool for linux - http://meld.sourceforge.net
>* ubuntu have some of their install tools in python.
>* txt2tags - a great markup language for doc writing. - 
>http://txt2tags.sourceforge.net/
>* sound recording/editing - http://www.jokosher.org

Thank you for that interesting applications.
They are surely interesting as example of learning pyhton
and convince some people to choose/switch to pyhton.

>
>Office?? - no idea, openoffice can be scripted in python.
>
>Web - * isnt bit torrent python?, probably lots of stuff but I dont know 
>of them ;)

That purpose also a good list could fulfill, to show the capabilities
of pyhton not only on a theoretical way of showing sample code.


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


Re: A question on plugin design

2007-08-05 Thread John J. Lee
Grzegorz Słodkowicz <[EMAIL PROTECTED]> writes:
[...]
> I'd also be grateful for pointers to a well designed Pythonic plugin
> architecture but I'd much prefer a small project with a simple API.

Google for setuptools and Python eggs.  Search for "entry point" on
the setuptools page.


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

Re: the one python book

2007-08-05 Thread [EMAIL PROTECTED]
On Aug 4, 7:23 am, "dhr" <[EMAIL PROTECTED]> wrote:
> newbie question:
>
> Is there a 'K&R" type of Python book? The book that you'd better have on
> your shelf if you are going into Python?

Personally, I have two paths for you to take.

If you are a programmer already, then I would recommend that you buy
Python in a Nutshell. It is actually a very concise book for people
who just want to know what the language provides. I would actually
recommend stopping once you get to the library reference and I would
make sure look into classes. After you done with that day-long read, I
would get your hands on the newest version of "Progamming
Python" (O'Reilly). It has a lot of practical applications for Python
and it is *not* a one-day read. It is enormous and it skips around a
lot. I like it because it is doesn't necessarily stick to one topic so
you pick up a lot of tricks along the way. It gets you started off
learning some sweet c-style OS functions. If you don't know just about
everything about Python by the end of that book, I would be very
surprised.

BTW, almost all of the Nutshell books have been fabulous. They kind of
put it out there for you to suck up like a vacuum. The only failure in
my opinion is the PHP nutshell . . . Since you even know hwo K&R (good
job) is, then I assume you know how to program and are ready to skip
all the crap.

Best of luck,
Travis

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


Re: Submit web form only client-side with Python? COM?

2007-08-05 Thread Jay Loden
Gabriel Genellina wrote:
> En Sat, 04 Aug 2007 19:17:35 -0300, Jay Loden <[EMAIL PROTECTED]>  
> escribió:
> 
>> Paul Rubin wrote:
>>> goldtech <[EMAIL PROTECTED]> writes:
 So I can present the user with an HTML form in it - but how can I
 write the form data to a local file on my work station?
>>> The simplest way is with the cgi and CGIHTTPServer modules.  You'd
>>> write your form in an html file, with the target set to a Python
>> CGIHTTPServer is not available on Windows (OP said they are on Win XP)
> 
> CGIHTTPServer does work on Windows (even on Python 2.1, as far as I can  
> go) and using it might be simple enough.

Hrm, if so then it's a documentation bug. That's actually good news then in this
case :-)
(see http://www.python.org/doc/2.1/lib/module-CGIHTTPServer.html )

[snip...]

> I can't see any other reply from you on this thread... (I'm using the  
> gmane newsgroup interfase)

It's under the title "Client-side HTML form processing with Python?", apparently
the same post is listed twice or something like that.

-Jay

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


Re: Best way to capture output from an exec'ed (or such) script?

2007-08-05 Thread [EMAIL PROTECTED]
On Aug 5, 5:50 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Sat, 04 Aug 2007 18:52:16 -0300, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> escribió:
>
> >> On Aug 2, 7:32 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:>
> >> If your web server is multithreaded (or you use some other way to
> >> process
> >> > many simultaneous requests) you have to be more careful - remember
> >> that
> >> > sys.stdout is global, you must find a way to distinguish between
> >> output
> >> >  from different processes all going into the same collector.
>
> > I'm actually worried about this now.  Does anyone know of any
> > potential solutions?  Anything to at least get me started?
>
> You can use threading.currentThread() to distinguish between threads, and
> a Lock (or RLock) to ensure the output doesn't get mixed:
>
> def write(msg):
>  t = time.strftime("%x %X", time.localtime())
>  who = threading.currentThread().getName()
>  line = "%s (%-15.15s) %s\n" % (t, who, msg)
>  OutputDebugString("%s (%-15.15s) %s\n" % (t, who, msg))
>  loglock.acquire()
>  try:
>  with logfile() as f:
>  f.write(line)
>  finally:
>  loglock.release()
>
> --
> Gabriel Genellina


Thanks, Gabriel.  I'm not actually making the threads myself though.
Rather it's a simple single threaded script running under FastCGI.
Would your method still work?  I don't know too much about how FastCGI
works.  Perhaps that's where I should start.

-Greg

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

Semantics of thread.error

2007-08-05 Thread Paul Miller
In the language documentation, all that is said about thread.error is
that it's raised "on thread-specific errors."  Is there anywhere a
list of conditions which will cause thread.error to be raised?  (I
mean, other than the thread library C source, of course.)

Thanks!

Paul

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


Re: the one python book

2007-08-05 Thread vasudevram
> On Aug 4, 7:23 am, "dhr" <[EMAIL PROTECTED]> wrote:
>
> > newbie question:
>
> > Is there a 'K&R" type of Python book? The book that you'd better have on
> > your shelf if you are going into Python?
>

Python in a Nutshell, the Python Cookbook and Programming Python are
all very good, IMO. Programming Python comes with a CD of all the
source code in the book (at least the 2nd edition did, as well as
Python language - this can save you some time keying in the examples.
Of course, many of the O'Reilly books (and all 3 of these are from
O'Reilly) have links to downloadable source code from them. Just
Google for the name of the book, then in the results, hit the
appropriate link to the O'Reilly site for the book, and look down the
page for the link to the examples' source.

Or (for Programming Python):

http://www.oreilly.com/catalog/python2/
http://www.oreilly.com/catalog/python3/

Vasudev

"1 person in 100 understand binary. The other 11 don't."
Vasudev Ram
Biz site: http://www.dancingbison.com
Blog: http://jugad.livejournal.com
PDF creation/construction toolkit:
  http://sourceforge.net/projects/xtopdf



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


Re: Best programs written completly in Python

2007-08-05 Thread Evan Klitzke
On 8/5/07, Franz Steinhäusler <[EMAIL PROTECTED]> wrote:
> Hello NG,
>
> wWhat are the best programs in your opinion, written entirly
> in pyhton, divided into categories like:
> a) Games
> b) Utilities/System
> c) Office
> d) Web/Newsreader/Mail/Browser

I might be a little biased, but surely Yelp.com is the best "program"
written entirely in Python ;-)

Other really cool Python projects are Launchpad
(https://launchpad.net/) and Trac (http://trac.edgewall.org/). And of
course most Linux desktop distributions (especially Ubuntu and
Redhat/Fedora) have a huge number of small components that rely on
Python entirely or to put together the frontend. Great examples of
this are Bazaar VCS and the Anaconda installer.

The Twisted project isn't a program per se, but it's written in Python
and is really incredible as well.

Google's Mondrian code review system is written in Python and looks
really amazing. I just wish I could try it out :-)

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

PyQt v4.3 (Python Bindings for Qt) Released

2007-08-05 Thread Phil Thompson
Riverbank Computing is pleased to announce the release of PyQt v4.3 available 
from http://www.riverbankcomputing.co.uk/pyqt/.

The highlights of this release include:

- Full support for Qt v4.3.0.
- Partial functions can be used as slots.
- Many Qt classes now support the standard Python pickle protocol for data
  serialisation.

PyQt is a comprehensive set of Qt bindings for the Python programming language 
and supports the same platforms as Qt (Windows, Linux and MacOS/X).  Like Qt, 
PyQt is available under the GPL and a commercial license.

See http://www.riverbankcomputing.com/Docs/PyQt4/html/classes.html for the 
class documentation.

PyQt v4 supports Qt v4 (http://www.trolltech.com/products/qt/index.html).  
PyQt v3 is still available to support earlier versions of Qt.

PyQt v4 is implemented as a set of 11 extension modules containing 
approximately 400 classes and 6,000 functions and methods.

QtCore
The non-GUI infrastructure including event loops, threads, i18n, Unicode,
signals and slots, user and application settings.

QtGui
A rich collection of GUI widgets.

QtNetwork
A set of classes to support TCP and UDP socket programming and higher
level protocols (eg. HTTP, SSL).

QtOpenGL
A set of classes that allows PyOpenGL to render onto Qt widgets.

QtScript
A set of classes that implements a JavaScript interpreter.

QtSql
A set of classes that implement SQL data models and interfaces to industry
standard databases.  Includes an implementation of SQLite.

QtSvg
A set of classes to render SVG files onto Qt widgets.

QtTest
A set of classes to automate unit testing of PyQt applications and GUIs.

QtXML
A set of classes that implement DOM and SAX parsers.

QtAssistant
A set of classes that enables the Qt Assistant online help browser to be
integrated with an application.

QAxContainer
A set of classes for Windows that allows the integration of ActiveX
controls and COM objects.

A Windows installer is provided for the GPL version of PyQt which contains 
everything needed for PyQt development (including Qt, Qwt, QScintilla and the 
eric IDE).

PyQt includes the pyuic4 utility which generates Python code to implement user 
interfaces created with Qt Designer in the same way that the uic utility 
generates C++ code.  It is also able to load Designer XML files dynamically.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.

2007-08-05 Thread [EMAIL PROTECTED]
On Aug 5, 4:06?am, SMERSH009 <[EMAIL PROTECTED]> wrote:
> On Aug 4, 8:25 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Aug 4, 9:21?pm, "Jim Langston" <[EMAIL PROTECTED]> wrote:
>
> > > <[EMAIL PROTECTED]> wrote in message
>
> > >news:[EMAIL PROTECTED]
>
> > > > On Aug 4, 6:35?pm, SMERSH009 <[EMAIL PROTECTED]> wrote:
> > > >> Hi All.
> > > >> Let's say I have some badly formatted text called doc:
>
> > > >> doc=
> > > >> """
> > > >> friendid
> > > >> Female
>
> > > >> 23 years old
>
> > > >> Los Gatos
>
> > > >> United States
> > > >> friendid
> > > >> Male
>
> > > >> 24 years old
>
> > > >> San Francisco, California
>
> > > >> United States
> > > >> """
>
> > > >> How would I get these results to be displayed in a format similar to:
> > > >> friendid;Female;23 years old;Los Gatos;United States
> > > >> friendid;Male; 24 years old;San Francisco, California;United States
>
> > > >> The latter is a lot easier to organize and can be quickly imported
> > > >> into Excel's column format.
>
> > > >> Thanks Much,
> > > >> Sam
>
> > > > d = doc.split('\n')
>
> > > > f = [i.split() for i in d if i]
>
> > > > g = [' '.join(i) for i in f]
>
> > > > rec = []
> > > > temprec = []
> > > > for i in g:
> > > >if i:
> > > >if i == 'friendid':
> > > >rec.append(temprec)
> > > >temprec = [i]
> > > >else:
> > > >temprec.append(i)
> > > > rec.append(temprec)
>
> > > > output = [';'.join(i) for i in rec if i]
>
> > > > for i in output: print i
>
> > > > ##friendid;Female;23 years old;Los Gatos;United States
> > > > ##friendid;Male;24 years old;San Francisco, California;United States
>
> > > also, I would suggest you use CSV format.
>
> > Well, the OP asked for a specific format. One is not
> > always at liberty to change it.
>
> > > CSV stands for "Comma Seperated
> > > Variable" and Excel can load such a sheet directly.
>
> > And Excel can load the shown format directly also,
> > just specify the delimiter.
>
> > > Instead of seperating using ; seperate using ,  Of course, this provides a
> > > problem when there is a , in a string.
>
> > Which explains the popularity of using tabs as delimiters.
> > The data deliverable specification I use at work
> > uses the pipe character | which never appears as data
> > in this particular application.
>
> > > Resolution is to quote the string.
>
> > Which makes the file bigger and isn't necessary
> > when tabs and pipes are used as delimiters.
>
> > > Being such, you can just go ahead and quote all strings.  So you would 
> > > want
> > > the output to be:
>
> > > "friendid","Female","23 years old","Los Gatos","United States"
> > > "friendid","Male","24 years old","San Francisco, California","United 
> > > States"
>
> > Which I would do if I had a specification that
> > demanded it or was making files for others. For my
> > own use, I wouldn't bother as it's unnecessary work.
>
> > > Numbers should not be quoted if you wish to treat them as numeric and not
> > > text.
>
> > A good reason not to use quotes at all. Besides which,
> > Excel can handle that also.
>
> Thanks for all your posts guys.
> mensanator's was the most helpful, and I only ended up needing to use
> a few lines from that code.
> The only question that remains for me--and this is just for my
> knowledge-- what does the "if i" mean in this code snippet?
> f = [i.split() for i in d if i]

d is a list of strings, some of which are empty (caused
by the previous split). "if i" evaluates False for
an empty string, so that particular i will not get
split and ends up ommitted from f.

> How is it helpful to leave a dangling "if i"? Why not just f =
> [i.split() for i in d]?

Compare the result of having "if i":
[[], ['friendid'], ['Female'], ['23', 'years', 'old'], ['Los',
'Gatos'], ['United', 'States'], ['friendid'], ['Male'], ['24',
'years', 'old'], ['San', 'Francisco,', 'California'], ['United',
'States']]

to not having it:
>>> ff = [i.split() for i in d]
>>> ff
[[], ['friendid'], ['Female'], [], [], ['23', 'years', 'old'], [], [],
['Los', 'Gatos'], [], [], ['United', 'States'], ['friendid'],
['Male'], [], [], ['24', 'years', 'old'], [], [], ['San',
'Francisco,', 'California'], [], [], ['United', 'States'], []]

All the blank lines became empty lists which actually
wouldn't change anything if they get joined. But that
won't always be the case. Knowing how to use conditionals
in list comprehensions is worth knowing.

Even with the "if i" included, we end up with an
empty list at the start. This because the first "blank"
line wasn't blank, it was a space, so it passes the
"if i" test.

>
> And yes John, this was indeed a "homework question." It was for my
> daughter's preschool. You are going to help her ace her beginner
> Python class! (No, this was not a homework question).


Re: Semantics of thread.error

2007-08-05 Thread Martin v. Löwis
Paul Miller schrieb:
> In the language documentation, all that is said about thread.error is
> that it's raised "on thread-specific errors."  Is there anywhere a
> list of conditions which will cause thread.error to be raised? 

I don't think so. However, it is fairly easy to extract such a list
from the source: "grep ThreadError */*.c" reveals these causes

  PyErr_SetString(ThreadError, "release unlocked lock");
  PyErr_SetString(ThreadError, "can't allocate lock");
  PyErr_SetString(ThreadError, "can't start new thread");
  PyErr_SetString(ThreadError, "no current thread ident");
  PyErr_SetString(ThreadError, "setting stack size not supported");

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


Misleading wikipedia article on Python 3?

2007-08-05 Thread John J. Lee
I'm surprised to read this:

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

"""Note that while there is no explicit requirement that code be able
to run unmodified in both versions, in practice it is quite likely for
most code. As of January 2007, it looks like most reasonable code
should run quite well under either branch."""


I haven't been following Python 3 development recently.  Have things
really changed that much?  Last time I looked, e.g. dict.items() no
longer returned a list.  Seems unlikely that most code will run on 2
and 3, in that case, and IIUC Guido has said all along that not much
code will run on both.

Maybe somebody who's following current Py3k goings-on can fix the
article if needed...


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


Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread Martin v. Löwis
> I'm surprised to read this:
> 
> http://en.wikipedia.org/wiki/Python_3
> 
> """Note that while there is no explicit requirement that code be able
> to run unmodified in both versions, in practice it is quite likely for
> most code. As of January 2007, it looks like most reasonable code
> should run quite well under either branch."""

It's difficult to predict the future, but I think this statement is
a fair description.

> 
> I haven't been following Python 3 development recently.  Have things
> really changed that much?  Last time I looked, e.g. dict.items() no
> longer returned a list.

Correct.

> Seems unlikely that most code will run on 2
> and 3, in that case,

Why that? Most reasonable code doesn't care what dict.items returns,
as it reads like

for k,v in dict.items():
  do_something_with(k,v)

> and IIUC Guido has said all along that not much
> code will run on both.

I think you misunderstood. It's not a design goal that code works
without modifications, yet most reasonable code will even without
that being an explicit goal.

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


Re: Buffering HTML as HTMLParser reads it?

2007-08-05 Thread chrispwd
On Aug 1, 4:08 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Aug 1, 1:31 pm, [EMAIL PROTECTED] wrote:
> 
>
>
>
> > I'm thinking maybe somehow haveHTMLParserappend each character it
> > reads except for data inside tags in some kind of buffer? This way I
> > can have the HTML contents read into a buffer, then when I do my own
> > handle_ overrides, I can also append to that buffer with the
> > transformed data. Once the HTML page is finished parsing, ideally I
> > would be able to print the contents of the buffer and the HTML would
> > be identical except for the string transformations.
>
> > I also need to make sure that all newlines, tags, spacing, etc are
> > kept in tact -- this part is a requirement for other reasons.
>
> > Thanks!
>
> What you describe is almost exactly how pyparsing implements
> transformString.  See below:
>
> from pyparsing import *
>
> boldStart,boldEnd = makeHTMLTags("B")
>
> # convert  to  and  to 
> boldStart.setParseAction(replaceWith(''))
> boldEnd.setParseAction(replaceWith(''))
> converter = boldStart | boldEnd
>
> html = "Display this in bold"
> print converter.transformString(html)
>
> Prints:
>
> Display this in bold
>
> All text not matched by a pattern in the converter is left as-is.  (My
> CSS style/form may not be up to date, but I hope you get the idea.)
>
> -- Paul

Hello,

Sorry for the delay in reply, and that you for the info. Though, I
think either I am mis-understanding your post or its not the solution
I'm looking for.

How does this fit into what I'm looking to do with HTMLParser?

Thanks!

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


Re: the one python book

2007-08-05 Thread Silfheed
On Aug 4, 6:23 am, "dhr" <[EMAIL PROTECTED]> wrote:

Assuming that you already know that a ton of great stuff is on the
web, I'd also recommend 'Programming Python' and 'Python Cookbook'.
'The Python Book' would have to be the Python book ('Programming
Python', cuz it has a python on the cover and covers the python
language, brilliant!) It's huge and is full of great scripts and,
most importantly, promotes good coding style.  Hopefully they've
updated the index tho, since the 2nd edition has an utterly pathetic
index, tho you can still find what you want pretty quickly with just
the toc.

Python Cookbook is necessary because it covers so many little hidden
secrets of python.  The section on dateutil is worth the price of the
book alone.

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


Re: Best programs written completly in Python

2007-08-05 Thread markacy
On 5 Sie, 12:14, Franz Steinhäusler <[EMAIL PROTECTED]>
wrote:
> Hello NG,
>
> wWhat are the best programs in your opinion, written entirly
> in pyhton, divided into categories like:
> a) Games
> b) Utilities/System
> c) Office
> d) Web/Newsreader/Mail/Browser
> ...
>
> I don't want to start a long thread, if a site of such
> an discussion already exists, a link will be enough.
>
> Many thanks in advance!
>
> --
> Franz Steinhaeusler

I guess, that gentoo's portage is (almost?) entirely written in
python. The same is with Zope/Plone (Web category), though I know,
that Zope has some parts of code written in C. Django?

Big part's of google "tools" are written in python as well. Matplotlib
is said to be written entirely in python.
These are examples from the top of my head. If I'll came up with
something else, I will let You know :-)

Cheers,
Marek

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

Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.

2007-08-05 Thread Ricardo Aráoz
[EMAIL PROTECTED] wrote:
> In a message dated 8/4/2007 11:50:05 PM Central Daylight Time,
> [EMAIL PROTECTED] writes:
> 
> [EMAIL PROTECTED] wrote:
> > On Aug 4, 6:35?pm, SMERSH009 <[EMAIL PROTECTED]> wrote:
> >> Hi All.
> >> Let's say I have some badly formatted text called doc:
> >>
> >> doc=
> >> """
> >> friendid
> >> Female
> >>
> >> 23 years old
> >>
> >> Los Gatos
> >>
> >> United States
> >> friendid
> >> Male
> >>
> >> 24 years old
> >>
> >> San Francisco, California
> >>
> >> United States
> >> """
> >>
> >> How would I get these results to be displayed in a format similar to:
> >> friendid;Female;23 years old;Los Gatos;United States
> >> friendid;Male; 24 years old;San Francisco, California;United States
> >>
> >> The latter is a lot easier to organize and can be quickly imported
> >> into Excel's column format.
> >>
> >> Thanks Much,
> >> Sam
> >
> > d = doc.split('\n')
> >
> > f = [i.split() for i in d if i]
> >
> > g = [' '.join(i) for i in f]
> >
> > rec = []
> > temprec = []
> > for i in g:
> > if i:
> > if i == 'friendid':
> > rec.append(temprec)
> > temprec = [i]
> > else:
> > temprec.append(i)
> > rec.append(temprec)
> >
> > output = [';'.join(i) for i in rec if i]
> >
> > for i in output: print i
> >
> > ##friendid;Female;23 years old;Los Gatos;United States
> > ##friendid;Male;24 years old;San Francisco, California;United
> > States
> >
> 
> Also :
> 
> docList = [ i.strip() for i in doc.split('\n') if i.strip()]
> 
> lines = [i for i in xrange(len(docList)) if docList[i] ==
> 'friendid']+[len(docList)]
> 
> docOut = ''
> for k in [docList[lines[j]:lines[j+1]] for j in xrange(len(lines)-1)]:
> docOut += '\n' + ';'.join(k)
> 
> docOut = docOut[1:]# Get rid of initial '\n'
> 
> Aren't you making an unwarranted assumption here?
> That doc ALWAYS starts with EXACTLY one blank line?

I guess you are referring to :
docList = [ i.strip() for i in doc.split('\n') if i.strip()]

Actually no, "doc.split('\n')" will split it a list member per line,
whether there are blank lines or not. Then "i.strip()" will take care of
redundant space, and "if i.strip()" will take care of blank lines. Try
it in your shell, play with "doc" and you'll see (I did try it without
the first blank line, and with a lot of blank lines and it's ok).

>  
> That's why I didn't use a list comprehension in that
> one section, to cover the possibility of any number
> (including none) of blank lines.

It works, didn't make a thorough testing but the cases you suggest were
tested.

>  
> By blindly coding [1:] you run the risk of data loss,
> and that's a poor example for the OP.

It is not "blindly". I guarantee the first byte will ALLWAYS be a '\n',
that's because I'm putting it there with "docOut += '\n' + ';'.join(k)"
(check the '\n' added at the beginning of each cycle), and I need to
strip the beginning '\n' which is not necessary.

Cheers

Ricardo


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


Re: xlrd question

2007-08-05 Thread jay
Hi Has,


>> 2.3.5 (#1, Jan 30 2006, 13:30:29)
>> [GCC 3.3 20030304 (Apple Computer, Inc. build 1819)]
>> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
>> python2.3/site -packages/
>> xlrd/__init__.pyc
>
> Note that:
>
> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/
> site-packages
>
> is actually just a symlink to:
>
> /Library/Python/2.3/site-packages
>
> While third-party modules do usually go in python2.x/site-packages,
> Apple don't like users messing about in /System so their stock Python
> installation keeps third-party modules under /Library instead...


Thanks very much for your incredibly helpful and detailed  
info!  :-)So if I'm understanding this correctly, it really only  
installs something in '/Library/Python/2.3/site-packages' (as well as  
an alias to it from '/System/Library/Frameworks/Python.framework/ 
Versions/2.3/lib/python2.3/site-packages').  I'll keep the  
documentation, etc. as you encouraged.


> You can script Excel directly from Python via appscript which talks to
> scriptable Mac apps via the same API as AppleScript:...


Very cool!  Thanks very much for sharing this.  I'll definitely look  
into 'appscript'.


> If you need more info just ask.


Thanks again Has, for taking the time to share all this!  I really  
appreciate it!

Jay

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


smtplib, gmail, quit vs. close and SSL3_GET_RECORD:wrong version number

2007-08-05 Thread Roger
I am having a problem sending email through smtp.gmail.com using 
smtplib.  Everything works and the mail is sent and received, except 
quit.  The following shows the problem (without bothering to login or do 
the sendmail):

 import smtplib
 server = smtplib.SMTP('smtp.gmail.com',25)
 server.ehlo()
> (250, 'mx.google.com at your service, [68.98.218.211]\nSIZE 
> 28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES')
 server.starttls()
> (220, '2.0.0 Ready to start TLS')
 server.ehlo()
> (250, 'mx.google.com at your service, [68.98.218.211]\nSIZE 
> 28311552\n8BITMIME\nAUTH LOGIN PLAIN\nENHANCEDSTATUSCODES')
 server.noop()
> (250, '2.0.0 OK')
 server.quit()
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> server.quit()
>   File "c:\Python25\lib\smtplib.py", line 716, in quit
> self.docmd("quit")
>   File "c:\Python25\lib\smtplib.py", line 378, in docmd
> return self.getreply()
>   File "c:\Python25\lib\smtplib.py", line 352, in getreply
> line = self.file.readline()
>   File "c:\Python25\lib\smtplib.py", line 160, in readline
> chr = self.sslobj.read(1)
> sslerror: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version 
> number')
 

I have not had this problem with other mail servers (but only tried 
two).  A solution for gmail seems to be to replace the server.quit() 
with server.close().  The difference between the two commands is quit() 
sends a 'QUIT' string before calling close().  Because close() is not 
included in the smtplib docs, it does not appear to be the right solution.

What is the correct way to terminate a gmail session?

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


Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread John J. Lee
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:

>> I'm surprised to read this:
>> 
>> http://en.wikipedia.org/wiki/Python_3
>> 
>> """Note that while there is no explicit requirement that code be able
>> to run unmodified in both versions, in practice it is quite likely for
>> most code. As of January 2007, it looks like most reasonable code
>> should run quite well under either branch."""
>
> It's difficult to predict the future, but I think this statement is
> a fair description.
>
>> 
>> I haven't been following Python 3 development recently.  Have things
>> really changed that much?  Last time I looked, e.g. dict.items() no
>> longer returned a list.
>
> Correct.
>
>> Seems unlikely that most code will run on 2
>> and 3, in that case,
>
> Why that? Most reasonable code doesn't care what dict.items returns,
> as it reads like
>
> for k,v in dict.items():
>   do_something_with(k,v)

We could discuss that.  However, my example wasn't really intended to
relate strictly to that technical feature.  Rather, to the intent of
the Python 3 developers, as suggested by things like that change, and
by what they've said over the last year or so (I think I've seen that
specific change used several times by people explaining that 2.6 / 3.0
compatibility will be impractical, which is why I chose it).


>> and IIUC Guido has said all along that not much
>> code will run on both.
>
> I think you misunderstood. It's not a design goal that code works
> without modifications, yet most reasonable code will even without
> that being an explicit goal.

I think the design goals have been fairly clear.  What hasn't been
clear (to me, at least) is the practical question of the feasibility
of code working unchanged on both 2.6 and 3.0.

http://www.python.org/dev/peps/pep-3000/

"""There is no requirement that Python 2.6 code will run unmodified on
Python 3.0. Not even a subset. (Of course there will be a tiny subset,
but it will be missing major functionality.)"""


Though certainly neither quote is precise enough to pin it down
formally, certainly the tone of the first quote (from the Wikipedia
article) to my ear makes it sound like (at minimum!) it will be
practical for most projects, if they do the work to support both 3.0
and 2.6, to run simultaneously on 2.6 and 3.0 without use of a
translation tool.  The second quote makes it sound like that will be
highly impractical.  That picture is reinforced by what follows (in
PEP 3000):

"""
The recommended development model for a project that needs to support
Python 2.6 and 3.0 simultaneously is as follows:

   0. You should have excellent unit tests with close to full
  coverage.

   1. Port your project to Python 2.6.

   2. Turn on the Py3k warnings mode.

   3. Test and edit until no warnings remain.

   4. Use the 2to3 tool to convert this source code to 3.0 syntax. Do
  not manually edit the output!

   5. Test the converted source code under 3.0.

   6. If problems are found, make corrections to the 2.6 version of
  the source code and go back to step 3.

   7. When it's time to release, release separate 2.6 and 3.0 tarballs
  (or whatever archive form you use for releases).

It is recommended not to edit the 3.0 source code until you are ready
to reduce 2.6 support to pure maintenance (i.e. the moment when you
would normally move the 2.6 code to a maintenance branch anyway).
"""


So which is it?  That is, will it be practical for most projects to
support 2.6 and 3.0 simultaneously, from the same codebase, without
relying on translation tools?  I'm assuming the practicalities of this
*are* clear by now to the Python 3 developers -- is that right?  It
seems to me that if I don't understand what the Python 3 developers
expect the practicalities to be, most other interested people won't
either ("interested" in the opposite sense to "disinterested" rather
than to "uninterested").


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

Re: Best programs written completly in Python

2007-08-05 Thread Franz Steinh�usler
On Sun, 05 Aug 2007 11:26:13 -0700, markacy <[EMAIL PROTECTED]> wrote:

>On 5 Sie, 12:14, Franz Steinhäusler <[EMAIL PROTECTED]>
>wrote:
>> Hello NG,
>>
>> wWhat are the best programs in your opinion, written entirly
>> in pyhton, divided into categories like:
>> a) Games
>> b) Utilities/System
>> c) Office
>> d) Web/Newsreader/Mail/Browser
>> ...
>>
>> I don't want to start a long thread, if a site of such
>> an discussion already exists, a link will be enough.
>>
>> Many thanks in advance!
>>
>> --
>> Franz Steinhaeusler
>
>I guess, that gentoo's portage is (almost?) entirely written in
>python. The same is with Zope/Plone (Web category), though I know,
>that Zope has some parts of code written in C. Django?
>
>Big part's of google "tools" are written in python as well. Matplotlib
>is said to be written entirely in python.
>These are examples from the top of my head. If I'll came up with
>something else, I will let You know :-)
>
>Cheers,
>Marek

Ah yes of course,

One or I, often see only programs, which is "closed in itself",
like an editor, viewer, newsreader, and oversee, that big parts
of "invisible" software is written in python.

Thank you for mentioning that pieces of software!

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


Re: A question on plugin design

2007-08-05 Thread John J. Lee
[EMAIL PROTECTED] (John J. Lee) writes:

> Grzegorz Słodkowicz <[EMAIL PROTECTED]> writes:
> [...]
>> I'd also be grateful for pointers to a well designed Pythonic plugin
>> architecture but I'd much prefer a small project with a simple API.
>
> Google for setuptools and Python eggs.  Search for "entry point" on
> the setuptools page.

And as an example of a project that uses that plugin system, look at
the nose testing tool (I suggest looking at version 0.10, not version
0.9):

http://code.google.com/p/python-nose/


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

Re: Google message munging (was: Live editing...)

2007-08-05 Thread [EMAIL PROTECTED]

> What the blazes is Google doing with messages that such a high
> proportion of them come through in this painful-to-read double-wrapped
> format? I'm referring to the fact that the lines appear to have been
> wrapped at one length, and then each line broken again into a long and
> a short line.
>

I entirely agree with Ben Finney's remarks.  Painful for
an author to see a post mangled that way too, writers
being also readers.

Back to the original thread (sort of): I think the deeper
issue is the relationship between "shell" (REPL),
"debugger" (per WingIDE 101 for example) and "runtime"
ala Python just crunching through a .py file.

The OLPC people are pushing for exotic "live debugging"
and think Python is deficient in this regard, not as a
language so much as an environment (which Guido need take
no responsibility for, though he often has and does).

My tossing out of some ZODB-based solutions was mostly
just an ice-breaker.  I don't mind that it ended up
prompting discussions of formatting.

Anyway, back to thinking about iterator types:
http://mail.python.org/pipermail/edu-sig/2007-August/008168.html
( python.next() might trigger a fork/jump to a next "live"
interpreter, leaving behind "snake skin" or "ghost" interpreter
available for "live" interventions? ).

Kirby

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


Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread Martin v. Löwis
>> I think you misunderstood. It's not a design goal that code works
>> without modifications, yet most reasonable code will even without
>> that being an explicit goal.
> 
> I think the design goals have been fairly clear.  What hasn't been
> clear (to me, at least) is the practical question of the feasibility
> of code working unchanged on both 2.6 and 3.0.
> 
> http://www.python.org/dev/peps/pep-3000/
> 
> """There is no requirement that Python 2.6 code will run unmodified on
> Python 3.0. Not even a subset. (Of course there will be a tiny subset,
> but it will be missing major functionality.)"""

That's a different statement, though: It is likely that code will not
run unmodified on 3k. For example, print is now a statement, and
many many modules use that statement somewhere; they break in 3k.

However, it *is* a design goal to make 2.6 so that transition to
3k becomes simpler. That's not a 3k feature, but a 2.6 one.

> Though certainly neither quote is precise enough to pin it down
> formally, certainly the tone of the first quote (from the Wikipedia
> article) to my ear makes it sound like (at minimum!) it will be
> practical for most projects, if they do the work to support both 3.0
> and 2.6, to run simultaneously on 2.6 and 3.0 without use of a
> translation tool.  The second quote makes it sound like that will be
> highly impractical.  That picture is reinforced by what follows (in
> PEP 3000):
> 
> """
> The recommended development model for a project that needs to support
> Python 2.6 and 3.0 simultaneously is as follows:

That's Guido's recommendation, yes: use the 2to3 tool.

There are certainly projects for which this might be the only reasonable
strategy. However, whether that will be the *common* strategy remains
to be seen. I personally believe that many projects won't need the 2to3
tool, if they are willing to compromise on the notations used in the
source code.

> So which is it?

Both.

> That is, will it be practical for most projects to
> support 2.6 and 3.0 simultaneously, from the same codebase, without
> relying on translation tools?

That remains to be seen. I believe it will be, yes. Only when people
start trying we will actually know. Personal preference will vary
across projects; some will use the conversion tool even though they
could have come up with a single-source solution, others will fight
for a single-source solution even though life would have been much
simpler with the conversion tool.

> I'm assuming the practicalities of this
> *are* clear by now to the Python 3 developers -- is that right?

Not at all (at least now to me). I know what kind of changes *I*
regularly do to make code run in 3k, namely, put parentheses around
into the print statements. I can live with that. Whether it is
practical to run, say, Django unmodified, I don't know - I have
not looked into Django with that much detail, let alone tested
whether it will work.

Note that I'm primarily talking about pure Python here; for
C code, you can get a single-source version only with a lot
of #ifdefs (but again, I believe it is practical to make it
work that way).

> It
> seems to me that if I don't understand what the Python 3 developers
> expect the practicalities to be, most other interested people won't
> either ("interested" in the opposite sense to "disinterested" rather
> than to "uninterested").

I think comp.lang.python is then the wrong place to find out; the py3k
list likely reaches more of these developers. OTOH, I don't know whether
they all want to participate in a survey of their expectations...

Rather than studying people's opinions, why don't you try to port your
own projects to 3k, and report whether you found it practical to use
a single source (assuming you would prefer such a solution for your
own project)?

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


Re: Google message munging (was: Live editing...)

2007-08-05 Thread [EMAIL PROTECTED]
On Jul 31, 10:38?pm, Paul Rubin  wrote:
> Ben Finney <[EMAIL PROTECTED]> writes:
> > > [... more lines of broken line wrapping...]
> > What the blazes is Google doing with messages that such a high
> > proportion of them come through in this painful-to-read double-wrapped
> > format? I'm referring to the fact that the lines appear to have been
> > wrapped at one length, and then each line broken again into a long and
> > a short line.
>
> Users write in a text editor formatting the text into lines of
> reasonable size, separated by newline characters.  They then paste the
> text into a web form, which reformats it with slightly shorter lines
> (breaking up the user's longer lines) but leaves the user's newlines
> in place.

Google used to provide a preview before actual posting,
but that is no longer available, so there's nothing the
poster can do about it.

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


Question about pychecker and pylint

2007-08-05 Thread KLEIN Stephane
Hi,

I wonder if pychecker projet is dead ? On pychecker home page
(http://pychecker.sourceforge.net/), last version date from February 3, 
2006 and
their mailist contain spam messages only.

Other tools like pychecker is pylint at
(http://www.logilab.org/project/eid/857). This is a great tools and it's 
still
active. However, it has issue : its web site, it is very incomprehensible.

Do you have other pylint web site ?

Thanks for your information.
Stephane

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


Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.

2007-08-05 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
   ...
> Even with the "if i" included, we end up with an
> empty list at the start. This because the first "blank"
> line wasn't blank, it was a space, so it passes the
> "if i" test.

...and you can fix that by changing the test to [... if i.split()].


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


Re: Efficient Rank Ordering of Nested Lists

2007-08-05 Thread [EMAIL PROTECTED]
On Aug 4, 7:29 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Cousin Stanley <[EMAIL PROTECTED]> wrote:
>
>...
>
> >   for i , item in reversed( enumerate( sorted( single_list ) ) ) :
>...
> > TypeError: argument to reversed() must be a sequence
>
> Oops, right.  Well then,
>
> aux_seq = list(enumerate(sorted(single_list)))
> for i, item in reversed(aux_seq): ...
>
> or the like.
>
> Alex

The particular embedded list I have been tinkering with is 43 x 3884
and the dictionary approach (as you can probably guess) is a big
improvement over the linear one.  It also has the added benefit of
being compatible with Python24.  If I'm not mistaken the binary
approach suggested by Neil requires Python25.  Since in some
situations I don't have control over the version available I will go
with a variant of the dictionary recipe.

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


Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread John J. Lee
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:
[... snip stuff I don't follow ...]
> However, it *is* a design goal to make 2.6 so that transition to
> 3k becomes simpler. That's not a 3k feature, but a 2.6 one.

Not sure I care about this sort of thing for the purpses of my
question.  I just wanted to know: is it easy to make my code so it
runs on 2.6 and 3.0, without funny stuff like a code translator?
Seems wikipedia said "yes" and Guido said "no".


[...]
> to be seen. I personally believe that many projects won't need the 2to3
> tool, if they are willing to compromise on the notations used in the
> source code.

OK, so there's disagreement on this point amongst the Python 3
developers.  That's interesting (I don't mean that in a negative way).


[...]
>> It
>> seems to me that if I don't understand what the Python 3 developers
>> expect the practicalities to be, most other interested people won't
>> either ("interested" in the opposite sense to "disinterested" rather
>> than to "uninterested").
>
> I think comp.lang.python is then the wrong place to find out; the py3k
> list likely reaches more of these developers. OTOH, I don't know whether
> they all want to participate in a survey of their expectations...

I was also hoping to get a quick answer rather than a long discussion,
if any Python 3 developers were around to talk to the broader range of
people that read this list.  You have given your answers, I wonder if
anybody else will turn up.


> Rather than studying people's opinions, why don't you try to port your
> own projects to 3k, and report whether you found it practical to use
> a single source (assuming you would prefer such a solution for your
> own project)?

Because that might well tell me much less than asking a Python 3
developer, and yet take far more time, and fail to inform everybody
else.


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

Re: MIMEText breaking the rules?

2007-08-05 Thread Dale Strickland-Clark
Tim Roberts wrote:

> Dale Strickland-Clark <[EMAIL PROTECTED]> wrote:
>>
>>The email module's mimetext handling isn't what you might expect from
>>something that appears to behave like a dictionary.
>>...
>>Having apparently REPLACED my recipient, what I've ended up with is both
>>of them.
> 
> This behavior is documented in Message.Message, from which MIMEText
> eventually inherits.  If you want to start over, delete the item:
> 
>   del Msg["To"]
> 
> I would have to say that the existing behavior is more intuitive for an
> email object.

Thanks for the info.

-- 
Dale Strickland-Clark
Riverhall Systems - www.riverhall.co.uk 

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


Re: Relative-importing *

2007-08-05 Thread rbysamppi
On Aug 4, 7:10 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > Yes, I'mimporting* for a reason, a good one, I think.
>
> Reading your description, I must say I don't see a good reason.
>
> > I have a set of modules (the number planned to reach about 400) that
> > would be dynamically loaded by my program as needed, and they're
> > somewhat similar to each other. I wish each of them to import * from
> > a certain "parent" module, so that they'll receive whatever
> > functions and variables I want all of them to share (using the
> > parent module's __all__), which may be overrided by the "child"
> > modules at their discretion. Sort of like class inheritance, but I'm
> > not doing that because implementing that would be a lot more tedious
> > and less elegant.
>
> It seems to me, based only on this description, that class inheritance
> would be far *more* elegant, and much easier to follow when reading
> the code.
>
> If all these functions and other objects are so closely-related that
> they form the core of some inheritance-like system, what's so
> inelegant about wrapping them in a class so that the inheritance is
> explicit in the module where it happens?
>
> --
>  \  "The only tyrant I accept in this world is the still voice |
>   `\   within."  -- Mahatma Gandhi |
> _o__)  |
> Ben Finney

Remember that I'm a relative beginner at Python, and actually
programming in general, so forgive me if what seems obvious is opaque
to me. This project's my way of learning the language. :)

I tried a class-based system. The reasons why I would prefer using
modules only rather than classes in modules was because I think that
it's a little redundant, and this redundancy made it more difficult to
grapple with the module/classes' names.

This system is for implementing "moves" in a game, of which there will
eventually be about 500 when all are implemented. I decided to try to
implement each move in a separate module, so we could add and maintain
moves to the system at convenience instead of editing a single huge
module with hundreds of classes. (Each move is completely separate and
unrelated to each other, other than the fact that they share a few
variables. In addition, I plan to make it possible to have a user add
new move modules at their discretion as extensions to the game.)

However, this ended up with a system where every single module had a
single class representing the move in it. The name of the class and
module have to be the same so that dynamic importing is possible, but
the repetition of the name is undesirable, as it increases the chance
of errors that might be hard to diagnose. (Because I'm planning to
have it possible for a hypothetical user to create his/her own
modules, I care a lot about making it as simple as possible.)

(In addition, it probably would make the program somewhat slower to
have an internal class inside every module, and performance is
important to me, as I'm planning to use this project in a future
game.
These modules are not going to have full-fledged object construction
and so forth. I don't want to construct and use objects at all--it
seems like a waste of time and memory to me to inherit __new__,
__del__, and so on. All that I want these modules to do is to
encapsulate varying information and behavior for /other/ objects to
use.)

It's not a matter of life-and-death for me if I have to use class
inheritance. But I think it would suboptimal.

But regardless of if it's the "right thing to do", do you all think
it's an unintended bug?

Thanks again! :)

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


Re: Tkinter or wxpython?

2007-08-05 Thread Jerry McBride
wang frank wrote:

> 
> Hi,
> 
> I want to build a GUI to execut python script. I found TKinter and
> wxpython. Which one is easier for a newbie? and which one is better?
> 

Tkiner is much easier to work with, but doesn't have the fine controls that
wx offers...



-- 


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


Re: Pyscripter

2007-08-05 Thread RichSaneSwindler
On Aug 5, 4:45 am, Stef Mientki <[EMAIL PROTECTED]>
wrote:
> RichSaneSwindler wrote:
> > I think that pyscripter is the most promising Python IDE around
>
> but for windows only !
>   and I
>
> > am exciting about its possibilities. However, I find a few issues with
> > it annoying enough that I don't use it. They seem easily fixed in
> > which case I think it would be superior to most IDEs. I am wondering
> > if any users out there would like to add to/debate this list of
> > benefits and issues (for reference I am using Pyscripter
>
> Neil,
> PyScripter has it's own discussion list
>http://groups.google.com/group/PyScripter/topics?hl=en
> and from my own experiences,
> I know that Kiriakos (the designer) is very willing to listen to good ideas,
> and if they are good he'll implement them in no time !
>
> cheers,
> Stef

Thanks, I will copy my message there.

Neil

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


ANN: ChiPy August Meeting Topic "Snakes On Apples"

2007-08-05 Thread Brian Ray
ChiPy the Chipmunk** invites you to attend August's Chicago Python  
User Group meeting. ChiPy says, "This will be the best meet ever!"

When


Thursday August 9th 2007 7:00PM

Cost


Free

Topics
--

Snakes on Apples  Developing Python  
on the Mac. All are welcome, no Macintosh, Unix, or Python experience  
required.

  - TextMate with Python -- Kumar McMillan
 + how to edit / navigate -- all the stuff that makes it  
comparable to emacs or whatnot (I'll keep this short)
 + hack: how to write commands / Bundles to automate your coding  
needs
  - Address Book Plugin for syncing with gmail contacts utilizing  
libgmail -- Brian Ray
  - Python Sprint at Google and PyCon '08 updates / discussion
  - After: If you wish, follow Chipy the Chipmunk to Greektown or  
Taylor Street

Venue
-

::
   The University of Illinois at Chicago
   Science and Engineering Offices (SEO 1000)
   851 South Morgan Street
   Chicago, Illinois 60607

(note: Emergency Cell 773 835 9876, if you get lost and need moral  
support)

CTA
~~~

FROM O'HARE AIRPORT BY CTA TRAIN: Take the CTA BLUE LINE TRAIN from  
O'Hare to the UIC-Halsted stop. Exit up
stairs in center of the train platform (the platform also has two  
long ramps on either side heading East and West, which also
can be used). Proceed South on street level to the UIC campus.

FROM MIDWAY AIRPORT BY CTA TRAIN: Take the CTA ORANGE LINE TRAIN from  
Midway to the Clark/Lake station. Exit
the train, GO DOWNSTAIRS and transfer to the CTA BLUE LINE. Take the  
Blue Line train towards 54/Cermak (Forest Park)
and exit at the UIC-Halsted stop. Exit up stairs in center of the  
train platform (the platform also has two long ramps on either
side heading East and West, which also can be used). Proceed South on  
street level to the UIC campus.


Driving
~~~

PARKING: Public parking is available via a four-level parking garage  
on the NE corner of Taylor & Halsted streets, and at
the open parking lot on the SE corner of Taylor and Morgan streets.  
IF PARKING IN THE GARAGE, ENTER ON THE
LEFT DRIVEWAY as you turn Nor th into the building, ensuring that you  
take a ticket. If parking in the open lot, enter
through the Southern most driveway, the one that has the attendant  
booth.

DRIVING FROM THE NORTH: Take 90/94 South (Kennedy Expressway) to the  
Taylor Street/Roosevelt Ave, Exit 52A.
Keep to the right and turn right immediately onto Taylor Street. The  
entrance to the parking garage will be immediately to
your right.

FROM THE SOUTH: Take 90/94 Nor th (Dan Ryan Expressway). Pass to the  
far right lane and take the Roosevelt Ave exit,
Exit 52B. Stay in the middle or far right lane and go straight  
through the first intersection, paralleling the expressway. Turn
left onto Taylor Street. The entrance to the parking garage will be  
to your right.

FROM THE WEST: Take 290 East (Eisenhower Expressway) to 90/94 South  
(Dan Ryan Expressway). Immediately exit to
the right onto Taylor Street/Roosevelt Ave, Exit 52A. Stay to the  
right and turn right at the light onto Taylor Street. The
entrance to the parking garage will be immediately to your right.
FROM THE EAST: In the Loop area, take Harrison Street. Proceed west  
and turn left onto Halsted Street. Continue South
on Halsted, turn left onto Taylor and left again into the parking  
garage.


Food Donations
--

Roy Talman & Associate


About ChiPy
---

ChiPy is a group of Chicago Python Programmers, l33t, and n00bs.
Meetings are held monthly at various locations around Chicago.
Also, ChiPy is a proud sponsor of many Open Source and Educational
efforts in Chicago. Stay tuned to the mailing list for more info.

ChiPy website: 
ChiPy Mailing List: 
Python website: 

** "ChiPy the Chipmunk" is a fictitious character. Any similarity to  
actual chipmunks, living or dead, is purely coincidental.

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


(Re)announcing APL 2007

2007-08-05 Thread Mike Kent

APL 2007 conference on Array Programming

 co-located with OOPSLA 2007


Sponsor:  ACM SIGAPL

Where:Montreal

When: October 21 (tutorials)
   October 22/23  (main conference program)

Keynote   Guy Steele
speaker:  Sun Microsystems Laboratories


Links:
 Info: http://www.sigapl.org/apl2007.html
 Registration: http://www.regmaster.com/conf/OOP07/oop07.pdf

 OOPSLA:   http://www.OOPSLA.org/oopsla2007
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread Martin v. Löwis
John J. Lee schrieb:
> "Martin v. Löwis" <[EMAIL PROTECTED]> writes:
> [... snip stuff I don't follow ...]
>> However, it *is* a design goal to make 2.6 so that transition to
>> 3k becomes simpler. That's not a 3k feature, but a 2.6 one.
> 
> Not sure I care about this sort of thing for the purpses of my
> question.  I just wanted to know: is it easy to make my code so it
> runs on 2.6 and 3.0, without funny stuff like a code translator?
> Seems wikipedia said "yes" and Guido said "no".

Neither of these are qualified to make any statements about your
code. Only you can find out yourself. OTOH, neither of these *did*
make any statement about *your* code.

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

Setting default output encoding

2007-08-05 Thread Torsten Bronger
Hallöchen!

I start a python script with subprocess from another Python script
with

python = subprocess.Popen(["python", "myscript.py"],
  stdout=subprocess.PIPE, stderr=subprocess.PIPE)

However, this child script has sys.stdout.encoding set to None,
which means that Unicode strings cannot be printed without trouble.
I tried

environment = os.environ
environment["LC_CTYPE"] = environment["LANG"] = "de_DE.UTF-8"
python = subprocess.Popen(["python", "myscript.py"],
  env = environment,
  stdout=subprocess.PIPE, stderr=subprocess.PIPE)

for setting it to UTF-8, however, it didn't work.  Any idea on how
to achieve this?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
  (See http://ime.webhop.org for ICQ, MSN, etc.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread Carsten Haese
On Sun, 2007-08-05 at 23:09 +, John J. Lee wrote:
> I just wanted to know: is it easy to make my code so it
> runs on 2.6 and 3.0, without funny stuff like a code translator?

That depends on your definitions of "easy" and "funny stuff." I'm pretty
sure you'll be able to run the same source code on Python 2.6 and Python
3.0 without either one breaking, as long as the code is written
sufficiently carefully. You may have to give up some Python 3.0 features
and/or write compatibility shims depending on what features you'll need.
Whether that's acceptable depends on the features you need and how much
"yak shaving" you find acceptable.

For instance, if you never use print statements in your code, you won't
notice that print is becoming a function. If you do, you'll have to make
appropriate accommodations.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: Setting default output encoding

2007-08-05 Thread Martin v. Löwis
> python = subprocess.Popen(["python", "myscript.py"],
>   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> 
> However, this child script has sys.stdout.encoding set to None,
> which means that Unicode strings cannot be printed without trouble.

The automatic setting of .encoding is only done when the output is a
terminal. If you write to a file, or a pipe, Python's guess as to what
the encoding of that stream is might be easily wrong.

If you want to be able to write Unicode strings to stdout always,
it's best to wrap stdout with the result of codecs.getwriter. If
you want to use the user's locale as the encoding, use
locale.getpreferredencoding().

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


Something in the function tutorial confused me.

2007-08-05 Thread Lee Fleming
Hello,
I have a simple question. Say you have the following function:

def f(x, y = []):
y.append(x)
return y

print f(23)  # prints [23]
print f(42)  # prints [23, 42]

As far as I understand, the default value y, an empty list, is created
when the def statement evaluates. With this thought in mind, the above
calls
to f make sense.

But this, the code that "fixes" the list accumulation confounds me:
def  f(x, y=None):
if y is None: y = []
y.append(x)
return y

print f(23)  # prints [23]
print f(42)  # prints [42]

Why didn't the second call to f, f(42) return [23, 42]?
As I understand it, y is only None at the beginning of f(23).
Then y changes from None to 23. When f ends, doesn't y still have 23
in it,
just as it did in the first function I discussed?
And if y has 23 in it, won't the second call to f not execute what's
in the if statement?

In other words, what's going on here? How is it that y accumulates
argument values between function calls in the first function, but
doesn't in the second one?

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