ANN: PyDev 0.9.8.1 released

2005-09-07 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.8.1 has been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.

Details for Release: 0.9.8.1

Major highlights:
---

* Java 1.4 support reintroduced.
* Styles added for syntax highlighting (bold and italic), 
contributed by Gerhard Kalab.


Others that are new and noteworthy:
-

* zombie process after exiting eclipse should not happen anymore
* paths with '.' are accepted for the pythonpath (unless they start 
with a '.', because it may not accept relative paths).
* relative imports are added to code-completion
* local imports are taken into consideration when doing code completion
* debugger has 'change support', so, changed variables in a scope 
appear red


Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com


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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


BayPIGgies: DATE CHANGE September 15, 7:30pm (Google)

2005-09-07 Thread Aahz
DATE CHANGE:

The next meeting of BayPIGgies will be Thurs, September 15 at 7:30pm at
Google.  We still don't have a room at Google; Paul Marxhausen has
accepted the task of pinging people, but we may need to switch to
Ironport if we don't get a room by Tuesday.

Agenda has not been finalized -- we've got several topics and are
juggling them.  Stay tuned!

BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://www.baypiggies.net/


Before the meeting, we plan to meet at 6pm for dinner.  Discussion of
dinner plans is handled on the BayPIGgies mailing list.  

Advance notice: The October 13 meeting agenda has been set.  Please
send e-mail to [EMAIL PROTECTED] if you want to suggest an agenda
(or volunteer to give a presentation).  We've got some options on the
plate for November but haven't settled anything yet.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Possible improvement to slice opperations.

2005-09-07 Thread Bengt Richter
On Tue, 06 Sep 2005 10:31:33 GMT, Ron Adam [EMAIL PROTECTED] wrote:
Steve Holden wrote:
[...]

 My point was that you can make those changes in your own code, leaving 
 others to accept the situation as it is.

It's only a suggestion and an interesting idea I thought I would share 
and see if anyone would like to discuss. I did title this as a 'possible 
improvement', and not as proposed improvement.


 Right, I wasn't trying to suggest that you didn't know what you were 
 talking about - or even that you didn't understand general relativity 
 (on which my grasp could be said to be tenuous) - merely that some 
 things are inherently difficult, and no matter how you twist the 
 implementations about, the difficulties will remain.

But shouldn't we try to make things easier when possible?

Sure ;-)

It occurs to me that maybe this discussion of slicing has a parallel
in mathematical intervals, and we might usefully check if it makes sense there.

IOW, let's compare [a, b] vs [a, b) vs (a, b] vs (a,b)

ISTM the python range model corresponds to [a, b) in terms of integers. The 
step thing
modifies that, but leave that aside to concetrate on the main issue.

For math, I think the notation requires a=b, but for programming, python has a 
convention
for specifying related intervals and a subsetting function, with similar 
notation adding step.

Leaving aside abs(step)!=1 which specifies subsetting, we could say that

 [a:b:1]
is
 [a, b)
and
 [a:b,-1]
is
 (a, b]

but the latter returned in reverse order.

If we factor out the issues of reversing and subsetting, we just have
the indication of which kind of interval: half-open to the right or left.

That we could do by
[a:b] = [a, b)
and
.[a:b] = (a, b]

Then the question is, do we need sugar for reversed(x.[a:b])
or list(reversed(x.[a:b])) for the right hand side of a statement,
and do we want to to use both kinds of intervals in slice assignment?
(maybe and yes ;-)

The reason for yes is that it solves the which-gap problem in assigning to [a:a]
if you define [a, a) as an empty interval to the left of a and (a, a] as an 
empty
interval to the right of a, sort of like +0 and -0 in half-open intervals ;-)
Replacing the empty interval does the insertion on the side you want ;-)

I am choosing the convention to stay compatible with python's current behaviour,
even though I'm not sure what the math world says about ax=a vs a=xa as
different-in-some-sense intervals. I guess the intervals as point sets are the 
same,
but the interval definitions are different...

Other than the a:a distinction, in terms of integers and UIAM
.[a:b]
is just sugar for
[a+1:b+1]
but the sugar is nice, and the slice assignment to either side is nicer.

I'll deal with the subsetting another time ...

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


Re: Possible improvement to slice opperations.

2005-09-07 Thread Bengt Richter
On Tue, 06 Sep 2005 18:34:13 +0200, Magnus Lycka [EMAIL PROTECTED] wrote:
[...]

Then you need to view it more in the mathematical way of
half-open (or half-closed if you prefer) intervals.

[a,b) = { x | a = x  b }

Funny, I just posted with the same thought (and some additional considerations)
I hadn't read yours yet, or I would have mentioned it ;-)

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


Re: os.system(rls) prints to screen??

2005-09-07 Thread Xah Lee
Xah Lee wrote:
 does anyone know why the folllowing prints to the screen?
 # python
 import os
 os.system(rls)

Steve Holden wrote:
 It only prints to the screen when standard output of the invoking
 process is the screen. The sub-process forked by os.system inherits
 stdin stdout and stderr from the invoking process.

Thanks.

 Xah
 [EMAIL PROTECTED]
∑ http://xahlee.org/

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

Re: py2exe 0.6.1 released

2005-09-07 Thread Bengt Richter
On Tue, 06 Sep 2005 11:12:46 +0200, Thomas Heller [EMAIL PROTECTED] wrote:

Giovanni Bajo [EMAIL PROTECTED] writes:

 Thomas Heller wrote:

 * py2exe can now bundle binary extensions and dlls into the
   library-archive or the executable itself.  This allows to
   finally build real single-file executables.

   The bundled dlls and pyds are loaded at runtime by some special
   code that emulates the Windows LoadLibrary function - they are
   never unpacked to the file system.


 Cute!

 I tried it using the wx singlefile example, but unfortunately the resulting
 executable segfaults at startup (using Python 2.3.3 on Windows 2000, with
 latest wxWindows).

Yes, I can reproduce that.  I'm still using wxPython 2.4.2.4 for Python
2.3.5, and that combo works.  I have done a few tests, and wxPython
2.5.1.5 also works, while 2.5.5.1 crashes.

 How can I debug it?

I'll assume that's a serious question.
There is no simple answer.  First, the py2exe'd app responds to a
PY2EXE_VERBOSE environment variable, if you set it to '1', the exe will
reports imports (just as PYTHONVERBOSE does for python scripts).  Of
course you have to change the sample so that it is built as console app
to be able to see the messages.
If you have a place in the program where output should never happen
except when you would want a console window to see it in, you can
call AllocConsole [1] safely even in multiple such places, just before
the printing, and the first such call will create the console and hook
up stdout and stderr ready to print. Subsequent calls to AllocConsole
are effectively ignored, so all the output goes to the same console
no matter which code section executed first. IMO this should be
built into at least the windows wpython to trigger at the first
attempt at stdout or stderr output. There could be an option to
override that default and thus ignore stdout/stderr output, but I
think it would be a useful default. Plus it would tell people early
that they had usesless prints going in their wpython programs.


Then, you can throw some additional prints into
lib\site-packages\zipextimporter.py, to see what it does.

I've done all this, and it seems it is crashing when trying to import
_gdi.pyd.  Next would be to debug through _memimported.pyd, but I don't
have a debug build of wxPython.

That's all I can say now.

I'll ask on the wxPython mailing list if they have an idea.

Thomas

[1]

The AllocConsole function allocates a new console for the
calling process.

BOOL AllocConsole(VOID)

Parameters

This function has no parameters.

Return Value

If the function succeeds, the return value is TRUE. If the
function fails, the return value is FALSE. To get extended
error information, call GetLastError.

Remarks

A process can only be associated with one console, so
AllocConsole fails if the calling process already has a
console. A process can use the FreeConsole function to
detach itself from its current console, and then it can call
AllocConsole to create a new console. If the calling process
creates a child process, the child inherits the new console.
AllocConsole also sets up standard input, standard output,
and standard error handles for the new console. The standard
input handle is a handle to the console's input buffer, and
the standard output and standard error handles are handles
to the console's screen buffer. To retrieve these handles,
use the GetStdHandle function.

This function is primarily used by graphics applications to
create a console window. Graphics applications are
initialized without a console. Console applications are
normally initialized with a console, unless they are created
as detached processes (by calling the CreateProcess function
with the DETACHED_PROCESS flag).

See Also

CreateProcess, FreeConsole, GetStdHandle

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


Re: py2exe uses __init__ for class names when logging

2005-09-07 Thread flupke
Thomas Heller wrote:
snip

 This has been discussed on the py2exe-users lists, and a fix was found
 by David Hess.  Fortunately he added it to the wiki:
 
 http://starship.python.net/crew/theller/moin.cgi/LoggingModule
 
 Thomas

Cool, thanks Thomas, i'll give that a whirl

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


Re: Ode to python

2005-09-07 Thread Gregory Bond
Hmmm... OK...  you forced me into it.

Python uses whitespace
Where C++ uses a brace
New users fret,
But old pros forget -
it quickly all falls into place.

I could go on..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for lambda - 'def' as an expression?

2005-09-07 Thread Simo Melenius
Paul Rubin http://[EMAIL PROTECTED] writes:

 Sybren Stuvel [EMAIL PROTECTED] writes:
  An example:
  
  def generate_randomizer(n, m):
  randomizer = def(x):
  return x ** n % m
  
  return randomizer
 
 You're a little bit confused; name doesn't necessarily mean persistent
 name.  You could write the above as:

   def generate_randomizer (n, m):
  def randomizer(x):
 return pow(x, n, m)
  return randomizer

But if you could do anonymous blocks, you could just write something
like:

def generate_randomizer (n, m):
return def (x):
return pow (x, n, m)

Personally, I don't mind naming local functions in practice (and
Python syntax doesn't lend itself very well to anonymous blocks) but
rather, the nuisance is that I feel there's just plain something wrong
with it. It's less beautiful than it could be.

Luckily, the last time I followed the discussion on this topic in
c.l.p, some bright mind whose name escapes me now pointed out the
craziness of _having to_ name functions by comparing it to the
situation where you'd have to bind any literal objects to symbols
before you could use them. Like:

def return_fixed_number ():
res = 42
return res

or:

arg1 = foo
arg2 = 42
arg3 = baz ()
myfunction (arg1, arg2, arg3.xyzzy ())

Sure, you don't lose any expressiveness in that: if you had to name
any object before using it, you could write all the same programs that
you can in the current Python. But it's the expressiveness of your
mind that gets harpooned: you'll have to keep part of your focus on
these extraneous local variables instead of thinking only in terms
of values where only values matter.


-- 
[EMAIL PROTECTED] -- Today is the car of the cdr of your life.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: round function problem

2005-09-07 Thread Bengt Richter
On Tue, 06 Sep 2005 09:27:48 +0200, mg [EMAIL PROTECTED] wrote:

Hi everybody...

We try to white scripts with Pyrhon 2.4 for an acoustic simulation and 
we wrote these follow lines :

begin script
c = 340
340 is an integer, which is different from 340.
i =j=k= 1
sum_ = 23
also an integer
table = []
freq = round((c/2*(sum_)**0.5),2)
c/2 is integer/integer, which is not the same as c/2.0
rules all-integer arimetic generally produces integer results,
so (unless you import division from __future__) pay attention or
write your constants with decimal points even if the values are exact integers.
note:
  5/2
 2
  from __future__ import division
  5/2
 2.5

print freq
table.append([freq,(i,j,k)])
print i,j,k,' freq',freq
for item in table: print item
end script

The problem is simple. The function 'round' allow to obtain the value 
with the specified number of digits after the ,. Then, when the 
variable 'freq' is printed, there is no problem; but when freq is set in 
the table and the table printed, all the digits are come back.

Is it a bug or a control behavour ? I don't understand ?!?!?!?!...

Others have pointed out the output formatting and binary representation
problems behind your question, but I thought you might not realize the above.

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


Re: Replacement for lambda - 'def' as an expression?

2005-09-07 Thread Paul Rubin
Simo Melenius [EMAIL PROTECTED] writes:
 But if you could do anonymous blocks, you could just write something
 like:
 
 def generate_randomizer (n, m):
 return def (x):
 return pow (x, n, m)

Yes, as it stands you can already say:

   def generate_randomizer(n, m):
 return lambda x: pow(x, n, m)

I was showing that it can also be done with a named internal function.

 Sure, you don't lose any expressiveness in that: if you had to name
 any object before using it, you could write all the same programs that
 you can in the current Python. But it's the expressiveness of your
 mind that gets harpooned: you'll have to keep part of your focus on
 these extraneous local variables instead of thinking only in terms
 of values where only values matter.

Yes, I agree with this.
-- 
http://mail.python.org/mailman/listinfo/python-list


dict and __cmp__() question

2005-09-07 Thread Alex
Entering

 help(dict)
Help on class dict in module __builtin__:

class dict(object)
 |  dict() - new empty dictionary.
 |  dict(mapping) - new dictionary initialized from a mapping object's
 |  (key, value) pairs.
 |  dict(seq) - new dictionary initialized as if via:
 |  d = {}
 |  for k, v in seq:
 |  d[k] = v
 |  dict(**kwargs) - new dictionary initialized with the name=value
pairs
 |  in the keyword argument list.  For example:  dict(one=1, two=2)
 |
 |  Methods defined here:
 |
 |  __cmp__(...)
 |  x.__cmp__(y) == cmp(x,y)
 |
 |  __contains__(...)
 |  D.__contains__(k) - True if D has a key k, else False

snip

 |  update(...)
 |  D.update(E, **F) - None.  Update D from E and F: for k in E:
D[k] = E[k]
 |  (if E has keys else: for (k, v) in E: D[k] = v) then: for k in
F: D[k] = F[k]
 |
 |  values(...)
 |  D.values() - list of D's values

Now I understand methods like update(...) and values(...), for instance

 D={'a':1, 'b':2}
 D.values()
[1, 2]


But what are those with double underscore? For instance __cmp__(...)?

I tried
 D.cmp('a','b')

Traceback (most recent call last):
  File pyshell#7, line 1, in -toplevel-
D.cmp('a','b')
AttributeError: 'dict' object has no attribute 'cmp'


Alex

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


Re: Function returns a function

2005-09-07 Thread Gregory Bond
Paul Rubin wrote:
 Aldo Cortesi [EMAIL PROTECTED] writes:


Thanks to Paul and Aldo...  one more question on the implementation.

Why is the func_closure a tuple of Cells and not just a tuple of 
objects?  Why the extra level of indirection?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ~ after script filename?

2005-09-07 Thread Fredrik Lundh
presentt [EMAIL PROTECTED] wrote:

 Huh, no ~ on other files when I edit them, but at least I don't have to
 worry about it.  Thanks Aldo.

according to

http://www.gnome.org/projects/gedit/

gedit supports backup files, so to figure out how and when they're
created, and how to control their creation, you probably just have
to read the documentation (which doesn't seem to exist on the web;
look in the help menu for the bundled version)

/F 



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


Re: assign dict by value to list

2005-09-07 Thread Bryan Olson

Phill Atwood wrote:
[...]
  So how do I add a dictionary into a list by value rather than
  by reference?

Is rec.items() what you want? It returns a list of (key, value)
tuples.


  The complete code is here:
[...]

Looks like you could use Python's ConfigParser module.

http://docs.python.org/lib/module-ConfigParser.html


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


Re: dict and __cmp__() question

2005-09-07 Thread Bryan Olson
Alex wrote:
  But what are those with double underscore? For instance __cmp__(...)?

Those are these:

 http://docs.python.org/ref/specialnames.html


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


pymacs + dbus

2005-09-07 Thread pber
Hi all,
I'm on trouble with pymacs and python binding of DBus 0.23.

Emacs/Xemacs have their gnuclient(s) to make remote calls to,
but I wanted to (try to) make some xemacs functions callable
via dbus.

Shortly:
- pymacs loads some python classes that publish the method
pop_to_window into a SessionBus (plus a threaded mailoop that 
enables receiving messages from python sub-process)
- when activated, the method pop_to_buffer calls the real 
lisp pop_to_buffer using Pymacs.lisp
- it works if called from inside xemacs: the current buffer switches
to the specified one.
- if called from DBus: my object hears the request and proceeds
to activate xemacs as usually, but in this case pymacs seems to ignore
the request. In buffer *Pymacs*, the last message I read is this:

31 (progn (pop-to-buffer sdbg))

and nothing more: pymacs does not reply.

Any idea?

Best regards
Paolo Bernardi

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


Re: Generators and Decorators doing my head in ..

2005-09-07 Thread Michele Simionato
I usually point out my decorator module
(http://www.phyast.pitt.edu/~micheles/python/decorator.zip) to simplify
decorator usage. In this case you would use it as follows:

from decorator import decorator

@decorator # convert logFunctionCalls into a decorator
def logFunctionCalls(function, *args, **kwargs):
try: # increment the counter
function.counter += 1
except AttributeError: # first call, there is no counter attribute
function.counter = 1
print Entering function:, function.__name__, function.counter
return function(*args, **kwargs)

@logFunctionCalls
def f():
pass

f()
f()
f()

help(f)

The whole point of the decorator module is that the signature of
the original function is left unchanged (i.e. in this case the
decorated f is still a thunk, not a generic function f(*args, **kw)).
HTH,

 Michele Simionato

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


Reading in external file - error checking and line numbers...

2005-09-07 Thread Hugh Macdonald
I'm writing a tool at the moment that reads in an external file (which
can use any Python syntax)

At the moment, I'm reading the file in using:

scriptLines = open(baseRippleScript).read()
exec scriptLines

However, if I raise an exception in my main code, in a function that is
called from the external script, the stack trace just has:

File string, line 8, in ?

Ideally, I'd want to be able to avoid throwing exceptions and would
like to, from my main code, print out an error that included the script
name (easily accessible) and the line number (less easily accessible).

Is there a better way of executing an external script that would let me
access at any time the line number from the external script that is
being executed.


More specifically, if a function is called from an external script with
an invalid parameter type, I want to be able to flag it accurately to
the user

Hope this made sense - let me know if I've confused you at all.


--
Hugh Macdonald

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


Re: Reading in external file - error checking and line numbers...

2005-09-07 Thread Fredrik Lundh
Hugh Macdonald wrote:

 I'm writing a tool at the moment that reads in an external file (which
 can use any Python syntax)

 At the moment, I'm reading the file in using:

 scriptLines = open(baseRippleScript).read()
 exec scriptLines

 However, if I raise an exception in my main code, in a function that is
 called from the external script, the stack trace just has:

 File string, line 8, in ?

 Ideally, I'd want to be able to avoid throwing exceptions and would
 like to, from my main code, print out an error that included the script
 name (easily accessible) and the line number (less easily accessible).

exec compile(scriptLines, baseRippleScript, exec)

(but in this case, you might as well use the execfile built-in)

/F 



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


multi pointer slider(scale)

2005-09-07 Thread [EMAIL PROTECTED]
HI, I am new to python graphics. I want to have a scale(tkinter) or
slider(wxpython), on which I can have more than one pointers. Using it
I want to have single slider for different parameters of an entity. Can
anyone help me to look for it OR make it.
Thanks in adwance.

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


Re: Reading in external file - error checking and line numbers...

2005-09-07 Thread Hugh Macdonald
Thankyou! That was much easier than I expected.

One more thing on a similar note. When raising exceptions, is it
possible to remove a few items from the top of the stack trace?

My stack trace is looking something like:

  File ripple, line 160, in ?
  File ripple, line 94, in executeRipple
  File test.rip, line 8, in ?
dependsOnFrame = new)
  File ripple, line 133, in __init__
  File ripple, line 148, in addDependsOnFrame
__main__.RippleError: 'Cannot add frame dependency to non frame-based
node'

I'd like to be able to remove the last two items in the stack so that
it just shows the user:

  File ripple, line 160, in ?
  File ripple, line 94, in executeRipple
  File test.rip, line 8, in ?
dependsOnFrame = new)
__main__.RippleError: 'Cannot add frame dependency to non frame-based
node'

Unfortunately, I don't know how many 'ripple' stack items there will
be...

This is why I'd much rather, if I can, do this without exceptions and
just be able to print out my own error message with the problem line
number marked

Or am I asking too much? ;)

--
Hugh Macdonald

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


Re: Replacement for lambda - 'def' as an expression?

2005-09-07 Thread Tom Anderson
On Tue, 6 Sep 2005, talin at acm dot org wrote:

 add = def( a, b ):
   return a + b

+1

This is so obviously the right syntax for closures in python that i really 
can't believe we're still arguing about it.

 What about passing an anonymous function as an argument, which is the 
 most common case? This gets tricky, because you can't embed a suite 
 inside of an expression. Or can you?

 The most powerful option would be to leverage the fact that you can
 already do line breaks inside of parentheses. So the def keyword
 would tell the parser to restart the normal indentation calculations,
 which would terminate whenever an unmatched brace or paren was
 encountered:

 a = map(
   (def( item ):
  item = do_some_calculation( item )
  return item
   ), list )

Can't we just rely on indentation here:

a = map(
def(item):
item = do_some_calculation(item)
return item
, list)

?

A consequence of that is that you *must* end the suite on a line of its 
own; with your scheme, you can in fact write:

a = map((def(item):
item = do_some_calculation(item)
return item), list)

Although i'm not convinced that this is something i want to be possible!

 The one-liner version looks a lot prettier of course:

 a = map( (def( item ): return item * item), list )

To do one-liners, which is absolutely essential, we can't rely on line 
ends, of course, so we'd need your scheme to be in operation here. For 
consistency, it should also apply to multi-line suites; it should be 
possible to have both the bracket-based and line-based rules in effect at 
the same time - changes in indent level are essentially treated as a kind 
of bracket.

 And it looks even nicer if we switch the order of the arguments around,
 since you can now use the final paren of the enclosing function call to
 terminate the def suite.

 a = map( list, def( item ): return item * item )

 Unfortunately, there's no other good way I can think of to signal the 
 end of the block of statements without introducing some radical new 
 language construct.

If there were no statements which ended with an expression list, it would 
be possible to detect the end by the presence of a comma. The python 
grammar would only need a few changes to meet that requirement, none of 
them that disruptive (mostly, you replace the expression list with a tuple 
- in many cases, making explicit what was previously implicit).

 (Besides, if being an expression is good enough for 'yield', why 
 shouldn't def get the same privilege? :)

A fine point!

tom

-- 
And the future is certain, give us time to work it out
-- 
http://mail.python.org/mailman/listinfo/python-list


Is there anything better than impalib/poplib?

2005-09-07 Thread Alessandro Bottoni
Is there any module or interface that allow the programmer to access a
imap4/pop3 server in a more pythonic (or Object Oriented) way than the
usual imaplib and popolib? 

I mean: is there any module that would allow me to query the server for
specific messages (and fetch them) in a way similar to a OODB?

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


Re: ~ after script filename?

2005-09-07 Thread Benjamin Niemann
presentt wrote:

 Hello all,
 
 I just wrote a really simple script and named it helloworld.py.  Inside
 was only:
 
 #!/usr/bin/env
 print Hello, world
 
 I used chmod to set the permissions, and ran it to see what happened (I
 just started learning Python, if you couldn't guess)
 
 Then, I typed ls in the directory to see what was there, and I noticed
 a new file, namely helloworld.py~ .  What is that file (its contents
 are identicle to helloworld.py)?  Why the ~?
 
 Thanks a lot.  I'm using Ubuntu Linux 5.04 (Hoary), and wrote the
 script with gedit.
 
 ~~Ted Present

As others have already said: this is not a python issue.

A ~ suffix is commonly used by editors for backup file. If you save a file
from the editor, and the file already exists (so it doesn't happen the
first time you save a new file), the existing version is renamed with the ~
suffix.

After some time, you will learn to simply ignore these files ;)
Many file managers have already learnt this lesson and have options to hide
such backup files.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


PEP-able? Expressional conditions

2005-09-07 Thread Kay Schluehr
One of the main reasons Pythons anonymous function lambda is considered
to be broken is Pythons disability to put statements into expressions
and support full functionality. Many attempts to improve lambdas syntax
had also been attempts to break the expression/statement distinction in
one or the other way. None of this suggestions have ever been
successfull in solving severe problems caused by Pythons indentation
syntax and I guess they will never succeed. On the other hand I do not
see immediately the necessaty to support the full range of Python
constructs in small anonymous functions that are dedicated to fit into
one line.

Instead of pushing statements into expressions one can try to do it the
other way round and model expressions with the functionality of
statements. The most important use-cases are assignments and
conditions. I want to consider conditions only.

In Python conditional statements have the form:

if COND_1:
   BLOCK_1
elif COND_2:
   BLOCK_2
...
else:
   BLOCK_n

Before turning this kind of statement into an expression we have to
restrict the BLOCKs to expressions:

if COND_1:
   EXPR_1
elif COND_2:
   EXPR_2
...
else:
   EXPR_n

Since the conditional statement is traversed sequentially we can
transform it into a sequence of (COND,EXPR) pairs. Finally we have to
recover the conditional semantics.

I want to propose a new associative binary operator that acts on
(COND,EXPR) pairs like a projection on the second EXPR argument of a
pair in case of COND evaluated True.

This function works much like

def cond(pair1, pair2):
COND1,EXPR1 = pair1
if COND1:
return EXPR1
try:
COND2,EXPR2 = pair2
if COND2:
return EXPR2
except TypeError:
return pair2


Alternative syntax proposals:

(a)   (COND1,EXPR1) || (COND2,EXPR2)
(b)   (COND1,EXPR1) case (COND2,EXPR2)
(c)   (COND1,EXPR1) owise (COND2,EXPR2)
(d)   (COND1,EXPR1) ? (COND2,EXPR2) 

Regards,
Kay

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


Re: determine if os.system() is done

2005-09-07 Thread Alessandro Bottoni
Xah Lee wrote: 
 of course, i can try workarounds something like os.system(gzip -d
 thiss.gz  tail thiss), but i wish to know if there's non-hack way to
 determine when a system process is done.

Well, if you use a function of the popen family, you get some kind of
return value from the subprocess on your output pipe. You should be able
to determine if your subprocess has terminated by examining (parsing) this
output pipe.

If you use os.system(), you should get a single return value (usually None
or a error code) that you can use for this task.

In both cases, you may have to use a loop (sleep(x)) to wait for the return
value (and check it) from within your code.

Have a look at the docu of the os.process module for details. (Maybe the
newer subprocess module is a better choice...)

HTH

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


Re: Python versus Perl

2005-09-07 Thread Michael Sparks
Dieter Vanderelst wrote:

 Dear all,
 
 I'm currently comparing Python versus Perl to use in a project that
 involved a lot of text processing. I'm trying to determine what the
 most efficient language would be for our purposes. I have to admit
 that, although I'm very familiar with Python, I'm complete Perl noob
 (and I hope to stay one) which is reflected in my questions.
 
 I know that the web offers a lot of resources on Python/Perl
 differences. But I couldn't find a satisfying answer to my questions:
 
 1 - How does the speed of execution of Perl compares to that of
 Python?

Much of a muchness in my experience.(Qualitative, not quantative)

 2 - Regular Expressions are a valuable tool in text processing. I have
 noticed that Regular Expressions are executed very fast in Python.
 Does anybody know whether Python executes RE faster than Perl does?
 3 - In my opinion Python is very well suited for text processing. Does
 Perl have any advantages over Python in the field of textprocessing
 (like a larger standard library maybe).

These two are related. If you're writing code and you expect to be
using *a lot* of regular expression [*] type code then you may find perl
more convenient.

   [*] That /might/ suggest you're taking the wrong approach mind you...

Python, for me, tends to be more readable, both immediately after
writing and if I go back to a year later - for maintenance, extension
etc.

Personally I like both languages for day in day out use, but these days
tend to choose python if I think I'm likely to want to modify or extend
the code. With the exception being where I'm doing heavy text
processing work that I think will be more maintainable in perl, or I'm
really sure I won't have to maintain it. (eg quick and dirty scripts)

One side effect of perl usage though is that due to them being easy to
use and convenient, they can get over used. (Rather than thinking
what's the best way of solving this problem, people can end up
thinking What regular expression can solve this problem - which isn't
ideal)

Your comment I'm complete Perl noob (and I hope to stay one) 
would suggest to me that if you really feel that way, stay that way :-)
(Though personally I do like learning new programming languages, since
you get more idioms and tools under your belt that way.)

 I hope somebody can answer my questions. Of course, every remark and
 tip on Python/Perl in texprocessing is most welcome.

In case you're not aware there's the book Text Processing in Python by
David Mertz, which is available online in a free as in beer form
which might be of use if you decide python instead of perl.


Michael.
-- 
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.

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


Re: determine if os.system() is done

2005-09-07 Thread Thomas Bellman
Xah Lee [EMAIL PROTECTED] writes:

 suppose i'm calling two system processes, one to unzip, and one to
 tail to get the last line. How can i determine when the first
 process is done?

 Example:

 subprocess.Popen([r/sw/bin/gzip,-d,access_log.4.gz]);

 last_line=subprocess.Popen([r/usr/bin/tail,-n 1,access_log.4],
 stdout=subprocess.PIPE).communicate()[0]

 of course, i can try workarounds something like os.system(gzip -d
 thiss.gz  tail thiss), but i wish to know if there's non-hack way to
 determine when a system process is done.

Have you tried reading the manual for the subprocess module?  You
just *might* find the answer to your question if you look at what
you can do with Popen objects.  Actually, just learning about the
exact semantics of the communicate() method might be enought to
solve your problem.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
I refuse to have a battle of wits with an   !  bellman @ lysator.liu.se
 unarmed person.!  Make Love -- Nicht Wahr!

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

Re: Job Offer in Paris, France : RD Engineer (Plone)

2005-09-07 Thread Adriaan Renting
 I'm in the US and have no EU papers.  Still feasible?

Unless you and your employer know the to talk the talk and walk the walk, it's 
probably going to be hard. I work at a place in the Netherlands where about 50% 
of the employees are from abroad, with large numbers from places like the USA, 
Canada, Russia, Australia, India etc. and from what I hear it's a lot of hoops 
you need tou jump though. Stuff like getting a house, work permit, car, drivers 
licence will be expensive and very time consuming, more so in Paris. It helps a 
lot if your employer knows to push the right buttons.

Not to discourage you, working abroad can realy be a nice thing to do, but 
expect a lot of paperwork, and a lot of contradicting answers. The basic thing 
is, that most european goventments aren't set up to deal with expats, most 
immigrants are economic and political refugees from the developing world, and 
Europe is trying to make it as hard as possible for them to get in.

And about the French language: Try to find some french radio broadcast on the 
internet or something like that, and see if you can understand it. I find 
reading/writing/speaking French is o.k., but understanding native speakers can 
be very hard. I have a lot easier time understanding for example italians 
speaking French.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: determine if os.system() is done

2005-09-07 Thread Fredrik Lundh
Thomas Bellman wrote:

 Have you tried reading the manual for the subprocess module?

han har försökt, men hans tourette tog överhanden:

http://mail.python.org/pipermail/python-list/2005-September/297642.html

/F 



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

Re: Job Offer in Paris, France : RD Engineer (Plone)

2005-09-07 Thread Paul Rubin
Adriaan Renting [EMAIL PROTECTED] writes:
 Not to discourage you, working abroad can realy be a nice thing to
 do, but expect a lot of paperwork, and a lot of contradicting
 answers. The basic thing is, that most european goventments aren't
 set up to deal with expats, most immigrants are economic and
 political refugees from the developing world, and Europe is trying
 to make it as hard as possible for them to get in.

Yes, I understand this, it's similar in the US.  That's why I had doubts
about it.  I did just chat with Huron about it and he thinks the problem
may be solvable, though certainly inconvenient at the least.

 And about the French language: Try to find some french radio
 broadcast on the internet or something like that, and see if you can
 understand it. I find reading/writing/speaking French is o.k., but
 understanding native speakers can be very hard. I have a lot easier
 time understanding for example italians speaking French.

I think the best way to deal with this is to listen to live speakers
for several hours a day.  After a few weeks, the words come into focus
from the formerly continuous blur of sound.  After that, one must of
course still work on figuring out what they mean ;-).  

As I mentioned, I once had a good French class in school, and at that
time I could understand spoken French fairly well.  That was a long
time ago but I think it would come back.  I never learned any French
computer jargon back then and don't know any now, but I expect I could
pick it up.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: determine if os.system() is done

2005-09-07 Thread Jeremy Jones
Thomas Bellman wrote:

Xah Lee [EMAIL PROTECTED] writes:

  

suppose i'm calling two system processes, one to unzip, and one to
tail to get the last line. How can i determine when the first
process is done?



  

Example:



  

subprocess.Popen([r/sw/bin/gzip,-d,access_log.4.gz]);



  

last_line=subprocess.Popen([r/usr/bin/tail,-n 1,access_log.4],
stdout=subprocess.PIPE).communicate()[0]



  

of course, i can try workarounds something like os.system(gzip -d
thiss.gz  tail thiss), but i wish to know if there's non-hack way to
determine when a system process is done.



Have you tried reading the manual for the subprocess module?  You
just *might* find the answer to your question if you look at what
you can do with Popen objects.

Oh, come on.  Don't you know that all Python documentation is rubbish 
and not worth reading, written by IT idiots who throw around useless 
jargon and indulge in extreme forms of self-gratification?  Someone of 
the caliber of Xah Lee would *never* stoop so low as to actually read 
the documentation.  It is beneath him.  Instead, he posts messages to a 
group of IT idiots who throw around useless jargon and indulge in 
extreme forms of self-gratification in posting answers to questions.

snip

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


Re: determine if os.system() is done

2005-09-07 Thread Martin Franklin
Xah Lee wrote:
 suppose i'm calling two system processes, one to unzip, and one to
 “tail” to get the last line. How can i determine when the first
 process is done?
 
 Example:
 
 subprocess.Popen([r/sw/bin/gzip,-d,access_log.4.gz]);
 
 last_line=subprocess.Popen([r/usr/bin/tail,-n 1,access_log.4],
 stdout=subprocess.PIPE).communicate()[0]
 
 of course, i can try workarounds something like os.system(gzip -d
 thiss.gz  tail thiss), but i wish to know if there's non-hack way to
 determine when a system process is done.
 
  Xah
  [EMAIL PROTECTED]
 ∑ http://xahlee.org/
 



I think the idea is you wait for the first call to subprocess.call to
finish before executing the second...



http://docs.python.org/lib/node231.html


call(   *args, **kwargs)
   Run command with arguments. *Wait for command to complete*, then
   return the returncode attribute.

   The arguments are the same as for the Popen constructor. Example:

   retcode = call([ls, -l])





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

Re: determine if os.system() is done

2005-09-07 Thread Nainto
Yeah, I agree. The Python documentation just merey describes what
arguements a function can take not as much how to use the actual
function.

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


Re: determine if os.system() is done

2005-09-07 Thread Fredrik Lundh
Nainto [EMAIL PROTECTED] wrote:
 Yeah, I agree. The Python documentation just merey describes what
 arguements a function can take not as much how to use the actual
 function.

yeah, that's a really relevant criticism when we're talking about a
module that contains one function and one class, and for which the
documentation contains *sixteen* examples.

/F 



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


Re: determine if os.system() is done

2005-09-07 Thread Lars Gustäbel
[Fredrik Lundh]
 han har försökt, men hans tourette tog överhanden:

IMHO it's more likely an Asperger's syndrome.

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

-- 
Lars Gustäbel
[EMAIL PROTECTED]

Any sufficiently advanced technology is indistinguishable
from magic.
(Arthur C. Clarke)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with Python for Windows extensions

2005-09-07 Thread KK
Hello,
I guess you could reproduce my problem, Kartic. I have tried the one u
suggested, but sadly it didn't work for me. I think the COM of pywin is
quite tricky, or it might be a bug. I have some friends who also had
experience of weird behaviors of pywin32, which makes me skeptical of
using it in real app.

Thanks
KK

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


Re: dual processor

2005-09-07 Thread Robin Becker
Paul Rubin wrote:
 Jeremy Jones [EMAIL PROTECTED] writes:
 
to pass data around between processes.  Or an idea I've been tinkering
with lately is to use a BSD DB between processes as a queue just like
Queue.Queue in the standard library does between threads.  Or you
could use Pyro between processes.  Or CORBA.
 
 
 I think that doesn't count as using a the multiple processors; it's
 just multiple programs that could be on separate boxes.
 Multiprocessing means shared memory.
 
 This module might be of interest:  http://poshmodule.sf.net
 
It seems it might be a bit out of date. I've emailed the author via sf, but no 
reply. Does anyone know if poshmodule works with latest stuff?
-- 
Robin Becker

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


Re: __dict__ of object, Was: Regular Expression IGNORECASE differentfor findall and split?

2005-09-07 Thread Chris
Fredrik Lundh wrote:
 Chris [EMAIL PROTECTED] wrote:
 
 
but more of a basic question following, I was doing the following before:

method = 'split' # came from somewhere else of course
result = re.__dict__[method].(REGEX, TXT)

precompiling the regex

r = compile(REGEX)

does give an regex object which has the needed methods

print dir(r)
['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner',
'search', 'split', 'sub', 'subn']

but how do I evaluate them without explicitly calling them?

result = r.__???MAGIC???__[method](TXT)

obviously I am not a Python pro ;)
 
 
 I really don't understand why you think you have to write
 your RE code that way, but the mechanism you're looking
 for is getattr:
 
 result = getattr(r, method)(TXT)
 

thanks (also to Steven) for the info, that is exactly what i was looking 
for.

reason is that I built a small UI in which the user may choose if he 
want to do a split, findall (and maybe later others like match or 
search). So the method name comes in from the UI. I could of course 
use if/elif/else blocks but thought getattr should be shorter and 
easier. I was not really aware of getattr which I was looking for on 
other occations before...

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


Open source Web testing tool - cPAMIE 1.6b released

2005-09-07 Thread calfdog
I am pleased to announce version cPAMIE 1.6 the Web automation tool for
Internet explorer.

If your looking for a fast way, easy to learn way to drive your browser
check out PAMIE.

Is PAMIE right for you?, depends on your needs and complexity of the
web application. Pamie can take care of the basic needs such as driving
web forms without a problem.

Been used to test and/or drive Dot Net and Java web applications.
can be combined with other opensource tools such as JMeter for
performance testing.

New Features:

* WriteScript method that writes out pamie scripts
* Frame Support
* Fixes for bugs related to XP sp2
* Get and Set methods for manipulating most controls. For example you
can set and/or get the values of textboxes, listboxes, radiobuttons,
tables, textarea's, checkboxes etc...
* Click methods for buttons, tree objects and links
* Fire Event methods
* Ability to parameterize data and drive data with add-on DataDriver
Class.
* Manipulate existing or new Browser windows (not modal dialogs)using
find window method.

* Use with pythons's PyUnit (unittest) for a complete web testing
framework.

To Do:
* Better Support for modal/non-modal type dialogs
* Threading to be addded.

Questions - email me: [EMAIL PROTECTED]

Enjoy
Rob M.

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


Re: Ode to python

2005-09-07 Thread Luis M. Gonzalez
I guess we all say foolishness when we're in love...

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


Re: Installation question

2005-09-07 Thread malv
I can't give you an exact answer, but maybe this helps a bit:
I tried running both Python 2.3 and 2.4 (both 32) with Qt3 on two other
distros. It never really worked and gave me lots of problems. It
certainly messed up a few things here and there. I never managed to
get things straightened out.
I later installed Suse 9.3 Pro with both Gnome  KDE. When installing
the eric3 IDE, I found that everything I needed, Python 2.4, Qt3.3,
PyQt, Sip, QScintilla was there already. (If I recall, I had only to
add in one or two development libraries for Qt).

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


Re: documentation error

2005-09-07 Thread Terry Hancock
On Sunday 04 September 2005 01:30 pm, Reinhold Birkenfeld wrote:
 tiissa wrote:
  bill wrote:
 From 3.2 in the Reference Manual The Standard Type Hierarchy:
  
  Integers
  These represent elements from the mathematical set of whole
  numbers.
  
  The generally recognized definition of a 'whole number' is zero and the
  positive integers.
  
  This term is ambiguous as it seems to be used for both natural numbers 
  and signed numbers [1].

You realize, of course, that natural numbers don't include zero. ;-)

This is a pretty serious nitpick, isn't it?  Integers is a well defined
mathematical concept, as well as a pretty well defined (but not coincident)
computer science concept.  It's probably worth mentioning that Python uses
the *mathematical* definition of integer here -- or more precisely that
Python long integers do, while regular integers are what are known as
long integers in C.

Okay.  I guess that *is* pretty confusing.

I think the manual is not so far off since whole number makes English
sense, if not mathematical.  Certainly, if I were explaining this to my
kids I would say whole and not integer (I at least know they know what
whole means).

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: Python compiled?

2005-09-07 Thread Terry Hancock
On Tuesday 06 September 2005 11:32 am, Jorgen Grahn wrote:
 I hope people are less hesitant to install interpreted applications today
 than they were ten years ago.
 
 I also believe it's better to convince the end user to install Python before
 installing the application[1], rather than to try to sneak in an interpreter
 with py2exe or something -- an interpreter which the end user cannot update,
 manage or use for other things.

I have to confess to be very ignorant about the Windows installation options
for Python packages, but surely in principle at least, it should be possible
to make self-installing .EXE files that do what I get from

apt-get install python-mypackage

or at least

dpkg --install mypackage

That is to say, which install an interpreter if one isn't already there, and
then install the package. Or, upon finding an interpreter install into it
along the lines of distutils.

I mean, with the whole AUTOEXEC.BAT start up a CD and run whatever
evil code we find there as soon as we stick it into our unwisely 
promiscuous machine, it ought to make it possible for the installation
to be completely transparent to the user.

You know, after writing that, I'm starting to rethink what people
mean when they say Windows is easy.  ;-)

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: Assigning 'nochage' to a variable.

2005-09-07 Thread Terry Hancock
On Sunday 04 September 2005 06:34 pm, Terry Reedy wrote:
  resembling the 'Z'-state of a electronic tri-state output?
 
 Not familiar with that.

Tri-state logic gate outputs can do one of three things:

 1) They can drive the voltage to 0.0  0
 2) They can drive the voltage to VCC  1
 3) They can act like they aren't connected at all Z

The Z actually is the standard symbol for impedence (in
DC circuits this is just a fancy way to say resistance), and
is short for high-Z state or high impedence state, which
is very much like what would happen if you just cut the wire.

Sending gates into the Z state is what allows computer buses
to work at all -- only the addressed register is allowed to
control the bus wires, all other connected devices are in the
Z state.

The software equivalent is throwing certain terms out of
a sum.  We usually do that with control flow.  Doing it
implicitly by value seems like it could be dangerous, but
I'd have to see a more complete implementation example to
be convinced one way or the other about that.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


BayPIGgies: DATE CHANGE September 15, 7:30pm (Google)

2005-09-07 Thread Aahz
DATE CHANGE:

The next meeting of BayPIGgies will be Thurs, September 15 at 7:30pm at
Google.  We still don't have a room at Google; Paul Marxhausen has
accepted the task of pinging people, but we may need to switch to
Ironport if we don't get a room by Tuesday.

Agenda has not been finalized -- we've got several topics and are
juggling them.  Stay tuned!

BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://www.baypiggies.net/


Before the meeting, we plan to meet at 6pm for dinner.  Discussion of
dinner plans is handled on the BayPIGgies mailing list.  

Advance notice: The October 13 meeting agenda has been set.  Please
send e-mail to [EMAIL PROTECTED] if you want to suggest an agenda
(or volunteer to give a presentation).  We've got some options on the
plate for November but haven't settled anything yet.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Job Offer in Paris, France : RD Engineer (Plone)

2005-09-07 Thread Fred Pacquier
Adriaan Renting [EMAIL PROTECTED] said :

 And about the French language: Try to find some french radio broadcast
 on the internet or something like that, and see if you can understand
 it. I find reading/writing/speaking French is o.k., but understanding
 native speakers can be very hard. I have a lot easier time
 understanding for example italians speaking French. 

This is a general case, and it goes both ways : we French usually 
communicate much more easily with italians (or whatever) speaking english 
than with native anglo-american speakers. Anyway, source code (esp. python) 
is the modern esperanto/volapük :-)

-- 
YAFAP : http://www.multimania.com/fredp/
-- 
http://mail.python.org/mailman/listinfo/python-list


encryption with python

2005-09-07 Thread jlocc
Hi!

I was wondering if someone can recommend a good encryption algorithm
written in python. My goal is to combine two different numbers and
encrypt them to create a new number that cann't be traced back to the
originals.

It would be great if there exists a library already written to do this,
and if there is, can somebody please point me to it??

Thanks in advance,
J

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


Re: PEP-able? Expressional conditions

2005-09-07 Thread Terry Hancock
On Wednesday 07 September 2005 05:29 am, Kay Schluehr wrote:
 Instead of pushing statements into expressions one can try to do it the
 other way round and model expressions with the functionality of
 statements. 

 Alternative syntax proposals:
 
 (a)   (COND1,EXPR1) || (COND2,EXPR2)
 (b)   (COND1,EXPR1) case (COND2,EXPR2)
 (c)   (COND1,EXPR1) owise (COND2,EXPR2)
 (d)   (COND1,EXPR1) ? (COND2,EXPR2) 

You appear to be reinventing the C ternary operator.  This is
definitely a dead horse. There was already a PEP, and it was
refused.

If you actually want this, you're going to have to implement it
with a function:

def ternary(condition, true_result, false_result):
if condition:
return true_result
else:
return false_result

Almost as good, and you don't have to talk curmudgeons into providing
it for you.

Cheers,
Terry   

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


question from beginner

2005-09-07 Thread dario
Hi, Im new on phyton programming.
On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive
a string from serial port and after send this one enclosed in an
e-mail.
All OK if the string is directly generated in the code. But it doesn't
works if I wait for this inside a 'while' loop. This is the simple
code:

global stringZVEI

  while stringZVEI=='':
  MOD.sleep(10)
  a=SER.send(' sono nel while stringZVEI==st vuota')
  stringZVEI = SER.readbyte()
  a=SER.send(' stringZVEI=')
  a=SER.send(stringZVEI)

MOD and SER are embedded class maked by third part.

From my very little debug possibility it seem that loop is executed 1
time only nevertheless stringZVEI is still empty. The line
  a=SER.send(' stringZVEI=')
work correctly but

a=SER.send(stringZVEI) 

doesn't work

Any suggestion?

Thanks
Dario.

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


Re: epydoc CLI and many files

2005-09-07 Thread Terry Hancock
On Monday 05 September 2005 08:10 am, Laszlo Zsolt Nagy wrote:
 I have a problem under Windows. 

There's your problem. ;-)

 I use the cli.py program included with 
 epydoc. I wrote a small program that lists all of my modules after the 
 cli. Something like this:
 
 cli.py  --html  --inheritance=grouped module1.py module2.py module3.py 
 ..
 
 The problem is that now I have so many modules that the shell (cmd.exe) 
 cannot interpret this as a one command. 

 How to overcome this problem?

Use Linux. Or Unix.  Or Mac OS X probably.  You know, a real
operating system. ;-)

Seriously though, try using a wildcard pattern instead of explicit
module names.

In POSIX systems, the shell expands wildcards into multiple files on
the command line, but under DOS/Windows systems, the expansion normally
takes place within the program (I think this is still true).  In this
case, I would guess that the Python interpreter would do the
expansion. That should avoid any limits on command length that
cmd.exe is giving you (I'm trusting that Python is much more capable).

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: Problems with Python for Windows extensions

2005-09-07 Thread Kartic
The Great 'KK' uttered these words on 9/7/2005 7:57 AM:
 Hello,
 I guess you could reproduce my problem, Kartic. I have tried the one u
 suggested, but sadly it didn't work for me. I think the COM of pywin is
 quite tricky, or it might be a bug. I have some friends who also had
 experience of weird behaviors of pywin32, which makes me skeptical of
 using it in real app.
 
 Thanks
 KK
 

Actually, I have created some robust win32com applications (using Word 
and Excel) that work consistently on all installed machines.

Could it be an Office 2003 quirk? Did some other app of yours crash 
while using COM? Such crashes could produce unpredictable results in COM 
related code, from my experience.

So, if you think it is worth your time, you could probably investigate 
it a bit more or better contact Mark Hammond to see if he can help. I 
don't know if there is a win32com mailing list; if there is one, please 
post your question there too.

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


Re: Ode to python

2005-09-07 Thread hans . eccentricity
Very good poem.
Mind if forward it around?? I'll include ur email ID if u don't mind

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


Re: encryption with python

2005-09-07 Thread Andreas Lobinger
Aloha,

[EMAIL PROTECTED] wrote:
 I was wondering if someone can recommend a good encryption algorithm
 written in python. 
 It would be great if there exists a library already written to do this,
 and if there is, can somebody please point me to it??

M2Crypto, interface to OpenSSL
http://sandbox.rulemaker.net/ngps/m2

Wishing a happy day
LOBI
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there anything better than impalib/poplib?

2005-09-07 Thread Thomas Guettler
Am Wed, 07 Sep 2005 10:14:45 + schrieb Alessandro Bottoni:

 Is there any module or interface that allow the programmer to access a
 imap4/pop3 server in a more pythonic (or Object Oriented) way than the
 usual imaplib and popolib? 
 
 I mean: is there any module that would allow me to query the server for
 specific messages (and fetch them) in a way similar to a OODB?

AFAIK there is not a better module. There is getmail a 
python script (and module) which can download messages from a pop3
server. I use it instead of fetchmail. Maybe you like this 
more than poplib.

 HTH,
   Thomas


-- 
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: [EMAIL PROTECTED]

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


Re: Python versus Perl

2005-09-07 Thread Terry Hancock
On Wednesday 07 September 2005 04:47 am, Michael Sparks wrote:
 Dieter Vanderelst wrote:
  I'm currently comparing Python versus Perl to use in a project that
  involved a lot of text processing. I'm trying to determine what the
  most efficient language would be for our purposes. I have to admit
  that, although I'm very familiar with Python, I'm complete Perl noob
  (and I hope to stay one) which is reflected in my questions.

 Your comment I'm complete Perl noob (and I hope to stay one) 
 would suggest to me that if you really feel that way, stay that way :-)

