Re: problem adding list values

2005-12-22 Thread Tomasz Lisowski
Dave Hansen wrote:
> I think what you want is 
> 
>for cr in credlist:
>   credits += cr
> 
> Which could also be implemented as
> 
>credits = reduce(lambda x,y: x+y, credlist)

or even:

credits = sum(credlist)

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


Re: newbie: concatenate literals (using jython)

2005-12-22 Thread Tomasz Lisowski
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
> 
> 
>>I'm using Jython (actually WebLogic WLST), and trying to do something
>>really simple.  I want to create a string from two function calls and a
>>literal, like:
>>
>>  serverport = server.getListenAddress() + ':' + server.getListenPort()
>>
>>This complains:
>>
>>TypeError: __add__ nor __radd__ defined for these operands
>>
>>I've looked at various references, and this seems like the way I'm
>>supposed to do this, but I'm obviously missing something.  Note that
>>"getListenPort()" returns an int.  Is that a problem?
> 
> 
> yes.  python's string concatenation operator doesn't convert things nilly-
> willy (should "1"+1 be 2 or "11" ?).  to convert an object to a string, use
> str(obj).  see this tutorial section for more info:
> 
> http://docs.python.org/tut/node9.html#SECTION00910
> 
> 
> 
> 
> 
You are right, Fredrik, but David is using Jython, so perhaps he tried 
to mimic the Java language behaviour, where adding ints and strings is 
perfectly valid :)

I admit, though, that I do not know much about Jython apart from the 
fact, that it is somehow related to Java ...

Best regards,
Tomasz Lisowski
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A simple list question.

2005-12-22 Thread Tomasz Lisowski
KraftDiner wrote:
> I am trying to implement a two dimensional array.
> mylist = [[a,b,c],[d,e,f,c],[g,h,i]]
> 
> So the array is of length 3 here...
> So how do I initialize this array and then set each object?
> At some point in my code I know there will be 3 lists in the list.
> So how do I initialize this list such that I can access them
> as elements... like
> mylist[1] = [c,f,g]
> in random order...
> 
Why not just say:

mylist = [[], [], []]

since you know, that this array will have a length of 3.

Then you can safely use append. I am not quite sure, though, what you 
mean by accessing the elements in random order. What's the idea behind 
having mylist[1] = [c,f,g], when the elements c, f, and g are apread 
across all three internal lists, and at various position within these 
lists (not necessarily 1, as the mylist index suggests).

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


Re: Which Python web framework is most like Ruby on Rails?

2005-12-22 Thread Robert Kern
Paul Rubin wrote:

> Hmmm.  I seem to remember RMS saying that the GPL didn't extend to
> Emacs Lisp functions that the user writes, even though those call
> various built-in Emacs functions, as long as they use the documented
> API.  Those certainly run in the same address space as Emacs.  This is
> the closest thing I can think of to the Karrigell situation.

RMS has said precisely the opposite, in fact.

http://lists.debian.org/debian-legal/2002/11/msg00217.html

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: Which Python web framework is most like Ruby on Rails?

2005-12-22 Thread Robert Kern
Paul Rubin wrote:
> Jeff Rush <[EMAIL PROTECTED]> writes:
> 
>>Your only solution would be a proprietary license that states you
>>purchased this program and don't have the right to pass it on to
>>others, similar to ActiveState or somesuch.
> 
> It sounds like that's what Kent wants to do with the apps that he's
> building.  That's not permitted under the GPL, if the apps contain or
> are based on GPL code.  What's not totally clear is whether that
> affects Karrigell apps (apps that run under Karrigell and call
> Karrigell functions but don't modify Karrigell itself).  

I believe that it's the FSF's view that importing a GPLed module triggers the
GPL conditions in analogy with dynamic linking for C and other such languages
(presuming the code is being distributed at all). I think it's reasonably safe
to say that most authors who choose the GPL deliberately also assume the FSF's
interpretation. Debian, for example, also holds to this interpretation and will
reject a GPL-incompatible Python package that imports a GPLed Python package as
not legal to distribute.

No court has ever ruled on the issue, and some people, like Larry Rosen, think
it's likely that a judge would not choose the FSF's interpretation. I think
Rosen is probably correct. However, I always assume that the author intends the
FSF's interpretation unless they make an explicit exception, and I respect that
intention.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: Guido at Google

2005-12-22 Thread Anand
> It's like having James Bond as your very own personal body guard ;)

That is such a nice quote that I am going to put it in my email
signature ! :)

-Anand

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


Re: call static function from extension module - syntaxerror

2005-12-22 Thread Erik Max Francis
Todd wrote:

> I'm working right from the example here to make a basic extenstion
> module.
> http://docs.python.org/ext/intro.html
> http://www.dalkescientific.com/writings/diary/archive/2005/04/26/extending_python.html
> 
> I can load my module into python and dir shows my function.  But I get
> a syntax error if I try to access it.
> 
 ast_man.exec
>   File "", line 1
> ast_man.exec
>^
> SyntaxError: invalid syntax
> 
> However, I can get at it using getattr.  I tried compiling myself and
> using setup.  My method is defined as
> 
> static PyMethodDef ast_man_methods[] = {
> {"exec",exec,METH_VARARGS,"Execute Asterisk commands."},
> {NULL,NULL,0,NULL}
> };
> 
> What might be my problem??

exec is a reserved word.

 >>> exec 'print 1'
1
 >>> exec = 1
   File "", line 1
 exec = 1
  ^
SyntaxError: invalid syntax

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   We have lingered long enough on the shores of the cosmic ocean.
   -- Carl Sagan, 1934-1996
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which Python web framework is most like Ruby on Rails?

2005-12-22 Thread Paul Rubin
Jeff Rush <[EMAIL PROTECTED]> writes:
> Your only solution would be a proprietary license that states you
> purchased this program and don't have the right to pass it on to
> others, similar to ActiveState or somesuch.

It sounds like that's what Kent wants to do with the apps that he's
building.  That's not permitted under the GPL, if the apps contain or
are based on GPL code.  What's not totally clear is whether that
affects Karrigell apps (apps that run under Karrigell and call
Karrigell functions but don't modify Karrigell itself).  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Providing 'default' value with raw_input()?

2005-12-22 Thread Alex Martelli
Bengt Richter <[EMAIL PROTECTED]> wrote:
   ...
> If you want to edit text, maybe the best thing is a text editor?
> Why not write it into a temp file and start the user's favorite editor

Agreed.  There's a recipe for that in the online Python Cookbook, and we
edited and enhanced that into the 2nd edition of the printed (O'Reilly)
Python Cookbook, too.


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


Re: Which Python web framework is most like Ruby on Rails?

2005-12-22 Thread Jeff Rush
Kent Johnson wrote:

>Luis M. Gonzalez wrote:
>  
>
>>The only problem with KARRIGELL, I guess, is that its creator is very
>>humble and doesn't like to advertise his creature. He is not very fond
>>of "marketing" ...
>>
>>
>From my point of view the biggest problem with Karrigell is that it is 
>released under the 
>GPL. Most of my projects at least have the potential of being distributed to 
>customers and 
>GPL is not an option.
>  
>
I don't understand your issue, as it applies to Python programs.

The GPL would (a) require you to supply the source to your customers, 
and (b) allow them
to pass it on to others.  But since Python programs are delivered as 
source (.py files), or easily
decompiled bytecode (.pyc file), they have the source anyway, as well as 
the static HTML
files for your app.

Python doesn't have a secure binary-only distribution format, so the 
question of protecting
your IP via an obscurement mechanism is moot.

And using a BSD-like license doesn't help since they still have the 
source in Python, and
BSD allows them to redistribute that.

Your only solution would be a proprietary license that states you 
purchased this program
and don't have the right to pass it on to others, similar to ActiveState 
or somesuch.

The real hook would seem to be the social one that you provide support 
and improvements
so they need to keep you in business.

-Jeff

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


call static function from extension module - syntaxerror

2005-12-22 Thread Todd
Hi,

I'm working right from the example here to make a basic extenstion
module.
http://docs.python.org/ext/intro.html
http://www.dalkescientific.com/writings/diary/archive/2005/04/26/extending_python.html

I can load my module into python and dir shows my function.  But I get
a syntax error if I try to access it.

>>> ast_man.exec
  File "", line 1
ast_man.exec
   ^
SyntaxError: invalid syntax

However, I can get at it using getattr.  I tried compiling myself and
using setup.  My method is defined as

static PyMethodDef ast_man_methods[] = {
{"exec",exec,METH_VARARGS,"Execute Asterisk commands."},
{NULL,NULL,0,NULL}
};

What might be my problem??

thanks

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


Re: print UTF-8 file with BOM

2005-12-22 Thread Kevin Yuan
import codecsdef read_utf8_txt_file (filename):    fileObj = codecs.open( filename, "r", "utf-8" )    content = fileObj.read()    content = content[1:] #exclude BOM
    print content
    fileObj.close()    read_utf8_txt_file("e:\\u.txt")22 Dec 2005 18:12:28 -0800, [EMAIL PROTECTED] <
[EMAIL PROTECTED]>:Hi Friends:fileObj = codecs.open( filename, "r", "utf-8" )
u = fileObj.read() # Returns a Unicode string from the UTF-8 bytes inthe fileprint uIt says error:UnicodeEncodeError: 'gbk' codec can't encode character u'\ufeff' inposition 0:
illegal multibyte sequenceI want to know how read from UTF-8 file, and convert to specifiedlocale (default is current system locale) and print out string. I hopeput away BOM header automatically.
Rgds, David--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Providing 'default' value with raw_input()?

2005-12-22 Thread Bengt Richter
On 22 Dec 2005 12:42:36 -0800, "planetthoughtful" <[EMAIL PROTECTED]> wrote:

>
>Bengt Richter wrote:
>> On 22 Dec 2005 08:55:17 -0800, "planetthoughtful" <[EMAIL PROTECTED]> wrote:
>>
>
>> >I would like to include the ability to edit an existing value (drawn
>> >from an SQLite table) using a DOS console Python app, but my gut
>> >feeling from reading what I can find about raw_input() is that it only
>> >allows you to provide a prompt, not a default value as well.
>> >
>> What's wrong with showing the default in the prompt itself? The thing is
>> what user input in response should signify the default? E.g., maybe a single
>> period by itself could mean "use the default" and nothing could mean "no 
>> change"
>> and other input would be a new value.
>
>Hi Bengt,
>
>I think that would be a great solution if the value being 'edited' was
>relatively short, or numeric, etc. But the values I want to 'edit' can
>be several hundred characters long (ie they're text fields containing
>todo notes), and using your method, I'd either accept the existing
>value, or have to retype the text for that record. I think I mislead
>people when I used the word 'default' -- I meant in the sense of being
>able to edit the existing value, so that value, out of each record,
>would be presented as the 'default', available for editing.
>
>Sorry for the confusion.
>
If you want to edit text, maybe the best thing is a text editor?
Why not write it into a temp file and start the user's favorite editor
on it, and when done, read the file back into python and delete the temp.
Maybe check whether any changes actually happened before updating the DB.

os.popen{2,3,4} and tempfile module might help.

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


Re: Providing 'default' value with raw_input()?

2005-12-22 Thread Roger Upole
If you have Pywin32 build 205 installed, you can use the
win32console module to add the data to the typeahead
buffer before you call raw_input.

import win32console
stdin=win32console.GetStdHandle(win32console.STD_INPUT_HANDLE)

def raw_input_with_default(prompt, default_val):
keypresses=[]
for c in default_val:
evt=win32console.PyINPUT_RECORDType(win32console.KEY_EVENT)
evt.Char=unicode(c)
evt.RepeatCount=1
evt.KeyDown=True
keypresses.append(evt)
stdin.WriteConsoleInput(keypresses)
return raw_input(prompt)

data=raw_input_with_default('modify this: ','some data')
print data

   hth
 Roger


"planetthoughtful" <[EMAIL PROTECTED]> wrote:
> Hi Steve,
>
> As keir mentioned, my goal is to be able to edit the value returned
> from a record stored in SQLite, so that it can be updated with the new
> value.
>
> To give a little background: as a learning exercise I'm writing a
> command line app that will allow me to quickly capture todo items
> (based on a similar concept used by an app for the Mac described on
> 43folders.com). I have the functionality working for adding todo items,
> and listing items by various criteria, and updating the status of
> items, but haven't included any functionality for being able to edit
> items.
>
> It seems, according to kier, that this simply can't be done via the
> command line in DOS, which is a shame.
>
> Sorry I didn't explain myself very well in my original post.
>
> Much warmth,
>
> planetthoughtful
>




== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wingide is a beautiful application

2005-12-22 Thread jussij
> I gave Zeus a try and it passed loading of a large (100 MByte)
> text file (many other text editors fail here).

Zeus is not designed as a large file editor :(

It will try to load the entire file into memory so when you open
these very large files the RAM is quickly used up.

> It looks at the first glance quite good, but I am a bit lost
> because of so many different menu items.

Zeus is fairly complex just because it has so many features (ie class
browsing, intellisening, compiler support, ftp editing, templates,
macros, workspaces etc etc).

For this reason I would recommend:
1) Select the Help, Help Contents Menu
2) Click on the User Manual section
3) Click on the Quick Start section
3) Read a few of the Quick Start links

