Re: python3: 'where' keyword

2005-01-08 Thread Carl Banks
Nick Coghlan wrote:
 Andrey Tatarinov wrote:
  Hi.
 
  It would be great to be able to reverse usage/definition parts in
  haskell-way with where keyword. Since Python 3 would miss lambda,
that
  would be extremly useful for creating readable sources.
 
  Usage could be something like:
 
res = [ f(i) for i in objects ] where:
def f(x):
#do something

[snip]
 For compound statements, a where clause probably isn't appropriate,
as it would
 be rather unclear what the where clause applied to.

Right.  But you know that as soon as you add this to simple
expressions, a bunch of people are going to come here whining about how
they don't get to use where with if-expressions.

Frankly, they might have a point here.  Although we have replacing
lambda expressions on our minds, I have in mind a different problem
that a where-statement would solve perfectly.  But it would have to be
used with an if-expression.

However, I think it might not be so hard.  Let's take Paul Rubin's
advice and precede the if statement with where.  Let's also allow
elif clauses to be replaced with else where ... if clauses.  That
which is bound in the while-block would be visible in both the
if-expression and if-block.

Then we could do this:

. where:
. m = someregexp.match(somestring)
. if m:
. blah blah blah
. else where:
. m = someotherregexp.match(somestring)
. if m:
. blah blah blah

We might want to spell else where instead as elwhere, to match
elif, but that's not important now.  This would take away one of the
major minor annoyances of Python.  (In fact, I've suggested something
like this as a solution to the set-and-test idiom, which Python makes
difficult, only I used the keyword suppose instead of where.)

Ok, but if you do that, now you have people whining that where comes
after some expressions, and before others.  (This would not bother me
one bit, BTW, but I'm pretty sure I'd lose the popular vote on this
one.)

So, let's go all out and say that while could precede any statement.
We now have consistency.  Well, that really wouldn't work for the
if-statement, though, because then how could we apply a different
while-block to an else clause?  We'd have to treat if-statements
specially anyways.  So we don't have consistency.

My solution would be to propose two different where statements: a
where...do statement, and a separate where...if statement.  The
where...do statement would look like this:

. where:
. def whatever(): pass
. do:
. blah blah use whatever blah

It has the advantage of being able to apply the where bindings to
several statements, and is, IMO, much cleaner looking than simply
applying where's bindings to the single following unindented statement.

I would recommend against where...while and where...for statements.
They can't accomplish anything you couldn't do with a break statement
inside the block, and it's not obvious whether the where clause gets
executed once or for each loop (since it's physically outside the loop
part).

One question: what do you do with a variable bound inside a while-block
that has the same name as a local variable?  (Or, horrors, a
surrounding while-block?)  I'm inclined to think it should be illegal,
but maybe it would be too restrictive.
Anyways, I like this idea a lot.

+1


-- 
CARL BANKS

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread michele . simionato
 snip So I've always had it in
 the back of my mind that languages that can easily support massive
 (especially automatic) parallelization will have their day in the
sun,
 at least someday.

and the language of the future will be called ... FORTRAN!

:-)

(joking, but it is the only language I know supporting massive
parallelization ...)


Michele Simionato

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


Re: Software archeology (was Re: Developing Commercial Applications in Python)

2005-01-08 Thread Aahz
In article [EMAIL PROTECTED],
Stephen Waterbury  [EMAIL PROTECTED] wrote:
Aahz wrote:
 In article [EMAIL PROTECTED],
 Stephen Waterbury  [EMAIL PROTECTED] wrote:

Also see Python Success Stories:  http://pythonology.org/success

A notable example is Verity's search engine -- see
http://python.oreilly.com/news/PythonSS.pdf
 
 Actually, your statement is slightly inaccurate.  The Verity search
 engine is more than fifteen years old in its core technology; it was
 started as a LISP project at IIRC MIT.  (At one point I was much amused
 to look at the C source code and find car() and cdr() functions.)  As of
 my last information, Python isn't used at all in or with the Verity
 search engine.  What you're referring to is the Verity Ultraseek engine,
 originally written and owned by Infoseek before getting transferred to
 Verity through a series of dot-bomb transactions.  The Ultraseek engine
 doesn't use Python, but Python is used to control the engine, and I think
 much of the spider is written in Python.

Actually, Aahz didn't add anything useful that wasn't explained better
in the article itself, pointing to which was the purpose of my post,
but he is correct:  Python was *not* used to write the Verity search
engine ... how the hell do these stupid rumors get started anyhow?? ;).
Just read the article, dammit! :)

You're quite correct that I added little useful information, but seeing
as I used to work at Verity, I couldn't resist adding some hopefully
interesting and/or amusing trivia.  Especially the LISP bit.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

19. A language that doesn't affect the way you think about programming,
is not worth knowing.  --Alan Perlis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Other notes

2005-01-08 Thread Nick Coghlan
Bengt Richter wrote:
IOW, I think there is a fix: keep tokenizing greedily and tokenize floating 
point as
a sequence of integers and operators, and let integerdotinteger be 
translated by
the compiler to floating point, and integerdotdotinteger be translated to 
the
appropriate generator expression implementation.
That would be:
int-literaldotint-literal - float(int-literal + . + int-literal)
int-literaldotidentifier - getattr(int(int-literal), identifier)
int-literaldotdotint-literal - xrange(int-literal, int-literal)
However, the problem comes when you realise that 1e3 is also a floating point 
literal, as is 1.1e3.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Getting List Of All Filesystem Mounts

2005-01-08 Thread Tim Daneliuk
Is there some pure Python/portable way to get a list
of all currently mounted filesystems?

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3: accessing the result of 'if'

2005-01-08 Thread Nick Coghlan
Carl Banks wrote:
Right.  But you know that as soon as you add this to simple
expressions, a bunch of people are going to come here whining about how
they don't get to use where with if-expressions.
Frankly, they might have a point here.  Although we have replacing
lambda expressions on our minds, I have in mind a different problem
that a where-statement would solve perfectly.  But it would have to be
used with an if-expression.
I have a different suggestion for this.
'as' is used for renaming in import statements. 'as' will be used for exception 
naming in Python 3k.

So let's use it for expression naming in 'if' statements, too.
if someregexp.match(s) as m:
  # blah using m
elif someotherregexp.match(s) as m:
  # blah using m
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Nick Coghlan
Steve Horsley wrote:
But my understanding is that the current Python VM is single-threaded 
internally,
so even if the program creates multiple threads, just one core will be 
dividing
its time between those threads.
Not really.
The CPython interpreter does have a thing called the 'Global Interpreter Lock' 
which synchronises access to the internals of the interpreter. If that wasn't 
there, Python threads could corrupt the data structures. In order to do anything 
useful, Python code must hold this lock, which leads to the frequent 
misapprehension that Python is 'single-threaded'.

However, the threads created by the Python threading mechanism are real OS 
threads, and the work load can be distributed between different cores.

In practice, this doesn't happen for a pure Python program, since any running 
Python code must hold the interpreter lock. The Python threads end up getting 
timesliced instead of running in parallel. Genuine concurrency with pure Python 
requires running things in separate processes (to reliably get multiple 
instances of the Python interpreter up and running).

Python threads are mainly intended to help deal with 'slow' I/O operations like 
disk and network access - the C code that implements those operations *releases* 
the GIL before making the slow call, allowing other Python threads to run while 
waiting for the I/O call to complete. This behaviour means threading can give 
*big* performance benefits on even single-CPU machines, and is likely to be the 
biggest source of performance improvements from threading.

However, on multi-processor machines, it is also handy if a CPU-intensive 
operation can be handled on one core, while another core keeps running Python code.

Again, this is handled by the relevant extension releasing the GIL before 
performing its CPU-intensive operations and reacquiring the GIL when it is done.

So Python's concurrency is built in a couple of layers:
Python-level concurrency:
  Multiple processes for true concurrency
  Time-sliced concurrency within a process (based on the GIL)
C-level concurrency:
  True concurrency if GIL is released when not needed
In some cases, problems with multi-threading are caused by invocation of 
extensions which don't correctly release the GIL, effectively preventing *any* 
other Python threads from running (since the executing extension never releases it).

As an example, I frequently use SWIG to access hardware API's from Python. My 
standard 'exception translator' (which SWIG automatically places around every 
call to the extension) now looks something like:

%exception {
  Py_BEGIN_ALLOW_THREADS
  try {
$action
  } except (...) {
Py_BLOCK_THREADS
SWIG_exception(SWIG_RuntimeError, Unexpected exception)
  }
  Py_END_ALLOW_THREADS
}
The above means that every call into my extension releases the GIL 
automatically, and reacquires it when returning to Python. I usually don't call 
the Python C API from the extension, but if I did, I would need to reacquire the 
GIL with PyGILState_Ensure() before doing so.

Without those threading API calls in place, operations which access the hardware 
always block the entire program, even if the Python program is multi-threaded.

See here for some more info on Python's threading:
http://www.python.org/doc/2.4/api/threads.html
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Operating System???

2005-01-08 Thread Roose

 But I thought Python was an all-purpose language.  After all, OS's
 have been written in Lisp before too.

It is a general purpose APPLICATION language.  I am surprised that this
hasn't been mentioned on this thread.

An OS is NOT an application.  It is a completely different kind of program.
Do you guys understand the difference between user and kernel mode?  Do you
know what address spaces and hardware interrupts are?  Python is not
equipped to handle these things.  You would end up doing so much in C
extensions that it could barely be called Python.

I am not trying to be insulting... but unless someone would like to educate
me otherwise, the idea of an OS written in Python is almost ludicrous.  As I
said, I think you might mean an OS SHELL, which would be a reasonable
(although maybe unconventional) thing to write in python.

Also I am no threading expert, but I would imagine it would be very hard to
write a task scheduler in Python given that it has the whole GIL thing.  (As
I said that isn't my domain of expertise but I'm sure someone here could
expound on that.)


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


Re: Getting List Of All Filesystem Mounts

2005-01-08 Thread Roel Schroeven
Tim Daneliuk wrote:
Is there some pure Python/portable way to get a list
of all currently mounted filesystems?
Check out MtPython: http://bebop.bigasterisk.com/python/docs/MtPython
--
Codito ergo sum
Roel Schroeven
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Operating System???

2005-01-08 Thread Paul Rubin
Roose [EMAIL PROTECTED] writes:
 An OS is NOT an application.  It is a completely different kind of program.
 Do you guys understand the difference between user and kernel mode?  Do you
 know what address spaces and hardware interrupts are?  Python is not
 equipped to handle these things.  You would end up doing so much in C
 extensions that it could barely be called Python.

You'd need some library functions to let Python access device registers
and you'd need some low level code to dispatch interrupts into Python code.

 I am not trying to be insulting... but unless someone would like to educate
 me otherwise, the idea of an OS written in Python is almost ludicrous.

