Re: Fibonacci series recursion error

2011-05-04 Thread Chris Angelico
On Mon, May 2, 2011 at 6:56 PM, Steven D'Aprano
 wrote:
> (The fact that most of those start with P is almost certainly a
> coincidence.)
>

There's definitely something attractive about that letter. Lots of
programming languages' names start with P. I smell a conspiracy. The
word "programming" has been secretly attracting related words to its
corner of the alphabet... and the government's *covering it up* and
pretending there's nothing happening!

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


A very minute correction on PDF

2011-05-04 Thread Mehta, Pratik

For tutorialPython.pdf

Page 17 of the ebook (i.e. page 23 of pdf) under topic 3.2 First Steps towards 
programming
Under while loop, there should be a "," after print b

Print b,
(a comma after 'b' is missing)

Regards,
__
[cid:[email protected]]Pratik Mehta
Associate Consultant | SOGETI - FR

TeamPark Support Team
Capgemini India |  Mumbai II
Tel.: +91 022 67 55 7000 - Mob: +91 9323054941
Extension: 225 1922 | www.capgemini.com
[email protected]
People matter, results count.
___







This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is 
intended only for the person to whom it is addressed. If you are not the 
intended recipient, you are not authorized to 
read, print, retain, copy, disseminate, distribute, or use this message or any 
part thereof. If you receive this message 
in error, please notify the sender immediately and delete all copies of this 
message.
<>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do directly imported variables behave differently than those attached to imported module?

2011-05-04 Thread Duncan Booth
Chris Angelico  wrote:

> Here's a side point. What types will hold a reference to the enclosing
> module (or at least its dictionary)? Would it be possible to use a
> from import to load a module, then "lose" the module even though
> you're using objects from it?
> 
> I am guessing that a function or class will hold such a reference,
> because otherwise it would be a bit awkward for them to use any sort
> of module-level state. Or do they not, and instead go look for their
> module in sys.modules?

A function object has a reference to the dictionary for the module in which 
it was defined; it needs this to access global variables. A class holds the 
name of the module but has no reference to the actual module itself.

Yes, it is quite possible to delete a module object, but it won't generally 
matter since any classes that are still referenced will prevent their 
methods being deleted and any functions or methods that are still 
accessible will keep the globals alive as long as required.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Aborting Python from C code

2011-05-04 Thread Chris Angelico
On Sat, Apr 30, 2011 at 7:29 PM, Dylan Evans  wrote:
> I think i see what you are trying to do but it depends on the environment
> and your goals.
> Generally i think you need to separate your code by forking (or perhaps you
> have already done that?),
> then you can run a check to see if the process died as expected. I don't
> know though, this not much
> information to go on, but if you are running untrusted code then you need to
> be able to isolate and kill it.

Well, I've gone with a slight variant on this. If the Python script
doesn't terminate in a timely manner, the process will be killed with
a longjmp straight from the signal handler (the setjmp having been
done long long ago back when the process initialized itself). So
Py_Finalize() will be called, but no other Python-related functions
_at all_, and the process promptly terminates. I'm assuming that
Python will flush out all its state on process termination (that is,
it doesn't hang onto any system-global resources).

Thanks for the advice!

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


Re: Running and killing a process in python

2011-05-04 Thread Jean-Michel Pichavant

James Mills wrote:

On Wed, May 4, 2011 at 10:45 AM, Astan Chee  wrote:
  

Hi,
I'm trying to make a python script (in windows 7 x64 using python 2.5) to
start a process, and kill it after x minutes/seconds and kill all the
descendants of it.
Whats the best way of doing this in python? which module is best suited to
do this? subprocess?



Yes start with the subprocess module:

http://docs.python.org/library/subprocess.html

cheers
James

  
As an alternative, you can have a look at 
http://codespeak.net/execnet/index.html


This module is designed to execute processes on remote machines, but it 
works great on the local host as well.

Among its features are:

"
- easy creation, handling and termination of multiple processes
- fully interoperable between Windows and Unix-ish systems
"

While it has more feature than what you need, if you do simple things, 
it stays simple.


(I never used subprocess with Windows, so I don't know if killing 
process is that easy. On *nix system, you should probably choose 
subprocess, execnet would be overkill)


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Devin Jeanpierre
> To illustrate the neither-fish-nor-fowl nature of Python calls:
>
> mwilson@tecumseth:~$ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> def 
> identify_call (a_list):
>
> ...   a_list[0] = "If you can see this, you don't have call-by-value"
> ...   a_list = ["If you can see this, you have call-by-reference"]
> ...>>> my_list = [None]
> >>> identify_call (my_list)
> >>> my_list
>
> ["If you can see this, you don't have call-by-value"]
>
> so it's neither call-by-value nor call-by-reference as (e.g.) C or PL/I
> programming would have it (don't know about Simula, so I am off topic,
> actually.)  It's not so wrong to think of Python's parameter handling as
> ordinary assignments from outer namespaces to an inner namespace.
>
>         Mel.

Eh, that example doesn't say what you think it does. It has the same
behavior in C: http://ideone.com/Fq09N . Python is pass-by-value in a
meaningful sense, it's just that by saying that we say that the values
being passed are references/pointers. This is maybe one level of
abstraction below what's ideal, but Scheme, Java, etc. share this
terminology. (Ruby calls it pass-by-reference AFAIK. Whatever, a rose
by any other name...)

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Steven D'Aprano
On Wed, 04 May 2011 02:56:28 -0700, Devin Jeanpierre wrote:

> Python is pass-by-value in a
> meaningful sense, it's just that by saying that we say that the values
> being passed are references/pointers. This is maybe one level of
> abstraction below what's ideal,

"Maybe"?

Given the following statement of Python code:

>>> x = "spam"

what is the value of the variable x? Is it...?

(1) The string "spam".

(2) Some invisible, inaccessible, unknown data structure deep in the 
implementation of the Python virtual machine, which the coder cannot 
access in any way using pure Python code.

(Possibly a pointer, but since it's an implementation detail, other 
implementations may make different choices.)

(3) Something else.


I argue that any answer except for (1) is (almost always) counter-
productive: it adds more confusion than shedding light. It requires 
thinking at the wrong level, at the implementation level instead of the 
level of Python code. If we define "value" to mean the invisible, 
inaccessible reference, then that leaves no word to describe was the 
string "spam" is.

(I say "almost always" counter-productive because abstractions leak, and 
sometimes you do need to think about implementation.)


> but Scheme, Java, etc. share this
> terminology. (Ruby calls it pass-by-reference AFAIK.

The intellectual contortions that some people will go through to hammer 
the square peg of actual programming language behaviour into the two 
round holes of "pass by value" and "pass by reference" never cease to 
astonish me.


> Whatever, a rose by any other name...)

Do you really think that roses would be the symbol of romantic love if 
they were called "disgusting stink-weeds of perversion and death"?

"How was the date last night?"
"Oh, it was marvelous! He presented me with a single red stink-weed, and 
then we went to a disgusting little restaurant. I had the swill."

When people cannot agree on the definition of words, how can they 
communicate? Pass by reference Ruby is completely different from the 
older usage in Pascal, VB and other languages. Likewise, pass by value in 
Java is completely different from that in older languages. Pass by 
reference in Ruby, and pass by value in Java, describe the same thing. 
What were these people thinking?


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


Handling the log in BaseHTTPServer

2011-05-04 Thread LehH Sdsk8
First, i'm sorry for any inglish error!

So, i use the BaseHTTPServer to create a page for monitoring purposes,
someone now how to direct the event log to a file?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Paul Rubin
Steven D'Aprano  writes:
 x = "spam"
> what is the value of the variable x? Is it...?
> (1) The string "spam".

Python works about the same way as Lisp or Scheme with regard to this
sort of thing, and those languages have been described with quite a bit
of mathematical formality.  So if you want a precise theoretical
treatment you might look at the Scheme report.  It should be pretty
clear how it carries over to Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Wed, 4 May 2011 02:56:28 -0700 (PDT), Devin Jeanpierre
   wrote:
:  Eh, that example doesn't say what you think it does. It has the same
:  behavior in C: http://ideone.com/Fq09N . Python is pass-by-value in a
:  meaningful sense, it's just that by saying that we say that the values
:  being passed are references/pointers.

No, Python is not pass-by-value, because the pointer is abstracted 
away.  You transmit arguments by reference only and cannot access the
value of the reference.  In C it is pass by value, as the pointer 
is explicit and do whatever you want with the pointer value.  

So, even though you have the same mechanism in C and Python, they
do not have the same name.  In the low-level C you only have pass
by value, but you can use the pointer syntax to do whatever you want
within pass by value.  In the higher-level python, you do not have 
the flexibility provided by explicit pointers, so you need to explain
the semantics without having a pointer concept defined a priori.

:This is maybe one level of
:  abstraction below what's ideal, but Scheme, Java, etc. share this
:  terminology. (Ruby calls it pass-by-reference AFAIK. Whatever, a rose
:  by any other name...)

Now, this is confusing, because the terminology is not universal and
hardly intuitive.  What is called transmission by reference in a
Simula context (Bjørn Kirkerud's textbook on OO Programming with Simula
for instance) is called object sharing in Wikipedia.  What Wikipedia
calls call by reference is transmission by name in the Simula context.

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


Re: vertical ordering of functions

2011-05-04 Thread John Roth
On May 3, 4:08 pm, Jabba Laci  wrote:
> Hi,
>
> I'm just reading Robert M. Martin's book entitled "Clean Code". In Ch.
> 5 he says that a function that is called should be below a function
> that does the calling. This creates a nice flow down from top to
> bottom.
> However, when I write a Python script I do just the opposite. I start
> with the lines
>
> if __name__ == "__main__":
>     main()
>
> Then I add main() above, which is a control function that contains
> some function calls that decompose the problem into subproblems. Then
> I add these functions above, etc.
>
> Is there a convention for this? Should main() be at the top and called
> function below?
>
> Thanks,
>
> Laszlo

I order classes and methods as I'd expect someone approaching the
program for the first time to want to read it. I think Robert Martin's
recommendation of use before declaration makes it easier to read a
program for the first time. Some compilers require declaration before
use because they need to see the declaration before they see any uses.
Python is in between: you can treat Python as if the order you write
things doesn't matter, but there are cases where it really does
matter. When it does, you have to have the definition before the use.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Devin Jeanpierre
On May 4, 6:51 am, Steven D'Aprano  wrote:
> On Wed, 04 May 2011 02:56:28 -0700, Devin Jeanpierre wrote:
> > Python is pass-by-value in a
> > meaningful sense, it's just that by saying that we say that the values
> > being passed are references/pointers. This is maybe one level of
> > abstraction below what's ideal,
>
> "Maybe"?
>
> Given the following statement of Python code:
>
> >>> x = "spam"
>
> what is the value of the variable x? Is it...?
>
> (1) The string "spam".
>
> (2) Some invisible, inaccessible, unknowndatastructure deep in the
> implementation of the Python virtual machine, which the coder cannot
> access in any way using pure Python code.
>
> (Possibly a pointer, but since it's an implementation detail, other
> implementations may make different choices.)
>
> (3) Something else.

As I said, a pointer or reference.

> I argue that any answer except for (1) is (almost always) counter-
> productive: it adds more confusion than shedding light. It requires
> thinking at the wrong level, at the implementation level instead of the
> level of Python code. If we define "value" to mean the invisible,
> inaccessible reference, then that leaves no word to describe was the
> string "spam" is.
>
> (I say "almost always" counter-productive because abstractions leak, and
> sometimes you do need to think about implementation.)

I don't know why you want to argue that it's counter-productive when
all I said was that it was meaningful / worked.

I don't think of "pass-by-value" involving references as being an
implementation-level thing. It's a way of thinking about Python's
behavior: a model. There don't even need to be actual references or
anything resembling them inside the implementation in order to apply
the model (for example, we probably all accept that Python could be
implemented using a turing machine, which lacks references/pointers).

Also, the word you suspected did not exist is "object". So if we have
var = "spam", var is a variable containing a reference to the object
"spam". Alternatively, it's a handle for the object "spam". I think
that's the call-by-sharing terminology, anyway.

> > but Scheme, Java, etc. share this
> > terminology. (Ruby calls it pass-by-reference AFAIK.
>
> The intellectual contortions that some people will go through to hammer
> the square peg of actual programming language behaviour into the two
> round holes of "pass by value" and "pass by reference" never cease to
> astonish me.

It isn't particularly contorted. I learned Python this way and it
makes perfect sense. It's just perhaps one level of abstraction away
from the ideal of what some programmers would think in. Python's "pass-
by-value" conforms exactly to the "pass-by-value" of other languages
such as C. The only twist is that you never get to dereference
pointers in Python, but you can in C. Not much of a twist if you ask
me, but then again, I've been thinking in this model for years. Maybe
I'm brainwashed. :)

> > Whatever, a rose by any other name...)
>
> Do you really think that roses would be the symbol of romantic love if
> they were called "disgusting stink-weeds of perversion and death"?
>
> "How was the date last night?"
> "Oh, it was marvelous! He presented me with a single red stink-weed, and
> then we went to a disgusting little restaurant. I had the swill."

Please don't argue with me in this manner. The point is that words
don't matter, the meaning behind them does. As long as it's clear
what's meant, and what's meant is internally-consistent, I don't have
much problem with it. Of course, this is a rule of thumb and you could
draw extreme scenarios where it just becomes a bother.

Devin Jeanpierre

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Devin Jeanpierre
On May 4, 6:56 am, Hans Georg Schaathun  wrote:
> On Wed, 4 May 2011 02:56:28 -0700 (PDT), Devin Jeanpierre  
>  wrote:
>
> :  Eh, that example doesn't say what you think it does. It has the same
> :  behavior in C:http://ideone.com/Fq09N. Python is pass-by-value in a
> :  meaningful sense, it's just that by saying that we say that the values
> :  being passed are references/pointers.
>
> No, Python is not pass-by-value, because the pointer is abstracted
> away.  You transmit arguments by reference only and cannot access the
> value of the reference.  In C it is pass by value, as the pointer
> is explicit and do whatever you want with the pointer value.  

The same argument applies to every language I know but two, all of
which describe themselves as pass-by-value. What you say certainly has
a consistency to it, it's just at odds with how I generally see the
term being applied. Forgive me if I don't share the same definition as
you, even if I do appreciate its elegance.

Devin Jeanpierre

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


[ann] pyjamas 0.8alpha1 release

2011-05-04 Thread Luke Kenneth Casson Leighton
after a long delay the pyjamas project - http://pyjs.org - has begun the
0.8 series of releases, beginning with alpha1:

https://sourceforge.net/projects/pyjamas/files/pyjamas/0.8/

pyjamas is a suite of projects, including a python-to-javascript
compiler with two modes of operation (roughly classified as "python
strict" and "Optimised"); a GUI Framework almost identical to that of
the GWT Project (1.5 to 1.7); and a "Desktop" version which is similar
in concept to Adobe Air, allowing python applications to be run -
unmodified - as stand-alone Desktop Applications.  pyjamas can
therefore be considered to be a Desktop GUI framework - a peer of GTK2
and QT4 - with the startling capability that applications can also be
compiled to javascript and run in any modern web browser with
absolutely no special plugins required, or it can be considered to be
an AJAX Web Framework with the massive advantage that applications are
written in python (not javascript) with a "Desktop" mode as well.
both descriptions are accurate, making pyjamas the world's only free
software python-based platform-independent, browser-independent,
GUI-toolkit-independent and OS-independent "Holy Grail" GUI
development environment [so there.  nyer, nyer to the corporate big
boys with access to $m who *still* haven't managed that one]

also included are ports of GChart and GWTCanvas, each of which run
under all web browsers and all desktop engines (with the exception at
present of the python-webkit desktop engines, which presently do not
support SVG Canvas).  all pyjamas UI libraries are designed to be
browser-independent as well as platform independent.  the usual
"browser foibles", tricks and gotchas are catered for with a
transparent "Platform Override" mechanism which ensures that the
published API of each UI Library is identical across all platforms
(including the Desktop Engines).  [no more "If Platform == IE or
Platform == Opera"]

due to the sheer number of modern browsers as well as the number of
pyjamas-desktop engines required to be supported, the 0.8 series will
be ready declared "stable" when sufficient community-led testing has
been done.  bugreports are in for Opera 11, IE8 and Google Chrome:
http://code.google.com/p/pyjamas/issues/detail?id=600
http://code.google.com/p/pyjamas/issues/detail?id=601
http://code.google.com/p/pyjamas/issues/detail?id=597

still requiring testing and confirmation is Opera 9 and 10; Firefox 2,
3, 3.1, 3.5, 3.6 and 4.0; IE6, 7 and 9; Safari 3 and 4, as well as
mobile phone browsers Android, Symbian Series 60, iphone, ipad and
blackberry OS 4.  also requiring testing and confirmation is the
Desktop Engines, of which there are now four variants: XulRunner
(Firefox Engine), pywebkitgtk, MSHTML and the new addition pywebkitdfb
(DirectFB).  each browser and each engine requires each of the 70
examples to be run, and in the case of the pyjamas compiler (pyjs),
compilation is required with both -O and --strict (with the exception
of the LibTest example).

the pywebkitdfb engine is a new addition, and merits a particular
mention.  some time last year, both GTK2 and QT4 independently
announced that they were dropping support for DirectFB from future
versions, and Enlightenment had not tested the DirectFB port for some
considerable time.  Webkit-GTK with the older GTK-DirectFB libraries
simply would not compile.  in the embedded space, where it can take 30
seconds to fire up Webkit-GTK on a 400mhz ARM9 and even longer to
start up WebkitQT4, this was something of a disaster.  To fix this, a
new port of Webkit was created which uses DirectFB directly, using a
tiny 50k Widget Toolkit called "Lite".  This development coincided
with the re-engineering of pywebkitgtk and the creation of the
pythonwebkit project, http://www.gnu.org/software/pythonwebkit:
pywebkitdfb was therefore also created at the same time.

Cutting a long story short, pywebkitdfb now exists and has a startup
time on 400mhz ARM9 processors of under 1.5 seconds.  The startup time
of both WebkitDFB and pywebkitdfb on Dual-Core 2ghz Intel systems is
so quick that it's difficult to determine: an estimate is under 0.1
seconds (100ms).  WebkitGTK. WebkitEFL and WebkitQT4 have
approximately 20 times or longer startup times.  So although WebkitDFB
is still significantly experimental, it is definitely worthwhile
considering, especially for Embedded Systems, but even for use on
X-Windows, and even just as a plain (but modern) web browser for those
people sick to the back teeth of long startup times on their web
browser [and it has python bindings, too.  yaay!]

summary: developing applications in pyjamas means the application can
be made to run just about anywhere, and it's an entirely python-based
and a free software framework.  it's a community-driven project, so
requires *your* input to get it to a proven stable state.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Wed, 4 May 2011 06:12:14 -0700 (PDT), Devin Jeanpierre
   wrote:
:  I don't think of "pass-by-value" involving references as being an
:  implementation-level thing. It's a way of thinking about Python's
:  behavior: a model. (...)
:  It isn't particularly contorted. I learned Python this way and it
:  makes perfect sense. It's just perhaps one level of abstraction away
:  from the ideal of what some programmers would think in. Python's "pass-
:  by-value" conforms exactly to the "pass-by-value" of other languages
:  such as C.

It is contorted and implementation-level because it is one level below
the abstraction assumed by the language.  It only works by assuming 
knowledge of C, which is language which has proved unsuitable for
complex and abstract data modelling.  Digging down into C should be 
unnecessary to explain Python.  

By calling it pass-by-value you introduce a new data type which is
unknown to Python, namely the pointer.  

:   The only twist is that you never get to dereference
:  pointers in Python, but you can in C. Not much of a twist if you ask
:  me, but then again, I've been thinking in this model for years. Maybe
:  I'm brainwashed. :)

You are.  You explain Python in terms of C.  That's useful when you 
talk to other speakers of C.

If you want to explain the language to a broader audience, you should
use terminology from the language's own level of abstraction.


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Chris Angelico
On Wed, May 4, 2011 at 11:44 PM, Hans Georg Schaathun  
wrote:
> It is contorted and implementation-level because it is one level below
> the abstraction assumed by the language.  It only works by assuming
> knowledge of C, which is language which has proved unsuitable for
> complex and abstract data modelling.  Digging down into C should be
> unnecessary to explain Python.

Sometimes, to explain Python, you need to dig down to the underlying
hardware - even deeper than C, if you like. And that's always going to
be the way, because abstractions leak from time to time. Or I should
say, they occasionally have confidential briefings with the press.
Abstracting everything perfectly is neither possible nor desirable.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread sturlamolden
On May 3, 3:50 pm, Hrvoje Niksic  wrote:

> I would say that, considering currently most popular languages and
> platforms, Python's data model is in the majority.  It is only the
> people coming from a C++ background that tend to be confused by it.

In C++, one will ususally put class variables (objects) on the stack
or in STL containers, and use references instead of pointers. This way
one gets deterministic clean-up, and operator overloading will work as
expected. It is a common beginner mistake for people coming from Java
to use "new" anywhere in C++ code, instead of inside constructors
only. Used properly, C++ has a data model for class variables similar
to Fortran (pass-by-reference). This is complicated by the ability of C
++ to pass-by-value for backwards compatibility with C, inclusing the
use of raw pointers. This hybrid and convoluted data model of C++ is a
common source of confusion and programming mistakes, both for
programmers coming from C++ to Python or C# or vice versa.

Java is somewhat between C and C#, in that it has C semantics for
elementary types (e.g. int and float), but not for objects in general.
In C# and Python, elementary types are immutable objects, byut thet
have no special pass-by-value semantics.

Python has the same data model as Scheme. This includes that code is
an object in Python (in Python that is byte code not source code, thus
no Lisp macros). Variables are names that bind to an object. Objects
are passed as references, but names are not. "Dummy arguments" (to use
Fortran termininology) are bound to the same objects with which the
function was called, but this is not call-by-reference semantics in
the style of Fortran and C++:

In Python, the "=" operator will rebind in the local scope, as in C,
Java and C#. It will not affect anything the the calling scope (as in C
++ and Fortran). Nevertheless, this is not pass-by-value, as no copy
are made. A reference in C++ and Fortran is an alias for the variable
in the calling scope. In Python it is a new variable pointing to the
same value. This is a major difference, but a common source of error
for those that don't understand it.

( for those confused about the claimed behavior of "=" in C++: The
previous paragraph deals with reference variables in C++, not those
passed with C-style pass-by-value sematics. C++ does not always behave
as C, sometimes it behaves like Fortran and Pascal.)

Thus, Python does not pass-by-value like C or C++, nor does it pass-by-
reference like C++ or Fortran.

The semantics of Python, C# and Lisp might be described as "pass-by-
handle" if we need to put a name on it.


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread sturlamolden
On May 3, 6:33 pm, Mel  wrote:

> def identify_call (a_list):
>   a_list[0] = "If you can see this, you don't have call-by-value"
>   a_list = ["If you can see this, you have call-by-reference"]


The first one is a mistake. If it were pass-by-value, it would
assign the string to a list unseen by the caller -- i.e. a copy
of the caller's argument (same value, different object).

But that does not happen. The string is assigned to the list
seen by the caller. Thus we can exclude call-by-value.

The second proposition is correct. This allows us to exclude
pass-by-reference similar to C++, Pascal and Fortran.

Thus:

def identify_call (a_list):
   a_list[0] = "If you cannot see this, you have call-by-value"
   a_list = ["If you can see this, you have call-by-reference"]


Clearly Python has neither call-by-value nor call-by-reference.

Python uses a third mechanism.

Sturla


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


Re: Pickling extension types

2011-05-04 Thread Robert Kern

On 5/3/11 9:28 PM, Stefan Kuzminski wrote:

closer I think

1) I changed tp_name to be 'observation.MV' ( module is named observation.c )
and now I get a new error..

PicklingError: Can't pickle : import of module
observation failed

2) here is the init function, sorry I did not include it in the original listing

void initobservation(void) {

   PyObject *m;
   m = Py_InitModule("observation", observation_methods);

   Py_INCREF(&PyMV_Type);
   PyModule_AddObject(m, "MV", (PyObject *)&PyMV_Type);

}


Without seeing the whole C code, or the Python code you are trying, I can't help 
much more.


--
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: Pickling extension types

2011-05-04 Thread Stefan Kuzminski
I got this to work by returning from reduce just the args that the __init__
of the type being pickled requires ( rather than the 5 length tuple
described in the pickling docs ), I am not going to argue with it though..

thank you *very* much for the help!
S


On Wed, May 4, 2011 at 11:06 AM, Robert Kern  wrote:

> On 5/3/11 9:28 PM, Stefan Kuzminski wrote:
>
>> closer I think
>>
>> 1) I changed tp_name to be 'observation.MV' ( module is named
>> observation.c )
>> and now I get a new error..
>>
>> PicklingError: Can't pickle : import of module
>> observation failed
>>
>> 2) here is the init function, sorry I did not include it in the original
>> listing
>>
>> void initobservation(void) {
>>
>>   PyObject *m;
>>   m = Py_InitModule("observation", observation_methods);
>>
>>   Py_INCREF(&PyMV_Type);
>>   PyModule_AddObject(m, "MV", (PyObject *)&PyMV_Type);
>>
>> }
>>
>
> Without seeing the whole C code, or the Python code you are trying, I can't
> help much more.
>
>
> --
> 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
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ann] pyjamas 0.8alpha1 release

2011-05-04 Thread Luke Kenneth Casson Leighton
On Wed, May 4, 2011 at 3:06 PM, Luke Kenneth Casson Leighton
 wrote:

> after a long delay the pyjamas project - http://pyjs.org - has begun the
> 0.8 series of releases, beginning with alpha1:
>
> https://sourceforge.net/projects/pyjamas/files/pyjamas/0.8/
>
> pyjamas is a suite of projects, including a python-to-javascript
> compiler with two modes of operation (roughly classified as "python
> strict" and "Optimised"); a GUI Framework almost identical to that of
> the GWT Project (1.5 to 1.7);

 oh one other thing - for the 0.8 release, jim washington kindly added
an HTML5-compliant "Drag-n-Drop" interface, which, on web engines that
do not have HTML5, is emulated.  and thus provides the exact same API,
regardless of the web browser being used.  cool, huh?  if i was a
java-lover, i'd look forward to that being added some day to GWT.

 btw - if anyone's at all curious [about GWT "Desktop" possibilities],
there *does* exist a sort-of "Desktop" version [not really] - it's
basically webkit, it requires execution under the eclipse IDE, and
it's still javascript (not Java).  i _did_ speak to the GWT Team,
raising with them the possibility of doing Java bindings to Webkit [or
XulRunner, or MSHTML] and providing a port of GWT that can run GWT
applications REALLY as stand-alone Desktop applications, and they
basically implied that that'll happen "when hell freezes over".  i
guess the idea of providing languages other than javascript with
direct access to the full and incredible capabilities of DOM and HTML5
is just... too alien.  which is funny, because pyjamas desktop shows
what can be done: web browser engines can literally be turned into
cross-platform GUI engines.

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


Re: Handling the log in BaseHTTPServer

2011-05-04 Thread Tapi

Hi,

You may create a subclass of (or Mixin for) BaseHTTPRequestHandler to 
override its log_message() method.
Here's a really simple example ; it's perfectible, but it should show 
you the way :


class MyLoggingHTTPRequestHandler(BaseHTTPRequestHandler):
def log_message(self, format, *args):
open(LOGFILE, "a").write("%s - - [%s] %s\n" %
 (self.address_string(),
  self.log_date_time_string(),
  format%args))

httpd = HTTPServer(ADDR, MyLoggingHTTPRequestHandler)
httpd.serve_forever()


Simon

On Wed, 4 May 2011 03:52:29 -0700 (PDT), LehH Sdsk8 wrote:

First, i'm sorry for any inglish error!

So, i use the BaseHTTPServer to create a page for monitoring 
purposes,

someone now how to direct the event log to a file?


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Michael Torrie
On 05/04/2011 08:44 AM, sturlamolden wrote:
> On May 3, 6:33 pm, Mel  wrote:
> 
>> def identify_call (a_list):
>>   a_list[0] = "If you can see this, you don't have call-by-value"
>>   a_list = ["If you can see this, you have call-by-reference"]
> 
> 
> The first one is a mistake. If it were pass-by-value, it would
> assign the string to a list unseen by the caller -- i.e. a copy
> of the caller's argument (same value, different object).
> 
> Clearly Python has neither call-by-value nor call-by-reference.
> 
> Python uses a third mechanism.

Which is exactly what the code showed.  The first one isn't a mistake.
You just read it wrong.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Handling the log in BaseHTTPServer

2011-05-04 Thread LehH Sdsk8
On 4 maio, 12:55, Tapi  wrote:
> Hi,
>
> You may create a subclass of (or Mixin for) BaseHTTPRequestHandler to
> override its log_message() method.
> Here's a really simple example ; it's perfectible, but it should show
> you the way :
>
> class MyLoggingHTTPRequestHandler(BaseHTTPRequestHandler):
>      def log_message(self, format, *args):
>          open(LOGFILE, "a").write("%s - - [%s] %s\n" %
>                           (self.address_string(),
>                            self.log_date_time_string(),
>                            format%args))
>
> httpd = HTTPServer(ADDR, MyLoggingHTTPRequestHandler)
> httpd.serve_forever()
>
> Simon
>
>
>
>
>
>
>
> On Wed, 4 May 2011 03:52:29 -0700 (PDT), LehH Sdsk8 wrote:
> > First, i'm sorry for any inglish error!
>
> > So, i use the BaseHTTPServer to create a page for monitoring
> > purposes,
> > someone now how to direct the event log to a file?

Thanks dude, this really works, my class is a subclass of
basehttprequesthandler, the only thing i have to do is put this
function inside.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Devin Jeanpierre
On May 4, 9:44 am, Hans Georg Schaathun  wrote:
> :   The only twist is that you never get to dereference
> :  pointers in Python, but you can in C. Not much of a twist if you ask
> :  me, but then again, I've been thinking in thismodelfor years. Maybe
> :  I'm brainwashed. :)
>
> You are.  You explain Python in terms of C.  That's useful when you
> talk to other speakers of C.
>
> If you want to explain the language to a broader audience, you should
> use terminology from the language's own level of abstraction.

No, I explained Python in terms of pointers/reference. I don't speak C
or come from a C background, I'm primarily a Python programmer. Also,
I don't agree with your notions of "should", I have seen it taught
this way to plenty of undergraduate students learning Python as their
first programming language, and they do fine. The precise notational
difference between sharing an object and copying a reference doesn't
matter, as long as you can draw a diagram of it and write/read code --
which they can, and they do fine.

I'm a bit uncomfortable with the vibe here. It's one thing for me to
self-deprecatingly suggest I'm brainwashed (with a smile), and another
for you to agree in complete seriousness.

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


Basic interaction with another program

2011-05-04 Thread ETP
I have a dos program (run in a window) that I would like to control
with a script.  It needs only text input.  For example, I only need to
tell it:

L
u
100 
u

It will then wait for a file to be created, rename the file, then
loop.  Simple.

I'd like to run this on Lucid Puppy Linux as it will be implemented on
a very old laptop, but can probably deal with windows if needed.

I only need direction on getting Python to interact with another
program; how do I get it to direct text onto another window?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic interaction with another program

2011-05-04 Thread Matty Sarro
Look into the pexpect library, it'll make this easy as punch.
http://www.noah.org/wiki/pexpect


On Wed, May 4, 2011 at 12:34 PM, ETP  wrote:
> I have a dos program (run in a window) that I would like to control
> with a script.  It needs only text input.  For example, I only need to
> tell it:
>
> L
> u
> 100 
> u
>
> It will then wait for a file to be created, rename the file, then
> loop.  Simple.
>
> I'd like to run this on Lucid Puppy Linux as it will be implemented on
> a very old laptop, but can probably deal with windows if needed.
>
> I only need direction on getting Python to interact with another
> program; how do I get it to direct text onto another window?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread sturlamolden
On May 4, 5:40 pm, Michael Torrie  wrote:

> Which is exactly what the code showed.  The first one isn't a mistake.
> You just read it wrong.

No, I read "call-by-value" but it does not make a copy. Call-by-value
dictates a deep copy or copy-on-write. Python does neither. Python
pass a handle to the object, not a handle to a copy of the object. If
you want to see call-by-value in practice, take a look at MATLAB,
SciLab or Octave; or consider what C++ copy constructors do in
function calls with value types.

The first one is indeed a mistake. An object has a value. A name binds
to an object, not to a value. If Python did pass-by-value, the string
would be inserted in an object (here: a list) with the same value
(e.g. empty list), it would not modify the same object by which you
called the function.

I think you understand what Python does, but not what call-by-value
would do.


C++ tells you the difference:


// copy constructor is invoked
// x is a copy of the argument's value
// this is call-by-value

void foobar1(Object x);


// no copy is taken
// x is a logical alias of the argument
// this is call-by-reference

void foobar2(Object &x);


// x is a pointer, not an object
// x is a copy of another pointer
// this is similar to Python sematics
// the pointer is passed by value, not the pointee

// in C, this is sometimes called call-by-reference
// as there are no reference types, but it's not

void foobar3(Object *x);



Sturla




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


Hooking into Python's memory management

2011-05-04 Thread Daniel Neilson


Hello,
 I'm hoping that there will be someone here with sufficient expertise 
to answer a question on Python 3 for me.


 I work in the Computer Science department at a large Canadian 
University. We are currently doing a feasibility analysis for switching 
to using Python in our first year major-stream courses.


 Part of our first year curriculum requires that students be exposed to 
explicit dynamic memory allocation in the form of C++'s new/delete, C's 
malloc/free, etc. I realize that Python is garbage collected, and that 
there is never a need to explicitly allocate & deallocate objects. 
However, I am trying to determine whether or not it is possible to 
simulate that behaviour within Python via a module for the purposes of 
instruction.


 For these purposes, I would like to know whether it is possible within 
Python 3 to write a Python-only module that, essentially, hooks into the 
"constructor" and "destructor" of many of the Python built-in types 
(specifically list, dictionary, set, tuple, and string) so that the 
module can:
 1) Maintain a list of object id()'s for objects that have been 
created. Ideally, this list would also contain the file & line number 
where the object was created.
 2) Provide a "deallocate" function that will remove a given object's 
id() from the list from (1).
 3) Print out an error message if the python script terminates with a 
non-empty list from (1). Preferably with a list of objects that are 
still "allocated."


 Baring a Python-only module, would this behaviour be possible to add 
via a C-language module?


 A module that hooked in to all memory allocation, and inspected the 
type of the object being allocated to conditionally add the object's 
id() to the list would also suffice.


 In either case, if such a module is possible, any pointers you could 
provide regarding how to implement such a module would be appreciated.


Thank you for your time,
 Daniel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Basic interaction with another program

2011-05-04 Thread Grant Edwards
On 2011-05-04, Matty Sarro  wrote:



> On Wed, May 4, 2011 at 12:34 PM, ETP  wrote:
>> I have a dos program (run in a window) that I would like to control
>> with a script.

> Look into the pexpect library, it'll make this easy as punch.

I don't think pexpect is going to do the OP much good. Quoting from
the web page:

  "Pexpect does not currently work on the standard Windows Python"

> http://www.noah.org/wiki/pexpect

Seriously?  Yellow on brown text?

-- 
Grant Edwards   grant.b.edwardsYow! When this load is
  at   DONE I think I'll wash it
  gmail.comAGAIN ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Wed, 4 May 2011 09:18:56 -0700 (PDT), Devin Jeanpierre
   wrote:
:  I'm a bit uncomfortable with the vibe here. It's one thing for me to
:  self-deprecatingly suggest I'm brainwashed (with a smile), and another
:  for you to agree in complete seriousness.

I am sorry.  It was not meant to be an insult.  I do think that you
sit tightly in a frame of reference which is obviously not the only 
one appropriate, and IMNHO not the optimal one for the purpose.
"Brainwashed" was not a word I meant to take seriously.  Apologies.

I should have cut the C reference too; the same frame of reference 
could be adopted from any number of languages.  

Note that it was not the use of references as a concept I objected to,
but that they might be passed by value.  With the references being
purely abstract entities and not data objects, the idea that they
have values do not make sense.  And pass-by-value where the value
is a reference is just confusing.

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


Re: Hooking into Python's memory management

2011-05-04 Thread sturlamolden
On May 4, 6:51 pm, Daniel Neilson  wrote:

>   In either case, if such a module is possible, any pointers you could
> provide regarding how to implement such a module would be appreciated.


The gc module will hook into the garbage collector.

The del statement will remove an object from the current scope.
(Delete the variable name and decrement the reference count.)

Python (CPython that is) is reference counted. When the refcount drops
to zero, the object is immediately garbage collected. Python is not
like Java, where this happen in bouts. The __del__ method is executed
deterministically, it's not like a finalizer in Java or C#.

Only dead objects involved in reference circles may linger until they
are spotted by the GC. And they may not have a __del__ method, or else
the GC will ignore them.

In fact, if you don't create circular references, the GC can safely be
turned off.

If you want volatile references, Python allows weak references as
well.


Sturla




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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Benjamin Kaplan
On Wed, May 4, 2011 at 12:40 PM, sturlamolden  wrote:
>
> On May 4, 5:40 pm, Michael Torrie  wrote:
>
> > Which is exactly what the code showed.  The first one isn't a mistake.
> > You just read it wrong.
>
> No, I read "call-by-value" but it does not make a copy. Call-by-value
> dictates a deep copy or copy-on-write. Python does neither. Python
> pass a handle to the object, not a handle to a copy of the object. If
> you want to see call-by-value in practice, take a look at MATLAB,
> SciLab or Octave; or consider what C++ copy constructors do in
> function calls with value types.

You missed a word in the sentence.

"If you can see this, you DON'T have call-by-value"
-- 
http://mail.python.org/mailman/listinfo/python-list


newbie needs help with cookielib

2011-05-04 Thread Sells, Fred
I'm using Python 2.4 and 2.7 for different apps.  I'm happy with a
solution for either one.

I've got to talk to a url that uses a session cookie.  I only need to
set this when I'm developing/debugging so I don't need a robust
production solution and I'm somewhat confused by the docs on cookielib.
I can use urllib2 without cookielib just fine, but need the cookie to
add some security.

I'm normally using Firefox 4.0 to login to the server and get the
cookie.  After that I need some way to set the same cookie in my python
script.  I can do this by editing my code, since I only need it while
defeloping from my test W7 box.


I was hoping to find something like

...set_cookie('mycookiename', 'myvalue', 'mydomain.org')

I've googled this most of the morning and found everything but what I
need, or I just don't understand the basic concept.  Any pointers would
be greatly appreciated.  One of my false starts looks like this. But I
get a 

...
  File "C:\alltools\python26\lib\urllib2.py", line 518, in
http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Access Deinied

def test1():
cj = cookielib.MozillaCookieJar()
cj.load('C:/Users/myname/Desktop/cookies.txt')
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open("http://daffyduck.mydomain.org/wsgi/myapp.wsgi";)   
print r.read() 
return

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Thu, 5 May 2011 00:20:34 +1000, Chris Angelico
   wrote:
:  Sometimes, to explain Python, you need to dig down to the underlying
:  hardware - even deeper than C, if you like.

Sometimes you may need to narrow down the scope and explain a particular
implementation of python with its hardware, OS, and interpreter.
However, explaining just python, you do not know what the underlying
hardware/OS/interpreter is, and digging down into it is not possible.

:  And that's always going to
:  be the way, because abstractions leak from time to time. Or I should
:  say, they occasionally have confidential briefings with the press.
:  Abstracting everything perfectly is neither possible nor desirable.

Sure, but every language assumes a certain level of abstraction, and
when the abstraction breaks the language fails to be unambiguous and/or
portable.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread sturlamolden
On May 4, 7:15 pm, Benjamin Kaplan  wrote:

> You missed a word in the sentence.
>
> "If you can see this, you DON'T have call-by-value"

Indeed I did, sorry!

Then we agree :)


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


Re: Basic interaction with another program

2011-05-04 Thread Ian Kelly
On Wed, May 4, 2011 at 10:52 AM, Grant Edwards  wrote:
> On 2011-05-04, Matty Sarro  wrote:
>> On Wed, May 4, 2011 at 12:34 PM, ETP  wrote:
>>> I have a dos program (run in a window) that I would like to control
>>> with a script.
>
>> Look into the pexpect library, it'll make this easy as punch.
>
> I don't think pexpect is going to do the OP much good. Quoting from
> the web page:
>
>  "Pexpect does not currently work on the standard Windows Python"

The OP said he was running Linux.  I gather the DOS program is being
run in DOSBox or something similar.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Developers with 5 years of experience

2011-05-04 Thread Jerome jjcpl.rpo
send resumes to [email protected]


One of our client in New Jersey is looking for Python Developers with 5 years 
of experience.   If you have any resumes please send it across.   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A very minute correction on PDF

2011-05-04 Thread Terry Reedy

On 5/4/2011 3:45 AM, Mehta, Pratik wrote:

For tutorialPython.pdf
Page 17 of the ebook (i.e. page 23 of pdf) under topic *3.2 First Steps
towards programming*
Under while loop, there should be a “,” after print b

Print b,

(a comma after ‘b’ is missing)


[You should mention versions when posting. Above is for 2.7]
The example is consistent as it is. A trailing comma would suppress the 
newline after each output, resulting in a single line of output.

1 1 2 3 5 8
While you could argue that the combined change would be better, the 
author of the example did not think so. This introductory chapter only 
uses the simplest form of the print statement.


--
Terry Jan Reedy


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


Re: Hooking into Python's memory management

2011-05-04 Thread Dan Stromberg
Sturla had some great comments; I'll add, in no particular order:

1) You could use the ctypes module to call the real malloc and free from
Python.
2) Yes, a Python "C extension module" can do explicit memory allocation.
3) Cython provides a language that is a hybrid of Python and C.  It might be
nice as a way of introducing explicit memory management.
4) You could also build a heap (not the tree kind, but the malloc kind) in
pure Python, and give it alloc and destroy operations.  Underneath it all,
things would still be reference counted/garbage collected, but that wouldn't
actually happen until you used your destroy.

On Wed, May 4, 2011 at 9:51 AM, Daniel Neilson  wrote:

  Part of our first year curriculum requires that students be exposed to
> explicit dynamic memory allocation in the form of C++'s new/delete, C's
> malloc/free, etc. I realize that Python is garbage collected, and that there
> is never a need to explicitly allocate & deallocate objects. However, I am
> trying to determine whether or not it is possible to simulate that behaviour
> within Python via a module for the purposes of instruction.
>
>  For these purposes, I would like to know whether it is possible within
> Python 3 to write a Python-only module that, essentially, hooks into the
> "constructor" and "destructor" of many of the Python built-in types
> (specifically list, dictionary, set, tuple, and string) so that the module
> can:
>  1) Maintain a list of object id()'s for objects that have been created.
> Ideally, this list would also contain the file & line number where the
> object was created.
>  2) Provide a "deallocate" function that will remove a given object's id()
> from the list from (1).
>  3) Print out an error message if the python script terminates with a
> non-empty list from (1). Preferably with a list of objects that are still
> "allocated."
>
>  Baring a Python-only module, would this behaviour be possible to add via a
> C-language module?
>
>  A module that hooked in to all memory allocation, and inspected the type
> of the object being allocated to conditionally add the object's id() to the
> list would also suffice.
>
>  In either case, if such a module is possible, any pointers you could
> provide regarding how to implement such a module would be appreciated.
>
> Thank you for your time,
>  Daniel
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development tools and practices for Pythonistas

2011-05-04 Thread Anssi Saari
rusi  writes:

>> I actually use rcs in Windows. Needs a little setup, but works great,
>> from Emacs VC-mode too.
>
> Where do you get it?
> [What google is showing seems to be about 10-15 years old]

As far as I know, RCS hasn't been updated since 5.7 which is about 10
years old now. Linux distributions also package the same version. I
use the stuff from rcs57pc1.zip, at ftp://ftp.cs.purdue.edu/pub/RCS/

The package includes also comparison tools cmp, diff, diff3, sdiff as
win32 versions. I suppose one would need to recompile if 64-bit
versions were needed.

The setup I mentioned was just setting RCSINIT to -x,v although I
don't remember now why I needed that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic interaction with another program

2011-05-04 Thread Grant Edwards
On 2011-05-04, Ian Kelly  wrote:
> On Wed, May 4, 2011 at 10:52 AM, Grant Edwards  
> wrote:
>> On 2011-05-04, Matty Sarro  wrote:
>>> On Wed, May 4, 2011 at 12:34 PM, ETP  wrote:
 I have a dos program (run in a window) that I would like to control
 with a script.
>>
>>> Look into the pexpect library, it'll make this easy as punch.
>>
>> I don't think pexpect is going to do the OP much good. Quoting from
>> the web page:
>>
>> ?"Pexpect does not currently work on the standard Windows Python"
>
> The OP said he was running Linux.

My bad. When I saw that he wanted to run a DOS program, I jumped to
the conclusion he was running Windows and missed the part about puppy
linux.

> I gather the DOS program is being run in DOSBox or something similar.

If it's running in a window as the OP claims, Pexpect still won't work
since when DOSBox or DOSEmu runs in a window it isn't reading commands
from a pty but rather from X11.  If he can get the program to run on a
pty (e.g. console or xterm or whatever) rather than in a window, then
Pexpect should work.

-- 
Grant Edwards   grant.b.edwardsYow! Are we wet yet?
  at   
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Today's fun and educational Python recipe

2011-05-04 Thread Raymond Hettinger
Here's a 22-line beauty for a classic and amazing algorithm:
http://bit.ly/bloom_filter

The wiki article on the algorithm is brief and well-written:
http://en.wikipedia.org/wiki/Bloom_filter

It turns out that people in the 1970's were pretty smart :-)


Raymond

---
follow my other python tips and recipes on twitter:  @raymondh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2011-05-04 Thread Ethan Furman

Raymond Hettinger wrote:

I'm writing-up more guidance on how to use super() and would like to
point at some real-world Python examples of cooperative multiple
inheritance.


Don't know if you are still looking for examples, but I recently came 
across a thread in Python-Dev which had an example using unittest:


Ricardo Kirkner wrote [much snippage]:
> I'll give you the example I came upon:
>
> I have a TestCase class, which inherits from both Django's TestCase
> and from some custom TestCases that act as mixin classes. So I have
> something like
>
> class MyTestCase(TestCase, Mixin1, Mixin2):
>...
>
> Since I explicitely base off 3 classes, I expected all 3
> classes to be initialized, and I expect the setUp method to be called
> on all of them.

As written this example failed because TestCase (from django) was based 
on unittest2.TestCase, which was not calling super.  I understand, 
however, that if the mixins were listed before TestCase that it would work.


Hope this helps.

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


Re: Pickling extension types

2011-05-04 Thread Robert Kern

On 5/4/11 10:45 AM, Stefan Kuzminski wrote:

I got this to work by returning from reduce just the args that the __init__ of
the type being pickled requires ( rather than the 5 length tuple described in
the pickling docs ), I am not going to argue with it though..


Let's take a step back. The documentation says to return a tuple between 2 and 5 
elements long. You can omit the optional ones or use Nones in their place. The 
original code you posted allocated a 5-tuple, but did not insert anything into 
positions 2, 3, or 4. This was an error. You should have returned a 2-tuple of 
the type object in the 0-index slot and the argument tuple in the 1-index slot. 
Are you saying that you just returned the argument tuple? I don't think that 
would work.


--
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: [ann] pyjamas 0.8alpha1 release

2011-05-04 Thread Terry Reedy

On 5/4/2011 10:06 AM, Luke Kenneth Casson Leighton wrote:

after a long delay the pyjamas project - http://pyjs.org - has begun the
0.8 series of releases, beginning with alpha1:

https://sourceforge.net/projects/pyjamas/files/pyjamas/0.8/

pyjamas is a suite of projects, including a python-to-javascript
compiler


As you well know, there is no such thing as 'python' when it comes to 
compiling actual code. So please specify both in announcements here and 
on the project homepage http://sourceforge.net/projects/pyjamas/
which versions are supported. I do not really want to have to download 
and experiment to determine whether to bother downloading.


If you do not yet support 3.x, I request and recommend that you do so, 
even if only on Windows with comtypes. Since comtypes uses ctypes, I 
presume it works fine with Python 3 (this is one major advantage of 
using ctypes.)


Like it or not, Python 3 is the future of Python. It is the Python that 
many Python newcomers learn first, and perhaps ever will. Such students 
usually have no experience or loyalty to any other GUI package, and I am 
sure that many would love to be able to develop apps that they can run 
on their desktop, give to friends to run in a browser, and run on their 
phones.


--
Terry Jan Reedy

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


Re: Hooking into Python's memory management

2011-05-04 Thread Terry Reedy

On 5/4/2011 12:51 PM, Daniel Neilson wrote:


Hello,
I'm hoping that there will be someone here with sufficient expertise to
answer a question on Python 3 for me.

I work in the Computer Science department at a large Canadian
University. We are currently doing a feasibility analysis for switching
to using Python in our first year major-stream courses.


If you did, I believe you would be following in the footsteps of MIT.


Part of our first year curriculum requires that students be exposed to
explicit dynamic memory allocation in the form of C++'s new/delete, C's
malloc/free, etc. I realize that Python is garbage collected, and that
there is never a need to explicitly allocate & deallocate objects.
However, I am trying to determine whether or not it is possible to
simulate that behaviour within Python via a module for the purposes of
instruction.


The Python ctypes module allows one to invoke compiled C (or C++, I 
presume) functions in shared libraries (.dll on Windows, .so on *Nix).



For these purposes, I would like to know whether it is possible within
Python 3 to write a Python-only module that, essentially, hooks into the
"constructor" and "destructor" of many of the Python built-in types


Python is compiled as a small startup executable (<30 KB). The builtins 
are all in shared libraries that you can access with ctypes. The 
functions in those libraries are documented in the Python/C API manual.



(specifically list, dictionary, set, tuple, and string) so that the
module can:
1) Maintain a list of object id()'s for objects that have been created.
Ideally, this list would also contain the file & line number where the
object was created.
2) Provide a "deallocate" function that will remove a given object's
id() from the list from (1).
3) Print out an error message if the python script terminates with a
non-empty list from (1). Preferably with a list of objects that are
still "allocated."


I presume you can do all of this easily. For point 3, a script can 
register an 'atexit' function. As a sidenote, using ctypes 'allows' one 
to crash (segfault, bluescreen) a program just like when using C ;-). It 
thus voids the usual guarantee that one cannot do that.



Baring a Python-only module, would this behaviour be possible to add via
a C-language module?


I do not think you will *need* to do this, though you might eventually 
decide to make a custom library with just the functions you want, with 
the names you want.



A module that hooked in to all memory allocation, and inspected the type
of the object being allocated to conditionally add the object's id() to
the list would also suffice.

In either case, if such a module is possible, any pointers you could
provide regarding how to implement such a module would be appreciated.


I hope the above helps. I think Python is a great learning language.

--
Terry Jan Reedy

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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Irmen de Jong

On 04-05-11 20:17, Raymond Hettinger wrote:

Here's a 22-line beauty for a classic and amazing algorithm:
http://bit.ly/bloom_filter

The wiki article on the algorithm is brief and well-written:
http://en.wikipedia.org/wiki/Bloom_filter

It turns out that people in the 1970's were pretty smart :-)



I think that often, the cleverness of people is inversely proportional 
to the amount of CPU power and RAM that they have in their computer.


"Meh, what would I need such a thing for, I could just as well stick 
everything into a list"


Thankfully there are also people for whom this doesn't count.
(are they stuck in the '70s?)

Also: wasn't there a talk on Pycon in which a bloom filter was mentioned?


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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Raymond Hettinger
> > It turns out that people in the 1970's were pretty smart :-)
>
> I think that often, the cleverness of people is inversely proportional
> to the amount of CPU power and RAM that they have in their computer.

The Google guys have plenty of CPU power *and* plenty of
cleverness :-)

According to the wikipedia article, Google BigTable uses Bloom filters
to reduce the disk lookups for non-existent rows or column.  The
Google Chrome web browser also uses Bloom filters to speed up its Safe
Browsing service.


> Also: wasn't there a talk on Pycon in which a bloom filter was mentioned?

Yes!  As a matter of fact there was:
http://www.slideshare.net/c.titus.brown/pycon-2011-talk-ngram-assembly-with-bloom-filters


Raymond

---
follow my other python tips and recipes on twitter:  @raymondh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic interaction with another program

2011-05-04 Thread Terry Reedy

On 5/4/2011 12:34 PM, ETP wrote:

I have a dos program (run in a window) that I would like to control
with a script.


Look at the subprocess module. You may have to (and be able to) have it 
start up the window program with the dos program as an argument.


  It needs only text input.  For example, I only need to

tell it:

L
u
100
u



You should be able to send this through a pipe connected to the subprocess.


--
Terry Jan Reedy

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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Grant Edwards
On 2011-05-04, Irmen de Jong  wrote:
> On 04-05-11 20:17, Raymond Hettinger wrote:
>> Here's a 22-line beauty for a classic and amazing algorithm:
>> http://bit.ly/bloom_filter
>>
>> The wiki article on the algorithm is brief and well-written:
>> http://en.wikipedia.org/wiki/Bloom_filter
>>
>> It turns out that people in the 1970's were pretty smart :-)
>>
>
> I think that often, the cleverness of people is inversely
> proportional to the amount of CPU power and RAM that they have in
> their computer.

True.

Unfortunately the difficulty in debugging and maintaining code is
often directly proportional to the cleverness exhibited by the
original programmer.

-- 
Grant Edwards   grant.b.edwardsYow! I'm also against
  at   BODY-SURFING!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Hans Georg Schaathun wrote:

It only works by assuming
knowledge of C, which is language which has proved unsuitable for
complex and abstract data modelling.


   That statement is untrue; evidenced by the very fact the CPython's 
complex and abstract data modeling has been very suitably handled by C.
   You cannot possibly mean what you have asserted... I realize there 
must be a contextual problem.  I have been handling complex data 
abstractions with C for more than 20 years... its quite well suited to 
the task... although, I am able to do my research today faster and with 
less lines of code in CPython.  That does not in any way impugn C..;. 
quite the contrary, given enough time,  C is better suited for modeling 
on a von Neumann processor, period.


   Here is the thing that everyone forgets... all we have to work with 
is a von Neumann processor. (same as EDVAC, ENIAC, the VIC20, etc). 
Assembler is still the best language on that processor.  'C'  is still 
the best high-level language on that processor.  CPython is implemented 
in C for a reason:  gcc and the von Neumann processor make it a no-brainer.


   Its silly to claim that one high-level language or another is better 
suited to complex data abstraction... don't go there.




Digging down into C should be unnecessary to explain Python.



   huh?   You have to be kidding. Why do you suppose we want it to be 
open-sourced?   Use the force Luke, read the source.   If you really 
want to know how Python is working you *must* dig down into the C code 
which implements it.  The folks who document Python should be able to 
tell us enough to know how to use the language, but to really 'know' you 
need the implementation source.




kind regards,
m harris



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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Paul Rubin
Raymond Hettinger  writes:
> Here's a 22-line beauty for a classic and amazing algorithm:
> http://bit.ly/bloom_filter

The use of pickle to serialize the keys is a little bit suspicious if
there might be a reason to dump the filter to disk and re-use it in
another run of the program.  Pickle representation might change between
Python releases, for example.  It's just supposed to stay interoperable
between versions, not necessarily bitwise-identical.

Otherwise it's quite nice.  I'd suggest adding a .update() operation
that adds keys from a user-supplied iterator.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Hans Georg Schaathun wrote:

In C it is pass by value, as the pointer
is explicit and do whatever you want with the pointer value.


You clearly are not a C programmer.

Most of my C data abstractions use dual circular linked lists of 
pointers to structures of pointers. *All* of that is only ever passed 
(at least in my programming) as references. My code almost never passes 
data by value.


We do not consider passing a pointer as *by value* because its an 
address; by definition, that is pass-by-reference. We are not passing 
the *value* of the data, we are passing the memory location (the 
reference) to the data. Pass by *value* on the other hand actually 
places the *value* of the data item on the call stack as a parameter.


Much of this conversation has more to do with semantics.


kind regards,
m harris




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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Irmen de Jong

On 04-05-11 21:13, Raymond Hettinger wrote:

It turns out that people in the 1970's were pretty smart :-)


I think that often, the cleverness of people is inversely proportional
to the amount of CPU power and RAM that they have in their computer.


The Google guys have plenty of CPU power *and* plenty of
cleverness :-)


Haha, true. We need to add a Googlyness factor in the equation.
Or perhaps: think what they could achieve if they only had a few 
machines instead of thousands ;-)




Also: wasn't there a talk on Pycon in which a bloom filter was mentioned?


Yes!  As a matter of fact there was:
http://www.slideshare.net/c.titus.brown/pycon-2011-talk-ngram-assembly-with-bloom-filters


Thanks, that was the one.

I didn't attend Pycon but I watched a truckload of talks on blip.tv and 
that one caught my attention because of its somewhat funny title

'handling ridiculous amounts of data with probabilistic data structures'

I didn't understand all of it but the name Bloom Filter stuck, it seems. 
 Adding it to my list of bookmarks of 
useful-stuff-I-intend-to-use-one-day-in-the-future...


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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Terry Reedy

On 5/4/2011 2:17 PM, Raymond Hettinger wrote:

Here's a 22-line beauty for a classic and amazing algorithm:
http://bit.ly/bloom_filter

The wiki article on the algorithm is brief and well-written:
http://en.wikipedia.org/wiki/Bloom_filter


As I understand the article, the array of num_bits should have 
num_probes (more or less independent) bits set for each key. But as I 
understand the code


for i in range(self.num_probes):
h, array_index = divmod(h, num_words)
h, bit_index = divmod(h, 32)
yield array_index, 1 << bit_index

the same bit is being set or tested num_probes times. The last three 
lines have no dependence on i that I can see, so they appear to do the 
same thing each time. This seems like a bug.


The article says "For a good hash function with a wide output, there 
should be little if any correlation between different bit-fields of such 
a hash, so this type of hash can be used to generate multiple 
"different" hash functions by slicing its output into multiple bit 
fields. Alternatively, one can pass k different initial values (such as 
0, 1, ..., k − 1) to a hash function that takes an initial value; or add 
(or append) these values to the key." I do not see the code doing either 
of these.


--
Terry Jan Reedy


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Benjamin Kaplan
On Wed, May 4, 2011 at 3:22 PM, harrismh777  wrote:
> Hans Georg Schaathun wrote:
>>
>> It only works by assuming
>> knowledge of C, which is language which has proved unsuitable for
>> complex and abstract data modelling.
>
>   That statement is untrue; evidenced by the very fact the CPython's complex
> and abstract data modeling has been very suitably handled by C.
>   You cannot possibly mean what you have asserted... I realize there must be
> a contextual problem.  I have been handling complex data abstractions with C
> for more than 20 years... its quite well suited to the task... although, I
> am able to do my research today faster and with less lines of code in
> CPython.  That does not in any way impugn C..;. quite the contrary, given
> enough time,  C is better suited for modeling on a von Neumann processor,
> period.
>
>   Here is the thing that everyone forgets... all we have to work with is a
> von Neumann processor. (same as EDVAC, ENIAC, the VIC20, etc). Assembler is
> still the best language on that processor.  'C'  is still the best
> high-level language on that processor.  CPython is implemented in C for a
> reason:  gcc and the von Neumann processor make it a no-brainer.
>

CPython is implemented in C because that's the language chosen. Python
is also implemented in Java, C#, Python, and several other languages.
And it's not tied to the von Neumann architecture either. Only the
current implementations of it are.

>   Its silly to claim that one high-level language or another is better
> suited to complex data abstraction... don't go there.
>
>
>> Digging down into C should be unnecessary to explain Python.
>
>
>   huh?   You have to be kidding. Why do you suppose we want it to be
> open-sourced?   Use the force Luke, read the source.   If you really want to
> know how Python is working you *must* dig down into the C code which
> implements it.  The folks who document Python should be able to tell us
> enough to know how to use the language, but to really 'know' you need the
> implementation source.
>

Reading the CPython sources will show you how CPython works under the
hood, but it has nothing to do with how Python works. There are lots
of things that CPython does that "Python" does not. For instance, the
GIL is not a part of Python. Reference counting is not a part of
Python. Caching small integers and strings is not a part of Python.
Why not read the Jython sources instead of the CPython? It's the same
language, after all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Devin Jeanpierre wrote:

"How was the date last night?"



>  "Oh, it was marvelous! He presented me with a single red stink-weed, and
>  then we went to a disgusting little restaurant. I had the swill."



Please don't argue with me in this manner.


   D'Aprano takes a little getting used to. He likes strawmen, 
red-hearings, and the venerable bogus analogy. Just read around them, he 
usually has some good points in there...



kind regards,
m harris



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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Benjamin Kaplan wrote:

CPython is implemented in C because that's the language chosen. Python
is also implemented in Java, C#, Python, and several other languages.


True enough. If I used Jython, I would want to take a look at those 
sources... as well as the Java sources... which were wrtten in, um,  C.



And it's not tied to the von Neumann architecture either. Only the
current implementations of it are.


   Oh, yes they are.   That is the $10,000,000 dollar problem... how to 
extricate ourselves from the von Neumann processor. *Everthing* comes 
down to that...  its hilarious to hear folks talk about lambda the 
ultimate (especially those guys on Lambda the Ultimate) when there is no 
such thing until such time as we have lambda the hardware architecture. 
 As long as we are all constrained to funnel data through the von 
Neumann ALU, that really is *all* that matters. Another way of saying 
this is that no matter how sophisticated our high level coding gets, it 
all has to be translated somehow one way or another into von Neumann 
codes toggling 1's and 0's on and off in the registers of the von 
Neumann ALU.




Reading the CPython sources will show you how CPython works under the
hood, but it has nothing to do with how Python works.


   Not conceptually, but practically. For instance, for a C programmer 
to see that Python's object references are C void pointers, tells the 
newbie Python ( C programmer ) much about how Python considers 
variables... as references... to objects.



There are lots
of things that CPython does that "Python" does not. For instance, the
GIL is not a part of Python. Reference counting is not a part of
Python. Caching small integers and strings is not a part of Python.


   This is not something I was aware of... caching of small ints is 
unique to CPython implementation only ??  I guess I'll have to go read 
the "sources" of the other implementations to check that out...   ;-)



Why not read the Jython sources instead of the CPython? It's the same
language, after all.


Yep.  Agreed.    on both counts.




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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Wed, 04 May 2011 14:22:38 -0500, harrismh777
   wrote:
:  That statement is untrue; evidenced by the very fact the CPython's 
:  complex and abstract data modeling has been very suitably handled by C.

That's an implementation.  Not modelling.

:  You cannot possibly mean what you have asserted... I realize there 
:  must be a contextual problem.  I have been handling complex data 
:  abstractions with C for more than 20 years...

I did not say that it is impossible.  On the other hand, you are
clearly not talking about abstraction or modelling at all, but
rather about computation or data processing.

: its quite well suited to 
:  the task... although, I am able to do my research today faster and with 
:  less lines of code in CPython.  That does not in any way impugn C..;. 
:  quite the contrary, given enough time,  C is better suited for modeling 
:  on a von Neumann processor, period.

What has that got to do with abstraction?

:  Here is the thing that everyone forgets... all we have to work with 
:  is a von Neumann processor. (same as EDVAC, ENIAC, the VIC20, etc). 
:  Assembler is still the best language on that processor.  'C'  is still 
:  the best high-level language on that processor.  CPython is implemented 
:  in C for a reason:  gcc and the von Neumann processor make it a no-brainer.

Again, what has that got to do with abstraction?

:  Its silly to claim that one high-level language or another is better 
:  suited to complex data abstraction... don't go there.

: 
: > Digging down into C should be unnecessary to explain Python.
: 
:  huh?   You have to be kidding. Why do you suppose we want it to be 
:  open-sourced? 

Python is a /language/.  The /implementation/ is may be open-source
(and may or may not be written in C).

: Use the force Luke, read the source.   If you really 
:  want to know how Python is working you *must* dig down into the C code 
:  which implements it.

Except that whatever you learn by doing so is only valid for that one
interpreter.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Grant Edwards
On 2011-05-04, harrismh777  wrote:
> Hans Georg Schaathun wrote:

>> In C it is pass by value, as the pointer is explicit and do whatever
>> you want with the pointer value.
>
> You clearly are not a C programmer.
>
> Most of my C data abstractions use dual circular linked lists of 
> pointers to structures of pointers. *All* of that is only ever passed
> (at least in my programming) as references. My code almost never
> passes data by value.
>
> We do not consider passing a pointer as *by value* because its an 
> address; by definition, that is pass-by-reference.

No, it isn't.  It's pass by value.  The fact that you are passing a
value that is a pointer to another value is not relevent.

Pass by reference means that if I call

  foo(x)

And foo looks like this:

  foo(param)
param = 4

Then 'x' in the caller's namespace ends up set to 4.

> We are not passing the *value* of the data, we are passing the memory
> location (the reference) to the data.

You're pass a value.  That value is a pointer to some other value.

> Pass by *value* on the other hand actually places the *value* of the
> data item on the call stack as a parameter.

C is pass by value.

if I call foo(x)

And this is foo:

void foo (float param)
{
  param = 1.23
}

The value of x in the caller's namespace is not changed.  If C used
pass by reference, x would change.

-- 
Grant Edwards   grant.b.edwardsYow! S!!  I hear SIX
  at   TATTOOED TRUCK-DRIVERS
  gmail.comtossing ENGINE BLOCKS into
   empty OIL DRUMS ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic interaction with another program

2011-05-04 Thread Dan Stromberg
On Wed, May 4, 2011 at 9:34 AM, ETP  wrote:

> I have a dos program (run in a window) that I would like to control
> with a script.  It needs only text input.
>
> It will then wait for a file to be created, rename the file, then
> loop.  Simple.
>

Or not.


> I'd like to run this on Lucid Puppy Linux as it will be implemented on
> a very old laptop, but can probably deal with windows if needed.
>

Easiest would probably be to do this on Windows - not because of any
inherent value in Windows, but because Microsoft limited what you could do
to protect their own interests.

I believe I once encountered a DOS emulator that could give curses output
for non-graphical (no CGA, Hercules, EGA, or VGA) applications.  It was ages
ago.  It probably was on SCO Xenix.

You could try one of these, and then talk to your program over a serial
port:
http://en.wikipedia.org/wiki/PC_Weasel_2000
...but I wouldn't count on it working well on a laptop.

You could possibly set up a DOS box somewhere, and access it over a network
from your laptop - depending on how the DOS program is doing its I/O.  If
it's writing directly to video RAM, good luck (other than the PC Weasel
option), but if it's disciplined enough to use DOS or the BIOS for I/O, it
might work pretty well.

Your best option, if legally and economically viable, would be to get the
source code to your DOS app and port it (or have it ported) to Linux.  Back
in the DOS days, Some programs were surprisingly easily ported to *ix.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Wed, 04 May 2011 14:33:34 -0500, harrismh777
   wrote:
:  Hans Georg Schaathun wrote:
: > In C it is pass by value, as the pointer
: > is explicit and do whatever you want with the pointer value.
: 
:  You clearly are not a C programmer.

I am not really a programmer period.  I am many things and run
into programming from many more angles than a typical programmer 
does.  And as to C, I no longer use C when I can avoid it (which 
I can most but not all of the time).

A few words are missing though.  C is semantically pass by value.
Always.  But because you have pointers are data object, you can do 
whatever you want with them, and pass a pointer by value.  Thus you
can achieve the effect of transmission by reference or by name, if 
you want to.

:  Most of my C data abstractions use dual circular linked lists of 
:  pointers to structures of pointers. *All* of that is only ever passed 
:  (at least in my programming) as references. My code almost never passes 
:  data by value.

Not if you do not consider pointers as data, but C does, in the sense 
that pointers can be manipulated in the same ways as any other kind of
data.

:  We do not consider passing a pointer as *by value* because its an 
:  address; by definition, that is pass-by-reference. We are not passing 
:  the *value* of the data, we are passing the memory location (the 
:  reference) to the data. Pass by *value* on the other hand actually 
:  places the *value* of the data item on the call stack as a parameter.

That is a useful viewpoint, but it falls a bit short when you need
to explain how to deal with pointers to pointers to pointers.  Pointers
in C are objects.

But mind you, I was not the one to suggested to refer to this 
as pass by value.  I was explaining why it makes more sense to 
do so for C but not for Python.

You simply end up with different wordings if you try to explain how
C works, and how to model data in C.  We can both be right, you know;
we are just addressing the issues at different levels of abstraction.

:  Much of this conversation has more to do with semantics.

Of course.  The concepts are used to explain the semantics of the
languages.  



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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Wed, 04 May 2011 14:58:38 -0500, harrismh777
   wrote:
:   True enough. If I used Jython, I would want to take a look at those 
:  sources... as well as the Java sources... which were wrtten in, um,  C.

And then, suddenly, you'll be developing code which fails on CPython
instead of code which fails on Jython.  Except that it will still 
fail on Jython too, unless you happen to have the right jvm.

Marvelous.

:  Oh, yes they are.   That is the $10,000,000 dollar problem... how to 
:  extricate ourselves from the von Neumann processor. *Everthing* comes 
:  down to that...  its hilarious to hear folks talk about lambda the 
:  ultimate (especially those guys on Lambda the Ultimate) when there is no 
:  such thing until such time as we have lambda the hardware architecture. 

The problem with your approach is that software development does not
scale.  Assembly worked very well with a few 100 lines of codes half
a century ago.  C and friends were a great step forward and reduced
the complexity to allow another magnitude of lines of codes.  Then
came further languages further removed from von Neumann, but close
enough to human cognition to handle yet a magnitude or too.

Of course you can still gain useful understanding by studying assembly
or von Neumann, or the instruction set of the CPU you use.  And in 
some projects it may be an optimal strategy.  However, there are 
many skills necessary to make an efficient system and in many projects
assembly and hardware skills are far down the list.

Virtualisation is there to the cut costs of rethinking solutions for 
multiple architectures.  If you need to understand the implementation
to do your programming, you are in fact disregarding one of the most
significant achievements deployed in computing the last two decades. 

:  Not conceptually, but practically. For instance, for a C programmer 
:  to see that Python's object references are C void pointers, tells the 
:  newbie Python ( C programmer ) much about how Python considers 
:  variables... as references... to objects.

And of course, this is useful as /one/ way to consider python variables.
As long as one is aware that this is just an example, one approach out
of many, then it enhances understanding.  If one blindly extrapolates 
from one implementation, it enhances misunderstanding.


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


Embedding Python's library as zip file

2011-05-04 Thread Wojtek Mamrak
Hello,

I spent a lot of time googling for a solution of this problem, with no
result.

I have a C++ application, in which I would like to embed Python interpreter.
I don't want to rely on an interpreter being installed on user machine,
instead I would like to distribute all the necessary files with my app.

As far as I understand, beside of my executable and Python.dll (I am using
Python27), I need to provide two folders:
 - DLLs,
 - Lib

If I place the Lib folder and the contents of the DLLs folder in a directory
of my executable, then everything seems to work.
However I would like to use a zipped Lib folder. Hence I made an archive
(which contains contents of Lib folder) called Python27.zip. Unfortunately
the app crashes during execution.
I assume the reason might be lack of zlib.pyd. Is that assumption correct?
If so, how to obtain it? If not, what am I doing wrong?

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Grant Edwards wrote:

We do not consider passing a pointer as*by value*  because its an
>  address; by definition, that is pass-by-reference.

No, it isn't.  It's pass by value.  The fact that you are passing a
value that is a pointer to another value is not relevent.



@ Edwards, &Schaathun

You are most definitely mistaken.   See:

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr233.htm


I understand that semantically some people insist that when C receives 
parms as pointers that pass-by-reference is only being simulated.


But that is the silliness of this argument... because down in the guts 
of the ALU we only have direct and indirect memory addressing. Period.


You either pass a function the memory directly (value) or you pass the 
data indirectly (reference).


Everything above that is high-level semantics.


If I want to pass values to my C functions, I can.  If I want to pass 
references to my C functions, I can.


If I want to implement a C language that does not use pointers directly 
(hides them) I can implement pass by reference completely (on the 
surface). In fact, I can implement the C compiler so that pass by value 
is not allowed! [ it wouldn't look much like C, but its do-able ]



Everyone forgets that their high-level language is not 'really' what's 
working...   gcc does not produce machine code... it produces assembler 
instructions that are passed to a translator... you can interrupt the 
process and have it produce the assembly instructions so you can see 
them if you want to...  the point being, after all is said and done, all 
you can do with today's von Neumann processors is pass data directly 
(value) or indirectly (reference).


Everything else is semantics.

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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Raymond Hettinger
On May 4, 12:42 pm, Terry Reedy  wrote:
> On 5/4/2011 2:17 PM, Raymond Hettinger wrote:
>
> > Here's a 22-line beauty for a classic and amazing algorithm:
> >http://bit.ly/bloom_filter
>
> > The wiki article on the algorithm is brief and well-written:
> >http://en.wikipedia.org/wiki/Bloom_filter
>
> As I understand the article, the array of num_bits should have
> num_probes (more or less independent) bits set for each key. But as I
> understand the code
>
>          for i in range(self.num_probes):
>              h, array_index = divmod(h, num_words)
>              h, bit_index = divmod(h, 32)
>              yield array_index, 1 << bit_index
>
> the same bit is being set or tested num_probes times. The last three
> lines have no dependence on i that I can see, so they appear to do the
> same thing each time. This seems like a bug.

The 512 bits in h are progressively eaten-up between iterations.  So
each pass yields a different (array index, bit_mask) pair.

It's easy to use the interactive prompt to show that different probes
are produced on each pass:

>>> bf = BloomFilter(num_bits=1000, num_probes=8)
>>> pprint(list(bf.get_probes('Alabama')))
[(19, 1073741824),
 (11, 64),
 (9, 134217728),
 (25, 1024),
 (24, 33554432),
 (6, 16),
 (7, 16777216),
 (22, 1048576)]

The 512 bits are uncorrelated -- otherwise sha512 wouldn't be much of
a cryptographic hash ;)

The fifty state example in the recipe is a reasonable demonstration
that the recipe works as advertised.  It successfully finds all fifty
states (the true positives) and it tries 100,000 negatives resulting
in only a handful of false negatives.  That should be somewhat
convincing that it all works.


Raymond

---
follow my other python tips and recipes on twitter:  @raymondh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Ben Finney
Steven D'Aprano  writes:

> Given the following statement of Python code:
>
> >>> x = "spam"
>
> what is the value of the variable x?

Mu (無).

‘x’ is a name. Names are bound to values. Talk of “variable” only
confuses the issue because of the baggage carried with that term.

Yes, the Python documentation disagrees with me.

> (1) The string "spam".

> I argue that any answer except for (1) is (almost always) counter-
> productive: it adds more confusion than shedding light.

I prefer to respond “The name ‘x’ is bound to a string, "spam"”.

(If I knew which version of Python we're using, I'd qualify the type as
“a text string” or “a byte string”.)

> It requires thinking at the wrong level, at the implementation level
> instead of the level of Python code. If we define "value" to mean the
> invisible, inaccessible reference, then that leaves no word to
> describe was the string "spam" is.

Fine, the value is the string. No problem there.

But the data model of Python doesn't fit well with the ideas that the
term “variable” connotes for most programmers: a box, perhaps of a rigid
shape (data type) or not, which is labelled ‘x’ and nothing else. For
another variable to have an equal value, that value needs to be copied
and put in a separate box; or perhaps some special reference to the
original needs to be made and placed in a box.

Saying “variable” and “has the value” just invites baggage needlessly,
and creates many assumptions about Python's data model which has to be
un-done, often after much false mental scaffolding has been built on
them by the newbie and needs to be dismantled carefully.

As we all know, Python doesn't work as the term “variable” implies for
many. Rather, ‘x’ isn't a container at all, but an identifier only. It's
more like a paper tag which can be tied to objects; that brings a bunch
of useful implications:

* that the paper tag is tied to only one object

* that a paper tag tied to no object is rather useless

* that many paper tags can be tied to the same object

* that the paper tag is only loosely associated with the object and can
  be removed and tied to a different object, without any change to the
  objects themselves

* that the object doesn't necessarily have any tag at a given point in
  time

* that the tag with its string is useful to find the object even without
  a name on the tag (the concept of other non-name bindings to objects,
  e.g. list items)

All those implications of the “paper tag” analogy are helpful in
thinking about the Python data model. And those implications don't even
have to be explicitly stated in order to help.

So instead of inviting confusion with “variable ‘x’ has the value
"spam"” I prefer to say “name ‘x’ is bound to the value "spam"”.

> The intellectual contortions that some people will go through to
> hammer the square peg of actual programming language behaviour into
> the two round holes of "pass by value" and "pass by reference" never
> cease to astonish me.

I maintain that avoiding the use of the term “variable”, and gently
correcting those who use it in the context of Python (with humility in
the face of the fact that the Python documentation liberally uses the
term), can short-circuit a lot of that needless confusion.

Python isn't pass by anything. Nothing gets copied, nothing gets passed;
when a function is called with an object as a parameter, the object
stays put, and simply gets a new temporary name bound to it for the
function's use.

Speaking of objects (or values) with names bound to them helps that
explanation in a way that the traditional image of “variables” does not.

> > Whatever, a rose by any other name...)
>
> Do you really think that roses would be the symbol of romantic love if 
> they were called "disgusting stink-weeds of perversion and death"?

Juliet's point stands, though: they would still smell as sweet, and the
term you describe would be unlikely to catch on since it doesn't
describe them well at all.

-- 
 \  “I like to fill my bathtub up with water, then turn the shower |
  `\   on and pretend I'm in a submarine that's been hit.” —Steven |
_o__)   Wright |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Developers with 5 years of experience

2011-05-04 Thread Ben Finney
"Jerome jjcpl.rpo"  writes:

> One of our client in New Jersey is looking for Python Developers with
> 5 years of experience. If you have any resumes please send it across.

Please do not solicit for jobs here. Instead, the Python Job Board
http://www.python.org/community/jobs/> is intended for that
purpose.

-- 
 \“The right to search for truth implies also a duty; one must |
  `\  not conceal any part of what one has recognized to be true.” |
_o__) —Albert Einstein |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Hans Georg Schaathun wrote:

That does not in any way impugn C..;.
:  quite the contrary, given enough time,  C is better suited for modeling
:  on a von Neumann processor, period.

What has that got to do with abstraction?


Everything, really.

Folks seem to think that because they are doing abstraction at a 
high-level (well, they never maybe programmed at a lower level) that 
abstraction somehow 'requires' a high level language.  (not true)


Back in the day, our abstractions were encapsulated not in source, but 
in psuedo-code, flow-charts, diagrams, and sometimes pretty pictures. It 
all ended up in assembly and machine code.


Today, high-level languages like Python (and others) allow programmers 
to place some of their abstraction into their source code directly. This 
does not make the high-level language any more 'suited' to abstraction 
than any other lower-level language; because the abstraction is a mental 
process not a language feature. It all ends up in assembly and machine 
code.



kind regards,
m harris



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


Re: What other languages use the same data model as Python?

2011-05-04 Thread John Nagle

On 5/4/2011 3:51 AM, Steven D'Aprano wrote:

On Wed, 04 May 2011 02:56:28 -0700, Devin Jeanpierre wrote:


Python is pass-by-value in a
meaningful sense, it's just that by saying that we say that the values
being passed are references/pointers. This is maybe one level of
abstraction below what's ideal,


"Maybe"?

Given the following statement of Python code:


x = "spam"


what is the value of the variable x? Is it...?

(1) The string "spam".

(2) Some invisible, inaccessible, unknown data structure deep in the
implementation of the Python virtual machine, which the coder cannot
access in any way using pure Python code.

(Possibly a pointer, but since it's an implementation detail, other
implementations may make different choices.)

(3) Something else.


I argue that any answer except for (1) is (almost always) counter-
productive: it adds more confusion than shedding light. It requires
thinking at the wrong level, at the implementation level instead of the
level of Python code. If we define "value" to mean the invisible,
inaccessible reference, then that leaves no word to describe was the
string "spam" is.

(I say "almost always" counter-productive because abstractions leak, and
sometimes you do need to think about implementation.)


   Yes.  In Python, the main leak involves the "is" operator and the 
"id()" function.  Consider:


>>> x = "spam"
>>> y = "spam"
>>> x == y
True
>>> x is y
True
>>> z = x + 'a'
>>> z = z[:4]
>>> z
'spam'
>>> x is z
False
>>> x == z
True
>>> id(x)
30980704
>>> id(y)
30980704
>>> id(z)
35681952

There, the abstraction has broken down.  x, y, and z all reference
the value "spam", but they reference two, not one or three, instances
of it.

   Arguably, Python should not allow "is" or "id()" on
immutable objects.  The programmer shouldn't be able to tell when
the system decides to optimize an immutable.

"is" is more of a problem than "id()"; "id()" is an explicit peek
into an implementation detail.  The "is" operator is a normal
part of the language, and can result in weird semantics.  Consider

>>> 1 is (1+1-1)
True
>>> 10 is (10+1-1)
False

That's a quirk of CPython's boxed number implementation.   All
integers are boxed, but there's a set of canned objects for
small integers.  CPython's range for this is -5 to +256,
incidentally.  That's visible through the "is" operator.
Arguably, it should not be.

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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Raymond Hettinger
On May 4, 12:27 pm, Paul Rubin  wrote:
> Raymond Hettinger  writes:
> > Here's a 22-line beauty for a classic and amazing algorithm:
> >http://bit.ly/bloom_filter
>
> The use of pickle to serialize the keys is a little bit suspicious if
> there might be a reason to dump the filter to disk and re-use it in
> another run of the program.  Pickle representation might change between
> Python releases, for example.  It's just supposed to stay interoperable
> between versions, not necessarily bitwise-identical.
>
> Otherwise it's quite nice.  I'd suggest adding a .update() operation
> that adds keys from a user-supplied iterator.

I chose pickle because it solved the problem of turning arbitrary
objects into bytes which are needed as inputs to sha512.

It seems that this particular choice of hash function is distracting
some readers away from the interesting part of how a Bloom filter
works.

Since the choice of hash functions is completely arbitrary, I'm
thinking of substituting something a little more basic.  What do you
think of this alternative as a way to make it clearer that each
successive probe is uncorrelated, yet fully dependent on the key?

def get_probes(self, key):
hasher = Random(key).randrange
num_words = len(self.arr)
for _ in range(self.num_probes):
array_index = hasher(num_words)
bit_index = hasher(32)
yield array_index, 1 << bit_index


Raymond
---

follow my other python tips and recipes on twitter:  @raymondh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Grant Edwards
On 2011-05-04, harrismh777  wrote:
> Grant Edwards wrote:
>>> We do not consider passing a pointer as*by value*  because its an
>>> >  address; by definition, that is pass-by-reference.
>> No, it isn't.  It's pass by value.  The fact that you are passing a
>> value that is a pointer to another value is not relevent.
>>
>
> @ Edwards, &Schaathun
>
> You are most definitely mistaken.

The "pass by value" and "pass by reference" parameter passing
mechanisms are pretty well defined, and C uses "pass by value".

> I understand that semantically some people insist that when C
> receives parms as pointers that pass-by-reference is only being
> simulated.

And they are right.

> If I want to pass values to my C functions, I can.  If I want to pass 
> references to my C functions, I can.

We're not talking about what _you_ do. We're talking about what the C
_compiler_ does.  The C compiler passes by value -- always.

> If I want to implement a C language that does not use pointers directly 
> (hides them) I can implement pass by reference completely (on the 
> surface).

That wouldn't be C.

> In fact, I can implement the C compiler so that pass by value is not
> allowed! [ it wouldn't look much like C, but its do-able ]

If you don't pass by value, it's not a C compiler.

> Everyone forgets that their high-level language is not 'really'
> what's working...  gcc does not produce machine code... it produces
> assembler instructions that are passed to a translator... you can
> interrupt the process and have it produce the assembly instructions
> so you can see them if you want to...  the point being, after all is
> said and done, all you can do with today's von Neumann processors is
> pass data directly (value) or indirectly (reference).

I have no idea what your point is.

At the machine level, there _is_ nothing but values.  You can use a
value as an integer, or as a pointer.  It's still just a value.  But
we're talking about parameter passing mechanisms defined by high-level
language specifications -- particularly C.

-- 
Grant Edwards   grant.b.edwardsYow! It was a JOKE!!
  at   Get it??  I was receiving
  gmail.commessages from DAVID
   LETTERMAN!!  !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding Python's library as zip file

2011-05-04 Thread Ian Kelly
On Wed, May 4, 2011 at 3:09 PM, Wojtek Mamrak  wrote:
> Hello,
>
> I spent a lot of time googling for a solution of this problem, with no
> result.
>
> I have a C++ application, in which I would like to embed Python interpreter.
> I don't want to rely on an interpreter being installed on user machine,
> instead I would like to distribute all the necessary files with my app.
>
> As far as I understand, beside of my executable and Python.dll (I am using
> Python27), I need to provide two folders:
>  - DLLs,
>  - Lib
>
> If I place the Lib folder and the contents of the DLLs folder in a directory
> of my executable, then everything seems to work.
> However I would like to use a zipped Lib folder. Hence I made an archive
> (which contains contents of Lib folder) called Python27.zip. Unfortunately
> the app crashes during execution.
> I assume the reason might be lack of zlib.pyd. Is that assumption correct?
> If so, how to obtain it? If not, what am I doing wrong?

I believe zlib.pyd is statically linked into python27.dll nowadays.
Some things to check:

Can you import from zip files when running the Python.exe interpreter?
Is the zip file included in sys.path?  You might need to add this
yourself after callying Py_Initialize().
Is there a top-level directory in the zip file that may be throwing
the importer off?
Are you getting any sort of error message?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic interaction with another program

2011-05-04 Thread ETP
Thanks everyone.

I actually ran the program in question using Wine compatibility layer
and it seemed to work fine.

Terry, that looks like it could be useful, too.  I'll give it a shot
and let you guys know how it works.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Ian Kelly
On Wed, May 4, 2011 at 3:35 PM, harrismh777  wrote:
> Grant Edwards wrote:
>>>
>>> We do not consider passing a pointer as*by value*  because its an
>>> >  address; by definition, that is pass-by-reference.
>>
>> No, it isn't.  It's pass by value.  The fact that you are passing a
>> value that is a pointer to another value is not relevent.
>>
>
> @ Edwards, &Schaathun
>
> You are most definitely mistaken.   See:
>
> http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr233.htm

That source actually supports the claim that pass-by-pointer falls
under pass-by-value.  It reads, in part (emphasis added):

> In C++, the reference parameters are initialized with the actual arguments 
> when the function is called. In C, the pointer parameters > are initialized 
> with pointer _values_ when the function is called.

However, I hope we can all agree that pass-by-pointer shares certain
features with both pass-by-value and pass-by-reference, and there are
perfectly reasonable arguments for lumping it in either category, yes?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Today's fun and educational Python recipe

2011-05-04 Thread Ben Finney
Grant Edwards  writes:

> On 2011-05-04, Irmen de Jong  wrote:
> > I think that often, the cleverness of people is inversely
> > proportional to the amount of CPU power and RAM that they have in
> > their computer.
>
> True.
>
> Unfortunately the difficulty in debugging and maintaining code is
> often directly proportional to the cleverness exhibited by the
> original programmer.

+1 QOTW

-- 
 \“Without cultural sanction, most or all of our religious |
  `\  beliefs and rituals would fall into the domain of mental |
_o__) disturbance.” —John F. Schumaker |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


[OT]: PiCloud - really cool!

2011-05-04 Thread James Mills
If anyone hasn't seen this yet, I encourage you to!
(I stumbled upon it with some random thoughts and Gooogling)

http://www.picloud.com/

Here's a quick test I wrote up that works locally using the simulator
and live (I did run it live):

#!/usr/bin/env python

import cloud

def fib(n):
a, b, = 1, 1
while n > 1:
a, b = b, a + b
n -= 1
return b

#cloud.start_simulator()

jobs = cloud.map(fib, range(100))

print [cloud.result(job) for job in jobs]

Enjoy! :)

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT]: PiCloud - really cool!

2011-05-04 Thread geremy condra
On Wed, May 4, 2011 at 5:13 PM, James Mills
 wrote:
> If anyone hasn't seen this yet, I encourage you to!
> (I stumbled upon it with some random thoughts and Gooogling)
>
> http://www.picloud.com/
>
> Here's a quick test I wrote up that works locally using the simulator
> and live (I did run it live):
>
> #!/usr/bin/env python
>
> import cloud
>
> def fib(n):
>    a, b, = 1, 1
>    while n > 1:
>        a, b = b, a + b
>        n -= 1
>    return b
>
> #cloud.start_simulator()
>
> jobs = cloud.map(fib, range(100))
>
> print [cloud.result(job) for job in jobs]
>
> Enjoy! :)

I was the poster across from them at PyCon two years back. Pretty fun
to play with, although last I checked it was hard to do true HPC on
it.

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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Terry Reedy

On 5/4/2011 5:39 PM, Raymond Hettinger wrote:


The 512 bits in h are progressively eaten-up between iterations.  So
each pass yields a different (array index, bit_mask) pair.


Yeh, obvious now that I see it.


It's easy to use the interactive prompt to show that different probes
are produced on each pass:


bf = BloomFilter(num_bits=1000, num_probes=8)
pprint(list(bf.get_probes('Alabama')))

[(19, 1073741824),
  (11, 64),
  (9, 134217728),
  (25, 1024),
  (24, 33554432),
  (6, 16),
  (7, 16777216),
  (22, 1048576)]


Should have tried that.


The 512 bits are uncorrelated -- otherwise sha512 wouldn't be much of
a cryptographic hash ;)



The fifty state example in the recipe is a reasonable demonstration
that the recipe works as advertised.  It successfully finds all fifty
states (the true positives) and it tries 100,000 negatives resulting
in only a handful of false negatives.


I presume you mean 'false positives', as in the program comment and 
Wikipedia.


The test would be more convincing to many with 10 other geographic 
names (hard to come by, I know), or other english names or words or even 
with longer random strings that matched the lengths of the state names. 
But an average of 5/10 false positives in 5 runs is good.


--
Terry Jan Reedy

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


Re: [OT]: PiCloud - really cool!

2011-05-04 Thread James Mills
On Thu, May 5, 2011 at 10:19 AM, geremy condra  wrote:
> I was the poster across from them at PyCon two years back. Pretty fun
> to play with, although last I checked it was hard to do true HPC on
> it.

Why's that ? And what is true HPC (High Performance Computing) anyway ?
I find the API provided to be quite simple robust and potentially very
powerful - depending on your application.

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT]: PiCloud - really cool!

2011-05-04 Thread geremy condra
On Wed, May 4, 2011 at 5:29 PM, James Mills
 wrote:
> On Thu, May 5, 2011 at 10:19 AM, geremy condra  wrote:
>> I was the poster across from them at PyCon two years back. Pretty fun
>> to play with, although last I checked it was hard to do true HPC on
>> it.
>
> Why's that ? And what is true HPC (High Performance Computing) anyway ?
> I find the API provided to be quite simple robust and potentially very
> powerful - depending on your application.

Last time I checked- and again, it's been a while- you were basically
just able to run some (probably computationally bound) function on an
EC2 instance that they managed for you without having any of the muss
and fuss of doing it yourself. That's very cool, but there are
problems where you really need more horsepower than a normal EC2
instance can provide, and if your application crosses that boundary
after you've written it against PiCloud you're probably in the same
hole you would have been without PiCloud. The other limitation is with
problems that take a lot of input data, where it's more time intensive
to ship the data across to EC2 than it is to just process it locally.

Once more for effect: I haven't played with this in a while, the guys
who built it seem pretty sharp, and it wouldn't surprise me at all to
find out that they have ways of dealing with this better now.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

John Nagle wrote:

Arguably, Python should not allow "is" or "id()" on
immutable objects.  The programmer shouldn't be able to tell when
the system decides to optimize an immutable.

"is" is more of a problem than "id()"; "id()" is an explicit peek
into an implementation detail.


Yes, yes, yes...  and I'll go you one more...

... Python should optimize on *all* immutables when possible.


For instance:

a = (1,2,3)
b = (1,2,3)

a == b  True

a is b  False

   To be consistent, in this case and others, a and b should reference
the same immutable tuple.


Or, as stated earlier, Python should not allow 'is' on immutable objects.


kind regards,
m harris

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Ian Kelly wrote:

However, I hope we can all agree that pass-by-pointer shares certain
features with both pass-by-value and pass-by-reference, and there are
perfectly reasonable arguments for lumping it in either category, yes?


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Grant Edwards wrote:

The "pass by value" and "pass by reference" parameter passing
mechanisms are pretty well defined, and C uses "pass by value".


Yeah, that's kind-a funny, cause I'm one of the guys (old farts) that 
helped define them



The problem you're having here is that you're thinking of parameter 
passing 'mechanisms' and not focusing on the definition of the terms.


A reference is a pointer (an address).

A value is memory (not an address).


These definitions go all the way back before the 8080, or the 6502, 8 
bit processors. Pass by reference has 'always' meant pass by using a 
memory address (indirect addressing);  a reference has always been a 
memory pointer.



If I call a function in C, and pass-by-value, the data's 'value' is 
placed on the stack in a stack-frame, as a 'value' parm... its a copy of 
the actual data in memory.


If I call a function in C, and pass-by-reference, the data's 'address' 
is placed on the stack in a stack-frame, as a 'reference' parm... no 
data is copied and the function must de-reference the pointer to get to 
the data   this is by definition.




There may be some language somewhere that does pass-by-reference which 
is not implemented under the hood as pointers, but I can't think of 
any...   'cause like I've been saying, way down under the hood, we only 
have direct and indirect memory addressing in today's processors. EOS.


If you pass a parm, you can either pass a copy (value) or pass a 
reference to its location (not a copy, a reference).



kind regards,
m harris




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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Raymond Hettinger
On May 4, 5:26 pm, Terry Reedy  wrote:
> The test would be more convincing to many with 10 other geographic
> names (hard to come by, I know), or other english names or words or even
> with longer random strings that matched the lengths of the state names.
> But an average of 5/10 false positives in 5 runs is good.

I've just posted an update with a spell checker using a large
dictionary.  That should make it easy to validate against some real
world text samples.


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Mark Hammond

On 5/05/2011 11:11 AM, harrismh777 wrote:


The "pass by value" and "pass by reference" parameter passing
mechanisms are pretty well defined, and C uses "pass by value".


Yeah, that's kind-a funny, cause I'm one of the guys (old farts) that helped 
define them


Cool - please tell us more about your involvement in that.  Obviously 
lots of people were in the industry then, but only a select few would be 
able to claim they helped define those terms.



There may be some language somewhere that does pass-by-reference which
is not implemented under the hood as pointers, but I can't think of
any... 'cause like I've been saying, way down under the hood, we only
have direct and indirect memory addressing in today's processors. EOS.


What about Python, where passing an integer to a function passes a 
pointer to an int object, but that function is able to change the value 
of the variable locally without changing the passed object (indeed, it 
is impossible to change the passed integer)?


So given the definitions above, Python uses a by-reference mechanism but 
(in some cases) has by-value semantics.


While I understand exactly how things work (so don't need an 
explanation), the point is that for anything close to a high-level 
language, things aren't as black and white as they are for the low-level 
languages...


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


Re: Today's fun and educational Python recipe

2011-05-04 Thread Chris Angelico
On Thu, May 5, 2011 at 5:02 AM, Irmen de Jong  wrote:
> I think that often, the cleverness of people is inversely proportional to
> the amount of CPU power and RAM that they have in their computer.

As Mark Rosewater is fond of saying, restrictions breed creativity.
Lack of computational resources is a major restriction (for an extreme
example of RAM shortage, look at how much code you can fit into a boot
sector without loading anything more from the disk). Take away all the
restrictions, and people will tend to code sloppily.

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


Re: importing class objects from a pickled file

2011-05-04 Thread Gregory Ewing

Catherine Moroney wrote:

I am having some problems reading the 
object back out, as I get complaints about "unable to import module X".


The only way I have found around it is to run the read-file code out of 
the same directory that contains the X.py file


Even when I put statements into the code such as "from Y.X import X" ...
the import statement works, but I am still unable to read the object


Is the program that reads the pickle file the same one that
was used to write it?

If not, what might be happening is that the writing program
has module X at the top level instead of inside package Y.
Then it will get pickled simply under the name "X" instead
of "Y.X", and the reading program will expect to find it at
the top level as well.

It's important that the reading and writing programs agree
about the location of the pickled classes in the package
namespace, unless you take steps to customise the pickling
process.

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


Re: Fibonacci series recursion error

2011-05-04 Thread Gregory Ewing

Chris Angelico wrote:


There's definitely something attractive about that letter. Lots of
programming languages' names start with P.


Including one I invented some years ago, that (in the spirit
of C and its derivatives) was called simply "P".

(I was playing around with Sun's NeWS window server, which
was programmed in Postscript, and I got fed up with Forth-like
syntax, so I wrote a translator that took an infix language and
generated Postscript from it.)

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Chris Angelico
On Thu, May 5, 2011 at 7:43 AM, Ben Finney  wrote:
> * that the paper tag is tied to only one object
>
> * that a paper tag tied to no object is rather useless
>
> * that many paper tags can be tied to the same object

I disagree minorly; a tag tied to no object is quite useful in some
circumstances. You can ditch the concept by having a special object
that's called "No Object" (Python does this, with None), or you can
allow your tag to point nowhere (C does this, with null pointers). The
difference is semantic; either way, your tag can point to any object
or it can point nowhere. (Pike goes for a slightly different approach;
any variable, regardless of its stated types, may legally hold the
integer 0. It acts somewhat as a null pointer, but it isn't really.)

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


Re: Hooking into Python's memory management

2011-05-04 Thread Gregory Ewing

Daniel Neilson wrote:

 1) Maintain a list of object id()'s for objects that have been created. 
Ideally, this list would also contain the file & line number where the 
object was created.


 2) Provide a "deallocate" function that will remove a given object's 
id() from the list from (1).


 3) Print out an error message if the python script terminates with a 
non-empty list from (1). Preferably with a list of objects that are 
still "allocated."


I don't think this will work out quite the way you seem to be
imagining. Consider that Python creates a lot of objects behind
the scenes without you doing anything specific to "allocate"
them. Examples include the dicts holding module and class
namespaces, all the strings representing names in loaded code,
ints, floats and strings representing literals in the code,
etc.

If you automatically add any object of any of these types
to the "allocated" list, these implicitly-created objects will
all still be present in it when the program terminates, and
the student will be told off for failing to deallocate them.

An alternative might be to provide an allocate() function which
the student is expected to use on any explicitly-created object.
But there wouldn't be any way of enforcing this.

Personally I think the whole idea is misguided, and it would be
better to teach these concepts in the context of a language
where they actually matter, which these days more or less
means C. If teaching C in the first year in parallel with
Python is considered too steep, then leave explicit memory
management until later in the curriculum.

(It's really a shame that Pascal is not taught any more. It
provided a fairly clean environment for teaching about things
like this, without getting so close to the machine that you
get your nosed rubbed in segfaults.)

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Tim Roberts
harrismh777  wrote:
>
>If I call a function in C, and pass-by-value, the data's 'value' is 
>placed on the stack in a stack-frame, as a 'value' parm... its a copy of 
>the actual data in memory.
>
>If I call a function in C, and pass-by-reference, the data's 'address' 
>is placed on the stack in a stack-frame, as a 'reference' parm... no 
>data is copied and the function must de-reference the pointer to get to 
>the data   this is by definition.

This is not correct.  Consider an example.

  int BumpMe( int * a )
  {
  return *a+3;
  }

  int Other()
  {
  int x = 9;
  return BumpMe( &x );
  }

That is not an instance of passing an "int" by reference.  That is an
instance of passing an "int *" by value.  The fact that the parameter "a"
in BumpMe happens to be an address is completely irrelevent to the
definition of the parameter passing mechanism.

C has pass-by-value, exclusively.  End of story.

>There may be some language somewhere that does pass-by-reference which 
>is not implemented under the hood as pointers, but I can't think of 
>any... 

Fortran had genuine pass-by-reference.  In Fortran, you could write a
program like this:

   SUBROUTINE CONFUSION(IVALUE)
   INTEGER IVALUE
   IVALUE = IVALUE + 1
   END

   PROGRAM MAIN
   CONFUSION(4)
   END

That program would actually modify the value of the constant 4.  Such an
abomination is simply not possible in C.  Is that implemented
under-the-hood with pointers/addresses?  Of course it is.  However, that
does not change the parameter passing model as defined by the language
specification.
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread Gregory Ewing

Hans Georg Schaathun wrote:

Is transmission by name the same as call by object?


No, it's not. With call-by-name, the caller passes a
small function (known as a "thunk") that calculates the
address of the parameter. Every time the callee needs to
refer to the parameter, it evaluates this function.

This allows some neat tricks, but it's massive overkill
for most uses. In later languages, the functionality of
call-by-name has been replaced by the ability to explicitly
pass functions as parameters.


Anyway, I have never seen anyone counting more than
three ways of doing this ...


There are other possibilities, such as value-result,
where a local copy is made and its final value is
copied back before returning. I think Fortran is
defined in such a way that this is an acceptable way
of implementing parameter passing. It's also the
only way of getting anything akin to by-reference
over an RPC connection.

But for most situations, by-value and by-reference
cover anything you might want to do. And if you
have a dynamic data model like Python, you don't
even need by-reference.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Mark Hammond wrote:

What about Python, where passing an integer to a function passes a
pointer to an int object, but that function is able to change the value
of the variable locally without changing the passed object (indeed, it
is impossible to change the passed integer)?

So given the definitions above, Python uses a by-reference mechanism but
(in some cases) has by-value semantics.


   Yeah, Mark, the trouble is that the concepts (by-value, or 
by-reference) have morphed into a concept(s) that say something of what 
should or should not happen within scopes (or, in the case of Python, 
namespaces) and says something less about what 'reference' or 'value' 
mean as terms for data. So, again, its semantics... not black and white, 
as you say and some of both|and.


   If C were 'strictly' pass-by-value (that is what the K&R states, 
sec. 1.8, p27 2nd ed) and had no concept of indirect memory addressing 
(memory references is what we called them in the early days ca. 1970~) 
in the form of pointers, then all of this semantic discussion would be 
mute. But, 'C' does provide for pointers which are used by all 'C' 
programmers to firmly provide pass-by-reference in their coding (C++ 
also, by the way). My 'C' functions can most definitely modify the parms 
passed in from their calling functions by simply 'de-referencing' the 
parms. This is done all the time--- and a good thing too, since nobody 
would want to pass a list by value, or worse yet a linked list with a 
couple of thousand nodes, by value.


   So, I argue that its silly to say that because the parameter passing 
'mechanism' of the 'C' language is pass-by-value (see K&R) that 'C' is a 
pass-by-value language, when clearly 'C' programmers use 
pass-by-reference routinely in their 'C' coding. This is quite different 
than some flavors of Fortran or Pascal where the called routines had 
access to the original vars--- which had more to do with scope than it 
did with parameter passing or indirection. In 'C' if I want to I can 
live with pass-by-value... or, I can live with pass-by-reference 
nicely... and its up to me... not language constraints. Again, it seems 
that some folks want to pigeon hole this concept into one or the other 
(and it clearly can be) but usually it is a combination of the two (both 
| and).


kind regards,
m harris

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


Re: Hooking into Python's memory management

2011-05-04 Thread scattered
On May 4, 12:51 pm, Daniel Neilson  wrote:
> Hello,
>   I'm hoping that there will be someone here with sufficient expertise
> to answer a question on Python 3 for me.
>
>   I work in the Computer Science department at a large Canadian
> University. We are currently doing a feasibility analysis for switching
> to using Python in our first year major-stream courses.
>
>   Part of our first year curriculum requires that students be exposed to
> explicit dynamic memory allocation in the form of C++'s new/delete, C's
> malloc/free, etc. I realize that Python is garbage collected, and that
> there is never a need to explicitly allocate & deallocate objects.
> However, I am trying to determine whether or not it is possible to
> simulate that behaviour within Python via a module for the purposes of
> instruction.
>
>   For these purposes, I would like to know whether it is possible within
> Python 3 to write a Python-only module that, essentially, hooks into the
> "constructor" and "destructor" of many of the Python built-in types
> (specifically list, dictionary, set, tuple, and string) so that the
> module can:
>   1) Maintain a list of object id()'s for objects that have been
> created. Ideally, this list would also contain the file & line number
> where the object was created.
>   2) Provide a "deallocate" function that will remove a given object's
> id() from the list from (1).
>   3) Print out an error message if the python script terminates with a
> non-empty list from (1). Preferably with a list of objects that are
> still "allocated."
>
>   Baring a Python-only module, would this behaviour be possible to add
> via a C-language module?
>
>   A module that hooked in to all memory allocation, and inspected the
> type of the object being allocated to conditionally add the object's
> id() to the list would also suffice.
>
>   In either case, if such a module is possible, any pointers you could
> provide regarding how to implement such a module would be appreciated.
>
> Thank you for your time,
>   Daniel

Maybe you can simulate a heap. Create a heap class where a heap-object
maintains an internal list of fixed length (whose length is determined
by a constructor)for its heap and a list of free blocks in this heap.
It can have methods for allocating and deallocating objects in the
heap. Perhaps some sort of dictionary with strings representing
pointers as keys and indices of corresponding allocated blocks as
values. Subscript-out of range errors in the internal heap would
correspond to segmentation errors. The heap-class could catch this
error and inform the student. It could also have methods which catch
things like dangling pointers and memory leaks. Perhaps a method to
display a schematic of the heap. Maybe something as simple as printing
something like

   ||||__|||__

where ||| represents used blocks and  represents free space.
Displaying this could show the problem of heap-fragmentation.

Once you get the interface down - assign some homework where the
students need to implement a simple algorithm which requires dynamic
memory alocation. The catch is that the students are forbidden from
using things like Python lists directly in their code but instead have
to get by with using a single instance of this heap object for their
data storage needs. Make a bit of a game out of it.

I obviously haven't worked out the details, but I suspect that this
sort of thing is both easier and more pedagogically sound (since you
can tailor the error messages) then what you were looking for.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-04 Thread John Nagle

On 5/4/2011 5:46 PM, harrismh777 wrote:

John Nagle wrote:

Arguably, Python should not allow "is" or "id()" on
immutable objects. The programmer shouldn't be able to tell when
the system decides to optimize an immutable.

"is" is more of a problem than "id()"; "id()" is an explicit peek
into an implementation detail.


Yes, yes, yes... and I'll go you one more...

... Python should optimize on *all* immutables when possible.


For instance:

a = (1,2,3)
b = (1,2,3)

a == b True

a is b False

To be consistent, in this case and others, a and b should reference
the same immutable tuple.


Actually, that's not necessarily an "optimization".  The cost of
looking up small tuples is probably higher than creating them.
There's also a potential optimization of duplicating tuples in
use by different threads, to reduce locking effort.  (CPython's
global lock is too dumb to exploit this, but there are other ways
to do it.)



Or, as stated earlier, Python should not allow 'is' on immutable objects.


   A reasonable compromise would be that "is" is treated as "==" on
immutable objects.

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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Tim Roberts wrote:

The fact that the parameter "a"
in BumpMe happens to be an address is completely irrelevent to the
definition of the parameter passing mechanism.

C has pass-by-value, exclusively.  End of story.


Yeah, Tim, I know... but that's my entire point in a nut-shell... 
whether the language is pass-by-value or pass-by-reference has less to 
do with how it is 'defined' (its mechanism--- indirection and stack) and 
more to do with how it is routinely used with the standard features it 
provides--- in this case memory indirection--- as pointers.


Something new here, just for fun...

... I ran my hello.c program through the gcc compiler and intercepted 
its assembly source output. Some folks on the list may not know that the 
gcc compiler used to generate CPython (at least on *nix systems) does 
not generate object or machine code directly, but generates an 
intermediate assembly source in AT&T syntax.   The assembly code is 
interesting for the discussion, if you've never seen it. If you have, 
blow this off.


   Anyway, I built a small wrapper called 'say()' around the printf 
function, so that I could pass a string var to say(), and I then called 
it a couple of times in main(). The assembly source code is listed at 
the end of this post. The thing to notice here is two things:
   1) assembly code is actually being used to generate the machine 
code, not 'C' (and this is true for Python as well, compiled from 
sources) In other words, Python interpreter does not do anything more 
(nor less) than what can be done with assembler (nor machine code for 
that matter).  And,
   2) The strings I am 'passing' to the say() function don't get 
'passed' anywhere. (I know that most of you know this, bear with me) The 
strings are set in memory, and through memory indirection pointers (the 
parenthesis 'references') the string's memory addresses are placed on 
the stack. The called routine say() has full access to the original 
strings in memory (via their memory addresses) if necessary. The main 
point being that the say() function has a 'reference' to the original, 
and not a local copy of the 'value', and it can change it!  The string's 
addresses are .LC0 and .LC1/


Here is the assembly of my hello.c  saved as hello.s with:

   gcc -Wall -S -o hello.s hello.c


.file   "hello.c"
.section.rodata
.LC0:
.string "\nhello, world!\n"
.align 4
.LC1:
.string "...and again I say, hello there, world!\n\n"
.text
.globl main
.type   main, @function
main:
pushl   %ebp
movl%esp, %ebp
andl$-16, %esp
subl$32, %esp
movl$0, 28(%esp)
movl$.LC0, (%esp)
callsay
movl$.LC1, (%esp)
callsay
movl28(%esp), %eax
leave
ret
.size   main, .-main
.section.rodata
.LC2:
.string "%s"
.text
.globl say
.type   say, @function
say:
pushl   %ebp
movl%esp, %ebp
subl$24, %esp
movl$.LC2, %eax
movl8(%ebp), %edx
movl%edx, 4(%esp)
movl%eax, (%esp)
callprintf
leave
ret
.size   say, .-say
.ident  "GCC: (Ubuntu 4.4.1-4ubuntu9) 4.4.1"
.section.note.GNU-stack,"",@progbits


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


Re: What other languages use the same data model as Python?

2011-05-04 Thread Hans Georg Schaathun
On Thu, 05 May 2011 15:48:51 +1200, Gregory Ewing
   wrote:
:  No, it's not. With call-by-name, the caller passes a
:  small function (known as a "thunk") that calculates the
:  address of the parameter. Every time the callee needs to
:  refer to the parameter, it evaluates this function.

Well, call-by-name is not the same as transmission by name either.
Transmission by name is what most posters here call call by
reference, and transmission by reference is what this thread calls
object sharing or call by object.

No wonder I started off confused :-)  It is better now.



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


Re: What other languages use the same data model as Python?

2011-05-04 Thread harrismh777

Dennis Lee Bieber wrote:

>  We do not consider passing a pointer as*by value*  because its an
>  address; by definition, that is pass-by-reference. We are not passing

To most of the world, pass-by-reference means the COMPILER, not the
PROGRAMMER is obtaining and passing the address, and the compiler also
always dereferences the passed "value"... The programmer has no control
over whether to operate on the address or the data referenced by the
address.


Who is "most of the world" ?Please see:

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr233.htm


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


  1   2   >