> Compared to UltraEdit/SPE I am missing the column mode I
> extensively use in my everyday work (rectangular select/copy/paste
> is there)

Zeus has several text marking modes one of which is column marking:

   http://www.zeusedit.com/forum/viewtopic.php?t=60
   http://www.zeusedit.com/forum/viewtopic.php?t=197

> and the autocompletion of any input word as e.g. a very long
> variable names I have defined in preceeding text.

This feature should be available via the Edit, Auto Complete Word
menu. If it is not working correctly this could be a bug :(

> I was not yet able to find how to change the font in the text area

Options, Editor Options menu, Fonts section and change the
baseline font for the Document View.

> and how to get rid of the italics used for displaying strings.

The syntax highlighting is defined in what Zeus calls a document
type. These are listed using the Options Document Types menu.

So for example to change this for the Python files, edit the
Python Document Type and in the Coloring section, select the
line and block comment categories and un-check the italic
option for this category.

> In UltraEdit I can choose any font in any style available
> on the system for the text area and in the syntax highlighting
> I can use bold/italics style.

The two menus mentioned above do exactly this.

> Code folding for Python is there, but I run into the problem
> of not folding the code of a Python class.

If you post a small example of code to the code folding
section of the Zeus forum:

  http://www.zeusedit.com/forum/viewforum.php?f=8

This will be get fix if it is at all possible to do so.

> but probably with not sufficient support for Python specifics,

Just out of curiosity, what "Python specifics" features would
think are missing?

> In my eyes with $40 for a license a worth to be evaluated
> professional editor, but not for me because of lack(?) of
> the column mode and not (yet?) found possibility to select
> a font for the in the editing area displayed text.

As mentioned above, Zeus does have these features ;)

Jussi Jumppanen
Author: Zeus for Windows

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


Re: Guido at Google

2005-12-22 Thread Alex Martelli
Bugs <[EMAIL PROTECTED]> wrote:

> So when *is* someone (either Guido himself or Google) going to 
> officially announce that Guido has moved to Google?  If at all?

I don't think any official announcement is planned.

> Also, it would be nice to know from Guido's perspective what, if any at
> all, impact this will have on Python?

I'll leave this to Guido to answer, if he wants to.

> Maybe here?  http://www.artima.com/weblogs/index.jsp?blogger=guido  Is
> this Guido's official blog?

I believe so, yes.


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


Re: Guido at Google

2005-12-22 Thread Alex Martelli
rbt <[EMAIL PROTECTED]> wrote:
   ...
> > His founder, Mark Shuttleworth, is a python fan.
> 
> Aren't most all intelligent people Python fans?

No: I know many intelligent people who are not Python fans, ranging from
the Perl crowd (lot of great, bright people who however prefer Perl to
Python) to Ruby fans, from the C++ intelligentsia to the Java
in-crowd... hard to explain, for sure, but, there you are!


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


Re: Guido at Google

2005-12-22 Thread Alex Martelli
Bengt Richter <[EMAIL PROTECTED]> wrote:

> On Thu, 22 Dec 2005 09:07:26 -0800, [EMAIL PROTECTED] (Alex Martelli)
> wrote:
> 
> >Renato <[EMAIL PROTECTED]> wrote:
> >
> >> all of the native administration tools of RedHat (all versions) and
> >> Fedora Core are written in python (system-config-* and/or
> >> redhat-config-* ). And even more importantly, yum (the official
> >> software package manager for Fedora and RHEL) and Anaconda (OS
> >> installer) are written in Python, too.
> >
> >BTW, Chip Turner (from RedHat, and deeply involved in those
> >developments) happened to start at Google the same day I did;-).
> >
> So is google about to determine how many luminaries can fit on the head of
> a project? ;-) Seriously, if you heavies do sometimes work on the same
> project, it would be interesting to know what modes of co-operation you
> tend to adopt.

Google's official position (per the article Hal Varian and Eric Schmidt
wrote recently) is that we are a "consensus-oriented culture".  I _have_
worked in companies with consensus-oriented cultures, such as IBM in the
'80s (where it sometimes paralized everything, since one manager's
"non-concur" was enough to block progress on a project), and I would
respectfully disagree (on this point only -- the rest of their article
is quite consonant with my personal experiences) with our beloved leader
and our most excellent advisor.  I would say we're a *results-oriented*
corporate culture... sometimes egos may get bruised, but we're all
supposed to have small-enough, resilient-enough egos to survive and
remain happy and productive anyway;-).  Check the xooglers' blog for
others' opinions...


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


Re: Guido at Google

2005-12-22 Thread Ilias Lazaridis
Greg Stein wrote:
> Guido would acknowledge a query, but never announce it. That's not his
> style.
> 
> This should have a positive impact on Python. His job description has a
> *very* significant portion of his time dedicated specifically to
> working on Python. (much more than his previous "one day a week" jobs
> have given him)

Doeas anyone at google realize the threat?

Mr. van Rossum should have 100% of his time for working on Python at 
least for around 3 to 6 months.

50% for working on it (whilst simply having fun, as he should)

50% for _decoupling_ the strong-dependency of the python-development 
from his person, thus python-evolution is ensured. This would involve to 
clarify, document and to communicate the need to the community (which 
seems to partially have a strong dependency, too).

.

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


Re: Guido at Google

2005-12-22 Thread Alex Martelli
Nicola Musatti <[EMAIL PROTECTED]> wrote:

> Alex Martelli wrote:
> > Renato <[EMAIL PROTECTED]> wrote:
> >
> > > all of the native administration tools of RedHat (all versions) and
> > > Fedora Core are written in python (system-config-* and/or
> > > redhat-config-* ). And even more importantly, yum (the official
> > > software package manager for Fedora and RHEL) and Anaconda (OS
> > > installer) are written in Python, too.
> >
> > BTW, Chip Turner (from RedHat, and deeply involved in those
> > developments) happened to start at Google the same day I did;-).
> 
> Ah, the closed source days! Back then you could just buy the company
> and be done with it. Now you have to chase developers one by one all
> over the world... ;-)

Well, you can STILL buy the company -- eBay's bought Skipe (and a slice
of craigslist), Yahoo's bought delicious and flickr, we've bought
Keyhole (and a tiny slice of AOL)... just to mention recent and salient
acquisitions...;-)


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


Re: Guido at Google

2005-12-22 Thread Ilias Lazaridis
Thomas Wouters wrote:
[...]

thank you for your comments.

-

TAG.python.evolution.negate

.

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


Re: Guido at Google

2005-12-22 Thread Ilias Lazaridis
Fredrik Lundh wrote:
> Gary Herron wrote:
> 
> 
>>So how about it... What's your complaint, what's your solution, and why
>>should we listen?
> 
> Nobody will ever know.  

simply review this explanations:

http://lazaridis.com/core/index.html

some people have already understood this in the past.

> Check the comp.lang.python/ruby/lisp/etc archives
> for more.

evaluations will be listed here shortly:

http://lazaridis.com/core/eval/index.html

(if you find an itresting topic, please send the link)

> 

.

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


Re: Guido at Google

2005-12-22 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> This is interesting. With more Python time in Guido's hands maybe Py
> 3.0 is a bit closer... :-)
> 
> I don't know if this is a silly idea:
> A small part of the wealth of a modern state is probably determined by
> the software it uses/produces, and a small part of this software is
> open source or free. This free sofware is used by a lot of people, and
> they probably use it to work too, etc.
> For a modern government, paying a salary to few (20?) very good open
> source programmers can make the whole society "earn" maybe 10 or more
> times that money... (The money given from EU to PyPy can be an example
> of this).

No, it's not a silly idea. Dean Baker, the Co-Director the Center for Economic
and Policy Research, has proposed for the U.S. government to establish a
Software Developer's Corps. For $2 billion per year, it could fund about 20,000
developers to make open source software. Much of that software would be directly
usable by local, state, and federal governments and thus pay back some, all, or
more of the investment (Dean estimates more). In addition, the general public
also benefits directly.

http://www.cepr.net/publications/windows_2005_10.pdf

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: Python IMAP4 Memory Error

2005-12-22 Thread Dody Suria Wijaya
Noah wrote:
> This looks like a bug in your build of Python 2.4.2 for Windows.
> Basically it means that C's malloc() function in the Python interpreter
> failed.
> 

On a second trial, it's also failed on Python 2.3.5 for Windows, Python 
2.3.3 for Windows, and Python 2.2.3 for Windows. So this seems to me as 
a Windows system related bug, not a particular version of Python bug.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IMAP4 Memory Error

2005-12-22 Thread Dody Suria Wijaya
Fredrik Lundh wrote:
> try adding a print statement to lib/imaplib.py, just before that read
> statement,
> 
> print size, read, size-read
> data = self.sslobj.read(size-read)
> 
> and let us know what it prints.

14130601 0 14130601
14130601 16353 14114248
14130601 32737 14097864
14130601 49121 14081480
14130601 65505 14065096
14130601 81889 14048712
14130601 94705 14035896
14130601 111089 14019512
14130601 127473 14003128
14130601 143857 13986744
14130601 160241 13970360
14130601 176625 13953976
14130601 192525 13938076
14130601 208909 13921692
14130601 221725 13908876
14130601 238109 13892492
14130601 254493 13876108
14130601 270877 13859724
14130601 287261 13843340
14130601 303645 13826956
14130601 319053 13811548
14130601 335437 13795164
14130601 340953 13789648
14130601 357337 13773264
14130601 373721 13756880
14130601 390105 13740496
14130601 406489 13724112
14130601 422873 13707728
14130601 429685 13700916
14130601 444285 13686316
14130601 460669 13669932
14130601 477053 13653548
14130601 493437 13637164
14130601 509821 13620780
14130601 526205 13604396
14130601 531557 13599044
14130601 547941 13582660
14130601 553457 13577144
14130601 569841 13560760
14130601 586225 13544376
14130601 602609 13527992
14130601 618993 13511608
14130601 635377 13495224
14130601 651761 13478840
14130601 668145 13462456
14130601 677229 13453372
14130601 693613 13436988
14130601 706429 13424172
14130601 722813 13407788
14130601 739197 13391404
14130601 755581 13375020
14130601 771965 13358636
14130601 788349 13342252
14130601 793701 13336900
14130601 801001 13329600
14130601 817385 13313216
14130601 833769 13296832
14130601 850153 13280448
14130601 866537 13264064
14130601 882921 13247680
14130601 895737 13234864
14130601 912121 13218480
14130601 928505 13202096
14130601 944889 13185712
14130601 961273 13169328
14130601 977657 13152944
14130601 983009 13147592
14130601 999393 13131208
14130601 1004909 13125692
14130601 1021293 13109308
14130601 1037677 13092924
14130601 1054061 13076540
14130601 1070445 13060156
14130601 1086829 13043772
14130601 1098185 13032416
14130601 1114569 13016032
14130601 1130953 12999648
14130601 1147337 12983264
14130601 1163721 12966880
14130601 1180105 12950496
14130601 1191625 12938976
14130601 1208009 12922592
14130601 1213525 12917076
14130601 1229909 12900692
14130601 1246293 12884308
14130601 1262677 12867924
14130601 1279061 12851540
14130601 1295445 12835156
14130601 1309393 12821208
14130601 1325777 12804824
14130601 1342161 12788440
14130601 1358545 12772056
14130601 1374929 12755672
14130601 1391313 12739288
14130601 1407697 12722904
14130601 1424081 12706520
14130601 1440465 12690136
14130601 1456849 12673752
14130601 1462365 12668236
14130601 1478749 12651852
14130601 1495133 12635468
14130601 1511517 12619084
14130601 1527901 12602700
14130601 1544285 12586316
14130601 1556937 12573664
14130601 1573321 12557280
14130601 1589705 12540896
14130601 1606089 12524512
14130601 1622473 12508128
14130601 1638857 12491744
14130601 1645669 12484932
14130601 1660269 12470332
14130601 1676653 12453948
14130601 1693037 12437564
14130601 1699689 12430912
14130601 1716073 12414528
14130601 1732457 12398144
14130601 1748841 12381760
14130601 1765225 12365376
14130601 1781609 12348992
14130601 1790045 12340556
14130601 1806429 12324172
14130601 1822813 12307788
14130601 1839197 12291404
14130601 1855581 12275020
14130601 1871965 12258636
14130601 1884617 12245984
14130601 1901001 12229600
14130601 1917385 12213216
14130601 1933769 12196832
14130601 1950153 12180448
14130601 1966537 12164064
14130601 1978057 12152544
14130601 1994441 12136160
14130601 157 12130644
14130601 2016341 12114260
14130601 2032725 12097876
14130601 2049109 12081492
14130601 2065493 12065108
14130601 2081877 12048724
14130601 2095825 12034776
14130601 2112209 12018392
14130601 2125025 12005576
14130601 2141409 11989192
14130601 2157793 11972808
14130601 2174177 11956424
14130601 2190561 11940040
14130601 2206945 11923656
14130601 2217005 11913596
14130601 2228193 11902408
14130601 2244577 11886024
14130601 2260961 11869640
14130601 2277345 11853256
14130601 2293729 11836872
Traceback (most recent call last):
   File "imap_tikikuli_monitor.py", line 15, in ?
 typ, data = M.fetch(num, '(RFC822)')
   File "c:\python24\lib\imaplib.py", line 426, in fetch
 typ, dat = self._simple_command(name, message_set, message_parts)
   File "c:\python24\lib\imaplib.py", line 1028, in _simple_command
 return self._command_complete(name, self._command(name, *args))
   File "c:\python24\lib\imaplib.py", line 858, in _command_complete
 typ, data = self._get_tagged_response(tag)
   File "c:\python24\lib\imaplib.py", line 959, in _get_tagged_response
 self._get_response()
   File "c:\python24\lib\imaplib.py", line 921, in _get_response
 data = self.read(size)
   File "c:\python24\lib\imaplib.py", line 1124, in read
 data = self.sslobj.read(size-read)
MemoryError




If I change the code to use non

Re: Guido at Google

2005-12-22 Thread Ilias Lazaridis
[EMAIL PROTECTED] wrote:
> Ilias Lazaridis wrote:
[...]

>> http://lazaridis.com/case/lang/python.html
[...]

> Hi there, I wonder what comments you would have about XOTCL, or other
>  OO extensions for tcl, like snit, and dozens more. I looked at the 
> various scripting languages available to me and decided to go with 
> tcl as it seemed the most versatile. I can't find it on your page 
> though. 
> Regards.

I had myself a positive impression about TCL, but a negative one with 
the community (and with the many OO extensions for TCL, which would be a 
sub-evaluation):

[JAMLANG] - Comparative Evaluation - Draft Version
http://groups.google.com/group/comp.lang.tcl/browse_frm/thread/8791f3b541d976f5

If you like, you can fill in the evaluation based on tcl/XOTCL (which
would be published then).

http://lazaridis.com/case/lang/index.html

you can alternatively sent a text-file via email.

If you have further questions, please contact me with private email.

Thank you for your intrest.

Best Regards,

Ilias Lazaridis

.

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


Re: Wingide is a beautiful application

2005-12-22 Thread Claudio Grondi
[EMAIL PROTECTED] wrote:
>>I don't like, that one of the latest UltraEdit releases
>>was buggy causing 100%CPU load and 2MByte of harddisk
>>data traffic beeing idle, so I am looking for an alternative
>>for years, but instead of finding it I was forced lately
>>to spend money again on renewing my license.
> 
> 
> Have you tried the Zeus for Windows programmers editor:
> 
>http://www.zeusedit.com
> 
> Zeus is closed source, but it is also very stable, comes
> with support for Python and you can even write Zeus
> scripts using Python.
> 
> Like all software it also has bugs, but when a bug is
> reported it is fixed ASAP and a free patch is then
> offered for download.
> 
> Jussi Jumppanen
> Author: Zeus for Windows
> 

I was not aware of Zeus, so thank you for telling me about it.

I gave Zeus a try and it passed loading of a large (100 MByte) text file 
(many other text editors fail here). It looks at the first glance quite 
good, but I am a bit lost because of so many different menu items.

Compared to UltraEdit/SPE I am missing the column mode I extensively use 
in my everyday work (rectangular select/copy/paste is there) and the 
autocompletion of any input word as e.g. a very long variable names I 
have defined in preceeding text.

I was not yet able to find how to change the font in the text area and 
how to get rid of the italics used for displaying strings. In UltraEdit 
  I can choose any font in any style available on the system for the 
text area and in the syntax highlighting I can use bold/italics style.
Configuration of colors and keyboard keys seem to be there, macro 
recording/playing, too. The line numbering has a small delay behind the 
displayed text what is a bit annoying (but only when going to the end of 
the 100 MByte file), but sure not a problem. Code folding for Python is 
there, but I run into the problem of not folding the code of a Python 
class.

I have not put much time into the evaluation yet, but my impression is, 
that it is a professional editor, focused on supporting programming and 
compilation of C programs, but probably with not sufficient support for 
Python specifics, except the Python syntax in writing macros, where 
access to the edit window is got with 'import zeus' and the macro itself 
is just Python code using the imported module and working on the opened 
text.

In my eyes with $40 for a license a worth to be evaluated professional 
editor, but not for me because of lack(?) of the column mode and not 
(yet?) found possibility to select a font for the in the editing area 
displayed text.

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


[ANN] python-dateutil 1.1

2005-12-22 Thread Gustavo Niemeyer

Changes since 1.0
-

- Fixed rrule byyearday handling. Abramo Bagnara pointed out that
  RFC2445 allows negative numbers.

- Fixed --prefix handling in setup.py (by Sidnei da Silva).

- Now tz.gettz() returns a tzlocal instance when not given any
  arguments and no other timezone information is found.

- Updated timezone information to version 2005q.


What is it?
---
The dateutil module provides powerful extensions to the standard
datetime module, available in Python 2.3+.


Features


* Computing of relative deltas (next month, next year,
  next monday, last week of month, and a lot more);

* Computing of relative deltas between two given
  date and/or datetime objects;

* Computing of dates based on very flexible recurrence rules
  (every month, every week on Thursday and Friday, every
  Friday 13th, and a *LOT* more), using a superset of the
  iCalendar RFC specification. Parsing of RFC strings is
  supported as well.

* Generic parsing of dates in almost any string format;

* Timezone (tzinfo) implementations for tzfile(5) format
  files (/etc/localtime, /usr/share/zoneinfo, etc), TZ
  environment string (in all known formats), iCalendar
  format files, given ranges (with help from relative deltas),
  local machine timezone, fixed offset timezone, UTC
  timezone, and Windows registry-based timezones.

* Internal up-to-date world timezone information based on
  Olson's database.

* Computing of Easter Sunday dates for any given year,
  using Western, Orthodox or Julian algorithms;

* More than 450 test cases.


Where to get it?

http://labix.org/python-dateutil


-- 
Gustavo Niemeyer
http://niemeyer.net
-- 
http://mail.python.org/mailman/listinfo/python-list


"Humane" programmer interfaces

2005-12-22 Thread Dave Benjamin
There's been a lot of discussion lately regarding Ruby and the notion of a 
"humane" interface to objects like arrays and maps, as opposed to
"minimalist" ones. I believe the article that started the debates was this 
one by Martin Fowler:

http://www.developertesting.com/archives/month200512/20051218-HumaneInterfaceOfMinimalInterface.html

And this one was posted in response by Bruce Eckel:

http://www.artima.com/forums/flat.jsp?forum=106&thread=141312

When I see the term "Humane Interface", I immediately think of the book 
"The Humane Interface" by the late Jef Raskin. Although this book mainly 
focuses on GUI interaction, it is also about the human-computer interface 
in general, and makes some points that apply to the programming experience 
as well.

The irony, I find, is that Raskin's definition of a humane interface seems 
to better fit what Fowler describes as "minimalist". Raskin argues that 
two ideals in interface design are what he calls "modelessness" and 
"monotony". The two terms essentially relate to causes and effects.

Modelessness means that the same cause produces the same effect. "Modes" 
are the different states that an application might be in; for example, if 
an app has a "novice" and "expert" mode, the user has to be consciously 
aware of which mode they are in, and performing the same action in 
novice mode may not produce the same result as if it were performed in 
expert mode. This somewhat resembles the notions of referential 
transparency, side-effects, global and shared state in programming.

The other side of the coin, "monotony", says that one effect should have, 
ideally, only one related cause. In a nutshell, "there's only one way to 
do it". Many of the arguments given in this newsgroup in favor of this 
Python design principle use a similar rationale:

"I use the term monotonous, tongue partially in cheek, to describe an 
interface having only one way to accomplish a task (See Appendix B; 
Alzofon and Raskin 1985, p. 95). Monotony is the dual of modelessness in 
an interface. In a modeless interface, a given user gesture has one and 
only one result: Gesture g always results in action a. However, there is 
nothing to prevent a second gesture, h, from also resulting in action a. A 
monotonous interface is one in which any desired result has only one means 
by which it may be invoked: Action a is invoked by gesture g and in no 
other way. An interface that is completely modeless and monotonous has a 
one-to-one correspondence between cause (commands) and effect (actions). 
The more monotony an interface has for a given task space, the easier it 
is for the user to develop automaticity, which, after all, is fostered by 
not having to make decisions about what method to use."

Thus, when I see people claiming that Ruby's array interface is more 
humane because it offers a "last" method as an alternative to the 
equivalent "get" method with a last index, I have trouble reconciling 
these two views. I especially have trouble with the idea that method 
aliases (like "size" and "length" methods that do the same thing) are 
somehow more humane. How is it an advantage that half the programmers 
accomplish a given task with method A, and the other half use method B? It 
doesn't seem much friendlier to me, since I have to look up these aliases 
to make sure my assumption is correct that they are identical. Usually, 
when I see two names for the same thing, I assume there's some (perhaps 
not-so) subtle difference in their purpose.

On the other hand, absolute minimalism may not be the most user-friendly. 
Python's strings support "startswith" and "endswith" methods, which could 
easily be implemented--outside of the string class--in terms of slices. 
However, I love having these methods available off of the string, not 
in some library of string utilities, because they are so handy and so 
often useful (and they save me from having to think about indexes and 
offsets when, conceptually, they are not relevant to the problem at hand).

As an example of the minimalist viewpoint, I highly recommend reading 
Bjarne Stroustrup's interview with Artima from a couple of years ago, 
called "The C++ Style Sweet Spot":

http://www.artima.com/intv/goldilocks.html

In the article, he explains an approach to class design that I have found 
invaluable: giving the class responsible for maintaining the invariant, 
and moving utility methods that do not bear this responsibility into 
utility libraries. If this approach were taken with Python's built-in data 
types, surely a few methods would have to go elsewhere, but I think that 
Python takes a pretty minimalist approach, and encourages the writing of 
utility functions as opposed to making every useful tool "part of the 
core". I think that, in contrast, Ruby goes a bit overboard.

Note that Stroustrup is willing to budge on this ideal for the sake of 
efficiency: "you might have five or ten member functions that are there 
because they are logica

print UTF-8 file with BOM

2005-12-22 Thread davihigh
Hi Friends:

fileObj = codecs.open( filename, "r", "utf-8" )
u = fileObj.read() # Returns a Unicode string from the UTF-8 bytes in
the file
print u

It says error:
UnicodeEncodeError: 'gbk' codec can't encode character u'\ufeff' in
position 0:
illegal multibyte sequence

I want to know how read from UTF-8 file, and convert to specified
locale (default is current system locale) and print out string. I hope
put away BOM header automatically.

Rgds, David

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


Re: Run Oracle stored procedure without ODBC

2005-12-22 Thread hubbardmail
Try http://www.computronix.com/utilities.shtml

Jason

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


Re: Guido at Google

2005-12-22 Thread bearophileHUGS
This is interesting. With more Python time in Guido's hands maybe Py
3.0 is a bit closer... :-)

I don't know if this is a silly idea:
A small part of the wealth of a modern state is probably determined by
the software it uses/produces, and a small part of this software is
open source or free. This free sofware is used by a lot of people, and
they probably use it to work too, etc.
For a modern government, paying a salary to few (20?) very good open
source programmers can make the whole society "earn" maybe 10 or more
times that money... (The money given from EU to PyPy can be an example
of this).

Bye,
bearophile

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


Re: Guido at Google

2005-12-22 Thread Luis M. González
[EMAIL PROTECTED] wrote:
> JB wrote:
>
> > long life to Guido & Goole ! many things to come ;)
>
> Google is merely the new Microsoft and surely just as unethical
> at its core.
>
> And your spelling Goole is probably closer to the mark,
> since it is merely the next ghoulish big company,
> come to restrict our freedoms and blot out the sky.

I beg to disagree.
Google is what it is because it creates good and useful products which
everybody enjoy for free. For doing this, they hire the best guns and,
guess what?
These talented people have to eat, like you and me.
Do you expect them to work for free?
Every company needs to make money, otherwise they would die.
But there are many ways to make it, and I think they are as good and
ethical as they can be.

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


Re: Run Oracle stored procedure without ODBC

2005-12-22 Thread Jorge Godoy
"John61" <[EMAIL PROTECTED]> writes:

> Is there a way to call a stored procedure on an Oracle database using Python 
> with a runtime connection? 

There seems to be a cxOracle (something like that) module that allows
connecting to Oracle.  With it you can connect and call the stored procedure. 

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


Run Oracle stored procedure without ODBC

2005-12-22 Thread John61
Is there a way to call a stored procedure on an Oracle database using Python 
with a runtime connection? 


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


Re: Wingide is a beautiful application

2005-12-22 Thread jussij
> The best not free overall text editing tool on Windows
> is UltraEdit

As I mentioned before, you should give Zeus a test drive.

Many Zeus users think it is the best programming tool for
the Windows platform:

   http://www.zeusedit.com/awards.html

Jussi Jumppanen
Author: Zeus for Windows

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


Re: Socket programming design problem

2005-12-22 Thread Dan Sommers
On Thu, 22 Dec 2005 22:12:09 +,
David <[EMAIL PROTECTED]> wrote:

> a) Big problem, I can't see how to receive from more than one socket
> at once.  I need to do this so that data from the TCP connection can
> be sent out on the UDP one and vice versa.  Do I need a thread for
> each, or is there some other way I can listen on two sockets at once
> (maybe non-blocking ones?)

Try the select module:

http://www.python.org/doc/current/lib/module-select.html

Regards,
Dan

-- 
Dan Sommers

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


Re: Please enlighten me about PyPy

2005-12-22 Thread Luis M. González
> Thanks for clearing up some of my confusion with PyPy, Luis!

Hey, I'm glad you brought up this topic!
This thread really helped me to understand some dark corners of this
exciting project.

I also want to thank Carl and all the other Pypy developers for their
outstanding work!
I've been quietly following the evolution of Pypy through its mailing
list, and I eagerly wait for every new announcement they make, but I
never dared to ask any question fearing that I would look like a fool
amongst these rocket scientist...

Cheers,
Luis

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


Re: Wingide is a beautiful application

2005-12-22 Thread jussij
> I don't like, that one of the latest UltraEdit releases
> was buggy causing 100%CPU load and 2MByte of harddisk
> data traffic beeing idle, so I am looking for an alternative
> for years, but instead of finding it I was forced lately
> to spend money again on renewing my license.

Have you tried the Zeus for Windows programmers editor:

   http://www.zeusedit.com

Zeus is closed source, but it is also very stable, comes
with support for Python and you can even write Zeus
scripts using Python.

Like all software it also has bugs, but when a bug is
reported it is fixed ASAP and a free patch is then
offered for download.

Jussi Jumppanen
Author: Zeus for Windows

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


Re: The Varieties of Pythonic Experience

2005-12-22 Thread Kent Johnson
Robert Hicks wrote:
> You mean Jython is still going?  ; )

Yes, I see the smiley but there are too many "is Jython dead?" posts on the 
Jython lists 
for me to leave this alone...

Jython is going strong. Thanks to Brian Zimmer and a grant from PSF it is under 
active 
development again and working towards compatibility with CPython 2.3. And of 
course the 
current 2.1 release is extremely stable and usable as is.

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


Re: Please enlighten me about PyPy

2005-12-22 Thread Bugs
Scott David Daniels wrote:
> [snip] The big trick is that you can specialize the interpreter for 
> running _its_ input (a Python program), thus giving you a new
> interpreter that only runs your Python program -- a very specialized
> interpreter indeed.
> 
Now THAT will be slick!

What is the current roadmap/timeline for PyPy?

Anyone know if Guido is interested in ever becoming deeply involved in 
the PyPy project?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI and graph

2005-12-22 Thread Kent Johnson
questions? wrote:
> I have a graph with different parameters along different parts of the
> graph.
> 
> I want to have a program that can display the graph with coloring for
> different part of the graph. Is this possible in Python? What should I
> read?

pydot is pretty amazing in its abilitity to make nice, readable renderings of 
graph data.
http://dkbza.org/pydot.html

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


Re: File object question

2005-12-22 Thread Kent Johnson
S. D. Rose wrote:
> Hello all.
>   If I read a binary file:
> 
> file = open('c:\\logo.gif', 'rw'') # Read from FS as one way to get the
> object, d/l from website another...
> file.read()
> 
> is there anyway I can determine the 'size' of the object file? (Without
> going to the filesystem and reading the filesize from the directory ...)

Once you have read the data you can get the size of that:
d = file.read()
print len(d)

Is that what you mean? Otherwise I don't know how you can get the size of a 
file without 
asking the filesystem...

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


Re: Guido at Google

2005-12-22 Thread x600y

JB wrote:

> long life to Guido & Goole ! many things to come ;)

Google is merely the new Microsoft and surely just as unethical
at its core.

And your spelling Goole is probably closer to the mark,
since it is merely the next ghoulish big company,
come to restrict our freedoms and blot out the sky.

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


Re: serialize object in jython, read into python

2005-12-22 Thread Kent Johnson
py wrote:
> I want to serialize an object in jython and then be able to read it in
> using python, and vice versa.
> 
> Any suggestions on how to do this?  pickle doesnt work, nor does using
> ObjectOutputStream (from jython).
> 
> I prefer to do it file based ...something like
> 
> pickle.dump(someObj, open("output.txt", "w"))
> 
> as opposed to shelve
> 
> f = shelve.open("output.txt")
> f['somedata'] = someObj

It works for me. I think the problem is that your pickle file is not closed 
properly, when 
I tried it with the form you have above the file was never written. Here is an 
example 
that works with Jython 2.1 and Python 2.4.2:

D:\WUTemp>jython
Jython 2.1 on java1.4.2_06 (JIT: null)
Type "copyright", "credits" or "license" for more information.
 >>> a='hello world'
 >>> b=tuple(range(10))
 >>> c={ 'a':1, 'b':2, 'c':3}
 >>> class Foo:
...   pass
...
 >>> d=Foo()
 >>> lst=[a,b,c,d]
 >>> lst
['hello world', (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), {'b': 2, 'a': 1, 'c': 3}, 
<__main__.Foo 
instance at 17930334>]
 >>> f=open('pickle.txt', 'wb')
 >>> import pickle
 >>> pickle.dump(lst, f)
 >>> f.close()
 >>> ^Z

D:\WUTemp>python
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
  >>> import pickle
  >>> class Foo:
  ...   pass
  ...
  >>> f=open('pickle.txt')
  >>> lst = pickle.load(f)
  >>> f.close()
  >>> lst
['hello world', (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), {'a': 1, 'c': 3, 'b': 2}, 
<__main__.Foo 
instance at 0x00A51350>]
  >>>

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


Re: GUI and graph

2005-12-22 Thread Avell Diroll
questions? wrote:
> I have a graph with different parameters along different parts of the
> graph.
> 
> I want to have a program that can display the graph with coloring for
> different part of the graph. Is this possible in Python? What should I
> read?
> 
> Thanks for any comments
> 

I would suggest a combination of pyGTK and Matplotlib.
A quick tutorial may be found here : http://www.serpia.org/pygtk

Thinking about it, you might be satisfied with the gnuplot interface for 
python : http://gnuplot-py.sourceforge.net/

Hope that helped ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guido at Google

2005-12-22 Thread Bugs
Greg Stein wrote:
> 50% "on"
> 100% "with"
> 

Wow, that's great to know, thanks Greg!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please enlighten me about PyPy

2005-12-22 Thread Ray
Carl Friedrich Bolz wrote:
> Hi!
>
> some more pointers in addition to the good stuff that Luis wrote...



Thanks Carl! That solidified my mental picture of PyPy a lot more :)

Warm regards,
Ray

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


Re: Please enlighten me about PyPy

2005-12-22 Thread Ray
Luis M. González wrote:
> Well, first and foremost, when I said that I leave the door open for
> further explanations, I meant explanations by other people more
> knowlegeable than me :-)



Thanks for clearing up some of my confusion with PyPy, Luis!

Cheers,
Ray

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


Re: Guido at Google

2005-12-22 Thread Greg Stein
50% "on"
100% "with"

On 12/22/05, Jay Parlar <[EMAIL PROTECTED]> wrote:
>
> On Dec 22, 2005, at 2:20 PM, Greg Stein wrote:
> > Guido would acknowledge a query, but never announce it. That's not his
> > style.
> >
> > This should have a positive impact on Python. His job description has a
> > *very* significant portion of his time dedicated specifically to
> > working on Python. (much more than his previous "one day a week" jobs
> > have given him)
> >
> > Cheers,
> > -g
> >
> Do you actually mean "working on Python", or did you mean "working WITH
> Python"?
>
> Jay P
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: serialize object in jython, read into python

2005-12-22 Thread Erik Max Francis
Noah wrote:

> You can give up on pickle, because pickle is only
> guaranteed to work with the exact same version of the Python
> interpreter.

Not true.  You're thinking of marshal.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Who knows whether any of us will be around in 1972?
   -- John F. Kennedy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File object question

2005-12-22 Thread Tim Williams (gmail)
On 22/12/05, S. D. Rose <[EMAIL PROTECTED]> wrote:
Hello all.  If I read a binary file:file = open('c:\\logo.gif', 'rw'') # Read from FS as one way to get theobject, d/l from website another...file.read()is there anyway I can determine the 'size' of the object file? (Without
going to the filesystem and reading the filesize from the directory ...
On my w2k box I use this for binary files

file = open('c:\\logo.gif', 'r+b'') # Read from FS as one way to get the
object, d/l from website another...
file_read = file.read() 
len(file_read)
Note:  you must specify the binary option for binary files or you may not get the whole file.HTH :)
-- Tim Williams
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to check if a string "is" an int?

2005-12-22 Thread Peter Otten
Steven D'Aprano wrote:

> But since you're going to take my protests about regexes more seriously
> than I intended you to, it is ironic that you supplied a regex that
> is nice and fast but doesn't work:

I think you said that "exceptions are cheap" elsewhere in this thread and
I read your post above as "regular expressions are slow". I meant to set
these statements into proportion.

Those who snip the Zawinski quote are doomed to demonstrate it in their
code, though it wouldn't have taken this lapse for me to grant you that
regexes are errorprone.

> BTW, you might find it informative to run timeit on the code snippet
> provided by Daniel before reflecting on the context of my "how slow"
> comment.

I'm getting about 10 usec for both cases, i. e. roughly the same as the
worstcase behaviour for try...except.

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


Re: A simple list question.

2005-12-22 Thread Kent Johnson
KraftDiner wrote:
> I am trying to implement a two dimensional array.
> mylist = [[a,b,c],[d,e,f,c],[g,h,i]]
> 
> So the array is of length 3 here...
> So how do I initialize this array and then set each object?
> At some point in my code I know there will be 3 lists in the list.
> So how do I initialize this list such that I can access them
> as elements... like
> mylist[1] = [c,f,g]
> in random order...

If you can separate the code into a list builder and a list client, maybe the 
builder can 
just use append and the client can use indexing.

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


Re: Guido at Google

2005-12-22 Thread Tim Peters
[Greg Stein]
>>> Guido would acknowledge a query, but never announce it. That's not his
>>> style.

He's been very low-key about it, but did make an informal announcement
on the PSF-Members mailing list.

>>> This should have a positive impact on Python. His job description has a
>>> *very* significant portion of his time dedicated specifically to working on
>>> Python. (much more than his previous "one day a week" jobs have given
>>> him)

It's got to be better than getting one patch per year from him, trying
to fix threading on the ever-popular Open Source combination of HP-UX
on an Itanium chip .

[Jay Parlar]
>> Do you actually mean "working on Python", or did you mean "working WITH
>> Python"?

[Robert Kern]
> I'm pretty sure he means "working on Python."

While I'm not a professional Greg-channeller, in this case I can:  he
meant what he said.

> No one hires Guido and expects him not to work *with* Python most of the time.

Ask Guido how fond he is of Java these days ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I get a dictionary of argument names with their default values?

2005-12-22 Thread Noah

Thanks! Much more handy than what I was trying to do
and it looks like I might even learn something new :-)

Yours,
Noah

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


Re: Python IMAP4 Memory Error

2005-12-22 Thread Fredrik Lundh
Dody Suria Wijaya wrote:

> Hi, I encountered a Memory Error Exception on using IMAP4 just like in
> Python documentation example, on a specially large email (10 MB). Any
> idea how to fix/circumvent this?
>
>  >>> typ, data = M.fetch(89, '(RFC822)')
> Traceback (most recent call last):
>File "", line 1, in ?
>File "C:\Python24\lib\imaplib.py", line 426, in fetch
>  typ, dat = self._simple_command(name, message_set, message_parts)
>File "C:\Python24\lib\imaplib.py", line 1028, in _simple_command
>  return self._command_complete(name, self._command(name, *args))
>File "C:\Python24\lib\imaplib.py", line 858, in _command_complete
>  typ, data = self._get_tagged_response(tag)
>File "C:\Python24\lib\imaplib.py", line 959, in _get_tagged_response
>  self._get_response()
>File "C:\Python24\lib\imaplib.py", line 921, in _get_response
>  data = self.read(size)
>File "C:\Python24\lib\imaplib.py", line 1123, in read
>  data = self.sslobj.read(size-read)
> MemoryError

try adding a print statement to lib/imaplib.py, just before that read
statement,

print size, read, size-read
data = self.sslobj.read(size-read)

and let us know what it prints.





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


Re: Socket programming design problem

2005-12-22 Thread John J. Lee
David <[EMAIL PROTECTED]> writes:
[...]
> a) Big problem, I can't see how to receive from more than one socket at
> once.  I need to do this so that data from the TCP connection can be sent
> out on the UDP one and vice versa.  Do I need a thread for each, or is
> there some other way I can listen on two sockets at once (maybe
> non-blocking ones?)

1. threads, yes
2. http://docs.python.org/lib/module-select.html (if on non-Windows system)
3. http://docs.python.org/lib/module-asyncore.html (ditto)
4. http://twistedmatrix.com/


Interesting but maybe not production-ready code:

1. http://kamaelia.sourceforge.net/Home
2. http://poshmodule.sourceforge.net/


> b) If the script dies prematurely, e.g. I mistyped something and Python
> throws an exception, it is caught by the generic handler at the bottom. 
> However, the socket does not seem to be cleaned up properly, as if I try to
> run it again immediately I get an error that it is still in use.  lsof
> doesn't show it in use though, which seems weird.  Is there any particular
> reason for this?

Google for SO_REUSEADDR



John

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


Re: Guido at Google

2005-12-22 Thread casioculture

Ilias Lazaridis wrote:
> Greg Stein wrote:
> > Yeah... we recognize that we could certainly open-source more of our
> > software. While we've released some stuff
> > (code.google.com/projects.html), there is a LOT more that we want to
>
> http://code.google.com/projects.html
>
> > do. Getting engineers' 20% time to do that has been difficult.
> > Thankfully, we know how to fix that and got the okay/headcount to make
> > it happen. (IOW, it isn't a lack of desire, but making it happen)
>
> When a company like Google open's sources, this means simply nothing
> more than:
>
>   - the software is not critical to their business (e.g. core-software)
>   - the internal resources cannot ensure further development
>
> See IBM, SUN and others, which have done the same thing.
>
> > But even if we haven't been able to open-source as much code as we'd
> > like, we *have* been trying to be very supportive of the community.
> > Between the Summer of Code and direct cash contributions, we've
> > provided a LOT of support to a large number of open source
> > organizations.
>
> I hope that you invest some time to _organize_ the Open Source Projects.
>
> Starting with Python and it's project-structure (e.g. build-process) and
> documentation (e.g. ensuring standard-terminology is kept, like "class")
>
> e.g.: where can I find an UML diagramm of the Python Object Model?
>
> Even Ruby has one:
>
> http://lazaridis.com/case/lang/ruby/TheRubyObjectModel.png
>
> -
>
> > And we have a couple other ideas on how to help the open source
> > community. We're working on it!
>
> The open-source-community can help Google, too!
>
> E.g.:  Google needs an public Issue-Tracking-System.
>
> I needed around 30 emails and 2 months until google-groups-support
> removed a bug which broke(!) existent links to google archives. (cannot
> find the topic. Simply search your support-archives to see the desaster).
>
> With publicity, the team would have removed the bug within one week.
>
> > Cheers,
> > -g
>
> And finally:
>
> If Mr. van Rossum is now at Google, and Python is essentially a Mr. van
> Rossum based product, then most possibly the evolution-speed of Python
> will decrease even more (Google will implement things needed by Google -
> van Rossum will follow, so simple).
>
> I mean, when will this language finally become a _really_ fully
> Object-Oriented one, with a clean reflective Meta-Model?
>
> Thus I can see Python pass this this _simple_ evaluation (which it does
> not pass in its current implementation):
>
> http://lazaridis.com/case/lang/python.html
>
> -
>
> I have around one year to await.
>
> Will see.
>
> .
>
> --
> http://lazaridis.com

Hi there, I wonder what comments you would have about XOTCL, or other
OO extensions for tcl, like snit, and dozens more. I looked at the
various scripting languages available to me and decided to go with tcl
as it seemed the most versatile. I can't find it on your page though.
Regards.

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


Re: How do I get a dictionary of argument names with their default values?

2005-12-22 Thread Fredrik Lundh
"Noah" <[EMAIL PROTECTED]> wrote:

> Is there a simple way to get a dictionary of
> argument names and their default values for
> a method or function? I came up with one solution, but
> I feel like Python must have a simpler way.

>>> import inspect
>>> help(inspect.getargspec)
Help on function getargspec in module inspect:

getargspec(func)
Get the names and default values of a function's arguments.

A tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names (it may contain nested lists).
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments.

>>> def foo(f1, f2, f3, f4="F4", f5="F5"):
... pass
...
>>> inspect.getargspec(foo)
(['f1', 'f2', 'f3', 'f4', 'f5'], None, None, ('F4', 'F5'))
>>> args, varargs, varkw, defaults = inspect.getargspec(foo)
>>> dict(zip(args[-len(defaults):], defaults))
{'f4': 'F4', 'f5': 'F5'}

>>> class fu:
... def foo (self, m1, m2, m3, m4='M4', m5='M5'):
... pass
...
>>> f = fu()
>>> inspect.getargspec(f.foo)
(['self', 'm1', 'm2', 'm3', 'm4', 'm5'], None, None, ('M4', 'M5'))
>>> args, varargs, varkw, defaults = inspect.getargspec(f.foo)
>>> dict(zip(args[-len(defaults):], defaults))
{'m5': 'M5', 'm4': 'M4'}





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


Re: Faster copying of composite new-class objects

2005-12-22 Thread John J. Lee
"Alex" <[EMAIL PROTECTED]> writes:

> My program requires copying thousands of composite new-class objects. I
> found that the following: objCopy=cPickle.loads(cPickle.dumps(obj,
> protocol=2)) works about 4 times faster than
> copyObj=copy.deepcopy(obj). Is there any way to do it even faster?
> 
> All objects have slots, __getstate__ and __setstate__.

At a wild guess: writing custom serialisation functions using module
marshal?


John

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


Re: Guido at Google

2005-12-22 Thread Robert Kern
Jay Parlar wrote:
> On Dec 22, 2005, at 2:20 PM, Greg Stein wrote:
> 
>>Guido would acknowledge a query, but never announce it. That's not his
>>style.
>>
>>This should have a positive impact on Python. His job description has a
>>*very* significant portion of his time dedicated specifically to
>>working on Python. (much more than his previous "one day a week" jobs
>>have given him)
>>
>>Cheers,
>>-g
> 
> Do you actually mean "working on Python", or did you mean "working WITH 
> Python"?

I'm pretty sure he means "working on Python." No one hires Guido and expects him
not to work *with* Python most of the time.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: A simple list question.

2005-12-22 Thread KraftDiner
I am trying to implement a two dimensional array.
mylist = [[a,b,c],[d,e,f,c],[g,h,i]]

So the array is of length 3 here...
So how do I initialize this array and then set each object?
At some point in my code I know there will be 3 lists in the list.
So how do I initialize this list such that I can access them
as elements... like
mylist[1] = [c,f,g]
in random order...

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


Re: Guido at Google

2005-12-22 Thread Jay Parlar

On Dec 22, 2005, at 2:20 PM, Greg Stein wrote:
> Guido would acknowledge a query, but never announce it. That's not his
> style.
>
> This should have a positive impact on Python. His job description has a
> *very* significant portion of his time dedicated specifically to
> working on Python. (much more than his previous "one day a week" jobs
> have given him)
>
> Cheers,
> -g
>
Do you actually mean "working on Python", or did you mean "working WITH 
Python"?

Jay P

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


Re: Interesting little "gotcha" with generators

2005-12-22 Thread Aahz
In article <[EMAIL PROTECTED]>,
Paul Rubin   wrote:
>[EMAIL PROTECTED] (Aahz) writes:
>>
>> What's wrong with
>> 
>> def foo():
>> if False: yield None
>
>Does the following work?
>
>def foo():
>raise StopIteration

Nope.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


How do I get a dictionary of argument names with their default values?

2005-12-22 Thread Noah
Is there a simple way to get a dictionary of
argument names and their default values for
a method or function? I came up with one solution, but
I feel like Python must have a simpler way.

Python provide a way to get a sequence of
argument names and a different way to get a
sequence of default argument values. Since
default values have to come at the end of an
argument list you can match up the values in the
default values sequence to the values in the
argument list sequence.

The following seems to work on both functions and methods::

def func_arg_defaults_dict (func):
default_dict = {}
if func.func_defaults is not None:
da_start = len(func.func_code.co_names) -
len(func.func_defaults)
for i in range(len(func.func_defaults)):
arg_name = func.func_code.co_names[da_start+i]
arg_value = func.func_defaults[i]
default_dict [arg_name] = arg_value
return default_dict

def foo (f1, f2, f3, f4='F4', a5='F5'):
print f1, f2, f3, f4, f5

class fu:
def foo (self, m1, m2, m3, m4='M4', m5='M5'):
print m1, m2, m3, m4, m5

f = fu()

# test function
print func_arg_defaults_dict (foo)
# test method
print func_arg_defaults_dict (f.foo)

Running the script prints this::

{'f4': 'F4', 'f5': 'F5'}
{'m5': 'M5', 'm4': 'M4'}

Is func_arg_defaults_dict() reasonable? It seems a bit convoluted.
I hope there is a more obvious way.

Yours,
Noah

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


Re: GUI and graph

2005-12-22 Thread mneyer
Look up the information on graphical displays in Tk for python.
http://www.pythonware.com/library/tkinter/introduction/

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


Re: Interesting little "gotcha" with generators

2005-12-22 Thread Paul Rubin
[EMAIL PROTECTED] (Aahz) writes:
> What's wrong with
> 
> def foo():
> if False: yield None

Does the following work?

def foo():
raise StopIteration
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Varieties of Pythonic Experience (was: Guido at Google)

2005-12-22 Thread Robert Hicks
You mean Jython is still going?  ; )

Robert

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


Re: Interesting little "gotcha" with generators

2005-12-22 Thread Will McGugan
Kenneth McDonald wrote:
> I recently had need to write the following code:
> 
> def compileOuter(self):
> if False: yield None
> else: return
> 
> "compileOuter" is a generator function which is implemented in  various 
> classes. In this particular class, it always yields nothing.  However, 
> none of the following work:
> 
> def compileOuter(self):
> return
> 
> def compileOuter(self):
> pass
> 
> def compileOuter(self):
> yield
> 
> The first two don't work because in order to define a generator, you  
> must have a yield statement inside it. The last doesn't work because  
> every "yield" must have an argument.
> 
> I've been using "return" in generators ever since I started using  
> generators, but on reflection, it seems to me that such a thing is in  
> some ways inconsistent; "return" is (conceptually, at least  originally) 
> a function statement, where "return" by itself really  stands in for 
> "return None". But in generators, it is being used as a  control flow 
> command. For example, you can't have "return" with an  argument inside a 
> generator.
> 
> Too bad "return" wasn't entirely forbidden within generators, and  
> "yield" without an argument mandated instead. Oh well, too let now I  
> suppose...

Would this work?

def compilerOuter(self):
raise StopIteration

Will McGugan
-- 
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
"jvyy*jvyyzpthtna^pbz")
-- 
http://mail.python.org/mailman/listinfo/python-list


Socket programming design problem

2005-12-22 Thread David
After programming with Python for a few hours, I've come up with some code:
http://p.shurl.net/3n.  However, now I've realised there's a bit of a
problem with the original design.

I have a number of questions, if anybody could answer I'd be grateful.

a) Big problem, I can't see how to receive from more than one socket at
once.  I need to do this so that data from the TCP connection can be sent
out on the UDP one and vice versa.  Do I need a thread for each, or is
there some other way I can listen on two sockets at once (maybe
non-blocking ones?)

b) If the script dies prematurely, e.g. I mistyped something and Python
throws an exception, it is caught by the generic handler at the bottom. 
However, the socket does not seem to be cleaned up properly, as if I try to
run it again immediately I get an error that it is still in use.  lsof
doesn't show it in use though, which seems weird.  Is there any particular
reason for this?

Thanks,

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


Re: Guido at Google

2005-12-22 Thread Greg Stein
Guido would acknowledge a query, but never announce it. That's not his
style.

This should have a positive impact on Python. His job description has a
*very* significant portion of his time dedicated specifically to
working on Python. (much more than his previous "one day a week" jobs
have given him)

Cheers,
-g

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


Re: Interesting little "gotcha" with generators

2005-12-22 Thread Aahz
In article <[EMAIL PROTECTED]>,
Kenneth McDonald  <[EMAIL PROTECTED]> wrote:
>
>I recently had need to write the following code:
>
> def compileOuter(self):
> if False: yield None
> else: return

What's wrong with

def foo():
if False: yield None
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting little "gotcha" with generators

2005-12-22 Thread Duncan Booth
Kenneth McDonald wrote:

> I recently had need to write the following code:
> 
>  def compileOuter(self):
>  if False: yield None
>  else: return
> 
> "compileOuter" is a generator function which is implemented in  
> various classes. In this particular class, it always yields nothing.  
> However, none of the following work:
> 
>  def compileOuter(self):
>  return
> 
>  def compileOuter(self):
>  pass
> 
>  def compileOuter(self):
>  yield
> 

This would work:

  def compileOuter(self):
return iter(())

and depending on how it is used, you might also get away with:

  def compileOuter(self):
return []

A generator is simply a function which when called returns an iterator, so 
you can use any other function which returns an iterator in its place.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check if a string "is" an int?

2005-12-22 Thread Steven D'Aprano
On Thu, 22 Dec 2005 09:33:20 +0100, Peter Otten wrote:

> Steven D'Aprano wrote:
> 
>> On Wed, 21 Dec 2005 16:39:19 +0100, Daniel Schüle wrote:
>> 
>>> [EMAIL PROTECTED] wrote:
 How do I check if a string contains (can be converted to) an int? I
 want to do one thing if I am parsing and integer, and another if not.
 
 /David
 
>>> 
>>> others already answered, this is just an idea
>>> 
>>>  >>> def isNumber(n):
>>> ... import re
>>> ... if re.match("^[-+]?[0-9]+$", n):
>>> ... return True
>>> ... return False
>> 
>> This is just a thought experiment, right, to see how slow you can make
>> your Python program run?
> 
> Let's leave the thought experiments to the theoretical physicists 

Didn't I have a smiley in there?


> and compare a regex with an exception-based approach:
> 
> ~ $ python -m timeit -s'import re; isNumber =
> re.compile(r"^[-+]\d+$").match' 'isNumber("-123456")'
> 100 loops, best of 3: 1.24 usec per loop

But since you're going to take my protests about regexes more seriously
than I intended you to, it is ironic that you supplied a regex that
is nice and fast but doesn't work:

>>> re.compile(r"^[-+]\d+$").match("123456") is None
True

Isn't that the point of Jamie Zawinski's quote about regexes? I too can
write a regex that doesn't solve the problem -- and this regex is a dead
simple case, yet still easy to get wrong.

BTW, you might find it informative to run timeit on the code snippet
provided by Daniel before reflecting on the context of my "how slow"
comment.



-- 
Steven.

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

sorting with expensive compares?

2005-12-22 Thread Dan Stromberg

Hi folks.

Python appears to have a good sort method, but when sorting array elements
that are very large, and hence have very expensive compares, is there some
sort of already-available sort function that will merge like elements into
a chain, so that they won't have to be recompared as many times?

Thanks!

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


Re: Guido at Google

2005-12-22 Thread Bugs
So when *is* someone (either Guido himself or Google) going to 
officially announce that Guido has moved to Google?  If at all?

Also, it would be nice to know from Guido's perspective what, if any at 
all, impact this will have on Python?

Maybe here?  http://www.artima.com/weblogs/index.jsp?blogger=guido  Is 
this Guido's official blog?
-- 
http://mail.python.org/mailman/listinfo/python-list


GUI and graph

2005-12-22 Thread questions?
I have a graph with different parameters along different parts of the
graph.

I want to have a program that can display the graph with coloring for
different part of the graph. Is this possible in Python? What should I
read?

Thanks for any comments

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


Interesting little "gotcha" with generators

2005-12-22 Thread Kenneth McDonald
I recently had need to write the following code:

 def compileOuter(self):
 if False: yield None
 else: return

"compileOuter" is a generator function which is implemented in  
various classes. In this particular class, it always yields nothing.  
However, none of the following work:

 def compileOuter(self):
 return

 def compileOuter(self):
 pass

 def compileOuter(self):
 yield

The first two don't work because in order to define a generator, you  
must have a yield statement inside it. The last doesn't work because  
every "yield" must have an argument.

I've been using "return" in generators ever since I started using  
generators, but on reflection, it seems to me that such a thing is in  
some ways inconsistent; "return" is (conceptually, at least  
originally) a function statement, where "return" by itself really  
stands in for "return None". But in generators, it is being used as a  
control flow command. For example, you can't have "return" with an  
argument inside a generator.

Too bad "return" wasn't entirely forbidden within generators, and  
"yield" without an argument mandated instead. Oh well, too let now I  
suppose...


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


Re: serialize object in jython, read into python

2005-12-22 Thread Fredrik Lundh
"Noah" <[EMAIL PROTECTED]> wrote:

> > Thanks for the help in advance.
>
> You can give up on pickle, because pickle is only guaranteed
> to work with the exact same version of the Python interpreter.

nope.

maybe you're thinking of marshalled bytecode, but I don't think
that's what the OP was talking about.





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


Re: Providing 'default' value with raw_input()?

2005-12-22 Thread Kent Johnson
planetthoughtful wrote:
> I think that would be a great solution if the value being 'edited' was
> relatively short, or numeric, etc. But the values I want to 'edit' can
> be several hundred characters long (ie they're text fields containing
> todo notes), and using your method, I'd either accept the existing
> value, or have to retype the text for that record. I think I mislead
> people when I used the word 'default' -- I meant in the sense of being
> able to edit the existing value, so that value, out of each record,
> would be presented as the 'default', available for editing.

For fields that long I think a GUI is more appropriate than trying to use 
command-line 
editing. You might take a look at easygui - it's textbox is readonly but it 
looks like it 
wouldn't be hard to make it editable - or learn enough Tkinter to do it 
yourself.
http://www.ferg.org/easygui/

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


Re: serialize object in jython, read into python

2005-12-22 Thread Paul Rubin
"py" <[EMAIL PROTECTED]> writes:
> Noah wrote:
> > You can give up on pickle, because pickle is only
> > guaranteed to work with the exact same version of the Python
> > interpreter.
> 
> :(

No that's confusing pickle with marshal.  Pickle is supposed to work
across versions, though it has recently grown a few slightly
incompatible optional modes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: serialize object in jython, read into python

2005-12-22 Thread py
Noah wrote:
> You can give up on pickle, because pickle is only
> guaranteed to work with the exact same version of the Python
> interpreter.

:(


> How complex of a serialization do you need?

simple

I just wrote the info out to a file.  then i have a thread which reads
in the files and parses them and creates the necessary object.

thanks anyway

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


Re: Guido at Google

2005-12-22 Thread blumberg
lazy bastard

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


Re: File object question

2005-12-22 Thread mrmakent
See http://www.python.org/doc/2.4.2/lib/os-file-dir.html for the 'stat'
function

import os
os.stat(path).st_size

This will return the size in bytes of the file designated by 'path'.

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


Re: Pydev questions: versions and keybindings

2005-12-22 Thread S. D. Rose
Would

(Eclipse) Help | About -> [Plug-in Details] | Plug-in Name -> PyDev - Python
Development Environment

do the trick for you?

-Dave

"Kenneth McDonald" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm trying to find out if I have the most recent version of Pydev for
> Eclipse installed, but can't find the version number in the Pydev
> user interface. Is it available anywhere in there?
>
> And, the reason that I'm trying to find the most recent update is
> because I can't redefine one keystroke that appears to be hardwired
> into Pydev (?) I'd like to bind ^/ to forward-word, but it keeps on
> applying commenting to the current line. I actually went and deleted
> the Pydev binding for comment line (which was actually ^-Shift-/, if
> I remember correctly), but to no avail. A visual check of keybindings
> in all modes reveals that nothing else is bound to ^/, so I'm trying
> to figure out what's going on.
>
> Many thanks,
> Ken
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



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


File object question

2005-12-22 Thread S. D. Rose
Hello all.
  If I read a binary file:

file = open('c:\\logo.gif', 'rw'') # Read from FS as one way to get the
object, d/l from website another...
file.read()

is there anyway I can determine the 'size' of the object file? (Without
going to the filesystem and reading the filesize from the directory ...)

Thanks!



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


Re: A simple list question.

2005-12-22 Thread Tim Williams (gmail)
On 22/12/05, Tim Williams (gmail) <[EMAIL PROTECTED]> wrote:
On 22 Dec 2005 10:14:10 -0800, KraftDiner <
[EMAIL PROTECTED]> wrote:
Is there a cleaner way to implement this code?if
len(self.listOfObjects) == 0:self.listOfObjects.append(self.currentObject)elif:self.listOfObjects[self.currentSlice]
= self.currentObjectlistOfObjects is a list of listsIf the listOfObjects is [] then I have to use append to add the firstlistotherwise I can access each list using the index into the list.


I'm assuming from your code that self.listOfObjects always exists (even
if it is empty) and that self.currentObject is also  list. 

   if  (not self.listOfObjects) or (self.listOfObjects[self.currentSlice] = self.currentObject):
   
self.listOfObjects =  self.currentObject 

 If self.currentObject is not a list or is only sometimes a list then change the 2nd line to 

  
self.listOfObjects =  list( self.currentObject )

HTH :)-- Tim Williams

OOPS !!   completely misread your code, should that elif be an else?

Try this:

   
if not self.listOfObjects:self.listOfObjects.append(self.currentObject)
  
#or:  self.listOfObjects = list(self.currentObject)
elif 
self.listOfObjects[self.currentSlice]
= self.currentObject :
   
do something
   
else:



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

Re: Python's ontology and governance

2005-12-22 Thread Martin v. Löwis
Cameron Laird wrote:
> Apart from a few very mild constraints that prohibit you from little 
> more than saying that you're Guido and you invented Python, you have 
> remarkable liberty to adapt Python to your own needs.  Moreover, this
> freedom is not merely a theoretical principle; *numerous* working
> engineers have changed Python to meet their own requirements, and
> quite a few of these "modified Pythons" are in production around the
> world.  I've heard Guido speak words of encouragement to others to do
> the same.

And indeed, in the area of "Extending and embedding", this is one
of the strengths of Python. Nobody will object if you add additional
library functions, data types, etc, and still call it Python.

Traditionally, reimplementations of the entire language have called
themselves differently (Jython, IronPython, PyPy,...), just to
distinguish themselves from (what they call) CPython. In all these
cases, the reimplementations strive for compatibility with the
Python language and library references, so nobody object that they
call themselves "Python implementations".

Also, nobody would object if you take some ideas from Python, some ideas
from other languages, and some of your own ideas, and call the result,
say, "Monad". If the language (syntax, semantics) is significantly
different, you shouldn't call it Python.

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


Re: serialize object in jython, read into python

2005-12-22 Thread Noah
py wrote:
> I want to serialize an object in jython and then be able to read it in
> using python, and vice versa.
>
> Any suggestions on how to do this?  pickle doesnt work, nor does using
> ObjectOutputStream (from jython).
>
> I prefer to do it file based ...something like
>
> pickle.dump(someObj, open("output.txt", "w"))
>
> as opposed to shelve
>
> f = shelve.open("output.txt")
> f['somedata'] = someObj
>
> Thanks for the help in advance.

You can give up on pickle, because pickle is only
guaranteed to work with the exact same version of the Python
interpreter.
(It will work on the same version of the Python interpreter on
different platforms, but
that's probably not useful to you here).

How complex of a serialization do you need?
Would simply saving a dictionary of strings work for you?
That's what I do for HTTP session management.
I then map my session dictionary to the dictionary of object
attributes.

You might also consider JSON which is very simple and lightweight.
http://www.json.org/

Yours,
Noah

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


Re: problem adding list values

2005-12-22 Thread mrmakent
Glad to help.  Your relevant code:

> i = 0
> for i in credlist:
> credits += credlist[i]
> i = i + 1

credlist is your list of credits, which are floating point numbers.
You use a for-loop to iterate thru this list of floating point numbers,
so each time thru the loop, the variable 'i' is set to the next
floating point number from the list.  'i' is NOT being set to a
sequence of integers starting with '0'.  You then try to index into
credlist using the floating-point number set in 'i' as the index, which
you can't do.  I presume you are used to the for-loop behavior from
some other language.

To rewrite this code to correctly use a for-loop, try something like:

totalCredits = 0.0

for credit in credlist:
totalCredits += credit

Alternatively, you can use the build-in function 'sum' to sum a
sequence of numbers:

totalCredits = sum(credlist)

Python isn't a hard language to pick up, but there are some significant
differences from other languages like C or Basic.  You're off to a good
start.

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


Re: A simple list question.

2005-12-22 Thread Tim Williams (gmail)
On 22 Dec 2005 10:14:10 -0800, KraftDiner <[EMAIL PROTECTED]> wrote:
Is there a cleaner way to implement this code?if
len(self.listOfObjects) == 0:self.listOfObjects.append(self.currentObject)elif:self.listOfObjects[self.currentSlice]
= self.currentObjectlistOfObjects is a list of listsIf the listOfObjects is [] then I have to use append to add the firstlistotherwise I can access each list using the index into the list.

I'm assuming from your code that self.listOfObjects always exists (even
if it is empty) and that self.currentObject is also  list. 

   if  (not self.listOfObjects) or (self.listOfObjects[self.currentSlice] = self.currentObject):
   
self.listOfObjects =  self.currentObject 

 If self.currentObject is not a list or is only sometimes a list then change the 2nd line to 

  
self.listOfObjects =  list( self.currentObject )

HTH :)-- Tim Williams
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: A simple list question.

