AroundWord - Blog Publishing System

2007-07-09 Thread Jonas
AroundWord_ is a free and open Blog Publishing System built on Python
using the most advanced technologies:

* Framework: Tesla upon Pylons
* Database Engine: SQLAlchemy + Elixir + SAContext
* Templates: Mako
* Widgets and Forms: ToscaWidgets + twForms + FormEncode
* Authorization and Authentication: AuthKit
* Internationalization (i18n) and Localization (L10n): Babel
* JavaScript Library: jQuery
* Site Search: Xapian

Currently, AroundWord is in early planning and development. You are
welcome to take participate in the development:

Join the `mailing list`_ and tell us what you think about this
project :)


.. _AroundWord: http://www.aroundword.org/
.. _mailing list: http://groups.google.com/group/aroundword-discuss

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

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


gozerbot 0.7 released

2007-07-09 Thread bthate
it time for a new gozerbot release ! we made a 0.7 release of
gozerbot.

new in gozerbot 0.7:

* we have a new developer on the team .. Wijnand 'tehmaze'
Modderman he contributed most of the new work in this release.
copyright on tehmaze's work is BSD
* new plugins: rest, lag, nickserv, snarf, tinyurl, umode, popcon,
job
* udp messaging can now be encrypted
* remote installable plugins are now signed .. this means gnupg is
required to install these plugins
* new plugin site: http://plugins.gozerbot.org
* gozerbot now has it own popularity contest webpage .. see
http://plugins.gozerbot.org/popcon
* new periodical class for easy scheduling of jobs
* new bugtracker site: http://dev.gozerbot.org

the new release can be downloaded from the following resources:

* http://gozerbot.org/
* http://code.google.com/p/gozerbot
* debian users can install the bot from sid/unstable

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

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-09 Thread John Nagle
Paul Rubin wrote:
 Diez B. Roggisch [EMAIL PROTECTED] writes:
 
Which implies that even in ADA, runtime type errors are in fact
expected - else there would be no handler for such a case.

Well, yes, runtime errors occur - in statically typed languages as
well. That's essentially the halting-problem.
 
 
 Well, no, it's quite possible for a language to reject every program
 that has any possibility of throwing a runtime type error.  The
 halting problem implies that no algorithm can tell EXACTLY which
 programs throw errors and which do not.  So the language cannot accept
 all programs that are free of runtime type errors and reject all
 programs that definitely have runtime type errors, with no uncertain
 cases.  But it's fine for a language to reject uncertain cases and
 accept only those which it can rigorously demonstrate have no type
 errors.

That's correct.  Speaking as someone who once implemented an automatic
proof of correctness system (here's the manual:
http://www.animats.com/papers/verifier/verifiermanual.pdf), the halting
problem isn't an issue.  If you write a program for which halting is
undecidable, the program is basically broken.

The way you prove loop termination in the real world is to define
some integer value (you can also use tuples like (1,2,1,3), like
paragraph numbers) that gets smaller each time you go through the
loop, but never goes negative.

Most type issues can be resolved at compile time if you can
see the whole program.

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


Re: socket: connection reset by server before client gets response

2007-07-09 Thread Hendrik van Rooyen
 ahlongxp [EMAIL PROTECTED] wrote:


 
  Try to wait a while in the server thread, after sending the
  message before closing the connection, to give the message
  time to get transmitted.
 
  time.sleep(0.5) should do it...
 
  - Hendrik
 
 OMG, it works.
 I can't believe the problem can be solved so easily.
 
 Thanks very much.

It's a pleasure.

Sometimes I think that all would be programmers should be
forced to write a Hello World to transmit out of a serial port
in assembler on hardware that carries no OS - just to teach 
them about interrupts and time.

I would require them to hand assemble the code too, to make
them appreciate what a compiler or an interpreter does.

And if you fail the test, you get taken out and fed to the 
sacred crocodiles.

- Hendrik

--
For training with a bite, enrol now in Heavy Henry's 
Wholesome Hackadamy for Precocious Programmers



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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-09 Thread John Nagle
Paul Rubin wrote:
 Diez B. Roggisch [EMAIL PROTECTED] writes:
 
Which implies that even in ADA, runtime type errors are in fact
expected - else there would be no handler for such a case.

Well, yes, runtime errors occur - in statically typed languages as
well. That's essentially the halting-problem.
 
 
 Well, no, it's quite possible for a language to reject every program
 that has any possibility of throwing a runtime type error.  The
 halting problem implies that no algorithm can tell EXACTLY which
 programs throw errors and which do not.  So the language cannot accept
 all programs that are free of runtime type errors and reject all
 programs that definitely have runtime type errors, with no uncertain
 cases.  But it's fine for a language to reject uncertain cases and
 accept only those which it can rigorously demonstrate have no type
 errors.

Also, if you're really into this, read this DEC SRL report on
Extended Static Checking for Java, a system from the 1990s.

ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/SRC-159.pdf

They were doing great work until Compaq bought DEC and killed off research.

The follow up to that is Microsoft's Spec# effort, which is program
verification for C#.  See

http://research.microsoft.com/specsharp/

They have some of the same people, and some of the same code, as the
DEC effort.

Back when I was working on this, we only had a 1 MIPS VAX, and theorem
proving was slow.  That's much less of a problem now.

John Nagle

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


Re: unify els database

2007-07-09 Thread luca72
Many thanks

I will try with Jython

Regards

Luca


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


Re: Where is the syntax for the dict() constructor ?! (OT)

2007-07-09 Thread Hendrik van Rooyen
 Steve Holden [EMAIL PROTECTED] wrote:

 Would we do that with esteeth?

Ok Steve you've got me - my dictionary goes from
estate to esteem to ester...

The US spelling of esthete may have a bearing...

- Hendrik

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


Re: ANN: gozerbot 0.7 released

2007-07-09 Thread bthate
On 9 jul, 07:25, Ben Finney [EMAIL PROTECTED]
wrote:
 bthate [EMAIL PROTECTED] writes:
  it time for a new gozerbot release ! we made a 0.7 release of
  gozerbot.

 When announcing a new release, please include a brief What is
 gozerbot? explanation section so that readers can know whether the
 announcement is of interest.

 --
  \   Pinky, are you pondering what I'm pondering? Well, I think |
   `\ so, Brain, but first you'd have to take that whole bridge |
 _o__)  apart, wouldn't you?  -- _Pinky and The Brain_ |
 Ben Finney

sorry forgot about it ;] will do so the next time.

Bart

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


Re: ANN: gozerbot 0.7 released

2007-07-09 Thread bthate
here is the about:

gozerbot is a Python IRC and Jabber bot
Requirements

* a shell
* python 2.4 or higher
* if you want to remotely install plugins: the gnupg module
* if you want mysql support: the py-MySQLdb module
* if you want jabber support: the xmpppy module

Why gozerbot?

* user management by userhost .. bot will not respond if it
doesn't know you (see /docs/USER/)
* fleet .. use more than one bot in a program (list of bots) (see /
docs/FLEET/)
* use the bot through dcc chat .. partyline
* fetch rss feeds (see /docs/RSS/)
* keep todo and shop lists
* karma
* quote
* remember items
* relaying between bots (see /docs/RELAY/)
* program your own plugins (see /docs/PROGRAMPLUGIN/)
* run the builtin webserver (see /docs/WEBSERVER/)
* query other bots webserver via irc (see /docs/COLLECTIVE/)
* other stuff


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


Re: Is there a way to program a robot with python (ex, an electric motor, control it's speed, etc)

2007-07-09 Thread Hendrik van Rooyen
 [EMAIL PROTECTED] wrote:

 i hope someone here can help me.
 
 basically, me and my friend have a summer project.
 
 in this project, we need something that would basically function as a
 blender. we know we'll need to buy a motor that spins, but what we're
 having trouble with is figuring out how to program it. we want to be
 able to control the speed of the motor. how would we accomplish this?
 
 i'm new to all of this, so i'm having a hard time wrapping my mind
 around how it'd be possible to program one of those things :\
 
 ex: what if i want the motor to turn for 10 seconds. stop for 5. then
 turn the other direction.
 
 would you program it the same way you would on a personal computer
 (via c, python, etc)?

It needs a bit more than just the motor - you need to organise some i/o
(lines that the computer can control) and some kind of interface to control
the power, and you have to put it all together - can you solder?

It may be easier to forget about the computer stuff and just use relay logic
for direction control - given that it is a DC motor that would turn the other
way, and not a universal motor (like the one in a drill, that turns the same 
way given either AC or DC).

Speed control for a small motor can be accomplished by a heavy rheostat
in series with the motor.

And that should be good enough for a summer project.

On the other hand, if you (or your parents) have pots of money then
you can buy digital to analog hardware that can be used to tell a powerful
DC coupled amplifier what to do, and have a stab at programming the
resultant combination.

But if I were you, I would do the first kind of thing, and use the rest of the 
summer to soak up the sun, instead of breathing solder fumes in a basement,
or crouching over a keyboard ruining your eyes watching a screen...


HTH  - Hendrik



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


Decorating instance methods

2007-07-09 Thread Alexander Draeger
Hello everybody,

I'm very interesting in using the decorator concept, but I can't
convert it in useful things. I have read many about decorators and
have seen a lot of examples, but I search a possibility, to decorate
methods of classes with reference to the instances. For example:

I have a class A:

class A(object):
def __init__(self, name):
self.name=name

@logging
def hello(self, name):
print 'Hello World.'



 a=A('Ernie')
 b=A('Bert')
 a.hello()
Entering a method. [Ernie]
Hello World.

 b.hello()
Entering a method. [Bert]
Hello World.


How should I implement the function logging, when I want to use the
variable self.name for the logging message?





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


Re: socket: connection reset by server before client gets response

2007-07-09 Thread ahlongxp
 It's a pleasure.

 Sometimes I think that all would be programmers should be
 forced to write a Hello World to transmit out of a serial port
 in assembler on hardware that carries no OS - just to teach
 them about interrupts and time.

 I would require them to hand assemble the code too, to make
 them appreciate what a compiler or an interpreter does.

Then there will be more crocodiles than programmers.
 And if you fail the test, you get taken out and fed to the
 sacred crocodiles.

 - Hendrik

 --
 For training with a bite, enrol now in Heavy Henry's
 Wholesome Hackadamy for Precocious Programmers

I feel a little embarrassed now.


--
ahlongxp

Software College,Northeastern University,China
[EMAIL PROTECTED]
http://www.herofit.cn

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


Re: Decorating instance methods

2007-07-09 Thread Diez B. Roggisch
Alexander Draeger schrieb:
 Hello everybody,
 
 I'm very interesting in using the decorator concept, but I can't
 convert it in useful things. I have read many about decorators and
 have seen a lot of examples, but I search a possibility, to decorate
 methods of classes with reference to the instances. For example:
 
 I have a class A:
 
 class A(object):
def __init__(self, name):
self.name=name
 
@logging
def hello(self, name):
print 'Hello World.'
 
 
 
  a=A('Ernie')
  b=A('Bert')
  a.hello()
 Entering a method. [Ernie]
 Hello World.
 
  b.hello()
 Entering a method. [Bert]
 Hello World.
 
 
 How should I implement the function logging, when I want to use the
 variable self.name for the logging message?


def logging(m):
 def _w(self, *args, **kwargs):
 print name:, self.name
 returm m(self, *args, **kwargs)
 return _w


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


Re: Decorating instance methods

2007-07-09 Thread Duncan Booth
Alexander Draeger [EMAIL PROTECTED] wrote:

 Hello everybody,
 
 I'm very interesting in using the decorator concept, but I can't
 convert it in useful things. I have read many about decorators and
 have seen a lot of examples, but I search a possibility, to decorate
 methods of classes with reference to the instances. For example:
 
 I have a class A:
 
 class A(object):
 def __init__(self, name):
 self.name=name
 
 @logging
 def hello(self, name):
 print 'Hello World.'
 
 
 
 a=A('Ernie')
 b=A('Bert')
 a.hello()
 Entering a method. [Ernie]
 Hello World.
 
 b.hello()
 Entering a method. [Bert]
 Hello World.
 
 
 How should I implement the function logging, when I want to use the
 variable self.name for the logging message?
 

(Did you intend that other parameter to the hello method? If so you had 
better pass it in when you call the method.)

Try this:

 def logging(f):
def deco(self, *args, **kw):
print Entering a method [%s] % self.name
return f(self, *args, **kw)
return deco

 class A(object):
def __init__(self, name):
self.name=name

@logging
def hello(self, name):
print 'Hello World.'


 a=A('Ernie')
 a.hello('world')
Entering a method [Ernie]
Hello World.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: having problems in changing directories doing ftp in python

2007-07-09 Thread Gabriel Genellina
En Sat, 07 Jul 2007 09:41:59 -0300, [EMAIL PROTECTED]  
[EMAIL PROTECTED] escribió:

 I'm trying to write a ftp in python to send files to my webserverr.
 Curtly I will change the directory to the folder name, down load the
 file, then do a chnag dir ..\ to go back to the root diretory, chnag
 the directory, save the file, do a ../.

 Instad of going back one directory by doing ..\, could I just go to
 the root directory?  Currtly I get a error saying file does not exist.

Use the pwd command to see exactly which is your current directory.

 When I log onto my server using my ftp program,
 The current path reads /home/admin/
 I change the directory to mainwebsite_html.
 The line that tells you the current directory now reads VAR/WWW/HTML.

 When I use python, I
 1.change the directory to mainwebsite_html
 2.change the directory to ted
 3.try to go back by changing the directory to var/www/html in which
 I get an error saying it does not exist.

If your server file system is case sensitive (likely if it's a linux/unix  
server), VAR/WWW/HTML is not the same thing as var/www/html

-- 
Gabriel Genellina

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


Re: Htmllib help

2007-07-09 Thread Gabriel Genellina
En Fri, 06 Jul 2007 03:44:20 -0300, [EMAIL PROTECTED] escribió:

 Thats right I don't need the output any where so I don't need to use the  
 writer. I can remove it wowever will the formater work since it needs  
 writer? Maybe I can use the Null writer?

Exactly. Look at the HTMLParser module too; depending on your needs, it  
may be easier to use.

  -- Original message --
 From: Gabriel Genellina [EMAIL PROTECTED]
 En Thu, 05 Jul 2007 20:23:08 -0300, [EMAIL PROTECTED] escribió:
 
  Even though I don't use any print statements, the htmllib seems to be
  throwing parts of the html page on to the standard out(my screen in  
 this
  case). Is there a way to disable the output?
 
  import htmllib
  w = formatter.DumbWriter()

 Change the above line. From  
 http://docs.python.org/lib/writer-impls.html:
 class DumbWriter([file[, maxcol = 72]])
  Simple writer class which writes output on the file object passed in as
 file or, if file is omitted, on standard output.

-- 
Gabriel Genellina

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


Florent CAYRE/SN09/SNECMA est absent.

2007-07-09 Thread florent.cayre
Je serai absent(e) du  19/02/2007 au 17/12/2007.

Bonjour,

je suis en cong=E9 sabbatique pour une dur=E9e de 10 mois.
En mon absence, adressez-vous =E0 Christophe Baudoin pour tout ce qui
concerne l'unit=E9 M=E9thodes et Outils du d=E9veloppement / A=E9rothermique=
 et
Combustion.

Florent Cayr=E9.



#=0A=
 This e-mail and any attached documents may contain confidential or proprie=
tary information. If you are not the intended recipient, please advise the s=
ender immediately and delete this e-mail and all attached documents from you=
r computer system. Any unauthorised disclosure, distribution or copying here=
of is prohibited.=0A=
=0A=
  Ce courriel et les documents qui y sont attaches peuvent contenir des inf=
ormations confidentielles. Si vous n'etes  pas le destinataire escompte, mer=
ci d'en informer l'expediteur immediatement et de detruire ce courriel  ains=
i que tous les documents attaches de votre systeme informatique. Toute divul=
gation, distribution ou copie du present courriel et des documents attaches=
 sans autorisation prealable de son emetteur est interdite.=0A=
#
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Machine A python script execute Machine B python script?

2007-07-09 Thread Nick Craig-Wood
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  On Jul 8, 6:45 pm, johnny [EMAIL PROTECTED] wrote:
  Anyone know how I can make Machine A python script execute a python
  script on Machine B ?
 
  xmlrpc will work.

Or pyro

http://pyro.sourceforge.net/

Pyro is short for PYthon Remote Objects. It is an advanced and
powerful Distributed Object Technology system written entirely in
Python, that is designed to be very easy to use. Never worry about
writing network communication code again, when using Pyro you just
write your Python objects like you would normally. With only a few
lines of extra code, Pyro takes care of the network communication
between your objects once you split them over different machines on
the network. All the gory socket programming details are taken care
of, you just call a method on a remote object as if it were a local
object!

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Empty text

2007-07-09 Thread Nick Craig-Wood
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
  On Sun, 08 Jul 2007 22:23:20 +0200, Jan Danielsson wrote:
 
 The problem is that this generates the following code:
  
tr
  thDescription/th
  td
textarea cols=64 name=desc rows=8 /
  /td
/tr
  
 Firefox is very unhappy about the textarea not having separate
  opening and a closing tags. i.e. I need this:
  
textarea cols=64 name=desc rows=8/textarea
  
 I understand the opitmization ElementTree is performing; but it seems
  there are cases when it is not the proper thing to do. Is it possible to
   force ElementTree to output the XHTML code I need it to?
 
  Then either Firefox is broken or you don't declare your XHTML properly and
  Firefox thinks it's HTML.

I suspect the former - we noticed exactly the same thing (can't
remember which tags we were having problems with), using the
declaration :-

  ?xml version=1.0 encoding=iso-8859-1?
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

I haven't tested this again recently though.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket: connection reset by server before client gets response

2007-07-09 Thread Adriano Varoli Piazza
Hendrik van Rooyen wrote:
 Sometimes I think that all would be programmers should be
 forced to write a Hello World to transmit out of a serial port
 in assembler on hardware that carries no OS - just to teach
 them about interrupts and time.

 I would require them to hand assemble the code too, to make
 them appreciate what a compiler or an interpreter does.

 And if you fail the test, you get taken out and fed to the
 sacred crocodiles.

 - Hendrik

 --
 For training with a bite, enrol now in Heavy Henry's
 Wholesome Hackadamy for Precocious Programmers

Gives a whole new meaning to chomp(), byte, nybble, and more :)
I wholeheartedly endorse this effort. I'm sick of reading about
students from WTF University (check thedailywtf.com if you don't know,
but beware. There be dragons).

--
Adriano
Once bitten, one arm less to code snafus with.

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


trouble controlling vim with subprocess on windows machine

2007-07-09 Thread [EMAIL PROTECTED]
 I am having trouble contolling vim with subprocess on a windows
machine.  It appears that vim comes up on the machine all right and it
sometimes looks like it is doing the searchs what I am asking it to do
but when I am asking it to load a file it doesn't do anything.  Is
there something I need to do to push the data through the pipe??  Here
is a couple different ways I am trying to do it.

def load_instrument(instr_name, csdname):
load an instrument using vim a path should be defined for vim
currently I am doing that with the .bat file that loads the program
f = open('csdfile.tmp','w')
my_path = /dex tracker
cmd = [gvim,csdname]
vimin = subprocess.Popen(cmd,stdin=subprocess.PIPE)#.comunicate()
[0] #, stdout = f, stderr = f, cwd = my_path )
#f.close
#x = subprocess.Popen(clear).communicate(None)[0]
innum = csr.return_unique_instr_number(csdname) - 1
cmd = /;start + str(innum) + '' +'\n'
print(cmd)
vimin.stdin.write(cmd)
cmd = /;endin +'\n'
vimin.stdin.communicate(cmd)
cmd = ':r ' + instr_name +'\n'
print(cmd)
vimin.stdin.write(cmd)
#vimin.stdin.write(instr_name + '\n')
cmd = instr_name + '\n'

f.close()
def load_instrument2(instr_name, csdname):
  second try uses comunicate
  cmd = [gvim,csdname]
  proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, )
  cmd = /;start + '\n'
  proc.communicate(cmd)[0]
  cmd = /;endin + '\n'
  proc.communicate(cmd)[0]
  cmd = ':r ' + instr_name  + '/n'
  proc.communicate(cmd)[0]
  proc.close()

I am calling these with

load_instrument2(strings.orc,'bay-at-night.csd')

and I define the path of vim in a batch file befour I call the
routines

path c:\program files\vim\vim71
python_awk_bridge.py
pause

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


Re: socket.makefile() buggy?

2007-07-09 Thread ahlongxp
On Jul 8, 9:54 pm, Steve Holden [EMAIL PROTECTED] wrote:
 That's a pretty pejorative subject line for someone who's been
 programming Python [guessing by the date of your first post] for about a
 month.

I have to admit it that I'm quite  a newbie programmer.
 Perhaps Incomprehensible behavior from socket.makefile(), or I have
 written a buggy network application? That would at least show that you
 are considering the possibility you yourself are the cause of the
 problem ;-)

Thanks. I'll be more careful about my words.
but I did show some possibility myself is the cause of the problem.
Is there any chance you missed the ? and guess at the same time.

 Python has been around for a long time, so you should ask yourself how
 likely it is that you would be the first to discover such a fundamental
 flaw?
very low but not zero.
Miracle happens.

I'd be very surprised if someone doesn't point you at an article
 on how to ask smart questions, but I will content myself with that
 oblique reference.


The big problem is that, I didn't know such a person like you before.
It's my misfortune.


 The big problem here seems to be that your server is closing the socket
 after reading 99 bytes, but the client is actually sending 120. If you
 change the 99 in the server to 120 you will see that the client
 works when it uses the makefile().read(). I can't be bothered to debug
 the exact reason why the 21 bytes of buffered data doesn't cause a
 problem with the recv() version, but I wouldn't regard the error you are
 getting as a bug in Python, rather as a bug in your application.

I don't know the underlying details of networking.
But with recv()  version I can get things done as expected while
makefile()
version can't.
I guess it's not that unreasonable to make a guess like I did.
 The underlying cause of all this appears to be your failure to
 understand that network protocols should ideally allow the endpoints to
 determine when a complete message has been transmitted, and to consume
 all transmitted data.

 You can't just ignore some or all of a client request and expect it not
 to cause problems.
Back to the problem, I make it working  by adding a sleep(0.5) just
before the
server closes the connection.
Actually this is Hendrik van Rooyen's idea.
And luckily I got a another lesson
http://groups.google.com/group/comp.lang.python/browse_thread/thread/9c5ad2608f4c80d5/4302772dfe27d8f1#4302772dfe27d8f1

If you look at some of the better-known TCP-based
 application protocols you will see they take pains to ensure that
 clients and servers can deterministically parse each others' messages.

I found something useful in RFC2616--Hypertext Transfer Protocol --
HTTP/1.1.
[PAGE49]
  - If an origin server receives a request that does not include
an
Expect request-header field with the 100-continue
expectation,
the request includes a request body, and the server responds
with a final status code before reading the entire request
body
from the transport connection, then the server SHOULD NOT
close
the transport connection until it has read the entire request,
or until the client closes the connection. Otherwise, the
client
might not reliably receive the response message. However, this
requirement is not be construed as preventing a server from
defending itself against denial-of-service attacks, or from
badly broken client implementations.

Otherwise, the client might not reliably receive the response
message.

My problem seems fixed.  But it's not relialbe though it's working
pretty
good under windows 2k, windowsxp, and linux.
I may reconsider my design and willprobably try dividing request with
body into two steps like HTTP does.
 In summary, a better protocol design will cause you rather less grief
 and a little more humility will result in less acidity from crabby old
 geeks like me.

I do appreciate your response.
I mean it.
 regards
  Steve
 --
 Steve Holden+1 571 484 6266   +1 800 494 3119
 Holden Web LLC/Ltd  http://www.holdenweb.com
 Skype: holdenweb  http://del.icio.us/steve.holden
 --- Asciimercial --
 Get on the web: Blog, lens and tag the Internet
 Many services currently offer free registration
 --- Thank You for Reading -


And last but not least,  I' here to be helped and help as long as I
can.
But as you noticed I'm not very good at expressing myself in English.
I didn't mean to offense anyone but I might seem to be rude or
offensive.
I hope you can understand.


--
ahlongxp

Software College,Northeastern University,China
[EMAIL PROTECTED]
http://www.herofit.cn

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


Re: Is there a way to program a robot with python (ex, an electric motor, control it's speed, etc)

2007-07-09 Thread Gabriel Genellina
En Sun, 08 Jul 2007 21:06:48 -0300, [EMAIL PROTECTED] escribió:

 in this project, we need something that would basically function as a
 blender. we know we'll need to buy a motor that spins, but what we're
 having trouble with is figuring out how to program it. we want to be
 able to control the speed of the motor. how would we accomplish this?

This is mostly an electronics question. How much power? For small power  
and fine control I'd look for stepwise motor on any robotics book; for a  
high power blender I think you don't care so much about fine control. In  
any case, it's the available motor which dictates how you can control it.

 i'm new to all of this, so i'm having a hard time wrapping my mind
 around how it'd be possible to program one of those things :\

 ex: what if i want the motor to turn for 10 seconds. stop for 5. then
 turn the other direction.

You may write the GUI using python, and the high level controlling API  
too. But you may need to use a PIC or some kind of controller, listening  
for commands from the PC and acting over the motor accordingly.

Picasso: a Python-controlled robot for doing paintings
http://youtube.com/watch?v=PsbKq5Kysj0

-- 
Gabriel Genellina

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


MP3 AVI DIVX MPEG SOFT = www.GEGEREKA.com

2007-07-09 Thread GEGEREKA!
Millions files for everyone. Music, movies, soft and other media.
Check it now!! http://www.gegereka.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to program a robot with python (ex, an electric motor, control it's speed, etc)

2007-07-09 Thread Wesley Brooks
For a robotics project I would highly recommend the use of Phidgets,
they can supply sensors and interface kits with APIs. Not sure if
Python is fully supported yet but there certinally seems to be a
considerable effort ongoing creating an API for python. I've only used
them to date for servo control and accelorometer sencor data
collection through c++ / wxWidgets.

http://www.phidgets.com/

They offer direct motor controllers but I'll be looking to control a
7.2V motor with a 100A draw, so I'll be using the servo controller to
drive a standard Radio Control Car motor controller.

Cheers,

Wes.

On 09/07/07, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Sun, 08 Jul 2007 21:06:48 -0300, [EMAIL PROTECTED] escribió:

  in this project, we need something that would basically function as a
  blender. we know we'll need to buy a motor that spins, but what we're
  having trouble with is figuring out how to program it. we want to be
  able to control the speed of the motor. how would we accomplish this?

 This is mostly an electronics question. How much power? For small power
 and fine control I'd look for stepwise motor on any robotics book; for a
 high power blender I think you don't care so much about fine control. In
 any case, it's the available motor which dictates how you can control it.

  i'm new to all of this, so i'm having a hard time wrapping my mind
  around how it'd be possible to program one of those things :\
 
  ex: what if i want the motor to turn for 10 seconds. stop for 5. then
  turn the other direction.

 You may write the GUI using python, and the high level controlling API
 too. But you may need to use a PIC or some kind of controller, listening
 for commands from the PC and acting over the motor accordingly.

 Picasso: a Python-controlled robot for doing paintings
 http://youtube.com/watch?v=PsbKq5Kysj0

 --
 Gabriel Genellina

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

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


Re: socket: connection reset by server before client gets response

2007-07-09 Thread ahlongxp
On Jul 9, 4:30 pm, Adriano Varoli Piazza [EMAIL PROTECTED] wrote:


 Gives a whole new meaning to chomp(), byte, nybble, and more :)
 I wholeheartedly endorse this effort. I'm sick of reading about
 students from WTF University (check thedailywtf.com if you don't know,
 but beware. There be dragons).

 --
 Adriano
 Once bitten, one arm less to code snafus with.

I feel officially offended.

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


Re: Is there a way to program a robot with python (ex, an electric motor, control it's speed, etc)

2007-07-09 Thread Christian Tismer

Hi there,


i hope someone here can help me.

basically, me and my friend have a summer project.

in this project, we need something that would basically function as a
blender. we know we'll need to buy a motor that spins, but what we're
having trouble with is figuring out how to program it. we want to be
able to control the speed of the motor. how would we accomplish this?

i'm new to all of this, so i'm having a hard time wrapping my mind
around how it'd be possible to program one of those things :\

ex: what if i want the motor to turn for 10 seconds. stop for 5. then
turn the other direction.

would you program it the same way you would on a personal computer
(via c, python, etc)?


I did something comparable to that some time ago.
This was a car simulation, for testing an electronic trip
recorder.
This simulation had a model for the whole car, its devices,
driver who inserts his card, starter who makes the voltage
break in, the gear shift, motion sensor and lots of other
stuff.

This system was written using Stackless Python, which
allows you to use a quite intuitive and efficient programming
model for this.

I would like to come back to this after EuroPython and the
sprints are over.

cheers - chris

--
Christian Tismer :^)   mailto:[EMAIL PROTECTED]
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key - http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/





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

Re: Learning Basics

2007-07-09 Thread BartlebyScrivener
On Jul 8, 12:10 pm, Brad [EMAIL PROTECTED] wrote:

 So I'd appreciate some good feedback or ideas.

I addition to Dan's suggestions, you could add a Tk text entry box to
make it easier to enter text.

I can send you some code if you'd like, as Steve Holden just
generously helped me make a text entry box for my quote database.  Or
you can make your own starting here:

 Alan Gauld's GUI Programming with Tkinter
 http://www.freenetpages.co.uk/hp/alan.gauld/tutgui.htm

These also came in very handy for cutting and pasting.

Jeff Eppler's clp post - 3 August 2005
cut and paste text between Tkinter widgets
http://tinyurl.com/2d97gj

rd

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


Re: trouble controlling vim with subprocess on windows machine

2007-07-09 Thread Nick Craig-Wood
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
   I am having trouble contolling vim with subprocess on a windows
  machine.  It appears that vim comes up on the machine all right and it
  sometimes looks like it is doing the searchs what I am asking it to do
  but when I am asking it to load a file it doesn't do anything.  Is
  there something I need to do to push the data through the pipe??  Here
  is a couple different ways I am trying to do it.

For controlling an interactive program subprocess isn't the right
tool.  Subprocess only really does one way communication - it isn't
good at conversations.  I'd suggest pexpect but it doesn't work on
windows.

You appear to be doing stuff with csound.  There are several python
modules out there which interface with csound - did you investigate
those?

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


?Hi Hi Hi.....ARE YOU Searching for Happiness

2007-07-09 Thread abdo911

Allow me to share with you here some information about  happiness.
 Happiness is a common goal that everyone strives to attain.
Philosophers, intellectuals, doctors and artists alike have all
strived in search of the causes of happiness and ways to escape
anxiety.

The reality is, however, that the proposed solutions achieve only
partial or superficial happiness. They are more or less like drugs
which only provide temporary relief; when their effect wares off,
anxieties return two fold.

The following words invite you to ultimate happiness and will lead you
to true success. But before you begin reading, I hope that you to take
a moment to try to open your heart and mind - as the intelligent one
is he who searches for the truth no matter where it lies.

An undeniable reality is that permanent happiness cannot be achieved
except by believing in God - The Creator - and following His guidance.
Since it is He who created mankind, He is the one who knows what
pleases and benefits them, just as he knows what saddens and harms
them. A number of psychologists have affirmed that only a religious
person lives with true content and serenity. So if believing in God
leads to ultimate happiness, then how can this be achieved?

There are numerous religions and a variety of creeds. However, their
critical differences in core issues make it impossible for all of them
to be correct. So which is the correct religion? What is the correct
creed that God requires us to believe in and in the end pleases Him?
And which one of these creeds guarantees us happiness in this life and
in the hereafter?

Before answering these questions, a criterion must first be
established to be used as a basis for correctly determining the true
religion. I firmly believe that all sensible people will agree that a
religion is not deemed correct simply due to the fact that one was
raised in that religion, had parents that adhered to it, or lived in a
society that practiced it. Rather a religion's accuracy and
authenticity are based upon substantial evidence and firm intellectual
proofs. Intellect, the distinguishing factor between mankind and
animals, must be applied when studying the issue of religion, which is
undeniably the most important and gravest of all matters.

A short journey into the world of religions and sifting through
various creeds could prove to be a good method in arriving at the
desired conclusion. In order to save you the time and effort, I say
with full conviction and confidence that no matter how much you
investigate this issue, you will only arrive at one reality: that the
true and correct religion is Islam and that true happiness and content
lies within it.

Before you hastily rebut this statement and stop reading, please
realize that completing the rest would not harm you at all, and it may
in fact benefit you. Also, remember that you have an intellect by
which you can distinguish things and determine truth from falsehood.

Why Islam?

This is an important question, indicating that the questioner is
mature and enlightened. In response I say:

Islam is a religion that includes a number of merits and
characteristics that are absent from other religions. These
characteristics, alone, serve as convincing evidence that Islam is the
true religion of God. You can determine the authenticity of this
statement by contemplating them.

Islam's many merits and characteristics make it impossible to
elaborate on all of them. However, some of the most important can be
summarized as follows:

1. Amongst the greatest merits of Islam is that it fulfills the
spiritual aspects of the human being and enables those who embrace it
to have an ongoing connection with God. This makes it possible for
them to be at ease spiritually. It shields them from chaos, being lost
or feeling (spiritually) empty, and protects from mental instability.

2. Another of Islam's merits is that it coincides totally with common
sense. All of the Islamic legislation and its rulings are acceptable
intellectually and are never contradictory. One man who embraced Islam
was asked why he did so and replied, Islam never ordered me to do
anything that I later wished wasn't obligated, and it never forbade me
from anything that I later wished wasn't forbidden.
Much of what is readily accepted in other religions causes great
confusion. This confusion makes it difficult to believe many of the
fundamental tenets/doctrines that these religions are based upon. On
the other hand, we find that Islam respects the intellect, prohibits
ignorance, and condemns blind following.

3. Islam is an all-inclusive way of life attending to both spiritual
and physical needs. Practicing Islam does not mean that one has to be
secluded or that he is prohibited from the finer things in life.
Rather, according to Islam, a person can be religious and still enjoy
a normal life - attaining prestigious ranks/positions and achieving
the highest academic degrees.

4. Among the merits of Islam is that it is a 

Re: Portable general timestamp format, not 2038-limited

2007-07-09 Thread Gabriel Genellina
En Thu, 05 Jul 2007 17:57:32 -0300, Wojtek [EMAIL PROTECTED] escribió:

 Note: Since I am using the year  as a magic number, some of you
 may think that I am repeating the Y2K problem. Hey, if my application
 is still being used in the year 9998 I am not being paid nearly
 enough...

I would not say the code itself, but some design decisions may survive for  
a long time. Like the railroad inter-rail distance, which even for the  
newest trains, remains the same as used by Stephenson in England two  
centuries ago - and he choose the same width as used by common horse carts  
at the time. (Some people goes beyond that and say it was the same width  
as used in the Roman empire but this may be just a practical coincidence,  
no causality being involved).

-- 
Gabriel Genellina

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


Re: Tests for Python Database API

2007-07-09 Thread Gerhard Häring
MD wrote:
 Are there any tests that will help me ensure that my Python database
 driver conforms to the Database API v2.0 specification?

There's this:

http://www.initd.org/tracker/psycopg/browser/psycopg2/trunk/tests/dbapi20.py

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


Re: A clean way to program an interface

2007-07-09 Thread Diez B. Roggisch
rh0dium wrote:

 Hi all,
 
 I got this new radio scanner (toy!!) this weekend and I can access it
 via a serial cable. I want to write a interface around it but I am
 looking for some suggestions.  I thought at first I would simply class
 the Scanner and write the various methods as attibutes similar to
 below..  But then I thought about it and I don't like it for a couple
 of obvious reasons - there isn't any data checking, and it's terribly
 repetitive.
 
 So I started searching on google - and I think it might be better to
 use a (sub)class for each function ( class STS, PRG, etc.). where the
 attributes are accessible as both dict items and lists - which
 ultimately go and set the scanner.
 
 I guess my question is this.
 
 I have a function SIN which when one argument is given does an
 effective get from the scanner - this returns some 10+ values.  When
 some 10+ parameters are given it does an effective set to the
 scanner.  Given that I can't remember all 10+ parameters I attempted
 below to represent them as a dict where the key tells me what the heck
 the parameter is supposed to represent.  So a simple translation
 occurs on both the set and get which splits the list into a named dict
 and vice versa.   Question 1 - I think I should be checking the data
 before a set - is this a smart thing or should I just do a try/
 except?  Question 2 - Since I only want to do this once (ok twice)
 should I represent each function as a class or should I keep the code
 I have below?

THROW IT AWAY

Seriously. That's one of the most convoluted, incomprehensible pieces of
python I've seen. Ever.

All the sys._getframe()-stuff has to go. Really. There are about a dozen
pieces of code worldwide that are allowed to have that in them. Maybe two
dozen.

And while I'm having difficulties grasping what you actually mean by  I
represent each function as a class or should I keep the code
 I have below?, I've done my fair share of serial programming. And I would
say that having one class that exposes different methods for commands is
the way to go.

But first - throw that code away. Fast. Faster.

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


Re: socket: connection reset by server before client gets response

2007-07-09 Thread Adriano Varoli Piazza
ahlongxp wrote:
 I feel officially offended.

I didn't intend to offend you, I was joking. I apologise in any case.
There's a few things to be said, though:

As per your message in another thread, it isn't that you don't express
yourself clearly in English, but that you were too quick to claim a
standard function was buggy without first thinking if your own code
could be buggy instead. That presumption isn't related to the language.

Second, if you do say that you aren't comfortable in English, try to
assume that people aren't trying to insult you by default. I was
speaking generallyin my message.

Third, this is usenet. Although probably not in this newsgroup, if you
continue to make the assumptions I and others pointed out, you will
receive this kind of answer. Perhaps with much more insult than right
now. So it is a great idea to grow a thick skin.

--
Saludos
Adriano

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


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Bjoern Schliessmann
Paul Rubin wrote:
 lex [EMAIL PROTECTED] writes:

 list = [1, True, True, False, False, True]
 status = True
 for each in list:
 status = status and each
 
 but what is your best way to test for for False in a list?
 
 status = all(list)

Am I mistaken, or is this no identity test for False at all?

Regards,


Björn

-- 
BOFH excuse #317:

Internet exceeded Luser level, please wait until a luser logs off
before attempting to log back on.

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


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Diez B. Roggisch
Bjoern Schliessmann wrote:

 Paul Rubin wrote:
 lex [EMAIL PROTECTED] writes:
 
 list = [1, True, True, False, False, True]
 status = True
 for each in list:
 status = status and each
 
 but what is your best way to test for for False in a list?
 
 status = all(list)
 
 Am I mistaken, or is this no identity test for False at all?

You are mistaken. all take an iterable and returns if each value of it is
true.

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


Re: trouble controlling vim with subprocess on windows machine

2007-07-09 Thread [EMAIL PROTECTED]
On Jul 9, 5:30 am, Nick Craig-Wood [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I am having trouble contolling vim with subprocess on a windows
   machine.  It appears that vim comes up on the machine all right and it
   sometimes looks like it is doing the searchs what I am asking it to do
   but when I am asking it to load a file it doesn't do anything.  Is
   there something I need to do to push the data through the pipe??  Here
   is a couple different ways I am trying to do it.

 For controlling an interactive program subprocess isn't the right
 tool.  Subprocess only really does one way communication - it isn't
 good at conversations.  I'd suggest pexpect but it doesn't work on
 windows.

 You appear to be doing stuff with csound.  There are several python
 modules out there which interface with csound - did you investigate
 those?

 --
 Nick Craig-Wood [EMAIL PROTECTED] --http://www.craig-wood.com/nick

The book (as kramer would say)

https://sourceforge.net/projects/dex-tracker

I would think that the purpose for stdin is input and stdout is
output..  otherwise why have stdin??  The pyexpect does look like what
I am after  but it isn't windows..  And did I mention I am willing to
cheat I have a large number of unix tools that are converted over (but
not cigwin) and will even be willing to generate a script file if I
can get it to vim when it starts up...  whatever it takes regardless
of how ugly looking it is.

I did notice expect

http://expect.nist.gov/#windows
http://bmrc.berkeley.edu/people/chaffee/tcltk.html

I am not sure what to do to call the tcl stuff from python though.

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


wx DatePicker (set blank values)

2007-07-09 Thread Marcpp
I need to set a DatePicker to blank value and GetValue() needs to be
0.
Thanks by advance.

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


Re: The file executing

2007-07-09 Thread Gabriel Genellina
En Fri, 06 Jul 2007 17:15:22 -0300, Benjamin [EMAIL PROTECTED]  
escribió:

How does one get the path to the file currently executing (not the
cwd). Thank you
 So:
 if __name__ == main:
 currentDir = os.path.dirname(sys.argv[0])
 else:
 currentDir = os.path.dirname(__file__)

I think you meant to test for __main__, but anyway, this should be  
enough:
currentDir = os.path.dirname(__file__)
or perhaps os.path.dirname(os.path.abspath(__file__)). Try to determine  
that early in your program because __file__ may contain a relative path  
(and will give a wrong result after changing the current directory).

-- 
Gabriel Genellina

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


Re: socket: connection reset by server before client gets response

2007-07-09 Thread ahlongxp
On Jul 9, 7:03 pm, Adriano Varoli Piazza [EMAIL PROTECTED] wrote:
 ahlongxp wrote:
  I feel officially offended.

 I didn't intend to offend you, I was joking. I apologise in any case.
 There's a few things to be said, though:

 As per your message in another thread, it isn't that you don't express
 yourself clearly in English, but that you were too quick to claim a
 standard function was buggy without first thinking if your own code
 could be buggy instead. That presumption isn't related to the language.

 Second, if you do say that you aren't comfortable in English, try to
 assume that people aren't trying to insult you by default. I was
 speaking generallyin my message.

 Third, this is usenet. Although probably not in this newsgroup, if you
 continue to make the assumptions I and others pointed out, you will
 receive this kind of answer. Perhaps with much more insult than right
 now. So it is a great idea to grow a thick skin.

 --
 Saludos
 Adriano
You don't have to apologise.  I was joking too.

But I know I have to change my way of thinking and questioning.
I'll consider more carefully before speaking.
I hope I can talk like you very soon.

Thanks.

--
ahlongxp

Software College,Northeastern University,China
[EMAIL PROTECTED]
http://www.herofit.cn

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


Re: The file executing

2007-07-09 Thread Benjamin
On Jul 9, 6:42 am, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Fri, 06 Jul 2007 17:15:22 -0300, Benjamin [EMAIL PROTECTED]  
 escribió:

 How does one get the path to the file currently executing (not the
 cwd). Thank you
  So:
  if __name__ == main:
  currentDir = os.path.dirname(sys.argv[0])
  else:
  currentDir = os.path.dirname(__file__)

 I think you meant to test for __main__, but anyway, this should be  
Yes
 enough:
 currentDir = os.path.dirname(__file__)
 or perhaps os.path.dirname(os.path.abspath(__file__)). Try to determine  
 that early in your program because __file__ may contain a relative path  
 (and will give a wrong result after changing the current directory).
I do it right at the top of the first module. Thanks for the help.

 --
 Gabriel Genellina


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

Looking for a Scholarship for your studies?)

2007-07-09 Thread Allin Sex...
Future Center for Students!
its for all students looking for scholarships, Student visas for UK,
USA, Australia, Get the

List of the worlds best universties  so much more.
Commited to give u golden opportunities.. Just visit us at:
http://www.mixmasti.com/futurecentre/scholarships.asp

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


Per thread data

2007-07-09 Thread Will McGugan
Hi,

Is there a canonical way of storing per-thread data in Python?

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


TypeError: can't multiply sequence to non-int

2007-07-09 Thread Snezhana

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


Re: Per thread data

2007-07-09 Thread Jean-Paul Calderone
On Mon, 09 Jul 2007 13:57:02 +0100, Will McGugan [EMAIL PROTECTED] wrote:
Hi,

Is there a canonical way of storing per-thread data in Python?


See threading.local:

  http://python.org/doc/lib/module-threading.html

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


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Hrvoje Niksic
Diez B. Roggisch [EMAIL PROTECTED] writes:

 but what is your best way to test for for False in a list?
[...]
 status = all(list)
 Am I mistaken, or is this no identity test for False at all?

 You are mistaken.
 all take an iterable and returns if each value of it is true.

Testing for truth is not the same as an identity test for False.  OP's
message doesn't make it clear which one he's looking for.  This
illustrates the difference:

 False in [3, 2, 1, 0, -1]
True# no False here
 all([3, 2, 1, 0, -1])
False   # false value present, not necessarily False
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Per thread data

2007-07-09 Thread Gerhard Häring
Will McGugan wrote:
 Hi,
 
 Is there a canonical way of storing per-thread data in Python?

Good question.

There's threading.local() which creates a thread-local object for you.

Maybe this Cookbook entry is helpful:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302088

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


Re: Python's only one way to do it philosophy isn't good?

2007-07-09 Thread Chris Mellon
On 7/6/07, Douglas Alan [EMAIL PROTECTED] wrote:
 Chris Mellon [EMAIL PROTECTED] writes:

  Sure, but thats part of the general refcounting vs GC argument -
  refcounting gives (a certain level of) timeliness in resource
  collection, GC often only runs under memory pressure. If you're
  saying that we should keep refcounting because it provides better
  handling of non-memory limited resources like file handles, I
  probably wouldn't argue. But saying we should keep refcounting
  because people like to and should write code that relies on implicit
  scope level object destruction I very strongly argue against.

 And why would you do that?  People rely very heavily in C++ on when
 destructors will be called, and they are in fact encouraged to do so.
 They are, in fact, encouraged to do so *so* much that constructs like
 finally and with have been rejected by the C++ BDFL.  Instead, you
 are told to use smart pointers, or what have you, to clean up your
 allocated resources.


For the record, C++ doesn't have a BDFL. And yes, I know that it's
used all the time in C++ and is heavily encouraged. However, C++ has
totally different object semantics than Python, and there's no reason
to think that we should use it because a different language with
different rules does it. For one thing, Python doesn't have the
concept of stack objects that C++ does.

 I so no reason not to make Python at least as expressive a programming
 language as C++.


I have an overwhelming urge to say something vulgar here. I'm going to
restrain myself and point out that this isn't a discussion about
expressiveness.

   Relying on the specific semantics of refcounting to give
   certain lifetimes is a logic error.
  
   For example:
  
   f = some_file() #maybe it's the file store for a database implementation
   f.write('a bunch of stuff')
   del f
   #insert code that assumes f is closed.

  That's not a logic error if you are coding in CPython, though I agree
  that in this particular case the explicit use of with would be
  preferable due to its clarity.

  I stand by my statement. I feel that writing code in this manner is
  like writing C code that assumes uninitialized pointers are 0 -
  regardless of whether it works, it's erroneous and bad practice at
  best, and actively harmful at worst.

 That's a poor analogy.  C doesn't guarantee that pointers will be
 initialized to 0, and in fact, they typically are not.  CPython, on
 other other hand, guarantees that the refcounter behaves a certain
 way.


It's a perfect analogy, because the value of an uninitialized pointer
in C is *implementation dependent*. The standard gives you no guidance
one way or the other, and an implementation is free to assign any
value it wants. Including 0, and it's not uncommon for implementations
to do so, at least in certain configurations.

The Python language reference explicitly does *not* guarantee the
behavior of the refcounter. By relying on it, you are relying on an
implementation specific, non-specified behavior. Exactly like you'd be
doing if you rely on the value of uninitialized variables in C.

 There are languages other than C that guarantee that values are
 initialized in certain ways.  Are you going to also assert that in
 those languages you should not rely on the initialization rules?


Of course not. Because they *do* guarantee and specify that. C
doesn't, and neither does Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Broken MUA interactions (was: Restarting a Python Application)

2007-07-09 Thread Chris Mellon
On 7/8/07, Ben Finney [EMAIL PROTECTED] wrote:
 Peter Decker [EMAIL PROTECTED] writes:

  Imagine if you wrote applications where the default behavior did not
  do what was needed 99% of the time: how long do you think you'd be
  in business?

 You seem to be complaining about the functionality of your mail user
 agent (MUA) software. The mailing list processor is doing its job
 fine.


It's working as instructed, but that doesn't mean that it's doing the
best thing. It's common practice for mailing lists to set the reply-to
to the list itself, because that's the common case, and because it's
encouraged to keep discussion on the list.

If whoever manages the python lists doesn't want to do it, either
because they have some practical reason or because they've got a bug
up their ass about mail readers without list support, thats fine. But
it's hardly incorrect to configure it with the reply-to set to the
list, either.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: accessing an object instance by only having one of its attribute values

2007-07-09 Thread Paul McGuire
On Jul 8, 8:29 pm, mshiltonj [EMAIL PROTECTED] wrote:

 Not sure why I slipped into the habit of testing for None, though. :-(


There is nothing wrong with testing for None.  But the right ways to
test for None are:
  if x is None:
and
  if x is not None:

Since None is a singleton, it is a waste to test using == or !=.  The
identity tests 'is' and 'is not' are sufficient.

In fact, testing for None is a very common way to implement a default
argument for an instance method (usually __init__ of a class) in which
the default is a list (usually an empty list, but not always).

The WRONG way:

class BorkBorkBork(object):
def __init__(self,words=[]):
self.vocabulary = words

Since the argument words=[] gets evaluated at class definition time,
all instances of BorkBorkBork will end up using the same list, which
is almost never the desired behavior, and a common surprise for new
Pythoners.

The ALMOST RIGHT way:

class BorkBorkBork(object):
def __init__(self,words=None):
if words:
self.vocabulary = words
else:
self.vocabulary = []

This is ALMOST RIGHT, now the default value of words is None, and the
if test fails.  Unfortunately, if this were called using:

chef = BorkBorkBork([])

then the if test fails, not because the argument was omitted from the
constructor, but BECAUSE THE PASSED VALUE EVALUATES TO FALSE!  So
what? you say, since in the else branch we just set the default value
to an empty list anyway.  But what about this?

Why the ALMOST RIGHT way isn't ALWAYS RIGHT:

class BorkBorkBork(object):
def __init__(self,words=None):
if words:
self.vocabulary = words
else:
self.vocabulary = ['bork','hernie','fernie','bernie']

Our default starting vocabulary isn't empty now, but there is no way
to initialize a BorkBorkBork'er to an empty list.

The RIGHT way:

class BorkBorkBork(object):
def __init__(self,words=None):
if words is not None:
self.vocabulary = words
else:
self.vocabulary = ['bork','hernie','fernie','bernie']


Now the loophole is closed.  If we want to initialize to an empty
list, we can do so; or if we omit the argument, then the newly-
constructed BorkBorkBork instance will have a minimally functional
vocabulary.

So testing for None is not inherently bad, and in many cases a healthy
idiom.

-- Paul

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


Re: A clean way to program an interface

2007-07-09 Thread rh0dium
On Jul 9, 3:53 am, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 THROW IT AWAY

 Seriously. That's one of the most convoluted, incomprehensible pieces of
 python I've seen. Ever.

 All the sys._getframe()-stuff has to go. Really. There are about a dozen
 pieces of code worldwide that are allowed to have that in them. Maybe two
 dozen.

 And while I'm having difficulties grasping what you actually mean by  I
 represent each function as a class or should I keep the code
  I have below?, I've done my fair share of serial programming. And I would
 say that having one class that exposes different methods for commands is
 the way to go.

 But first - throw that code away. Fast. Faster.

 Diez

Hi Diez,

Totally understand your confusion with sys._getframe().f_code.co_name
- that was borne out of the fact that I was creating a method for each
serial function and it was repeating.. over and over.. So I got tired
of changing the three items that differentiated each method so I
simplified it a bit. Perhaps too much.  So can I ask you to show or
point me to a good interface example?  I think we both can agree that
fundamentally this is pretty simple but I want to do it right and an
solid class example of interface programming would be nice.

Thanks

rh0dium



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


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Paul McGuire
On Jul 9, 7:39 am, Hrvoje Niksic [EMAIL PROTECTED] wrote:
 Diez B. Roggisch [EMAIL PROTECTED] writes:



  but what is your best way to test for for False in a list?
 [...]
  status = all(list)
  Am I mistaken, or is this no identity test for False at all?

  You are mistaken.
  all take an iterable and returns if each value of it is true.

 Testing for truth is not the same as an identity test for False.  OP's
 message doesn't make it clear which one he's looking for.  This
 illustrates the difference:

  False in [3, 2, 1, 0, -1]

 True# no False here all([3, 2, 1, 0, -1])

 False   # false value present, not necessarily False

I think if you want identity testing, you'll need to code your own;
here's a map+lambda way:

 any(map(lambda _ : _ is False,[3,2,1,0,-1]))
False
 any(map(lambda _ : _ is False,[3,2,1,0,-1,False]))
True


-- Paul

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


Re: Per thread data

2007-07-09 Thread Hrvoje Niksic
Will McGugan [EMAIL PROTECTED] writes:

 Is there a canonical way of storing per-thread data in Python?

mydata = threading.local()
mydata.x = 1
...

http://docs.python.org/lib/module-threading.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Carsten Haese
On Mon, 2007-07-09 at 07:02 -0700, Paul McGuire wrote:
  any(map(lambda _ : _ is False,[3,2,1,0,-1]))
 False
  any(map(lambda _ : _ is False,[3,2,1,0,-1,False]))
 True
 

Why the map/lambda? Is it faster than the more readable generator
expression?

 any(x is False for x in [3,2,1,0,-1])
False
 any(x is False for x in [3,2,1,0,-1,False])
True

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


patching pylint.el

2007-07-09 Thread lgfang
Hi,

I think this is a bug of pylint.el.  But I failed finding a way to
submit the bug neither in its official site nor in google.  So I post
it here wishing it may be useful for some buddies.

The bug is that it uses compile-internal from compile without
require compile.  So M-x pylint will fail if compile hadn't been
loaded in advance by any means.

My fix is rather straightforward: add (require 'compile) in the code.

-- begin diff output --
2a3
   (require 'compile)
-- end diff output --

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


Re: Tool for finding external dependencies

2007-07-09 Thread kyosohma
On Jul 8, 8:39 pm, Rob Cakebread [EMAIL PROTECTED] wrote:
 Hi,

 I need to find external dependencies for modules (not Python standard
 library imports).

 Currently I use pylint and manually scan the output, which is very
 nice, or use pylint's --ext-import-graph option to create a .dot file
 and extract the info from it, but either way can take a very long
 time.

 I'm aware of Python's modulefinder.py, but it doesn't find external
 dependencies (or at least I don't know how to make it do them).

 Thanks,
 Rob

Recently I ran into some debugging issues and the freeware app
Dependency Walker was suggested to me. I still haven't used it much
since I only got it last Friday, but it looks promising:
http://www.dependencywalker.com

Mike

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


Re: wxPython - ListCtrl ColumnSorterMixin sometimes works sometimes doesn't!

2007-07-09 Thread kyosohma
On Jul 7, 7:55 am, Steve Senior [EMAIL PROTECTED] wrote:
 Hi,

 My application has a tree control in which a user can select a filter.
 This filter is then applied to the results and the results are
 constructed in the ListControl (report style) widget.

 This all works fine.

 Recently I added the wx.lib.mixins.listctrl.ColumnSorterMixin mixin to
 the ListCtrl widget.

 Now here is the problem. On some of the filters you can sort all of the
 columns both ascending and descending - i.e. if you click a column once
 it will sort properly, then if you click the column again it will
 happily reverse the sort.

 On some of the filters you can only sort the column once. Repeated
 clicks do not reverse the sort order. I added some print statments to
 the listctrl.py to see what was happening here and it appears that when
 you click the column for the second time, it actually sorts it twice
 which means that the display doesn't change!

 This is really perplexing me, I've exhausted all of my options and need
 some help please.

 Many Thanks,
 Steve.

It sounds a lot like your program is firing an event twice. What event
are you using to capture the mouse-click? You are much better off
posting wxPython specific questions to the wxPython user's list:
http://www.wxpython.org/maillist.php

Mike

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


ANN: new Python magazine looking for authors

2007-07-09 Thread Marco Tabini

Hello—

I am happy to announce the launch of Python Magazine [1], a magazine  
dedicated entirely to programming with Python and related  
technologies. PyMag will be published starting in October and will be  
available in both print and PDF format.


Currently, we are looking for authors [2] and for suggestions on  
topics that you would like covered. We also offering a special deal  
on subscription pre-orders [3], including a contest to win a new  
MacBook.


Thanks!


Marco Tabini


[1] http://www.pythonmagazine.com
[2] http://www.pythonmagazine.com/c/p/write_for_us
[3] http://www.pythonmagazine.com/c/subscribe

--
Marco Tabini
php|architect / Python Magazine


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

Re: Broken MUA interactions (was: Restarting a Python Application)

2007-07-09 Thread Gabriel Genellina
En Mon, 09 Jul 2007 10:48:39 -0300, Chris Mellon [EMAIL PROTECTED]  
escribió:

 It's working as instructed, but that doesn't mean that it's doing the
 best thing. It's common practice for mailing lists to set the reply-to
 to the list itself, because that's the common case, and because it's
 encouraged to keep discussion on the list.

 If whoever manages the python lists doesn't want to do it, either
 because they have some practical reason or because they've got a bug
 up their ass about mail readers without list support, thats fine. But
 it's hardly incorrect to configure it with the reply-to set to the
 list, either.

No, it's not correct to modify Reply-To. Some reasons:  
http://www.unicom.com/pw/reply-to-harmful.html

-- 
Gabriel Genellina

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


Re: Tool for finding external dependencies

2007-07-09 Thread Rob Cakebread
On Jul 9, 7:17 am, [EMAIL PROTECTED] wrote:


 Recently I ran into some debugging issues and the freeware app
 Dependency Walker was suggested to me. I still haven't used it much
 since I only got it last Friday, but it looks 
 promising:http://www.dependencywalker.com

 Mike

Thanks Mike, but I'm just trying to determine Python imports, like:

$ pylint g_pypi

[snip lots of other tests which take a lonng time]

External dependencies
-
::

configobj (g_pypi.config)
portage (g_pypi.enamer,g_pypi.portage_utils,g_pypi.cli)
pkg_resources (g_pypi.cli,g_pypi.ebuild)
yolk
  \-pypi (g_pypi.cli)
  \-setuptools_support (g_pypi.cli)
  \-yolklib (g_pypi.cli)
gentoolkit (g_pypi.portage_utils)
pygments (g_pypi.ebuild)
  \-lexers (g_pypi.ebuild)
  \-formatters (g_pypi.ebuild)
Cheetah
  \-Template (g_pypi.ebuild)


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


catching empty strings (I guess that's what they are)

2007-07-09 Thread brad
I've began accepting user input :( in an old program. The input comes 
from a simple text file where users enter filenames (one per line). What 
is the appropriate way to handle blank lines that hold whitespace, but 
not characters? Currently, I'm doing this:

  for user_file in user_files:
 # Remove whitespace and make lowercase.
 file_skip_list.append(user_file.strip().lower())

  file_skip_list = list(sets.Set(file_skip_list))

However, if the input file has blank lines in it, I get this in my list:

'' (that's two single quotes with noting in between)

I thought I could do something like this:

if user_file == None:
 pass

Or this:

if user_file == '':
 pass

But, these don't work, the '' is still there. Any suggestions are 
appreciated!

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


Re: A clean way to program an interface

2007-07-09 Thread Diez B. Roggisch
rh0dium wrote:

 On Jul 9, 3:53 am, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 THROW IT AWAY

 Seriously. That's one of the most convoluted, incomprehensible pieces of
 python I've seen. Ever.

 All the sys._getframe()-stuff has to go. Really. There are about a dozen
 pieces of code worldwide that are allowed to have that in them. Maybe two
 dozen.

 And while I'm having difficulties grasping what you actually mean by  I
 represent each function as a class or should I keep the code
  I have below?, I've done my fair share of serial programming. And I
  would
 say that having one class that exposes different methods for commands is
 the way to go.

 But first - throw that code away. Fast. Faster.

 Diez
 
 Hi Diez,
 
 Totally understand your confusion with sys._getframe().f_code.co_name
 - that was borne out of the fact that I was creating a method for each
 serial function and it was repeating.. over and over.. 
 So I got tired 
 of changing the three items that differentiated each method so I
 simplified it a bit. Perhaps too much.  

I can't say that it has become simpler... It would have been if you at least
created a function for it. But even then, it's certainly the wrong way to
go.

 So can I ask you to show or 
 point me to a good interface example?  I think we both can agree that
 fundamentally this is pretty simple but I want to do it right and an
 solid class example of interface programming would be nice.

I don't understand what you mean by interface programming. If you tell us
how the serial protocol works, and what it accomplishes, one might come up
with a clean solution.

But that depends on the actual protocol.

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


Re: TypeError: can't multiply sequence to non-int

2007-07-09 Thread Gabriel Genellina
En Mon, 09 Jul 2007 10:12:42 -0300, Snezhana [EMAIL PROTECTED]  
escribió:

???

Did you intend to post any question?
The error is rather explicit: you can't say:
abc * 5.2241
[1,2,3] * Hello
(4,z) * None

The right operand must be an integer:
abc * 5 (gives abcabcabcabcabc)
[1,2,3] * 8 (gives a list with 24 numbers)
(4,z) * 2 (gives (4,z,4,z))

-- 
Gabriel Genellina

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


Re: catching empty strings (I guess that's what they are)

2007-07-09 Thread Diez B. Roggisch
brad wrote:

 I've began accepting user input :( in an old program. The input comes
 from a simple text file where users enter filenames (one per line). What
 is the appropriate way to handle blank lines that hold whitespace, but
 not characters? Currently, I'm doing this:
 
   for user_file in user_files:
  # Remove whitespace and make lowercase.
  file_skip_list.append(user_file.strip().lower())
 
   file_skip_list = list(sets.Set(file_skip_list))
 
 However, if the input file has blank lines in it, I get this in my list:
 
 '' (that's two single quotes with noting in between)
 
 I thought I could do something like this:
 
 if user_file == None:
  pass
 
 Or this:
 
 if user_file == '':
  pass
 
 But, these don't work, the '' is still there. Any suggestions are
 appreciated!

They are still there because you perform the stripping and lowercasing in
the append-call. Not beforehand. So change the code to this:

for uf in user_files:
uf = uf.strip().lower()
if uf:
   file_skip_list.append(uf)

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


compressing consecutive spaces

2007-07-09 Thread Beliavsky
How can I replace multiple consecutive spaces in a file with a single
character (usually a space, but maybe a comma if converting to a CSV
file)? Ideally, the Python program would not compress consecutive
spaces inside single or double quotes. An inelegant method is to
repeatedly replace two consecutive spaces with one.

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


What is the preferred doc extraction tool?

2007-07-09 Thread Emin.shopper Martinian.shopper

Dear Experts,

What is the preferred doc extraction tool for python? It seems that there
are many very nice options (e.g., pydoc, epydoc, HappyDoc, and lots of
others), but what is the standard tool or at least what is the tool used
to generate the documentation for the python standard library?

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

Re: catching empty strings (I guess that's what they are)

2007-07-09 Thread brad
Diez B. Roggisch wrote:

 They are still there because you perform the stripping and lowercasing in
 the append-call. Not beforehand. 

Thank you. I made the changes. It works.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tool for finding external dependencies

2007-07-09 Thread kyosohma
On Jul 9, 9:27 am, Rob Cakebread [EMAIL PROTECTED] wrote:
 On Jul 9, 7:17 am, [EMAIL PROTECTED] wrote:



  Recently I ran into some debugging issues and the freeware app
  Dependency Walker was suggested to me. I still haven't used it much
  since I only got it last Friday, but it looks 
  promising:http://www.dependencywalker.com

  Mike

 Thanks Mike, but I'm just trying to determine Python imports, like:

 $ pylint g_pypi

 [snip lots of other tests which take a lonng time]

 External dependencies
 -
 ::

 configobj (g_pypi.config)
 portage (g_pypi.enamer,g_pypi.portage_utils,g_pypi.cli)
 pkg_resources (g_pypi.cli,g_pypi.ebuild)
 yolk
   \-pypi (g_pypi.cli)
   \-setuptools_support (g_pypi.cli)
   \-yolklib (g_pypi.cli)
 gentoolkit (g_pypi.portage_utils)
 pygments (g_pypi.ebuild)
   \-lexers (g_pypi.ebuild)
   \-formatters (g_pypi.ebuild)
 Cheetah
   \-Template (g_pypi.ebuild)

Hmmm...I also use GUI2Exe, which may help you too. It'll list missing
modules and binary dependencies. It's basically a GUI interface to
py2exe:

http://xoomer.alice.it/infinity77/eng/GUI2Exe.html


This looks interesting, but I've never used it:

http://www.tarind.com/depgraph.html


Finally, here's some more info on modulefinder:

http://svn.python.org/projects/python/trunk/Lib/modulefinder.py

Looks like you run modulefinder like this:

code

mod = modulefinder.ModuleFinder()
mod.run_script(path/to/python_script.py)
mod.report()

/code

Mike

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


Re: What is the preferred doc extraction tool?

2007-07-09 Thread BJörn Lindqvist
On 7/9/07, Emin.shopper Martinian.shopper [EMAIL PROTECTED] wrote:
 Dear Experts,

 What is the preferred doc extraction tool for python? It seems that there
 are many very nice options (e.g., pydoc, epydoc, HappyDoc, and lots of
 others), but what is the standard tool or at least what is the tool used
 to generate the documentation for the python standard library?

The tool is Latex plus a lot of utilities that help make the HTML
output good looking. It doesn't even extract documentation from the
source. The best tool is definitely epydoc. It produces very good
looking javadoc-like html output by default, no annoying css setup
needed. You can also produce pdfs with it which is very nice.

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Broken MUA interactions (was: Restarting a Python Application)

2007-07-09 Thread Chris Mellon
On 7/9/07, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Mon, 09 Jul 2007 10:48:39 -0300, Chris Mellon [EMAIL PROTECTED]
 escribió:

  It's working as instructed, but that doesn't mean that it's doing the
  best thing. It's common practice for mailing lists to set the reply-to
  to the list itself, because that's the common case, and because it's
  encouraged to keep discussion on the list.
 
  If whoever manages the python lists doesn't want to do it, either
  because they have some practical reason or because they've got a bug
  up their ass about mail readers without list support, thats fine. But
  it's hardly incorrect to configure it with the reply-to set to the
  list, either.

 No, it's not correct to modify Reply-To. Some reasons:
 http://www.unicom.com/pw/reply-to-harmful.html


None of those are reasons, they're opinions and weary old excuses. I'm
not necessarily saying munging is the correct thing to do (although,
personally, I support it and would prefer if the python lists did it)
but it's about a clash of opinions about what cases and behaviors
should be supported and encouraged. Since it's obviously not my call
as I'm not the admin of the python lists I adjust to what the list
does, but claiming that people asking for the other behavior are
incorrect or out of line in some way is just unjustified.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Paul Rubin
Diez B. Roggisch [EMAIL PROTECTED] writes:
  status = all(list)
  
  Am I mistaken, or is this no identity test for False at all?
 
 You are mistaken. all take an iterable and returns if each value of it is
 true.

all(list) does what the OP's code did, tests for the presence of a false
value in the list.  If you want an identity test, use 

  status = not (False in list)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Hrvoje Niksic
Paul McGuire [EMAIL PROTECTED] writes:

  False in [3, 2, 1, 0, -1]

 True# no False here all([3, 2, 1, 0, -1])

 False   # false value present, not necessarily False

 I think if you want identity testing, you'll need to code your own;

I'm aware of that, I simply pointed out that False in list and
any(list) are not equivalent and where the difference lies.

 any(map(lambda _ : _ is False,[3,2,1,0,-1]))

Note that you can use itertools.imap to avoid the unnecessary
intermediate list creation.  Even better is to use a generator
expression:

 any(x is False for x in [3, 2, 1, 0, -1])
False
 any(x is False for x in [3, 2, 1, 0, -1, False])
True
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compressing consecutive spaces

2007-07-09 Thread Pomato
On Jul 9, 7:38 am, Beliavsky [EMAIL PROTECTED] wrote:
 How can I replace multiple consecutive spaces in a file with a single
 character (usually a space, but maybe a comma if converting to a CSV
 file)? Ideally, the Python program would not compress consecutive
 spaces inside single or double quotes. An inelegant method is to
 repeatedly replace two consecutive spaces with one.

You can use re.sub():
re.sub(pattern, substitution, string)

import re
re.sub(r'\ +', ' ', 'foo bar')


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


no python install

2007-07-09 Thread Beethon
my computer has no puthon installed
i downloaded some sofware that are shiped with .py files
please explain how the programs become workable ?

thanks

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


execute script in certain directory

2007-07-09 Thread brad
When I use idle or a shell to execute a python script, the script 
executes in the directory it is currently in (in this case, my desktop). 
However, when using GNOME and right clicking the py script and selecting 
'open with python', the execution occurs in my home directory, not my 
desktop.

Is there a way to force py scripts to always run within the directory 
that they reside in?

Thanks

Brad

/home/brad/Desktop/output - python from shell
/home/brad/Desktop/output - python from idle
/home/brad/output - python from Gnome 'right click' open with menu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Bjoern Schliessmann
Diez B. Roggisch wrote:
 Bjoern Schliessmann wrote:
 Paul Rubin wrote:
 lex [EMAIL PROTECTED] writes:

 but what is your best way to test for for False in a list?
 
 status = all(list)
 
 Am I mistaken, or is this no identity test for False at all?
 
 You are mistaken. all take an iterable and returns if each value
 of it is true.

That's an identity test for True, not for False (the latter was
requested). Thus, I'm not mistaken.

Regards,


Björn


-- 
BOFH excuse #236:

Fanout dropping voltage too much, try cutting some of those little
traces

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


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Paul Rubin
Bjoern Schliessmann [EMAIL PROTECTED] writes:
  You are mistaken. all take an iterable and returns if each value
  of it is true.
 
 That's an identity test for True, not for False (the latter was
 requested). Thus, I'm not mistaken.

No, true is not the same thing as True.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: no python install

2007-07-09 Thread kyosohma
On Jul 9, 10:26 am, Beethon [EMAIL PROTECTED] wrote:
 my computer has no puthon installed
 i downloaded some sofware that are shiped with .py files
 please explain how the programs become workable ?

 thanks

Check the softwares' website(s) to see what the dependencies are and
download them. You can download Python at www.python.org.

Mike

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


Re: Tool for finding external dependencies

2007-07-09 Thread Rob Cakebread
On Jul 9, 7:54 am, [EMAIL PROTECTED] wrote:
snip
 code

 mod = modulefinder.ModuleFinder()
 mod.run_script(path/to/python_script.py)
 mod.report()

 /code

 Mike

Nope. All of those tools and the code above show *all* imports/
dependencies, which is way too much information. I just need the
'external' dependencies, like in the example from pylint I pasted
above. If nothing exists I'll just have to figure out how pylint does
it.

I'm working on g-pypi which creates ebuilds for Gentoo Linux. For
packages that use setuptools I can get the dependencies easily enough
because of 'install_requires', but for packages that don't, I need
another way to find them.

Thanks,
Rob

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


Re: trouble controlling vim with subprocess on windows machine

2007-07-09 Thread Josiah Carlson
[EMAIL PROTECTED] wrote:
  I am having trouble contolling vim with subprocess on a windows
 machine.  It appears that vim comes up on the machine all right and it
 sometimes looks like it is doing the searchs what I am asking it to do
 but when I am asking it to load a file it doesn't do anything.  Is
 there something I need to do to push the data through the pipe??  Here
 is a couple different ways I am trying to do it.
[snip]

This recipe for asynchronous communication using subprocess could be 
used to write an expect-like tool:
   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

It works on both Windows and *nix.


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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-09 Thread Bruno Desthuilliers
Paul Rubin a écrit :
 Bruno Desthuilliers [EMAIL PROTECTED] writes:
 Some users in fact recommend writing an explicit type signature for
 every Haskell function, which functions sort of like a unit test.
 Stop here. explicit type signature == declarative static typing !=
 unit test.
 
 The user-written signature is not a declaration that informs the
 compiler of the type.  The compiler still figures out the type by
 inference, just as if the signature wasn't there.  The user-written
 signature is more like an assertion about what type the compiler will
 infer.  If the assertion is wrong, the compiler signals an error.  In
 that sense it's like a unit test; it makes sure the function does what
 the user expects.

It still boils down to the same problem : possibly valid types are 
rejected based on a declaration.

 I have few surprises with typing in Python. Very few. Compared to
 the flexibility and simplicity gained from a dynamism that couldn't
 work with static typing - even using type inference -, I don't see it
 a such a wonderful gain. At least in my day to day work.
 
 I'm going to keep an eye out for it in my day-to-day coding but I'm
 not so convinced that I'm gaining much from Python's dynamism.

I sure do.

 However, that may be a self-fulfilling prophecy since maybe I'm
 cultivating a coding style that doesn't use the dynamism,

Perhaps is this coding style not making the best use of Python's 
features ? To me, it sounds like doing procedural programming in OCaml - 
it's of course possible, but probably not the best way to use the language.

 and I could
 be doing things differently.  I do find since switching to Python 2.5
 and using iterators more extensively, I use the class/object features
 a lot less.  Data that I would have put into instance attributes on
 objects that get passed from one function to another, instead become
 local variables in functions that get run over sequences, etc.

Dynamism is more than simply adding cargo attributes to objects.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list.append not working?

2007-07-09 Thread Bruno Desthuilliers
Hardy a écrit :
 On 5 Jul., 18:07, infidel [EMAIL PROTECTED] wrote:
 On Jul 5, 8:58 am, Hardy [EMAIL PROTECTED] wrote:



 I experience a problem with append(). This is a part of my code:
 for entity in temp:
 md['module']= entity.addr.get('module')
 md['id']=entity.addr.get('id')
 md['type']=entity.addr.get('type')
 #print md
 mbusentities.append(md)
 #print mbusentities
 I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
 {'module': 'work', 'id': 456, 'type': 'core'}]
 md is always correct, BUT:mbusentities is wrong. Length of
 mbusentities is same of temp, so it appended everything. BUT:
 mbusentities only shows the values of the last append: [{'module':
 'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
 'type': 'core'}]
 What's wrong?
 You're reusing the same md dictionary over and over, appending the
 same object to the list each time.  So what you have is a list of
 references to the same dictionary.  You need to set md = {} first
 thing each iteration.
 
 Thanks, that was my mistake, should take a break, getting code-blind :D
 

append = mbusentities.append
for entity in temp:
   get = entity.addr.get
   append(dict((k, get(k)) for k in ('module', 'id', 'type')))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tool for finding external dependencies

2007-07-09 Thread Alex Popescu
On Jul 9, 6:42 pm, Rob Cakebread [EMAIL PROTECTED] wrote:
 On Jul 9, 7:54 am, [EMAIL PROTECTED] wrote:
 snip

  code

  mod = modulefinder.ModuleFinder()
  mod.run_script(path/to/python_script.py)
  mod.report()

  /code

  Mike

 Nope. All of those tools and the code above show *all* imports/
 dependencies, which is way too much information. I just need the
 'external' dependencies, like in the example from pylint I pasted
 above. If nothing exists I'll just have to figure out how pylint does
 it.


Isn't it possible to get from modulefinder what it has found and just
filter it out according to your rules?
This way you are in control and can deicde what is internal/external.

./alex
--
.w( the_mindstorm )p.

 I'm working on g-pypi which creates ebuilds for Gentoo Linux. For
 packages that use setuptools I can get the dependencies easily enough
 because of 'install_requires', but for packages that don't, I need
 another way to find them.

 Thanks,
 Rob


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


Re: Tool for finding external dependencies

2007-07-09 Thread Rob Cakebread
On Jul 9, 9:23 am, Alex Popescu [EMAIL PROTECTED]
wrote:
 Isn't it possible to get from modulefinder what it has found and just
 filter it out according to your rules?
 This way you are in control and can deicde what is internal/external.


At first glance it looked easy enough, by just filtering out
everything that isn't in site-packages, but that isn't quite accurate
as accurate as pylint and it also shows indirect dependencies too.
e.g. pkga imports pkgb, which imports pkgc. I don't want pkgc.

To clarify, if I had a module with:

import os,sys, re
import sqlobject

I only want to know about sqlobject. I don't want any of sqlobject's
dependencies, such as MySQLdb, pysqlite2, psycopg2 etc. which
modulefinder shows also.

And as far as I can tell, modulefinder needs a Python script, but its
much easier for me to find a package's modules automatically.


Thanks,
Rob



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


Re: A clean way to program an interface

2007-07-09 Thread Paul McGuire
I believe the OP is talking about interface as in hardware
interface, using some form of serial communication.  His example does
not use pyserial, but it does refer to a UnidenConnection class,
with parameters such as bitrate, port, etc. for what looks like serial
communication.

Some general comments:

1. Much of the OP's use of sys._getframe().f_code.co_name coincides
with his naming of certain methods with the same name as the command
to be sent down the serial line.  STS, EPG, PRG, SIN, etc. are
all 3-character command codes that get sent down the wire, along with
the appropriate values for the particular command.  While many of
these routines have *some* code in common, only a few have their
entire method body duplicated with one or more other methods.
Refactoring a couple of these into code closures, you can get:

@staticmethod
def makeStatusCheckCommandFunction(cmd):
def fn(self):
return ( self.uniden.write(cmd)[0]==OK )
return fn
PRG = makeStatusCheckCommandFunction(PRG)
EPG = makeStatusCheckCommandFunction(EPG)


@staticmethod
def makeCmdFunction(cmd,attrname):
def fn(self):
setattr(self, attrname, int(self.PRGWrite(cmd)[0]))
return getattr(self,attrname)
return fn
SCT = makeCmdFunction(SCT,systems)
SIH = makeCmdFunction(SIH,sih)
SIT = makeCmdFunction(SIT,sit)

Now there is no sys._getframe().f_code.co_name legerdemain going on,
the command strings are just passed along as the argument cmd, and the
functions themselves are named the same for some level of self-
documentation and/or convenience.

For the remaining methods, I declare a local variable named cmd and
assign to it the write mnemonic.  Yes, I know it violates DRY (Don't
Repeat Yourself), but it avoids the getframe() stuff and again, is at
least a snippet of self-documentation.

2. This code for reading and unpacking all the non-blank values feels
ugly:

cmd = SIF
if args is None:
p=self.PRGWrite(%s,%s % (cmd,idx))
t={}
t[site_type],t[name],t[quick_key],t[hld],t[lout],\
t[mod],t[att],t[cch],t[apco],t[threshold],\
t[rev_index],t[fwd_index],t[sys_index],t[chn_head],
\
t[chn_tail],t[seq_no],t[start_key],t[latitude],\
t[longitude],t[range],t[gps_enable],t[rsv]=p

delitems=[]
for item in t:
if t[item]==: delitems.append(item)
for x in delitems: del t[x]

How about this instead?:

cmd = SIF
if args is None:
p=self.PRGWrite(%s,%s % (cmd,idx))
names = site_type name quick_key hld lout mod att cch \
apco threshold rev_index fwd_index sys_index \
chn_head chn_tail seq_no start_key latitude  \
longitude range gps_enable rsv.split()

t = dict( k,v for k,v in zip(names,p) if v !=  )


HTH,
-- Paul

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


Python ghost compile

2007-07-09 Thread funtimes
I split a large python (2.5.1) program into three modules. Let's call them 
mainmod, submod1, and submod2. mainmod imports submod1 and submod2. When I 
make changes to any of these modules, it is not reflected in the 
compile.  Only if exit idle and re-run idle. I've removed the two relevant 
.pyc files. It holds onto the first compile made after starting idle. I've 
triple-checked the names I've given the modules, they're all unique. Any clues?


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


Re: compressing consecutive spaces

2007-07-09 Thread Paul McGuire
On Jul 9, 9:38 am, Beliavsky [EMAIL PROTECTED] wrote:
 How can I replace multiple consecutive spaces in a file with a single
 character (usually a space, but maybe a comma if converting to a CSV
 file)? Ideally, the Python program would not compress consecutive
 spaces inside single or double quotes. An inelegant method is to
 repeatedly replace two consecutive spaces with one.

Split with no arguments splits on whitespace, and multiple spaces
count as but a single separator.  So split+join = collapsed
whitespace.

 test = a  b c d   efdd  slkj   sdfdsfl
  .join(test.split())
'a b c d efdd slkj sdfdsfl'

Or use something other than   to join with, such as ,.
 ,.join(test.split())
'a,b,c,d,efdd,slkj,sdfdsfl'

-- Paul



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


Re: Python ghost compile

2007-07-09 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb:
 I split a large python (2.5.1) program into three modules. Let's call 
 them mainmod, submod1, and submod2. mainmod imports submod1 and submod2. 
 When I make changes to any of these modules, it is not reflected in the 
 compile.  Only if exit idle and re-run idle. I've removed the two 
 relevant .pyc files. It holds onto the first compile made after starting 
 idle. I've triple-checked the names I've given the modules, they're all 
 unique. Any clues?

Use reload. Or an external interpreter, to avoid side-effects.

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


Re: execute script in certain directory

2007-07-09 Thread Alex Popescu
On Jul 9, 6:31 pm, brad [EMAIL PROTECTED] wrote:
 When I use idle or a shell to execute a python script, the script
 executes in the directory it is currently in (in this case, my desktop).
 However, when using GNOME and right clicking the py script and selecting
 'open with python', the execution occurs in my home directory, not my
 desktop.

 Is there a way to force py scripts to always run within the directory
 that they reside in?

 Thanks

 Brad

 /home/brad/Desktop/output - python from shell
 /home/brad/Desktop/output - python from idle
 /home/brad/output - python from Gnome 'right click' open with menu

Interesting. I was wondering about the opposit: being in the parent
dir, how can I run a module from a package. (the current behavior when
running python dir_name\module.py is to consider the dir_name the
current dir and this breaks all imports). I am pretty sure this is
answered somewhere, but I must confess that so far I haven't been able
to find it :-(.

TIA,

./alex
--
.w( the_mindstorm )p.


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


Re: execute script in certain directory

2007-07-09 Thread vasudevram
On Jul 9, 8:31 pm, brad [EMAIL PROTECTED] wrote:
 When I use idle or a shell to execute a python script, the script
 executes in the directory it is currently in (in this case, my desktop).
 However, when using GNOME and right clicking the py script and selecting
 'open with python', the execution occurs in my home directory, not my
 desktop.

 Is there a way to force py scripts to always run within the directory
 that they reside in?

 Thanks

 Brad

 /home/brad/Desktop/output - python from shell
 /home/brad/Desktop/output - python from idle
 /home/brad/output - python from Gnome 'right click' open with menu

Any program that runs has a concept of a current directory. All its
work is done relative to that, unless you open files with absolute
paths.

Don't know if there's a generic way to do what you want. (There may
be, just can't think of it right now). But there are specific ways -
script-specific, that is:

Add these lines to the top of your script:

import os
os.chdir(rundir)

# Replace rundir above with the absolute path (in quotes) of whatever
directory you want the script to have as its current directory when it
runs.

Looks like GNOME is doing a chdir to your home directory (probably for
convenience or security reasons) before running your script, thats why
you see that behaviour. This is why I say there may not be an easy
generic way to do it - because it would involve modifying all possible
execution environments from which your script could be launched. E.g.:
even if you modify GNOME to do what you want, how about if tomorrow
someone else wants to run your script from KDE or some other window
manager? these could do things differently.

HTH
Vasudev Ram
http://www.dancingbison.com
http://jugad.livejournal.com
http://sourceforge.net/projects/xtopdf


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


Python ghost compile

2007-07-09 Thread funtimes
I split a large python (2.5.1) program into three modules. Let's call them 
mainmod, submod1, and submod2. mainmod imports submod1 and submod2. When I 
make changes to any of these modules, it is not reflected in the 
compile.  Only if exit idle and re-run idle. I've removed the two relevant 
.pyc files. It holds onto the first compile made after starting idle. I've 
triple-checked the names I've given the modules, they're all unique. Any 
clues?


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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-09 Thread Chris Mellon
On 07 Jul 2007 23:27:08 -0700, Paul Rubin
http://phr.cx@nospam.invalid wrote:
 Hamilton, William  [EMAIL PROTECTED] writes:
   Why on earth would anyone prefer taking a failure in the field over
   having a static type check make that particular failure impossible?
 
  Because static typechecking won't make that particular failure
  impossible,  but instead just change it from a type error into a data
  error that may or may not be harder to identify.  If your program gets a
  piece of data that breaks it, you'll get a failure in the field.  Static
  typechecking won't prevent that.

 I'm not doing a good job explaining that regexp example.  Static
 checking a la Haskell and ML avoids these problems by:

   1) noticing through case analysis that you actually handle the
  error return (except it looks like you have to use a separate
  tool for this in Haskell, sigh); and

   2) (in Haskell) using monadic types to propagate match results from
  one operation to another, automatically taking care of turning
  a match failure in a chain of operations into a failure of the
  whole chain.

 In Python it's all too common to say

  g1 = re.match(pattern, string)
  a = g2.group(0)
  g2 = re.match(template % a, other_string)
  result = g2.group(1)

 or stuff like that, without bothering to check for match failures,
 just because of Python's inconvenient syntax.


I don't think it's the syntax that keeps people from checking for
errors. It's more a difference of error handling philosophy - in
Python, if you can't do something sensible with an error you  just
pretend it can't happen and rely on your caller to do something
sensible. In a lot of cases, this means that nobody does anything and
errors propagate all the way up and thats fine.

What you're describing with the type inference solution feels more
like Javas checked exceptions to me, where the compiler ends up
signaling an error if you don't pretend like you considered the error
condition. In Java, at least, this tends to create actively harmful
code where you stick in empty or otherwise useless exception handlers
to shut up the compiler, and when can't happen errors actually do
occur they are lost or worse. Maybe this doesn't happen in Haskel, but
I'd be interested in how it doesn't.
-- 
http://mail.python.org/mailman/listinfo/python-list


Class file location

2007-07-09 Thread axjacob

Is there a way to define a different directory for the generated 
.class(*$py.class) files than the current directory where the python scripts 
are located and executed from?

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


Re: Htmllib help

2007-07-09 Thread axjacob
Thank you.

The NullWriter worked perfectly. I will certainly look at HTMLParser. 

 -- Original message --
From: Gabriel Genellina [EMAIL PROTECTED]
 En Fri, 06 Jul 2007 03:44:20 -0300, [EMAIL PROTECTED] escribió:
 
  Thats right I don't need the output any where so I don't need to use the  
  writer. I can remove it wowever will the formater work since it needs  
  writer? Maybe I can use the Null writer?
 
 Exactly. Look at the HTMLParser module too; depending on your needs, it  
 may be easier to use.
 
   -- Original message --
  From: Gabriel Genellina [EMAIL PROTECTED]
  En Thu, 05 Jul 2007 20:23:08 -0300, [EMAIL PROTECTED] escribió:
  
   Even though I don't use any print statements, the htmllib seems to be
   throwing parts of the html page on to the standard out(my screen in  
  this
   case). Is there a way to disable the output?
  
   import htmllib
   w = formatter.DumbWriter()
 
  Change the above line. From  
  http://docs.python.org/lib/writer-impls.html:
  class DumbWriter([file[, maxcol = 72]])
 Simple writer class which writes output on the file object passed in as
  file or, if file is omitted, on standard output.
 
 -- 
 Gabriel Genellina
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list

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

ImportError: MemoryLoadLibrary failed loading

2007-07-09 Thread kyosohma
Hi,

Recently I began my journey into creating executables. I am using
Andrea
Gavana's cool GUI2EXE program which works very well and that is a GUI
for
py2ece. I am also using Inno Setup to create a script/executable.
Anyway,
today I am putting the program to the test with some volunteer testers
and
I've hit a wall. On the first tester's PC the program installed
beautifully and runs great. The next tester's PC, the program failed
to
run complaining that MSVCR71.dll didn't exist. I copied that file on
there and now I get the following traceback written to my exe's log
file:

Traceback (most recent call last):
File reminder.py, line 23, in ?
File zipextimporter.pyo, line 78, in load_module
File wx\__init__.pyo, line 45, in ?
File zipextimporter.pyo, line 78, in load_module
File wx\_core.pyo, line 4, in ?
File zipextimporter.pyo, line 91, in load_module
ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd

I see other user's have this issue too sometimes and they talk a lot
about
a gdiplus.dll file. My user's PC has that file in 4 places on her
computer and my development PC has it in 6 places. Does either DLL
have to
be in a specific location for the executable to find it? Is this
something
else entirely? I tried sticking the gdiplus.dll file in the directory
my
executable runs from too, but that didn't work either.

I have posted this to the wxPython's group and the py2exe group, but
the latter doesn't have much activity and the wxPython suggestions
didn't work.

Thanks a lot!


Mike

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


Re: How to Machine A python script execute Machine B python script?

2007-07-09 Thread vasudevram
On Jul 9, 1:30 pm, Nick Craig-Wood [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
   On Jul 8, 6:45 pm, johnny [EMAIL PROTECTED] wrote:
   Anyone know how I can make Machine A python script execute a python
   script on Machine B ?

   xmlrpc will work.

 Or pyro

 http://pyro.sourceforge.net/

 Pyro is short for PYthon Remote Objects. It is an advanced and
 powerful Distributed Object Technology system written entirely in
 Python, that is designed to be very easy to use. Never worry about
 writing network communication code again, when using Pyro you just
 write your Python objects like you would normally. With only a few
 lines of extra code, Pyro takes care of the network communication
 between your objects once you split them over different machines on
 the network. All the gory socket programming details are taken care
 of, you just call a method on a remote object as if it were a local
 object!

 --
 Nick Craig-Wood [EMAIL PROTECTED] --http://www.craig-wood.com/nick

  xmlrpc will work.
Right. Pretty easy to use. Go to the xml-rpc.com site to read about
it. Python has it included in the standard library, so you don't need
to get anything extra to use XML-RPC. And it works as advertised, more
or less - I recently wrote some simple servers and clients using
Python and XML-RPC.

Or SOAP (Google for Python SOAP). But not sure if SOAP is actively
supported for Python nowadays.

Or ICE - see www.zeroc.com. Haven't tried it out yet, but appears
interesting.
But it seems ICE has more overhead to setup (your ICE code, I mean,
not to install the software itself) than XML-RPC or Pyro. (It looks
like a lighter version of CORBA - some of the key people who created
it are ex-CORBA experts). Could possibly give better performance or
have more features, though ...

Also, XML-RPC, SOAP, and ICE are all interoperable with different
languages - meaning your server and client can be in different
languages; at least, XML-RPC and SOAP have support in many languages,
while ICE has it for at least for C++, C#, Java, Python, Ruby, PHP,
and Visual Basic (some of these have only support for clients, when I
last checked).

Vasudev Ram
http://www.dancingbison.com
http://jugad.livejournal.com
http://sourceforge.net/projects/xtopdf


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


Re: Class file location

2007-07-09 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote:
 Is there a way to define a different directory for the generated
 .class(*$py.class) files than the current directory where the
 python scripts are located and executed from?

Excuse me, since when does python generate .class files?

Regards,


Björn

-- 
BOFH excuse #439:

Hot Java has gone cold

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


Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Bjoern Schliessmann
Paul Rubin wrote:
 Bjoern Schliessmann [EMAIL PROTECTED]
 writes:

 That's an identity test for True, not for False (the latter was
 requested). Thus, I'm not mistaken.
 
 No, true is not the same thing as True.

Oops, read over that case. Still: No identity test for False.

Regards,


Björn

-- 
BOFH excuse #145:

Flat tire on station wagon with tapes.  (Never underestimate the
bandwidth of a station wagon full of tapes hurling down the
highway Andrew S. Tannenbaum) 

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


Re: compressing consecutive spaces

2007-07-09 Thread [EMAIL PROTECTED]
On Jul 9, 7:38 am, Beliavsky [EMAIL PROTECTED] wrote:
 How can I replace multiple consecutive spaces in a file with a single
 character (usually a space, but maybe a comma if converting to a CSV
 file)? Ideally, the Python program would not compress consecutive
 spaces inside single or double quotes. An inelegant method is to
 repeatedly replace two consecutive spaces with one.



One can try mx.TextTools.  E.g.,


from mx.TextTools import *
import re

string_inside_quotes=re.compile(r'(?Pquote[\']).*?(?!\\)(?
P=quote)',
re.MULTILINE)

def advance_position(text, position, len_text, sre):
mobj = sre.match(text[position:])
if mobj:
incr = len(mobj.group(0))
else:
incr = 0
return position + incr


table = ('try_again',
('quoted_string', CallArg,
(advance_position, string_inside_quotes), +1,
'try_again'),
('nonspace', AllNotIn, ' ', +1, 'try_again'),
('space', AllIn, ' ', +1, 'try_again'),
(None, EOF, Here, +1, MatchOk),
(None, Fail, Here),)

for target_string in (
 Tryusing mx.TextTools 'for parsingstrings',
'It mightbe' just what you needed,
'I find   itworthwhile',
):
print BEFORE:%s % target_string
_, taglist, _ = tag(target_string, table)
if taglist:
tokens = []
for t in taglist:
tagobj, left_index, right_index = t[0:3]
if tagobj == 'space':
tokens.append(' ')
else:
tokens.append(target_string[left_index:right_index])
print AFTER:%s % ''.join(tokens)
else:
print Something went horribly wrong


--
Hope this helps,
Steven

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


Re: Class file location

2007-07-09 Thread axjacob

My mistake. It is Jython.

 -- Original message --
From: Bjoern Schliessmann [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
  Is there a way to define a different directory for the generated
  .class(*$py.class) files than the current directory where the
  python scripts are located and executed from?
 
 Excuse me, since when does python generate .class files?
 
 Regards,
 
 
 Björn
 
 -- 
 BOFH excuse #439:
 
 Hot Java has gone cold
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list

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

  1   2   >