Is an OS written in Lisp also ludicrous?  Because it's been done.

When Unix was first written, people thought implementing an OS in C
was ludicrous.  Everyone knew OS's had to be written in assembler.

 Also I am no threading expert, but I would imagine it would be very hard to
 write a task scheduler in Python given that it has the whole GIL thing.  (As
 I said that isn't my domain of expertise but I'm sure someone here could
 expound on that.)

The GIL is not part of the Python language.  It's just an artifact of
one particular implementation.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-08 Thread AdSR
Nick Coghlan wrote:
Killer app for this keyword:
class C(object):
  x = property(get, set) where:
def get(self):
  return Silly property
def set(self, val):
  self.x = Told you it was silly
Hey, this is super-elegant!
AdSR
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-08 Thread Paul Rubin
AdSR [EMAIL PROTECTED] writes:
  Killer app for this keyword:
  class C(object):
x = property(get, set) where:
  def get(self):
return Silly property
  def set(self, val):
self.x = Told you it was silly
 
 Hey, this is super-elegant!

Heh, even further:

z = C() where:
   class C(object):
  ...

Lets you make anonymous classes and singleton objects.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting rid of self.

2005-01-08 Thread Terry Reedy

BJörn Lindqvist [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I think it would be cool if you could refer to instance variables
without prefixing with self.

Others have expressed such a wish -- this comes up perhaps once a year. 
The bottom line is that as long as Python has separate instance and local 
namespaces with possibly duplicate names, then there must be a way to tell 
which namespace a name should be looked up in.  The current system is 
completely consistent with Python's object.attribute system.  It would be 
odd if instance attributes were referred to differently in module level 
code and function level code.

Terry J. Reedy



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


Re: Another look at language comparisons

2005-01-08 Thread Michael Sparks
Pierre Quentel wrote:

 http://khason.biz/blog/2004/12/why-microsoft-can-blow-off-with-c.html

I almost didn't look at this, but I'm glad I did - quite a fun comparison,
nicely arbitrary and reminds me of RFC in a similar vein :)


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


Re: python3: 'where' keyword

2005-01-08 Thread Andrey Tatarinov
Bengt Richter wrote:
It also allows the necessary but uninteresting setup for an expression 
to be moved out of the way, bringing the expression that does the real 
work to prominence.
Killer app for this keyword:
class C(object):
 x = property(get, set) where:
   def get(self):
 return Silly property
   def set(self, val):
 self.x = Told you it was silly
Yes, that is cool and it _is_ an interesting idea. Are suites nestable? E.g., is this legal?
...
And, is the whole thing after the '=' an expression? E.g.,
  x = ( foo(x) where:
 x = math.pi/4.0
  ) where:
 def foo(x): print 'just for illustration', x
or is this legal?
  for y in ([foo(x) for x in bar] where:
 bar = xrange(5)
): baz(y) where:
def baz(arg): return arg*2
Not trying to sabotage the idea, really, just looking for clarification ;-)
yes, all your examples are correct. And that's the way I'd like to use 
this feature.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-08 Thread Andrey Tatarinov
Nick Coghlan wrote:
It also allows the necessary but uninteresting setup for an expression 
to be moved out of the way, bringing the expression that does the 
real work to prominence.
Killer app for this keyword:
class C(object):
  x = property(get, set) where:
def get(self):
  return Silly property
def set(self, val):
  self.x = Told you it was silly
oh, that's great! I can't imagine prettier example
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: google groups bug, or worse?

2005-01-08 Thread aaronwmail-usenet

Bengt Richter wrote:
 What did you google with? Is this it?

http://groups-beta.google.com/groups?hl=enie=UTF-8q=%22The+xsdbXML+framework+provides+a+flexible+and+well+defined+infrastructure%22qt_s=Search+Groups

That was my *reply* to one of the original posts using Google,
which I faked up when I couldn't find it (posted using google).
The two originals aren't there.

hmmm.   -- Aaron Watters
===
You'd be paranoid too, if everyone was out to get you!

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


tuples vs lists

2005-01-08 Thread worzel
I get what the difference is between a tuple and a list, but why would I 
ever care about the tuple's immuutability?
Also, do you say 'too-ple' or 'chu-ple' - if you get my drift. (tomato or 
tomato kind of thing)
TIA 


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


Re: Another look at language comparisons

2005-01-08 Thread Jan Dries
[EMAIL PROTECTED] wrote:
From the web site:
Why Microsoft can Blow-Off with C#? These people have thought up
programming languages Fortran, Prologue, Ada.
The author is ignorant. Fortran was invented by IBM in the late 1950s,
long before Microsoft existed. Ada was commissioned by the U.S.
Department of Defense in the 1970s. The Prolog programming language is
not spelled Prologue.
I don't think that these people is refering to Microsoft. Instead, it 
is refering to the three pictures below the text. I assume they are the 
pictures of the respective authors of these languages.

The bottom line of the article is that languages authored by men with 
beards are more successful than those authored by people without beards.
At least the anecdotical evidence to that is overwhelming :-)

And there is hope for Python, as Guido has recently been seen with a 
beard :-)
http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg

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


The best way to do web apps with Python?

2005-01-08 Thread worzel



What is the best way 
to web developemnt with Python? Is there anything close to PHP style in-page 
script placement that can create and use other Python objects? I am not really 
interested in Zope (I believe that is more a CMS than anything else?) I am also 
looking for something a little more structured than a series of CGI 
Scripts.

While on the topic - what is the expectataion of 
Python for this kind of stuff? Would one use Python for certain other things but 
turn to PHP for web apps - or would one use their Python skills in place of PHP? 


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

Re: Pre/Postconditions with decorators

2005-01-08 Thread rittersporn
Thank you very much. It is really a very elegant piece of code :-)

Eiffel (language) has both type checking and design by contract.
Python lacks both.
Your module tackles type checking, I
tried to execute arbitrary code before
and after function execution to realize
runtime assertions.

I wonder if this should be separated in a Python
checker-module.
Both are part of the interface contract.

Ciao

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


Re: The best way to do web apps with Python?

2005-01-08 Thread Paul Rubin
worzel [EMAIL PROTECTED] writes:
 What is the best way to web developemnt with Python? Is there
 anything close to PHP style in-page script placement that can create
 and use other Python objects? I am not really interested in Zope (I
 believe that is more a CMS than anything else?) I am also looking
 for something a little more structured than a series of CGI Scripts.

Basically, yes, there are various Python template systems similar to
PHP.  I won't name them because other people more knowledgeable than
me will do a better job than I could.  I'll say that Python is a
better language than PHP, but getting a basic dynamic web app running
in PHP is much simpler than it is in Python.  Python's advantage
starts to shine once the app gets complicated.

 While on the topic - what is the expectataion of Python for this
 kind of stuff? Would one use Python for certain other things but
 turn to PHP for web apps - or would one use their Python skills in
 place of PHP?  TIA

It's sort of a difficult trade-off and it depends a lot on your
application, who will develop and maintain it, who will use it, where
it will be deployed, etc.  Lots more people know PHP than Python, PHP
is easier to get started with, and cheap PHP hosting is available all
over.  So if you're building some simple app that you want to
distribute widely and run everywhere, PHP is attractive.  If you're
building a complex system which you'll run on a server that you have
more control over, and you'll have relatively high-powered developers
on hand to maintain the code, Python beats PHP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The limitation of the Photon Hypothesis

2005-01-08 Thread Steve Horsley
bill wrote:
Please reply to [EMAIL PROTECTED], thank you !
No - I'll reply to the newsgroup, if you don't mind.
The limitation of the Photon Hypothesis
snip
THE UNCERTAINTY PRINCIPLE IS UNTENABLE
Big snip
You cannot use classical theory to disprove quantum theory that easily.
The uncertainty is quantum in origin, and not just an artifact of
classical mechanics applied to clumsy measurement.
You don't convince me.
Also, I think you probably accidentally posted to the wrong newsgroup.
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: tuples vs lists

2005-01-08 Thread Bruno Desthuilliers
worzel a écrit :
I get what the difference is between a tuple and a list, but why would I 
ever care about the tuple's immuutability?
Because, from a purely pratical POV, only an immutable object can be 
used as kay in a dict. So you can use tuples for 'composed key'.

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


Re: Pre/Postconditions with decorators

2005-01-08 Thread Skip Montanaro

 Eiffel (language) has both type checking and design by contract.
 Python lacks both.

Actually, Python is strongly typed.  It's just dynamically instead of
statically typed.

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Lee Harr
 [http://www.gotw.ca/publications/concurrency-ddj.htm]. It argues that the 
 continous CPU performance gain we've seen is finally over. And that future 
 gain would primary be in the area of software concurrency taking advantage 
 hyperthreading and multicore architectures.


 Well, yes. However, it's not as bad as it looks. I've spent a good part
 of my professional life with multiprocessors (IBM mainframes) and
 I have yet to write a multi-thread program for performance reasons.
 All of those systems ran multiple programs, not single programs
 that had to take advantage of the multiprocessor environment.
 Your typical desktop is no different. My current system has 42
 processes running, and I'd be willing to bet that the vast majority
 of them aren't multi-threaded.



Exactly. If every one of your processes had its own 2 Ghz processor
running nothing else, I think you would be pretty happy. Your OS
had better be well-written to deal with concurrent access to
memory and disks, but I think for general application development
there will be huge speed boosts with little need for new
programming paradigms.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python/Qt Problem

2005-01-08 Thread Lee Harr
On 2005-01-08, Michael [EMAIL PROTECTED] wrote:
 Hi,

 I am experiencing something very weird with PyQt. I have created several 
 windows based on QWidget using Designer. I can easily hide and show 
 these with the hide and show methods. However I have just created a new 
 window with Designer and the show method works in my main script but not 
 inside the button action method (not using proper temrinology, sorry) of 
 another window. Why is that? This works fine for the other windows.



If you do not get a satisfactory answer here, you should try
the dedicated PyQt mailing list:
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

The other thing I would suggest is to post some code along
with your description of what you believe it should do.
I do not think anyone will be able to diagnose the problem
without seeing the code.

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


Re: tuples vs lists

2005-01-08 Thread Steve Horsley
worzel wrote:
I get what the difference is between a tuple and a list, but why would I 
ever care about the tuple's immuutability?
Mainly for security and speed. Many library functions return info by 
returning
a reference to an internally held tuple, and could be damaged / compromised
/ corrupted if that internal data was modified by malicious code. If tuples
were mutable (lists) then it would be necessary to return a copy instead.
Also, do you say 'too-ple' or 'chu-ple' - if you get my drift. (tomato or 
tomato kind of thing)
Try 'Two-pull'.
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: why not datetime.strptime() ?

2005-01-08 Thread Lee Harr
On 2005-01-07, Skip Montanaro [EMAIL PROTECTED] wrote:

 josh Shouldn't datetime have strptime?

 Sure, but it's not quite as trivial to implement as was strftime() support.
 While strftime() is a C library function and thus easily called from within
 the datetime C code, strptime() is implemented in Python as part of the time
 module for portability (strptime(3) is not universally available).  You'd
 need to import the time module, call its strptime() function with the input
 string and format, then use the tuple it returns to initialize a new
 datetime object.



Not sure this is exactly related, but I was using datetime
the other day to make timestamps:

 import datetime
 ts = datetime.datetime.now().isoformat()
 ts
'2005-01-08T09:45:16.896805'


and figured there would be an easy way to reverse that.
Something along the lines of:
dt = datetime.datetime.fromisoformat(ts)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tuples vs lists

2005-01-08 Thread worzel
Cheers - thanks for the feedback guys - pretty much answers the question for 
me.

'Two-Pull' it is then, thanks.


Steve Horsley [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 worzel wrote:
 I get what the difference is between a tuple and a list, but why would I 
 ever care about the tuple's immuutability?

 Mainly for security and speed. Many library functions return info by 
 returning
 a reference to an internally held tuple, and could be damaged / 
 compromised
 / corrupted if that internal data was modified by malicious code. If 
 tuples
 were mutable (lists) then it would be necessary to return a copy instead.

 Also, do you say 'too-ple' or 'chu-ple' - if you get my drift. (tomato or 
 tomato kind of thing)

 Try 'Two-pull'.

 Steve 


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


Re: The best way to do web apps with Python?

2005-01-08 Thread JZ
Dnia Sat, 8 Jan 2005 21:11:49 +0800, worzel napisa(a):

 What is the best way to web developemnt with Python? 

Hmm. :) I prefer http://cherrypy.org + http://cheetahtemplate.org/. Very
easy to learn and develop, yet powerfull.

 Is there anything close to PHP style in-page script 
 placement that can create and use other Python objects? 

Check http://spyce.sourceforge.net 
or http://nick.borko.org/pse

--
JZ ICQ: 6712522
http://zabiello.om
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Other notes

2005-01-08 Thread beliavsky
Bengt Richter wrote:

OTOH, there is precedent in e.g. fortran (IIRC) for named operators of
the
form .XX. -- e.g., .GE. for = so maybe there could be room for both.

Yes, but in Fortran 90 ==, =  etc. are equivalent to .EQ. and
.GE.. It is also possible to define operators on native and
user-defined types, so that

Y = A .tx. B

can be written instead of the expression with the F90 intrinsic
functions

Y = matmul(transpose(A),B)

The Fortran 95 package Matran at
http://www.cs.umd.edu/~stewart/matran/Matran.html uses this approach to
simplify the interface of the Lapack library and provide syntax similar
to that of Matlab and Octave.

I don't know if the syntax of your idea clashes with Python, but it is
viable in general.

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Jp Calderone
On Sat, 08 Jan 2005 14:22:30 GMT, Lee Harr [EMAIL PROTECTED] wrote:
 [http://www.gotw.ca/publications/concurrency-ddj.htm]. It argues that the 
  continous CPU performance gain we've seen is finally over. And that future 
  gain would primary be in the area of software concurrency taking advantage 
  hyperthreading and multicore architectures.
 
 
  Well, yes. However, it's not as bad as it looks. I've spent a good part
  of my professional life with multiprocessors (IBM mainframes) and
  I have yet to write a multi-thread program for performance reasons.
  All of those systems ran multiple programs, not single programs
  that had to take advantage of the multiprocessor environment.
  Your typical desktop is no different. My current system has 42
  processes running, and I'd be willing to bet that the vast majority
  of them aren't multi-threaded.
 
 
 Exactly. If every one of your processes had its own 2 Ghz processor
 running nothing else, I think you would be pretty happy. Your OS
 had better be well-written to deal with concurrent access to
 memory and disks, but I think for general application development
 there will be huge speed boosts with little need for new
 programming paradigms.

  Not likely.  How often do you run 4 processes that are all 
bottlenecked on CPU?  It's not a common usage pattern.  If you
have 16 CPUs, and 15 of them are running mostly idle processes
and that *one* process you'd wish would hurry the heck up and 
finish has the 16th pegged at 100% usage, you are not a happy 
camper.

  For the case where you do have a lot of competing unrelated 
processes, no doubt SMP is a big win automatically, but there 
will still need to be language innovations to make it easier 
to develop software which can benefit from the additional 
hardware for the more common case of individual CPU hungry 
processes.

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Skip Montanaro

Jp How often do you run 4 processes that are all bottlenecked on CPU?

In scientific computing I suspect this happens rather frequently.

More is never enough. -- Bob Saltzman

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


Re: python3: 'where' keyword

2005-01-08 Thread André
At the risk of generating controversy, here's another type of example:

def gcd(a, b):
where:
a: int, b: int
return c where:
c: int
while a:
a, b = b%a, a
return b

More can be found at http://aroberge.blogspot.com

Andre

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Philippe C. Martin
I remember a _few_ year ago when all specialists (Intel's) included
agreed that the 100MHZ barrier would never be passed - so, at least, we
did get free lunch for a couple of years :-)

I also must add that in my 17 years of realtime/embedded programming,
the problem usually was not the CPU speed - since you know _prior_ to
the design of your software whether your CPU will change context on time
when the hardware IRQ comes in - but rather the fact that all the
software/peripherals had to share the same bus == that usually was
where the bottleneck was.

I guess my point is to not focus the performance of a system solely on
its CPU's.




Regards,

Philippe




-- 
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Aahz
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:
Michele deleted an attribution:

 snip So I've always had it in
 the back of my mind that languages that can easily support massive
 (especially automatic) parallelization will have their day in the sun,
 at least someday.

and the language of the future will be called ... FORTRAN!

:-)

(joking, but it is the only language I know supporting massive
parallelization ...)

Less of a joke than you think, perhaps.  Back in the early 1980s, a
family friend said something like, In the year 2000, there will be a
programming language.  I don't know what it will look like, and I don't
know what it will do.  But I do know one thing: it will be called
FORTRAN.

After all, FORTRAN 2003 contains OOP support
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

19. A language that doesn't affect the way you think about programming,
is not worth knowing.  --Alan Perlis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-08 Thread André
Darn space-eater google groups :-(   Here is it again, at teh risk of
generating controversy

.def gcd(a, b):
.where:
.a: int, b: int
.return c where:
.c: int
.while a:
.a, b = b%a, a
.return b
more examples can be found at aroberge.blogspot.com

André

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


Re: Returning same type as self for arithmetic in subclasses

2005-01-08 Thread Max M
Tim Peters wrote:
Yes, and all builtin Python types work that way.  For example,
int.__add__ or float.__add__ applied to a subclass of int or float
will return an int or float; similarly for a subclass of str.  This
was Guido's decision...
I will not discuss it with him. He is usually right :-s

Generally speaking, no.  But I'm sure someone will torture you with a
framework that purports to make it easy wink.
Apparently not... But here is my solution.
If anybody is interrested. It should also be obvious what I am working on.
Btw. I really love doctests ... Unittests are a nice idea. But doctest 
is a really practical solution.

###
class vDatetime(datetime):

A subclass of datetime, that renders itself in the iCalendar datetime
format.
 dt = vDatetime(1970, 1,1, 12, 30, 0)
 str(dt)
'19700101T123000'
 dt2 = vDatetime(1970, 1,1, 0, 0, 0)
 str(dt - dt2)
'PT12H30M'
Adding is not allowed
 dt + dt2
Traceback (most recent call last):
...
AttributeError: 'NotImplementedType' object has no attribute 'days'

def __init__(self, *args, **kwargs):
datetime.__init__(self, *args, **kwargs)
self.params = Params()
def __add__(self, other):
return self._to_vdatetime(datetime.__add__(self, other))
def __sub__(self, other):
return self._to_vdatetime(datetime.__sub__(self, other))
def _to_vdatetime(self, result):
if hasattr(result, 'timetuple'):
return vDatetime(*result.timetuple()[:6])
return vDuration(result.days, result.seconds)
def fromstring(st):
Class method that parses
try:
timetuple = map(int, ((
st[:4], # year
st[4:6],# month
st[6:8],# day
st[9:11],# hour
st[11:13],# minute
st[13:15],# second
)))
except:
raise ValueError, 'Wrong format'
return vDatetime(*timetuple)
fromstring = staticmethod(fromstring)
def __str__(self):
return self.strftime(%Y%m%dT%H%M%S)

--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-08 Thread Max M
Jan Dries wrote:
[EMAIL PROTECTED] wrote:
And there is hope for Python, as Guido has recently been seen with a 
beard :-)
http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg
LOL, he is working on linux, isn't he?
So it was about bloody time.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: The best way to do web apps with Python?

2005-01-08 Thread Rob Emmons
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
 HTMLHEAD
 META http-equiv=Content-Type content=text/html; charset=iso-8859-1
 META content=MSHTML 6.00.2900.2523 name=GENERATOR
 STYLE/STYLE
 /HEAD
 BODY
 DIVFONT face=Arial size=2What is /FONTFONT face=Arial size

Just FYI -- the post you posted was in HTML -- you might want to avoid
this in the future.  99% of all posts to news groups are in text, not
html.  Html is hard for everyone to read with normal news readers and not
usually of any extra value.  It's also more of a security risk to read it --
because there is more potential for exploitation.

Anyway, just thought I'd mention it if you didn't know.

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


Re: Python Operating System???

2005-01-08 Thread David Brown
So how would I make an OS Shell?


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


Re: Tkinter: passing parameters to menu commands

2005-01-08 Thread Kent Johnson
Philippe C. Martin wrote:
menu.add_cascade(label=File, menu=filemenu)
filemenu.add_command(label=New, command=lambda: callback('New'))
filemenu.add_command(label=Open..., command=lambda:

Of course you could do this with named forwarding functions if you
prefer
I'm not sure what 'named forwarding functions' 
Bad choice of terminology, I just mean you can explicitly define
def handleNew:
  callback('New')
etc.
are but I'm actually in a
class and when applying your suggestion in the following manner,
everything works (THANKS!)

def __Dec(self,p_string):
  for i in p_string:
self.__Insert(i)
.
.
.
#menu creation
l_dec.add_command(label = 'ATR', command=lambda: self.__Dec('ATR'))
l_dec.add_command(label = 'IN', command=lambda:self.__Dec('IN'))
.
.
.

Yet I have a question:
If I replace the menu creation code as below, and since __Insert appends
the string p_string into a text widget that is created _after_ the menu
creation; the method __Dec seems to be called at the menu creation and
I get an error in __Insert because the test widget is equal to None.
My reflexes of C programmer tell me that command=self.__Dec just
passes a method pointer (sorry I said it) to add_command - yet it does
not seem to be so.

 What is actually going on ?


 #menu creation
 l_dec.add_command(label = 'ATR', command=self.__Dec('ATR'))
 l_dec.add_command(label = 'IN', command=self.__Dec('IN'))
self.__Dec is a reference to the function. It is similar to a method pointer so you don't need to 
apologize ;) The name of a function without the () is a reference. When you append () it becomes a 
call to the referenced function.

The command parameter for the menu must be a reference to a function. The function is called with no 
arguments when the menu is invoked.

So, you need a function of no arguments to handle the command. For example,
def handleMenu():
  print 'Handled'
filemenu.add_command(label=New, command=handleMenu)
Note there is no () after handleMenu. 'command' is bound to the function object; the function is not 
called until later.

OK, now suppose you want to pass a parameter to handleMenu?
def handleMenu(menuName):
  print 'Handled', menuName
Now what do you put in the command parameter? This won't work because you are *calling* handleMenu 
and assigning the result of the call (in this case the value None) to 'command':

filemenu.add_command(label=New, command=handleMenu('New')) # WRONG
You need a new function of zero arguments to bind to 'command'. Here is one way 
to do it:
def handleNew():
  handleMenu('New')
filemenu.add_command(label=New, command=handleNew) # OK
Note, again, no () after handleNew. 'command' is bound to the function object 
again.
OK, what about lambda? lambda is a way to create a simple anonymous function. One simple use of 
lambda is to make a new function that binds a parameter to another function.

lambda: handleMenu('New')
defines a function that does the same thing as handleNew. The value of the lambda expression is the 
function object. So

filemenu.add_command(label=New, command=lambda: handleMenu('New')) # OK
is another way to get the result you want.
Kent
--
http://mail.python.org/mailman/listinfo/python-list


there's a socket.sendall(), so why no socket.recvall()?

2005-01-08 Thread Irmen de Jong
Subject says it all;
there's a socket.sendall(), so why no socket.recvall()?
I know that I can use the MSG_WAITALL flag with recv(),
but this is not implemented on all platforms, most
notably windows.
--Iremn
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-08 Thread oren
When I first saw this I thought: hmmm... this seems as redundant as
adding a repeat/until loop to Python; there's no chance in hell it will
ever be accepted by the community or Guido, but I actually kinda like
it.  It's nice to see mostly positive reactions to this idea so far.

I think it's a really ingenious solution to the the anonymous function
problem - don't make it anonymous! A short, throwaway name with a very
localized scope is as good as a truly anonymous function and feels more
Pythonic to me. We thought we wanted a better syntax than lambda for
anonymous functions but Andrey shows that perhaps it wasn't what we
really need. What we need is a solution to quickly and cleanly generate
bits of callable code without polluting the containing namespace,
without having to think too hard about unique names and while making
their temporary and local nature clear from the context. Anonymity
isn't one of the requirements.

I really liked Nick Coghlan's property example. The names 'get' and
'set' are too short and generic to be used without a proper scope but
with this syntax they are just perfect.

Here's another example:

w = Widget(color=Red, onClick=onClick, onMouseOver=onMouseOver) where:
.   def onClick(event): do_this(event.x, event.y, foo)
.   def onMouseOver(event): someotherwidget.do_that()

The onClick=onClick part seems a bit redundant, right? So how about
this:

w = Widget(**kw) where:
.   color = Red
.   def onClick(event): do_this(event.x, event.y, blabla)
.   def onMouseOver(event): someotherwidget.do_that()
.   x, y = 100, 200
.   kw = locals()

I'm not really sure myself how much I like this. It has a certain charm
but also feels like abuse of the feature. Note that w =
Widget(**locals()) where: would produce the wrong result as it will
include all the values in the containing scope, not just those defined
in the where block. 

   Oren

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Donn Cave
Quoth Skip Montanaro [EMAIL PROTECTED]:
|
| Jp How often do you run 4 processes that are all bottlenecked on CPU?
|
| In scientific computing I suspect this happens rather frequently.

I think he was trying to say more or less the same thing - responding
to (IBM mainframes) ... All those systems ran multiple programs ...
My current system has 42 processes running ..., his point was that
however many processes on your desktop, on the rare occasion that
your CPU is pegged, it will be 1 process.  The process structure of
a system workload doesn't make it naturally take advantage of SMP.
So there will still need to be language innovations etc. -- to
accommodate scientific computing or whatever.  Your 4 processes are
most likely not a natural architecture for the task at hand, but
rather a complication introduced specifically to exploit SMP.

Personally I wouldn't care to predict anything here.  For all I know,
someday we may decide that we need cooler and more efficient computers
more than we need faster ones.

Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing IPython on win2k

2005-01-08 Thread Dave Merrill
Hi, I'm new to python, and ipython, but not to programming, having trouble
getting ipython installed on windows 2000, python 233. Any help would be
much appreciated; I'm sure I'm being some basic flavor of dense...

First downloaded and installed PythonWin, readline and ctypes. They're all
pretty clearly here and working, because I can run PythonWin, and from
there, importing readline and ctypes works.

Then downloaded ipython-0.6.6.zip and unzipped it. When I double-click
setup.py, I get only a brief wait cursor; nothing else happens, and
importing ipython as a test fails.

I tried moving the whole unzipped dir to site-packages, no difference.

Both files in the scripts dir, ipython and pycolor, have no filename
extension, which seems odd to my newbie eye. I tried renaming them to .py,
still no difference.

My apologies for this basic question, and my no doubt ignorant flailing
about. Very much looking forward to getting this working.

Thanks,

Dave Merrill


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


Real Election Reform

2005-01-08 Thread D Flint
What do you think about this and have you seen this popular site before?

This was taken from a web site
http://www.afvr.org

How can we safeguard the integrity of each vote?
Today we have technology that protects our financial systems, military
weapon systems and national intelligent organizations. These proven systems
can be combined in a way to issue serialized equipment to authorize
personnel for the dates and hours needed. Each would have their own level of
clearance to perform the tasks they are responsible for. Each action would
be recorded and verified with a higher levels of network authority and
again, only available during the hours and dates needed. Ballots would only
be printed after the voter has cast their vote but before they leave the
booth. If the voter made a mistake he could put the printed ballot into the
booth's scanner for correction. All ballots scanned at the booth would go
into a shredder and the voter could then correct his ballot on the screen
and reprint his ballots. Once the voter accepts the printed ballot he
submits his vote on the screen and takes the two ballots to the depository.
So two computer generated, serialized and scanner perfect receipts of the
completed ballot are printed.* One for the voter and one for the public
record. This would eliminate all the extra ballots that could be used for
unauthorized voting as well as any question of voter intent.  Each piece of
equipment involved in the issuing of the receipt would be linked to the
serial# of that ballot and an electronic document would be generated that
exactly matched the two printed receipts. So the voter themselves has
validate the printed ballots, keeping one for themselves, while the other
electronic time-stamped document is deposited into an optical scanner used
as a secure depository. This second scanned count which should always match
the electronic count. This paper ballot could also be used for recounts if
needed. The voter could use the receipt to inquire about their vote in the
future. The stuffing of the ballot box or finding ballots would be
eliminated.  With this system, if you find a ballot, you have to find the
voter that cast that ballot too. This is not so in any of the current
systems in place today nor have we ever heard such a system ever proposed.
  http://www.afvr.org











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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread John Roth
Donn Cave [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Quoth Skip Montanaro [EMAIL PROTECTED]:
|
| Jp How often do you run 4 processes that are all bottlenecked on 
CPU?
|
| In scientific computing I suspect this happens rather frequently.

I think he was trying to say more or less the same thing - responding
to (IBM mainframes) ... All those systems ran multiple programs ...
My current system has 42 processes running ..., his point was that
however many processes on your desktop, on the rare occasion that
your CPU is pegged, it will be 1 process.  The process structure of
a system workload doesn't make it naturally take advantage of SMP.
So there will still need to be language innovations etc. -- to
accommodate scientific computing or whatever.  Your 4 processes are
most likely not a natural architecture for the task at hand, but
rather a complication introduced specifically to exploit SMP.
Exactly. I wasn't addressing some of the known  areas where one
can take advantage of multiple processors, or where one can take
advantage of threading on a single processor to avoid delays.
At this point in time, though, I see multithreading for compute
intensive tasks to be an intermediate step. The final step is to
restructure it so it can take advantage of cluster architectures.
Then you can simply ignore all of the complexity of threads.
That still leaves putting long running tasks (such as printing)
into the background so the UI stays responsive.
Personally I wouldn't care to predict anything here.  For all I know,
someday we may decide that we need cooler and more efficient computers
more than we need faster ones.
Chuckle. I basically think of shared memory multiprocessing
as being perverse: the bottleneck is memory, not compute
speed, so adding more processors accessing the same memory
doesn't strike me as exactly sane. Nor does pushing compute
speed up and up and up when it just stressed the memory
bottleneck.
Donn Cave, [EMAIL PROTECTED] 
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: spacing of code in Google Groups

2005-01-08 Thread Peter Hansen
JanC wrote:
Have a look at: http://gnuwin32.sourceforge.net/
They have native win32 builds of many of the GNU commandline utilities...
Thanks, everyone, for all your kind help.
(Uh, I thought it was clear I didn't actually *want* a
method of cutting columns, since I have needed the
functionality once in the last ten years, but on behalf
of those who do what it and didn't know how to get it,
I give you thanks. ;-)
-quite-happy-with-simple-editors-and-a-command-line-ly y'rs,
 Peter
--
http://mail.python.org/mailman/listinfo/python-list


windows mem leak

2005-01-08 Thread Bob Smith
Does the Win32 port of Python have a memory leak? I have some code that 
runs flawlessly on Linux, but bombs after a few hours on Windows. It's 
threaded and uses a lot of memory.

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


Re: sorting on keys in a list of dicts

2005-01-08 Thread Peter Hansen
Nick Coghlan wrote:
Stability in sorting is a property not to be sneezed at - it means 
switching to sorting by a second key gives the effect of sort by key 1, 
then by key 2, whereas that doesn't hold with an unstable sort 
Assuming key 1 refers to the first key, and key 2 to the second
key, then I believe you meant gives the effect of 'sort by key 2
then by key 1'.
In other words, if you have a stable sort algorithm and do one sort
operation using key 2, then a second sort operation using key 1,
it's the same as doing a single sort with the key combination key 1, key 2,
not the other way around.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2 versions of python on 1 machine

2005-01-08 Thread Peter Hansen
flupke wrote:
I used the 2 batch files technique and removed c:\python23 from my
path var and all is fine now.
Where did you find more info on PYTHONHOME and PYTHONPATH because
the docs don't seem to contain a whole lot of info.
Typing python -h gives a good start.  I'm sorry, I don't recall
where else there is useful info on those, though I'm pretty sure
Google could help.  (I'm not sure there's much to add to what the
-h option tells you, however.)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3: 'where' keyword

2005-01-08 Thread Peter Hansen
Andrey Tatarinov wrote:
  print words[3], words[5] where:
  words = input.split()
- defining variables in where block would restrict their visibility to 
one expression
Then your example above doesn't work...  print takes a
sequence of expressions, not a tuple as you seem to think.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Operating System???

2005-01-08 Thread Peter Hansen
Paul Rubin wrote:
When Unix was first written, people thought implementing an OS in C
was ludicrous.  Everyone knew OS's had to be written in assembler.
Actually, when Unix was first written that belief was entirely
correct, and OSes *did* have to be written in assembler.
That is, pure C did not have the capability to handle all
that was required.  I recall it taking a good decade before it
became *common* to find C compilers with, for example, @interrupt
support to let the compiler generate code that properly saved
all registers and used RTI instead of RTS (or whatever it might
have been called one one's particular flavour of CPU).
Now, once you added a few tiny interrupt handlers, and some context
switching (stack manipulation) routines, pretty much everything else
*could* be done in C, but that doesn't invalidate the point.
I think it's safe to say that none of pure C, pure Lisp, or pure Python
are really capable of being used as the *sole* language to build
an operating system.
It's also safe to say that this is a largely irrelevant point.
It would probably only be of academic interest to try to do
something like that.  Any practical attempt would not think more
than twice of resorting to a little glue in assembler or in
the form of canned byte sequences built by hand and stuck
into the appropriate places in memory...
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: google groups bug, or worse?

2005-01-08 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
I'm concerned that google groups is not correctly reflecting the
python lists.  A month ago I announced the xsdbXML framework to the
python list and the python-announce list.  As you can see from the
links
below the python announce submission was approved by the moderators
(thanks!)
and the python list submission also went out, but the messages cannot
be found at google groups.
http://mail.python.org/pipermail/python-list/2004-December/254479.html
http://mail.python.org/pipermail/python-announce-list/2004-December/003583.html
Is it a google bug?  Or is it something darker, like an anti-Python
conspiracy at google?
You didn't post via Google, right?  Just sent to the mailing list?
I believe that Google knows nothing about mailing lists, but
watches a news feed, so if the list/Usenet gateway failed to
deliver those messages, Google would never see them.
Furthermore, news delivery is not necessarily guaranteed.
(Actually, I don't recall how reliable the protocol is,
but I doubt it's foolproof.)  If any one of the news
servers between yours and Google's happened to drop some
messages, it's quite possible Google would never see
them.
Given the architecture of Usenet, I wouldn't be surprised
if Google missed messages consistently, a very small percentage
of the time.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Peter Hansen
John Roth wrote:
I have yet to write a multi-thread program for performance reasons.
If we include in the set of things covered by the term
performance not only throughput, but also latency, then
I suspect you actually have written some multithreaded programs
for performance reasons.
*I* certainly have: that's easily the reason for threading
in 95% of the cases I've dealt with, and I suspect those of
many others.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Recent infoworld column

2005-01-08 Thread Peter Hansen
Dwarf Electrician wrote:
from a long time listener...
http://www.infoworld.com/article/04/12/30/01OPstrategic_1.html
Kudos for Roger Binns!
--
http://mail.python.org/mailman/listinfo/python-list


Re: windows mem leak

2005-01-08 Thread Peter Hansen
Bob Smith wrote:
Does the Win32 port of Python have a memory leak? I have some code that 
runs flawlessly on Linux, but bombs after a few hours on Windows. It's 
threaded and uses a lot of memory.
Let's see what you're missing:
1. platform specifics
2. versions of things involved
3. any sort of detail about the code
4. how you're noticing/measuring the problem
5. what bombs means
6. any mention that you've checked Sourceforge to see whether
   a similar problem has been reported
There have been memory leaks in various past versions of Python,
and could easily be in the current version, but they're generally
rather specific in terms of the code that can trigger it.  Once it
was doing some particular work with a socket, once it was trying to
append (or extend?) to an empty list, and so on.
There are also a few ways you could have written your application
to cause memory to leak as a result of your own code, not as a
result of Python's.  And it's even possible that this would happen
only on one platform (though I'm trying hard to think of an example
and can't... maybe it's very unlikely.)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Operating System???

2005-01-08 Thread Arich Chanachai
Peter Hansen wrote:
Paul Rubin wrote:
When Unix was first written, people thought implementing an OS in C
was ludicrous.  Everyone knew OS's had to be written in assembler.

Actually, when Unix was first written that belief was entirely
correct, and OSes *did* have to be written in assembler.
*nods*
That is, pure C did not have the capability to handle all
that was required.  I recall it taking a good decade before it
became *common* to find C compilers with, for example, @interrupt
support to let the compiler generate code that properly saved
all registers and used RTI instead of RTS (or whatever it might
have been called one one's particular flavour of CPU).
If my memory serves me, you are entirely correct.
Now, once you added a few tiny interrupt handlers, and some context
switching (stack manipulation) routines, pretty much everything else
*could* be done in C, but that doesn't invalidate the point.
*nods*
I think it's safe to say that none of pure C, pure Lisp, or pure Python
are really capable of being used as the *sole* language to build
an operating system.
*nods*
It's also safe to say that this is a largely irrelevant point.
It would probably only be of academic interest to try to do
something like that.  Any practical attempt would not think more
than twice of resorting to a little glue in assembler or in
the form of canned byte sequences built by hand and stuck
into the appropriate places in memory...
-Peter
Indeed indeed.  Once must remain focused and ask oneself what he/she is 
attempting to achieve.  In all likelihood, a little asm/c/python glue 
work won't hurt the objective, especially given that doing otherwise 
would entail a very  _low level_ reworking of Python that would take as 
much and likely more effort and skill than to resort to asm/c when 
Python falls incapable.  One could do a Python-Lisp OS w/ Lisp used for 
the Python incapable areas, but you would near entirely loose the 
benefits of Lisp in that respect--- it would have to be so low-level, 
could you call it Lisp?  (A question someone else here posed in this 
thread.)

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


Re: DOS problem (simple fix??)

2005-01-08 Thread Steve Holden
Gavin Bauer wrote:
My DOS window (running in windows ME) closes the second it finishes
running my programs. As you can imagine, this makes it hard to see the
results. I've gotten in the habit of putting raw_input(Press enter to
exit) at the end of every program, and in addition to being pain in
the butt, it often fails to work. Being new to programming in general,
I make more mistakes than most people. My programs often have errors
before they get to my raw_input command. They then display the error
and immediately close. It is naturally a lot easier to fix an error
when you know what the error is. This makes debugging even more
annoying than it ordinarily would be, if you can imagine that. I've
heard that it should be a simple preference fix, but I've asked around
and no one seems to know how.
I presume this means you are starting the program by the time-honored 
expedient of double-clicking on it. For debugging you would probably 
find it more satisfactory to run your programs from the command line, 
and there's a FAQ that explains how at

  http://www.python.org/doc/faq/windows.html
If that isn't simple enough then please let me know, as it's *supposed* 
to be.

Thank you, and please make all answers simple enough to be understood
by a highschool student and his father :) .
If you wanted to get really adventurous you could try tweaking the 
command that Windows runs when you double-click a Python script, but 
we'll leave that for another time.

Welcome to Python!
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: The limitation of the Photon Hypothesis

2005-01-08 Thread Steve Holden
Steve Horsley wrote:
bill wrote:
Please reply to [EMAIL PROTECTED], thank you !

No - I'll reply to the newsgroup, if you don't mind.
The limitation of the Photon Hypothesis
snip
THE UNCERTAINTY PRINCIPLE IS UNTENABLE
Big snip
You cannot use classical theory to disprove quantum theory that easily.
The uncertainty is quantum in origin, and not just an artifact of
classical mechanics applied to clumsy measurement.
You don't convince me.
Also, I think you probably accidentally posted to the wrong newsgroup.
Steve

No, he deliberately posted to the wrong newsgroup. But that's because 
there isn't a right newsgroup for this kind of twaddle (except possibly 
alt.rubbish.alternate.universe).

You have just marked yourself as a noob, since this hoary old favorite 
seems to appear about ten times a year.

Welcome to Usenet!
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


RE: there's a socket.sendall(), so why no socket.recvall()?

2005-01-08 Thread Robert Brewer
Irmen de Jong wrote:
 Subject says it all;
 there's a socket.sendall(), so why no socket.recvall()?

Good question! Something like:

# Receive reply.
data = []
while True:
try:
chunk = conn.recv(8192)
except Exception, x:
if x.args[0] != 10035:
raise x
else:
if chunk == '':
break
data.append(chunk)

If you call .makefile() and then .read() the _fileobject, you get the
same behavior (only better). Adding recvall would just duplicate that, I
think. But that's desirable IMO.


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: tuples vs lists

2005-01-08 Thread Steve Holden
worzel wrote:
Cheers - thanks for the feedback guys - pretty much answers the question for 
me.

'Two-Pull' it is then, thanks.
Well, it might be Two-Pull in American, but in English it's tyoopl 
-- NOT choopl (blearch!). I've also heard people say tuppl.

So, basically, say whatever you want. Language is about communication :-)
you-say-tomato-ly y'rs  - steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Weekly Python Patch/Bug Summary

2005-01-08 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  267 open ( +6) /  2727 closed ( +9) /  2994 total (+15)
Bugs:  798 open ( -3) /  4748 closed (+15) /  5546 total (+12)
RFE :  165 open ( +0) /   140 closed ( +1) /   305 total ( +1)

New / Reopened Patches
__

Remove witty comment in pydoc.py  (2005-01-01)
CLOSED http://python.org/sf/1094007  opened by  Reinhold Birkenfeld

Docs for file() vs open()  (2005-01-01)
CLOSED http://python.org/sf/1094011  opened by  Reinhold Birkenfeld

Improvements for shutil.copytree()  (2005-01-01)
CLOSED http://python.org/sf/1094015  opened by  Reinhold Birkenfeld

xml.dom.minidom.Node.replaceChild(obj, x, x) removes child x  (2005-01-01)
   http://python.org/sf/1094164  opened by  Felix Rabe

os.py: base class _Environ on dict instead of UserDict  (2005-01-02)
   http://python.org/sf/1094387  opened by  Matthias Klose

add Bunch type to collections module  (2005-01-02)
   http://python.org/sf/1094542  opened by  Steven Bethard

self.button.pack() in tkinter.tex example  (2005-01-03)
   http://python.org/sf/1094815  opened by  [N/A]

fixes urllib2 digest to allow arbitrary methods  (2005-01-03)
   http://python.org/sf/1095362  opened by  John Reese

Argument passing from /usr/bin/idle2.3 to idle.py  (2003-11-30)
   http://python.org/sf/851459  reopened by  jafo

fix for trivial flatten bug in astgen  (2005-01-04)
   http://python.org/sf/1095541  opened by  DSM

exclude CVS conflict files in sdist command  (2005-01-04)
   http://python.org/sf/1095784  opened by  Wummel

Fix for wm_iconbitmap to allow .ico files under Windows.  (2005-01-05)
   http://python.org/sf/1096231  opened by  John Fouhy

Info Associated with Merge to AST  (2005-01-07)
   http://python.org/sf/1097671  opened by  Kurt B. Kaiser

Direct framework linking for MACOSX_DEPLOYMENT_TARGET  10.3  (2005-01-07)
   http://python.org/sf/1097739  opened by  Bob Ippolito

Encoding for Code Page 273 used by EBCDIC Germany Austria  (2005-01-07)
   http://python.org/sf/1097797  opened by  Michael Bierenfeld

Patches Closed
__

locale.getdefaultlocale does not return tuple in some OS  (2004-10-21)
   http://python.org/sf/1051395  closed by  rhettinger

imghdr -- identify JPEGs in EXIF format  (2003-06-08)
   http://python.org/sf/751031  closed by  rhettinger

Remove witty comment in pydoc.py  (2005-01-01)
   http://python.org/sf/1094007  closed by  rhettinger

Docs for file() vs open()  (2005-01-01)
   http://python.org/sf/1094011  closed by  rhettinger

Improvements for shutil.copytree()  (2005-01-01)
   http://python.org/sf/1094015  closed by  jlgijsbers

a new subprocess.call which raises an error on non-zero rc  (2004-11-23)
   http://python.org/sf/1071764  closed by  astrand

Argument passing from /usr/bin/idle2.3 to idle.py  (2003-11-30)
   http://python.org/sf/851459  closed by  jafo

@decorators, including classes  (2004-08-12)
   http://python.org/sf/1007991  closed by  jackdied

Convert glob.glob to generator-based DFS  (2004-04-27)
   http://python.org/sf/943206  closed by  jlgijsbers

Make cgi.py use email instead of rfc822 or mimetools  (2004-12-06)
   http://python.org/sf/1079734  closed by  jlgijsbers

New / Reopened Bugs
___

marshal.dumps('hello',0) Access violation  (2005-01-03)
CLOSED http://python.org/sf/1094960  opened by  Mark Brophy

General FAW - incorrect most stable version  (2005-01-03)
   http://python.org/sf/1095328  opened by  Tim Delaney

Python FAQ: list.sort() out of date  (2005-01-03)
CLOSED http://python.org/sf/1095342  opened by  Tim Delaney

Bug In Python  (2005-01-04)
CLOSED http://python.org/sf/1095789  opened by  JastheAce

Macintosh references in the docs need to be checked.  (2005-01-04)
   http://python.org/sf/1095802  opened by  Jack Jansen

The doc for DictProxy is missing  (2005-01-04)
   http://python.org/sf/1095821  opened by  Colin J. Williams

Apple-installed Python fails to build extensions  (2005-01-04)
   http://python.org/sf/1095822  opened by  Jack Jansen

time.tzset() not built on Solaris  (2005-01-05)
   http://python.org/sf/1096244  opened by  Gregory Bond

sys.__stdout__ doco isn't discouraging enough  (2005-01-05)
   http://python.org/sf/1096310  opened by  Just van Rossum

_DummyThread() objects not freed from threading._active map  (2004-12-22)
   http://python.org/sf/1089632  reopened by  saravanand

Example needed in os.stat()  (2005-01-06)
CLOSED http://python.org/sf/1097229  opened by  Facundo Batista

SimpleHTTPServer sends wrong Content-Length header  (2005-01-06)
   http://python.org/sf/1097597  opened by  David Schachter

urllib2 doesn't handle urls without a scheme  (2005-01-07)
   http://python.org/sf/1097834  opened by  Jack Jansen

getsource and getsourcelines in the inspect module  (2005-01-07)
CLOSED http://python.org/sf/1098134  opened by  Björn Lindqvist

mailbox 

Re: The best way to do web apps with Python?

2005-01-08 Thread Steve Holden
worzel wrote:
What is the best way to web developemnt with Python? Is there anything 
close to PHP style in-page script placement that can create and use 
other Python objects? I am not really interested in Zope (I believe that 
is more a CMS than anything else?) I am also looking for something a 
little more structured than a series of CGI Scripts.
 
More ways than you can shake a stick at, but nowadays you should 
consider using WSGI if you want your code to be portable across many 
frameworks. The Web SIG worked very hard last year on defining this 
gateway interface, with the intention that it should become widely 
available, and implementations are available now on environments as 
diverse as mod_python and CherryPy.

You can read about it in Philip Eby's excellent PEP at
  http://www.python.org/peps/pep-0333.html
While on the topic - what is the expectataion of Python for this kind of 
stuff? Would one use Python for certain other things but turn to PHP for 
web apps - or would one use their Python skills in place of PHP?
 
Python is a real programming language, whereas PHP was originally 
intended as a simple way of scripting web content. Since then it has 
grown to encompass many of the same features as Python, but since they 
were retrofitted rather than designed in they are sometimes kind of 
clunky (as, IMHO, is Perl, although in a different way).

But there's a lot of good work been done in both PHP and Perl, and I'd 
usually recommend using existing functionality in either language over a 
just-for-the-sake-of-it rewrite in Python. But that could just be 
because I don't like re-inventing wheels.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Recent infoworld column

2005-01-08 Thread Carlos Ribeiro
On Sat, 08 Jan 2005 13:14:17 -0500, Peter Hansen [EMAIL PROTECTED] wrote:
 Dwarf Electrician wrote:
  from a long time listener...
 
  http://www.infoworld.com/article/04/12/30/01OPstrategic_1.html
 
 Kudos for Roger Binns!

From Mr. Udell himself:


When people talk about the heroes of open source, you tend to hear
such familiar names as Linus Torvalds, Larry Wall, Brendan Eich, Guido
van Rossum, Monty Widenius, Miguel de Icaza, and Rasmus Lerdorf. No
question about it: These people are my heroes. But so is Roger Binns,
and so are the countless other unsung heroes of open source. For
solving a host of vexing problems with quiet competence, and for doing
it in ways that invite others to stand on their shoulders, I salute
them all.


That's recognition. Wow.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Weekly Python Patch/Bug Summary

2005-01-08 Thread Max M
Kurt B. Kaiser wrote:
Remove witty comment in pydoc.py  (2005-01-01)
CLOSED http://python.org/sf/1094007  opened by  Reinhold Birkenfeld
This is not a joke? :-)
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Working with recordsets

2005-01-08 Thread Steve Holden
AdSR wrote:
[EMAIL PROTECTED] wrote:
Hi.
I have one recorset that I would like to pass to 2 functions, one is
for create an CSV file and the other one is to create a HTML file. The
problem is that the recordset is totally read in the first function,
and then when I pass it to the second funtion the recordset is in the
last record.
I've read docs, but I think that one cursor doesn't have something
like movefirst() method. Anybody have an idea to solve this?
Thank's.
Try loading the whole recordset with the fetchall() method and use the 
resulting sequence in your functions. It won't be memory-efficient but 
it will be easy to do.

AdSR
Or, if this doesn't suit, try creating two separate cursors from the 
same connection and execute the same query on each. There's some chance 
that your database driver/backend combination will optimize the queries 
then.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Installing IPython on win2k

2005-01-08 Thread Tim G
Dave Merrill wrote:
 Hi, I'm new to python, and ipython, but not to programming, having
trouble
 getting ipython installed on windows 2000, python 233. Any help would
be
 much appreciated; I'm sure I'm being some basic flavor of dense...

First of all, rest assured that it does work (and quite
easily) so welcome to Python and iPython and I hope
the going's a bit smoother as you go along.

 Then downloaded ipython-0.6.6.zip and unzipped it. When I
double-click
 setup.py, I get only a brief wait cursor; nothing else happens, and
 importing ipython as a test fails.

First of all, ipython isn't really an import into python; you run
it and it runs python (if you understand me). So when you've
installed it, I think it puts an item on your start menu. On
linux, it puts an executable ipython onto your path.

I've just downloaded and run the setup.py, and it does
create a Start Menu item which will start iPython. Look
out for that and see if it does the business.

 Both files in the scripts dir, ipython and pycolor, have no filename
 extension, which seems odd to my newbie eye. I tried renaming them to
.py,
 still no difference.

This is a unixism. Some unix types decry the use of file extensions
because the information the extension gives -- which executable
program to use -- is already embedded in the first line of a file.


 My apologies for this basic question, and my no doubt ignorant
flailing
 about. Very much looking forward to getting this working.
 
 Thanks,
 
 Dave Merrill

Good luck and happy hunting

TJG

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


Re: Embedding a restricted python interpreter

2005-01-08 Thread Dieter Maurer
Doug Holton [EMAIL PROTECTED] writes on Thu, 06 Jan 2005 20:34:31 -0600:
 ...
 Hi, there is a page on this topic here:
 http://www.python.org/moin/SandboxedPython
 
 The short answer is that it is not possible to do this with the
 CPython, but you can run sandboxed code on other virtual machines,
 such as Java's JVM with Jython, or .NET/Mono's CLR with Boo or
 IronPython.

Zope contains a restrictedPython implementation.

  It uses a specialized compiler that prevents dangerous bytecode operations
  to be generated and enforces a restricted builtin environment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread aurora
Of course there are many performance bottleneck, CPU, memory, I/O, network  
all the way up to the software design and implementation. As a software  
guy myself I would say by far better software design would lead to the  
greatest performance gain. But that doesn't mean hardware engineer can sit  
back and declare this as software's problem. Even if we are not writing  
CPU intensive application we will certain welcome free performace gain  
coming from a faster CPU or a more optimized compiler.

I think this is significant because it might signify a paradigm shift.  
This might well be a hype, but let's just assume this is future direction  
of CPU design. Then we might as well start experimenting now. I would just  
throw some random ideas: parallel execution at statement level, look up  
symbol and attributes predicitively, parallelize hash function, dictionary  
lookup, sorting, list comprehension, etc, background just-in-time  
compilation, etc, etc.

One of the author's idea is many of today's main stream technology (like  
OO) did not come about suddenly but has cumulated years of research before  
becoming widely used. A lot of these ideas may not work or does not seems  
to matter much today. But in 10 years we might be really glad that we have  
tried.


aurora [EMAIL PROTECTED] writes:
Just gone though an article via Slashdot titled The Free Lunch Is
Over: A  Fundamental Turn Toward Concurrency in Software
[http://www.gotw.ca/publications/concurrency-ddj.htm]. It argues that
the  continous CPU performance gain we've seen is finally over. And
that future  gain would primary be in the area of software concurrency
taking advantage  hyperthreading and multicore architectures.
Well, another gain could be had in making the software less wasteful
of cpu cycles.
I'm a pretty experienced programmer by most people's standards but I
see a lot of systems where I can't for the life of me figure out how
they manage to be so slow.  It might be caused by environmental
pollutants emanating from Redmond.
--
http://mail.python.org/mailman/listinfo/python-list


Re: there's a socket.sendall(), so why no socket.recvall()?

2005-01-08 Thread Irmen de Jong
Robert Brewer wrote:
Irmen de Jong wrote:
Subject says it all;
there's a socket.sendall(), so why no socket.recvall()?

[...]
If you call .makefile() and then .read() the _fileobject, you get the
same behavior (only better). Adding recvall would just duplicate that, I
think. But that's desirable IMO.
Hm, I didn't consider makefile(). But I'm not sure if that
works in all cases. Until now, I've been using a loop rather
like the one you posted.
But, as I pointed out earlier, there is the MSG_WAITALL option
on various platforms (Linux for instance).
So instead of sticking it in an explicitly programmed loop
in Python, or using an extension module such as this one:
http://mail.python.org/pipermail/python-list/2003-January/143051.html
, I'd rather have a recvall method on the socket object that
essentially uses MSG_WAITALL if available, and uses a
loop construction if not.
I may even write a patch for socketmodule.c right now :-D
--Irmen de Jong
--
http://mail.python.org/mailman/listinfo/python-list


Re: tuples vs lists

2005-01-08 Thread Irmen de Jong
Steve Holden wrote:
Well, it might be Two-Pull in American, but in English it's tyoopl 
-- NOT choopl (blearch!). I've also heard people say tuppl.
Probably the same ones who attend Tuppl-ware parties.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: windows mem leak

2005-01-08 Thread Steve Holden
Bob Smith wrote:
Does the Win32 port of Python have a memory leak? I have some code that 
runs flawlessly on Linux, but bombs after a few hours on Windows. It's 
threaded and uses a lot of memory.

Thanks!
Yes, that's a well-known problem. Code that runs with a few errors will 
port without any trouble at all to Windows, but once it runs flawlessly 
on Linux it starts to leak memory on Windows. The PSU suspects a plot in 
Redmond, the basic details of which ar
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


losing CGI variables in os.environ in Python 2.4

2005-01-08 Thread jtauber
Did something change between 2.3 and 2.4 that would affect os.environ
being populated with CGI variables when using the
BaseHTTPServer/CGIHTTPServer?

I received a bug report from someone trying to run my wiki/blog
software, Leonardo[1] under Python 2.4 on Windows 2000. I was able to
reproduce the problem under Python 2.4 on Windows XP Pro but confirmed
that it worked fine under Python 2.3.

Simply printing out os.environ at the point things like PATH_INFO are
extracted by Leonardo revealed that os.environ contained no CGI-related
variables when run under Python 2.4 but did contain them under 2.3

I can't see in the code for the http server modules that anything
changed in this area. Am I missing something?

Thanks in advance.
James Tauber
http://jtauber.com/blog/

[1] http://jtauber.com/leonardo

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


Re: Installing IPython on win2k

2005-01-08 Thread Dave Merrill

Tim G  wrote in message
news:[EMAIL PROTECTED]
 Dave Merrill wrote:
  Hi, I'm new to python, and ipython, but not to programming, having
 trouble
  getting ipython installed on windows 2000, python 233. Any help would
 be
  much appreciated; I'm sure I'm being some basic flavor of dense...

 First of all, rest assured that it does work (and quite
 easily) so welcome to Python and iPython and I hope
 the going's a bit smoother as you go along.

I'm having fun with python itself, but feeling a little constrained in the
IDE and debugger departments. (Not to mention the clues I haven't got...).


  Then downloaded ipython-0.6.6.zip and unzipped it. When I
 double-click
  setup.py, I get only a brief wait cursor; nothing else happens, and
  importing ipython as a test fails.

 First of all, ipython isn't really an import into python; you run
 it and it runs python (if you understand me). So when you've
 installed it, I think it puts an item on your start menu. On
 linux, it puts an executable ipython onto your path.

 I've just downloaded and run the setup.py, and it does
 create a Start Menu item which will start iPython. Look
 out for that and see if it does the business.

Removed the files I'd unzipped and started over, putting a fresh unzip in
Program Files. Ran setup.py while watching the windows task list, and
pythonw ran for just a second, then disappeared. I saw no other signs of
anything running, and there's no shortcut for ipython in my start menu.


  Both files in the scripts dir, ipython and pycolor, have no filename
  extension, which seems odd to my newbie eye. I tried renaming them to
 .py,
  still no difference.

 This is a unixism. Some unix types decry the use of file extensions
 because the information the extension gives -- which executable
 program to use -- is already embedded in the first line of a file.

So what do I do to try ipython directly, bypassing the shortcut (since I can
make my own later)? I tried right-click on scripts/ipython, Open With, and
chose python, but got only a quick DOS window.

Now what?

Thanks,

Dave Merrill


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


Re: Python Operating System???

2005-01-08 Thread Roose

 Is an OS written in Lisp also ludicrous?  Because it's been done.

Can you point me to this?  I'd like to see how truly Lisp it is.

My first guess would be -- not very.  And I'd like to install it on my PC.


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


Re: Python Operating System???

2005-01-08 Thread Roose
Well can you describe what kind of things you want to do exactly?

My guess is you are not out to develop a new algorithm for virtual memory or
task scheduling.

There are many parts to an OS shell.  An example is the command line, i.e.
bash and the like in Unix, and cmd.exe in Windows.  In Windows, Windows
Explorer could be considered part of the shell, as well as the start menu
and all that user-specific stuff.

Basically you need to pick your OS, and then find out what the API to
program the shell to would be.  e.g. in Windows you would do it with the
Win32 API.  This will let you do things like delete and create files,
interact with user structures, the registry, etc.

OR, as a first stab -- I would just write a prototype.  i.e., don't tie it
to a real OS.  Just pretend you have your own users, your own file
system, your own display space, etc.  This will help you get a much better
idea of what you want to do.


David Brown [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 So how would I make an OS Shell?




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


Re: EOF for binary?

2005-01-08 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], flamesrock
wrote:

 os.path.getsize(infile) = infile.tell()
 
 Because that returns the error:
 #  File /usr/lib/python2.3/posixpath.py, line 142, in getsize
 #return os.stat(filename).st_size
 #TypeError: coercing to Unicode: need string or buffer, file found
 for me.

This error message gives a good hint what's wrong with your code snippet.

 f = open('tmp.txt')
 os.path.getsize(f)
Traceback (most recent call last):
  File stdin, line 1, in ?
  File /usr/lib/python2.3/posixpath.py, line 142, in getsize
return os.stat(filename).st_size
TypeError: coercing to Unicode: need string or buffer, file found

Something expected a string instead of a file object.

 os.path.getsize(tmp.txt)
28190L

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: escape string for command line

2005-01-08 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Ksenia
Marasanova wrote:

 I have a simple ecard creation script on a website, where user can add
 text to a graphic. I use ImageMagick for it:
 
 # template_file = path to image template file
 # new_file = path to generated file
 # text = user input
 command = '''convert %s -font OfficinaSanITC-BookOS -pointsize 12
 -fill #8C2F48 -draw gravity north text 0,26 '%s' %s''' % (
 template_file, text, new_file)
 system(command)
 
 I was wondering, is there a general way to escape the string entered
 by the user, to prevent code injection into command line?

Take a look at the string-escape encoding:

 evil = '; rm -rf /;
 command = echo '%s'
 print command % evil.encode('string-escape')
echo '\'; rm -rf /;'

 Will it
 always be safe, even when binary data is submitted through POST?

Don't know if it's always safe.  Unprintable bytes like 0x00 will be
escaped as '\x00'.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing IPython on win2k

2005-01-08 Thread Dave Merrill
Fernando replied to a similar post of mine on the IPython list, and had a
suggestion that for some unknown reason, worked. Or rather, what's unknown
is why normal setup failed.

For the benefit of anyone else who has this issue, I unzipped the files into

  C:\Program Files\ipython-0.6.6

...then opened a DOS window, and did the following two cmds:

  cd C:\Program Files\ipython-0.6.6
  C:\Program Files\Python23\python.exe setup.py install

Tons of DOS cmds spat out, the shortcut was created, and launching it
brought up the config wizard, then ipython.

I'd really love it if ipython could be invoked in the current debugger
context in PyDev under Eclipse. Is there any way to do that?

Thanks again,

Dave Merrill


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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread John Roth
Peter Hansen [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
John Roth wrote:
I have yet to write a multi-thread program for performance reasons.
If we include in the set of things covered by the term
performance not only throughput, but also latency, then
I suspect you actually have written some multithreaded programs
for performance reasons.
*I* certainly have: that's easily the reason for threading
in 95% of the cases I've dealt with, and I suspect those of
many others.
Actually, I've never written a multi-threaded program for
any reason. There were only two times I had to deal with concurrency:
one was a very nice co-routine implementation (HASP,
the predecessor to the JES2 subsystem on MVS), and
the other was event driven (on an IBM SP). The former
system didn't have a threading library, let alone a lightweight
one, and the event driven design was a lot simpler for the
second application - and I did consider all three options.
John Roth
-Peter 
--
http://mail.python.org/mailman/listinfo/python-list


Documenting data members

2005-01-08 Thread Frans Englich

Hello,

I have a custom module which among others contains a dictionary, acting as a 
constant. I want to document it, but no matter what I do, it doesn't show 
up in `pydoc`. For example, the following doesn't work:


A dictionary of the namespaces.

xmlns = {
...
}

or

xmlns = {

A dictionary of the namespaces.

...
}

Bottom line: how do I document data members?

I also have another documentation question:

In a module which I install, the file starts with a comment containing a 
license header, to then be followed by a Python documentation string(this 
module ...). The problem is that in pydoc, I get the uninteresting license 
header as documentation, instead of the doc string. I want to have the 
license header at the top.
Is this somehow fixable? That the doc string, instead of the license header, 
shows up in pydoc despite the latter being first in the file?


Cheers,

Frans


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


Re: escape string for command line

2005-01-08 Thread Ksenia Marasanova
 
  I was wondering, is there a general way to escape the string entered
  by the user, to prevent code injection into command line?
 
 Take a look at the string-escape encoding:
 
  evil = '; rm -rf /;
  command = echo '%s'
  print command % evil.encode('string-escape')
 echo '\'; rm -rf /;'

Cool, thanks! Next time I'll study stdlib better before asking the question :)

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


Re: Python Operating System???

2005-01-08 Thread jtauber
My experiment, Cleese, was making progress before I got distracted by
other things.

The approach was a micro-kernel in C made up of the CPython bytecode
interpreter with the file-related calls to libc ripped out and some
bare-metal port read/writes and memory operations exposed to Python as
built-in functions.

Everything else could then be written in pure Python. Dave Long was
able to write a VGA driver in Python and an implementation of Sokoban
that used it. You could then boot your machine to Sokoban :-)

I should probably get back to it at some stage.

see http://cleese.sourceforge.net/
James Tauber
http://jtauber.com/blog/

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


Python Installation

2005-01-08 Thread brolewis
I need to install Python on a number of laptop computers (at least a
dozen). I am needing to install Python 2.4, pycrypto, win32all,
wxPython, and pyCurl. Can anyone tell me an easy way to install these
onto the laptops? Ideally I would like to have a single executable to
handle everything for me. I have also looked into using NSIS to handle
the installation, but am still unaware how to install the modules that
I need easily. Does anyone have any suggestions?

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


Re: Python Installation

2005-01-08 Thread brolewis
For what its worth, I am running Windows XP Pro on all of these
machines.

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


Re: python3: 'where' keyword

2005-01-08 Thread Carlos Ribeiro
On Sat, 08 Jan 2005 12:53:05 -0500, Peter Hansen [EMAIL PROTECTED] wrote:
 Andrey Tatarinov wrote:
print words[3], words[5] where:
words = input.split()
 
  - defining variables in where block would restrict their visibility to
  one expression
 
 Then your example above doesn't work...  print takes a
 sequence of expressions, not a tuple as you seem to think.

I found it strange that he had chosen to make the example with
print, that is a statement. I'm not sure how could it be made to
work with both expressions and statements, it just seems strange...

Overall, I found the idea interesting. It seems like a obvious
counterpart to with, in the sense that both act as modifiers to the
scoping rules. I think it can be made to work, and that it would lead
to elegant  readable code, but there are still lots of things to
consider: exception handling, fast name lookup in the where block,
access to symbols outside the where block, just to name a few.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ranting about the state of Python IDEs for Windows

2005-01-08 Thread AkioIto
Carlos Ribeiro wrote:
 Oh well. A mailing list is not the most appropriate place for rants
(a
 blog is better), but it's still better than keeping it for myself.

 I'm frustrated. My search for a good IDE to support my activities --
 doing development for Python in the Windows environment -- are not
 being succesful as I had originally dreamt. I have big constraints on
 what can I do now; money is not an option, and my current machine is
 still useful but it's below par for more advanced stuff. It's my
 fault? Probably. But it's all that I have -- a 500MHz PC with 64MB
and
 Win98 SE. It has to be Windows, for reasons beyond my control (read
 wife and kids :-).

Look at http://www.pspad.com/en/index.html.
Very good and smart editor for Python and other languages.
You even can set menu for brazillian portuguese! And it's free...
A dica vem com um certo atrazo, mas espero que seja util.

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


Re: A Fundamental Turn Toward Concurrency in Software

2005-01-08 Thread Carlos Ribeiro
On Sat, 08 Jan 2005 11:52:03 -0800, aurora [EMAIL PROTECTED] wrote:
 One of the author's idea is many of today's main stream technology (like
 OO) did not come about suddenly but has cumulated years of research before
 becoming widely used. A lot of these ideas may not work or does not seems
 to matter much today. But in 10 years we might be really glad that we have
 tried.

One thing that I would love to see included in Python is a native
library for fast inter-process communication, including support for
message passing primitives and remote object calls. I know that there
are a number of offerings in this arena: third party libraries such as
Pyro, message passing libraries such as the ones from ScyPy, and
standard libraries such as the XMLRPC ones. The key requirements are:
fast, and native.

By fast, I mean, highly optimized, and at least as fast (in the same
order of magnitude, let's say) as any other competitive environment
available. By native, it means that it has to be included in the
standard distribution, and has to be as transparent and convenient as
possible. In other words, it has to feel like a native part of the
language.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: [EMAIL PROTECTED]
mail: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-08 Thread Rick Parsons
On Sat, 08 Jan 2005 14:18:15 +0100, Jan Dries wrote:

snip
 
 The bottom line of the article is that languages authored by men with 
 beards are more successful than those authored by people without beards.
 At least the anecdotical evidence to that is overwhelming :-)
 
 And there is hope for Python, as Guido has recently been seen with a 
 beard :-)
 http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg
 
 Regards,
 Jan



What about languages USED by men with beards?  There may be hope for me
yet.

Regards,
Rick

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


printing line numbers for debugging purpose

2005-01-08 Thread Philippe C. Martin
Hi,

All of the methods from my program return None on error (i.e; I do not
want to assert and have the program exit).

Is it possible to print the current source file name/line number ?

ex: in C/C++ I would use the macros __FILE__ and __LINE__.

Regards,

Philippe



-- 
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***

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


Re: EOF for binary?

2005-01-08 Thread flamesrock
ahh..that does make sense. But maybe getsize() should have a way of
inferring what file is specified. I might actually submit a request..

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


Re: printing line numbers for debugging purpose

2005-01-08 Thread Mark McEahern
Philippe C. Martin wrote:
Hi,
All of the methods from my program return None on error (i.e; I do not
want to assert and have the program exit).
Is it possible to print the current source file name/line number ?
ex: in C/C++ I would use the macros __FILE__ and __LINE__.
Consider something like this:
#!/usr/bin/env python
def main():
   raise RuntimeError('whatever')
if __name__ == '__main__':
   try:
   main()
   except:
   import sys, traceback
   t, v, tb = sys.exc_info()
   traceback.print_tb(tb)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding a restricted python interpreter

2005-01-08 Thread Paul Rubin
Dieter Maurer [EMAIL PROTECTED] writes:
   It uses a specialized compiler that prevents dangerous bytecode operations
   to be generated and enforces a restricted builtin environment.

Does it stop the user from generating his own bytecode strings and
demarshalling them?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Operating System???

2005-01-08 Thread Paul Rubin
Roose [EMAIL PROTECTED] writes:
  Is an OS written in Lisp also ludicrous?  Because it's been done.
 
 Can you point me to this?  I'd like to see how truly Lisp it is.

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

 My first guess would be -- not very.  And I'd like to install it on my PC.

Although written with federal funds at a university, it was never
released to the public, but was instead offered for sale from some
companies.  The conflicts over this led to the birth of the free
software movement.

Also, it was never intended to run on PC's (which didn't exist at that
time).  It needed special hardware that was built for the purpose of
running Lisp.  Lately there are people trying to program PC's to
simulate the Lisp hardware and to get the Lisp Machine software
released (now that the commercial market for it has long since dried
up).  However, both of those projects have a ways to go.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: windows mem leak

2005-01-08 Thread Bob Smith
Steve Holden wrote:
Bob Smith wrote:
Does the Win32 port of Python have a memory leak? I have some code 
that runs flawlessly on Linux, but bombs after a few hours on Windows. 
It's threaded and uses a lot of memory.

Thanks!

Yes, that's a well-known problem. Code that runs with a few errors will 
port without any trouble at all to Windows, but once it runs flawlessly 
on Linux it starts to leak memory on Windows. The PSU suspects a plot in 
Redmond, the basic details of which ar
Oh, the humor of it all ;)
Attached is the code. Run it yourself and see. You too Peter. Be gentle 
with me, this was my first attempt with threads.
import os
import urllib
import socket
import time
import Queue
import threading

##
#   Network Section  #
##

socket.setdefaulttimeout(30)

networks = []
hosts = []
subnets = []

# Add the network 192.168.0 possibility to networks.
networks.append(192.168.0.)

# Generate and add networks 192.168.1-255 to networks.
n = 0
while n  255:
   n = n + 1
   networks.append(192.168.%s. %(n))

# Generate and add hosts 1-254 to hosts.
for network in networks:
   h = 1
   # Add the n.n.n.0 host possibility to hosts.
   hosts.append(network+str(h))
   while h  254:
  h = h + 1
  hosts.append(network+str(h))
  
# This should equal 65024 or 256 * 254
# because 256 possibilities are OK in the 3rd octet,
# but only 254 possibilities are OK in the 4th octet...
# we exclude 0 and 255.
print There are, len(hosts), total hosts (192.168.256*254) in the hosts 
list.

a = 0
b = 254

## Add the 192.168.0 net list to the subnets list.
subnets.append(hosts[0:254])
##print subnets
##print len(subnets)

## Add the 192.168.1-254 net lists to the subnets list.
for x in xrange(254):
a = a+254
b = b+254
subnets.append(hosts[a:b])
##print subnets
##print len(subnets)

## Add the 192.168.255 net list to the subnets list.
subnets.append(hosts[64770 :65024])
##print subnets[0]
print There are, len(subnets), class C network lists in the subnets list.
  
##
#  Queue Section #
##

# Create a queue of urls to feed the threads
# Make it so that the queue only contains 256 items

nmap_queue = Queue.Queue(256)
for subnet in subnets:
nmap_queue.put(subnet)

###
#  Thread Section #
###

class prac(threading.Thread):

def run(self):
net = nmap_queue.get()
for ip in net:
Y = os.popen('nmap -sT -p 80 -P0 -n %s' %ip)
data = Y.read()
Y.close()
if 'open' in data:
O = file('opened.txt', 'a')
print  O, ip
O.close()
elif 'closed' in data:
C = file('closed.txt', 'a')
print  C, ip
C.close()
elif 'filtered' in data:
F = file('filtered.txt' , 'a')
print  F, ip
F.close()
else:
V = file('other.txt', 'a')
print  V, data, ip
V.close()

threads = []
for i in xrange(256):
go = prac()
threads.append(go)
for thread in threads:
thread.start()
while threading.activeCount()  1:
print str(threading.activeCount()), threads running incl. main
time.sleep(1)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pre/Postconditions with decorators

2005-01-08 Thread Stephen Thorne
On Fri, 7 Jan 2005 20:01:50 +0200, George Sakkis [EMAIL PROTECTED] wrote:
  Hi George,
  it would be nice to see how you have tackled
  the task.
  Maybe we will have a checker
  module in Python one day... ;-)
 
 I posted my module on http://rafb.net/paste/results/voZYTG78.html and its 
 unit test on
 http://rafb.net/paste/results/MYxMQW95.html. Any feedback will be appreciated.

Okay, nice.

Unresolved Problems:
1) How do you handle duck types, i.e. a method that accepts StringIO,
cStringIO or any other object that has a .readlines(), .seek() and
.read() method?
2) How do you turn off the type checking for production code?

Otherwise I quite like it. Please publish it somewhere.

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


Re: Pre/Postconditions with decorators

2005-01-08 Thread Paul Rubin
Stephen Thorne [EMAIL PROTECTED] writes:
 Unresolved Problems:
 1) How do you handle duck types, i.e. a method that accepts StringIO,
 cStringIO or any other object that has a .readlines(), .seek() and
 .read() method?

That should really be done through having those classes inherit a
file-operations mixin, or else through interfaces (which might get
added to Python).

 2) How do you turn off the type checking for production code?

It should be left on.  Leaving it in for development and turning it
off for production is like wearing a parachute during ground training
and taking it off once you're in the air.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >