Re: Gnu/Linux dialogue boxes in python

2007-12-18 Thread Donn Ingle
> I've now uploaded a new release of the desktop module which is now, in
> fact, a package:
Thanks Paul, I saw it via the cheese shop rss. I have been too busy to read
this list for a week. I will have a look in due course.

\d

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


Re: build a syntax tree

2007-12-18 Thread Arnaud Delobelle
On Dec 18, 10:43 pm, Federico <[EMAIL PROTECTED]> wrote:
> Hi I've some trivial question:
>
> for exercise I want to parse a string that like this:
>
> "x -34 + 65 * 96 = 102"
>
> now if I had this ("(25+24)/2") is extremely easy to have a result but
> I want to resolve the above string (for the 'x' variable) what can I
> do?
>
> Especially for symbolic function  I think that I've to build an
> 'operations tree' with a variable table.
> I want to  know how Derive parse this kind of string.
>
> If I've to build a tree, please give me resources and/or examples of
> what physically is a tree and how to build on python.
>
> Thanks :)

You can use a parser generator to build the syntax tree that you want.
See http://wiki.python.org/moin/LanguageParsing for a list.

Perhaps pyparsing is a good one to start with?
http://pyparsing.wikispaces.com/

HTH

--
Arnaud

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


Re: Problem untaring python2.5

2007-12-18 Thread samuel . progin
Hello,

It is not possible to give sharp hints without more relevant
information like:
- What is your platform?
- Which version of python?
- What is the version of: $ tar --version (GNU tar, other proprietary
tar, according to my personal experience, AIX tar may fail)
- Is your disk full or do you have the correct permissions with your
current user?

++

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


import X between submodules in a package

2007-12-18 Thread Donn Ingle
Hi, I'm sure this is a FAQ, but I have just not found clarity on the
web/docs.

(using monospaced type to show the tree)
trunk:$ tree
.
fp
|-- fontypython
|   |-- __init__.py
|   |-- cli.py
|   |-- config.py

(I start it all with ./fp)

fp says:
import cli

cli.py says:
import os
import config

config.py says:
print os.environ['HOME']

I get a NameError in config.py

If I add 'import os' to config.py all is well.

So, I guess I am confused about the 'scope' of what gets imported where. I
am thinking that if one module (py file) does *import os* something and
*then* imports another module - the second module should have access to os
too?
 I imagine myself "standing" inside cli.py at this point and saying "well I
can see os, and I'm bringing config *into* this space, so they should be
able to see os too."

How do I structure things so that I don't have endless repetitions of import
in every py file within my package directory?

\d


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


Re: More than one interpreter per process?

2007-12-18 Thread Christian Heimes
Roger Binns wrote:
> sturlamolden wrote:
>> If one can have more than one interpreter in a single process, 
> 
> You can.  Have a look at mod_python and mod_wsgi which does exactly
> this.  But extension modules that use the simplified GIL api don't work
> with them (well, if at all).

No, you can't. Sub-interpreters share a single GIL and other state. Why
don't you run multiple processes? It's on of the oldest and best working
ways use the full potential of your system. Lot's of Unix servers like
postfix, qmail, apache (with some workers) et al. use processes.

Christian

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


Re: New+old-style multiple inheritance

2007-12-18 Thread Michele Simionato
On Dec 18, 9:25 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> A well-considered, timely monkey-patch can sometimes save all kinds of
> workarounds and other headaches.
>
> Carl Banks

+1

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


Re: Strict mode?

2007-12-18 Thread Noah Dain
On Dec 18, 2007 5:03 PM, Jack <[EMAIL PROTECTED]> wrote:
> While enjoying the dynamic feature of Python I find it difficult to refactor
> code without breaking it. For example, if I modify a function to take more
> arguments, or arguments of different types, I'll need to manually find out
> all places where the function is called and make sure I modify them all,
> unlike in C/Java, where the compiler will do the work of checking function
> signatures, etc. I suppose there isn't a strict mode in Python. It would be
> helpful though, when I don't need things to be so dynamic, and this is often
> the case, when it comes to function arguments and return values, for
> example. Even a module level or function level flag would be very helpful to
> find broken code. Or, are there any third party tools that do this?
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Description: A refactoring tool for python
 A framework and refactoring tool for Python. IDE Plugins are included for
 Pymacs, IDLE and Vim. Using Bicycle Repair Man you can rename classes, methods
 and variables, and all users of them are found and adjusted appropriately.
 .
  Homepage: http://bicyclerepair.sourceforge.net/


-- 
Noah Dain
"The beatings will continue, until morale improves" - the Management
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New+old-style multiple inheritance

2007-12-18 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| Thank Gabriel,
|
| That sounds exactly right and your work-around provides confirmation.
| This code is an expedient solution for us so I expect we'll go with
| forcing a slot update.  Hopefully the library concerned is going to
| fix the problem in a future release.

To work with 3.0, they will have to, or rather it will be done for them, 
since there will only be new style classes.



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


Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)

2007-12-18 Thread Ravi Kumar
>
> If I had to do something like this I would host a Python web
> server listening on some port and let .NET application talk to me
> using HTTP requests preferably or SOAP if I really had to.
> It could be a Paster or Cherrypy or Twisted based server.
> Google for instruction on how to package it using py2exe
> into a windows service.
> The service could be hosted on the same server as .NET or a separate
> box

Thats is the best solution to me also, but restrictions are I cann't
consume extra service for it. I need tight integration and no remote
service calls, thats why it seems bit tricky to me., and i am working
to integrate Python implementation in .NET.
So where the .NET application has to work with PDF part, it will
invoke the IronPython Engine, pass required configurations and
parameters, and get the result+exceptions etc.

>
> http://pybrary.net/pyPdf/

Noted for my reference.  Thanks :)

> > -Which XML Library is pure python based.
> >
>
> ElementTree
So ElementTree solved one part. thanks friend.


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


Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)

2007-12-18 Thread Ravi Kumar
> Joshua:
> PDF library: ReportLab. But that is most generation of PDFs.  For reading,
> splitting, etc, you may have to look at their commercial offering

I will have to research on it, i think time to list the best available
libs, and finding all's dependency.

> On Dec 19, 2007 6:10 AM, Boris Borcic <[EMAIL PROTECTED]> wrote:
> Everybody will tell you "reportlab", but AFAIK the open-source kit does not
> provide manipulation of existing pdf file contents - "only" creation. Besides
> it's targeted at CPython and it isn't 100% clear it runs perfectly on other
> implementations; so have a look at itextsharp - it might better fit your needs
> if you decide to use IronPython.
>

iTextSharp look very promising. But i am unable to find any good
documentation. I think i will have to buy the book, so that I can have
API docs just beside me for reference.

One thing I am stuck at right now. the IronPython 1.0.2467 on .NET
2.0.50727.42 is installed on my Ubuntu, so does CPython 2.5 libraries
can be called in it without any problem.
In ipy shell,
>>> sys.path
['/home/rskumar', '/usr/lib/ironpython/Lib', '/usr/lib/python2.4',
'/usr/lib/python2.4/site-packages']
>>>

so it uses Python 2.4 libs. I am fearing to mix the 2.4 and 2.5 libs.
I need to load CPython 2.5 libs by adding it in site.py file of
ironpython. Maybe I should go experimenting and let you people know
about it.

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


Re: More than one interpreter per process?

2007-12-18 Thread Graham Dumpleton
On Dec 19, 3:07 pm, Roger Binns <[EMAIL PROTECTED]> wrote:
> Graham Dumpleton wrote:
> > When using mod_wsgi there is no problem with C extension modules which
> > use simplified GIL API provided that one configures mod_wsgi to
> > delegate that specific application to run in the context of the first
> > interpreter instance created by Python.
>
> Graham, I've asked you before but never quite got a straight answer.

Maybe because it isn't that simple. :-)

> What *exactly* should extension authors change their code to in order to
> be fully compatible?  For example how should the C function below be
> changed:
>
> void somefunc(void)
> {
>   PyGILState_STATE gilstate=PyGILState_Ensure();
>
>   abc();
>
>   Py_BEGIN_ALLOW_THREADS
>  def();
>   Py_END_ALLOW_THREADS
>
>   ghi();
>
>   PyGILState_Release(gilstate);
>
> }

What you do depends on what the overall C extension module does. It
isn't really possible to say how the above may need to be changed as
there is a great deal of context which is missing as far as knowing
how that function comes to be called. Presented with that function in
isolation I can only say that using simplified GIL API is probably the
only way of doing it and therefore can only be used safely against the
first interpreter created by Python.

If the direction of calling for a C extension module is always Python
code into C code and that is far as it goes, then none of this is an
issue as you only need to use Py_BEGIN_ALLOW_THREADS and
Py_END_ALLOW_THREADS.

The problem case is where C code needs to callback into Python code
and you are not using simplified GIL API in order to be able to
support multiple sub interpreters. The easiest thing to do here is to
cache a thread state object for the interpreter instance when you
first obtained the handle for the object which allows you to interact
with C extension module internals. Later when a callback from C to
Python code needs to occur then you lookup the cached thread state
object and use that as the argument to PyEval_AcquireThread().

As example see:

  http://svn.dscpl.com.au/ose/trunk/software/python/opydispatch.cc

The thread state object is cached when handle to an instance is first
created. Any callbacks which are registered remember the interpreter
pointer and then that is used as key to lookup up the cached thread
state.

This code was done a long time ago. It is possible that it needs to be
revised based on what has been learnt about simplified GIL API.

This way of doing things will also not work where it is possible that
sub interpreters are created and then later destroyed prior to process
exit because of the fact that the interpreter pointer is cached. But
then, enough C extension modules have this problem that recycling sub
interpreters in a process isn't practical anyway.

Note that the indicated file uses a global cache. The agent.hh/
opyagent.cc files at that same location implement a more complicated
caching system based on individual objects.

The software which this is from is probably a more extreme example of
what is required, but your example was too simple to draw any
conclusions from.

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


Re: How to generate pdf file from an html page??

2007-12-18 Thread abhishek
On Dec 17, 8:42 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-12-16, abhishek <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone, I am trying to generate a PDF printable format file from
> > an html page. Is there a way to do this using python. If yes then
> > which library and functions are required and if no then reasons why it
> > cant be done.
>
> Here's one way:
>
> --html2pdf.py-
> #!/usr/bin/python
> import os,sys
>
> inputFilename,outputFilename = sys.argv[1:3]
>
> os.system("w3m -dump %s | a2ps -B --borders=no | ps2pdf - %s" % 
> (inputFilename,outputFilename))
> --
>
> --
> Grant Edwards   grante Yow! Someone in DAYTON,
>   at   Ohio is selling USED
>visi.comCARPETS to a SERBO-CROATIAN

hi grant have tried the command it resulted in the following errors
--

sh: a2ps: not found
ESP Ghostscript 815.04:  Could not open the file /home/samba/users/
Abhishek/newTemplate.pdf .
 Unable to open the initial device, quitting.
256
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why custom objects take so much memory?

2007-12-18 Thread Robert Kern
Steven D'Aprano wrote:
> On Tue, 18 Dec 2007 21:13:14 +0100, Hrvoje Niksic wrote:
> 
>> Each object takes 36 bytes itself: 4 bytes refcount + 4 bytes type ptr +
>> 4 bytes dict ptr + 4 bytes weakptr + 12 bytes gc overhead.  That's not
>> counting malloc overhead, which should be low since objects aren't
>> malloced individually.  Each object requires a dict, which consumes
>> additional 52 bytes of memory (40 bytes for the dict struct plus 12 for
>> gc).  That's 88 bytes per object, not counting malloc overhead.
> 
> And let's not forget that if you're running on a 64-bit system, you can 
> double the size of every pointer.
> 
> Is there a canonical list of how much memory Python objects take up? Or a 
> canonical algorithm?

Here is Martin v. Löwis giving a few pointers (pardon the pun):

http://mail.python.org/pipermail/python-list/2002-March/135223.html
http://groups.google.de/group/comp.lang.python/msg/b9afcfc2e1de5b05?hl=de

> Or failing either of those, a good heuristic?

I thought there was a tool that tried to estimate this using hints from the
type, but Googling has availed me not.

>> Then there's string allocation: your average string is 6 chars long; add
>> to that one additional char for the terminating zero.
> 
> Are you sure about that?

Yes. Look at Include/stringobject.h:

"""
Type PyStringObject represents a character string.  An extra zero byte is
reserved at the end to ensure it is zero-terminated, but a size is
present so strings with null bytes in them can be represented.  This
is an immutable object type.
"""

> If Python strings are zero terminated, how does 
> Python deal with this?
> 
 'a\0string'[1]
> '\x00'

It stores a length separate from the value. The 0-termination is a courtesy to C
APIs that expect 0-terminated strings. It does not define the end of the Python
string, though.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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

Re: NameError: name 'main' is not defined

2007-12-18 Thread jolly
thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem untaring python2.5

2007-12-18 Thread abhishek
Hi everyone , i am not able to untar python 2.5 source code using "
tar -xvzf " . Is it a problem with my system settings or python 2.5
itself.

When i tried to do it it resulted in following errors --

tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ide/
new_window_made.gif
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/ide/new_window_made.gif: Cannot open: No such file or
directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ide/
output_window.gif
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/ide/output_window.gif: Cannot open: No such file or
directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ide/
simple_commands.gif
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/ide/simple_commands.gif: Cannot open: No such file or
directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
doc/
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/doc: Cannot mkdir: No such file or directory
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/doc/
index.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/doc/index.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
scripting.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/scripting.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
python.gif
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/python.gif: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
pythonsmall.gif
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/pythonsmall.gif: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
community.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/community.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
gui.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/gui.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
PackageManager.gif
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/PackageManager.gif: Cannot open: No such file or
directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
finder.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/finder.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
index.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/index.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
shell.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/shell.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
packman.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/packman.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/
intro.html
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
Documentation/intro.html: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/English.lproj/InfoPlist.strings
tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/
InfoPlist.strings: Cannot open: No such file or directory
tar: Skipping to next header
Python-2.5/Mac/Resources/app/Resources/PythonInterpreter.icns
tar: Python-2.5/Mac/Resources/app/Resources/PythonInterpreter.icns:
Cannot open: No such file or directory
tar: Skipping to next header
tar: Error exit delayed from previous errors
-- 
http://mail.python.org/mailman/listinfo/python-list


Python-URL! - weekly Python news and links (Dec 18)

2007-12-18 Thread Gabriel Genellina
QOTW:  "XML.  Almost as good as plain text for grepping." - Joe Mason

"Where there's IP, there's a way." - Kyler Laird, on network programming


Linked lists, deques, and iteration over a mutating container:

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

Containers should compare themselves using only their
contained objects's available comparison operators:

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

The distinction between methods and callable attributes:

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

Discussing alternative loop constructs:

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

Analyzing slow code for loading data, and trying to
improve it, with general tips on optmization:

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

Unexpected floating point rounding errors:

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

Improving the Python core (JIT compilation and others), and how
the development process works (a long thread started last week)

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

Ways to do inter-process communication:

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

The csv module: examples, improvements, and complaints
about lack of documentation:

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

Is Python really a "scripting language"? (advocacy)

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

Looping two iterables at once:

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

zip() as its own inverse:

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

Python compared to Java

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



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

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

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

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish "the efforts of Python enthusiats":
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the "Planet" sites:
http://planetpython.org
http://planet.python.org

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

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

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

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

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

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

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

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development a

Re: Why custom objects take so much memory?

2007-12-18 Thread Steven D'Aprano
On Tue, 18 Dec 2007 21:13:14 +0100, Hrvoje Niksic wrote:

> Each object takes 36 bytes itself: 4 bytes refcount + 4 bytes type ptr +
> 4 bytes dict ptr + 4 bytes weakptr + 12 bytes gc overhead.  That's not
> counting malloc overhead, which should be low since objects aren't
> malloced individually.  Each object requires a dict, which consumes
> additional 52 bytes of memory (40 bytes for the dict struct plus 12 for
> gc).  That's 88 bytes per object, not counting malloc overhead.

And let's not forget that if you're running on a 64-bit system, you can 
double the size of every pointer.

Is there a canonical list of how much memory Python objects take up? Or a 
canonical algorithm?

Or failing either of those, a good heuristic?


> Then there's string allocation: your average string is 6 chars long; add
> to that one additional char for the terminating zero.

Are you sure about that? If Python strings are zero terminated, how does 
Python deal with this?

>>> 'a\0string'[1]
'\x00'




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


Re: WikiInclude on 0.11 - Noah Kantrowitz blocks bug-fix

2007-12-18 Thread Ilias Lazaridis
On Dec 18, 9:15 pm, smallpond <[EMAIL PROTECTED]> wrote:
> On Dec 17, 9:23 pm, Ilias Lazaridis <[EMAIL PROTECTED]> wrote:
>
>
>
> > Essence:
>
> >  * Deletion of valid defect reports on trac community resources
>
> > The "WikiInclude" plugin is not recognised on trac 0.11, thus I took a
> > look an made a small addition to the setup.py (the entry_point).
>
> > Other users have the same problem, thus I filed a ticket in the "trac-
> > hacks" community resource.
>
> > Mr. Noah Kantrowitz closed the ticket as "invalid". My comments within
> > this ticket are deleted, directly in the database, which is the same
> > as censorship. I've copied the email-notification from my comment
> > below. [1]
>
> > Please realize:
>
> >  * this is a real-live defect, which remains unprocessed, thus more
> > users run into this trouble.
> >  * My attemps to inform users in the user-threads do not show up in
> > all threads (moderation on trac-users!!!)
> >  * The "IncludeMacro" is not compatible to the "WikiInclude" macro
> >  * My comments were deleted in a non-trackable way
> >  * Users of the WikiInclude plugin are not informed in any way
>
> > You are may wondering why the trac project fails to produce a stable
> > 1.0 version since years. The answer is here:
>
> >http://case.lazaridis.com/wiki/TracAudit
>
> > -
>
> > [1]
>
> > #2294: Plugin is not detectd on trac 0.11 (even the 0.11 specific one)
> > 
> > +---
> > Reporter:  [EMAIL PROTECTED]  |Owner:  yu-ji
> >Type:  defect   |   Status:  reopened
> > Priority:  normal   |Component:  WikiIncludePlugin
> > Severity:  critical |   Resolution:
> > Keywords:   |  Release:  0.11
> > 
> > +---
> > Changes (by [EMAIL PROTECTED]):
>
> >  * status:  closed => reopened
> >  * resolution:  invalid =>
> >  * summary:  Missing "entry_point" within setup.py => Plugin is not
> >  detectd on trac 0.11 (even the 0.11 specific
> >  one)
>
> > Comment:
>
> >  (Mr. Kantrowitz. This is defenitely a defect, which occoured for
> > several
> >  users. The provided information helps any user which hits on this
> > ticket
> >  via a search. I ask you once more to stop with the deletions on this
> >  '''community''' resource).
>
> >  The resolution "invalid" is incorrect.
>
> >  The problem exists for me '''and other''' users, see e.g.:
>
> >  * [http://groups.google.com/group/trac-users/browse_frm/thread/
> > de454e7dcf9f0438/d9806ad4a31a14a7 thread 1]
> >  * [http://groups.google.com/group/trac-users/browse_frm/thread/
> > 2ccf4b2855a6f242?q=WikiInclude& thread 2]
>
> >  I've solved it whilst simply adding the entry point to the setup.py.
>
> >  It is ok to point to the more flexible and maintained "IncludeMacro",
> > but
> >  other people possibly just want to continue to use the simpler
> >  "WikiInclude" one.
>
> >  I suggest the maintainer of "WikiInclude" (or another developer)
> > corrects
> >  the setup.py in the repo, and additionally one should place a note in
> > the
> >  "WikiInclude" documentation, that there's a more flexible
> > "IncludeMacro"
> >  available.
>
> Trac is a python application.

yes, that's why the followup goes to c.l.p

> Please read the posting guidelines for c.l.p.m

no need.

the topic affects other open-source communities, too.

(hints: censorship, trac is used within open-source domain, ...)

http://case.lazaridis.com/ticket/42
http://case.lazaridis.com/wiki/TracAudit

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


Re: operator module isSequenceType with builtin set produces False

2007-12-18 Thread Gabriel Genellina
En Tue, 18 Dec 2007 09:15:12 -0300, English, Mark <[EMAIL PROTECTED]>  
escribió:

 try: set
 except NameError: from sets import Set as set
 class myset_fails(set): pass
 class myset_works(set):
 def __getitem__(self): pass
 s = set()
 fails = myset_fails()
 works = myset_works()
 import operator
 operator.isSequenceType(s) #Not what I expected
> False
 operator.isSequenceType(fails) #Not what I expected either
> False
 operator.isSequenceType(works) #A hint at what isSequenceType does ?
> True
>
> Are sets not sequences ? I didn't think the isSequenceDisclaimer gave
> false negatives.

No, sets aren't sequences, as they have no order. Same as dicts, which  
aren't sequences either.
If you add a __getitem__ method, isSequenceType can only *guess* that it  
*could* be used with integer indexes, so this object *could* be (or behave  
like) a sequence. The object could be a mapping too, and there is no way  
to tell the difference without inspecting or executing __getitem__. That's  
all isSequenceType can do for arbitrary objects.

> See Raymond Hettinger's post here too:
> http://groups.google.co.uk/group/comp.lang.python/tree/browse_frm/thread
> /bd04db20cc1f23bb/36f1f48bb7be1e4b?hl=en&rnum=1&q=set+isSequenceType&_do
> ne=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2Fbd04db20cc1f23bb%
> 2F0454f5debc01c20d%3Fhl%3Den%26lnk%3Dgst%26q%3Dset%2BisSequenceType%26#d
> oc_0454f5debc01c20d
>
> Although there are suggestions that it means simply that you're headed
> in the wrong direction design wise:
> http://www.mail-archive.com/[EMAIL PROTECTED]/msg11576.html
>
> but then why have isSequenceType at all ?

There are *true* sequences that it can detect, like lists, strings and all  
their subclases. For classic classes (that couldn't inherit from builtin  
types) all it can do is to guess based on __getitem__. For new style  
classes, it checks whether the slot used for __getitem__ is filled.

> Not particularly vital. Just implementing __str__ on some class and if
> one of the members was a sequence
> I was going to format that bit of data in brackets.

As R. Hettinger said, you may add your own knowledge to what  
isSequenceType says, to determine whay *you* consider a sequence in this  
context.

-- 
Gabriel Genellina

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


Re: NameError: name 'main' is not defined

2007-12-18 Thread Robert Kern
jolly wrote:
> hey guys,
> 
> When i try to run my code I get an error. NameError name 'main is not
> defined'
> 
> [code]
> if __name__ == "__main__":
> main()

Put this at the end of the file. Currently, it is getting executed before the
code that defines main().

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: More than one interpreter per process?

2007-12-18 Thread Roger Binns
Graham Dumpleton wrote:
> When using mod_wsgi there is no problem with C extension modules which
> use simplified GIL API provided that one configures mod_wsgi to
> delegate that specific application to run in the context of the first
> interpreter instance created by Python.

Graham, I've asked you before but never quite got a straight answer.
What *exactly* should extension authors change their code to in order to
be fully compatible?  For example how should the C function below be
changed:

void somefunc(void)
{
  PyGILState_STATE gilstate=PyGILState_Ensure();

  abc();

  Py_BEGIN_ALLOW_THREADS
 def();
  Py_END_ALLOW_THREADS

  ghi();

  PyGILState_Release(gilstate);
}

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


Re: More than one interpreter per process?

2007-12-18 Thread Roger Binns
sturlamolden wrote:
> On 18 Des, 10:24, Roger Binns <[EMAIL PROTECTED]> wrote:
> 
>> The biggest stumbling block is what to do when the external environment
>> makes a new thread and then eventually calls back into Python.  It is
>> hard to know which interpretter that callback should go to.
> 
> Not if you explicitely hav to pass a pointer to the interpreter in
> every API call, which is what I suggested.

You missed my point.  What if the code calling back into Python doesn't
know which interpreter it belongs to?  Think of web server with python
callbacks registered for handling various things.  Currently that
situation works just fine as the simplified gil apis just pick the main
interpreter.

You have now imposed a requirement on all extension modules that they
need to keep track of interpreters in such a way that callbacks from new
threads not started by Python know which interpreter they belong to.
This is usually possible because you can give callback data in the
external environment apis, but your mechanism would prevent any that
don't have that ability from working at all.  We wouldn't find those
"broken" implementations until changing to your mechanism.

> But porting could be automated by a simple Python script. 

Have you actually tried it?  See if you can do it for the sqlite module
which is a standard part of the Python library.

> PEPs are closed for Python 3.

You glossed over my "prove the benefit outweighs the costs" bit :-)
This project will let you transparently use multiple processes:

 http://cheeseshop.python.org/pypi/processing

There are other techniques for parallelization using multiple processes
and even the network.  For example:

http://www.artima.com/forums/flat.jsp?forum=106&thread=214303
http://www.artima.com/weblogs/viewpost.jsp?thread=214235

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


Re: Detecting memory leaks on apache, mod_python

2007-12-18 Thread Ilias Lazaridis
On Dec 17, 8:41 am, Ilias Lazaridis <[EMAIL PROTECTED]> wrote:
> How to detect memory leaks of python programms, which run in an
> environment like this:
>
>  * Suse Linux 9.3
>  * Apache
>  * mod_python
>
> The problem occoured after some updates on the infrastructure. It's
> most possibly caused by trac and it's dependencies, but several
> components of the OS where updated, too.
>
> Any nice tools which play with the above constellation?
>
> Thank's for any hints!

No tool available to detect memory leaks for python applications?

> context:
>
> http://dev.lazaridis.com/base/ticket/148

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


NameError: name 'main' is not defined

2007-12-18 Thread jolly
hey guys,

When i try to run my code I get an error. NameError name 'main is not
defined'

[code]
if __name__ == "__main__":
main()

filename = "addbook.dat"

def main():
theMenu = '''
1) Add Entry
2) Remove Entry
3) Find Entry
4) Quit and Save
'''
theBook = {}
readBook(theBook)
choice = getChoice(theMenu)
while choice != 4:
if choice == 1:
addEntry(book)
elif choice == 2:
removeEntry(book)
elif choice == 3:
findEntry(book)
else:
print "Invalid choice, try again."
choice = getChoice(theMenu)
saveBook(theBook)


def readbook(book):
import os
if os.path.exists(filename):
store = open(filename,'r')
for line in store:
name = line.rstrip()
entry = store.net().rstrip
book[name] = entry
store.close()

def saveBook(book):
store = open(filename,'w')
for name,entry in book.items():
store.write(name + '\n')
store.write(entry + '\n')
store.close()

def getChoice(menu):
print menu
choice = int( raw_input("Select a choice(1-4): ") )
return choice

def addEntry(book):
name=raw_input("Enter a name: ")
entry = raw_input("Enter a street, town and phone number: ")
book[name] = entry

