Re: how to finish a while loop...

2008-02-20 Thread Chris
On Feb 20, 3:42 am, richie [EMAIL PROTECTED] wrote:
 On Feb 20, 9:35 am, icarus [EMAIL PROTECTED] wrote:



   To the original poster what environment are you running this in?

  Linux.  Xubuntu if that matters.

   When I put your program in notepad and run it from the windows command
   prompt it works.

  yeah yeah...same here.
  After I got the tip that it actually worked, I went into the eclipse
  directory where the program lives, ran it there from the shell, and it
  worked.  Meaning, I didn't modify anything on the file itself (by
  accident or on purpose).

   But when I paste it into eclipse and run it
   eclipse's console, it doesn't work because answer seems to have a
   stray '\r' carriage return (CR) and therefore the comparison to 'no'
   fails.

I get no 'compile' errors there.
I get regular execution but it just doesn't change the
  condition to False at the very end.
Therefore it loops forever.  I used other values like zeros
  and ones to make sure I could print the values when the interpreter
  got down to that line.  Everything checked.  Just didn't change the
  condition on the main loop.

 I've changed this code a little.
 condition = True
 while ( condition ):
 try:
 integer_one = int ( raw_input( Please enter an integer:  ) )
 integer_two = int ( raw_input( Please enter the second
 integer:  ) )
 division = integer_one / integer_two
 except( ZeroDivisionError ):
 print \nDivision by zero detected
 except( ValueError ):
 print \nYou didn't enter an integer
 else:
 print The result is, division
 answer = raw_input(Do you want to try again (yes or no)? )
 print answer
 #answer=no
 if answer == yes:
 condition=True
 elif answer == no:
 condition=False
 print Good bye, you don't want to continue
 print condition
 And i got this result in eclipse3.2:
 Please enter an integer: 8
 Please enter the second integer: 4
 The result is 2
 Do you want to try again (yes or no)? no
 no
 Good bye, you don't want to continue
 True
 Please enter an integer:

 it seems the input no in eclipse's console to answer won't equal the
 no we compare.
 And when I remove the comment and I get this result:
 Please enter an integer: 8
 Please enter the second integer: 4
 The result is 2
 Do you want to try again (yes or no)? no
 no
 Good bye, you don't want to continue
 False

strip and lowercase your answer for better comparison checking.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the standard for code docs?

2008-02-20 Thread Diez B. Roggisch

 Are people really writing pure HTML snippets in docstrings to document
 each module/class/method?  For anything other than a toy project?
 
 One of the main reasons I'm considering moving to epydoc + reST is
 precisely because it's very un-HTML.
 
 Mind you I want to be able to produce HTML format docs from the
 source, but I don't want to actually *put* HTML anywhere near my
 precious sources.

In the Java-world it *is* pure HTML snipplets... but no, not in python.

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


Why the result same as before modifing py files

2008-02-20 Thread zaley
In my C++ program ,python is embeded . I import One module(py file)
and execute some functions .Then I modify py files in order to modify
func parameters when process is still running .I import the module and
execute functions again.But I find  the result is same as before
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the standard for code docs?

2008-02-20 Thread Paul McGuire
On Feb 15, 10:59 am, Preston  Landers [EMAIL PROTECTED] wrote:
 Hey guys and gals.  What are all the cool kids using these days to
 document their code?  My goal is to create in-line documentation of
 each package/module/class/method and create some semi-nice looking (or
 at least usable) packaged documentation from it, in HTML and/or PDF
 format.

 I've been using effbot's PythonDoc for a while, but it seems like the
 new standard (if there is one) is docutils and restructured text
 (ReST.)  Is that accurate?

 Just from glancing at some samples of ReST the actual format looks
 much easier to work with in plain text in the text editor.
 PythonDoc has not been very popular with my team due to its HTML-ish
 nature and I think ReST will gain more acceptance.  Of course I don't
 want to bother making the jump from PythonDoc to docutils if that
 project is somehow a dead end.

 thanks for any info or advice you can provide.

 Preston

I use epydoc for pyparsing, and I really like the results.  Just make
sure that importing your modules doesn't really do anything
substantial (like connect to db's, or run unit tests that run for
hours); epydoc imports your code and then introspects it to extract
the classes, methods, docstrings, etc.

(And I think you asked an honest question, and did not deserve the
rude answers you got.  This NG is normally better behaved.)

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


Re: Why must implementing Python be hard unlike Scheme?

2008-02-20 Thread Paul Rubin
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:
 Does VM = interpreter?

I think it means the bytecode interpreter. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils and data files

2008-02-20 Thread Robert Bossy
Sam Peterson wrote:
 I've been googling for a while now and cannot find a good way to deal
 with this.

 I have a slightly messy python program I wrote that I've historically
 just run from the extracted source folder.  I have pictures and sound
 files in this folder that this program uses.  I've always just used
 the relative path names of these files in my program.

 Lately, I had the idea of cleaning up my program and packaging it with
 distutils, but I've been stuck on a good way to deal with these
 resource files.  The package_data keyword seems to be the way to go,
 but how can I locate and open my files once they've been moved?  In
 other words, what should I do about changing the relative path names?
 I need something that could work from both the extracted source
 folder, AND when the program gets installed via the python setup.py
 install command.
   
This seems to be a classic distutils  question:  how a python module can 
access to data files *after* being installed?

The following thread addresses this issue:
http://www.gossamer-threads.com/lists/python/python/163159

Carl Banks' solution seems to overcome the problem: his trick is to 
generate an additional configuration module with the relevant 
informations from the distutil data structure. However it is quite an 
old thread (2003) and I don't know if there has been progress made since 
then, maybe the distutils module now incorporates a similar mechanism.

Hope it helps,
RB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the standard for code docs?

2008-02-20 Thread cokofreedom
On Feb 20, 9:12 am, Diez B. Roggisch [EMAIL PROTECTED] wrote:
  Are people really writing pure HTML snippets in docstrings to document
  each module/class/method?  For anything other than a toy project?

  One of the main reasons I'm considering moving to epydoc + reST is
  precisely because it's very un-HTML.

  Mind you I want to be able to produce HTML format docs from the
  source, but I don't want to actually *put* HTML anywhere near my
  precious sources.

 In the Java-world it *is* pure HTML snipplets... but no, not in python.

 Diez

Doxygen is your friend!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Double underscores -- ugly?

2008-02-20 Thread benhoyt

  Then again, what's stopping us just using a single leading underscore?
  Nobody calls their own private methods _init or _add

 You must be looking at different code from the rest of us. A single
 leading underscore on the name *is* the convention for this attribute
 is not part of the external interface, which is about as private as
 Python normally gets.

Yeah, I understand that. I meant -- and I could be wrong -- that I
haven't seen people creating a method called init with a single
leading underscore. It's too similar to __init__, so they would use
some other name.

In other words, defining _init to mean what __init__ now means
probably wouldn't cause name conflicts.

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


Adding more warnings

2008-02-20 Thread Thomas Dybdahl Ahle
I tend to make a lot of mistakes of misspelled variable names.

Is it possible to make python warn me about those at compile time?

Very few times I use dynamic variable initialization. I can live with
getting a warning for those as well.

-- 
Best Regards,
Med Venlig Hilsen,
Thomas

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


Re: Adding more warnings

2008-02-20 Thread Ben Finney
Thomas Dybdahl Ahle [EMAIL PROTECTED] writes:

 I tend to make a lot of mistakes of misspelled variable names.

You would greatly benefit from using tools like 'pyflakes', 'pylint',
and a unit test suite for your code. They're very good for finding
such simple bugs in your code.

 Is it possible to make python warn me about those at compile time?

The names are resolved at run time, so the compiler has insufficient
information to say whether a name is used incorrectly.

-- 
 \Program testing can be a very effective way to show the |
  `\presence of bugs, but is hopelessly inadequate for showing |
_o__)  their absence.  -- Edsger Dijkstra |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Double underscores -- ugly?

2008-02-20 Thread Ben Finney
Please preserve attribution lines on the quoted material, so we can
see who wrote what at each level.

benhoyt [EMAIL PROTECTED] writes:

   Then again, what's stopping us just using a single leading
   underscore? Nobody calls their own private methods _init or _add
 
  You must be looking at different code from the rest of us. A
  single leading underscore on the name *is* the convention for
  this attribute is not part of the external interface, which is
  about as private as Python normally gets.
 
 Yeah, I understand that. I meant -- and I could be wrong -- that I
 haven't seen people creating a method called init with a single
 leading underscore. It's too similar to __init__, so they would
 use some other name.
 
 In other words, defining _init to mean what __init__ now means
 probably wouldn't cause name conflicts.

But it would conflict with the existing conventions. '_init' as a name
indicates that it's *not* treated specially, because it's not named
with double-underscores. Since it *is* treated specially by Python, it
would be confusing not to follow the convention for naming such
attributes.

-- 
 \ I know you believe you understood what you think I said, but I |
  `\ am not sure you realize that what you heard is not what I |
_o__)  meant.  -- Robert J. McCloskey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The big shots

2008-02-20 Thread Carsten Haese
On Tue, 2008-02-19 at 13:48 -0800, [EMAIL PROTECTED] wrote:
 OH YEAH.  Color me absent-minded.  File under No, they're not
 compiled.

I'd ask what you're trying to say here if I had any hope of
understanding the answer. It is becoming clear to me that I am not
worthy of communicating with you.

Best regards,

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


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


Re: firefox cache Python

2008-02-20 Thread subeen
Searching for FF automation but still no luck.

Any other idea on how to locate the cache directory and then read the
directory ?

regards,
Subeen
http://love-python.blogspot.com/

On Feb 20, 3:20 am, Gabriel Genellina [EMAIL PROTECTED]
wrote:

 Search for firefox automation

 --
 Gabriel Genellina

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


Re: Why the result same as before modifing py files

2008-02-20 Thread Helmut Jarausch
zaley wrote:
 In my C++ program ,python is embeded . I import One module(py file)
 and execute some functions .Then I modify py files in order to modify
 func parameters when process is still running .I import the module and
 execute functions again.But I find  the result is same as before

'import' is cached. If do want Python to re-import a module just call
reload(module.)


-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Linux/Python Issues

2008-02-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 
 Paul Boddie wrote:
 The whole CNR stuff and the
 proprietary software slant of Linspire obscures the solution, in my
 opinion.
 
 Thanks for all your help, Paul.
 
 CNR, which is now free, is absolutely marvelous when it's got what you
 need. If Python2.5 were in the warehouse, I'd have clicked, gone to
 make a cup of coffee and the appropriate icon would be on my desktop
 when I came back. If I were Python.org I'd not consider anything ready
 for release until it was in the warehouse.

It's not the project's team duty to build specific packages for each and 
every possible platform / distro / package manager. Debian, Unbuntu, 
Mandriva, RedHat, Gentoo etc all build their own specific packages for 
the projects they want to be part of their distro. Bad luck you choose a 
distro that doesn't do a proper job here. May I suggest you give Ubuntu 
a try ? You might find it very welcoming to outsiders !-)


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


Re: Current Fastest Python Implementation?

2008-02-20 Thread Carl Friedrich Bolz
[EMAIL PROTECTED] wrote:
 On Feb 18, 9:37 am, Stefan Behnel [EMAIL PROTECTED] wrote:
 samuraisam wrote:
 Has anyone done any recent testing as to which current python
 implementation is the quickest?
 Search for a recent thread on CPython and IronPython.

 Perhaps for Django development -
 though the current one certainly is fast (and I doubt micro
 optimizations would make much difference in overall performance).
 Regardless - have those pypy folks made a faster implementation, or
 the jython folks? Or the .NET implementation?
 Depends on your use case. Take your application, do some benchmarking and use
 the implementation that turns out to be a) most reliable and b) the fastest.

 In that order.

That's very good advice. Basically all four of those Python
implementations have situations where they are faster than all the
others. I guess CPython (possibly using Psyco) is still faster in many
cases, but it really depends on your application.

 PyPy [http://codespeak.net/pypy/dist/pypy/doc/home.html] is getting
 progressively faster.

This is true – PyPy is slowly getting faster. We have two students
working explicitly on speed right now: Anto Cuni is doing a phd thesis
on speeding up PyPy's Python interpreter when compiled to .NET and I am
doing a Master thesis on improving the JIT of PyPy.

 In fact for certain things it can be faster than C [http://
 morepypy.blogspot.com/2008/01/rpython-can-be-faster-than-c.html]!

This link is misleading, since it is about the speed of RPython when
translated to C, not normal Python programs. Normal Python programs tend
to be not RPython, so that figure is hardly interesting.

 However it seems it still has a way to go to be fully operational!
 Still looks like the future to me.

Cheers,

Carl Friedrich Bolz

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


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-20 Thread Stani
On Feb 19, 1:19 pm, Steve Holden [EMAIL PROTECTED] wrote:
  Perhaps you could put a link to the source on the Windows instalL page?
  I don't mind being a second-class citizen, but it's annoying to have to
  jump around like that.
It is an open wiki, but I changed it. I am a bit reluctant as the only 
website which is fixed now is http://photobatch.stani.be and all other 
parts (dedibox, wikidot) might change once I've got the time to build my 
own website. So those references run the risk of being outdated in the 
future.

  Looks like a nice piece of work.
Thanks, have a nice day!

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


Re: how to finish a while loop...

2008-02-20 Thread Bruno Desthuilliers
icarus a écrit :
 Hi all, i'm new to python.  Learning on my own how to ask a user to
 finish a loop or not.
 For some reason, it behaves as infinite loop although I changed its
 condition.  Please tell me what I'm doing wrong. Thanks in advance.

Problem mostly solved, so I'll just comment a bit on the code:

 
 condition = True
 
 while ( condition ):

You don't need the parens here

while condition:

 try:
 integer_one = int ( raw_input( Please enter an
 integer:  ) )
 integer_two = int ( raw_input( Please enter the
 second integer:  ) )
 division = integer_one / integer_two
 
 except( ZeroDivisionError ):

You don't need (nor want) the parens here:

   except ZeroDivisionError:

 print \nDivision by zero detected
 except( ValueError ):

idem.

Also, the user will have to start over (ie: re enter 2 integers) if it 
fails the second time.

 print \nYou didn't enter an integer
 else:
 print The result is, division
 answer = raw_input(Do you want to try again (yes or
 no)? )
 if answer == 'yes':
 condition

This line is basically a noop. You don't need this part of the branch.

 elif answer == 'no':
 condition = False

This could be rewritten as:

   if answer == 'no':
   condition = False

which is a very verbose way to say:

   condition = (answer != 'no')



 print Good bye, you don't want to continue


here's a possible rewrite:

class DecodeError(RuntimeError):
pass

def nodecode(val):
return val

def decodeint(val):
 try:
 return int(val)
 except ValueError:
 raise DecodeError(%s is not an integer % val)

YESNO={'yes':True,'y':True,'no':False,'n':False}
def decodeyesno(val):
 try:
 return YESNO[val.strip().lower()]
 except KeyError:
 raise DecodeError(please answer 'yes' or 'no')

def read_input(prompt, decode=nodecode):
 while True:
 val = raw_input(prompt)
 try:
 return decode(val)
 except DecodeError, e:
 print e

def main():
 run = True
 while run:
 integer_one = read_input(Please enter an integer: , decodeint)
 integer_two = read_input(
Please enter the second integer: ,
decodeint
)
 try:
 division = integer_one / integer_two
 except ZeroDivisionError:
 print Division by zero detected
 else:
 print The result is, division
 run = read_input(
 Do you want to try again (yes or no)? ,
  decodeyesno
   )

 print Good bye, you don't want to continue

if __name__ == '__main__':
main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-20 Thread Stani
Wolfgang Strobl news2 at mystrobl.de writes:

 
 Steve Holden steve at holdenweb.com wrote:
 
 RTFM: the web site instructions clearly state that setup.py doesn't 
 currently work with Windows. 
 
 Do they? http://photobatch.stani.be/ doesn't, following documentation
 http://photobatch.stani.be/ doesn't, either.  
Strange. If you follow documentation on http://photobatch.stani.be you get on
the documentation website, where there are clearly links to install.

 I missed start phatch in
 trunk/phatch while browsing through the web site, though. Not finding
 any specific instructions in README and finding no INSTALL at all, I
 expected setup.py to work on any platform.
For the next release I added a remark in README. I hope that helps.

I strongly advise you to read the tutorials:
http://photobatch.wikidot.com/tutorials (for your convenience one of them is
even translated in german, feel free to translate the other one)

Thans to Frédéric, there is now a tutorial for writing your own actions with PIL
(no knowledge of wxpython needed):
http://photobatch.wikidot.com/writing-actions

Also to understand fully how variables work in Phatch for filenames and folders:
http://photobatch.wikidot.com/variables

As a general note, the documentation website is an open wiki, so feel free to
improve or contribute (eg how to install Phatch on Windows ;-) ).





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

Re: The big shots

2008-02-20 Thread Marco Mariani
Sergio Correia wrote:

 I don't get this thread. At all. I want my 15 minutes back.

I think it's a sort of Turing test, to fine-tune some spammer's text 
generating algorithm.

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


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-20 Thread Stani
Fred Pacquier xnews2 at fredp.lautre.net writes:

 
 Steve Holden steve at holdenweb.com said :
 
  Perhaps you could put a link to the source on the Windows instalL page? 
  I don't mind being a second-class citizen, but it's annoying to have to 
  jump around like that.
 
 I'm interested too, and was also wondering if Phatch is as full-featured 
 unders Windows as under Linux, specifically the EXIF/IPTC functions made 
 available through pyexiv2 : exiv2 itself seems to discriminate between the 
 two, the Windows package only has the executable, not the library.
 

Even without python-pyexiv2 Phatch features read-only EXIF support thanks to
PIL. So you can name your files or write data stamps (date, aperature, velocity,
...) based on EXIF information. If you want to save EXIF and IPTC information to
files you need python-pyexiv2. From its website:
However, the library and all the tools used are cross-platform, so very little
tweaking should be needed to get it to work fine on Windows or MacOS X.
http://tilloy.net/dev/pyexiv2/developers.htm

The exiv2 website says:
The Windows package only contains the command line utility exiv2.exe
(statically linked), manpage and a sample command file; get the source and doc
packages for the library, documentation and other tools.
http://www.exiv2.org/download.html

So maybe someone can compile it.


But... Phatch is designed with flexibility in mind. If someone can point me to a
free python library for Windows for EXIF and other metadata, I'll be happy to
integrate support for it in Phatch. Ideas anyone?

Or you could write a python wrapper around the executable.

Stani
--
Phatch - http://photobatch.stani.be
SPE - http://pythonide.stani.be


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


Re: Double underscores -- ugly?

2008-02-20 Thread Jorge Godoy
Ivan Illarionov wrote:

 I would like to see something like %init or init to be converted to
 __init__ behind the scenes. And $something to be converted to
 self.something. But, unfortunately, most Python people would consider
 this ugly just because Perl uses too much syntactic sugar and anything
 Perl-like is considered ugly in Python community. So, unless Perl die,
 I believe that Python will remain sugar-free.

A good text editor allows you to replace text.  Some of them can even do
that for you with macros when you save a document or open it for editing
(making it possible to go from $ to self and vice-versa).

Maybe using another tool would solve your problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the standard for code docs?

2008-02-20 Thread Marc 'BlackJack' Rintsch
On Tue, 19 Feb 2008 16:37:23 -0800, Preston  Landers wrote:

 On Feb 19, 4:31 pm, [EMAIL PROTECTED] wrote:
 
 But after reading some of your other recent posts on other topics, I'm
 not confident that it was intended to make sense at all.

Have a little bit patience, the bot is still in its early learning phase.  ;-)

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


Re: Double underscores -- ugly?

2008-02-20 Thread Bruno Desthuilliers
Jason a écrit :
(snip)
 Hmm.  I must be the only person who doesn't think the double
 underscores are ugly. 

As far as I'm concerned, I just don't care if they are ugly or not - 
FWIW, I never ever think of them in terms of beauty or ugliness.

What I  do care about is that they simply and clearly convey a special 
meaning (just like the _single_leading_underscore names), and make sure 
you won't accidentaly override such a name.



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


Re: Double underscores -- ugly?

2008-02-20 Thread Bruno Desthuilliers
benhoyt a écrit :
(snip)
 Then again, what's stopping us just using a single leading underscore?
 Nobody calls their own private methods _init or _add

I do.

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


Re: Double underscores -- ugly?

2008-02-20 Thread Bruno Desthuilliers
benhoyt a écrit :
 Then again, what's stopping us just using a single leading underscore?
 Nobody calls their own private methods _init or _add
 You must be looking at different code from the rest of us. A single
 leading underscore on the name *is* the convention for this attribute
 is not part of the external interface, which is about as private as
 Python normally gets.
 
 Yeah, I understand that. I meant -- and I could be wrong -- that I
 haven't seen people creating a method called init with a single
 leading underscore.

Can you see me ?

 It's too similar to __init__, so they would use
 some other name.

Nope. It's perfect for a template method that is supposed to be called 
from the parent's class __init__.

 In other words, defining _init to mean what __init__ now means
 probably wouldn't cause name conflicts.

It would.

What you obviously fail to understand is that the __magic_name__ 
convention is here to clearly separate language implementation space 
from user space. Your suggestion would break this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The big shots

2008-02-20 Thread Dotan Cohen
On 20/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 My point was, that if someone is trying to make
  friends, and either failing or forgetting success, then call a social
  worker.  Or, reach out.

That's the reason why you are often ignored, Castironpi. That point
has no place on this mailing list. We are here to discuss Python, not
social problems and their solutions.

   By the way, you may have noticed that you have been mostly replying to
   your own posts here in c.l.py, which indicates that the lack of

 It.

It what?!?

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Automating GUI interaction with Python

2008-02-20 Thread jorma kala
Hi,

Is there a python library or bindings to a library in some other language
for automating GUI interaction (the kind of functionality provided by Autoit
for instance).
What I need to do is very simple GUI automation : moving the mouse cursor to
and from specified screen coordinates, clicking, etc.
Thanks a lot.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: The big shots

2008-02-20 Thread Dotan Cohen
On 20/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 On Feb 19, 5:31 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
May I insist?  By the criteria you've mentioned so far, nothing rules
out 'ext'.  If it's still a bad idea, there's a reason.  What is it?
  
   You imply that just because something is somehow working and even useful
   for a *some* people (some being maybe only you) that it would be worth
   including in the python standard lib. It is not.
  
   There are no really formal rules for inclusion, but these are certainly
   rules of thumb that are being considered:
  
 - is it useful for *a lot of people*
  
 - will it be mantained and maintainable for ever once it is part of
   the standard distribution
  
 - does it introduce external dependencies? If yes, this must be *very*
   carful considered.
  
 - is the design well-thought and mature
  
 - does it make sense tying the release cycle of python the cycle of the
   new lib
  
   And insulting the people who do work on python and do a marvellous job
   doing so is certainly *not* helping.
  
   Diez


 I don't know quite how to handle your reply.  Counterexamples are
  already in.  Shall I add this to the list:

- is someone's favorite?

No, that is not reason to include something in the standard libraries.

  You all know the allegory of the Apes and the Fire Hose.  But 'ext' is
  actually good.

No, I don't. Does anybody else?

  Do you have these:

  - It would not get used by anyone
  - It is not useful to very many people
  - There is some concern it could not remain maintainable
  - It is neither well-thought out nor mature
  - It will not ever make sense to tie it in to the Python cycle

  ?

  If not, how about these:

  - It doesn't match the rest of the language
  - It's too cutting edge
  - It is too hard to handle
  - It would get out of hand really quickly
  - I can't control you anymore after I let it in
  - The functionality already exists per se
  - It is to the rest of the language as wires #3, #4, and #5 are to RCA
  cables

What?  Here, again, you talk of things that noone here necessarily understands.

  - HTML 4.01 is not an improvement over HTML 4.0

How is that relevant?

  ?

  If still not, how about these:

  - It hurts my feelings
  - It foils my revenge
  - I'd rather you toil meanially
  - Tedious is good
  - You shouldn't have power
  - But I'm greedy
  - We can't afford it

That's trolling. You are about a picometer from my killfile.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Double underscores -- ugly?

2008-02-20 Thread cokofreedom
So people's problem with __word__ is that it is not very readable?

How so, it stands out on page, it clearly is different from other
objects and doesn't abuse other symbols that generally have a meaning
based on their use.

I haven't seen a single alternative that really stands out as much as
__word__ does.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Automating GUI interaction with Python

2008-02-20 Thread Ryan Ginstrom
 On Behalf Of jorma kala
 Is there a python library or bindings to a library in some 
 other language for automating GUI interaction (the kind of 
 functionality provided by Autoit for instance).
 What I need to do is very simple GUI automation : moving the 
 mouse cursor to and from specified screen coordinates, clicking, etc.
 Thanks a lot.

For Windows, try pyWinAuto
http://pywinauto.openqa.org/

Regards,
Ryan Ginstrom

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


help others or

2008-02-20 Thread rpriya94
help others or

guide others or

love others .

**
http://cellbiologystructural.blogspot.com/
**
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Memory Manager

2008-02-20 Thread MartinRinehart


Jeff Schwab wrote:
 What's the Intel architecture?  Do you mean the x86_64 architecture
 that was actually developed by AMD, or x86 for x  some number, or do
 you actually mean IA64?

I mean chips of the family that goes back to the 8086 and 8088 chips,
chips that support the REPZ prefix to the MOVSW instruction.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Memory Manager

2008-02-20 Thread Paul Rubin
[EMAIL PROTECTED] writes:
 I mean chips of the family that goes back to the 8086 and 8088 chips,
 chips that support the REPZ prefix to the MOVSW instruction.

repz movsw is a pretty lame way to copy data on current x86's. 
Use XMM instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Double underscores -- ugly?

2008-02-20 Thread Ben Finney
[EMAIL PROTECTED] writes:

 So people's problem with __word__ is that it is not very readable?

No, the complaint seems to be that it's ugly.