2005-12-22 Thread Larry Bates
KraftDiner wrote:
> Is there a cleaner way to implement this code?
> 
>   if len(self.listOfObjects) == 0:
>   self.listOfObjects.append(self.currentObject)
>   elif:
>   self.listOfObjects[self.currentSlice] = 
> self.currentObject
> 
> listOfObjects is a list of lists
> If the listOfObjects is [] then I have to use append to add the first
> list
> otherwise I can access each list using the index into the list.
> 
It appears you are trying to do two different things in one if
statement and it is unclear where self.currentSlice comes from.
You also need a condition on your elif.  Perhaps more explanation
is needed (at least for me to help).

-Larry Bates


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


Re: Providing 'default' value with raw_input()?

2005-12-22 Thread keirr
planetthoughtful wrote:
> Hi Kier,
>
> Any idea where I'd find documentation on using this extension? I've
> downloaded and installed, but haven't had any luck finding docs for it.
>
As it's a windows version of the standard readline module (usually
available on Unix only)
I'd _guess_ that you could use the standard library readline
documenation, i.e. go to python.org and look up the readline module in
the library docs.

Cheers,

 Keir.

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


Re: problem adding list values

2005-12-22 Thread andy
David M. Synck wrote:

>Hi all, 
>
>I am fairly new to Python and trying to figure out a syntax error
>concerning lists and iteration through the same. What I am trying to do is
>sum a list of float values and store the sum in a variable for use later.
>
>The relevant code looks like this -
>
>def getCredits():
>
>""" This function asks the user to input any credits not shown on their 
> bank statement
>
>It returns the sum(converted to float) of the entered credits """
>
>global credits
>credlist = []
>credits = 0.0
>temp = 0.0
>print "Now you need to enter any credits not shown on your bank statement 
> \n"
>print "Please enter a zero (0) once all credits have been entered \n"
>raw_input("Hit 'Enter' to continue \n")
>temp = float(raw_input("Please enter the first credit \n"))
>
>while temp != 0:
>credlist.append(temp)
>temp = float(raw_input("Please enter the next credit \n"))
>   
>i = 0
>for i in credlist:
>credits += credlist[i]
>i = i + 1
>
>return credits
>
>And the syntax error I get is this - 
>
>Traceback (most recent call last):
>  File "./BankReconciler_Rev1.py", line 129, in ?
>main()
>  File "./BankReconciler_Rev1.py", line 116, in main
>getCredits()
>  File "./BankReconciler_Rev1.py", line 60, in getCredits
>credits += credlist[i]
>TypeError: list indices must be integers
>
>
>If anyone can point me in the right direction, I would greatly appreciate
>it.
>
>Thanks in advance
>  
>
Your problem is here:

i = 0 
for i in credlist:  
credits += credlist[i]
i = i + 1

In the for loop, i is successively bound to each element in credlist
(which are floats) and you then try to index credlist with each element
in turn: you can't index lists with floats, so you get an error.

Try inserting a print command just before the credits expression, and
you'll see what I mean:

i = 0 
for i in credlist:  
print i
credits += credlist[i]
i = i + 1


What you probably mean is:

credits = 0.0
for i in credlist:
credits += i

However, you should really use:

credits = sum(credlist)

It's far faster and more "pythonic".

NOTE: Although it may be easy to think of Python lists as arrays,
they're more than that. The Python for loop moves through a list,
binding (think assigning) the loop variable (in this case "i") to each
*element* of the list at a time on successive iterations, viz:

>>> for i in ["apples","oranges","grapes","pears","tomatoes"]:
... print i
apples
oranges
grapes
pears
tomatoes
>>>

Hope that helps ;-)

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


Re: Providing 'default' value with raw_input()?

2005-12-22 Thread planetthoughtful
Hi Kier,

Any idea where I'd find documentation on using this extension? I've
downloaded and installed, but haven't had any luck finding docs for it.

Much warmth,

planetthoughtful

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


Re: Providing 'default' value with raw_input()?

2005-12-22 Thread planetthoughtful

Bengt Richter wrote:
> On 22 Dec 2005 08:55:17 -0800, "planetthoughtful" <[EMAIL PROTECTED]> wrote:
>

> >I would like to include the ability to edit an existing value (drawn
> >from an SQLite table) using a DOS console Python app, but my gut
> >feeling from reading what I can find about raw_input() is that it only
> >allows you to provide a prompt, not a default value as well.
> >
> What's wrong with showing the default in the prompt itself? The thing is
> what user input in response should signify the default? E.g., maybe a single
> period by itself could mean "use the default" and nothing could mean "no 
> change"
> and other input would be a new value.

Hi Bengt,

I think that would be a great solution if the value being 'edited' was
relatively short, or numeric, etc. But the values I want to 'edit' can
be several hundred characters long (ie they're text fields containing
todo notes), and using your method, I'd either accept the existing
value, or have to retype the text for that record. I think I mislead
people when I used the word 'default' -- I meant in the sense of being
able to edit the existing value, so that value, out of each record,
would be presented as the 'default', available for editing.

Sorry for the confusion.

Much warmth,

planetthoughtful

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


Re: Please enlighten me about PyPy

2005-12-22 Thread Carl Friedrich Bolz
Hi!

Scott David Daniels wrote:
> Luis M. González wrote:
> 
> 
>>At this moment, the traslated python-in-python version is, or intends
>>to be, something more or less equivalent to Cpython in terms of
>>performance.
> 
> Actually, I think here it is more or less equivalent in behavior.

Yes, apart from some minor differences (obscure one: in CPython you 
cannot subclass str or tuple while adding slots, for no good reason, 
while you can do that in PyPy).

[snip]
> 
> While the psyco-like tricks for specialization should definitely improve
> the interpreter, there is a second trick (watch for exploding heads
> here).  The big trick is that you can specialize the interpreter for 
> running _its_ input (a Python program), thus giving you a new
> interpreter that only runs your Python program -- a very specialized
> interpreter indeed.

Indeed! And this specialized interpreter can with some right be called a 
compiled version of the user-program! That means that an interpreter 
together with a specializer is a compiler.

Now it is possible to take that fun game even one step further: You 
specialize the _specializer_ for running its input (which is the 
interpreter), thus giving you a new specializer which can specialize 
only the interpreter for a later given user program -- a very 
specialized specializer indeed. This can then be called a just-in-time 
compiler. (Note that this is not quite how JIT of PyPy will look like :-)

recursively-yours,

Carl Friedrich Bolz

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


Re: problem adding list values

2005-12-22 Thread Dave Hansen
On Thu, 22 Dec 2005 19:43:15 GMT in comp.lang.python, "David M. Synck"
<[EMAIL PROTECTED]> wrote:

[...]
>temp = float(raw_input("Please enter the first credit \n"))
>
>while temp != 0:
>credlist.append(temp)
>temp = float(raw_input("Please enter the next credit \n"))

Here you're building credlist as a list of floats.

>   
>i = 0

This is wasted effort

>for i in credlist:

You've asked to loop through credlist, so each value of i is going to
be float.  Maybe you should rename i to something that looks less like
an index and more like a credit.

>credits += credlist[i]

Here, you're trying to indexa list with a float.  No can do...
[...]
>TypeError: list indices must be integers

...ss it's telling you here
>
>
>If anyone can point me in the right direction, I would greatly appreciate
>it.

I think what you want is 

   for cr in credlist:
  credits += cr

Which could also be implemented as

   credits = reduce(lambda x,y: x+y, credlist)

HTH,
-=Dave

-- 
Change is inevitable, progress is not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyUnit and dynamic test functions

2005-12-22 Thread Sakcee
Excellent , your example is elegant and runs beautifully

so the idea is to create a testcase which runs a general function
"testRun" (which calls the function defined in file )and loads data
based on type ,

add this testcase to suite and run suite.

thanks , this is exactly what I was looking for.

Fabrizio Milo wrote:
> > thanks for any input or any alternate approach to it
>
> I think that your approach is not fair.
>
> You should create a TestCase for each of your data input, add it to a 
> TestSuite
> and run the test suite.
>
> Here is a stub for loading just a 'dict' type, hoping it is helpful
>
>
> import unittest
> import glob
> from string import split,strip
>
> def getUSStates(*args):
>#Fake
>return {'AK:': 'Alaska', 'CA:': 'California', 'AR:': 'Arkansas',
> 'CO:': 'Colorado', 'WY:': 'Wyoming', 'AZ:': 'Arizona', 'AL:':
> 'Alabama'}
>
> class TestStubException( Exception ):
>'''
>Test case creation failed.
>'''
>
> class TestStub( unittest.TestCase ):
>
>def __init__( self, fname, farg, t_out, out ):
>unittest.TestCase.__init__(self,'testRun')
>self.fname = eval(fname,globals())
>self.input = farg
>self.fparse = getattr(self,'load_%s' % t_out)
>self.output = self.fparse( out )
>
>def load_dict(self,data):
>assert data[0] is '{', 'Wrong dict format %s' % data
>assert data[-1] is '}', 'Wrong dict format %s' % data
>items = data[1:-1].split(',')
>return dict( map( split, map( strip, items ) ) )
>
>def testRun(self):
>self.assertEquals( self.fname(self.input), self.output )
>
>
> def build_tests( filename ):
>try:
>fd = open( filename, 'r')
>tc = TestStub( *fd.read().split("~") )
>del fd
>return tc
>except:
>import traceback; traceback.print_exc()
>raise TestStubException( 'Failed creating test case from file
> : %s'%filename )
>
> if __name__== '__main__':
>
>tc_data = glob.glob('*.txt') # all text files with data
>
>ts = unittest.TestSuite()
>
>for tc_file in tc_data:
>ts.addTest( build_tests( tc_file ) )
>
>unittest.TextTestRunner().run(ts)
> 
> 
> Fabrizio Milo aka Misto

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


  1   2   3   >