def removeEntry(book):
name=raw_input("Enter a name: ")
del(book[name])

def findEntry(book):
name = raw_input("Enter a name: ")
if name in book:
print name, book[name]
else: print "Sorry, no entry for: ",name


[/code]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: askopenfilename() as root window

2007-12-18 Thread Sean DiZazzo
On Dec 18, 6:06 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> On 18 dic, 22:43, Sean DiZazzo <[EMAIL PROTECTED]> wrote:
>
> > Is there any way to open a Tkinter.askopenfilename() without opening a
> > root window alongside the file chooser?
>
> > I simply want a script to open a dialog and return the chosen file's
> > path to stdout.
>
> Yes, create the root yourself so you can call the withdraw() method:
>
> root = Tk()
> root.withdraw()
> print askopenfilename()
>
> --
> Gabriel Genellina

As usual... Thank you Gabriel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Grant Edwards
On 2007-12-19, Jonathan Gardner <[EMAIL PROTECTED]> wrote:
> On Dec 18, 2:16 pm, Sam <[EMAIL PROTECTED]> wrote:
>> layouts = ['column', 'form', 'frame']
>> cmds.window(t='gwfUI Builder')
>> cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
>> 100)))
>> cmds.paneLayout(configuration='horizontal2')
>> cmds.frameLayout(l='Layouts')
>> cmds.scrollLayout(cr=True)
>> cmds.columnLayout(adj=True, cat=('both', 2))
>> for i in layouts:
>> cmds.button(l=i)
>> cmds.setParent('..')
>> cmds.setParent('..')
>> cmds.setParent('..')
>> cmds.setParent('..')
>> cmds.setParent('..')
>> cmds.showWindow()
>>
>
> While Grant is pulling his hair out and yelling obscenities at the
> moon,

Damn.  I thought that webcam was shut off...

-- 
Grant

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


Re: More than one interpreter per process?

2007-12-18 Thread Graham Dumpleton
On Dec 18, 8:24 pm, Roger Binns <[EMAIL PROTECTED]> wrote:
> sturlamolden wrote:
> > If one can have more than one interpreter in a single process,
>
> You can.  Have a look at mod_python andmod_wsgiwhich does exactly
> this.  But extension modules that use the simplified GIL api don't work
> with them (well, if at all).

When using mod_wsgi there is no problem with C extension modules which
use simplified GIL API provided that one configures mod_wsgi to
delegate that specific application to run in the context of the first
interpreter instance created by Python.

In theory the same should be the case for mod_python but there is
currently a bug in the way that mod_python works such that some C
extension modules using simplified API for the GIL still don't work
even when made to run in first interpreter.

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


Re: Best way to protect my new commercial software.

2007-12-18 Thread Robert Kern
Steven D'Aprano wrote:
> On Tue, 18 Dec 2007 21:54:26 +, Grant Edwards wrote:
> 
>> On 2007-12-18, Steven D'Aprano <[EMAIL PROTECTED]>
>> wrote:
>>> On Tue, 18 Dec 2007 17:04:29 +, Grant Edwards wrote:
>>>
 On 2007-12-18, Jan Claeys <[EMAIL PROTECTED]> wrote:
> Op Fri, 14 Dec 2007 16:54:35 +, schreef Grant Edwards:
>
>> Uh what?  I don't know what country you're in, but in the US, it
>> doesn't take any time at all to copyright something.  The mere act
>> of writing something copyrights it.  I thought it was the same in
>> Europe as well.
> No, it's only copyrighted when you _publish_ it.
 Interesting.  So, in Europe, if somebody steals something you wrote
 before you get it published, they're free to do with it as they
 please?
>>> Please do not conflate theft and copyright infringement, or theft and
>>> plagiarism.
>> I wasn't.  If I write something down and somebody steals that paper,
>> that's theft.
> 
> In which case copyright isn't going to protect you -- especially if you 
> were relying on automatic copyright and haven't registered it.


Well, you can get injunctive relief without registering the copyright. Copyright
doesn't protect one from physical theft, but it does grant some protection
against the things the thief might do with the stolen goods.

For example, suppose someone steals my laptop with all of my code on it. They
could take my unpublished code and slap it on SourceForge. Provided that I could
prove authorship, I could get a court order for the thief to remove that code. I
don't need to prove that he stole my laptop in order to do that. Actually, now
that I think about it, I could issue a DMCA takedown notice, and I wouldn't need
to prove anything at all unless if the notice gets challenged; then the burden
of proof is on them.


-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: More than one interpreter per process?

2007-12-18 Thread Graham Dumpleton
On Dec 19, 2:37 am, sturlamolden <[EMAIL PROTECTED]> wrote:
> On 18 Des, 10:24, Roger Binns <[EMAIL PROTECTED]> wrote:
>
> > You can.  Have a look at mod_python andmod_wsgiwhich does exactly
> > this.  But extension modules that use the simplified GIL api don't work
> > with them (well, if at all).
>
> mod_python implements use Py_NewInterpreter() to create sub-
> interpreters. They all share the same GIL. The GIL is declared static
> in ceval.c, and shared for the whole process. But ok, if
> PyEval_AquireLock() would take a pointer to a 'sub-GIL', sub-
> interpreters could run concurrent on SMPs. But it would require a
> separate thread scheduler in each subprocess.

In current versions of Python it is possible for multiple sub
interpreters to access the same instance of a Python object which is
notionally independent of any particular interpreter. In other words,
sharing of objects exists between sub interpreters. If you remove the
global GIL and make it per sub interpreter then you would loose this
ability. This may have an impact of some third party C extension
modules, or in embedded systems, which are able to cache simple Python
data objects for use in multiple sub interpreters so that memory usage
is reduced.

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


Re: Best way to protect my new commercial software.

2007-12-18 Thread Steven D'Aprano
On Tue, 18 Dec 2007 21:54:26 +, Grant Edwards wrote:

> On 2007-12-18, Steven D'Aprano <[EMAIL PROTECTED]>
> wrote:
>> On Tue, 18 Dec 2007 17:04:29 +, Grant Edwards wrote:
>>
>>> On 2007-12-18, Jan Claeys <[EMAIL PROTECTED]> wrote:
 Op Fri, 14 Dec 2007 16:54:35 +, schreef Grant Edwards:

> Uh what?  I don't know what country you're in, but in the US, it
> doesn't take any time at all to copyright something.  The mere act
> of writing something copyrights it.  I thought it was the same in
> Europe as well.

 No, it's only copyrighted when you _publish_ it.
>>> 
>>> Interesting.  So, in Europe, if somebody steals something you wrote
>>> before you get it published, they're free to do with it as they
>>> please?
>>
>> Please do not conflate theft and copyright infringement, or theft and
>> plagiarism.
> 
> I wasn't.  If I write something down and somebody steals that paper,
> that's theft.

In which case copyright isn't going to protect you -- especially if you 
were relying on automatic copyright and haven't registered it.




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


Re: askopenfilename() as root window

2007-12-18 Thread Gabriel Genellina
On 18 dic, 22:43, Sean DiZazzo <[EMAIL PROTECTED]> wrote:

> Is there any way to open a Tkinter.askopenfilename() without opening a
> root window alongside the file chooser?
>
> I simply want a script to open a dialog and return the chosen file's
> path to stdout.

Yes, create the root yourself so you can call the withdraw() method:

root = Tk()
root.withdraw()
print askopenfilename()

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


askopenfilename() as root window

2007-12-18 Thread Sean DiZazzo
Is there any way to open a Tkinter.askopenfilename() without opening a
root window alongside the file chooser?

I simply want a script to open a dialog and return the chosen file's
path to stdout.

"""
from tkFileDialog import askopenfilename

print askopenfilename()
"""

...does the job, but it opens that nagging root window beside it.  I
tried setting parent=None to no avail.  The second window always shows
up.  Any ideas?

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


Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)

2007-12-18 Thread Waldemar Osuch
On Dec 18, 6:42 am, "Ravi Kumar" <[EMAIL PROTECTED]> wrote:
> In continuation of last mail [since pressing tab+space sent the mail :( ]
> Things on high priorities right now are:
> - How to integrate Python calling from .NET

If I had to do something like this I would host a Python web
server listening on some port and let .NET application talk to me
using HTTP requests preferably or SOAP if I really had to.
It could be a Paster or Cherrypy or Twisted based server.
Google for instruction on how to package it using py2exe
into a windows service.
The service could be hosted on the same server as .NET or a separate
box

> - Any suggestions for optimizations that would prevent overburden to
> application due to IronPython interpretation calling, if any, or does
> such things happen.
> - Pointers to good resources
> - Any step in such kind of situation, so to make it Enterprise Grade
> application components

I do not have Enterprise Grade Seal of Approval but similar setup is
running successfully at my workplace for the last 2 years.

> - your opinion with available PDF Libraries, that are best among. Also
> which library to use for Windows server platform (there is limitation
> on installing long chain libraries that include other deep
> dependencies too). A pure python PDF library would be good, but which
> one.

http://pybrary.net/pyPdf/

> -Which XML Library is pure python based.
>

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


Re: pySerial

2007-12-18 Thread __zip__
Tnx for help. Done it.

The problem was that returning bytes were on few lines and I
didn't look after first \n :(

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


Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Jason
On Dec 18, 5:18 pm, Sam <[EMAIL PROTECTED]> wrote:
> On Dec 18, 7:09 pm, Jonathan Gardner
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > On Dec 18, 2:16 pm, Sam <[EMAIL PROTECTED]> wrote:
>
> > > layouts = ['column', 'form', 'frame']
> > > cmds.window(t='gwfUI Builder')
> > > cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
> > > 100)))
> > > cmds.paneLayout(configuration='horizontal2')
> > > cmds.frameLayout(l='Layouts')
> > > cmds.scrollLayout(cr=True)
> > > cmds.columnLayout(adj=True, cat=('both', 2))
> > > for i in layouts:
> > > cmds.button(l=i)
> > > cmds.setParent('..')
> > > cmds.setParent('..')
> > > cmds.setParent('..')
> > > cmds.setParent('..')
> > > cmds.setParent('..')
> > > cmds.showWindow()
>
> > While Grant is pulling his hair out and yelling obscenities at the
> > moon, let me try to explain why you'd never want to indent code that
> > way, let alone write code that way.
>
> > In cases where you have to run a sequence of code in a nested way,
> > like this, it's best to create functions and then nest the functions.
> > Of course, I'm thinking more of a lisp solution and less of a C one.
>
> > In this case, you're going to have to have objects (or data
> > structures) that know what to do to execute the commands necessary.
> > When you get them all assembled, you simply run them in a recursive
> > way.
>
> > For instance:
>
> >   cmd.build(('pane', dict(configuration='horizontal'), ('frame',
> > dict(l='Layouts'), (
>
> > You can indent these arbitrarily. Plus, you don't have to worry too
> > much about matching setParent and the other commands.
>
> That makes sense to me.  The library that was being used in that
> example didn't strike me as very Pythonic (what with the using one
> command object for everything and calling setParent('..') to point to
> the next object up in the hierarchy).  But there's no reason (as far
> as I know) that he couldn't create helper functions to wrap that with
> something more sane.

Let me add that, for lots of GUI layout, most programming languages
are the wrong tool for the job.  GUI layout involves tons of nested,
almost boiler-plate type data.  Use a tool to generate the layout that
the code can load, and perform the few tweaks that you might need.
This makes things far more sane, especially for anyone who has to
maintain the layout later.

The lack of such a layout tool is a weakness of your GUI library, not
necessarily a problem with the program language.

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


Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)

2007-12-18 Thread Boris Borcic
Ravi Kumar wrote:
> - your opinion with available PDF Libraries, that are best among. Also
> which library to use for Windows server platform (there is limitation
> on installing long chain libraries that include other deep
> dependencies too). A pure python PDF library would be good, but which
> one.

Everybody will tell you "reportlab", but AFAIK the open-source kit does not 
provide manipulation of existing pdf file contents - "only" creation. Besides 
it's targeted at CPython and it isn't 100% clear it runs perfectly on other 
implementations; so have a look at itextsharp - it might better fit your needs 
if you decide to use IronPython.

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


Re: pySerial

2007-12-18 Thread John Machin
On Dec 19, 10:49 am, __zip__ <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using pySerial for communication with modem.
>
> Does anyone knows which values are for what in these variables?
>
> xonxoff=0
> rtscts=0
> dsrdtr=0
>
> if xonxoff=0 is it hardware control on or of (logic says it would be off
> , but who knows).

Disclaimer: It's a long time since I bit-bashed a UART ...

Where those relate to bits in the control registers, I'd expect 1 maps
to 1 and 0 maps to 0. Where they relate to functionality provided by
the software, I'd expect 1 to mean "do it" and 0 to mean "don't do
it". Do you have any reason for assuming otherwise?

>
> Second question is: do I need to send \n or soemthing when I use write().

That depends on what the modem is expecting.

>
> I would like to do:
>
> ser.write("AT")
> print ser.readline()
>
> and get "OK".

And what did you get"?

>
> Am I doing soemthing wrong?

Probably what you are doing wrong is not reading the docs.
http://pyserial.sourceforge.net/
"""Be carefully when using "readline". Do specify a timeout when
opening the serial port otherwise it could block forever if no newline
character is received. Also note that "readlines" only works with a
timeout. "readlines" depends on having a timeout and interprets that
as EOF (end of file). It raises an exception if the port is not opened
correctly.
"""

When you have a problem, show all the code (including the opening and
configuring of the port) and tell us what did happen with that code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Sam
On Dec 18, 7:09 pm, Jonathan Gardner
<[EMAIL PROTECTED]> wrote:
> On Dec 18, 2:16 pm, Sam <[EMAIL PROTECTED]> wrote:
>
>
>
> > layouts = ['column', 'form', 'frame']
> > cmds.window(t='gwfUI Builder')
> > cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
> > 100)))
> > cmds.paneLayout(configuration='horizontal2')
> > cmds.frameLayout(l='Layouts')
> > cmds.scrollLayout(cr=True)
> > cmds.columnLayout(adj=True, cat=('both', 2))
> > for i in layouts:
> > cmds.button(l=i)
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.showWindow()
>
> While Grant is pulling his hair out and yelling obscenities at the
> moon, let me try to explain why you'd never want to indent code that
> way, let alone write code that way.
>
> In cases where you have to run a sequence of code in a nested way,
> like this, it's best to create functions and then nest the functions.
> Of course, I'm thinking more of a lisp solution and less of a C one.
>
> In this case, you're going to have to have objects (or data
> structures) that know what to do to execute the commands necessary.
> When you get them all assembled, you simply run them in a recursive
> way.
>
> For instance:
>
>   cmd.build(('pane', dict(configuration='horizontal'), ('frame',
> dict(l='Layouts'), (
>
> You can indent these arbitrarily. Plus, you don't have to worry too
> much about matching setParent and the other commands.

That makes sense to me.  The library that was being used in that
example didn't strike me as very Pythonic (what with the using one
command object for everything and calling setParent('..') to point to
the next object up in the hierarchy).  But there's no reason (as far
as I know) that he couldn't create helper functions to wrap that with
something more sane.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Sam
On Dec 18, 5:28 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-12-18, Sam <[EMAIL PROTECTED]> wrote:
>
>
>
> > A friend of mine is picking up some Python and is frustrated by
> > Python's indentation rules (http://greatbiggary.livejournal.com/
> > 260460.html?thread=1835884#t1835884).  Personally, I've never had any
> > issues with Python's ways of indentation, but that conversation got me
> > thinking about the issue.
>
> > Consider the following indentation rules:
> > 1. Blocks begin with a line ending in ":"
> > 2. A line on the same indentation level or lower ends a block.
>
> > Under those rules, this would work:
> > layouts = ['column', 'form', 'frame']
> > cmds.window(t='gwfUI Builder')
> > cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
> > 100)))
> > cmds.paneLayout(configuration='horizontal2')
> > cmds.frameLayout(l='Layouts')
> > cmds.scrollLayout(cr=True)
> > cmds.columnLayout(adj=True, cat=('both', 2))
> > for i in layouts:
> >cmds.button(l=i)
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.setParent('..')
> > cmds.showWindow()
>
> And you think that example is an argument in _favor_ of what
> you propose?
>
> > Do such rules make sense?
>
> IMO, no.
>
> > Is there any way to make code work that way in Python?
>
> no.
>
> > Should there be?
>
> God no.
>
> Code should work the way it looks and look the way it works.
> Changing the language in order to allow authors to mislead
> readers is a bad thing.
>
> > Does that make this sort of code more or less readable?
>
> You must be joking.
>
> --
> Grant Edwards   grante Yow! I joined scientology
>   at   at a garage sale!!
>visi.com

Well, using tabs to lay out GUI elements in a hierarchy is something
I've seen before in other programming languages, so it seems that
_some_ people would find that more readable.  Admittedly, I don't find
the oddly tabbed code easier to read (it strikes me as about the same
level of readability).  The code provided as an example of some non-
Python language being "more readable" (also in the post I linked to)
struck me as far less readable, but I assumed that was only because I
didn't know the language in question.

The question that interests me more is how much power Python
programmers have to alter how the compiler deals with indentation and
so on (within Python, without altering the source code of the compiler
itself or something like that).  I couldn't find anything that
indicated that such power exists, but I'm still relatively new to
Python, so I thought that someone on CLP might have a more decisive
answer.

Anyways, thanks for your reply.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Jonathan Gardner
On Dec 18, 2:16 pm, Sam <[EMAIL PROTECTED]> wrote:
> layouts = ['column', 'form', 'frame']
> cmds.window(t='gwfUI Builder')
> cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
> 100)))
> cmds.paneLayout(configuration='horizontal2')
> cmds.frameLayout(l='Layouts')
> cmds.scrollLayout(cr=True)
> cmds.columnLayout(adj=True, cat=('both', 2))
> for i in layouts:
> cmds.button(l=i)
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.showWindow()
>

While Grant is pulling his hair out and yelling obscenities at the
moon, let me try to explain why you'd never want to indent code that
way, let alone write code that way.

In cases where you have to run a sequence of code in a nested way,
like this, it's best to create functions and then nest the functions.
Of course, I'm thinking more of a lisp solution and less of a C one.

In this case, you're going to have to have objects (or data
structures) that know what to do to execute the commands necessary.
When you get them all assembled, you simply run them in a recursive
way.