-- 
 \   [T]he speed of response of the internet will re-introduce us |
  `\to that from which our political systems have separated us for |
_o__) so long, the consequences of our own actions.  -- Douglas Adams |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Article of interest: Python pros/cons for the enterprise

2008-02-20 Thread estherschindler
This is part of a series examining the strengths and weaknesses of
various scripting languages, with particular attention to enterprise
(read: big company) use.

You Used Python to Write WHAT?
Python is a powerful, easy-to-use scripting language suitable for use
in the enterprise, although it is not right for absolutely every use.
Python expert Martin Aspeli identifies when Python is the right
choice, and when another language might be a better option.
http://www.cio.com/article/185350
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Double underscores -- ugly?

2008-02-20 Thread Steven D'Aprano
On Wed, 20 Feb 2008 03:12:39 -0800, cokofreedom wrote:

 So people's problem with __word__ is that it is not very readable?
 
 How so, it stands out on page, it clearly is different from other
 objects and doesn't abuse other symbols that generally have a meaning
 based on their use.
 
 I haven't seen a single alternative that really stands out as much as
 __word__ does.

My only two gripes about double underscore names are that:

(1) My news reader interprets _X_ as underline X, which leads to ugly 
display. I could turn that feature off, but that would mean losing *X* 
bold X, which I like.

(2) Two underscores __ is insufficiently visually different from a single 
underscore _. Choosing a good font reduces the problem, but doesn't make 
it go away.

However, these are minor gripes. On a scale of 0 to -9, where 0 is it 
doesn't upset me or please me at all and -9 is I'd rather die than live 
with this one more minute, these gripes are both about a -2, and far out-
weighed by the advantages. Taking the advantages and the disadvantages 
both into account, I give it a total score of about +4.



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


threaded http server

2008-02-20 Thread bharath venkatesh
hi
   i want to create fast n efficient http server which serve multiple
client  concurrently .. so i thought of threading the http server  using

class HTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):
  pass:

as this creates an  threaded version of  http server ... but i read in  one
of   the postings  in mailing list that it will create a deadlock . the
following postings can found at
http://mail.python.org/pipermail/python-list/2001-January/064088.html

as mentioned in that posting log_request must be redefined...  can any one
tell me how to redefine  it so that it creates a  threading behavior for   fast
n efficient http server. or will it be  ok just to pass the definition as
done in the posting mentioned above  and still create an efficient threading
behavior
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Memory Manager

2008-02-20 Thread MartinRinehart


Paul Rubin wrote:
 repz movsw is a pretty lame way to copy data on current x86's.
 Use XMM instead.

Thank you, Paul. I'm pretty sure you meant MMX, Multi-Media
eXtensions.

Paul's just told me to upgrade my 32-bit thinking to use newer 64-bit
registers, even on a 32-bit cpu. Please divide my prior timings by
two.
Pentium or later required.

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


Re: The big shots

2008-02-20 Thread Dotan Cohen
On 20/02/2008, Marco Mariani [EMAIL PROTECTED] wrote:
 Sergio Correia wrote:

   I don't get this thread. At all. I want my 15 minutes back.


 I think it's a sort of Turing test, to fine-tune some spammer's text
  generating algorithm.

You mean this:
http://science.slashdot.org/article.pl?sid=07/12/09/1356201

You've probably right!

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Memory Manager

2008-02-20 Thread MartinRinehart


Steve Holden wrote:
 You have a strange idea of nearly free ...

 Extending an integer array from 100 to 150 items is a pretty puny
 operation when you compare it with the amount of data that might need to
 be moved during a compactifying garbage collection of a 20MB Python
 program image.

20 MBs = 5 M 32-bit words = 1.25 millis to move half of them on a
2GHz
machine. Don't know how much a milli costs where you live.


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


Re: The big shots

2008-02-20 Thread Dotan Cohen
On 20/02/2008, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I'm going to start marking my subjective comments with a star, so it's
  clear what is emperically verifiable, and what is not.

An ascii star? You do realize that email is a text medium, no?

  It's a bad sign.  If you aren't keeping your thoughts to yourself, and
  thrashing about the world for a peer, a social network, a support
  group, or a community, then you missed the day in grammar school when
  they were handing out smiles.  But they're not handing them out
  anymore.

You talk in analogies. I don't understand them. I do not know Spanish,
and maybe if I knew both Spanish and your local customs, I would
understand your analogies. But as a Hebrew-speaking middle easterner,
I don't.

  Even on my emperical claims, I'm wrong 90% of the time.  On the
  subjective ones, I'm not only wrong that much, but no one else want to
  hear, or even can verify them.  Smell's fine to me.

I don't have time for 10% right. I cannot go verify everything that
you think out loud because 10% might be true. No matter how it smells
to you.

  Emotions are prejudiced; and even in my own concrete thoughts, I will
  misidentify myself with another, and others with me.  When I say I,
  I mean you.

I believe that text was reworded for the final draft of Through the
Looking Glass.

  French and Spanish have impersonal pronouns: on and se,
  respectively.  In English, they often come out as, we, they, and
  you a lot, on occasion a one, and sometimes, even, I.

In Hebrew, we have 8 different words for you. That does not affect
my English communications, however.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Double underscores -- ugly?

2008-02-20 Thread Steven D'Aprano
On Tue, 19 Feb 2008 21:50:33 -0800, Ivan Illarionov wrote:

 I would like to see something like %init or init to be converted to
 __init__ behind the scenes.

Unfortunately -- or perhaps fortunately -- % clashes with the already 
established uses of % as the modulus operator for numbers and the 
interpolation operator for strings.

 5 % 3
2
 hello %s % world
'hello world'


The last thing I want is to have to study code carefully to try to work 
out whether %name means __name__ or %name.

Similarly for , the bitwise and operator:

 9  12
8



 And $something to be converted to self.something.

Well, at least $ is unused in Python at the moment. That's a point in the 
idea's favour. It's a tiny point, but a point.


 But, unfortunately, most Python people would consider
 this ugly 

Yes.

 just because Perl uses too much syntactic sugar 

No. It's because Perl uses too much *line noise*, punctuation characters 
instead of syntax.


 and anything
 Perl-like is considered ugly in Python community. So, unless Perl die, I
 believe that Python will remain sugar-free.

Python has lots of syntactic sugar. Some examples:

class Foo is syntactic sugar for a call to the new.classobj() function.

Both def foo(): and lambda : are syntactic sugar for a call to the 
new.function() function.

Double-underscore method names are syntactic sugar.

Decorators are syntactic sugar.

Generator expressions and list comprehensions are syntactic sugar.

Dict, tuple and list literals {a: b} (a, b) [a, b] are syntactic sugar.

Method calls and method definitions are syntactic sugar.

The trinary if operator x if flag else y is syntactic sugar.

Most of these have been part of Python since the earliest days. Some of 
them, like method calls, are so established in Python and other languages 
that it's hard to remember that they could be done another way, without 
syntax support, but of course they could be:

# instance.method(arg)
getattr(instance, 'method')(arg)


Python uses relatively little punctuation. That's one of the strengths of 
the language, and why its very unlikely that your suggestions will be 
implemented in Python.



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


Re: What's the standard for code docs?

2008-02-20 Thread Paul Boddie
On 20 Feb, 09:32, Paul McGuire [EMAIL PROTECTED] wrote:

 I use epydoc for pyparsing, and I really like the results.  Just make
 sure that importing your modules doesn't really do anything
 substantial (like connect to db's, or run unit tests that run for
 hours); epydoc imports your code and then introspects it to extract
 the classes, methods, docstrings, etc.

Or use the --parse-only option to avoid the introspection.

 (And I think you asked an honest question, and did not deserve the
 rude answers you got.  This NG is normally better behaved.)

Indeed.

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


is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Jorge Vargas
I need a data structure that will let me do:

- attribute access (or index)
- maintain the order (for iter and print)
- be mutable.

in case there isn't one. I was thinking having a base class like Bunch
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 and on
top of that keeping a list of the keys and pop/push to the list when
adding/deleting items. I don't like this idea because I'll have to
keep each key twice. (in the list and in __dict__, is this the only
way of doing it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Jarek Zgoda
Jorge Vargas napisał(a):

 - attribute access (or index)
 - maintain the order (for iter and print)
 - be mutable.

These are all attributes of standard Python lists.

 in case there isn't one. I was thinking having a base class like Bunch
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 and on
 top of that keeping a list of the keys and pop/push to the list when
 adding/deleting items. I don't like this idea because I'll have to
 keep each key twice. (in the list and in __dict__, is this the only
 way of doing it?

What is your objective? From the description of this recipe I cann't get
your use case.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

We read Knuth so you don't have to. (Tim Peters)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: threaded http server

2008-02-20 Thread Steve Holden
bharath venkatesh wrote:
 hi
i want to create fast n efficient http server which serve multiple 
 client  concurrently .. so i thought of threading the http server  using  
 
 class HTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):
   pass:
 
 as this creates an  threaded version of  http server ... but i read in  
 one of   the postings  in mailing list that it will create a deadlock . 
 the following postings can found at 
 http://mail.python.org/pipermail/python-list/2001-January/064088.html
 
 as mentioned in that posting log_request must be redefined...  can any 
 one  tell me how to redefine  it so that it creates a  threading 
 behavior for   fast n efficient http server. or will it be  ok just to 
 pass the definition as done in the posting mentioned above  and still 
 create an efficient threading behavior
 
For fast and efficient, move away from any pofh te SocketServer based 
libraries immediately. Regard them more as proofs of concept, and simple 
models you can tinker with to improve your understanding.

Twisted, TurboGears, Django, Zope - these and other frameworks have 
reasonably efficient ways to serve the web from Python.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Python Memory Manager

2008-02-20 Thread Paul Rubin
[EMAIL PROTECTED] writes:
  Use XMM instead.
 
 Thank you, Paul. I'm pretty sure you meant MMX, Multi-Media eXtensions.

MMX is the obsolete 64 bit predecessor to XMM.  XMM encompasses 128
bit wide MMX-like integer instructions and several generations of SSE
floating point ops.  Main thing about it is that it's 128 bits wide
and has instructions to get cache prefetches started now if you'll
need them later.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Jorge Vargas
2008/2/20 Jarek Zgoda [EMAIL PROTECTED]:
 Jorge Vargas napisał(a):

  - attribute access (or index)
  - maintain the order (for iter and print)
  - be mutable.

 These are all attributes of standard Python lists.
probably I confused you with the or index part. I want to be able to
do item.value1 or item['value1'] the list can't do this.

  in case there isn't one. I was thinking having a base class like Bunch
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 and on
  top of that keeping a list of the keys and pop/push to the list when
  adding/deleting items. I don't like this idea because I'll have to
  keep each key twice. (in the list and in __dict__, is this the only
  way of doing it?

 What is your objective? From the description of this recipe I cann't get
 your use case.

I got an xml object which feed me in data. in a simple format
item
propety1foo/propety1
value1bar/value1
propety2baz/propety2
value2bal/value2
/item

I want to turn this into a datastructure I can manipulate in my
program for example.

 print myItem.property1

 if myItem.property1[value1]  0:
   print 'ok'

 print myItem
{'property1':'value1','property2,'value2'}

 --
 Jarek Zgoda
 Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

 We read Knuth so you don't have to. (Tim Peters)
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread bearophileHUGS
subeen:
 I think you should go for 'dictionary' that is a built-in data
 structure of Python.

The OP asks this too:
 maintain the order (for iter and print)

So I think an ordered dict is fitter, the op can search for an odict
implementation, in the cookbook too (I too have written one, but it's
useful only if you have to delete keys often, because it's O(1) for
that operation too, but generally slow if you don't need to delete
keys too).

Bye,
bearophile
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread subeen
I think you should go for 'dictionary' that is a built-in data
structure of Python.


regards,
Subeen
http://love-python.blogspot.com/


On Feb 20, 7:32 pm, Jorge Vargas [EMAIL PROTECTED] wrote:
 2008/2/20 Jarek Zgoda [EMAIL PROTECTED]: Jorge Vargas napisa³(a):

   - attribute access (or index)
   - maintain the order (for iter and print)
   - be mutable.

  These are all attributes of standard Python lists.

 probably I confused you with the or index part. I want to be able to
 do item.value1 or item['value1'] the list can't do this.

   in case there isn't one. I was thinking having a base class like Bunch
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308and on
   top of that keeping a list of the keys and pop/push to the list when
   adding/deleting items. I don't like this idea because I'll have to
   keep each key twice. (in the list and in __dict__, is this the only
   way of doing it?

  What is your objective? From the description of this recipe I cann't get
  your use case.

 I got an xml object which feed me in data. in a simple format
 item
 propety1foo/propety1
 value1bar/value1
 propety2baz/propety2
 value2bal/value2
 /item

 I want to turn this into a datastructure I can manipulate in my
 program for example.

  print myItem.property1
  if myItem.property1[value1]  0:

print 'ok'

  print myItem

 {'property1':'value1','property2,'value2'}





  --
  Jarek Zgoda
  Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

  We read Knuth so you don't have to. (Tim Peters)
  --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Jorge Vargas
dict doesn't maintains order.

 a=[(3,2),(2,2)]
 dict(a).items()
[(2, 2), (3, 2)]
 a=[(3,2),(2,2)]
 assert dict(a).items()==a
Traceback (most recent call last):
  File stdin, line 1, in module
AssertionError
 dict(a).items()
[(2, 2), (3, 2)]


On Feb 20, 2008 7:50 AM, subeen [EMAIL PROTECTED] wrote:
 I think you should go for 'dictionary' that is a built-in data
 structure of Python.


 regards,
 Subeen
 http://love-python.blogspot.com/


 On Feb 20, 7:32 pm, Jorge Vargas [EMAIL PROTECTED] wrote:
  2008/2/20 Jarek Zgoda [EMAIL PROTECTED]: Jorge Vargas napisa³(a):
 
- attribute access (or index)
- maintain the order (for iter and print)
- be mutable.
 
   These are all attributes of standard Python lists.
 
  probably I confused you with the or index part. I want to be able to
  do item.value1 or item['value1'] the list can't do this.
 
in case there isn't one. I was thinking having a base class like Bunch
   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308and on
top of that keeping a list of the keys and pop/push to the list when
adding/deleting items. I don't like this idea because I'll have to
keep each key twice. (in the list and in __dict__, is this the only
way of doing it?
 
   What is your objective? From the description of this recipe I cann't get
   your use case.
 
  I got an xml object which feed me in data. in a simple format
  item
  propety1foo/propety1
  value1bar/value1
  propety2baz/propety2
  value2bal/value2
  /item
 
  I want to turn this into a datastructure I can manipulate in my
  program for example.
 
   print myItem.property1
   if myItem.property1[value1]  0:
 
 print 'ok'
 
   print myItem
 
  {'property1':'value1','property2,'value2'}
 
 
 
 
 
   --
   Jarek Zgoda
   Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

 
   We read Knuth so you don't have to. (Tim Peters)
   --
  http://mail.python.org/mailman/listinfo/python-list

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

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


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Larry Bates
Jorge Vargas wrote:
 I need a data structure that will let me do:
 
 - attribute access (or index)
 - maintain the order (for iter and print)
 - be mutable.
 
 in case there isn't one. I was thinking having a base class like Bunch
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 and on
 top of that keeping a list of the keys and pop/push to the list when
 adding/deleting items. I don't like this idea because I'll have to
 keep each key twice. (in the list and in __dict__, is this the only
 way of doing it?

Sounds like a good time to learn ElementTree (included in Python 2.5 but 
available for earlier versions).

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


Re: Python seems to be ignoring my except clause...

2008-02-20 Thread Larry Bates
Adam W. wrote:
 I am trying to handle a Unicode error but its acting like the except
 clause is not even there.  Here is the offending code:
 
 def characters(self, string):
 if self.initem:
 try:
 self.data.append(string.encode())
 except:
 self.data.append('No habla la Unicode')
 
 And the exception:
 
   File C:\Users\Adam\Desktop\XMLWorkspace.py, line 65, in characters
 try:
 UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in
 position 83: ordinal not in range(128)
 
 Its got to be something really dumb I'm missing, this make no sence.

Seems that others have addressed you specific problem so I wanted to take this 
opportunity to save you from hours of frustration in the future (trust me on 
this one).  It is almost NEVER a good idea to use a blank except: clause in 
your 
code.  The problem is that it catches ALL exceptions, not just the one you are 
trying to catch.  It is much better to determine the exception you are trying 
to 
catch here.

Example:

try:
 self.data.append(string.encode())
except UnicodeEncodeError:
 self.data.append('No habla la Unicode')


You can spend a lot of time trying to figure out what is going on when your 
blank except catches all the exceptions.  This lets the other exceptions do 
what 
they should do.

Hope this helps.

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


Re: threaded http server

2008-02-20 Thread Christian Heimes
bharath venkatesh wrote:
 hi
i want to create fast n efficient http server which serve multiple
 client  concurrently .. so i thought of threading the http server  using

Threads ain't efficient for IO bound problems like a HTTP server. Most
OSs have far better ways to deal with IO bound applications like
select(), poll(), epoll(), kqueue() or IOCP.

Use Twisted :)

Christian

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


Re: Article of interest: Python pros/cons for the enterprise

2008-02-20 Thread Tim Chase
 You Used Python to Write WHAT?
 http://www.cio.com/article/185350


Furthermore, the power and expressivity that Python offers means 
that it may require more skilled developers.
[...down to the summary...]
Python may not be an appropriate choice if you:
[...]
*  Rely on teams of less-experienced programmers. These 
developers may benefit from the wider availability of training 
for languages like Java and are less likely to make mistakes with 
a compile-time, type-checked language.


Oh noes!  You might need competent programmers that actually 
understand what they're doing!

(they might even have to write testing code to make sure their 
code works as intended...it's a good thing that Python includes 
unittest and doctest modules in the stock install)

Sigh.  Any programmer that can overcome the hurdles of learning 
Java or C# can quickly/easily pick up Python as long as they're 
willing to unlearn some bad habits.

-tkc


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


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Duncan Booth
Jorge Vargas [EMAIL PROTECTED] wrote:

  I was thinking having a base class like Bunch
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 and on
 top of that keeping a list of the keys and pop/push to the list when
 adding/deleting items. I don't like this idea because I'll have to
 keep each key twice

You do realise I hope that just because the key appears in both a 
dictionary and a list doesn't mean you have two copies of the key? If the 
same object is used in a dictionary and a list then all you have is an 
extra reference to the same object.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Automating GUI interaction with Python

2008-02-20 Thread jay graves
On Feb 20, 5:37 am, Ryan Ginstrom [EMAIL PROTECTED] wrote:
  On Behalf Of jorma kala
  Is there a python library or bindings to a library in some
  other language for automating GUI interaction (the kind of
  functionality provided by Autoit for instance).
  What I need to do is very simple GUI automation : moving the
  mouse cursor to and from specified screen coordinates, clicking, etc.
  Thanks a lot.

 For Windows, try pyWinAutohttp://pywinauto.openqa.org/

dogtail is another
http://people.redhat.com/zcerza/dogtail/

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


Re: The big shots

2008-02-20 Thread Grant Edwards
On 2008-02-20, Marco Mariani [EMAIL PROTECTED] wrote:
 Sergio Correia wrote:

 I don't get this thread. At all. I want my 15 minutes back.

 I think it's a sort of Turing test,

You're probably right, and I think I failed the test.

-- 
Grant Edwards   grante Yow! Am I in GRADUATE
  at   SCHOOL yet?
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


smtplib gnupg

2008-02-20 Thread Brot
Hello,

at the moment my program sends mail with smtplib. Is there a chance to
sign and/or encode/cipher this mails with GnuPG?
If yes, does anyone have some sample code?

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


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread jay graves
On Feb 20, 7:32 am, Jorge Vargas [EMAIL PROTECTED] wrote:
  What is your objective? From the description of this recipe I cann't get
  your use case.

 I got an xml object which feed me in data. in a simple format
 item
 propety1foo/propety1
 value1bar/value1
 propety2baz/propety2
 value2bal/value2
 /item

If it is XML why not use ElementTree or some other XML DOM library?

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


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread Jorge Vargas
On Feb 20, 2008 8:15 AM, Larry Bates [EMAIL PROTECTED] wrote:
 Jorge Vargas wrote:
  I need a data structure that will let me do:
 
  - attribute access (or index)
  - maintain the order (for iter and print)
  - be mutable.
 
  in case there isn't one. I was thinking having a base class like Bunch
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 and on
  top of that keeping a list of the keys and pop/push to the list when
  adding/deleting items. I don't like this idea because I'll have to
  keep each key twice. (in the list and in __dict__, is this the only
  way of doing it?

 Sounds like a good time to learn ElementTree (included in Python 2.5 but
 available for earlier versions).
I am using ET, to fetch the data from the XML, after that I want a
plain python object. for the rest of the program.


 -Larry

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

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


Re: Why must implementing Python be hard unlike Scheme?

2008-02-20 Thread Jason
On Feb 19, 11:22 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 On Feb 19, 9:49 pm, Kay Schluehr [EMAIL PROTECTED] wrote:

  Building a
  Python VM in a high level language is certainly not harder than
  creating a Scheme interpreter.

 Does VM = interpreter?
 Are you saying implementing a toy Python interpreter is not any harder
 than implementing a toy Scheme interpreter?

 I don't understand why you think that.
 The Python grammar is much more complicated.  Python ASTs are much
 more complicated.  Parsing Python files with the whitespace is harder.
 Please prove me wrong.  I hope you are right.

 Chris

If you create a byte-code interpreter, you don't need to worry about
the AST or whitespace.  Python code compiles down into a byte-code
that runs on a simple virtual machine.  Values are put in a stack,
then popped off the stack to perform operations.  Jython compiles
Python into the Java byte-code machine, while IronPython
generates .NET / CLR byte codes.

The dis module allows you to disassemble the byte-code instructions,
at least for CPython.  Take a look at http://docs.python.org/lib/
module-dis.html.  (There's a link at the bottom to a page that
describes what the byte-codes in CPython are.)

You also don't have to jump directly to doing everything yourself.
Python has modules that will already lex (module tokenize) and parse
(module parser) the language, so you can use of the modules to focus
on implementing the other module.

Python is somewhat more difficult to parse because it isn't a
functional language.  While functional languages are easier to
implement, they aren't as easy for the beginner or average programmer
to use.  I know how to work within the MFC and wxWidget/wxPython
frameworks, but darned if I know how Scheme could be used to implement
a COM object.

Take a look at Shalabh Chaturvedi's Python Types and Objects [1].
This describes how Python's type and object objects work.  Since this
is the top of Python's new-style classes, getting this right is
imperative.

I hope this gives you some idea on how to proceed.  Python's grammar
really isn't that difficult.  Python uses a LL parser [2], while many
languages uses LALR parsers [3].  The parts of the BNF are described
in detail in Python's Python Reference Manual [4].

I hope that the resources help.

  --Jason

[1] Python Types and Objects:
http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html
[2] LL Parsers: http://en.wikipedia.org/wiki/LL_parser
[3] LALR Parsers: http://en.wikipedia.org/wiki/LALR_parser
[4] Python Reference Manual: http://docs.python.org/ref/ref.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Handling locked db tables...

2008-02-20 Thread breal
I have a db table that holds a list of ports.  There is a column
in_use that is used as a flag for whether the port is currently in
use.  When choosing a port the table is read and the first available
port with in_use = 0 is used, updated to in_use = 1, used, then
updated to in_use = 0.  I am using MySQLdb and want to make sure I am
locking the table when doing reads, writes, updates since there will
be several instances of my program looking for available ports
simultaneously.

When I run a lock table mytable read I can do all of my
transactions.  But, when another cursor then tries to do the read I
get an error unless the first process has been completed... unlocking
the tables.  How is this handled generally?

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


Re: smtplib gnupg

2008-02-20 Thread Shane Geiger
To the best of my knowledge, GNUPG acts upon the body of the message. 
If you think about it you should realize that the header of the message
cannot be encrypted, as it will be handled by mail servers that have no
knowledge of GNUPG or your encryption keys.  I am further emboldened to
make this assertion because the encryption takes place before the
message is sent--that is, before the headers are completely formed.



Brot wrote:
 Hello,

 at the moment my program sends mail with smtplib. Is there a chance to
 sign and/or encode/cipher this mails with GnuPG?
 If yes, does anyone have some sample code?

 Regards
   Bernd
   


-- 
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

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


Re: Handling locked db tables...

2008-02-20 Thread M.-A. Lemburg
On 2008-02-20 16:24, breal wrote:
 I have a db table that holds a list of ports.  There is a column
 in_use that is used as a flag for whether the port is currently in
 use.  When choosing a port the table is read and the first available
 port with in_use = 0 is used, updated to in_use = 1, used, then
 updated to in_use = 0.  I am using MySQLdb and want to make sure I am
 locking the table when doing reads, writes, updates since there will
 be several instances of my program looking for available ports
 simultaneously.
 
 When I run a lock table mytable read I can do all of my
 transactions.  But, when another cursor then tries to do the read I
 get an error unless the first process has been completed... unlocking
 the tables.  How is this handled generally?

This is normal database locking behavior. If you do an update to
a table from one process, the updated row is locked until the
transaction is committed.

If another process wants to access that row (even if only indirectly,
e.g. a select that does a query which includes the data from the locked
row), that process reports a database lock or times out until the
lock is removed by the first process.

The reason is simple: you don't want the second process to report
wrong data, since there's still a chance the first process might
roll back the transaction.

Most modern database allow row-level locking. I'm not sure whether
MySQL supports this. SQLite, for example, only support table locking.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Feb 20 2008)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The big shots

2008-02-20 Thread Preston Landers
On Feb 19, 7:19 pm, [EMAIL PROTECTED] wrote:

 If not, how about these:

 - It doesn't match the rest of the language
 - It's too cutting edge
 - It is too hard to handle
 - It would get out of hand really quickly
 - I can't control you anymore after I let it in
 - The functionality already exists per se
 - It is to the rest of the language as wires #3, #4, and #5 are to RCA
 cables
 - HTML 4.01 is not an improvement over HTML 4.0

 ?

 If still not, how about these:

 - It hurts my feelings
 - It foils my revenge
 - I'd rather you toil meanially
 - Tedious is good
 - You shouldn't have power
 - But I'm greedy
 - We can't afford it

 ?

I think your tin foil hat may screwed on a wee bit tight.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's the standard for code docs?

2008-02-20 Thread Preston Landers
On Feb 20, 2:32 am, Paul McGuire [EMAIL PROTECTED] wrote:

 I use epydoc for pyparsing, and I really like the results.  Just make
 sure that importing your modules doesn't really do anything
 substantial (like connect to db's, or run unit tests that run for
 hours); epydoc imports your code and then introspects it to extract
 the classes, methods, docstrings, etc.

OK thanks for the advice.  We already have a policy of not doing
anything heavyweight on module import so in introspection wouldn't
be a problem.

 (And I think you asked an honest question, and did not deserve the
 rude answers you got.  This NG is normally better behaved.)

Yeah I've been lurking a long time.  I've noticed a strange uptick in
weirdness lately. No clue why though.



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


Re: Python Memory Manager

2008-02-20 Thread Ross Ridge
[EMAIL PROTECTED] wrote:
20 MBs = 5 M 32-bit words = 1.25 millis to move half of them on a
2GHz machine. Don't know how much a milli costs where you live.

A 2GHz machine doesn't have 20Mb of 2GHz memory.  You made the mistake
of measuring the speed of processor's cache, rather than the RAM.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: threaded http server

2008-02-20 Thread bharath venkatesh
hi,
will this twisted,turbo gear etc help me to create a http server that can
serve multiple clients concurrently
and also the http server which i want to create in my project will not be
doing any IO (it is not like frontend  and backend ).. but it will act as a
image_proxy_server i.e when a client wants an image  it will do a http
request to my  http server if the image is present in cache it will fetch it
directly from cache  and return  it  to the  client as an http reponse
otherwise  it  fetch from  www  and  store  it cache and also return it to
the client as an http response so basically i want to serve many clients
concurrently in fast n efficient manner

On Feb 20, 2008 5:51 AM, Christian Heimes [EMAIL PROTECTED] wrote:

 bharath venkatesh wrote:
  hi
 i want to create fast n efficient http server which serve multiple
  client  concurrently .. so i thought of threading the http server  using

 Threads ain't efficient for IO bound problems like a HTTP server. Most
 OSs have far better ways to deal with IO bound applications like
 select(), poll(), epoll(), kqueue() or IOCP.

 Use Twisted :)

 Christian

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

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

Re: psycopg2: connect copy_from and copy_to

2008-02-20 Thread Thomas Guettler
[EMAIL PROTECTED] schrieb:
 On Feb 19, 8:06 am, Thomas Guettler [EMAIL PROTECTED] wrote:
 Any suggestions?
 
 If you don't mind trying out some beta quality software, you can try
 my pg_proboscis driver. It has a DBAPI2 interface, but for you to use
 COPY, you'll need to use the GreenTrunk interface:
 

Up to now I am happy with psycopg2. Why do you develop pg_proboscis?

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


PEP: Adding Priority Scheduling feature to the subprocess

2008-02-20 Thread [EMAIL PROTECTED]
I am working on a PEP and would appreciate comment.  The proposal is
available at

http://python.timehorse.com/PEP_-_Application_Priority.reST

and is repeated below:

-

:PEP: Unassigned
:Title: Adding Priority Scheduling feature to the subprocess module
:Version: $Rev: 93 $
:Last Modified: $Date: 2008-02-20 08:37:00 -0500 (Wed, 20 Feb 2008) $
:Author: Jeffrey C. Jacobs
:Discussions-To: python at timehorse dot com
:Status: Draft
:Type: Standards Track
:Content-Type: text/x-rst
:Created: 19-Feb-2008
:Python-Version: 2.5.1
:Post-History: None

--

Introduction


The ``subprocess`` module is intended to create a platform-independent
method of *spawning* or *popening* or *execing* an OS-level sub-
process.  This module provides the ability to spawn processes on a
variety of platforms by creating an instance of the
``subprocess.Popen`` class.

Currently, only the Windows version of the ``Popen.__init__`` method
can set the OS priority of a spawned process directly using the
``createFlags`` parameter.  Clients operating under UNIX must use some
version of the ``preexec_fn`` to either wrap a C-call to the
``setpriority`` POSIX function or do so by prepending ``nice u`` to
the ``args`` or in the ``executable``, which would only work for sub-
processes spawned from a shell.  Under a Windows environment, however,
the ``preexec_fn`` parameter is ignored and there is no ``nice`` shell
program.  This thus precludes the easy setting of a spawned process's
priority in the UNIX environment, as well as creates a disconnect in
terms of the way priorities are set between Windows and UNIX
platforms, which somewhat defeats the purpose of ``subprocess.py`` in
terms of being relatively platform-independent.

In addition to these issues, because Windows processes are referenced
by handles, not by process IDs, although this would divide the UNIX-
specific and Windows specific code, the Handle for the windows would
none the less be useful in the ``win32process`` module and therefore
it is proposed that this handle be officially exposed from the
``Popen`` instance via the name ``handle``.  Currently, this property
is unofficially accessible via the name ``_handle``, so this proposes
to rename that value and make the name official for python running
under Windows.  The value of ``handle`` for other platforms would then
be ``None``.  In addition to officially exposing the Handle to
Process, it is proposed that the Main Thread Handle, also internally
exposed within the ``Popen.__init__`` process, be externally exposed
via the name ``hthread`` for use by ``win32process`` and the priority
methods.

Because UNIX uses priorities between +20 and -20 and Windows, via
Process and Thread priorities, allows settings between 0 and 31, a
uniform setting for each system should be derived.  This would be
accomplished by giving process priority in terms of a floating-point
value between 0.0 and 1.0 for lowest and highest possible priority,
respectively.  This priority would be added to the ``Popen``
constructor as an optional parameter, with a default value of
``None``.  If and only if something other than ``None`` is set, that
value would override any setting in ``createFlags``, and the Process
Priority flags of ``createFlags`` would be masked off under the
Windows environment.  In all cases a non-``None`` setting would cause
the spawned process to run at the indicated priority converted to the
platform-specific units.

The Macintosh OS X / BSD subsystem should be compatible with the UNIX-
specific sections of this proposal.

Specifics
~

The following steps would accomplish this proposal:

1) Add a C-Python wrapper for the POSIX ``getpriority`` /
``setpriority`` methods to the ``os`` module.  These methods would
only be available in a UNIX environment and would mesh well with the
existing file/process functions specified therein.  The
``win32process`` module already exposes the corresponding Windows
methods.

2) Officially expose the Process Handle as ``handle`` and the
Process's Main Thread Handle as ``hThread`` within the ``Popen``
instance interface.

3) Add ``setPriority`` / ``getPriority`` methods to the ``Popen``
class which will use the platform-specific priority function either
from ``os`` for UNIX or ``win32process`` for Windows. The input
priority to ``setPriority`` will be checked and raise a ``ValueError``
exception for values not in the range 0.0 to 1.0.

   The 0.0 to 1.0 scale will be converted to the 32-point Windows
scale by linear mapping, e.g. for a floating-point priority *p*, the
Windows priority is given by:

   ``int(p*31 + .5)``

   Windows is limited to a non-linear, 7-point scale for process
priorities, with thread priorities making up the difference relative
to the 32-point internal priority scale.  Thus, the Windows versions
of these functions will use a combination of ``SetPriorityClass`` and
``SetThreadPriority`` in order to set the requested process priority,
using the ``handle`` 

Re: Handling locked db tables...

2008-02-20 Thread breal
On Feb 20, 8:05 am, M.-A. Lemburg [EMAIL PROTECTED] wrote:
 On 2008-02-20 16:24, breal wrote:

  I have a db table that holds a list of ports.  There is a column
  in_use that is used as a flag for whether the port is currently in
  use.  When choosing a port the table is read and the first available
  port with in_use = 0 is used, updated to in_use = 1, used, then
  updated to in_use = 0.  I am using MySQLdb and want to make sure I am
  locking the table when doing reads, writes, updates since there will
  be several instances of my program looking for available ports
  simultaneously.

  When I run a lock table mytable read I can do all of my
  transactions.  But, when another cursor then tries to do the read I
  get an error unless the first process has been completed... unlocking
  the tables.  How is this handled generally?

 This is normal database locking behavior. If you do an update to
 a table from one process, the updated row is locked until the
 transaction is committed.

 If another process wants to access that row (even if only indirectly,
 e.g. a select that does a query which includes the data from the locked
 row), that process reports a database lock or times out until the
 lock is removed by the first process.

 The reason is simple: you don't want the second process to report
 wrong data, since there's still a chance the first process might
 roll back the transaction.

 Most modern database allow row-level locking. I'm not sure whether
 MySQL supports this. SQLite, for example, only support table locking.

 --
 Marc-Andre Lemburg
 eGenix.com

 Professional Python Services directly from the Source  (#1, Feb 20 2008) 
 Python/Zope Consulting and Support ...http://www.egenix.com/
  mxODBC.Zope.Database.Adapter ...http://zope.egenix.com/
  mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

 

  Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 

eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611

Marc-Andre,

Thanks for the reply.  I understand that this is normal locking
behavior.  What I am looking for is a standard method to either loop
the query until the table is unlocked, or put the query into some sort
of queue.  Basically my queries work like this.

Request comes in

PART I:
LOCK TABLE port_usage READ;
SELECT * FROM port_usage WHERE in_use = 0;
Get available port
UPDATE port_usage SET in_use = 1 WHERE port = available_port;
UNLOCK TABLES;

send request to available port and do some stuff until finished with
port

PART II:
LOCK TABLE port_usage READ
UPDATE port_usage SET in_use = 0 WHERE port = available_port;
UNLOCK TABLES;

Several of these *may* be happening simultaneously so when a second
request comes in, and the first one has the table locked, I want to
have the PART I sql still work.  Any suggestions here?

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


Re: threaded http server

2008-02-20 Thread bharath venkatesh
oh .. thanks for  explaining   since this is my first ever project i
don't know much ... can u give me a basic idea of how it(image_proxy_server)
can be done efficiently .. like serving many clients concurrently

On Feb 20, 2008 9:01 AM, Christian Heimes [EMAIL PROTECTED] wrote:

 bharath venkatesh wrote:
  hi,
  will this twisted,turbo gear etc help me to create a http server that
 can
  serve multiple clients concurrently
  and also the http server which i want to create in my project will not
 be
  doing any IO (it is not like frontend  and backend ).. but it will act
 as a
  image_proxy_server i.e when a client wants an image  it will do a http
  request to my  http server if the image is present in cache it will
 fetch it
  directly from cache  and return  it  to the  client as an http reponse
  otherwise  it  fetch from  www  and  store  it cache and also return it
 to
  the client as an http response so basically i want to serve many clients
  concurrently in fast n efficient manner

 You are reading data from a network socket (IO), you are serving images
 from a disk cache or memory cache (IO) or you are retrieving images from
 a remote site (IO).

 Your application is most certainly not using the CPU much. All you do is
 serving data or reading data - input and output - IO. :)

 Christian


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

Re: threaded http server

2008-02-20 Thread Christian Heimes
bharath venkatesh wrote:
 hi,
 will this twisted,turbo gear etc help me to create a http server that can
 serve multiple clients concurrently
 and also the http server which i want to create in my project will not be
 doing any IO (it is not like frontend  and backend ).. but it will act as a
 image_proxy_server i.e when a client wants an image  it will do a http
 request to my  http server if the image is present in cache it will fetch it
 directly from cache  and return  it  to the  client as an http reponse
 otherwise  it  fetch from  www  and  store  it cache and also return it to
 the client as an http response so basically i want to serve many clients
 concurrently in fast n efficient manner

You are reading data from a network socket (IO), you are serving images
from a disk cache or memory cache (IO) or you are retrieving images from
a remote site (IO).

Your application is most certainly not using the CPU much. All you do is
serving data or reading data - input and output - IO. :)

Christian

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


Re: Handling locked db tables...

2008-02-20 Thread Larry Bates
breal wrote:
 On Feb 20, 8:05 am, M.-A. Lemburg [EMAIL PROTECTED] wrote:
 On 2008-02-20 16:24, breal wrote:

 I have a db table that holds a list of ports.  There is a column
 in_use that is used as a flag for whether the port is currently in
 use.  When choosing a port the table is read and the first available
 port with in_use = 0 is used, updated to in_use = 1, used, then
 updated to in_use = 0.  I am using MySQLdb and want to make sure I am
 locking the table when doing reads, writes, updates since there will
 be several instances of my program looking for available ports
 simultaneously.
 When I run a lock table mytable read I can do all of my
 transactions.  But, when another cursor then tries to do the read I
 get an error unless the first process has been completed... unlocking
 the tables.  How is this handled generally?
 This is normal database locking behavior. If you do an update to
 a table from one process, the updated row is locked until the
 transaction is committed.

 If another process wants to access that row (even if only indirectly,
 e.g. a select that does a query which includes the data from the locked
 row), that process reports a database lock or times out until the
 lock is removed by the first process.

 The reason is simple: you don't want the second process to report
 wrong data, since there's still a chance the first process might
 roll back the transaction.

 Most modern database allow row-level locking. I'm not sure whether
 MySQL supports this. SQLite, for example, only support table locking.

 --
 Marc-Andre Lemburg
 eGenix.com

 Professional Python Services directly from the Source  (#1, Feb 20 2008) 
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ...http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/
 

  Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 

eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
 
 Marc-Andre,
 
 Thanks for the reply.  I understand that this is normal locking
 behavior.  What I am looking for is a standard method to either loop
 the query until the table is unlocked, or put the query into some sort
 of queue.  Basically my queries work like this.
 
 Request comes in
 
 PART I:
 LOCK TABLE port_usage READ;
 SELECT * FROM port_usage WHERE in_use = 0;
 Get available port
 UPDATE port_usage SET in_use = 1 WHERE port = available_port;
 UNLOCK TABLES;
 
 send request to available port and do some stuff until finished with
 port
 
 PART II:
 LOCK TABLE port_usage READ
 UPDATE port_usage SET in_use = 0 WHERE port = available_port;
 UNLOCK TABLES;
 
 Several of these *may* be happening simultaneously so when a second
 request comes in, and the first one has the table locked, I want to
 have the PART I sql still work.  Any suggestions here?
 

I think you want to use SELECT for UPDATE or SELECT LOCK IN SHARE MODE.

Here is a link that might help:

http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html

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


Re: The big shots

2008-02-20 Thread Wildemar Wildenburger
Dotan Cohen wrote:
  French and Spanish have impersonal pronouns: on and se,
  respectively.  In English, they often come out as, we, they, and
  you a lot, on occasion a one, and sometimes, even, I.
 
 In Hebrew, we have 8 different words for you. That does not affect
 my English communications, however.
 
Also, let's not forget that the English language has one as an 
impersonal pronoun.

/W
(BTW: Don't feed the bot. ;) )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread thebjorn
On Feb 20, 3:32 pm, Jorge Vargas [EMAIL PROTECTED] wrote:
 On Feb 20, 2008 8:15 AM, Larry Bates [EMAIL PROTECTED] wrote:

  Jorge Vargas wrote:
   I need a data structure that will let me do:

   - attribute access (or index)
   - maintain the order (for iter and print)
   - be mutable.

[...]

  Sounds like a good time to learn ElementTree (included in Python 2.5 but
  available for earlier versions).

 I am using ET, to fetch the data from the XML, after that I want a
 plain python object. for the rest of the program.

Ok, you just lost me... Why do you thin ET is not appropriate (*)?  It
fits all your requirements, is optimized for representing hierarchical
data (especially xml), it is fast, it is well tested, it has a
community of users, it is included in the standard library, etc., etc.

...maybe I didn't grok what you meant by plain python object?

-- bjorn

(*) I just had a flashback to the movie ET -- the scene when he's in
the closet ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


class object using widget

2008-02-20 Thread asit
from Tkinter import *  # get widget classes
from tkMessageBox import askokcancel   # get canned std dialog

class Quitter(Frame):  # subclass our GUI
def __init__(self, parent=None):   # constructor method
Frame.__init__(self, parent)
self.pack()
widget = Button(self, text='Quit', command=self.quit)
widget.pack(side=LEFT)
def quit(self):
ans = askokcancel('Verify exit', Really quit?)
if ans: Frame.quit(self)

if __name__ == '__main__':  Quitter().mainloop()

In the above program, why the error comes ??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to finish a while loop...

2008-02-20 Thread Martin Blume
richie schrieb
   That code works. Maybe you fixed it while 
   you were mailing it =)
 
  This is weird mate.
  I'm using eclipse 3.2 with the pydev plugin.  
  There it loops forever - from the eclipse console.
  Two hours of trying, changing the code...finally gave up.
 
  Then I got your reply.  Opened up a regular console 
  and executed it from there.
  And voilait works! Well, after this I'm going 
  back to the old trusty shell.
 
  Thanks again mate.
 
 I try it too in my eclipse3.2. I got the same result.
 It seems very strange.

Print out answer and see if there is a difference ...

my $0.02
Martin


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


packing things back to regular expression

2008-02-20 Thread Amit Gupta
Hi

I wonder if python has a function to pack things back into regexp,
that has group names.

e.g:
exp = (?Pname1[a-z]+)
compiledexp = re.compile(exp)

Now, I have a dictionary mytable = {a : myname}

Is there a way in re module, or elsewhere, where I can have it match
the contents from dictionary to the re-expression (and check that it
matches the rules) and than return the substituted string?

e.g
 re.SomeNewFunc(compilexp, mytable)
myname
 mytable = {a : 1}
 re.SomeNewFunc(compileexp, mytable)
ERROR



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


Re: The big shots

2008-02-20 Thread Kay Schluehr
On 19 Feb., 04:14, [EMAIL PROTECTED] wrote:

 The printing press, rail, automobiles, and Python, were not in
 prevalent use before their invention.

True but automobiles fuelled with newspapers and driven by Pythons
still aren't. Right?

Not entirely sure what you are after but it sounds much like the quite
familiar Guido-doesn't-give-Python-newbies-enough-freedom-to-change-
the-language father complex.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: packing things back to regular expression

2008-02-20 Thread Gary Herron
Amit Gupta wrote:
 Hi

 I wonder if python has a function to pack things back into regexp,
 that has group names.

 e.g:
 exp = (?Pname1[a-z]+)
 compiledexp = re.compile(exp)

 Now, I have a dictionary mytable = {a : myname}

 Is there a way in re module, or elsewhere, where I can have it match
 the contents from dictionary to the re-expression (and check that it
 matches the rules) and than return the substituted string?
   
I'm not following what you're asking for until I get to the last two 
words.  The re module does have functions to do string substitution.  
One or more occurrences  of a pattern matched by an re can be replaces 
with a given string.  See sub and subn.  Perhaps you can make one of 
those do whatever it is you are trying to do.

Gary Herron

 e.g
   
 re.SomeNewFunc(compilexp, mytable)
   
 myname
   
 mytable = {a : 1}
 re.SomeNewFunc(compileexp, mytable)
   
 ERROR



 Thanks
 A
   

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


Re: Why must implementing Python be hard unlike Scheme?

2008-02-20 Thread Eduardo O. Padoan
On Feb 19, 2008 3:15 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Does this have to be true?  Beneath the more complex syntax are there
 a few core design principles/objects/relationships to help in grokking
 the whole thing? Got any related links?

Take a look at a simpler implementation, like tinypy:
http://www.philhassey.com/blog/2008/02/19/tinypy-64k-nearing-10-and-it-really-does-fit-in-64k/

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


correlation between seemingly independent instances of same class

2008-02-20 Thread nikipore
Hello,

the results of the following code boggle me. i would have expected
that y.data is not affected by setting z.data.

Regards Jan


--code-
class Test:
  def __init__(self, x={}):
self.data = x
  #end def
#end class Test

y = Test()
z = Test()

print 'y.data = ',y.data
print 'z.data = ',z.data

z.data['B'] = 2   # this statement also sets y.data
z.data= {'A': 1}  # this statement doesn't

print 'y.data = ',y.data
print 'z.data = ',z.data
--code end---

--output---
C:\Program Files\Python25\pythonw -u thestrangething.py
y.data =  {}
z.data =  {}
y.data =  {'B': 2}
z.data =  {'A': 1}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: packing things back to regular expression

2008-02-20 Thread Amit Gupta
Before I read the message: I screwed up.

Let me write again

 x = re.compile(CL(?Pname1[a-z]+))
# group name name1 is attached to the match of lowercase string of
alphabet
# Now I have a dictionary saying {name1, iamgood}
# I would like a function, that takes x and my dictionary and return
CLiamgood
# If my dictionary instead have {name1, 123}, it gives error on
processingit
#
# In general, I have reg-expression where every non-trivial match has
a group-name. I want to do the reverse of reg-exp match. The function
can take reg-exp and replace the group-matches from dictionary
# I hope, this make it clear.

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


scanf in python?

2008-02-20 Thread Bob and Deb
Hello python-list,

This is my first post and yes I am a python newbie :-)

I've been trying to figure out how to convert an old database dump into a
form that can be imported into Postgresql.  The file (dealing with one
table) looks something like this:

create table table1 (id int, name char(20), agw_map char(14), agw real)
id 1 11 name 13 32 agw 34 47
619536_00195 26.728
618836_00188 31.905
621736_00223 19.644
607836_00024 38.055
607936_00025 37.678
608036_00027 40.03
608136_00028 38.884
608236_00030 43.616
608336_00032 46.548
608436_00033 48.593
608536_00036 53.764
** End of Table **

In C I could build a format string (using info from the table create
statement and the column position in the header) and use scanf to parse this
file.  What does the Python solution looks like?

Thanks in advance.

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

Re: packing things back to regular expression

2008-02-20 Thread Tim Chase
 mytable = {a : myname}
 re.SomeNewFunc(compilexp, mytable)
 myname

how does SomeNewFunc know to pull a as opposed to any other key?

 mytable = {a : 1}
 re.SomeNewFunc(compileexp, mytable)
 ERROR

You could do something like one of the following 3 functions:

   import re
   ERROR = 'ERROR'
   def some_new_func(table, regex):
 Return processed results for values matching regex
 result = {}
 for k,v in table.iteritems():
   m = regex.match(v)
   if m:
 result[k] = m.group(1)
   else:
 result[k] = ERROR
 return result

   def some_new_func2(table, regex, key):
 Get value (if matches regex) or ERROR based on key
 m = regex.match(table[key])
 if m: return m.group(0)
 return ERROR

   def some_new_func3(table, regex):
 Sniff the desired key from the regexp (inefficient)
 for k,v in table.iteritems():
   m = regex.match(v)
   if m:
 groupname, match = m.groupdict().iteritems().next()
 if groupname == k:
   return match
 return ERROR

   if __name__ == __main__:
 NAME = 'name1'
 mytable = {
   'a': 'myname',
   'b': '1',
   NAME: 'foo',
   }
 regexp = '(?P%s[a-z]+)' % NAME
 print 'Using regex:'
 print regexp
 print '='*10

 r = re.compile(regexp)
 results = some_new_func(mytable, r)
 print 'a: ', results['a']
 print 'b: ', results['b']
 print '='*10
 print 'a: ', some_new_func2(mytable, r, 'a')
 print 'b: ', some_new_func2(mytable, r, 'b')
 print '='*10
 print '%s: %s' % (NAME, some_new_func3(mytable, r))

Function#2 is the optimal solution, for single hits, whereas 
Function#1 is best if you plan to repeatedly extract keys from 
one set of processed results (the function only gets called 
once).  Function#3 is just ugly, and generally indicates that you 
need to change your tactic ;)

-tkc



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


unitests don't run under pdb

2008-02-20 Thread Amit Gupta
Hi

I have a unitest file: If I do

python testname.py : the unitests runs as usual and I get the
following results:
--
Ran 2 tests in 0.024s

OK


However, if I do python -m pdb testnames.py: I get
ython -m pdb testnames.py
 /s/nd6/amit/pyiglu/testnames.py(1)module()
- import unittest
(Pdb) c

--
Ran 0 tests in 0.000s

OK
---



Anything else, I should be doing (python version 2.5.1)


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


Re: how to finish a while loop...

2008-02-20 Thread Jeff Schwab
icarus wrote:

 Opened up a regular console and executed it
 from there.
 And voilait works! Well, after this I'm going back to the old
 trusty shell.

+1 QOTW
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is this data structure build-in or I'll have to write my own class?

2008-02-20 Thread mkPyVS
On Feb 20, 12:07 pm, thebjorn [EMAIL PROTECTED]
wrote:
 On Feb 20, 3:32 pm, Jorge Vargas [EMAIL PROTECTED] wrote:



  On Feb 20, 2008 8:15 AM, Larry Bates [EMAIL PROTECTED] wrote:

   Jorge Vargas wrote:
I need a data structure that will let me do:

- attribute access (or index)
- maintain the order (for iter and print)
- be mutable.

 [...]

   Sounds like a good time to learn ElementTree (included in Python 2.5 but
   available for earlier versions).

  I am using ET, to fetch the data from the XML, after that I want a
  plain python object. for the rest of the program.

 Ok, you just lost me... Why do you thin ET is not appropriate (*)?  It
 fits all your requirements, is optimized for representing hierarchical
 data (especially xml), it is fast, it is well tested, it has a
 community of users, it is included in the standard library, etc., etc.

 ...maybe I didn't grok what you meant by plain python object?

 -- bjorn

 (*) I just had a flashback to the movie ET -- the scene when he's in
 the closet ;-)

This isn't so optimal but I think accomplishes what you desire to some
extent... I *think* there is some hidden gem in inheriting from dict
or an mapping type that is cleaner than what I've shown below though.

class dum_struct:
   def __init__(self,keyList,valList):
  self.__orderedKeys = keyList
  self.__orderedValList = valList
   def __getattr__(self,name):
  return self.__orderedValList[self.__orderedKeys.index(name)]


keys = ['foo','baz']
vals = ['bar','bal']

m = dum_struct(keys,vals)

print m.foo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: class object using widget

2008-02-20 Thread Jeff Schwab
asit wrote:
 from Tkinter import *  # get widget classes
 from tkMessageBox import askokcancel   # get canned std dialog
 
 class Quitter(Frame):  # subclass our GUI
 def __init__(self, parent=None):   # constructor method
 Frame.__init__(self, parent)
 self.pack()
 widget = Button(self, text='Quit', command=self.quit)
 widget.pack(side=LEFT)
 def quit(self):
 ans = askokcancel('Verify exit', Really quit?)
 if ans: Frame.quit(self)
 
 if __name__ == '__main__':  Quitter().mainloop()
 
 In the above program, why the error comes ??

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


Re: Querying a complex website

2008-02-20 Thread schweet1
On Feb 19, 4:04 pm, 7stud [EMAIL PROTECTED] wrote:
 schweet1 wrote:
  Greetings,

  I am attempting to use python to submit a query to the following URL:

 https://ramps.uspto.gov/eram/patentMaintFees.do

  The page looks simple enough - it requires submitting a number into 2
  form boxes and then selecting from the pull down.

  However, my test scripts have been hung up, apparently due to the
  several buttons on the page having the same name.  Ideally, I would
  have the script use the Get Bibligraphic Data link.

  Any assistance would be appreciated.

  ~Jon

 This is the section you are interested in:

 -
 tr
 td colspan=3input type=submit name=maintFeeAction
 value=Retrieve Fees to Pay /td
 /tr

 tr
 td colspan=3input type=submit name=maintFeeAction value=Get
 Bibliographic Data /td
 /tr

 tr
 td colspan=3input type=submit name=maintFeeAction value=View
 Payment Windows /td
 /tr
 tr
 

 1) When you click on a submit button on a web page, a request is sent
 out for the web page listed in the action attribute of the form tag,
 which in this case is:

 form name=mfInputForm method=post action=/eram/
 getMaintFeesInfo.do;jsessionid=-MCoYNbJsaUCr2VfzZhKILX:11g0uepfb

 The url specified in the action attribute is a relative url.  The
 current url in the address bar of your browser window is:

 https://ramps.uspto.gov/eram/patentMaintFees.do

 and if you compare that to the url in the action attribute of the
 form tag:

 -https://ramps.uspto.gov/eram/patentMaintFees.do

 /eram/getMaintFeesInfo.do;jsessionid=-MCoYNbJsaUCr2VfzZhKILX:
 11g0uepfb
 -

 you can piece them together and get the absolute url:

 https://ramps.uspto.gov/eram/getMaintFeesInfo.do;jsessionid=-MCoY...

 2) When you click on a submit button, a request is sent to that url.
 The request will contain all the information you entered into the form
 as name/value pairs.  The name is whatever is specified in the name
 attribute of a tag and the value is whatever is entered into the form.

 Because the submit buttons in the form have name attributes,  the name
 and value of the particular submit button that you click will be added
 to the request.

 3)  To programmatically mimic what happens in your browser when you
 click on the submit button of a form, you need to send a request
 directly to the url listed in the action attribute of the form.
 Your request will contain the name/value pairs that would have been
 sent to the server if you had actually filled out the form and clicked
 on the 'Get Bibliographic Data' submit button.  The form contains
 these input elements:

 
 input type=text name=patentNum maxlength=7 size=7 value=

 input type=text name=applicationNum maxlength=8 size=8
 value=
 

 and the submit button you want to click on is this one:

 input type=submit name=maintFeeAction value=Get Bibliographic
 Data

 So the name value pairs you need to include in your request are:

 data = {
     'patentNum':'1234567',
     'applicationNum':'08123456',
     'maintFeeAction':'Get Bibliographic Data'

 }

 Therefore, try something like this:

 import urllib

 data = {
     'patentNum':'1234567',
     'applicationNum':'08123456',
     'maintFeeAction':'Get Bibliographic Data'

 }

 enc_data = urllib.urlencode(data)
 url = 'https://ramps.uspto.gov/eram/
 getMaintFeesInfo.do;jsessionid=-MCoYNbJsaUCr2VfzZhKILX:11g0uepfb'

 f = urllib.urlopen(url, enc_data)

 print f.read()
 f.close()

 If that doesn't work, you may need to deal with cookies that the
 server requires in order to keep track of you as you navigate from
 page to page.  In that case, please post a valid patent number and
 application number, so that I can do some further tests.- Hide quoted text -

 - Show quoted text -

Thanks all - I think there are cookie issues - here's an example data
pair to play with: 6,725,879 (10/102,919).  I'll post some of the code
i've tried asap.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL

2008-02-20 Thread Fred Pacquier
Stani [EMAIL PROTECTED] said :

 Even without python-pyexiv2 Phatch features read-only EXIF support
 thanks to PIL. So you can name your files or write data stamps (date,
 aperature, velocity, ...) based on EXIF information. 

Oh, that's good. I hadn't looked at PIL for a long while and wasn't aware 
it did that.

 If you want to
 save EXIF and IPTC information to files you need python-pyexiv2. From
 its website: However, the library and all the tools used are
 cross-platform, so very little tweaking should be needed to get it to
 work fine on Windows or MacOS X. 
 http://tilloy.net/dev/pyexiv2/developers.htm 
 The exiv2 website says:
 The Windows package only contains the command line utility exiv2.exe
 (statically linked), manpage and a sample command file; get the source
 and doc packages for the library, documentation and other tools.
 http://www.exiv2.org/download.html
 So maybe someone can compile it.

Thanks for the confirmation Stani : as I suspected, this means exiv2 is 
(deliberately ?) not end-user-ready for Windows (as in, download, install 
and configure). I have Googled around a bit but there doesn't seem to be 
anyone supplying a ready-made binary lib. Too bad.
 
 But... Phatch is designed with flexibility in mind. If someone can
 point me to a free python library for Windows for EXIF and other
 metadata, I'll be happy to integrate support for it in Phatch. Ideas
 anyone? 

That is exactly the problem. EXIF/IPTC were fashionable in python circles 
some years ago but apart from a long-dead sourceforge project and a 
couple of read-only modules, nothing really came out of it.

In fact, I was coincidentally searching for just such a thing when I came 
across a pointer to Phatch, a few days before you announced it here...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The big shots

2008-02-20 Thread castironpi
On Feb 19, 7:52 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Tue, 19 Feb 2008 23:19:29 -0200, [EMAIL PROTECTED] escribió:

  But 'ext' is actually good.

 Even if it were, that alone doesn't mean it should be included in the  
 stdlib.

 Start writting a recipe in the Python Cookbook:  
 http://aspn.activestate.com/ASPN/Cookbook/Python/
 Upload the module to the Python Package Index:http://pypi.python.org/pypi
 Post a notice in the announcement list.
 Wait for user feedback. Listen. Improve it. Make it so good that everyone  
 would love to have it always available. Commit yourself to maintain the  
 module forever. Suggest inclusion in the stdlib.

 --
 Gabriel Genellina

I don't know what everyone would love to have always available.
I'm baffled that anyone ever pretends to (know).

No, but nobody likes it.
What?

If cl-py is not the right place for personal exchanges, then get
going.

I am seeking a rational, informed, constructive evaluation of the
merits and demerits of 'ext'.

It's also productive to characterize trends of things in the std.
lib., and I could even see that discussion arising from this one.
It's just up to us whether it's in the same thread or not.
-- 
http://mail.python.org/mailman/listinfo/python-list


syntax error in python

2008-02-20 Thread Lalit
Hi
I am executing following commands.
 test = os.path.isfile('c:\\src\\kasjdfl.txt')
 print test
True
working fine but for below statement it is giving syntax
error.

 if (os.path.isfile('c:\\src\\kasjdfl.txt'))
SyntaxError: invalid syntax

any idea what is incorrect in my syntax
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: syntax error in python

2008-02-20 Thread Lalit
On Feb 20, 2:03 pm, Lalit [EMAIL PROTECTED] wrote:
 Hi
 I am executing following commands. test = 
 os.path.isfile('c:\\src\\kasjdfl.txt')
  print test

 True
 working fine but for below statement it is giving syntax
 error.

  if (os.path.isfile('c:\\src\\kasjdfl.txt'))

 SyntaxError: invalid syntax

 any idea what is incorrect in my syntax

oops got the mistake I was nt ending if with :
sorry and thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The big shots

2008-02-20 Thread Chris Mellon
On Tue, Feb 19, 2008 at 5:31 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 
   May I insist?  By the criteria you've mentioned so far, nothing rules
   out 'ext'.  If it's still a bad idea, there's a reason.  What is it?

  You imply that just because something is somehow working and even useful
  for a *some* people (some being maybe only you) that it would be worth
  including in the python standard lib. It is not.

  There are no really formal rules for inclusion, but these are certainly
  rules of thumb that are being considered:

   - is it useful for *a lot of people*

   - will it be mantained and maintainable for ever once it is part of
 the standard distribution

   - does it introduce external dependencies? If yes, this must be *very*
 carful considered.

   - is the design well-thought and mature

   - does it make sense tying the release cycle of python the cycle of the
 new lib


  And insulting the people who do work on python and do a marvellous job
  doing so is certainly *not* helping.



And of course if ext was a good idea, we'd use Weave from scipy
instead, which exists and works.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: allmydata.org Tahoe v0.8 -- a secure, decentralized filesystem

2008-02-20 Thread zooko
ANNOUNCING: Allmydata.org Tahoe version 0.8

We are pleased to announce the release of version 0.8 of allmydata.org
Tahoe.

Allmydata.org Tahoe is a secure, decentralized, fault-tolerant
filesystem.  All of the source code is available under a Free
Software, Open Source licence (or two).

This filesystem is encrypted and distributed over multiple peers in
such a way that it continues to work correctlly even when some of the
peers are unavailable, malfunctioning, or malicious.

This is the successor to Allmydata-Tahoe v0.7, which was released
January 8, 2008 [1].

This release improves performance, diagnostics, and packaging.  This
release of allmydata.org Tahoe will form the basis of the next
consumer backup product from Allmydata, Inc. -- http://allmydata.com .


Since v0.7 we've made the following changes:

  * Add a preliminary Microsoft Windows package (ticket #195).

  * Add a preliminary Macintosh package (ticket #182).

  * Display information about peers (ticket #32).

  * Display information about uploads and downloads (ticket #39).

  * Add unit tests and docs for contrib/fuse (ticket #255).

  * Add a preliminary FUSE interface for Macintosh.

  * Update docs, starting with docs/about.html --
http://allmydata.org/source/tahoe/trunk/docs/about.html .

  * Improve logging, diagnostic tools, statistics, timing measurements
during upload, etc..

  * Add more measurements of performance:
http://allmydata.org/trac/tahoe/wiki/Performance .

  * Add an upload helper, with resumption of incomplete uploads and
short-circuiting of uploads if the file is already present (tickets
#116, #258, #218).

  * Make upload continue even if some servers disappear during the
upload process.

  * Add mtime and ctime timestamps to files (ticket #183).

  * Make introduction more efficient by allowing nodes to act as
clients-only and not publish themselves as servers (ticket #271).

  * Extend the web API to allow programmatic control of mutable files.

  * Fix potential problem that could cause corruption of downloaded
mutable files if a long series of unlikely coincidences and hacked
clients occurred (ticket #312).

  * Make file and directory names use unicode.

  * Use SHA-256d instead of SHA-256 for secure hashes.


WHAT IS IT GOOD FOR?

With Tahoe, you can distribute your filesystem across a set of
computers, such that if some of the computers fail or turn out to be
malicious, the filesystem continues to work from the remaining
computers.  You can also share your files with other users, using a
strongly encrypted, capability-based access control scheme.

This release is targeted at hackers and smart users who are willing to
use a web user interface, a command-line user interface, or a FUSE
interface.  (Or a RESTful API.  Just telnet to localhost and type HTTP
requests to get started.)

Because this software is new, it is not yet recommended for storage of
highly confidential data nor for valuable data which is not otherwise
backed up. However, it works well in practice, it comes with extensive
unit tests [2], and there are no known security flaws which would
compromise confidentiality or data integrity.  (For a current
description of all known security issues and an overview of Tahoe's
security properties, please see the Security web page: [3].)

This release of Tahoe is suitable for the friendnet use case [4] --
it is easy to create a filesystem spread over the computers of you and
your friends so that you can share files and disk space with one
another.


LICENCE

You may use this package under the GNU General Public License, version
2 or, at your option, any later version.  See the file COPYING.GPL
for the terms of the GNU General Public License, version 2.

You may use this package under the Transitive Grace Period Public
Licence, version 1.0.  The Transitive Grace Period Public Licence says
that you may distribute proprietary derived works of Tahoe without
releasing the source code of that derived work for up to twelve
months, after which time you are obligated to release the source code
of the derived work under the Transitive Grace Period Public Licence.
See the file COPYING.TGPPL.html for the terms of the Transitive
Grace Period Public Licence, version 1.0.

(You may choose to use this package under the terms of either licence,
at your option.)


INSTALLATION

Tahoe works on Linux, Mac OS X, Windows, Cygwin, and Solaris.  For
installation instructions please see docs/install.html [5].


HACKING AND COMMUNITY

Please join us on the mailing list [6] to discuss uses of Tahoe.
Patches that extend and improve Tahoe are gratefully accepted -- the
RoadMap page [7] shows the next improvements that we plan to make and
CREDITS [8] lists the names of people who've contributed to the
project.  The wiki Dev page [9] contains resources for hackers.


SPONSORSHIP

Tahoe is sponsored by Allmydata, Inc. [10], a provider of consumer
backup services.  Allmydata, Inc. contributes hardware, 

Re: threaded http server

2008-02-20 Thread Steve Holden
bharath venkatesh wrote:
 hi,
 will this twisted,turbo gear etc help me to create a http server that 
 can serve multiple clients concurrently

Yes. Google for the projects and do some reading, they are all serving 
large web sites with sometimes havy demand.

 and also the http server which i want to create in my project will not 
 be doing any IO (it is not like frontend  and backend ).. but it will 
 act as a image_proxy_server i.e when a client wants an image  it will do 
 a http request to my  http server if the image is present in cache it 
 will fetch it directly from cache  and return  it  to the  client as an 
 http reponse otherwise  it  fetch from  www  and  store  it cache and 
 also return it to the client as an http response so basically i want to 
 serve many clients concurrently in fast n efficient manner
 
Sorry: reading from and writing to the network *is* I/O (the data is 
outside the proess, isn't it?).

This might be OK as a learning exercise, but if you just need this in 
production as quickly as possible I would imagine some combination of 
Squid and Apache would meet your needs very nicely.

 On Feb 20, 2008 5:51 AM, Christian Heimes [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:
 
 bharath venkatesh wrote:
   hi
  i want to create fast n efficient http server which serve multiple
   client  concurrently .. so i thought of threading the http server
  using
 
 Threads ain't efficient for IO bound problems like a HTTP server. Most
 OSs have far better ways to deal with IO bound applications like
 select(), poll(), epoll(), kqueue() or IOCP.
 
 Use Twisted :)
 
regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


  1   2   >