Movado Portico Watches Collection - Best Movado
Movado Portico Watches Collection - Best Movado Watches Collection : http://www.watches-collection.com/ Movado Watches Collection : http://movado.watches-collection.com/ Movado Portico Watches Collection : http://movado.watches-collection.com/movado-portico-watches.html Movado Portico Watches All Hot Luxury Wristwatch Collection : Movado Portico Mens Watch 0604568 Collection : http://movado.watches-collection.com/Movado-Portico-Mens-Watch-0604568.html Movado Portico Two Tone Mens Watch 0604573 Collection : http://movado.watches-collection.com/Movado-Portico-Two-Tone-Mens-Watch-0604573.html Movado Portico Womens Watch 0604698 Collection : http://movado.watches-collection.com/Movado-Portico-Womens-Watch-0604698.html Movado Portico Two Tone Ladies Watch 0604574 Collection : http://movado.watches-collection.com/Movado-Portico-Two-Tone-Ladies-Watch-0604574.html Movado Portico Ladies Watch 0604569 Collection : http://movado.watches-collection.com/Movado-Portico-Ladies-Watch-0604569.html Other Movado Series Collection : Movado Allia Watches Collection : http://movado.watches-collection.com/movado-allia-watches.html Movado Amorosa Watches Collection : http://movado.watches-collection.com/movado-amorosa-watches.html Movado Artiko Watches Collection : http://movado.watches-collection.com/movado-artiko-watches.html Movado Bareleto Watches Collection : http://movado.watches-collection.com/movado-bareleto-watches.html Movado Celestina Watches Collection : http://movado.watches-collection.com/movado-celestina-watches.html Movado Certa Watches Collection : http://movado.watches-collection.com/movado-certa-watches.html Movado Classic Watches Collection : http://movado.watches-collection.com/movado-classic-watches.html Movado Concerto Watches Collection : http://movado.watches-collection.com/movado-concerto-watches.html Movado Dolca Watches Collection : http://movado.watches-collection.com/movado-dolca-watches.html Movado Eliro Watches Collection : http://movado.watches-collection.com/movado-eliro-watches.html Movado Elliptica Watches Collection : http://movado.watches-collection.com/movado-elliptica-watches.html Movado Esperanza Watches Collection : http://movado.watches-collection.com/movado-esperanza-watches.html Movado Exclusive Watches Collection : http://movado.watches-collection.com/movado-exclusive-watches.html Movado Faceto Watches Collection : http://movado.watches-collection.com/movado-faceto-watches.html Movado Fiero Watches Collection : http://movado.watches-collection.com/movado-fiero-watches.html Movado Folio Watches Collection : http://movado.watches-collection.com/movado-folio-watches.html Movado Gentry Watches Collection : http://movado.watches-collection.com/movado-gentry-watches.html Movado Harmony Watches Collection : http://movado.watches-collection.com/movado-harmony-watches.html Movado Horwitt Watches Collection : http://movado.watches-collection.com/movado-horwitt-watches.html Movado Junior Sport Watches Collection : http://movado.watches-collection.com/movado-junior-sport-watches.html Movado Juro Watches Collection : http://movado.watches-collection.com/movado-juro-watches.html Movado Kara Watches Collection : http://movado.watches-collection.com/movado-kara-watches.html Movado Kardelo Watches Collection : http://movado.watches-collection.com/movado-kardelo-watches.html Movado La Nouvelle Watches Collection : http://movado.watches-collection.com/movado-la-nouvelle-watches.html Movado Luno Watches Collection : http://movado.watches-collection.com/movado-luno-watches.html Movado Medalist Watches Collection : http://movado.watches-collection.com/movado-medalist-watches.html Movado Meza Watches Collection : http://movado.watches-collection.com/movado-meza-watches.html Movado Military Watches Collection : http://movado.watches-collection.com/movado-military-watches.html Movado Moderno Watches Collection : http://movado.watches-collection.com/movado-moderno-watches.html Movado Monto Watches Collection : http://movado.watches-collection.com/movado-monto-watches.html Movado Museum Watches Collection : http://movado.watches-collection.com/movado-museum-watches.html Movado Olympian Watches Collection : http://movado.watches-collection.com/movado-olympian-watches.html Movado Ono Watches Collection : http://movado.watches-collection.com/movado-ono-watches.html Movado Ono Due Watches Collection : http://movado.watches-collection.com/movado-ono-due-watches.html Movado Portico Watches Collection : http://movado.watches-collection.com/movado-portico-watches.html Movado Revi Watches Collection : http://movado.watches-collection.com/movado-revi-watches.html Movado Rondiro Watches Collection : http://movado.watches-collection.com/movado-rondiro-watches.html Movado Safiro Watches Collection : http://movado.watches-collection.com/movado-safiro-watches.html Movado Sapphire Watches Collect
Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 Collection
Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 Collection Watches Collection Site : http://www.watches-collection.com/ Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 View Full : http://girard-perregaux.watches-collection.com/Girard-Perragaux-Sport-Classique-Stainless-Steel-Mens-Watch-499201114144.html Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 AdditionalInfo : Brand : Girard Perregaux ( http://girard-perregaux.watches-collection.com/ ) Gender : Mens Code : GP-49920.1.11.4144 Also Called : $ Movement : Bezel : Case Material : Case Diameter : Dial Color : Crystal : Clasp : Water Resistant : Availability: Contact Us For AvailabilityNeed Assistance? Call us at 866-581-JOMAGirard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144Stainless Steel Case. Stainless Steel Bracelet. Blue Dial. Unidirectional Rotating Bezel. Scratch Resistant Sapphire Crystal. Hidden Deployment Clasp. Date Displays Between 1 and 2 O'clock Positions. Power Reserve Indicator. Case Diameter 40mm. Case Thickness 13.35mm. Automatic Movement. Water Resistant At 300 meters (1000 feet). Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 is brand new, join thousands of satisfied customers and buy your Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 with total satisfaction . A Weholesale-watches.org 30 Day Money Back Guarantee is included with every Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144 for secure, risk-free online shopping. Weholesale- watches.org does not charge sales tax for the Girard Perragaux Sport Classique Stainless Steel Mens Watch 49920.1.11.4144, unless shipped within New York State. Weholesale-watches.org is rated 5 stars on the Yahoo! network. The Girard Perregaux Watches Collection Series : Girard Perregaux Ferrari Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-ferrari-watches.html Girard Perregaux Classic Elegance Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-classic-elegance-watches.html Girard Perregaux Richeville Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-richeville-watches.html Girard Perregaux Collection Lady Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-collection-lady-watches.html Girard Perregaux Vintage 1945 Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-vintage-1945-watches.html Girard Perregaux Sport Classique Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-sport-classique-watches.html Girard Perregaux Cat's Eye Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-cats-eye-watches.html Girard Perregaux Seahawk II Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-seahawk-ii-watches.html Girard Perregaux Laureato EVO3 Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-laureato-evo3-watches.html Girard Perregaux Worldwide Time Control Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-worldwide-time-control-watches.html Girard Perregaux Foudrayante Watches Collection : http://girard-perregaux.watches-collection.com/girard-perregaux-foudrayante-watches.html -- http://mail.python.org/mailman/listinfo/python-list
Invicta Lupah Grand Watches Collection - Best Invicta
Invicta Lupah Grand Watches Collection - Best Invicta Watches Collection : http://www.watches-collection.com/ Invicta Watches Collection : http://invicta.watches-collection.com/ Invicta Lupah Grand Watches Collection : http://invicta.watches-collection.com/invicta-lupah-grand-watches.html Invicta Lupah Grand Watches All Hot Luxury Wristwatch Collection : Invicta Lupah Grand Watch 2234 Collection : http://invicta.watches-collection.com/Invicta-Lupah-Grand-Watch-2234.html Invicta Lupah Grand Watch 2235 Collection : http://invicta.watches-collection.com/Invicta-Lupah-Grand-Watch-2235.html Invicta Lupah Grand Watch 2238 Collection : http://invicta.watches-collection.com/Invicta-Lupah-Grand-Watch-2238.html Invicta Lupah Grand Watch 2237 Collection : http://invicta.watches-collection.com/Invicta-Lupah-Grand-Watch-2237.html Invicta Lupah Grand Watch 2233 Collection : http://invicta.watches-collection.com/Invicta-Lupah-Grand-Watch-2233.html Invicta Lupah Grand Watch 2232 Collection : http://invicta.watches-collection.com/Invicta-Lupah-Grand-Watch-2232.html Other Invicta Series Collection : Invicta Lupah Watches Collection : http://invicta.watches-collection.com/invicta-lupah-watches.html Invicta Lupah Grand Watches Collection : http://invicta.watches-collection.com/invicta-lupah-grand-watches.html Invicta Lupah Dragon Watches Collection : http://invicta.watches-collection.com/invicta-lupah-dragon-watches.html Invicta Lupah Diver Watches Collection : http://invicta.watches-collection.com/invicta-lupah-diver-watches.html Invicta Lady Lupah Watches Collection : http://invicta.watches-collection.com/invicta-lady-lupah-watches.html Invicta Baby Lupah Watches Collection : http://invicta.watches-collection.com/invicta-baby-lupah-watches.html Invicta Infinity Watches Collection : http://invicta.watches-collection.com/invicta-infinity-watches.html Invicta Diver Watches Collection : http://invicta.watches-collection.com/invicta-diver-watches.html Invicta Pro Diver Watches Collection : http://invicta.watches-collection.com/invicta-pro-diver-watches.html Invicta Time Square Watches Collection : http://invicta.watches-collection.com/invicta-time-square-watches.html Invicta Chronograph Watches Collection : http://invicta.watches-collection.com/invicta-chronograph-watches.html Invicta Abyss Watches Collection : http://invicta.watches-collection.com/invicta-abyss-watches.html Invicta Camelot Watches Collection : http://invicta.watches-collection.com/invicta-camelot-watches.html Invicta Charmed Watches Collection : http://invicta.watches-collection.com/invicta-charmed-watches.html Invicta Elite Watches Collection : http://invicta.watches-collection.com/invicta-elite-watches.html Invicta Speedway Watches Collection : http://invicta.watches-collection.com/invicta-speedway-watches.html Invicta Ocean Ghost Watches Collection : http://invicta.watches-collection.com/invicta-ocean-ghost-watches.html Invicta Transatlantic Watches Collection : http://invicta.watches-collection.com/invicta-transatlantic-watches.html Invicta Ocean Pro Watches Collection : http://invicta.watches-collection.com/invicta-ocean-pro-watches.html Invicta 10 Collection Watches Collection : http://invicta.watches-collection.com/invicta-10-collection-watches.html Invicta Lefty Chronograph Watches Collection : http://invicta.watches-collection.com/invicta-lefty-chronograph-watches.html Invicta Corduva Watches Collection : http://invicta.watches-collection.com/invicta-corduva-watches.html Invicta Vintage Watches Collection : http://invicta.watches-collection.com/invicta-vintage-watches.html Invicta Russian Diver Watches Collection : http://invicta.watches-collection.com/invicta-russian-diver-watches.html Invicta Multi-Function Watches Collection : http://invicta.watches-collection.com/invicta-multi-function-watches.html Invicta Extreme Watches Collection : http://invicta.watches-collection.com/invicta-extreme-watches.html Invicta Signature Watches Collection : http://invicta.watches-collection.com/invicta-signature-watches.html Invicta Caprice Watches Collection : http://invicta.watches-collection.com/invicta-caprice-watches.html Invicta Curlo Melody Watches Collection : http://invicta.watches-collection.com/invicta-curlo-melody-watches.html Invicta Corduba Watches Collection : http://invicta.watches-collection.com/invicta-corduba-watches.html Invicta II Watches Collection : http://invicta.watches-collection.com/invicta-ii-watches.html Invicta Just Added Watches Collection : http://invicta.watches-collection.com/invicta-just-added-watches.html -- http://mail.python.org/mailman/listinfo/python-list
Vacheron Constantin Malte Dual Time Regulator Mens Watch 42005000R9068 Collection
Vacheron Constantin Malte Dual Time Regulator Mens Watch 42005000R9068 Collection Watches Collection Site : http://www.watches-collection.com/ Vacheron Constantin Malte Dual Time Regulator Mens Watch 42005000R9068 View Full : http://vacheron-constantin.watches-collection.com/Vacheron-Constantin-Malte-Dual-Time-Regulator-Mens-Watch-42005000R9068.html Vacheron Constantin Malte Dual Time Regulator Mens Watch 42005000R9068 AdditionalInfo : Brand : Vacheron Constantin ( http://vacheron-constantin.watches-collection.com/ ) Gender : Mens Code : 42005000R9068 Also Called : $ 42005000R9068 Movement :Automatic Chronometer Bezel : Fixed Case Material : 18k Rose Gold Case Diameter : 11.0 mm Dial Color : Silver Crystal : Anti reflective Sapphire Clasp : Leather - Black Water Resistant : 30m / 100ft (suitable for splashing, light rain; unsuitable for swimming or diving) Vacheron traces its history back to 1755 when Jean-Marc Vacheron established his watchmaking firm in Geneva. Francois Constantin joined in 1819 creating Vacheron & Constantin. In 1974, Vacheron & Constantin officially dropped the ampersand from the company name, although its wristwatches had already engraved with the newer title since the 1950s. Among its multitude of watchmaking firsts, Vacheron Constantin invented the winding crown. Today, Vacheron Constantin manufactures superb complications and exquisite wristwatches coveted by even the most discerning collector. The Vacheron Constantin Watches Collection Series : Vacheron Constantin Asymmetrique Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-asymmetrique-watches.html Vacheron Constantin Caree Historique Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-caree-historique-watches.html Vacheron Constantin Chronometre Royal Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-chronometre-royal-watches.html Vacheron Constantin Egerie Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-egerie-watches.html Vacheron Constantin Jubilee 1755 Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-jubilee-1755-watches.html Vacheron Constantin Kalla Lune Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-kalla-lune-watches.html Vacheron Constantin Les Cabinotiers Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-les-cabinotiers-watches.html Vacheron Constantin Malte Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-malte-watches.html Vacheron Constantin Overseas Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-overseas-watches.html Vacheron Constantin Patrimony Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-patrimony-watches.html Vacheron Constantin Perpetual Calendar Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-perpetual-calendar-watches.html Vacheron Constantin Royal Eagle Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-royal-eagle-watches.html Vacheron Constantin Toledo Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-toledo-watches.html Vacheron Constantin Tour de I'lle Watches Collection : http://vacheron-constantin.watches-collection.com/vacheron-constantin-tour-de-ille-watches.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does numpy.array(a[0],b[0]) have this meaning?
just a shot in the dark. second arg to numpy.array is of type see numpy.array.__doc__ -nop On Mon, Nov 3, 2008 at 1:26 AM, Rick Giuly <[EMAIL PROTECTED]> wrote: > Hello All, > > Case 1 > This generates an error, which makes sense because the argument should > be a list of numbers: > numpy.array(10,10) > > Case 2 > This does not generate an error and the result is an array with a > single element: > a = numpy.array([10]) > b = numpy.array([10]) > numpy.array(a[0],b[0]) > > The only different I see here between the numpy.array call in the > cases is that > a[0] is a numpy int32 > 10 is an int > > Why would this minor difference in integer types cause a totally > different result for the two cases - or is something else causing the > difference in results? > > > -rick > > P.S. > I am aware that numpy.array([10,10]) will work, but I'm trying to > understand what is going on syntactically/semantically in the two > cases above. > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
How to build python 32 bit version on 64 bit linux.
Hi Experts, I want to build a 32 bit version of python on 64 bit Linux machine. Could any body tell how can I achieve this.I tried many alternatives but didn't work. Much appreciate your time and help, Thanks in advance, -Pravin Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/-- http://mail.python.org/mailman/listinfo/python-list
Why does numpy.array(a[0],b[0]) have this meaning?
Hello All, Case 1 This generates an error, which makes sense because the argument should be a list of numbers: numpy.array(10,10) Case 2 This does not generate an error and the result is an array with a single element: a = numpy.array([10]) b = numpy.array([10]) numpy.array(a[0],b[0]) The only different I see here between the numpy.array call in the cases is that a[0] is a numpy int32 10 is an int Why would this minor difference in integer types cause a totally different result for the two cases - or is something else causing the difference in results? -rick P.S. I am aware that numpy.array([10,10]) will work, but I'm trying to understand what is going on syntactically/semantically in the two cases above. -- http://mail.python.org/mailman/listinfo/python-list
how to call this dll in python
I have a windows dll1.dll with a export function: int f1(char filename,char **buf,int *bufLen) { int len; //got the length of file anyway,such as 100 len = 100;//len = getLen(filename); *buf = (char*)calloc(100); *bufLen = len; return 0; } then how can I call the f1 function with python. thanks for your response. -- http://mail.python.org/mailman/listinfo/python-list
Re: Responding to web request with python
On Sun, 2 Nov 2008, Tim Roberts wrote: > scott212 <[EMAIL PROTECTED]> wrote: > > > >I'm responding with xml to a web request from google checkout but I > >think I'm in a catch-22. To get my webserver (apache) to respond I > >need a header and then a blank line before my xml begins, or else it > >throws the 500 error. If have the blank line before the xml, the > >service I'm responding to cannot parse it. If it's a response, can I > >still use urllib or something like that? Is that my answer? > > You must be misunderstanding something. The HTTP protocol REQUIRES that > the headers and the content be separated by a blank line. > > Perhaps you should try to use a debug proxy to intercept the exact text of > the response, just to make sure you're sending what you think you are > sending. > -- > Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc. > I agree with Tim, check the output. I had the same issue while serving up GIF images generated on the fly. I was sending two blank lines before the image data since an extra newline was being automatically added by the "print" statement. # Print the header information print "Content-type: image/gif\n\n" The above fails since it sends: "header,newline,newline,newline" with the last newline appended by the print statement. A solution would have been to simple remove one of the my coded newline characters and let the print statement add the second one. However, I switched to "write" statements so I could _see_ the newline characters in my code. import sys # Write out the header information sys.stdout.write("Content-type: image/gif\n\n") The above worked because "write" does not add an automatic newline character to the output. Also, make sure your content-type is correct. The same content would be handled differently by a browser depending on how it is identified. "Content-type: text/html" - Sent through the HTML parser then displayed. "Content-type: text/plain" - Displayed without formatting. What is the application you're communicating with looking for? Hope that helps, Christopher -- http://mail.python.org/mailman/listinfo/python-list
Re: CAD.py
r wrote: On Nov 1, 7:13 pm, infixum <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: r> I am currently looking to create a small CAD program with python. Instead of starting from scratch how about extending PythonCAD instead: http://www.pythoncad.org/ Skip ThanCAD might have a few ideas too. Carl T. Thanks for the replies: I tried pythoncad but all links to source are broken I even contacted devoloper and he gave me a link that also is broken...hmm I also tried thancad, did get it to download but cant run it yet... but anyway thanks again i will keep trying. you can use git to get the source of pythoncad git clone git://repo.or.cz/pythoncad.git -nop -- http://mail.python.org/mailman/listinfo/python-list
Dont miss... Just click...
http://www.sportstips8.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the instance reference of an object
On Sun, 02 Nov 2008 13:23:11 -0800, Aaron Brady wrote: > But, doing so, an object is not the same as a reference to it, and all > Python does is pass and copy references. No, that's what at least one particular implementation of Python does. That's not what Python does. The Python VM doesn't have any concept of "values" or "references" or "values which are actually references in disguise". The Python VM knows about *names in namespaces* and *objects*. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorator for validation - inefficient?
On Sun, 02 Nov 2008 09:33:41 -0800, Bryan wrote: > I'm coming from a .Net background, and yes, one of the reasons I did not > consider raising exceptions was to avoid the overhead of an exception > handler clause, which in .Net land is expensive. Actually catching an exception in Python is expensive, so I wouldn't recommend you use exceptions for message-passing in time-critical code. As I understand it, in your case you actually need to stop for user-input if the user's data fails the validation. If that's the case, an extra few milliseconds to catch an exception isn't going to matter much. > some more thought on this: > > If I were going to be checking for validity during a property setter, I > would probably raise an exception there, because the essence of what a > client was requesting is "set property", and an invalid value precludes > this action from happening. > > However, hoping to make client code cleaner and to avoid setter > functions doing expensive db lookup validations, I do not validate > during the setter, but instead defer it until the client explicitly asks > for the validity of the business object. Presumably if they *don't* explicitly ask, you validate anyway at some point? > So the essence of the client's > request at that point is "what are the invalid values for the object", > and an exception should only be raised if there was something stopping > this request from being served. Invalid business object field values do > not stop the functionality of the invalid() method. > > If I had a validation function that checked the db for a duplicate > primary key, then the invalid() function should raise an exception if > the db could not be contacted. Yes! > A client should be on the lookout for > that type of exception, but to throw a bunch of exceptions back at a > client who simply requested a list of things that need to be fixed seems > heavy. > > We would essentially be using Exceptions as an expected return > value of a function. So a doc string would explain: "Returns None for a > valid object, and Exceptions for an invalid object." > > Should exceptions be an expected "return value" from a function? Am I > still using my .Net brain? Because exceptions are first-class objects just like lists, ints and strings, there is a difference between *returning* an exception and *raising* an exception. E.g.: def build_exception(n): if n < 0: raise ValueError('unexpected negative code') else: exc = TypeError('error code #%d' % n) exc.foo = "More info here" return exc try: obj = build_exception(57) print obj.foo another_obj = build_exception(-1) print "We never get here" except ValueError, e: print "Failed with error message:", e.message Making the exception part of your code's API is perfectly legitimate and I would recommend it. The docstring could say this: "Return None for a valid object, otherwise raises InvalidDataException (subclass of ValueError). You can get a list of errors from the exception's errorlist attribute." Here's a minimal way to generate the exception: class InvalidDataException(ValueError): pass and then in your validation code: def validate(obj): print "Testing many things here" e = InvalidDataException("failed because of %d errors") % 4 e.errorlist = [ "too many questions", "too few answers", "not enough respect", "and your query's hair is too long (damn hippy)"] raise e That's one way. There are others. Have a browse through the standard library or the Python docs and see how other exceptions are used. But now that I have a better picture of your use-case, I'm leaning towards a completely different model. Rather than testing if the business object is valid, and raising an error if it isn't, you test it for errors, returning an empty list if there aren't any. def check_for_errors(obj): errorlist = [] print "Testing many things here" if too_many_questions(): errorlist.append("too many questions") # and any others return errorlist I've used strings as errors, but naturally they could be any object that makes sense for your application. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Docpicture 0.2
André wrote: Docpicture 0.2 has been released. You can download it from http://code.google.com/p/docpicture/ Docpicture's goal is to enable embedding pictures inside Python docstrings using some custom domain specific language (dsl). docpicture includes a plugin architecture enabling users to extend it by adding new dsl parsers. Docpicture behaves as an enhanced help() for Python. It requires a default browser capable of displaying svg images (e.g. Firefox 3) === This version of docpicture can display the following type of images: 1. turtles (!) 2. images downloaded from the web (in any format) 3. Mathematical equations (requires matplotlib) 4. UML sequence diagrams (require a live internet connection) 5. Full matplotlib plots. This is very much a proof-of-concept version. Comments and suggestions are most welcome. Code contributions [for other types of images] even more so. ;-) André Roberge I've looked thru some of the project code. It's good stuff. Thanks -nop -- http://mail.python.org/mailman/listinfo/python-list
Re: Unyeilding a permutation generator
[EMAIL PROTECTED] wrote: > Hello, can someone please help. > > I found the following code at http://code.activestate.com/recipes/252178/ > > def all_perms(str): > if len(str) <=1: > yield str > else: > for perm in all_perms(str[1:]): > for i in range(len(perm)+1): > #nb str[0:1] works in both string and list contexts > yield perm[:i] + str[0:1] + perm[i:] > > which allows me to do things like > > for x in all_permx("ABCD"): > print x > > I believe it is making use of the plain changes / Johnson Trotter > algorithm. > Can someone please confirm? > > Anyway what I want to do is experiment with code similar to this (i.e. > same algorithm and keep the recursion) in other languages, > particularly vbscript and wondered what it would look like if it was > rewritten to NOT use the yield statement - or at least if it was > amended so that it can be easily translated to other languages that > dont have python's yield statement. I think the statement "for perm in > all_perms(str[1:]):" will be hardest to replicate in a recursive > vbscript program for example. > There are various approaches you could use, the simplest of which is to provide a "callback function" as an additional argument to the all_perms function, and call it with the permutation as an argument in place of the yield statement. 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: Restricted Execution of untrusted code
In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote: > "Emanuele D'Arrigo" <[EMAIL PROTECTED]> writes: > > > On Nov 1, 12:44 am, Lawrence D'Oliveiro wrote: > > > I think the most reliable solution is to take advantage of a level > > > in the system that already has to provide protection against > > > malicious code: use a chroot jail. > [â¦] > > > > [sigh] That sound a little overkill for a small application. I guess > > somebody should come up with a sandbox version of python, that can > > be executed, say, with a directory provided as a parameter and all > > the os calls are never made above that level. > > That's exactly what a chroot jail *is*, except you don't need to wait > for a special version of Python. What's more, the kernel is in a much better position to understand how a pathname maps to a location in the physical file system than any application could. Should Python attempt to understand what it means to traverse a symlink? A mount point? -- http://mail.python.org/mailman/listinfo/python-list
Re: Restricted Execution of untrusted code
"Emanuele D'Arrigo" <[EMAIL PROTECTED]> writes: > On Nov 1, 12:44 am, Lawrence D'Oliveiro wrote: > > I think the most reliable solution is to take advantage of a level > > in the system that already has to provide protection against > > malicious code: use a chroot jail. […] > > [sigh] That sound a little overkill for a small application. I guess > somebody should come up with a sandbox version of python, that can > be executed, say, with a directory provided as a parameter and all > the os calls are never made above that level. That's exactly what a chroot jail *is*, except you don't need to wait for a special version of Python. You don't gain anything with the appropach you describe that you wouldn't have by setting up a chroot jail using the existing functionality for that purpose. -- \“You can't have everything; where would you put it?” —Steven | `\Wright | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: storing a string data in access
On Nov 3, 3:47 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi > I have > access.Fields("Time").value=t > I would like t to be a string reprsenting a data. How can I do this? t = "string representing a datum" access.Fields("Time").value = t -- http://mail.python.org/mailman/listinfo/python-list
Re: CAD.py
On Nov 1, 7:13 pm, infixum <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > r> I am currently looking to create a small CAD program with python. > > > Instead of starting from scratch how about extending PythonCAD instead: > > > http://www.pythoncad.org/ > > > Skip > > ThanCAD might have a few ideas too. > Carl T. Thanks for the replies: I tried pythoncad but all links to source are broken I even contacted devoloper and he gave me a link that also is broken...hmm I also tried thancad, did get it to download but cant run it yet... but anyway thanks again i will keep trying. -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
In article <[EMAIL PROTECTED]>, Terrence Brannon <[EMAIL PROTECTED]> wrote: > >The most common way of dynamically producing HTML is via template >engines like genshi, cheetah, makotemplates, etc. > >These engines are 'inline' --- they intersperse programming constructs >with the HTML document itself. > >An opposite approach to this form of dynamic HTML production is called >push-style templating, as coined by Terence Parr: >http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf I'm not sure what you mean because I'm not going to bother reading a PDF, but you might look into Quixote: http://www.mems-exchange.org/software/quixote/ -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ import antigravity -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] Python 3 Symbol Glossary
Terry Reedy wrote: Over the years, people have complained about the difficulty of finding the meaning of symbols used in Python syntax. So ... I wrote a Python 3 Symbol Glossary http://code.google.com/p/xploro/downloads/list There are .txt and .odt versions. Replaced with an updated .html version courtesy of help from Arnaud Delobelle. -- http://mail.python.org/mailman/listinfo/python-list
comptech
Discover history of communications. Fact-filled, fun and totally free. Click below for more details *** www.ambairam.webs.com www.recipesallin1.50webs.com www.busioperatin.50webs.com www.scorecash4all.webs.com *** -- http://mail.python.org/mailman/listinfo/python-list
Re: Restricted Execution of untrusted code
On Nov 1, 12:44 am, Lawrence D'Oliveiro wrote: > I think the most reliable solution is to take advantage of a level in the > system that already has to provide protection against malicious code: use a > chroot jail. Or run a complete virtualized machine with its own OS > installation. Then the code is free to do what it wants, it simply won't > see anything sensitive that it could compromise. [sigh] That sound a little overkill for a small application. I guess somebody should come up with a sandbox version of python, that can be executed, say, with a directory provided as a parameter and all the os calls are never made above that level. Manu -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Use ANSI for Remote Screen Scraping?
After playing with this, it seems the key is to pass objects to the ANSI terminal via the following: import ANSI crt = ANSI.ANSI(25,80) head_output = ["line 1 ABCDEFGHIJKL", "line 2 ABCDEFGHIJKL", "line 3 ABCDEFGHIJKL", "line 4 ABCDEFGHIJKL", "line 5 ABCDEFGHIJKL", "line 6 ABCDEFGHIJKL"] for i in head_output: crt.write(i + "\n") print crt.get_region(2, 6, 5, 10) Output from ANSI terminal region: ['2 ABC', '3 ABC', '4 ABC', '5 ABC'] On Sun, Nov 2, 2008 at 3:30 PM, Henry Chang <[EMAIL PROTECTED]> wrote: > I am taking a step back, and just get something simple working with ANSI. > The following code works (creates the ANSI terminal object, and inserts a > few characters, and scrap the characters back). > > import ANSI > > crt = ANSI.ANSI(25,80) > > crt.insert_abs(2,2,"a") > crt.insert_abs(3,10,"b") > crt.insert_abs(5,5,"z") > > print crt.get_region(1, 1, 5, 10) > > But if I try to print something to the screen, the ANSI terminal doesn't > capture anything. > > import ANSI > import os > > crt = ANSI.ANSI(25,80) > > crt.insert_abs(2,2,"a") > crt.insert_abs(3,10,"b") > crt.insert_abs(5,5,"z") > > head_output = os.system("head -n 10 long_text_file.txt") > print head_output > > print crt.get_region(1, 1, 5, 10) > > How can I get the head output into the ANSI terminal? My example code is > similar to the the usage example from the link below. Yet ANSI is not > scraping the screen. What am I doing wrong? > > > http://coding.derkeiler.com/Archive/Python/comp.lang.python/2005-03/1441.html > > Thanks for any help. > > On Sat, Nov 1, 2008 at 5:03 PM, Henry Chang <[EMAIL PROTECTED]> wrote: > >> Using the below script, I can use pexpect to correctly output the entire >> remote terminal content to screen. >> At this point, I am running into difficulty to scrap the screen, for the >> screen elements that I want. (Say: the screen region from the complete 3rd >> line to the 8th line.) I believe I need to use ANSI module. I tried a few >> things, but have run out of ideas. >> >> Can anyone please help? How can the code below be modified to use ANSI? >> >> Thanks so much for any help. >> >> >> import pexpect >> >> child = pexpect.spawn ('ssh [EMAIL PROTECTED]') >> child.expect ('Password: ') >> >> child.sendline ('dummy_password') >> child.expect ('[513] ') >> >> child.sendline ('w2ktt') # windows 2000 terminal type >> child.expect ('Command:') >> >> child.sendline ('dummy_command') >> child.expect('non-guest room') >> >> # This will output the console to the screen. >> print child.before >> >> child.expect('Command:') >> child.sendline ('logoff') >> >> > -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Use ANSI for Remote Screen Scraping?
I am taking a step back, and just get something simple working with ANSI. The following code works (creates the ANSI terminal object, and inserts a few characters, and scrap the characters back). import ANSI crt = ANSI.ANSI(25,80) crt.insert_abs(2,2,"a") crt.insert_abs(3,10,"b") crt.insert_abs(5,5,"z") print crt.get_region(1, 1, 5, 10) But if I try to print something to the screen, the ANSI terminal doesn't capture anything. import ANSI import os crt = ANSI.ANSI(25,80) crt.insert_abs(2,2,"a") crt.insert_abs(3,10,"b") crt.insert_abs(5,5,"z") head_output = os.system("head -n 10 long_text_file.txt") print head_output print crt.get_region(1, 1, 5, 10) How can I get the head output into the ANSI terminal? My example code is similar to the the usage example from the link below. Yet ANSI is not scraping the screen. What am I doing wrong? http://coding.derkeiler.com/Archive/Python/comp.lang.python/2005-03/1441.html Thanks for any help. On Sat, Nov 1, 2008 at 5:03 PM, Henry Chang <[EMAIL PROTECTED]> wrote: > Using the below script, I can use pexpect to correctly output the entire > remote terminal content to screen. > At this point, I am running into difficulty to scrap the screen, for the > screen elements that I want. (Say: the screen region from the complete 3rd > line to the 8th line.) I believe I need to use ANSI module. I tried a few > things, but have run out of ideas. > > Can anyone please help? How can the code below be modified to use ANSI? > > Thanks so much for any help. > > > import pexpect > > child = pexpect.spawn ('ssh [EMAIL PROTECTED]') > child.expect ('Password: ') > > child.sendline ('dummy_password') > child.expect ('[513] ') > > child.sendline ('w2ktt') # windows 2000 terminal type > child.expect ('Command:') > > child.sendline ('dummy_command') > child.expect('non-guest room') > > # This will output the console to the screen. > print child.before > > child.expect('Command:') > child.sendline ('logoff') > > -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
Hi, first a bit of background: I've been using push-style templating in the form of XMLC before. Actually, I've been a core-developer of BarracudaMVC, a java web-framework that for rendering massively relied on XMLC and has been driving XMLC's development (at least used to). And I liked it. But eventually, Barracuda grew a attribute-defined templating system, similar to what we see in TAL or Genshi or KID. It was still relying on XMLC, but extended the capabilities. And was/is simply much more powerful. Your templating engine you have in your paper has yet another language. So where is the difference? if you are talking about StringTemplate, yes, that is a weakness of its approach. It is another language and it must be learned. Now, the same would be true of Terence Parr's StringTemplate engine. It is small, only 4 commands, but it litters the template with too much if you ask me. TAL's core has also only a few "commands". So not much to learn. If thats to much, development is not for you I fear ;) no, Python is for me. Python handles all external data formats (csv, xml, imap, rdbms) without those formats requiring an embedded language. Dynamically unwinding HTML need be no different. if I am provided a high quality API for processing all those formats, I only need one for XHTML as well... meld3 is pretty good for example. TAL does not have as large a userbase or robust testing as Python does. I only want robust languages with large numbers of users. Language with quality libraries. Not language + mini-language. TAL *is* a library. Just because language constructs are mapped to API-calls does not change that. The same argument about numbers of users and can be made for your preferred approach as well. I like the approach of my own HTML::Seamstress --- object-oriented Perl and knowledge of an object-oriented tree-rewriting library is all you need: http://search.cpan.org/~tbone/HTML-Seamstress-5.0b/lib/HTML/Seamstress.pod#Text_substitution_via_replace_content()_API_call. Still you need to learn. There is no way out. Seamstress only requires learning an *API* --- that is not the same as learning another language and its limitations and idiosyncrasies. That is debatable. I don't know TAL much, but I do know (and use) Genshi and KID, two similar approaches to HTML-creation. They use python-syntax where possible, e.g. Learning the handful of constructs is the same as learning a handful of API calls. The same goes for idiosyncrasies of e.g. inserting sub-templates or dealing with repeating content. just remember: XHTML is a subset of XML and no one ever touches XML directly. There really is no reason for HTML to be handled any differently than XML. That TSSL is a nightmare. It's trying to be a programming language. And again, we already have Perl/Python, so why bother? You can avoid touching HTML by using Python. Mini languages is the correct term. And yes they have their purpose. (Think of SQL for example). yes mini-language. But let's look at SQL. SQL is pure. You dont stick Python in your database and unroll the database with it. You dont stick Python in SQL. And you dont put SQL in your tables. Matter of factly people *do* stick Python into SQL - or PL, or other languanges - by defining triggers and stored procedures. With varying degrees of actually mixing the two languanges. The same goes for embedding SQL into e.g. Java. I don't say I very much like that or consider it a better way than separating things. Yet it does serve as example that other people think different about mixing languages (and language paradigms), most probably rightfully so. the keyword is *orthogonal* --- things may interact, but they should not mix. TAL, KID & Genshi don't mix, the stand for their own. They are languages extending XHTML mostly via clever namespace usage, and don't require you to actually learn much syntax that you don't know already. And there is one big point about using them in favor of push-style templating that hasn't been brought up before (or maybe it has, but somehow slipped me - I seem to only see parts of the discussion in this thread for some wicked reason), which is IMHO of utmost importance: the separation of controller-logic and data representation for e.g. layout purposes, as the MVC-pattern encourages. If writing code for a webapplication, my controller provides data to be rendered in an output-language of my choice. Using templating, I can keep that totally separated from the rendering. I can use the same code for providing (X)HTML or JSON, depending on e.g. the HTTP-header - so my Ajax-calls use the same method. Additionally, getting a grasp of what a piece of template is about is much easier when I use a proper templating language - because I can infer easily and mostly without looking at actual code what the template is expecting of it's data. Even more so, I can give the template to somebody
[ANN] PySmell v0.7, a Python auto-completion library
I'm very proud to announce the release of PySmell v0.7! PySmell is an auto-completion library for Python, meant to be plugged in different editors. It uses static analysis to generate a TAGS file for your code, and uses that to give you suggestions. It's very fast - suggestions are instantaneous and analyzing Django 1.0 takes ~15 seconds. Download from PyPI: http://pypi.python.org/pypi/pysmell/ Issue tracking at Google Code: http://code.google.com/p/pysmell Development at GitHub: http://github.com/orestis/pysmell/tree/master The big news for this release is the support for Emacs and TextMate, on top of the already existing Vim support. This isn't tested as rigorously as I'd like, so please report any issues at Google Code. Thank you, Orestis Markou -- [EMAIL PROTECTED] http://orestis.gr/ -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
Tino Wildenhain wrote: Terrence Brannon wrote: Tino Wildenhain wrote: An opposite approach to this form of dynamic HTML production is called push-style templating, as coined by Terence Parr: Hm. "$attr.title$ $if(attr.active)$ $attr.submenu:menuItem()$ $endif$" This looks ugly to me. It looks ugly to me too. Why not just using well tested TAL, which is also available for a number of languages? well, to me, TAL has to be learned. It is a language. Why is this an issue? Let me answer: I already know Python. I already know the XHTML standard. I do not wish to learn TAL. If you know Python, and can read the API to a high-quality XML processing toolkit, then you are done. TAL introduces another language and I have to learn its conventions and idiosyncrasies. Your templating engine you have in your paper has yet another language. So where is the difference? if you are talking about StringTemplate, yes, that is a weakness of its approach. It is another language and it must be learned. Now, the same would be true of Terence Parr's StringTemplate engine. It is small, only 4 commands, but it litters the template with too much if you ask me. TAL's core has also only a few "commands". So not much to learn. If thats to much, development is not for you I fear ;) no, Python is for me. Python handles all external data formats (csv, xml, imap, rdbms) without those formats requiring an embedded language. Dynamically unwinding HTML need be no different. if I am provided a high quality API for processing all those formats, I only need one for XHTML as well... meld3 is pretty good for example. TAL does not have as large a userbase or robust testing as Python does. I only want robust languages with large numbers of users. Language with quality libraries. Not language + mini-language. I like the approach of my own HTML::Seamstress --- object-oriented Perl and knowledge of an object-oriented tree-rewriting library is all you need: http://search.cpan.org/~tbone/HTML-Seamstress-5.0b/lib/HTML/Seamstress.pod#Text_substitution_via_replace_content()_API_call. Still you need to learn. There is no way out. Seamstress only requires learning an *API* --- that is not the same as learning another language and its limitations and idiosyncrasies. just remember: XHTML is a subset of XML and no one ever touches XML directly. There really is no reason for HTML to be handled any differently than XML. That TSSL is a nightmare. It's trying to be a programming language. And again, we already have Perl/Python, so why bother? You can avoid touching HTML by using Python. Mini languages is the correct term. And yes they have their purpose. (Think of SQL for example). yes mini-language. But let's look at SQL. SQL is pure. You dont stick Python in your database and unroll the database with it. You dont stick Python in SQL. And you dont put SQL in your tables. the keyword is *orthogonal* --- things may interact, but they should not mix. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unyeilding a permutation generator
On Nov 2, 3:34 pm, [EMAIL PROTECTED] wrote: > Hello, can someone please help. > > I found the following code athttp://code.activestate.com/recipes/252178/ > > def all_perms(str): > if len(str) <=1: > yield str > else: > for perm in all_perms(str[1:]): > for i in range(len(perm)+1): > #nb str[0:1] works in both string and list contexts > yield perm[:i] + str[0:1] + perm[i:] > > which allows me to do things like > > for x in all_permx("ABCD"): > print x > > I believe it is making use of the plain changes / Johnson Trotter > algorithm. > Can someone please confirm? > > Anyway what I want to do is experiment with code similar to this (i.e. > same algorithm and keep the recursion) in other languages, > particularly vbscript and wondered what it would look like if it was > rewritten to NOT use the yield statement - or at least if it was > amended so that it can be easily translated to other languages that > dont have python's yield statement. I think the statement "for perm in > all_perms(str[1:]):" will be hardest to replicate in a recursive > vbscript program for example. > > Thanks for any constructive help given. > > Hal I think multi-threading is the "truest" to the original. You might develop a framework to set events when particular generators are to take a turn, place their "yields", per se, in a particular place, set the return event, etc., and reuse it. Of course, starting threads in VBS might be another matter. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unyeilding a permutation generator
[EMAIL PROTECTED] wrote: > Anyway what I want to do is experiment with code similar to this (i.e. > same algorithm and keep the recursion) in other languages, > particularly vbscript and wondered what it would look like if it was > rewritten to NOT use the yield statement An obvious (though memory-inefficient) replacement is to accumulate a list and return the list. Initialize a result variable to an empty list, and instead of yielding elements, append them to the result variable. Then return the result variable at the end of the function. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Unyeilding a permutation generator
[EMAIL PROTECTED] writes: > Anyway what I want to do is experiment with code similar to this (i.e. > same algorithm and keep the recursion) in other languages, > particularly vbscript and wondered what it would look like if it was > rewritten to NOT use the yield statement - Without the yield statement and keeping the same space complexity, you basically have to wrap the enumeration state in a data object that you can enumerate over explicitly. That in turn may mean you have to unwind the recursion into old fashioned stack operations. -- http://mail.python.org/mailman/listinfo/python-list
Unyeilding a permutation generator
Hello, can someone please help. I found the following code at http://code.activestate.com/recipes/252178/ def all_perms(str): if len(str) <=1: yield str else: for perm in all_perms(str[1:]): for i in range(len(perm)+1): #nb str[0:1] works in both string and list contexts yield perm[:i] + str[0:1] + perm[i:] which allows me to do things like for x in all_permx("ABCD"): print x I believe it is making use of the plain changes / Johnson Trotter algorithm. Can someone please confirm? Anyway what I want to do is experiment with code similar to this (i.e. same algorithm and keep the recursion) in other languages, particularly vbscript and wondered what it would look like if it was rewritten to NOT use the yield statement - or at least if it was amended so that it can be easily translated to other languages that dont have python's yield statement. I think the statement "for perm in all_perms(str[1:]):" will be hardest to replicate in a recursive vbscript program for example. Thanks for any constructive help given. Hal -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the instance reference of an object
On Oct 31, 3:23 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 30 Oct 2008 19:55:57 -0700, Aaron Brady wrote: > > On Oct 30, 9:05 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > >> On Fri, 31 Oct 2008 13:58:13 +1300, greg wrote: > >> > Dale Roberts wrote: > > > snip > > >> > If they understand how assignment works in Python, that tells them > >> > all they need to know. > > >> Nonsense. > > > Maybe I missed this part. What does the phrase, "value of variable x" > > mean in Python? Is it the same as what it means in C, Pascal, etc.? > > > In other words, > > x= [ 2, 3, 4 ] > '0x%x'%id( x ) > > '0xb39dd0' > > > What is the value of 'x'? > > a) [ 2, 3, 4 ] > > b) An object with contents [ 2, 3, 4 ] > > c) 0xb39dd0 > > d) None of the above. > > Solution a) is just shorthand for b), because there are (or at least > could be) many such objects [2, 3, 4]. So I'd accept either a) or b) as > reasonable answers. snip I'm actually going to take issue with this... not to beat a dead horse. (a) and (b) are distinct, at least potentially, and Steven did not supply the burden of proof necessary for answering more than one. More specifically, I want a definition of what it means "to copy an object onto the stack". If one wanted to say, "copy a reference to it onto the stack", would one say it, necessarily and always? In other words, can one infer from a fact that one didn't say the latter, that one didn't mean it? People just express themselves and don't always speak with mathematical precision. But, doing so, an object is not the same as a reference to it, and all Python does is pass and copy references. In fact, observing that the equals sign is not a mutating operation, I'd even hold that Python calls by reference. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows DOS box redirection
* Dennis Lee Bieber (Sat, 01 Nov 2008 11:34:32 -0700) > On Sat, 1 Nov 2008 18:50:53 +0100, Thorsten Kampe > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > That article mentions a pipe - and has nothing to do with input or > > output redirection... > > > And what is a pipe, at least on Windows command lines, if not a > linked pair of I/O redirection? First program output redirected to <>, > second program input redirected from <> (where <> represents some > shared data stream which could possibly be implemented by creating a > scratch file in, say %TEMP%\apipe.dat) In the case of redirection you get the input from or output to a file. In the case of a pipe you don't have files involved. Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
On 2 Nov, 15:25, Terrence Brannon <[EMAIL PROTECTED]> wrote: > > I like the approach of my own HTML::Seamstress --- object-oriented Perl > and knowledge of an object-oriented tree-rewriting library is all you need: > http://search.cpan.org/~tbone/HTML-Seamstress-5.0b/lib/HTML/Seamstres The Python equivalent to your list of templating systems can be found here (under "Engines with Annotated Templates"): http://wiki.python.org/moin/Templating I note that your list mentions XMLC which was probably one of the first solutions I encountered employing the approach you describe. One issue typically arises when using such solutions, however: trivial modifications to the output document are convenient, but how do you effectively manage situations where you need to modify or populate large numbers of "slots" in the output document? Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: compare items in list to x
Matt Herzog a écrit : I want a program that loops over a list of numbers (y) and tells me whether each number in the list is less than, greater than or equal to another number (x). In the below code, I can't get python to see that 2 is equal to 2. x = 2 def compare(): for y in ['12', '33', '2']: if x < y: print x, "is less than", y elif x > y: print x, "is greater than", y else: print x, "and", y, "are equal" compare() def compare(x, alist): formats = { -1 : "%d is less than %d", 0 : "%d and %d are equals", 1 : "%d is greater than %d" } print "\n".join(formats[cmp(x, y)] % (x, y) for y in map(int, alist)) compare(2, ['12', '1', '33', '2']) -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorator for validation - inefficient?
Bryan <[EMAIL PROTECTED]> writes: > However, hoping to make client code cleaner and to avoid setter > functions doing expensive db lookup validations, I do not validate > during the setter, but instead defer it until the client explicitly > asks for the validity of the business object. So the essence of the > client's request at that point is "what are the invalid values for the > object", and an exception should only be raised if there was something > stopping this request from being served. Invalid business object > field values do not stop the functionality of the invalid() method. This is perfectly fine IMHO, in fact this is similar to how django does form validation. Each form has a property 'is_valid' and validation is only triggered when form.is_valid is checked. This doesn't raise exceptions but makes the errors available to the form user. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] Python 3 Symbol Glossary
[EMAIL PROTECTED] wrote: Terry> Over the years, people have complained about the difficulty of Terry> finding the meaning of symbols used in Python syntax. So ... I Terry> wrote a Python 3 Symbol Glossary Terry> http://code.google.com/p/xploro/downloads/list Arnaud Delobelle wrote a python script to convert the entries into a nice 4-column table in an html file. I will be adding that, with a couple of corrections, to the downloads page. Why not just add a new section to the current Python Glossary: http://wiki.python.org/moin/PythonGlossary It should be a separate page. Could an html file be loaded into a wiki page? (I looked but did not see anything about file uploading in the help files.) If not, that is your answer. tjr -- http://mail.python.org/mailman/listinfo/python-list
storing a string data in access
Hi I have access.Fields("Time").value=t I would like t to be a string reprsenting a data. How can I do this? -- http://mail.python.org/mailman/listinfo/python-list
Re: compare items in list to x
On Nov 2, 9:54 pm, "Pete Kirkham" <[EMAIL PROTECTED]> wrote: > 2 is not equal to '2' As the error is correctly marked, u have to convert '2' to 2 by using int() function so the write code is x = 2 def compare(): for y in ['12', '33', '2']: y=int(y) #string '2' is converted to int 2 if x < y: print x, "is less than", y elif x > y: print x, "is greater than", y else: print x, "and", y, "are equal" compare() Regards Asit Dhal -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorator for validation - inefficient?
On Nov 1, 6:57 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 01 Nov 2008 17:12:33 -0700, Bryan wrote: > > The list of validation error descriptions is returned instead of raising > > exceptions so clients can show the errors to the user for fixing. > > Raising exceptions seems like an uneeded burden for the client, as there > > is nothing exceptional about bad user input. > > But of course there is. Exceptional doesn't mean rare. In this case, it > just means it's not the "normal" input which is expected. > > > Instead, I want to raise an > > exception if a client actually tries to save an invalid entity back to > > the database. I will have to think on your suggestion a bit more before > > I am sure however. > > As a general rule, every function should return one "kind" of thing. > Notice I don't say "type", because it doesn't matter what the type/class > of the data is, so long as it is conceptually the same sort of result. > > E.g. a function that opens a connection to a database should *only* > return a connection to a data, although the actual type of that > connection may differ depending on the database. It shouldn't return > either a connection or an error code. > > I say that this is a general rule, because you can get away with breaking > it, sometimes. E.g. string.find() returns either an offset or an error > signal of -1. But note that this sometimes leads to bugs where people > forget to check for a result of -1, and end up with code doing something > unexpected. > > You've suggested a usage: > > "The list of validation error descriptions is returned instead of > raising exceptions so clients can show the errors to the user for > fixing." > > But you can do that with an exception as well: > > while True: > try: > validate(arguments) # returns None on success, or raise Failure > break > except Failure, e: > print e.msg > for error in e.errors: > print "You must fix this error: %s" % error > # when we exit the loop, the arguments are validated. > do_something_with(arguments) > > If you're coming from a Java background, you may be concerned that > exceptions are expensive. They aren't. Setting up the try...except block > is very cheap. There's very little overhead to a try block that doesn't > fail. > > -- > Steven I'm coming from a .Net background, and yes, one of the reasons I did not consider raising exceptions was to avoid the overhead of an exception handler clause, which in .Net land is expensive. some more thought on this: If I were going to be checking for validity during a property setter, I would probably raise an exception there, because the essence of what a client was requesting is "set property", and an invalid value precludes this action from happening. However, hoping to make client code cleaner and to avoid setter functions doing expensive db lookup validations, I do not validate during the setter, but instead defer it until the client explicitly asks for the validity of the business object. So the essence of the client's request at that point is "what are the invalid values for the object", and an exception should only be raised if there was something stopping this request from being served. Invalid business object field values do not stop the functionality of the invalid() method. If I had a validation function that checked the db for a duplicate primary key, then the invalid() function should raise an exception if the db could not be contacted. A client should be on the lookout for that type of exception, but to throw a bunch of exceptions back at a client who simply requested a list of things that need to be fixed seems heavy. We would essentially be using Exceptions as an expected return value of a function. So a doc string would explain: "Returns None for a valid object, and Exceptions for an invalid object." Should exceptions be an expected "return value" from a function? Am I still using my .Net brain? Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: compare items in list to x
2 is not equal to '2' -- http://mail.python.org/mailman/listinfo/python-list
compare items in list to x
I want a program that loops over a list of numbers (y) and tells me whether each number in the list is less than, greater than or equal to another number (x). In the below code, I can't get python to see that 2 is equal to 2. x = 2 def compare(): for y in ['12', '33', '2']: if x < y: print x, "is less than", y elif x > y: print x, "is greater than", y else: print x, "and", y, "are equal" compare() -- "'My country, right or wrong,' is a thing that no patriot would think of saying. It is like saying, 'My mother, drunk or sober.'" -- G.K. Chesterton -- http://mail.python.org/mailman/listinfo/python-list
buffer
i am using it postgresql as back-end and HTML as front-end,i want to, display 10-10 records at a time which is there in the database using, python.so what is function for buffer that we can use it in python?i, am able to connect my databse in python,but dont know how to create, buffer in python and how to take records from tables which are there, in the database?can please provide me any kind of function or code for, buffer in python?, i have one more doubt that how to call python script in HTML?, PLEASE REPLY -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
Terrence Brannon wrote: Tino Wildenhain wrote: An opposite approach to this form of dynamic HTML production is called push-style templating, as coined by Terence Parr: Hm. "$attr.title$ $if(attr.active)$ $attr.submenu:menuItem()$ $endif$" This looks ugly to me. It looks ugly to me too. Why not just using well tested TAL, which is also available for a number of languages? well, to me, TAL has to be learned. It is a language. Why is this an issue? Let me answer: I already know Python. I already know the XHTML standard. I do not wish to learn TAL. If you know Python, and can read the API to a high-quality XML processing toolkit, then you are done. TAL introduces another language and I have to learn its conventions and idiosyncrasies. Your templating engine you have in your paper has yet another language. So where is the difference? Now, the same would be true of Terence Parr's StringTemplate engine. It is small, only 4 commands, but it litters the template with too much if you ask me. TAL's core has also only a few "commands". So not much to learn. If thats to much, development is not for you I fear ;) I like the approach of my own HTML::Seamstress --- object-oriented Perl and knowledge of an object-oriented tree-rewriting library is all you need: http://search.cpan.org/~tbone/HTML-Seamstress-5.0b/lib/HTML/Seamstress.pod#Text_substitution_via_replace_content()_API_call. Still you need to learn. There is no way out. http://en.wikipedia.org/wiki/Template_Attribute_Language In contrast there would be something like TSSL, which unfortunately never saw the light of the day yet :-) http://mail.zope.org/pipermail/zpt/2002-May/003304.html (This solution would not even touch the HTML directly) just remember: XHTML is a subset of XML and no one ever touches XML directly. There really is no reason for HTML to be handled any differently than XML. That TSSL is a nightmare. It's trying to be a programming language. And again, we already have Perl/Python, so why bother? You can avoid touching HTML by using Python. Mini languages is the correct term. And yes they have their purpose. (Think of SQL for example). Thank you for writing. I enjoyed the discussion. Yeah :-) Cheers Tino smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
Tino Wildenhain wrote: An opposite approach to this form of dynamic HTML production is called push-style templating, as coined by Terence Parr: Hm. "$attr.title$ $if(attr.active)$ $attr.submenu:menuItem()$ $endif$" This looks ugly to me. It looks ugly to me too. Why not just using well tested TAL, which is also available for a number of languages? well, to me, TAL has to be learned. It is a language. Why is this an issue? Let me answer: I already know Python. I already know the XHTML standard. I do not wish to learn TAL. If you know Python, and can read the API to a high-quality XML processing toolkit, then you are done. TAL introduces another language and I have to learn its conventions and idiosyncrasies. Now, the same would be true of Terence Parr's StringTemplate engine. It is small, only 4 commands, but it litters the template with too much if you ask me. I like the approach of my own HTML::Seamstress --- object-oriented Perl and knowledge of an object-oriented tree-rewriting library is all you need: http://search.cpan.org/~tbone/HTML-Seamstress-5.0b/lib/HTML/Seamstress.pod#Text_substitution_via_replace_content()_API_call. http://en.wikipedia.org/wiki/Template_Attribute_Language In contrast there would be something like TSSL, which unfortunately never saw the light of the day yet :-) http://mail.zope.org/pipermail/zpt/2002-May/003304.html (This solution would not even touch the HTML directly) just remember: XHTML is a subset of XML and no one ever touches XML directly. There really is no reason for HTML to be handled any differently than XML. That TSSL is a nightmare. It's trying to be a programming language. And again, we already have Perl/Python, so why bother? You can avoid touching HTML by using Python. Thank you for writing. I enjoyed the discussion. -- http://mail.python.org/mailman/listinfo/python-list
Re: push-style templating - an xml-like way to process xhtml
Terrence Brannon wrote: Hello, The most common way of dynamically producing HTML is via template engines like genshi, cheetah, makotemplates, etc. These engines are 'inline' --- they intersperse programming constructs with the HTML document itself. An opposite approach to this form of dynamic HTML production is called push-style templating, as coined by Terence Parr: Hm. "$attr.title$ $if(attr.active)$ $attr.submenu:menuItem()$ $endif$" This looks ugly to me. Why not just using well tested TAL, which is also available for a number of languages? http://en.wikipedia.org/wiki/Template_Attribute_Language In contrast there would be something like TSSL, which unfortunately never saw the light of the day yet :-) http://mail.zope.org/pipermail/zpt/2002-May/003304.html (This solution would not even touch the HTML directly) Regards Tino smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast list traversal
Steven D'Aprano: > The only solutions to that are to reduce the amount of > computation in each loop, reduce the number of items, or get a faster > computer. Changing language too is an option :-) Languages like Java, D, C, C++ may help :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Ping monitor - monitor ip in the background?
On Nov 2, 12:47 pm, "ScottZ" <[EMAIL PROTECTED]> wrote: > Andrey - Thank you very much for the example. > Is something missing after the def start(self): or should def run(): not > be there? No, Scott, this is one of the neatest features of Python -- "run" is a nested function. It is visible and usable only in "start" function. -- Best Regards, Andrey Balaguta -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] Python 3 Symbol Glossary
Terry> Over the years, people have complained about the difficulty of Terry> finding the meaning of symbols used in Python syntax. So ... I Terry> wrote a Python 3 Symbol Glossary Terry> http://code.google.com/p/xploro/downloads/list Why not just add a new section to the current Python Glossary: http://wiki.python.org/moin/PythonGlossary Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Executing a hidden/background program
On Nov 2, 3:59 am, "Mike Driscoll" <[EMAIL PROTECTED]> wrote: > You probably want to create a Windows service with Python. There are > various ways to accomplish this. Was considering a Windows service too, however would like to avoid that as non-Admin users may not be able to do that. While I'm not familiar with threading, I'm considering starting a seperate thread and use a function such as os.pexec that hangs until the external daemon .exe exists. -- http://mail.python.org/mailman/listinfo/python-list
RE: Ping monitor - monitor ip in the background?
Andrey - Thank you very much for the example. Is something missing after the def start(self): or should def run(): not be there? I think I understand the idea your showing though and working on adapting it. Again thanks! Jorgen - yes that is very true in regards to the *nix comment. I will change that comment to "for my *nix environment" to be more precise in the future. It was posted as an example of what I'm doing rather than a global ping solution for all. I deploy an alternative set of common tools (ping being one of them) amongst our various platforms so the options in this case isn't an issue for me. A built in ping method would be better was being looked into but wanted to get this part finished first. Thanks Original Message Subject: Re: Ping monitor - monitor ip in the background? From: Jorgen Grahn <[EMAIL PROTECTED]> Date: Sun, November 02, 2008 1:04 am To: python-list@python.org On Sat, 01 Nov 2008 20:26:43 -0700, ScottZ <[EMAIL PROTECTED]> wrote: ... > if os.name == "nt": # Windows > pcmd = "ping -n 1 -w 1000 " > else: # *nix > pcmd = "ping -c1 -W1 " Not really correct. Unfortunately there are many variants of ping for Unix, and they don't take the same flags. In Solaris, for example, -c is not a count, and -W doesn't seem to exist at all. If I recall correctly, you can't even count on Linux installations to have compatible pings. Too bad that you cannot easily implement ping in your program -- it needs extra privileges in order to handle ICMP. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast list traversal
On Sun, 02 Nov 2008 00:25:13 -0700, dineshv wrote: > I want to see if there is an alternative method for fast list traversal. > The code is very simple: > > dict_long_lists = defaultdict(list) > for long_list in dict_long_lists.itervalues() > for element in long_list: > array_a[element] = m + n + p# m,n,p > are variable numbers It might help if you showed some sample data, because your explanation is confusing. You are asking about traversing lists, but your data is in a defaultdict. Why is it in a dict, when you don't seem to be using the key anywhere? Putting that aside, I'm going to make a guess and assume your data looks something like this... dict_long_lists = { 'key1': [0, 1, 2, 3, 4, 5], 'key2': [16, 17, 18, 19], 'key3': [7, 9, 11, 13, 15], 'key4': [6, 8, 10, 12, 14] } Then you do something like this: array_a = [None]*20 Then after running your code, you end up with: array_a == [x0, x1, x2, x3, , x19] where each x is calculated from m + n + p. > The long_list's are read from a defaultdict(list) dictionary and so > don't need initializing. The elements of long_list are integers and > ordered (sorted before placing in dictionary). There are > 20,000 > long_list's each with a variable number of elements (>5,000). The > elements of long_list are immutable (ie. don't change). The above code > is within a def function. > > I've tried set() using defaultdict(set) but the elements are not > ordered. It's not clear what you have tried to do with set(), or why the elements need to be ordered. > What is the fastest way to traverse these long_list's sequentially from > the beginning to the end? Maybe there is another data structure that > can be used instead of a list. I doubt you'll find anything faster than a list. You have > 20,000 lists of > 5,000 items each, which means you have a *minimum* of 100,000,000 items to traverse. If each iteration takes 0.1 millisecond, not an unreasonably slow speed depending on the amount of computation each iteration is, that will take 10,000 seconds or nearly three hours. The only solutions to that are to reduce the amount of computation in each loop, reduce the number of items, or get a faster computer. Have you tried running the profiler to see where the time is actually going? I suggest you write a small set of test data (say, 1000 items), and profile it, then write a longer set of test data (say, 100,000 items), and if it's still not clear where the time is being lost, ask for help. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
push-style templating - an xml-like way to process xhtml
Hello, The most common way of dynamically producing HTML is via template engines like genshi, cheetah, makotemplates, etc. These engines are 'inline' --- they intersperse programming constructs with the HTML document itself. An opposite approach to this form of dynamic HTML production is called push-style templating, as coined by Terence Parr: http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf I keep a list of push-style templating solutions for all languages here: http://www.perlmonks.org/?node_id=674225#python And wanted to update the list of Python ones. Notes: - nagare has updated meld3 so the replace method can replace with entire HTML trees, not just plain text node. the author of meld3 (chrism) seems to be out of touch: he hasnt responded to my last 2 emails - basic xml processors are typically a bit too low level for convenient xhtml processing. for example, lxml and elementtree are both powerful xml processors, but webstring makes them much more useable for xhtml processing - the amara xml toolkit is very attractive. It shows how to climb on top of a low-level XML processing suite (the 4suite tools) and dynamically produce XHTML with Pythonic idioms. But I get the willies when the quickref tutorial is a broken link - http://uche.ogbuji.net/tech/4suite/amara/quickref - if there are any other new solutions in Python for this, I would like to know about them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast list traversal
dineshv: > What is the fastest way to traverse these long_list's sequentially > from the beginning to the end? Maybe there is another data structure > that can be used instead of a list. Psyco can help a lot in that kind of code. >The elements of long_list are immutable (ie. don't change).< A tuple too may be fit then, but probably it doesn't improve the situation. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast list traversal
On Nov 2, 1:00 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 2 Nov 2008 00:25:13 -0700 (PDT), dineshv > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > I want to see if there is an alternative method for fast list > > traversal. The code is very simple: > > > dict_long_lists = defaultdict(list) > > for long_list in dict_long_lists.itervalues() > > for element in long_list: > > array_a[element] = m + n + p # m,n,p > > are variable numbers > > > The long_list's are read from a defaultdict(list) dictionary and so > > don't need initializing. The elements of long_list are integers and > > ordered (sorted before placing in dictionary). There are > 20,000 > > Out of curiosity, what code is used to put the values in? The sample > you give above is creating an empty dictionary rigged, if I understand > the help file, to automatically give an empty list if a non-existent key > is requested. But in your loop, there is no possibility of a > non-existent key being requested -- .itervalues() will only traverse > over real data (ie; keys that DO exist in the dictionary). > > And, if you are sorting a list "before placing in dictionary", why > need the defaultdict()? A plain > > dict[key] = presorted_list_of_integers > > would be sufficient. > > Or do you mean to imply that you are using something like: > > thedefaultdict[key].append(single_value) > thedefaultdict[key].sort() > > EACH time you obtain another value from where-ever? If so, that's going > to be the biggest time sink... > > > What is the fastest way to traverse these long_list's sequentially > > from the beginning to the end? Maybe there is another data structure > > that can be used instead of a list. > > So far as I know, the list IS the fastest structure available for > sequential processing. > -- > Wulfraed Dennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ dict_long_lists is a dictionary of lists and is NOT empty. Thank-you -- http://mail.python.org/mailman/listinfo/python-list
Re: Ping monitor - monitor ip in the background?
On Sat, 01 Nov 2008 20:26:43 -0700, ScottZ <[EMAIL PROTECTED]> wrote: ... > if os.name == "nt": # Windows > pcmd = "ping -n 1 -w 1000 " > else:# *nix > pcmd = "ping -c1 -W1 " Not really correct. Unfortunately there are many variants of ping for Unix, and they don't take the same flags. In Solaris, for example, -c is not a count, and -W doesn't seem to exist at all. If I recall correctly, you can't even count on Linux installations to have compatible pings. Too bad that you cannot easily implement ping in your program -- it needs extra privileges in order to handle ICMP. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list
Re: Ping monitor - monitor ip in the background?
Hi, ScottZ. I I have to write such a thing, I'll wrap the whole thing into some class, say Pinger. It will have "do" method, which will perform one particular pinging action. It'll also have a start/stop mechanism, which will start a thread to continuously pinging a host. To notify environment (say, yours tray icon) about host state change (dead/ alive), it will have callback mechanism (register_callback/ unregister_callback). Here, I've written a simple implementation, maybe this will be helpful. == pinger.py import os import threading import subprocess import re import time class Pinger: def __init__(self, ip = None): self.ip = None self.running = False self.callbacks = list() self.setAddress(ip) def setAddress(self, ip): if self.ip != ip: if self.running: self.stop() self.ip = ip def do(self): if os.name == "nt": # Windows pcmd = "ping -n 1 -w 1000 " else:# *nix pcmd = "ping -c1 -W1 " p = subprocess.Popen(pcmd + self.ip, shell=True, stdout=subprocess.PIPE) # give it time to respond p.wait() a = re.search('(.*)ms', p.stdout.read()) if a: return True else: return False def start(self): def run(): result = False while self.running: next = self.do() if next != result and self.running: [ callback(next) for callback in self.callbacks ] result = next self.ping_thread = threading.Thread(target = run) self.running = True self.ping_thread.start() def stop(self): self.running = False def register_callback(self, callback): if callback not in self.callbacks: self.callbacks.append(callback) def unregister_callback(self, callback): if callback in self.callbacks: self.callbacks.remove(callback) if __name__ == '__main__': p = Pinger('192.168.1.1') def printout(alive): if alive: print 'Host is alive.' else: print 'Host is dead.' p.register_callback(printout) p.start() while True: print "Ding..." time.sleep(1) Note that printout will be called ONLY if host state has changed, not on EVERY ping. -- Best Regards, Andrey Balaguta -- http://mail.python.org/mailman/listinfo/python-list
Fast list traversal
I want to see if there is an alternative method for fast list traversal. The code is very simple: dict_long_lists = defaultdict(list) for long_list in dict_long_lists.itervalues() for element in long_list: array_a[element] = m + n + p# m,n,p are variable numbers The long_list's are read from a defaultdict(list) dictionary and so don't need initializing. The elements of long_list are integers and ordered (sorted before placing in dictionary). There are > 20,000 long_list's each with a variable number of elements (>5,000). The elements of long_list are immutable (ie. don't change). The above code is within a def function. I've tried set() using defaultdict(set) but the elements are not ordered. What is the fastest way to traverse these long_list's sequentially from the beginning to the end? Maybe there is another data structure that can be used instead of a list. Dinesh -- http://mail.python.org/mailman/listinfo/python-list