For instance:

  cmd.build(('pane', dict(configuration='horizontal'), ('frame',
dict(l='Layouts'), (

You can indent these arbitrarily. Plus, you don't have to worry too
much about matching setParent and the other commands.
-- 
http://mail.python.org/mailman/listinfo/python-list


Crunchy release 0.9.8.6

2007-12-18 Thread André
Crunchy is an application that transforms static (text based) Python
tutorials into interactive Python sessions within your browser.
Since the last announcement on this list, there has been 6 new
releases.

The latest release can always be found at http://code.google.com/p/crunchy/

New in 0.9.8.6: If docutils is installed, Crunchy can process
reStructuredText (.rst) files the same as if they were plain html
files.
New in 0.9.8.5: Crunchy can make use of any installed Python version
(including 3.0a1) to launch external applications.
New in 0.9.8.4: Crunchy messages to users available in Italian,
Polish, Macedonian, Brazilian Portuguese, German, Hungarian, Spanish,
Estonian, French and English.

Note that the the bulk of the improvements in the last three releases
is due to the work of many students that participated in Google's
Highly Open Participation contest.

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


pySerial

2007-12-18 Thread __zip__
Hi,

I am using pySerial for communication with modem.

Does anyone knows which values are for what in these variables?

xonxoff=0
rtscts=0
dsrdtr=0

if xonxoff=0 is it hardware control on or of (logic says it would be off 
, but who knows).


Second question is: do I need to send \n or soemthing when I use write().

I would like to do:

ser.write("AT")
print ser.readline()

and get "OK".

Am I doing soemthing wrong?

tnx in advance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to protect my new commercial software.

2007-12-18 Thread Paul Boddie
On 18 Des, 22:38, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
>
> I dare say that European countries which have had automatic copyright
> longer than the US have seen far more of their national heritage (early
> film, photographs and the like) rot away.

Indeed. One of the most famous and ridiculous cases is that of the
Domesday Project: a nationwide survey of Britain in the spirit of the
Domesday Book (which was 900 years old at the time of the endeavour),
where the newly gathered, late twentieth century information was in
danger of becoming unrecoverable due to the scarcity of parts for, and
knowledge about, the technology employed (now just over 20 years old).
This site provides an overview of the recovery process and information
about the history of the project:

http://www.si.umich.edu/CAMILEON/domesday/domesday.html

Although other technical discussions and perspectives have been
published about the project [1,2], the most pertinent issue to this
particular discussion is mentioned here:

"Many different copyright owners contributed a range of different
types of data to the Domesday Project for inclusion on the discs.
Unfortunately it is unclear as to exactly who contributed and under
what circumstances the data in question can be used."

http://www.si.umich.edu/CAMILEON/domesday/ipr.html

In many ways, those acting to preserve the contents of the Domesday
Project were able to act with some pretty large organisations watching
their backs. Others may not be as fortunate, as was pointed out.

Paul

P.S. Steven's post is indeed highly informative reading for those
willing to consider more thoroughly the nature and impact of
copyright.

[1] http://www.atsf.co.uk/dottext/domesday.html
[2] http://www.ariadne.ac.uk/issue36/tna/
-- 
http://mail.python.org/mailman/listinfo/python-list


[search for reviewers] asyncore delayed calls feature

2007-12-18 Thread Giampaolo Rodola'
Hi,
I post this message here in the hope someone using asyncore could
review
this.
Since the thing I miss mostly in asyncore is a system for calling a
function after a certain amount of time, I spent the last 3 days
trying
to implement this with the hopes that this could be included in
asyncore
in the the future.
The logic consists in calling a certain function (the "scheduler") at
every loop to check if it is the proper time to call one or more
scheduled functions.
Such functions are scheduled by the new delayed_call class which is
very
similar to the DelayedCall class defined in /twisted/internet/base.py
I
drew on.
It provides a basic API which can be used for setting, resetting and
canceling the scheduled functions.
For better performance I used an heap queue structure. This way the
scheduler() only needs to check the scheduled functions due to expire
soonest.
diff file and modified asyncore.py can be found here:
http://bugs.python.org/issue1641

The following code sample implements an idle-timeout capability using
the attached modified asyncore library.

--- code snippet ---
import asyncore, asynchat, socket

class foo(asynchat.async_chat):

   def __init__(self, conn=None):
   asynchat.async_chat.__init__(self, conn)
   self.set_terminator(None)
   self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
   self.connect(('127.0.0.1', 21))
   self.scheduled_timeout = self.call_later(120,
self.handle_timeout)

   def collect_incoming_data(self, data):
   self.scheduled_timeout.reset()
   # do something with the data...

   def handle_timeout(self):
   self.push("500 Connection timed out.\r\n")
   self.close_when_done()

   def close(self):
   if not self.scheduled_timeout.cancelled:
   self.scheduled_timeout.cancel()
   asyncore.dispatcher.close(self)

foo()
asyncore.loop()
--- /code snippet ---


Today I played a little more with it and I tried to add bandwidth
throttling capabilities to the base asynchat.py.
The code could be surely improved but it's just an example to show
another useful feature which wouldn't be possible to implement without
having a "call_later" function under the hood:


--- code snippet ---
class throttled_async_chat(asynchat.async_chat):
# maximum number of bytes to transmit in a second (0 == no limit)
read_limit = 100 * 1024
write_limit = 100 * 1024

# smaller the buffers, the less bursty and smoother the throughput
ac_in_buffer_size = 2048
ac_out_buffer_size  = 2048

def __init__(self, conn=None):
asynchat.async_chat.__init__(self, conn)
self.read_this_second = 0
self.written_this_second = 0
self.r_timenext = 0
self.w_timenext = 0
self.r_sleep = False
self.w_sleep = False
self.delayed_r = None
self.delayed_w = None

def readable(self):
return asynchat.async_chat.readable(self) and not self.r_sleep

def writable(self):
return asynchat.async_chat.writable(self) and not self.w_sleep

def recv(self, buffer_size):
chunk = asyncore.dispatcher.recv(self, buffer_size)
if self.read_limit:
self.read_this_second += len(chunk)
self.throttle_read()
return chunk

def send(self, data):
num_sent = asyncore.dispatcher.send(self, data)
if self.write_limit:
self.written_this_second += num_sent
self.throttle_write()
return num_sent

def throttle_read(self):
if self.read_this_second >= self.read_limit:
self.read_this_second = 0
now = time.time()
sleepfor = self.r_timenext - now
if sleepfor > 0:
# we've passed bandwidth limits
self.r_sleep = True
def unthrottle():
self.r_sleep = False
self.delayed_r = self.call_later((sleepfor * 2),
unthrottle)
self.r_timenext = now + 1

def throttle_write(self):
if self.written_this_second >= self.write_limit:
self.written_this_second = 0
now = time.time()
sleepfor = self.w_timenext - now
if sleepfor > 0:
# we've passed bandwidth limits
self.w_sleep = True
def unthrottle():
self.w_sleep = False
self.delayed_w = self.call_later((sleepfor * 2),
unthrottle)
self.w_timenext = now + 1

def close(self):
if self.delayed_r and not self.delayed_r.cancelled:
self.delayed_r.cancel()
if self.delayed_w and not self.delayed_w.cancelled:
self.delayed_w.cancel()
asyncore.dispatcher.close(self)
--- /code snippet ---


I don't know if there's a better way to implement this "call_later"
feature.
Maybe someone experienced with Twisted could provide a better
approach.
I would ask someone using asyncore to review this since, IMHO, it
would
fill a very big 

Re: Strict mode?

2007-12-18 Thread Larry Bates
Jack wrote:
> While enjoying the dynamic feature of Python I find it difficult to refactor 
> code without breaking it. For example, if I modify a function to take more 
> arguments, or arguments of different types, I'll need to manually find out 
> all places where the function is called and make sure I modify them all, 
> unlike in C/Java, where the compiler will do the work of checking function 
> signatures, etc. I suppose there isn't a strict mode in Python. It would be 
> helpful though, when I don't need things to be so dynamic, and this is often 
> the case, when it comes to function arguments and return values, for 
> example. Even a module level or function level flag would be very helpful to 
> find broken code. Or, are there any third party tools that do this? 
> 
> 

 > if I modify a function to take more
 > arguments, or arguments of different types, I'll need to manually find out
 > all places where the function is called and make sure I modify them all

This is not necessarily true.  I add keyword arguments to functions quite 
commonly and they don't affect any of the previously defined calls.  If I do, a 
good editor with search/replace seems to do the trick.  I find it quite 
uncommon 
to change the "types" of arguments, but when I do, I can use duck typing to 
work 
around that as well.  Hang in there, you will get it.

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


Re: Changing intobject to use int rather than long

2007-12-18 Thread Martin v. Löwis
>> On a 64-bit machine, that's 16 bytes for PyObject_HEAD and 8 more 
>> bytes for the value, 24 bytes total.  Changing long to int won't 
>> decrease the struct size to 20 because the compiler will pad it to
>> 24, the nearest multiple of 8.  (Forcing the compiler to pack the
>> struct won't help because malloc will still pad it for you.)
> 
> That's an excellent point. And true, too. Thanks, that will lay the 
> issue to rest.

As a side observation, notice how the increase in memory consumption
does not primarily originate from the increase in the size of a long.
Instead, all pointers double their sizes. In an OO language (like
Python), you have lots of pointers, so you will often find that the
application uses more memory when run in 64-bit mode.

If that is a concern to you, let me rephrase Terry's observation:
just try running a 32-bit Python interpreter on your 64-bit system,
and you may find that it actually runs better because it uses less
memory.

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


Re: It's ok to __slots__ for what they were intended (was: Don't use __slots__ (was Re: Why custom objects take so much memory?))

2007-12-18 Thread Carl Banks
On Dec 18, 4:49 pm, [EMAIL PROTECTED] (Aahz) wrote:
> In article <[EMAIL PROTECTED]>,
>
> Chris Mellon <[EMAIL PROTECTED]> wrote:
>
> >You can reduce the size of new-style classes (inherit from object) by
> >quite a bit if you use __slots__ to eliminate the class dictionary.
>
> You can also reduce your functionality quite a bit by using __slots__.
> Someday I'll have time to write up a proper page about why you shouldn't
> use __slots__

Shouting absolute commands without full understanding of the situation
is not going to help anyone.

The OP wanted to minimize memory usage, exactly the intended usage of
slots.  Without knowing more about the OP's situation, I don't think
your or I or Chris Mellon can be sure it's not right for the OP's
situation.

You're obviously smart and highly expert in Python--I just wish you
would be more constructive with your advice.


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


Re: IronPython faster than CPython?

2007-12-18 Thread Mark Shroyer
In article <[EMAIL PROTECTED]>,
 "Jack" <[EMAIL PROTECTED]> wrote:

> I learned a lot from the other thread 'Is a "real" C-Python possible?' about 
> Python performance and optimization. I'm almost convinced that Python's 
> performance is pretty good for this dynamic language although there are 
> areas to improve, until I read some articles that say IronPython is a few 
> times faster. I find it amazing that something that's written in C and runs 
> on hardware is slower than a .NET app that runs on CLR as managed code:
> 
> http://www.python.org/~jeremy/weblog/031209a.html
> http://blogs.msdn.com/jasonmatusow/archive/2005/03/28/402940.aspx 

You might argue that Python programs executed using CPython "run on 
hardware" to a *lesser* extent than they do when run in IronPython.  In 
either case, your program is parsed and compiled into bytecode (Python 
bytecode or MSIL), then loaded by the Python virtual machine or the .NET 
VM, respectively.  But whereas the Python VM is a bytecode interpreter, 
the .NET VM, like Java, uses just-in-time compilation to translate MSIL 
bytecode to optimized machine code for more efficient execution.  This 
is probably the most important factor in the performance difference 
demonstrated in the above links.

The fact that the IronPython compiler is written in C# and therefore 
runs from the VM, whereas the CPython compiler is compiled straight to 
machine code, is unimportant.  Even if a significant performance 
difference did result from this, keep in mind that the bulk of the 
execution time of any Python app worth profiling is going to be after 
this initial Python-to-bytecode compilation, during the execution of the 
program's bytecode itself.

-- 
Mark Shroyer
http://markshroyer.com/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie observations

2007-12-18 Thread Rick Dooling
On Dec 18, 2:14 pm, [EMAIL PROTECTED] wrote:

> But where? Look it up in the function reference. OK,
> where's the function reference? A line of code that you'd type in a
> second is a ten-minute search. Thank God for google.

Maybe this will help:

http://rgruet.free.fr/PQR25/PQR2.5.html

But since you're already a programmer, you really should take an hour
and read the tutorial. It was written for people like you.

rd

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


build a syntax tree

2007-12-18 Thread Federico
Hi I've some trivial question:

for exercise I want to parse a string that like this:

"x -34 + 65 * 96 = 102"

now if I had this ("(25+24)/2") is extremely easy to have a result but
I want to resolve the above string (for the 'x' variable) what can I
do?

Especially for symbolic function  I think that I've to build an
'operations tree' with a variable table.
I want to  know how Derive parse this kind of string.

If I've to build a tree, please give me resources and/or examples of
what physically is a tree and how to build on python.

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


Re: IronPython faster than CPython?

2007-12-18 Thread John Machin
On Dec 19, 9:18 am, "Jack" <[EMAIL PROTECTED]> wrote:
> I learned a lot from the other thread 'Is a "real" C-Python possible?' about
> Python performance and optimization. I'm almost convinced that Python's
> performance is pretty good for this dynamic language although there are
> areas to improve, until I read some articles that say IronPython is a few
> times faster. I find it amazing that something that's written in C and runs
> on hardware is slower than a .NET app that runs on CLR as managed code:
>
> http://www.python.org/~jeremy/weblog/031209a.html

Four years old. IP 0.1 vs CP 2.3. Sheesh.

> http://blogs.msdn.com/jasonmatusow/archive/2005/03/28/402940.aspx

Close to 3 years old but somewhat more meaningful ...

"""IronPython 0.7 is up to 1.8x faster than Python-2.4 on the standard
pystone benchmark. The key to IronPython's performance is that it
compiles Python code to .NET Intermediary Language which is then
translated to optimized machine code by the runtime."""

Where did you get "a few times faster" from?
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Don't use __slots__ (was Re: Why custom objects take so much memory?)

2007-12-18 Thread Delaney, Timothy (Tim)
Aahz wrote:

> In article <[EMAIL PROTECTED]>,
> Chris Mellon <[EMAIL PROTECTED]> wrote:
>> 
>> You can reduce the size of new-style classes (inherit from object) by
>> quite a bit if you use __slots__ to eliminate the class dictionary.
> 
> You can also reduce your functionality quite a bit by using __slots__.
> Someday I'll have time to write up a proper page about why you
> shouldn't use __slots__

Although admittedly this *is* one of the cases where __slots__ is being
suggested for it's intended use - where memory issues require smaller
objects.

Of course, a better result can probably be achieved by using a different
algorithm or technology (database?).

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


Re: Allowing Arbitrary Indentation in Python

2007-12-18 Thread Grant Edwards
On 2007-12-18, Sam <[EMAIL PROTECTED]> wrote:

> A friend of mine is picking up some Python and is frustrated by
> Python's indentation rules (http://greatbiggary.livejournal.com/
> 260460.html?thread=1835884#t1835884).  Personally, I've never had any
> issues with Python's ways of indentation, but that conversation got me
> thinking about the issue.
>
> Consider the following indentation rules:
> 1. Blocks begin with a line ending in ":"
> 2. A line on the same indentation level or lower ends a block.
>
> Under those rules, this would work:
> layouts = ['column', 'form', 'frame']
> cmds.window(t='gwfUI Builder')
> cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
> 100)))
> cmds.paneLayout(configuration='horizontal2')
> cmds.frameLayout(l='Layouts')
> cmds.scrollLayout(cr=True)
> cmds.columnLayout(adj=True, cat=('both', 2))
> for i in layouts:
>   cmds.button(l=i)
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.setParent('..')
> cmds.showWindow()

And you think that example is an argument in _favor_ of what
you propose?

> Do such rules make sense?

IMO, no.

> Is there any way to make code work that way in Python?

no.

> Should there be?

God no.

Code should work the way it looks and look the way it works.
Changing the language in order to allow authors to mislead
readers is a bad thing.

> Does that make this sort of code more or less readable?

You must be joking.

-- 
Grant Edwards   grante Yow! I joined scientology
  at   at a garage sale!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strict mode?

2007-12-18 Thread John Machin
On Dec 19, 9:03 am, "Jack" <[EMAIL PROTECTED]> wrote:
> While enjoying the dynamic feature of Python I find it difficult to refactor
> code without breaking it. For example, if I modify a function to take more
> arguments, or arguments of different types, I'll need to manually find out
> all places where the function is called and make sure I modify them all,
> unlike in C/Java, where the compiler will do the work of checking function
> signatures, etc.

This specific problem can be addressed at least partially by setting
reasonable defaults for new arguments. This is a necessary technique
when the publisher of a language or a module/package wants to extend
the functionality of a function or method without introducing a new
name for the function/method.

The general problem is usually addressed in dynamic languages by
running a test suite.
-- 
http://mail.python.org/mailman/listinfo/python-list


IronPython faster than CPython?

2007-12-18 Thread Jack
I learned a lot from the other thread 'Is a "real" C-Python possible?' about 
Python performance and optimization. I'm almost convinced that Python's 
performance is pretty good for this dynamic language although there are 
areas to improve, until I read some articles that say IronPython is a few 
times faster. I find it amazing that something that's written in C and runs 
on hardware is slower than a .NET app that runs on CLR as managed code:

http://www.python.org/~jeremy/weblog/031209a.html
http://blogs.msdn.com/jasonmatusow/archive/2005/03/28/402940.aspx 


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


Allowing Arbitrary Indentation in Python

2007-12-18 Thread Sam
A friend of mine is picking up some Python and is frustrated by
Python's indentation rules (http://greatbiggary.livejournal.com/
260460.html?thread=1835884#t1835884).  Personally, I've never had any
issues with Python's ways of indentation, but that conversation got me
thinking about the issue.

Consider the following indentation rules:
1. Blocks begin with a line ending in ":"
2. A line on the same indentation level or lower ends a block.

Under those rules, this would work:
layouts = ['column', 'form', 'frame']
cmds.window(t='gwfUI Builder')
cmds.paneLayout(configuration='vertical3', ps=((1, 25, 100), (3, 20,
100)))
cmds.paneLayout(configuration='horizontal2')
cmds.frameLayout(l='Layouts')
cmds.scrollLayout(cr=True)
cmds.columnLayout(adj=True, cat=('both', 2))
for i in layouts:
cmds.button(l=i)
cmds.setParent('..')
cmds.setParent('..')
cmds.setParent('..')
cmds.setParent('..')
cmds.setParent('..')
cmds.showWindow()

Do such rules make sense?  Is there any way to make code work that way
in Python?  Should there be?  Does that make this sort of code more or
less readable?

P.S. I'm definitely not looking for a tabs vs. spaces flamewar here.
That's a different issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Strict mode?

2007-12-18 Thread Jack
While enjoying the dynamic feature of Python I find it difficult to refactor 
code without breaking it. For example, if I modify a function to take more 
arguments, or arguments of different types, I'll need to manually find out 
all places where the function is called and make sure I modify them all, 
unlike in C/Java, where the compiler will do the work of checking function 
signatures, etc. I suppose there isn't a strict mode in Python. It would be 
helpful though, when I don't need things to be so dynamic, and this is often 
the case, when it comes to function arguments and return values, for 
example. Even a module level or function level flag would be very helpful to 
find broken code. Or, are there any third party tools that do this? 


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


Re: Funny python cartoon... hope it's not a repost

2007-12-18 Thread Ben Finney
Breal <[EMAIL PROTECTED]> writes:

> http://xkcd.com/353/

Instead of *hoping* it's not a repost, please search the group
archives *before* posting.

-- 
 \ "I'm beginning to think that life is just one long Yoko Ono |
  `\   album; no rhyme or reason, just a lot of incoherent shrieks and |
_o__)   then it's over."  -- Ian Wolff |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to protect my new commercial software.

2007-12-18 Thread Grant Edwards
On 2007-12-18, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Tue, 18 Dec 2007 17:04:29 +, Grant Edwards wrote:
>
>> On 2007-12-18, Jan Claeys <[EMAIL PROTECTED]> wrote:
>>> Op Fri, 14 Dec 2007 16:54:35 +, schreef Grant Edwards:
>>>
 Uh what?  I don't know what country you're in, but in the US, it
 doesn't take any time at all to copyright something.  The mere act of
 writing something copyrights it.  I thought it was the same in Europe
 as well.
>>>
>>> No, it's only copyrighted when you _publish_ it.
>> 
>> Interesting.  So, in Europe, if somebody steals something you wrote
>> before you get it published, they're free to do with it as they please?
>
> Please do not conflate theft and copyright infringement, or theft and 
> plagiarism.

I wasn't.  If I write something down and somebody steals that
paper, that's theft.

> They are very different concepts, and confusing them does not 
> help.

Sorry if I was unclear.  The "stealing" was of the medium
containing the authored work.

-- 
Grant Edwards   grante Yow! Used staples are good
  at   with SOY SAUCE!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Don't use __slots__ (was Re: Why custom objects take so much memory?)

2007-12-18 Thread Aahz
In article <[EMAIL PROTECTED]>,
Chris Mellon <[EMAIL PROTECTED]> wrote:
>
>You can reduce the size of new-style classes (inherit from object) by
>quite a bit if you use __slots__ to eliminate the class dictionary.

You can also reduce your functionality quite a bit by using __slots__.
Someday I'll have time to write up a proper page about why you shouldn't
use __slots__
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Typing is cheap.  Thinking is expensive."  --Roy Smith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to protect my new commercial software.

2007-12-18 Thread Steven D'Aprano
On Tue, 18 Dec 2007 17:04:29 +, Grant Edwards wrote:

> On 2007-12-18, Jan Claeys <[EMAIL PROTECTED]> wrote:
>> Op Fri, 14 Dec 2007 16:54:35 +, schreef Grant Edwards:
>>
>>> Uh what?  I don't know what country you're in, but in the US, it
>>> doesn't take any time at all to copyright something.  The mere act of
>>> writing something copyrights it.  I thought it was the same in Europe
>>> as well.
>>
>> No, it's only copyrighted when you _publish_ it.
> 
> Interesting.  So, in Europe, if somebody steals something you wrote
> before you get it published, they're free to do with it as they please?

Please do not conflate theft and copyright infringement, or theft and 
plagiarism. They are very different concepts, and confusing them does not 
help.


> I'm glad it doesn't work that way here in the US.  Over here, something
> is copyrighted as soon as it's written (actually I think the phrase is
> "fixed in a medium" or something like that).

I'm not glad at all. The Change from an "everything is uncopyrighted 
unless explicitly copyrighted" model to a "everything is copyrighted 
unless explicitly exempted" model was only one of many deleterious 
changes to copyright law over the last half century or so.

It means the merest throw-away scribble on a napkin has equal protection 
to the opus an author slaved over for thirty years (although in fairness 
you are unlikely to win a copyright case over the words "Meet me at the 
bar" scribbled on a napkin then tossed in a rubbish bin... *wink*). It 
means that there is a serious problem of "orphan works", where rare and 
valuable films from the 1920s and earlier are rapidly decaying into an 
unusable powder because nobody dares copy them lest the unknown copyright 
owners descend like vultures and sue you for copyright infringement 
*after* you've done the hard work of restoring our cultural heritage.

(Although the orphan works problem is at least equally as much a problem 
of excessively long copyrights as it is to do with automatic copyright.)

I dare say that European countries which have had automatic copyright 
longer than the US have seen far more of their national heritage (early 
film, photographs and the like) rot away.

Discussions of copyright so often focus on protecting the author's 
privileges and ignore the opportunity costs of locking up works. When 
works needed to be explicitly copyrighted, something of the order of just 
ONE PERCENT of authors bothered to copyright their published works -- and 
just one percent of them bothered to renew it for a second 14 year term. 
That gives you an idea of how valuable copyright really is. For every 
Mickey Mouse, there are 100,000 or more works that don't have enough 
economic value to the creator to bother protecting -- but they're part of 
our cultural heritage, and maybe somebody else could build on top of it, 
like Disney built their empire on other folks' uncopyrighted stories and 
ideas. Even Mickey Mouse himself got his start in a derivative work of 
Buster Keaton's Steamboat Bill Jr.

This newsgroup is a perfect example of the fraud that is the idea of 
copyright. Every single post sent to the newsgroup is copyrighted, and 
yet they invariable have no economic value to the author. If they have 
any economic value, it is to the readers -- but they don't pay for it, 
and we authors don't ask for payment. In principle, anyone who forwards 
on something they read here, or uses a code snippet in their own work, is 
infringing copyright. We don't need copyright to encourage us to create 
works of this nature, and in fact this newsgroup can only exist by 
pretending copyright doesn't exist -- there are informal conventions that 
unless somebody explicitly states otherwise, any reader can forward on 
posts, copy and reuse code, and so forth.

(Disclaimer: for the avoidance of all doubt, I'm not suggesting that ALL 
creative works should be uncopyrighted, or that no creative works benefit 
from the encouragement of copyright.)



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


Re: why only an msi-installer for windows ?

2007-12-18 Thread Gabriel Genellina
On 18 dic, 15:54, Stef Mientki <[EMAIL PROTECTED]> wrote:

> having a lot of trouble installing 2.5 (without affecting my stable 2.4),
> I wonder why there's only a msi installer for windows users ?

What's your problem? I have five versions installed (2.1, 2.3, 2.4,
2.5 and svn) and they coexist peacefully. Just make sure when
installing 2.5: a) use a different directory (obviously!) b) don't
associate .py extension with this new version.
Regarding the standard library, Python tries to locate it based on
where the executable (python.exe) resides, so this should not be a
problem. Better if you don't set a PYTHONPATH environment variable
(usually there is no need to do that; if required, you can extend the
search path using .pth files instead)

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


Re: Funny python cartoon... hope it's not a repost

2007-12-18 Thread Breal
On Dec 18, 11:56 am, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Breal a écrit :
>
> >http://xkcd.com/353/
>
> Bad luck: it *is* a repost.
>
> While we're at it, did you notice the alternate text for the image ?-)

Did not notice the alt text... friggin hilarious!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New+old-style multiple inheritance

2007-12-18 Thread [EMAIL PROTECTED]
Thank Gabriel,

That sounds exactly right and your work-around provides confirmation.
This code is an expedient solution for us so I expect we'll go with
forcing a slot update.  Hopefully the library concerned is going to
fix the problem in a future release.

Cheers,
Stephen.

On  Dec 18, 7:40 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> On 18 dic, 12:08, "[EMAIL PROTECTED]"
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > We are trying to monkey-patch a third-party library that mixes new and
> > old-style classes with multiple inheritance.  In so doing we have
> > uncovered some unexpected behaviour:
>
> > 
> > class Foo:
> > pass
>
> > class Bar(object):
> > pass
>
> > class Baz(Foo,Bar):
> > pass
>
> > # Monkey-patch Foo to add a special method
> > def my_nonzero(self):
> > print "my_nonzero called"
> > return False
> > Foo.__nonzero__ = my_nonzero
>
> > b = Baz()
>
> > print "doing the test on Baz(Foo,Bar).  Should return false"
> > if b:
> > print "true"
> > else:
> > print "false"
> > 
>
> > Produces this output:
>
> >   doing the test on Baz(Foo,Bar).  Should return false
> >   true
>
> > With some experimentation it is clear that this behaviour only occurs
> > when you combine new+old-style multiple inheritance, monkey-patching
> > and special methods.  If Foo and Bar are either old or new-style it
> > works.  calling b.__nonzero__() directly works.  Defining __nonzero__
> > within Foo works.
>
> > I know this level of messing with python internals is a bit risky but
> > I'm wondering why the above code doesn't work.
>
> I think I can barely explain what happens here (but I may be
> absolutely wrong! Please someone with greater knowledge of Python
> innards correct whatever is wrong on my description!)
>
> type objects contain "slots" (function pointers) corresponding to the
> "magic" methods like __nonzero__ (this one is stored into the
> nb_nonzero slot). new-style classes are types; old-style classes are
> not (they're all instances of classobj).
> The slots are populated when a new type is created (e.g., when
> creating a new-style class) and are updated when a magic attribute is
> set onto the type. By example, setting the __nonzero__ attribute on a
> new-style class updates the nb_nonzero slot. old-style classes just
> store the magic attribute in its __dict__. Note that if you patch Foo
> *before* defining Baz, it works fine, because Baz sees the magic
> attribute and can populate its nb_nonzero slot when the new type is
> created.
>
> When you define Baz, neither Foo nor Bar have a __nonzero__ at this
> time, so the nb_nonzero slot on Baz is empty.
> Later, when you alter Foo, Baz cannot notice it (Foo has no way to
> notify Baz that something changed).
>
> If Foo were a new-style class, things are different: new-style classes
> maintain a list of subclasses, and the subclasses can then be notified
> of changes. In particular, setting a magic attribute on a base class
> notifies all its subclasses, and the corresponding slots are updated.
>
> The problem seems to be exactly that: old-style base classes can't
> notify its derived new-style classes when magic methods are added, so
> the corresponding slots aren't updated. Always asking the base class
> whether it has a magic method or not would slow down all method
> lookups.
>
> To force a slot update:
>
> py> Baz.__nonzero__ = "xxx"
> py> del Baz.__nonzero__
> py> bool(b)
> my_nonzero called
> False
>
> (setting or deleting __nonzero__ triggers the slot update)
>
> This is *why* it happens. How to avoid this... well, don't do that in
> the first place :) Or try to patch the base class *before* the new-
> style derived class is defined. Or replace the derived class with a
> new version of itself (once the base was patched). Or, if you know all
> the derived classes, force a slot update on them as above.
>
> --
> Gabriel Genellina

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


Re: New+old-style multiple inheritance

2007-12-18 Thread [EMAIL PROTECTED]
On Dec 18, 8:25 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Dec 18, 2:09 pm, Jonathan Gardner
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > On Dec 18, 7:08 am, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > We are trying to monkey-patch a third-party library that mixes new and
> > > old-style classes with multiple inheritance.  In so doing we have
> > > uncovered some unexpected behaviour:
>
> > 
>
> > > I know this level of messing with python internals is a bit risky but
> > > I'm wondering why the above code doesn't work.
>
> > You've already discovered why--you're mixing old and new style
> > classes.
>
> > Monkey patching is definitely unpythonic. You must be a Ruby guy. Why
> > don't you try doing something else to get the behavior you want,
> > something more explicit?
>
> Time and place.
>
> A well-considered, timely monkey-patch can sometimes save all kinds of
> workarounds and other headaches.
>
> Carl Banks

Indeed, I chuckled at the idea I was a Ruby programmer.  Of course
it's a bit of a hack but monkey-patching has been common place in the
Zope world for years (maybe Zope3 has rid itself of the problem).

Agreed, mixing new and old-style classes in multiple inheritance is
asking for trouble (although the Guido's essay on the new-style
classes  suggests you can: 
http://www.python.org/download/releases/2.2.3/descrintro/#subclassing).
I won't name and shame the library involved but unfortunately we can't
always pick and choose the tools we work with unless we want to write
(or rewrite) everything ourselves.

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


Re: why only an msi-installer for windows ?

2007-12-18 Thread John Machin
On Dec 19, 7:11 am, Tim Couper <[EMAIL PROTECTED]> wrote:
> I think as msi is "The *Windows Installer* .. is an engine for the
> installation, maintenance, and removal of software on modern Microsoft
> Windows  systems" (from
> Wikipaedia)", it's clear it's a Windows product ... not sure that
> they're up for putting it on other operating systems .. but you may want
> to email Bill G and ask him ..
>

It all depends on context, none of which the OP has supplied, and how
much weight one can attach to the position of "only" in his sentence.

"only a msi installer for windows users" could mean "Python supplies
only an msi installer [no exe installer, as was the case for earlier
Python versions] for Windows users. This presents difficulties
installing Python 2.5 on antique versions of Windows".

If Tim's interpretation is correct, it would help greatly if the OP
would say explicitly what his platform is and what his real problem
is, instead of asking why a purported solution doesn't exist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rounding

2007-12-18 Thread John Machin
On Dec 19, 7:21 am, "Ron Provost" <[EMAIL PROTECTED]> wrote:
> Adding 0.5, then converting to an int always works for me.
>
> >>> x = 6.345
> >>> int( x + 0.5 )
> >>> 6

Always?

>>> x = -6.345
>>> int(x + 0.5)
-5
>>>

I therefore deduce that you have never crossed the equator :-)

Be careful, doing that can be dangerous:
http://catless.ncl.ac.uk/Risks/3.44.html#subj1.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another newbie design question

2007-12-18 Thread MartinRinehart
> My 2 cents...

Thanks for the feedback, Bruno. Seriously thinking about ditching the
block comments and adding multi-line strings. (Block comments are the
last item on my tokenizer's "todo" list. Multi-line strings would be
easier.)

Beginners will be programming fun things in a GUI environment. Think
games. Brightly colored bouncing balls. Remember Pong? That's a Decaf-
level program.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie observations

2007-12-18 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> First, it is absolutely horrible being a newbie. I'd forgot how bad it
> was. In addition to making a fool of yourself in public, you have to
> look up everything. I wanted to find a substring in a string. OK,
> Python's a serious computer language, so you know it's got a function
> to do this. But where? Look it up in the function reference. OK,
> where's the function reference? A line of code that you'd type in a
> second is a ten-minute search. Thank God for google.

If you're having trouble with some of Python's basic syntax (like 
slicing), you should go through the tutorial first:

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

It doesn't take too long, and you'll hit slicing by section 3.1.2.

> Second, would anyone mind if we tossed the semi-colon (which this
> newbie is forever forgetting)? I think the language is parsable
> without it.

What are you using them for?  They're only intended to separate two 
simple statements on the same line.  I always use one statement per 
line, so I never see semi-colons.  I highly recommend that you never use 
semi-colons either.

> Third, could our classes be a little more selfless? Or a lot more
> selfless? The Stroustrup's idea of having the compiler, not the
> programmer, worry about the self pointer was an excellent decision.
> What was van Rossum thinking?

http://www.python.org/doc/faq/general/#why-must-self-be-used-explicitly-in-method-definitions-and-calls
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New+old-style multiple inheritance

2007-12-18 Thread Carl Banks
On Dec 18, 2:09 pm, Jonathan Gardner
<[EMAIL PROTECTED]> wrote:
> On Dec 18, 7:08 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > We are trying to monkey-patch a third-party library that mixes new and
> > old-style classes with multiple inheritance.  In so doing we have
> > uncovered some unexpected behaviour:
>
> 
>
> > I know this level of messing with python internals is a bit risky but
> > I'm wondering why the above code doesn't work.
>
> You've already discovered why--you're mixing old and new style
> classes.
>
> Monkey patching is definitely unpythonic. You must be a Ruby guy. Why
> don't you try doing something else to get the behavior you want,
> something more explicit?

Time and place.

A well-considered, timely monkey-patch can sometimes save all kinds of
workarounds and other headaches.


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


Re: lotus nsf to mbox

2007-12-18 Thread Adam Lanier
On Tue, 2007-12-18 at 19:25 +, Fabian Braennstroem wrote:
> Hi to all,
> 
> thanks, I'll try your suggestions...
> 
> Regards!
> Fabian
> 
> Brian Munroe schrieb am 12/15/2007 07:10 PM:
> > Well, If you wish to go that route, I believe you will have to reverse
> > engineer the Notes Database binary structure because I've never seen
> > it published anywhere.  My suggestion, if you can use a Windows
> > machine, just use the Lotus Notes COM Objects via the Python Win32
> > bindings, as mentioned above.
> > 
> > If you really need to do it from Linux and are lucky enough to be
> > running the IIOP task on your Domino server, then you could possibly
> > use CORBA.

You could always enable the IMAP interface on the Domino machine and use
imaplib to retrieve the mail via IMAP.

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


Re: Newbie observations

2007-12-18 Thread John Machin
On Dec 19, 7:14 am, [EMAIL PROTECTED] wrote:
> Warning! Complaints coming.
>
> The good news is that 10-days of part-time Python coding has convinced
> me that I picked the right language. Now, observations.
>
> First, it is absolutely horrible being a newbie. I'd forgot how bad it
> was. In addition to making a fool of yourself in public,

[snip]

>
> Second, would anyone mind if we tossed the semi-colon (which this
> newbie is forever forgetting)? I think the language is parsable
> without it.

Do you mean colon?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why custom objects take so much memory?

2007-12-18 Thread Hrvoje Niksic
jsanshef <[EMAIL PROTECTED]> writes:

> That means every object is around 223 bytes in size That's too
> much considering it only contains a string with a maximum size of 7
> chars.

The list itself consumes 4 MB because it stores 1 million PyObject
pointers.  It possibly consumes more due to overallocation, but let's
ignore that.

Each object takes 36 bytes itself: 4 bytes refcount + 4 bytes type ptr
+ 4 bytes dict ptr + 4 bytes weakptr + 12 bytes gc overhead.  That's
not counting malloc overhead, which should be low since objects aren't
malloced individually.  Each object requires a dict, which consumes
additional 52 bytes of memory (40 bytes for the dict struct plus 12
for gc).  That's 88 bytes per object, not counting malloc overhead.

Then there's string allocation: your average string is 6 chars long;
add to that one additional char for the terminating zero.  The string
struct takes up 20 bytes + string length, rounded to nearest
alignment.  For your average case, that's 27 bytes, rounded (I assume) to 28.
You also allocate 1024*1024 integers which are never freed (they're
kept on a free list), and each of which takes up at least 12 bytes.

All that adds up to 128 bytes per object, dispersed over several
different object types.  It doesn't surprise me that Python is eating
200+ MB of memory.

> So, what's exactly going on behind the scenes? Why is using custom
> objects SO expensive? What other ways of creating structures can be
> used (cheaper in memory usage)?
>
> Thanks a lot in advance!

Use a new-style class and set __slots__:

class MyClass(object):
__slots__ = 'mystring',
def __init__(self, s):
self.mystring = s

That brings down memory consumption to ~80MB, by cutting down the size
of object instance and removing the dict.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New+old-style multiple inheritance

2007-12-18 Thread Carl Banks
On Dec 18, 10:08 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> We are trying to monkey-patch a third-party library that mixes new and
> old-style classes with multiple inheritance.

New library?  Geez, if people are dumb enough to do this, are you sure
you want your application to depend on their library?

Sometimes you have to work with code that's not up to your standards,
but come on.


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


Re: Rounding

2007-12-18 Thread Ron Provost
Adding 0.5, then converting to an int always works for me.

>>> x = 6.345
>>> int( x + 0.5 )
>>> 6

Ron


- Original Message - 
From: "katie smith" <[EMAIL PROTECTED]>
To: 
Sent: Saturday, December 15, 2007 9:09 AM
Subject: Rounding


> if i have a number 6.345 and i wanted it to be 6 without subtracting .345 
> because it won't always be .345 what do i do?
>
> how do i round to the nearest whole number. Or in this case round down. Is 
> there an easy way to round down to the nearest whole number?
>
>
> 
> 
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list 

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


Newbie observations

2007-12-18 Thread MartinRinehart
Warning! Complaints coming.

The good news is that 10-days of part-time Python coding has convinced
me that I picked the right language. Now, observations.

First, it is absolutely horrible being a newbie. I'd forgot how bad it
was. In addition to making a fool of yourself in public, you have to
look up everything. I wanted to find a substring in a string. OK,
Python's a serious computer language, so you know it's got a function
to do this. But where? Look it up in the function reference. OK,
where's the function reference? A line of code that you'd type in a
second is a ten-minute search. Thank God for google.

Second, would anyone mind if we tossed the semi-colon (which this
newbie is forever forgetting)? I think the language is parsable
without it.

Third, could our classes be a little more selfless? Or a lot more
selfless? The Stroustrup's idea of having the compiler, not the
programmer, worry about the self pointer was an excellent decision.
What was van Rossum thinking?

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


Re: Passing arguments to exe

2007-12-18 Thread kyosohma
On Dec 15, 6:46 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Fri, 14 Dec 2007 16:38:28 -0800 (PST), [EMAIL PROTECTED] declaimed
> the following in comp.lang.python:
>
> > The executable runs, but no argument appears to get passed into it. Of
> > course, I don't really know that for sure as the executable doesn't
> > redirect stdout/stderr. I tried doing something like this in the above
> > reg entry:
>
> > cmd /C "c:\program files\myProg.exe %1"
> > "c:\program files\myProg.exe %1"
> > "c:\program files\myProg.exe"
>
> What happens if you put the %1 OUTSIDE the quotes...
>
> cmd /c "c:\program files\myProg.exe" "%1"
>
> After all, if the quotes are being used to keep the command line seeing
> "program files" as a single term in the path, then your quotes are also
> treating "myProg.exe %1" as a single term.
> --
> WulfraedDennis Lee Bieber   KD6MOG
> [EMAIL PROTECTED] [EMAIL PROTECTED]
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff:   [EMAIL PROTECTED])
> HTTP://www.bestiaria.com/

This works:

"c:\program files\myProg.exe" %1

Thanks for the tip.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why custom objects take so much memory?

2007-12-18 Thread Chris Mellon
On Dec 18, 2007 1:26 PM, jsanshef <[EMAIL PROTECTED]> wrote:
> Hi,
>
> after a couple of days of script debugging, I kind of found that some
> assumptions I was doing about the memory complexity of my classes are
> not true. I decided to do a simple script to isolate the problem:
>
> class MyClass:
> def __init__(self,s):
> self.mystring  = s
>
> mylist = []
> for i in range(1024*1024):
> mylist.append(MyClass(str(i))) #allocation
> #stage 1
> mylist = None
> gc.collect()
> #stage 2
>
> I take measures of the memory consumption of the script at #stage1 and
> #stage 2 and I obtain:
> #stage1 -> 238MB
> #stage2 -> 15MB
>
> That means every object is around 223 bytes in size That's too
> much considering it only contains a string with a maximum size of 7
> chars.
>

Classes are fairly heavyweight - in your case you've got the size of
the PyObject struct, a dictionary for class attributes (which itself
is another pyobject), and the string object (yet another pyobject),
and the actual string data.

> If you change the allocation line for this other:
> >>mylist.append(str(i)) #we don't create the custom class, but append the 
> >>string directly into the list
>
> the numbers decrease substantially to:
> #stage1 -> 47.6MB
> #stage2 -> 15MB
> (so this time we can say string vars occupy around 32 bytesstill a
> lot, isn't it?)
>

string objects don't have dictionaries and are smaller than "regular"
python objects.

> So, what's exactly going on behind the scenes? Why is using custom
> objects SO expensive? What other ways of creating structures can be
> used (cheaper in memory usage)?
>

If you're worried about per-instance memory costs Python is probably
not the language for your purposes. On the other hand, odds are that
you actually don't need to worry so much.

You can reduce the size of new-style classes (inherit from object) by
quite a bit if you use __slots__ to eliminate the class dictionary.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why only an msi-installer for windows ?

2007-12-18 Thread Tim Couper
I think as msi is "The *Windows Installer* .. is an engine for the 
installation, maintenance, and removal of software on modern Microsoft 
Windows  systems" (from 
Wikipaedia)", it's clear it's a Windows product ... not sure that 
they're up for putting it on other operating systems .. but you may want 
to email Bill G and ask him ..

Tim

Stef Mientki wrote:
> hello,
>
> having a lot of trouble installing 2.5 (without affecting my stable 2.4),
> I wonder why there's only a msi installer for windows users ?
>
> thanks,
> Stef
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Funny python cartoon... hope it's not a repost

2007-12-18 Thread Bruno Desthuilliers
Breal a écrit :
> http://xkcd.com/353/

Bad luck: it *is* a repost.

While we're at it, did you notice the alternate text for the image ?-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another newbie design question

2007-12-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
(snip)
> I'd like to hear from people who use Python's multi-line strings other
> than in doc comments.

Then: do you hear me ?-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another newbie design question

2007-12-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> Fortran (1957) had line comments. C (1972) replaced these with non-
> nested block comments. C++ (1983) added here-to-EOL comments. Python
> (1991) keeps here-to-EOL comments but replaces block comments with
> multi-line quotes. Block comments and multi-line quotes both serve the
> same purpose as doc comments. Block comments, especially if they nest,
> are helpful for commenting out code. Multi-line quotes serve to add
> text.
> 
> Is Python, in this particular, an advance over C++?
> 
> I wrote a lot of Java (here-to-EOL and block comments) without ever
> feeling the need for multi-line quotes.

I wrote a lot of Java without ever feeling the need for things functions 
as objects, lexical closures, lazy evaluation, anonymous functions etc. 
Then I learned to use these features and couldn't stand coding in Java 
no more.

> I've written a little Perl and
> found multi-line quotes useful for responding to -help switches. On
> the other hand -help switches are very old-fashioned, a direction I'll
> not be pointing my tiny beginner's language.

"old-fashioned" ? Do you have something better to suggest ? Please keep 
in mind that most servers don't have GUIs (for obvious reasons).

But multiline strings are not only useful for "old-fashioned -help 
switches" - they are useful anywhere you need a quick and simple text 
templating system - be it html, javascript, SQL, whatever - and using a 
full blown templating system would be overkill. IOW, like a lot of other 
features, it's not that you cannot do without, but it really helps when 
it's available *and* braindead easy to setup and use.

My 2 cents...
-- 
http://mail.python.org/mailman/listinfo/python-list


Funny python cartoon... hope it's not a repost

2007-12-18 Thread Breal
http://xkcd.com/353/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New+old-style multiple inheritance

2007-12-18 Thread Gabriel Genellina
On 18 dic, 12:08, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> We are trying to monkey-patch a third-party library that mixes new and
> old-style classes with multiple inheritance.  In so doing we have
> uncovered some unexpected behaviour:
>
> 
> class Foo:
> pass
>
> class Bar(object):
> pass
>
> class Baz(Foo,Bar):
> pass
>
> # Monkey-patch Foo to add a special method
> def my_nonzero(self):
> print "my_nonzero called"
> return False
> Foo.__nonzero__ = my_nonzero
>
> b = Baz()
>
> print "doing the test on Baz(Foo,Bar).  Should return false"
> if b:
> print "true"
> else:
> print "false"
> 
>
> Produces this output:
>
>   doing the test on Baz(Foo,Bar).  Should return false
>   true
>
> With some experimentation it is clear that this behaviour only occurs
> when you combine new+old-style multiple inheritance, monkey-patching
> and special methods.  If Foo and Bar are either old or new-style it
> works.  calling b.__nonzero__() directly works.  Defining __nonzero__
> within Foo works.
>
> I know this level of messing with python internals is a bit risky but
> I'm wondering why the above code doesn't work.

I think I can barely explain what happens here (but I may be
absolutely wrong! Please someone with greater knowledge of Python
innards correct whatever is wrong on my description!)

type objects contain "slots" (function pointers) corresponding to the
"magic" methods like __nonzero__ (this one is stored into the
nb_nonzero slot). new-style classes are types; old-style classes are
not (they're all instances of classobj).
The slots are populated when a new type is created (e.g., when
creating a new-style class) and are updated when a magic attribute is
set onto the type. By example, setting the __nonzero__ attribute on a
new-style class updates the nb_nonzero slot. old-style classes just
store the magic attribute in its __dict__. Note that if you patch Foo
*before* defining Baz, it works fine, because Baz sees the magic
attribute and can populate its nb_nonzero slot when the new type is
created.

When you define Baz, neither Foo nor Bar have a __nonzero__ at this
time, so the nb_nonzero slot on Baz is empty.
Later, when you alter Foo, Baz cannot notice it (Foo has no way to
notify Baz that something changed).

If Foo were a new-style class, things are different: new-style classes
maintain a list of subclasses, and the subclasses can then be notified
of changes. In particular, setting a magic attribute on a base class
notifies all its subclasses, and the corresponding slots are updated.

The problem seems to be exactly that: old-style base classes can't
notify its derived new-style classes when magic methods are added, so
the corresponding slots aren't updated. Always asking the base class
whether it has a magic method or not would slow down all method
lookups.

To force a slot update:

py> Baz.__nonzero__ = "xxx"
py> del Baz.__nonzero__
py> bool(b)
my_nonzero called
False

(setting or deleting __nonzero__ triggers the slot update)

This is *why* it happens. How to avoid this... well, don't do that in
the first place :) Or try to patch the base class *before* the new-
style derived class is defined. Or replace the derived class with a
new version of itself (once the base was patched). Or, if you know all
the derived classes, force a slot update on them as above.

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


Re: is it possible to install 2 Python versions on windows XP ?

2007-12-18 Thread Stef Mientki
I finally found a way to let everything work:


My base system is a stable Scipy installation, based on Python 2.4,
with a few extra or updated libraries.
This Python installation is completed with RPYC and PyScripter,
to form a good workplace to develop GUI through wxPython.

Installing of a working Python 2.5 version is done in the following way:
- get a winXP system on which Python is not necessary
- install on that PC Python 2.5
- copy from windows\system32\Python25.dll
   to  the root where you installed Python 2.5
- now you can move the newly created root map to any place you like
- place a shortcut to python.exe on your desktop
- drop any file you like to run in Python 2.5 on the shortcut

Seems to work like a charm.
But maybe there might be better ways.

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


Re: Changing intobject to use int rather than long

2007-12-18 Thread Terry Reedy

"Clarence" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| That's an excellent point. And true, too. Thanks, that will lay the
| issue to rest.

Good idea.  I think people who moved to 64 bits to get 64 bits would be 
upset if they did not ;-).





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


Re: checking a string against multiple patterns

2007-12-18 Thread Jonathan Gardner
On Dec 18, 4:41 am, tomasz <[EMAIL PROTECTED]> wrote:
> Is there an alternative to it? Am I missing something? Python doesn't
> have special variables $1, $2 (right?) so you must assign the result
> of a match to a variable, to be able to access the groups.
>
> I'd appreciate any hints.
>

Don't use regexes for something as simple as this. Try find().

Most of the time I use regexes in perl (90%+) I am doing something
that can be done much better using the string methods and some simple
operations. Plus, it turns out to be faster than perl usually.
-- 
http://mail.python.org/mailman/listinfo/python-list


Why custom objects take so much memory?

2007-12-18 Thread jsanshef
Hi,

after a couple of days of script debugging, I kind of found that some
assumptions I was doing about the memory complexity of my classes are
not true. I decided to do a simple script to isolate the problem:

class MyClass:
def __init__(self,s):
self.mystring  = s

mylist = []
for i in range(1024*1024):
mylist.append(MyClass(str(i))) #allocation
#stage 1
mylist = None
gc.collect()
#stage 2

I take measures of the memory consumption of the script at #stage1 and
#stage 2 and I obtain:
#stage1 -> 238MB
#stage2 -> 15MB

That means every object is around 223 bytes in size That's too
much considering it only contains a string with a maximum size of 7
chars.

If you change the allocation line for this other:
>>mylist.append(str(i)) #we don't create the custom class, but append the 
>>string directly into the list

the numbers decrease substantially to:
#stage1 -> 47.6MB
#stage2 -> 15MB
(so this time we can say string vars occupy around 32 bytesstill a
lot, isn't it?)

So, what's exactly going on behind the scenes? Why is using custom
objects SO expensive? What other ways of creating structures can be
used (cheaper in memory usage)?

Thanks a lot in advance!



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


Re: Does fileinput.input() read STDIN all at once?

2007-12-18 Thread Jonathan Gardner
On Dec 18, 5:55 am, Adam Funk <[EMAIL PROTECTED]> wrote:
> I'm using this sort of standard thing:
>
>for line in fileinput.input():
>   do_stuff(line)
>
> and wondering whether it reads until it hits an EOF and then passes
> lines (one at a time) into the variable line.  This appears to be the
> behaviour when it's reading STDIN interactively (i.e. from the
> keyboard).
>
> As a test, I tried this:
>
>for line in fileinput.input():
>   print '**', line
>
> and found that it would print nothing until I hit Ctl-D, then print
> all the lines, then wait for another Ctl-D, and so on (until I pressed
> Ctl-D twice in succession to end the loop).
>

There is probably a 1024 byte buffer. Try filling it up and see if you
get something before you hit CTRL-D.

Otherwise, the writers have to flush the buffer if they want a line to
be sent before the buffer fills up. C++ endl would do this, I believe,
in addition to printing '\n'.

Note that terminals (what you get if you are typing from the command
line) are terminals and behave quite differently than open files.

> Is it possible to configure this to pass each line of input into line
> as it comes?
>

It's up to the writer to flush the buffers. There's not much you can
do, so just learn to live with it.

It sounds like you want to write some kind of interactive program for
the terminal. Do yourself a favor and use curses or go with a full-
blown GUI.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing intobject to use int rather than long

2007-12-18 Thread Clarence
On Dec 18, 6:58 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:

> I don't think changing the underlying type will help at all.  The

>
> On a 64-bit machine, that's 16 bytes for PyObject_HEAD and 8 more
> bytes for the value, 24 bytes total.  Changing long to int won't
> decrease the struct size to 20 because the compiler will pad it to 24,
> the nearest multiple of 8.  (Forcing the compiler to pack the struct
> won't help because malloc will still pad it for you.)

That's an excellent point. And true, too. Thanks, that will lay the
issue
to rest.

> If you need to store millions of integers compactly, maybe
> array.array('i') can help.

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


Re: WikiInclude on 0.11 - Noah Kantrowitz blocks bug-fix

2007-12-18 Thread smallpond
On Dec 17, 9:23 pm, Ilias Lazaridis <[EMAIL PROTECTED]> wrote:
> Essence:
>
>  * Deletion of valid defect reports on trac community resources
>
> The "WikiInclude" plugin is not recognised on trac 0.11, thus I took a
> look an made a small addition to the setup.py (the entry_point).
>
> Other users have the same problem, thus I filed a ticket in the "trac-
> hacks" community resource.
>
> Mr. Noah Kantrowitz closed the ticket as "invalid". My comments within
> this ticket are deleted, directly in the database, which is the same
> as censorship. I've copied the email-notification from my comment
> below. [1]
>
> Please realize:
>
>  * this is a real-live defect, which remains unprocessed, thus more
> users run into this trouble.
>  * My attemps to inform users in the user-threads do not show up in
> all threads (moderation on trac-users!!!)
>  * The "IncludeMacro" is not compatible to the "WikiInclude" macro
>  * My comments were deleted in a non-trackable way
>  * Users of the WikiInclude plugin are not informed in any way
>
> You are may wondering why the trac project fails to produce a stable
> 1.0 version since years. The answer is here:
>
> http://case.lazaridis.com/wiki/TracAudit
>
> -
>
> [1]
>
> #2294: Plugin is not detectd on trac 0.11 (even the 0.11 specific one)
> 
> +---
> Reporter:  [EMAIL PROTECTED]  |Owner:  yu-ji
>Type:  defect   |   Status:  reopened
> Priority:  normal   |Component:  WikiIncludePlugin
> Severity:  critical |   Resolution:
> Keywords:   |  Release:  0.11
> 
> +---
> Changes (by [EMAIL PROTECTED]):
>
>  * status:  closed => reopened
>  * resolution:  invalid =>
>  * summary:  Missing "entry_point" within setup.py => Plugin is not
>  detectd on trac 0.11 (even the 0.11 specific
>  one)
>
> Comment:
>
>  (Mr. Kantrowitz. This is defenitely a defect, which occoured for
> several
>  users. The provided information helps any user which hits on this
> ticket
>  via a search. I ask you once more to stop with the deletions on this
>  '''community''' resource).
>
>  The resolution "invalid" is incorrect.
>
>  The problem exists for me '''and other''' users, see e.g.:
>
>  * [http://groups.google.com/group/trac-users/browse_frm/thread/
> de454e7dcf9f0438/d9806ad4a31a14a7 thread 1]
>  * [http://groups.google.com/group/trac-users/browse_frm/thread/
> 2ccf4b2855a6f242?q=WikiInclude& thread 2]
>
>  I've solved it whilst simply adding the entry point to the setup.py.
>
>  It is ok to point to the more flexible and maintained "IncludeMacro",
> but
>  other people possibly just want to continue to use the simpler
>  "WikiInclude" one.
>
>  I suggest the maintainer of "WikiInclude" (or another developer)
> corrects
>  the setup.py in the repo, and additionally one should place a note in
> the
>  "WikiInclude" documentation, that there's a more flexible
> "IncludeMacro"
>  available.


Trac is a python application.
Please read the posting guidelines for c.l.p.m
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging pipe IPC

2007-12-18 Thread Ian Clark
Jim B. Wilson wrote:
> ...  My fondest wish is to play the role of the child at the
> good old ">>>" prompt. ...
> 
> Jim

Okay, I misunderstood the direction you wanted to go. I thought that you 
wanted to play the part of the mother, giving commands to the child and 
not the other way around.

Assuming you're on a *nix make child.py as:

import os
os.system("netcat -l -p 1234 localhost")

Run it though mother and on another terminal type: netcat localhost 1234

HTH,

Ian

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


Re: New+old-style multiple inheritance

2007-12-18 Thread Jonathan Gardner
On Dec 18, 7:08 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> We are trying to monkey-patch a third-party library that mixes new and
> old-style classes with multiple inheritance.  In so doing we have
> uncovered some unexpected behaviour:
>

>
> I know this level of messing with python internals is a bit risky but
> I'm wondering why the above code doesn't work.
>

You've already discovered why--you're mixing old and new style
classes.

Monkey patching is definitely unpythonic. You must be a Ruby guy. Why
don't you try doing something else to get the behavior you want,
something more explicit?

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


Re: Changing intobject to use int rather than long

2007-12-18 Thread Hrvoje Niksic
Clarence <[EMAIL PROTECTED]> writes:

> When you move your application to a 64-bit system in order to get a
> bigger address space to store your millions/billions of integers in
> RAM, but they get twice as big, you don't gain very much.

I don't think changing the underlying type will help at all.  The
layout of the int object is as follows:

typedef struct {
// PyObject_HEAD
Py_ssize_t ob_refcnt;
struct _typeobject *ob_type;
// the actual value
long ob_ival;
} PyIntObject;

On a 64-bit machine, that's 16 bytes for PyObject_HEAD and 8 more
bytes for the value, 24 bytes total.  Changing long to int won't
decrease the struct size to 20 because the compiler will pad it to 24,
the nearest multiple of 8.  (Forcing the compiler to pack the struct
won't help because malloc will still pad it for you.)

If you need to store millions of integers compactly, maybe
array.array('i') can help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .NET and Python Integration Problem and PDF Library (Need Help and Suggestions)

2007-12-18 Thread Joshua Kugler
Ravi Kumar wrote:
> - your opinion with available PDF Libraries, that are best among. Also
> which library to use for Windows server platform (there is limitation
> on installing long chain libraries that include other deep
> dependencies too). A pure python PDF library would be good, but which
> one.
> -Which XML Library is pure python based.

Never done Python/.NET integration, so I can't help you there.

PDF library: ReportLab. But that is most generation of PDFs.  For reading,
splitting, etc, you may have to look at their commercial offering.  And I
do believe it is all pure python.

XML: ElementTree  http://effbot.org/zone/element-index.htm  Should be all
you need.

Hope that helps some.

j

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


why only an msi-installer for windows ?

2007-12-18 Thread Stef Mientki
hello,

having a lot of trouble installing 2.5 (without affecting my stable 2.4),
I wonder why there's only a msi installer for windows users ?

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


Re: Best way to protect my new commercial software.

2007-12-18 Thread tinnews
Jan Claeys <[EMAIL PROTECTED]> wrote:
> Op Fri, 14 Dec 2007 16:54:35 +, schreef Grant Edwards:
> 
> > Uh what?  I don't know what country you're in, but in the US, it doesn't
> > take any time at all to copyright something.  The mere act of writing
> > something copyrights it.  I thought it was the same in Europe as well.
> 
> No, it's only copyrighted when you _publish_ it.
> 
Which basically means letting anyone else see it, i.e. sending as an
E-Mail, posting on Usenet, etc.


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


Re: Changing intobject to use int rather than long

2007-12-18 Thread Clarence
On Dec 18, 6:24 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
>
> Your int objects get twice as large, but you get 4294967296 times more
> address space.
>
> (They don't always get twice as large, and you don't actually get that
> much address space, and there's lots of other things wrong with this
> answer, but the core truth - that your available address space grows
> at a greater rate than the size of your ints - is correct).

Technically true, but in my real world, I deal with physical RAM in
the machine. I went from a 2GB machine that was using half its memory
to an 8GB machine that is using one quarter its memory. Yes, it's
better,
but I still want that factor of two!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing intobject to use int rather than long

2007-12-18 Thread Chris Mellon
On Dec 18, 2007 11:59 AM, Clarence <[EMAIL PROTECTED]> wrote:
> Does anyone think (or know) that it might cause any internal problems
> if the ival member of the struct defining an intobject were to be
> changed from its current "long int" to just "int"?
>
> When you move your application to a 64-bit system in order to get a
> bigger address space to store your millions/billions of integers in
> RAM, but they get twice as big, you don't gain very much.
>

Your int objects get twice as large, but you get 4294967296 times more
address space.

(They don't always get twice as large, and you don't actually get that
much address space, and there's lots of other things wrong with this
answer, but the core truth - that your available address space grows
at a greater rate than the size of your ints - is correct).

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


Re: lotus nsf to mbox

2007-12-18 Thread Fabian Braennstroem
Hi to all,

thanks, I'll try your suggestions...

Regards!
Fabian

Brian Munroe schrieb am 12/15/2007 07:10 PM:
> On Dec 15, 11:04 am, Fabian Braennstroem <[EMAIL PROTECTED]>
> wrote:
> 
>> thanks for your ideas! I actually thought of something like
>> a python parser, which just converts the nsf structure to an
>> mbox; could that work!?
>>
> 
> Well, If you wish to go that route, I believe you will have to reverse
> engineer the Notes Database binary structure because I've never seen
> it published anywhere.  My suggestion, if you can use a Windows
> machine, just use the Lotus Notes COM Objects via the Python Win32
> bindings, as mentioned above.
> 
> If you really need to do it from Linux and are lucky enough to be
> running the IIOP task on your Domino server, then you could possibly
> use CORBA.
> 

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


  1   2   >