I missed that on the first reading.  IMHO, people love perl *really*
because it was the first language of its type.  However, we learned
a lot from that experience, and have since made better languages
in the same general category. The best of these of course, is
Python. ;-)

I felt that way about C, and occasionally Fortran.  But I've gotten
over it. ;-)

I took Perl classes after I learned Python, and I haven't found
anything Perl is enough better suited to do that it is worth the
trouble of messing with it.  Yes, the one and two liner programs are
nice, but now that six months have passed and I can no longer remember
Perl syntax, it's a lot easier to do it in Python, even if I do wind
up using, say, 4 lines of code.

The biggest distinction I got from looking at Perl from the perspective
of Python is that:

1) Perl makes regular expressions first-class objects, which makes them
really easy to use, and a beginner subject in a Perl class.

2) Python makes objects and classes really easy to use, so they are a
beginner subject.

However, each can do the other when pressed. So which would you rather
have be easy?

Regular expression program makes huge incomprehensible piles of
gobblygook which you forget 10 seconds after you wrote it, while
objects and classes make it easy to understand the structure of
your program.

Even regular expressions are clearer in Python (IMHO) because of the
ability to apply string operations on them.  Furthermore, the ready
availability of more direct methods of string manipulation encourages
more optimized and clearer design decisions (in Python if you just
want to find a word, you can just say so, instead of crafting a 
routine regular expression).

Performance is a complete non-issue. Both languages are reasonably
fast, and neither has a clear advantage on real world projects. Python
and Perl are rivals precisely because they are very similar in what
they can do.

So I'd second the suggestion to eschew the Perl if you can at all
get away with it.  If you're already sold on Python, there's no
reason to question your judgement.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: infinite loop

2005-09-07 Thread Carl Friedrich Bolz
Hi!

LOPEZ GARCIA DE LOMANA, ADRIAN wrote:
 Hi all, 
 
 I have a question with some code I'm writting:
 
 
 def main():
 
 if option == 1:
 
 function_a()
 
 elif option == 2:
 
 function_b()
 
 else:
 
 raise 'option has to be either 1 or 2'
 
[snip]

One further note: string exceptions are being phased out. It is 
discouraged to use them. See

http://docs.python.org/lib/module-exceptions.html
http://www.python.org/peps/pep-0290.html

for details.

Cheers,

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


Re: encryption with python

2005-09-07 Thread Michael J. Fromberger
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:

 Hi!
 
 I was wondering if someone can recommend a good encryption algorithm
 written in python. My goal is to combine two different numbers and
 encrypt them to create a new number that cann't be traced back to the
 originals.
 
 It would be great if there exists a library already written to do this,
 and if there is, can somebody please point me to it??

I recommend you investigate PyCrypto:
  http://www.amk.ca/python/code/crypto
  http://sourceforge.net/projects/pycrypto

Cheers,
-M

-- 
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/  | Dartmouth College, Hanover, NH, USA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe 0.6.1 released

2005-09-07 Thread cmkl
I removed conditional imports from visual and after that I works like a
charm. Now I've got a VPython application within a single 3 Mbyte
exe-file (Python-2.3).
That is really cool. 

Thanks

Carl

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


Re: Job Offer in Paris, France : RD Engineer (Plone)

2005-09-07 Thread Terry Hancock
On Tuesday 06 September 2005 03:34 am, Huron wrote:
  1) whether there would be legal or procedural obstacles for a
  non-European wanting to work in Paris for a while; and
 If you are a member of the EU (the netherlands ?), there no such problem on
 our side. Only _you_ would have some paperwork to do.

Europeans have been tearing Americans to shreds over our parochialism,
it's amusing to see them succomb to the same faults now that they are
convinced they are the economic center of the universe, isn't it?

I guess the foot's on the other hand now. ;-D

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: 'isa' keyword

2005-09-07 Thread Terry Hancock
On Sunday 04 September 2005 07:25 am, Colin J. Williams wrote:
 Rocco Moretti wrote:
  Terry Hancock wrote:
  
  On Thursday 01 September 2005 07:28 am, Fuzzyman wrote:
 
  What's the difference between this and ``isinstance`` ?
 
 
  I must confess that an isa operator sounds like it would
  have been slightly nicer syntax than the isinstance() built-in
  function. But not enough nicer to change, IMHO.
  
  
  Especially conidering that checking parameters with isinstance is 
  considered bad form with Python's duck typing.
 
 Could you elaborate on that please?

It would indeed be better to have a keyword for querying whether
a class or object *implements* a given *interface*.  Which is essentially
what duck typing does, albeit somewhat haphazardly.  The formal
alternative, of using interfaces is provided by external packages
such as Zope and PyProtocols, but has never been standardized and
adopted into the standard library.  Perhaps it should be.

Certainly as long as there is more than one implementation of
interfaces, support for testing them cannot be at the keyword
level and remains through functions and methods.  This is actually
pretty easy to use, though.

Giving isinstance() a keyword status as isa would encourage
bad style, though, as it would attract beginners away from much
better styles such as component/interface design.

While that wouldn't necessarily be sufficient reason to *remove*
an isa keyword if one existed, it certainly detracts from the
desire to add one.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


The right way to do i18n

2005-09-07 Thread Laszlo Zsolt Nagy

  Hello,

I wonder if there is a standard for making i18n in Python projects. I 
have several Python projects that are internationalized. I also have 
Python packages with i18n. But it is still not clean to me what is the 
recommended way to do it. Currently, I use a module called 
'localization.py' with this code:

from i18n_domain import DOMAIN
import gettext
t = gettext.translation(DOMAIN,'messages',languages=['hu'])
t.install()


But I believe this is not the best way to do it. Problem one: I cannot 
do unit testing and I cannot use pydoc/epydoc for my libraries. They all 
use the _() function but it is installed in the main program only. What 
I do now is this:

import pydoc
import sys
import __builtin__
import os
sys.argv.append('-g')
def _(s):
return str(s)
__builtin__._ = _

pydoc.cli()

But this is very very ugly.

Another problem is with libraries. I have a common library 'LibFoo' and 
several projects 'Project1', 'Project2' etc. I would like to distribute 
my projects and my library as distinct Python (distutil) packages. Of 
course, I would like to include all messages (po, pot and mo files) with 
my distributions. Is there a standard way to do it? I mean, there are 
many packages out there and most of them need i18n. Also there are many 
projects and they also need i18n. But how these two come together? There 
should be a standard way to unify gettext messages from various 
libraries. I'm thinking about a general i18n protocol, where each 
package or module has a standard way to add its own messages to the whole.

   Les

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


python and ARCView GIS desktop

2005-09-07 Thread GISDude
hi all. I am a newbie, so be kind.
I am using ARCView GIS 9.1 and python win. I am trying to develop a
module using the GZIP module in my ARCView map session. What I am
attempting to do (I think) is use the zip mod to zip up all the files
in a .mxd document into one neat little zipped file, ready to copy to
cd or email(if it's small enough(.

I got this idea while using autocad. There is a function in autocad
(E-TRANSMIT) that allows you to press the button on the toolbar and it
will zip up all files(and dependent files too) in the current drawing
and have it in one zip file ready for email.

I thought ESRI would think of this but when I've posted this to the
message boards, there is no response.

I was wondering if anyone had any ideas. Maybe I could use VBA or
something else?
Thanks in advance

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


Re: anaconda.real in RH7.1

2005-09-07 Thread Allan Adler
Allan Adler [EMAIL PROTECTED] writes:

 I'm trying to reinstall RedHat 7.1 Linux on a PC that was disabled when
 I tried to upgrade from RH7.1 [] 
 The file anaconda.real is invoked with the line
 exec /usr/bin/anaconda.real -T $@
 I don't know what effect the -T $@ has.

Tiny progress on this: in a shell script, $@ apparently lets you refer
to the output of a previous command. I don't know what output would be
relevant, since the last few lines of the shell script anaconda that
invokes anaconda.real are:

cd /usr/sbin
uncpio  sbin.cgz
rm sbin.cgz
cd /lib
uncpio  libs.cgz
rm libs.cgz
cd /
exec /usr/bin/anaconda.real -T $@

As for exec itself, the command line
exec -T
leads to a complaint that -T is an illegal option for exec, while
python -T
leads to a usage statement that doesn't list -T among the options for python.
So, I still don't understand the statement that is used to call the python
script anaconda.real.

I also tried to execute in interactive session some of the commands in the
file anaconda.real. E.g. the first command signal.signal(SIGINT,SIG_DFL)

Python 1.5.2 (#1, Mar  3 2001, 01:35:43)
[GCC 2.96 2731 (Red Hat Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 signal.signal(SIGINT,SIG_DFL)
Traceback (innermost last):
  File stdin, line 1, in ?
NameError: signal
 import signal
 signal.signal(SIGINT,SIG_DFL)
Traceback (innermost last):
  File stdin, line 1, in ?
NameError: SIGINT
 import SIGINT
Traceback (innermost last):
  File stdin, line 1, in ?
ImportError: No module named SIGINT

On the other hand, while looking at Kernighan and Pike, The Unix programming
environment (1984), I fortuitously ran across a discussion of signals and
interrupts on p.225, including the example

#include signal.h
signal(SIGINT,SIG_DFL)

which restores default action for process termination. The resemblance to the
first command in anaconda.real is so close that I think the intention in
both must be the same. What is the right way to get python to do this?

The file anaconda.real doesn't explicitly execute
import signal
but it still somehow knows what signal means (my example session above shows
that it stops complaining about not knowing what signal means after I import
signal). Presumably there is some way of invoking python that causes signal
and other stuff to be imported automatically. What is it?
-- 
Ignorantly,
Allan Adler [EMAIL PROTECTED]
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: encryption with python

2005-09-07 Thread Steve M
My goal is to combine two different numbers and
encrypt them to create a new number that cann't be traced back to the
originals.

Here's one:
def encrypt(x, y):
Return a number that combines x and y but cannot be traced back
to them.
return x + y

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


py2exe 0.6.2 released

2005-09-07 Thread Thomas Heller
This is a bugfix release for py2exe 0.6.1.

py2exe 0.6.2 released
=

py2exe is a Python distutils extension which converts python scripts
into executable windows programs, able to run without requiring a
python installation.  Console and Windows (GUI) applications, windows
NT services, exe and dll COM servers are supported.

Changes in 0.6.2:

* Several important bugfixes:

  - bundled extensions in packages did not work correctly, this
made the wxPython single-file sample fail with newer wxPython
versions.

  - occasionally dlls/pyds were loaded twice, with very strange
effects.

  - the source distribution was not complete.

  - it is now possible to build a debug version of py2exe.

Changes in 0.6.1:

* py2exe can now bundle binary extensions and dlls into the
  library-archive or the executable itself.  This allows to
  finally build real single-file executables.

  The bundled dlls and pyds are loaded at runtime by some special
  code that emulates the Windows LoadLibrary function - they are
  never unpacked to the file system.

  This part of the code is distributed under the MPL 1.1, so this
  license is now pulled in by py2exe.
  
* By default py2exe now includes the codecs module and the
  encodings package.
  
* Several other fixes.

Homepage:

http://starship.python.net/crew/theller/py2exe

Download from the usual location:

http://sourceforge.net/project/showfiles.php?group_id=15583

Enjoy,

Thomas

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


Re: py2exe 0.6.1 released

2005-09-07 Thread Thomas Heller
Giovanni Bajo [EMAIL PROTECTED] writes:

 Thomas Heller wrote:

 I tried it using the wx singlefile example, but unfortunately the
 resulting executable segfaults at startup (using Python 2.3.3 on
 Windows 2000, with latest wxWindows).

 Yes, I can reproduce that.  I'm still using wxPython 2.4.2.4 for
 Python
 2.3.5, and that combo works.  I have done a few tests, and wxPython
 2.5.1.5 also works, while 2.5.5.1 crashes.

 Ah that's fine, then. I thought it was one of those only in my computer kind
 of issue :)

 How can I debug it?

 I'll assume that's a serious question.

 Of course it was, I'm not sure why you should doubt it. I was just trying to
 being helpful to you, thinking that it could have been hard to reproduce.
 Luckily, you can look into it yourself.

I wasn't offended ;-).  Debugging the bundled executables is difficult -
because the source file debug info is lost (or at least MSVC isn't able
to access it).  So you end up steppiung through the disassembly.

 I've done all this, and it seems it is crashing when trying to import
 _gdi.pyd.  Next would be to debug through _memimported.pyd, but I
 don't have a debug build of wxPython.

 OK. Do you believe that _memimported.pyd can eventually converge to something
 stable? Emulating LoadLibrary for all versions of Windows is not an easy task
 after all. Wine might provide some insights.

Currently there's no platform specific code in this emulation.  But I
have to admit I don't use win98 any more.
I hope that _memimporter.pyd eventually becomes stable, the new 0.6.2
release contains some important fixes.

For the original problem: the code to load extensions contained in
packages was buggy.  With 0.6.2 the wxPython singlefile sample at least
works wit wxPython 2.4.2.4 + python 2.3.5, and wxPython 2.6.1.0 + Python
2.4.1.

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


Re: py2exe 0.6.1 released

2005-09-07 Thread Thomas Heller
[EMAIL PROTECTED] (Bengt Richter) writes:

 If you have a place in the program where output should never happen
 except when you would want a console window to see it in, you can
 call AllocConsole [1] safely even in multiple such places, just before
 the printing, and the first such call will create the console and hook
 up stdout and stderr ready to print. Subsequent calls to AllocConsole
 are effectively ignored, so all the output goes to the same console
 no matter which code section executed first. IMO this should be
 built into at least the windows wpython to trigger at the first
 attempt at stdout or stderr output. There could be an option to
 override that default and thus ignore stdout/stderr output, but I
 think it would be a useful default. Plus it would tell people early
 that they had usesless prints going in their wpython programs.


IMO that would be a nice addition to pythonw.exe, but I have no time to
care about this myself.  For py2exe, I'm still unsure how debugging
output from a frozen gui program should be handled.

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


Re: [Jython-users] ANN: PyDev 0.9.8.1 released

2005-09-07 Thread stri ker
I am a Mac OS X user running Tiger.  The install was extremely easy  
and Eclipse seems to have some good features at first glance.
For anyone interested after installing Eclipse you can download and  
install PyDev with the instructions on this page.  They are for  
Windows, but other OS's should be very similar.

http://www.erin.utoronto.ca/~ebutt/eclipse_python.htm


On Sep 7, 2005, at 12:04 AM, could ildg wrote:

 Thanks.
 pydev is so alive.

 On 9/7/05, Fabio Zadrozny [EMAIL PROTECTED] wrote: Hi All,

 PyDev - Python IDE (Python Development Enviroment for Eclipse) version
 0.9.8.1 has been released.

 Check the homepage (http://pydev.sourceforge.net/ ) for more details.

 Details for Release: 0.9.8.1

 Major highlights:
 ---

 * Java 1.4 support reintroduced.
 * Styles added for syntax highlighting (bold and italic),
 contributed by Gerhard Kalab.


 Others that are new and noteworthy:
 -

 * zombie process after exiting eclipse should not happen anymore
 * paths with '.' are accepted for the pythonpath (unless they  
 start
 with a '.', because it may not accept relative paths).
 * relative imports are added to code-completion
 * local imports are taken into consideration when doing code  
 completion
 * debugger has 'change support', so, changed variables in a scope
 appear red


 Cheers,

 Fabio

 --
 Fabio Zadrozny
 --
 Software Developer

 ESSS - Engineering Simulation and Scientific Software
 www.esss.com.br

 PyDev - Python Development Enviroment for Eclipse
 pydev.sf.net
 pydev.blogspot.com




 ---
 SF.Net email is Sponsored by the Better Software Conference  EXPO
 September 19-22, 2005 * San Francisco, CA * Development Lifecycle  
 Practices
 Agile  Plan-Driven Development * Managing Projects  Teams *  
 Testing  QA
 Security * Process Improvement  Measurement * http://www.sqe.com/ 
 bsce5sf
 ___
 Jython-users mailing list
 [EMAIL PROTECTED]
 https://lists.sourceforge.net/lists/listinfo/jython-users

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

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


Re: Cleaning strings with Regular Expressions

2005-09-07 Thread sheffdog
Good Idea I'll try that!

Thanks for your assistance.
/\/\

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


Question about concatenation error

2005-09-07 Thread colonel
I am new to python and I am confused as to why when I try to
concatenate 3 strings, it isn't working properly. 

Here is the code:

--
import string
import sys
import re
import urllib

linkArray = []
srcArray = []
website = sys.argv[1]

urllib.urlretrieve(website, 'getfile.txt')   

filename = getfile.txt
input = open(filename, 'r')  
reg1 = re.compile('href=.*')   
reg3 = re.compile('.*?')   
reg4 = re.compile('http')
Line = input.readline() 

while Line:  
searchstring1 = reg1.search(Line)
if searchstring1:
rawlink = searchstring1.group()  
link = reg3.search(rawlink).group()  
link2 = link.split('')  
cleanlink = link2[1:2]   
fullink = reg4.search(str(cleanlink))
if fullink:
linkArray.append(cleanlink)  
else:
cleanlink2 = str(website) + / + str(cleanlink)
linkArray.append(cleanlink2)
Line = input.readline()   

print linkArray
---

I get this:

[http://www.slugnuts.com/['index.html'],
http://www.slugnuts.com/['movies.html'],
http://www.slugnuts.com/['ramblings.html'],
http://www.slugnuts.com/['sluggies.html'],
http://www.slugnuts.com/['movies.html']]

instead of this:

[http://www.slugnuts.com/index.html];,
http://www.slugnuts.com/movies.html];,
http://www.slugnuts.com/ramblings.html];,
http://www.slugnuts.com/sluggies.html];,
http://www.slugnuts.com/movies.html];]

The concatenation isn't working the way I expected it to.  I suspect
that I am screwing up by mixing types, but I can't see where...

I would appreciate any advice or pointers.

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


Re: Question about concatenation error

2005-09-07 Thread colonel
On Wed, 07 Sep 2005 16:34:25 GMT, colonel [EMAIL PROTECTED]
wrote:

I am new to python and I am confused as to why when I try to
concatenate 3 strings, it isn't working properly. 

Here is the code:

--
import string
import sys
import re
import urllib

linkArray = []
srcArray = []
website = sys.argv[1]

urllib.urlretrieve(website, 'getfile.txt')   

filename = getfile.txt
input = open(filename, 'r')  
reg1 = re.compile('href=.*')   
reg3 = re.compile('.*?')   
reg4 = re.compile('http')
Line = input.readline() 

while Line:  
searchstring1 = reg1.search(Line)
if searchstring1:
rawlink = searchstring1.group()  
link = reg3.search(rawlink).group()  
link2 = link.split('')  
cleanlink = link2[1:2]   
fullink = reg4.search(str(cleanlink))
if fullink:
linkArray.append(cleanlink)  
else:
cleanlink2 = str(website) + / + str(cleanlink)
linkArray.append(cleanlink2)
Line = input.readline()   

print linkArray
---

I get this:

[http://www.slugnuts.com/['index.html'],
http://www.slugnuts.com/['movies.html'],
http://www.slugnuts.com/['ramblings.html'],
http://www.slugnuts.com/['sluggies.html'],
http://www.slugnuts.com/['movies.html']]

instead of this:

[http://www.slugnuts.com/index.html];,
http://www.slugnuts.com/movies.html];,
http://www.slugnuts.com/ramblings.html];,
http://www.slugnuts.com/sluggies.html];,
http://www.slugnuts.com/movies.html];]

The concatenation isn't working the way I expected it to.  I suspect
that I am screwing up by mixing types, but I can't see where...

I would appreciate any advice or pointers.

Thanks.


Okay.  It works if I change:

fullink = reg4.search(str(cleanlink))
if fullink:
linkArray.append(cleanlink)  
else:
cleanlink2 = str(website) + / + str(cleanlink)

to

fullink = reg4.search(cleanlink[0])
if fullink:
linkArray.append(cleanlink[0])  
else:
cleanlink2 = str(website) + / + cleanlink[0]


so can anyone tell me why cleanlink gets coverted to a list?  Is it
during the slicing?


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


List of integers L.I.S.

2005-09-07 Thread n00m
Given a list of N arbitrarily permutated integers from set {1..N}.
Need to find the ordering numbers of each integer in the LONGEST
increasing sequence to which this number belongs. Sample:

List:
[4, 5, 6, 1, 2, 7, 3]

Corresponding ordering numbers:
[1, 2, 3, 1, 2, 4, 3]

Details:
e.g. number 7 belongs to increasing sequence 1, 2, 7;
but this sequence is not the LONGEST sequence for 7.
The longest sequence for the 7 is 4, 5, 6, 7.
So, the 7's ordering number in this sequence is 4.

The salt of the thing is to do this with an O(n*log(n))
algorithm!
The straightforward O(n^2) algorithm is t slooow.

Any ideas?

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


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-07 Thread n00m
 Code run from IDLE but not via double-clicking on its *.py

It still does not work. Weird.

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


Re: [Py2exe-users] py2exe 0.6.2 released

2005-09-07 Thread Ray Schumacher
First, Thanks again for the update.

At 08:55 AM 9/7/2005, Thomas Heller wrote:

  This part of the code is distributed under the MPL 1.1, so this
  license is now pulled in by py2exe.

As I read it, it seems that I need to include an Exibit A
http://www.mozilla.org/MPL/MPL-1.1.html#exhibit-a
filled out so that it includes the py2exe home, as well as Python, probably.
It could be put in the Zip or Rar to be viewed on extraction.
Does this sound correct?

Ray Schumacher 

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


Re: anaconda.real in RH7.1

2005-09-07 Thread Steve Holden
Allan Adler wrote:
 Allan Adler [EMAIL PROTECTED] writes:
 
 
I'm trying to reinstall RedHat 7.1 Linux on a PC that was disabled when
I tried to upgrade from RH7.1 [] 
The file anaconda.real is invoked with the line
exec /usr/bin/anaconda.real -T $@
I don't know what effect the -T $@ has.
 
 
 Tiny progress on this: in a shell script, $@ apparently lets you refer
 to the output of a previous command. I don't know what output would be
 relevant, since the last few lines of the shell script anaconda that
 invokes anaconda.real are:
 
 cd /usr/sbin
 uncpio  sbin.cgz
 rm sbin.cgz
 cd /lib
 uncpio  libs.cgz
 rm libs.cgz
 cd /
 exec /usr/bin/anaconda.real -T $@
 
$@ doesn't refer to the output of a previous command. It refers to a 
list of quoted arguments of the script it's a part of. It's supposed, 
IIRC, to be equivalent to

 exec /usr/bin/anaconda.real -T $1 $2 $2 ...

as opposed to $*, which would be equivalent to

 exec /usr/bin/anaconda.real -T $1 $2 $3 ...

 As for exec itself, the command line
 exec -T
 leads to a complaint that -T is an illegal option for exec, while
 python -T
 leads to a usage statement that doesn't list -T among the options for python.
 So, I still don't understand the statement that is used to call the python
 script anaconda.real.
 
What's supposed to happen is that anaconda.real is supposed to be 
processed by the Python interpreter. You will probably find a shebang 
line at the start of anaconda.real that reads something like

#!/usr/bin/python1.5.2

The -T argument is, I suspect, intended for anaconda.real - you could 
check the source and verify that it looks at sys.argv.

 I also tried to execute in interactive session some of the commands in the
 file anaconda.real. E.g. the first command signal.signal(SIGINT,SIG_DFL)
 
 Python 1.5.2 (#1, Mar  3 2001, 01:35:43)
 [GCC 2.96 2731 (Red Hat Linux 7.1 2 on linux-i386
 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 
signal.signal(SIGINT,SIG_DFL)
 
 Traceback (innermost last):
   File stdin, line 1, in ?
 NameError: signal
 
import signal
signal.signal(SIGINT,SIG_DFL)
 
 Traceback (innermost last):
   File stdin, line 1, in ?
 NameError: SIGINT
 
import SIGINT
 
 Traceback (innermost last):
   File stdin, line 1, in ?
 ImportError: No module named SIGINT
 
 On the other hand, while looking at Kernighan and Pike, The Unix programming
 environment (1984), I fortuitously ran across a discussion of signals and
 interrupts on p.225, including the example
 
 #include signal.h
 signal(SIGINT,SIG_DFL)
 
 which restores default action for process termination. The resemblance to the
 first command in anaconda.real is so close that I think the intention in
 both must be the same. What is the right way to get python to do this?
 
SIGINT is defined in the signal module so you probably want

 signal.signal(signal.SIGINT, signal.SIG_DFL)

 The file anaconda.real doesn't explicitly execute
 import signal
 but it still somehow knows what signal means (my example session above shows
 that it stops complaining about not knowing what signal means after I import
 signal). Presumably there is some way of invoking python that causes signal
 and other stuff to be imported automatically. What is it?

On that one you have me stumped. It's possible it imports some other 
module that plays with the namespace in a magical way.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: Sockets: code works locally but fails over LAN

2005-09-07 Thread n00m
I was trying to test the send() vs sendall() like this:

x=send(data)
print len(data)-x  0 ? (when the code fails)

but I could not reproduce the failures anymore.
As if the lan got refreshed after the first
using of sendall() instead of send().

Btw, why we need send() if there is sendall()?

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


Re: Possible improvement to slice opperations.

2005-09-07 Thread Ron Adam
Bengt Richter wrote:

 Then the question is, do we need sugar for reversed(x.[a:b])
 or list(reversed(x.[a:b])) for the right hand side of a statement,
 and do we want to to use both kinds of intervals in slice assignment?
 (maybe and yes ;-)

Yes, I think this is the better way to do it, as this address's the 
underlying causes instead of treating the symptoms.


 The reason for yes is that it solves the which-gap problem in assigning to 
 [a:a]
 if you define [a, a) as an empty interval to the left of a and (a, a] as an 
 empty
 interval to the right of a, sort of like +0 and -0 in half-open intervals ;-)
 Replacing the empty interval does the insertion on the side you want ;-)
 
 I am choosing the convention to stay compatible with python's current 
 behaviour,
 even though I'm not sure what the math world says about ax=a vs a=xa as
 different-in-some-sense intervals. I guess the intervals as point sets are 
 the same,
 but the interval definitions are different...

Not sure either.  I think intervals is an important concept and enabling 
python to work with them would be good if it could be done in a simple 
and consistent way.  This extends a lot further than just slice 
operations because of the relationship between ...

  for x in range()  -  slice(range)


So defining an interval object that can be used as an iterator in a for 
loop might be the beginning, and then finally slice with an alternate 
syntax to an abbreviated form.  So then you would have the relationship 
of...

 for x in interval() - slice(interval)


 Other than the a:a distinction, in terms of integers and UIAM
 .[a:b]
 is just sugar for
 [a+1:b+1]
 but the sugar is nice, and the slice assignment to either side is nicer.

Wouldn't that be [a:b+1] ?

As sugar the index's are translated at compile time, it may run into the 
current edge case indexing problems.  So it will most likely need to be 
an actual interval object, with an alternative syntax to use it.

 I'll deal with the subsetting another time ...

No hurry, this isn't a hack it out because the boss wants it on his 
desk Monday situation.  ;-)

 Regards,
 Bengt Richter

Cheers,
Ron



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


Re: Question about concatenation error

2005-09-07 Thread Steve Holden
colonel wrote:
 On Wed, 07 Sep 2005 16:34:25 GMT, colonel [EMAIL PROTECTED]
 wrote:
 
 
I am new to python and I am confused as to why when I try to
concatenate 3 strings, it isn't working properly. 

Here is the code:

--
import string
import sys
import re
import urllib

linkArray = []
srcArray = []
website = sys.argv[1]

urllib.urlretrieve(website, 'getfile.txt')   

filename = getfile.txt
input = open(filename, 'r')  
reg1 = re.compile('href=.*')   
reg3 = re.compile('.*?')   
reg4 = re.compile('http')
Line = input.readline() 

while Line:  
   searchstring1 = reg1.search(Line)
   if searchstring1:
   rawlink = searchstring1.group()  
   link = reg3.search(rawlink).group()  
   link2 = link.split('')  
   cleanlink = link2[1:2]   
   fullink = reg4.search(str(cleanlink))
   if fullink:
   linkArray.append(cleanlink)  
   else:
   cleanlink2 = str(website) + / + str(cleanlink)
   linkArray.append(cleanlink2)
   Line = input.readline()   

print linkArray
---

I get this:

[http://www.slugnuts.com/['index.html'],
http://www.slugnuts.com/['movies.html'],
http://www.slugnuts.com/['ramblings.html'],
http://www.slugnuts.com/['sluggies.html'],
http://www.slugnuts.com/['movies.html']]

instead of this:

[http://www.slugnuts.com/index.html];,
http://www.slugnuts.com/movies.html];,
http://www.slugnuts.com/ramblings.html];,
http://www.slugnuts.com/sluggies.html];,
http://www.slugnuts.com/movies.html];]

The concatenation isn't working the way I expected it to.  I suspect
that I am screwing up by mixing types, but I can't see where...

I would appreciate any advice or pointers.

Thanks.
 
 
 
 Okay.  It works if I change:
 
 fullink = reg4.search(str(cleanlink))
 if fullink:
 linkArray.append(cleanlink)  
 else:
 cleanlink2 = str(website) + / + str(cleanlink)
 
 to
 
 fullink = reg4.search(cleanlink[0])
 if fullink:
 linkArray.append(cleanlink[0])  
 else:
 cleanlink2 = str(website) + / + cleanlink[0]
 
 
 so can anyone tell me why cleanlink gets coverted to a list?  Is it
 during the slicing?
 
 
 Thanks.

The statement

 cleanlink = link2[1:2]

results in a list of one element. If you want to accesss element one 
(the second in the list) then use

 cleanlink = link2[1]

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: improvements for the logging package

2005-09-07 Thread Trent Mick
[EMAIL PROTECTED] wrote]
 Perhaps so, but the logging module seems like such an unpythonic beast to
 me.  How about cleaning it up (*) before we add more to it?

Yes. I was also trying to encourage Rotem to get involved in other parts
of the logging module/package later on in my email. :)

 Stuff like colorizing seems like it belongs in its own module
 (presuming a reasonably general markup scheme can be agreed upon) so
 it can be used outside the logging package.

Yah, you are probably right. Most additions to the logging system could
easily live as their own separate pieces.

 (*) Stuff that seems very odd to me:
 
 - It's a package, but contrary to any other package I've ever seen, most
   of its functionality is implemented in __init__.py.  __init__.py is
   roughly four times larger than the next largest (bsddb, which is a
   beast because BerkDB has gotten so big over the years and the
   module/package has strived to remain backwards-compatible).

I'm not defending the implementation, but does this cause any particular
problems?


   The obvious 'hello world' example
 
 import logging
 logging.info('hello world')
 
   ought to just work (implicitly add a stream handler connected to
   stderr to the root logger).

Maybe. Unless that causes troubles for real use. Having lazy
configuration like this means that it can be a subtle thing for
top-level application code to setup the proper logging configuration.

I cringe a little bit when I see this presented as the hello world
example. My basic hello world tends to be:

import logging
log = logging.getLogger(name-of-my-module-or-script)

# use log.{debug|info|warn|error}() in module/script...
#...

if __name__ == __main__:
logging.basicConfig()
#...

and then I wish again that the default output were a bit nicer for my
most common usage -- which is logging to the command line in scripts --
rather than looking more like to web server error/access logs.

I think the usability of the logging module could be much improved with
a nicer introduction to it (i.e. docs). It's not really a hello world
type of tool. Its usefulness only really shows in larger use cases.


 - Its functionality is partitioned in sometimes odd ways.  For example,
   it has a handlers module, but what I presume would be the most
   commonly used handler (StreamHandler) is not defined there.  It's in
   (you have three guesses and the first two don't count) __init__.py
   instead of in logging.handlers.  Consequently, browsing in the obvious
   way fails to find the StreamHandler class.

 - It doesn't use PEP 8 style as far as naming is concerned, instead
   doing some sort of Java or C++ or Perl camelCase thing.  Eschewing PEP
   8 is fine for other stuff, but code in the Python core (especially new
   code like the logging module) should strive to adhere to PEP 8, since
   many people will use the core code as a pattern for their own code.

Perhaps Vijay (who did all the implementation) can comment on these.
Unfortunately backwards-compat might restrict some cleanups to the
package, but perhaps not too much. I did a poor job of keeping up with
the package after I laid out an initial design, er copied an initial
design from Java's log4j package (and I'm not even a Java guy). :(

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP-able? Expressional conditions

2005-09-07 Thread Kay Schluehr
Terry Hancock wrote:
 On Wednesday 07 September 2005 05:29 am, Kay Schluehr wrote:
  Instead of pushing statements into expressions one can try to do it the
  other way round and model expressions with the functionality of
  statements.

  Alternative syntax proposals:
 
  (a)   (COND1,EXPR1) || (COND2,EXPR2)
  (b)   (COND1,EXPR1) case (COND2,EXPR2)
  (c)   (COND1,EXPR1) owise (COND2,EXPR2)
  (d)   (COND1,EXPR1) ? (COND2,EXPR2)

 You appear to be reinventing the C ternary operator.  This is
 definitely a dead horse. There was already a PEP, and it was
 refused.

Well, I'm not inspired by C and the operator is not ternary but binary
and associative. Nevertheless the behaviour of the ternary condition
operator exists as a limit case. The expression becomes more a kind of
a horizontal squeezed switch. Therefore the case keyword proposal.

It might become more obvious if one chains the expression using more
terms:

(a') (COND1,EXPR1) || (COND2,EXPR2) || ... || (CONDk,EXPRk)
(b') (COND1,EXPR1) case (COND2,EXPR2) case ... case (CONDk,EXPRk)

 If you actually want this, you're going to have to implement it
 with a function:

 def ternary(condition, true_result, false_result):
   if condition:
   return true_result
   else:
   return false_result

No, as I explained it is not a ternary operator and it can't easily be
implemented using a Python function efficiently because Python does not
support lazy evaluation. One usually does not want to evaluate all
conditions as well as all the results ( when passing them into the
function ) but evaluate conditional expressions sequentially and stop
at the first true condition. Well I would indeed like to go even
further and introduce lazy tuples this way but I wanted to notice the
responses to an obvious use case first.

Kay

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


Re: py2exe 0.6.2 released

2005-09-07 Thread Bugs
As a big test of Thomas's excellent work with py2exe, I tried to create 
a single-file executable of the wxPython demo (demo.py).
The executable was built (5.3MB) but gets a C++ runtime error when I try 
to execute?

Here's the log:
Traceback (most recent call last):
   File demo.py, line 4, in ?
   File Main.pyo, line 1738, in main
   File wx\_core.pyo, line 7473, in __init__
   File wx\_core.pyo, line 7125, in _BootstrapApp
   File Main.pyo, line 1723, in OnInit
   File Main.pyo, line 1677, in __init__
   File wx\_core.pyo, line 2889, in ConvertToBitmap
wx._core.PyAssertionError: C++ assertion wxAssertFailure failed in 
..\..\src\msw\bitmap.cpp(822): invalid image

I'm brand new to py2exe so I'm not sure if I'm using it properly.  I 
created the executable by using the samples\singlefile\gui\setup.py and 
just updated script = demo.py.  Then I ran the script as follows:
  python setup.py py2exe --bundle 1

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


Re: epydoc CLI and many files

2005-09-07 Thread Dave Benjamin
Terry Hancock wrote:
 On Monday 05 September 2005 08:10 am, Laszlo Zsolt Nagy wrote:
 
The problem is that now I have so many modules that the shell (cmd.exe) 
cannot interpret this as a one command. 
 
 In POSIX systems, the shell expands wildcards into multiple files on
 the command line, but under DOS/Windows systems, the expansion normally
 takes place within the program (I think this is still true).  In this
 case, I would guess that the Python interpreter would do the
 expansion. That should avoid any limits on command length that
 cmd.exe is giving you (I'm trusting that Python is much more capable).

Python does not do this translation for you automatically, but it does 
provide the tools to make it easy. See the glob module:

http://docs.python.org/lib/module-glob.html

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


Python CGI and Firefox vs IE

2005-09-07 Thread Jason
Hey y'all, this falls under the murky realm of HTML, CGI and
Python...and IE.

Python 2.4, using CGI to process a form.

Basically I've got 3 buttons.  Here's the HTML code:

form action='http://127.0.0.1/cgi-bin/server_status.py' method=post
button name='display' value='all,status' type='submit'All
Servers/button
button name='display' value='wkpea1,status'
type='submit'WKPEA1/button
button name='display' value='wknha2,status'
type='submit'WKNHA2/button
/form


And the code that's messing things up:

fields = cgi.FieldStorage()

if fields.has_key('display'):
print fields['display']
which_server,which_display = fields['display'].value.split(',')
if which_server == 'all':
which_server = servers
else:
which_server = [which_server]


This program works fine under firefox.  If, say, you clicked on the 1st
button, All Servers, you'd get this returned in the field['display']
variable

MiniFieldStorage('display', 'all,status')



Under Internet Explorer, this is what I get in field['display']:

[MiniFieldStorage('display', 'All Servers'),
MiniFieldStorage('display', 'WKPEA1'), MiniFieldStorage('display',
'WKNHA2')]




I see what's happening, but I'm at a loss to figure out what to do
about it.  Any help would be appreciated.

thanks,

jason

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


Sniffer with RAW SOCKETS

2005-09-07 Thread billiejoex
Hi all. I'm trying to make a simple icmp sniffer by using SOCK_RAW.
The code below works but ONLY if I first use the sendto() function.
Does anybody knows why?
Regards

from socket import *
import select
def recv():
while 1:
if s in select.select([s],[],[],99)[0]:
reply = s.recvfrom(2000)[0]
print reply
s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)
s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
s.sendto('test', ('127.0.0.1', 0)) # without this it doesn't work.
recv()


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


distutils question

2005-09-07 Thread Joachim Dahl
I am trying to make a customized install script for an extension module 
using the distutils.ccompiler class.

I want to embed an existing makefile for the C libraries into the Python 
setup script, but I am not sure what's the right way to do it...

E.g., say I want to compile a project as:

gcc -Ddef1 -c foo.c -o foo_def1.o
gcc -Ddef2 -c foo.c -o foo_def2.o
gcc foo_def1.o foo_def2.o -o myext_module.o

How would I do that using distutils? It doesn't seem to be possible with
the normal core.setup method, and distutils.ccompiler seems to be the
best option, but I couldn't get it working...

Hopefully someone the list can enlighten me.
Thanks!
Joachim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python CGI and Firefox vs IE

2005-09-07 Thread Stephan Diehl
On Wed, 07 Sep 2005 10:50:15 -0700, Jason wrote:

 Hey y'all, this falls under the murky realm of HTML, CGI and
 Python...and IE.
 
 Python 2.4, using CGI to process a form.
 
 Basically I've got 3 buttons.  Here's the HTML code:
 
 form action='http://127.0.0.1/cgi-bin/server_status.py' method=post
 button name='display' value='all,status' type='submit'All
 Servers/button
 button name='display' value='wkpea1,status'
 type='submit'WKPEA1/button
 button name='display' value='wknha2,status'
 type='submit'WKNHA2/button
 /form
 
 
 And the code that's messing things up:
 

No, here you are wrong. IE doesn't work as expected with buttons.
See
http://www.solanosystems.com/blog/archives/2005/04/12/the-submit-button-problem/

This has nothing to do with Python.
---
Stephan
 jason

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


Re: Question about concatenation error

2005-09-07 Thread Terry Reedy

colonel [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 so can anyone tell me why cleanlink gets coverted to a list?
  Is it during the slicing?

Steve answered for you, but for next time, you could find out faster by 
either using the all-purpose debuging tool known as 'print' or, with 
Python, the handy-dandy interactive window:
 [1,2,3][1:2]
[2]

Terry J. Reedy



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


Re: Python CGI and Firefox vs IE

2005-09-07 Thread infidel
 I see what's happening, but I'm at a loss to figure out what to do
 about it.  Any help would be appreciated.

Try giving the buttons different name attributes.

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


Re: Python CGI and Firefox vs IE

2005-09-07 Thread Jason
IE...sigh

Have to come up with a workaround, go back to the old input.  I'm
about the only one who uses firefox in our facility.

Thanks for the reply and the link.

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


Re: Question about concatenation error

2005-09-07 Thread Terry Hancock
On Wednesday 07 September 2005 11:34 am, colonel wrote:
 I am new to python and I am confused as to why when I try to
 concatenate 3 strings, it isn't working properly. 
 
 Here is the code:

I'm not taking the time to really study it, but at first
glance, the code looks like it's probably much more
complicated than it needs to be.

 [http://www.slugnuts.com/['index.html'],
 http://www.slugnuts.com/['movies.html'],
 http://www.slugnuts.com/['ramblings.html'],
 http://www.slugnuts.com/['sluggies.html'],
 http://www.slugnuts.com/['movies.html']]

The tail end of that is the string representation of
a list containing one string, not of that string. I
suspect you needed to use ''.join() somewhere.  Or,
you could, in principle have indexed the list, since
you only want one member of it, e.g.:

 ['index.html'][0]
'index.html'

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: Sniffer with RAW SOCKETS

2005-09-07 Thread Grant Edwards
On 2005-09-07, billiejoex [EMAIL PROTECTED] wrote:

 Hi all. I'm trying to make a simple icmp sniffer by using
 SOCK_RAW.

Just a suggestion: you'd probably be better off using the PCAP
library.

 The code below works but ONLY if I first use the sendto()
 function. Does anybody knows why?

'Fraid not.

-- 
Grant Edwards   grante Yow!  I just bought
  at   FLATBUSH from MICKEY
   visi.comMANTLE!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP-able? Expressional conditions

2005-09-07 Thread Terry Reedy

Kay Schluehr [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 No, as I explained it is not a ternary operator and it can't easily be
 implemented using a Python function efficiently because Python does not
 support lazy evaluation.

By *carefully* using the flow-control operators 'and' and 'or', you can 
often get what you want *now*, no PEP required.

 One usually does not want to evaluate all
 conditions as well as all the results ( when passing them into the
 function ) but evaluate conditional expressions sequentially and stop
 at the first true condition.

*If* bool(result_expression_i) ==  True for all i, (except maybe last 
default expression), which is true for some actual use cases, then the 
following expression evaluates to the result corresponding to the first 
'true' condition (if there is one) or to the default:

c0 and r0 or c1 and r1 or c2 and r2... or default.

I have only seen real examples with one and-pair, like (x  0) and -x or x 
for absolute value.

Terry J. Reedy



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


Re: ~ after script filename?

2005-09-07 Thread Steve Horsley
presentt wrote:
 Hello all,
 
 I just wrote a really simple script and named it helloworld.py.  Inside
 was only:
 
 #!/usr/bin/env
 print Hello, world
 
 I used chmod to set the permissions, and ran it to see what happened (I
 just started learning Python, if you couldn't guess)
 
 Then, I typed ls in the directory to see what was there, and I noticed
 a new file, namely helloworld.py~ .  What is that file (its contents
 are identicle to helloworld.py)?  Why the ~?
 
 Thanks a lot.  I'm using Ubuntu Linux 5.04 (Hoary), and wrote the
 script with gedit.
 
 ~~Ted Present
 

As others have said, this is a feature of gedit. It can make a 
backup copy of the previous version as you save, and can also 
automatically save periodically (default seems to be 10 minutes). 
 From the menus, choose:
   Edit - Preferences
and see the section marked File Saving.

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


Re: Ode to python

2005-09-07 Thread James Stroud
On Tuesday 06 September 2005 09:29 pm, Paul Rubin wrote:
 [EMAIL PROTECTED] writes:
  Python or C? C is simply a pawn.
  Venomous problem? Pythons squeeze and constrict, until the problem is
  gone.

 Don't quit your day job.

I beg to differ, perhaps we see a spark of inspiration:

 Abolish all globals, and all mutinous variables.
 Embed precious methods in organized crucibles.

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

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


pickling objects in jython

2005-09-07 Thread Shahin Saadati
Hi,
The following sample code is to pickle and unpickle an object. It works 
fine with CPython, but the unpickling fails in Jython and I receive an 
error stating that A is unsafe to unpickle (even though I believe I 
have the code to make A safe for unpickling). What do I do wrong and 
how can I fix it?
Thanks,

==
import sys
import cPickle
import copy_reg

class A(object):
 __slots__ = (x,y)
 __safe_for_unpickling__ = True
 def __init__(self, a, b):
 self.x = a
 self.y = b
 def __str__(self):
 return str(self.__getstate__())
 def __reduce__(self):
 return (self.__class__.__name__, self.__getstate__())
 def __new__(cls, a, b):
 return object.__new__(cls)
 def __getnewargs__(self):
 return self.__getstate__()
 def __getstate__(self):
 return (self.x, self.y)
 def __setstate__(self, state):
 (self.x, self.y) = state

copy_reg.constructor(A)
a = A(5,abcd)

print Before Pickling: %s%str(a)
mfile = open(dumptest,wb)
cPickle.dump(a,mfile,-1)
mfile.close()

mfile = open(dumptest,rb)
m = cPickle.load(mfile)
print After Pickling: %s%str(m)
mfile.close()
==
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dual processor

2005-09-07 Thread Michael Sparks
Jorgen Grahn wrote:

 On Tue, 06 Sep 2005 08:57:14 +0100, Michael Sparks [EMAIL PROTECTED]
 wrote: ...
 Are you so sure? I suspect this is due to you being used to writing code
 that is designed for a single CPU system. What if you're basic model of
 system creation changed to include system composition as well as
 function calls? Then each part of the system you compose can potentially
 run on a different CPU. Take the following for example:
 ...
 It probably looks strange, but it's really just a logical extension of
 the Unix command line's pipelines to allow multiple pipelines. Similarly,
 from a unix command line perspective, the following will automatically
 take advantage of all the CPU's I have available:

(find |while read i; do md5sum $i; done|cut -b-32) 2/dev/null |sort

 And a) most unix sys admins I know find that easy (probably the above
 laughable) b) given a multiprocessor system will probably try to maximise
 pipelining c) I see no reason why sys admins should be the only people
 writing programs who use concurrency without thinking about it :-)
 
 Nitpick: not all Unix users are sysadmins ;-) Some Unix sysadmins actually
 have real users, and the clued users use the same tools. I used the 'make
 -j3' example elsewhere in the thread (I hadn't read this posting when I
 responded there).

I simply picked a group that do this often :-) The example pipeline I gave
above is I admit a particularly dire one. Things like the following are far
more silly:

# rm file; fortune | tee file | wc | cat - file
  3  16 110
Bubble Memory, n.:
A derogatory term, usually referring to a person's
intelligence.  See also vacuum tube.

And

# (rm file; (while [ ! -s file ]; do echo /dev/null; done; cat file |wc)  
fortune | tee file) 2/dev/null
Yea, though I walk through the valley of the shadow of APL, I shall
fear no evil, for I can string six primitive monadic and dyadic
operators together.
-- Steve Higgins
#   4  31 171

 It seems to me that there must be a flaw in your arguments, but I can't
 seem to find it ;-)

Sorry, but that's probably the funniest thing I've read all day :-)

Best Regards,


Michael.

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


Re: determine if os.system() is done

2005-09-07 Thread Steve Horsley
Xah Lee wrote:
 suppose i'm calling two system processes, one to unzip, and one to
 “tail” to get the last line. How can i determine when the first
 process is done?
 
 Example:
 
 subprocess.Popen([r/sw/bin/gzip,-d,access_log.4.gz]);
 
 last_line=subprocess.Popen([r/usr/bin/tail,-n 1,access_log.4],
 stdout=subprocess.PIPE).communicate()[0]
 
 of course, i can try workarounds something like os.system(gzip -d
 thiss.gz  tail thiss), but i wish to know if there's non-hack way to
 determine when a system process is done.
 
  Xah
  [EMAIL PROTECTED]
 ∑ http://xahlee.org/
 

As far as I can tell from the docs (worth reading), 
system(command) doesn't return until the process has completed. 
It would have to do some fancy footwork to return the exit code 
BEFORE the process had completed!

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

Improving Python docs (was Re: OpenSource documentation problems)

2005-09-07 Thread Aahz
In article [EMAIL PROTECTED],
Steve Holden  [EMAIL PROTECTED] wrote:
Aahz wrote:
 In article [EMAIL PROTECTED],
 Steve Holden  [EMAIL PROTECTED] wrote:
. 
Bear in mind that the PSF made its very first grants last year. The 
reason none of those grants was awarded to a documentation project was 
that the (volunteer) Grants Committee and helpers didn't see any 
documentation projects worthy of support. 
 
 Really?  And what exactly is Software Engineering with Python for
 Scientist and Engineers if not a documentation project?  It may not be
 the kind of documentation people are talking about in this thread, but it
 certainly is documentation.

Sigh. Fine. Any more nits you'd like to pick?

scratch head  Why are you calling this a nit?  It is direct proof that
the PSF is prepared to allocate financial resources to improve the Python
documentation.  We only await people to take up the challenge.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >