Re: XML-schema 'best practice' question
On Sep 18, 8:28 am, Frank Millman [EMAIL PROTECTED] wrote: Hi all This is not strictly a Python question, but as I am writing in Python, and as I know there are some XML gurus on this list, I hope it is appropriate here. XML-schemas are used to define the structure of an xml document, and to validate that a particular document conforms to the schema. They can also be used to transform the document, by filling in missing attributes with default values. [..] Or maybe the best practice is to *always* validate a document before processing it. I have realised that my question was irrelevant. xml's raison d'etre is to facilitate the exchange of information between separate entities. If I want to use xml as a method of serialisation within my own system, I can do what I like, but there can be no question of 'best practice' in this situation. When xml is used as intended, and you want to process a document received from a third party, there is no doubt that you should always validate it first before processing it. Thank you, Lorenzo, for pointing out the obvious. It may take me a while to catch up, but at least I can see things a little more clearly now. As to why I am using xml at all, I know that there is a serious side to Skip's light-hearted comment, so I will try to explain. I want to introduce an element of workflow management (aka Business Process Management) into the business/accounting system I am developing. I used google to try to find out what the current state of the art is. After several months of very confusing research, this is the present situation, as best as I can figure it out. There is an OMG spec called BPMN, for Business Process Modeling Notation. It provides a graphical notation, intended to be readily understandable by all business users, from business analysts, to technical developers, to those responsible for actually managing and monitoring the processes. Powerful though it is, it does not provide a standard method of serialsing the diagram, so there is no standard way of exchanging a diagram between different vendors, or of using it as input to a workflow engine. There is an OASIS spec called WS-BPEL, for Web Services Business Process Execution Language. It defines a language for specifying business process behavior based on Web Services. This does have a formal xml-based specification. However, it only covers processes invoked via web services - it does not cover workflow-type processes within an organisation. To try to fill this gap, a few vendors got together and submitted a draft specification called BPEL4People. This proposes a series of extensions to the WS-BPEL spec. It is still at the evaluation stage. The BPMN spec includes a section which attempts to provide a mapping between BPMN and BPEL, but the authors state that there are areas of incompatibility, so it is not a perfect mapping. Eventually I would like to make sense of all this, but for now I want to focus on BPMN, and ignore BPEL. I can use wxPython to design a BPMN diagram, but I have to invent my own method of serialising it so that I can use it to drive the business process. For good or ill, I decided to use xml, as it seems to offer the best chance of keeping up with the various specifications as they evolve. I don't know if this is of any interest to anyone, but it was therapeutic for me to try to organise my thoughts and get them down on paper. I am not expecting any comments, but if anyone has any thoughts to toss in, I will read them with interest. Thanks Frank -- http://mail.python.org/mailman/listinfo/python-list
Re: report a BUG of package setuptools-0.6c8.
为爱而生 wrote: File /usr/lib/python2.5/site-packages/setuptools/command/sdist.py, line 98, in entries_finder log.warn(unrecognized .svn/entries format in %s, dirname) NameError: global name 'log' is not defined global name 'log' is not defined to the line 98!!! please report bugs here: http://bugs.python.org/ /F -- http://mail.python.org/mailman/listinfo/python-list
The Python computer language
http://pthoncomputerlanguage.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: The Python computer language
ROSEEE wrote: http://pthoncomputerlanguage.blogspot.com report here: http://tinyurl.com/blogspot-spam /F -- http://mail.python.org/mailman/listinfo/python-list
Ascii Menu I/O redirection
I am writing a small application with a simple ascii based menu. The menu is used to test individual functions, and to change some timings. Otherwise the application just runs automatically, depending on command line options. I want to be able to redirect the menu. The console, a serial port, or possibly a socket are target candidates. Now a serial port and a socket are single files, so I need a file that represents the console, to pass to the working functions. Simply re-assigning for instance sys.stdin.write to point to sys.stdout.write, and using sys.stdin as such a file does not work... So I do the following: start code fragment class console(object): This spoofs a single file like object, using stdout - in (Minimalistic proof of concept implementation) def __init__(self): self.read = sys.stdin.read self.readline = sys.stdin.readline self.write = sys.stdout.write self.flush = sys.stdout.flush self.closeout = sys.stdout.close # keep references to close self.closein = sys.stdin.close def close(self): self.closein() self.closeout() # see if we must run, and how: if __name__ == __main__: if 'serial' in sys.argv: # for RS-232 i/o to terminal f = open('/dev/ttyS0','r+b') else: # console i/o f = console() sys.stderr = f # redirect errors sys.stdout = f # redirect printing sys.stdin = f # redirect raw_input stuff if 'menu' in sys.argv: # test and timing changes menu_loop(menu_dict,f) # (menu_dict is dispatch dict) else:# else just run the system autorun(menu_dict,f) end code fragment The above just shows a choice between console and serial as an example - adding a socket option would be trivial. This all seems to work, but I am asking here before I take the trouble to turn it into production code, as I don't think it is exactly a new problem. Questions are: Is this a reasonable way of doing this kind of thing? Is there a canonical or better way of doing it? Am I missing something? Using Linux only. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Not fully OO ?
Excerpt quoted from http://www.astro.ufl.edu/~warner/prog/python.html : About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
This is wrong. Python _is_ a full OOP language. Everything form modules, functions to basic data types are an object. --JamesMills On Sat, Sep 20, 2008 at 7:23 PM, candide [EMAIL PROTECTED] wrote: Excerpt quoted from http://www.astro.ufl.edu/~warner/prog/python.html : About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. -- http://mail.python.org/mailman/listinfo/python-list -- -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list
how can i check whether a variable is iterable in my code?
hi, all i want to check if a variable is iterable like a list, how can i implement this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On 20 Sep., 11:23, candide [EMAIL PROTECTED] wrote: Excerpt quoted fromhttp://www.astro.ufl.edu/~warner/prog/python.html: About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. This is somewhat true. But what is OO, really? Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
Kay Schluehr wrote: Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. you're satirising the quoted author's cargo-cultish view of object orientation, right? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: report a BUG of package setuptools-0.6c8.
On Sep 20, 1:11 am, Fredrik Lundh [EMAIL PROTECTED] wrote: 为爱而生 wrote: File /usr/lib/python2.5/site-packages/setuptools/command/sdist.py, line 98, in entries_finder log.warn(unrecognized .svn/entries format in %s, dirname) NameError: global name 'log' is not defined global name 'log' is not defined to the line 98!!! please report bugs here: http://bugs.python.org/ Does bugs.python.org track bugs for setuptools? (Genuine question; the PEAK site doesn't list an obvious way to report bugs so I wonder if they're using bugs.python.org? Hope not) If not, the OP should ask on the setuptools mailing list. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
satoru wrote: hi, all i want to check if a variable is iterable like a list, how can i implement this? this would be one way, though I'm sure others exist: if hasattr(yourVar, '__iter__'): # do stuff -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sep 20, 2:23 am, candide [EMAIL PROTECTED] wrote: Excerpt quoted fromhttp://www.astro.ufl.edu/~warner/prog/python.html: About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. Python is what it is, whatever you call it. That page has a whole list of features (we'll give the author the benefit of the doubt and assume they're accurate and fairly up-to-date). Those features (more or less) define what Python is, not trendy computer science catch words. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
On Sep 20, 6:35 pm, Aidan [EMAIL PROTECTED] wrote: satoru wrote: hi, all i want to check if a variable is iterable like a list, how can i implement this? this would be one way, though I'm sure others exist: if hasattr(yourVar, '__iter__'): # do stuff thank you,but this will miss out sequences like string just because it doesn't have an attribute named '__iter__' -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
satoru wrote: hi, all i want to check if a variable is iterable like a list, how can i implement this? untested def is_iterable(param): try: iter(param) except TypeError: return False else: return True -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
candide wrote: Excerpt quoted from http://www.astro.ufl.edu/~warner/prog/python.html : About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. foreach: for x in array: statements Loops over the array given by array. On each iteration, the value of the current element is assigned to x and the internal array pointer is advanced by one. This could be a useful addition to Python. numarray is no longer supported. It has been supplanted by numpy. How is OOP defined? Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
On Sep 20, 8:54 pm, satoru [EMAIL PROTECTED] wrote: On Sep 20, 6:35 pm, Aidan [EMAIL PROTECTED] wrote: satoru wrote: hi, all i want to check if a variable is iterable like a list, how can i implement this? this would be one way, though I'm sure others exist: if hasattr(yourVar, '__iter__'): # do stuff thank you,but this will miss out sequences like string just because it doesn't have an attribute named '__iter__' str objects have a __getitem__ attribute, as do other built-in sequence types: unicode, xrange, buffer. AFAIK if an object has no __iter__ but has a __getitem__, iter(obj) will create an iterator that calls obj.__getitem__(0), obj.__getitem__(1), etc until IndexError is raised. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
Colin J. Williams wrote: foreach: for x in array: statements Loops over the array given by array. On each iteration, the value of the current element is assigned to x and the internal array pointer is advanced by one. This could be a useful addition to Python. for-in could be a useful addition to Python? looks like Guido's used his time machine again, then, since it's been around since the pre-1.0 days: http://www.python.org/doc/ref/for.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
for-in could be a useful addition to Python? looks like Guido's used his time machine again, then, since it's been around since the pre-1.0 days: http://www.python.org/doc/ref/for.html He somehow must have misinterpreted http://www.astro.ufl.edu/~warner/prog/python.html which has the exact text he quoted. Unfortunately, this text has foreach in bold, so he might have assumed foreach to be a keyword (despite the example to the right demonstrating the contrary). What this has to do with OO, or with numpy, is beyond me. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
candide [EMAIL PROTECTED] wrote: Excerpt quoted from http://www.astro.ufl.edu/~warner/prog/python.html : About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. General comments about the page: Section 2: Poor demonstration of 'global'. The declaration of 'a' as global is unnecessary and misleading. Section 4: Maths: Requires import math The supplied examples won't work if you just import math, they need a from math import ... (either * or better an explicit list of functions). Worse, the random number examples won't work whatever you import as they include both 'random.seed()' which assumes 'random' is the module and 'x = random()' which requires 'from random import random'. Section 5: Strings do not expand escape sequences unless it is defined as a raw string by placing an r before the first quote What is that supposed to mean? Describing triple quoted strings as 'optional syntax' is a bit weird too: the syntax is no more optional than any other form of string literal, you can use it or not. Another pointless example given under the heading 'String Operators': Concatenation is done with the + operator. Converting to numbers is done with the casting operations: x = 1 + float(10.5) String functions actually mostly describes string methods with len hidden in the middle but only the example tells you that it is different than the other examples. Section 6 is all about numarray but bizarrely (for something purporting to be an overview of Python) there is nothing at all about either list or dict types. Section 7 says There is no switch or case statement so multiple elifs must be used instead. omitting to mention other possibly more appropriate options such as dicts or inheritance. This is a good indication that the author doesn't know much about OOP. Section 8 for x in array: statements shows that the author doesn't understand things like iterators. Section 10 has such interesting facts as Only constant initializers for class variables are allowed (n = 1) or Objects can be compared using the == and != operators. Two objects are equal only if they are the same instance of the same object. and an example with a completely spurious class attributes, some pointless getter/setter methods, and contorted calls to base class methods. Section 11 demonstrates again that the author doesn't understand about iterable objects. I'd say the claim that Python isn't a full OOP language is not the most important reason to ignore the page. -- http://mail.python.org/mailman/listinfo/python-list
jips works with in online
http://candapud.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sat, 20 Sep 2008 13:13:08 +, Duncan Booth wrote: This is a good indication that the author doesn't know much about OOP. I think you can drop the last two words :) Actually that's unfair -- it looks like he knows quite a bit about the metallicity of quasers, but he's just parroting a bunch of Java concepts as if Java was the be-all and end-all of object oriented programming, which is clearly wrong because we all know that Python's object model is the One True OOP. *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
thanks very much! -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii Menu I/O redirection
On Sat, 20 Sep 2008 23:14:26 +0200, Hendrik van Rooyen wrote: class console(object): This spoofs a single file like object, using stdout - in (Minimalistic proof of concept implementation) def __init__(self): self.read = sys.stdin.read self.readline = sys.stdin.readline self.write = sys.stdout.write self.flush = sys.stdout.flush self.closeout = sys.stdout.close # keep references to close self.closein = sys.stdin.close def close(self): self.closein() self.closeout() I'm not sure that closing stdin and stout are a good idea. This could have side-effects for other parts of your program, and will almost certainly end badly if you're running in the interactive interpreter. Other than that, what you've done seems reasonable, although since every instance of console() has the same state, I'd write it slightly differently: class console(object): This spoofs a single file like object, using stdout - in (Minimalistic proof of concept implementation) read = sys.stdin.read readline = sys.stdin.readline write = sys.stdout.write flush = sys.stdout.flush closeout = sys.stdout.close closein = sys.stdin.close @classmethod def close(cls): cls.closein() cls.closeout() [...] Questions are: Is this a reasonable way of doing this kind of thing? Is there a canonical or better way of doing it? Am I missing something? It seems to me that you might have been better off to write your program to take two files, an input and an output, instead of forcing both to go to the same file. if 'serial' in sys.argv: # for RS-232 i/o to terminal infile = open('/dev/ttyS0','r+b') outfile = infile else: # console i/o infile = sys.stdin outfile = sys.stdout Hope this helps. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On 20 Sep., 12:14, Fredrik Lundh [EMAIL PROTECTED] wrote: Kay Schluehr wrote: Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. you're satirising the quoted author's cargo-cultish view of object orientation, right? /F I wonder if the OO fetish hasn't already lost much of its magic powers. What are the most powerful fetishes these days? A year ago I would have suspected purely functional but I'm not sure it has really caught on. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sat, Sep 20, 2008 at 11:26 AM, Kay Schluehr [EMAIL PROTECTED] wrote: On 20 Sep., 12:14, Fredrik Lundh [EMAIL PROTECTED] wrote: Kay Schluehr wrote: Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. you're satirising the quoted author's cargo-cultish view of object orientation, right? /F I wonder if the OO fetish hasn't already lost much of its magic powers. What are the most powerful fetishes these days? A year ago I would have suspected purely functional but I'm not sure it has really caught on. I think the current fetish is paralelism and erlang's share-nothing concurrency model. Or something like it. -- http://mail.python.org/mailman/listinfo/python-list -- Eduardo de Oliveira Padoan http://djangopeople.net/edcrypt/ http://stopforwarding.us/etiq.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sep 20, 5:23 am, candide [EMAIL PROTECTED] wrote: Excerpt quoted fromhttp://www.astro.ufl.edu/~warner/prog/python.html: About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. My comment is Who cares? I was always under the impression that if any language truly was OO it would be smalltalk. And I don't derive any benefit from smalltalk at all. I do however derive substantial benefit from other languages that OO zealots would likely poo poo on including python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
Fredrik Lundh wrote: Colin J. Williams wrote: foreach: for x in array: statements Loops over the array given by array. On each iteration, the value of the current element is assigned to x and the internal array pointer is advanced by one. This could be a useful addition to Python. for-in could be a useful addition to Python? looks like Guido's used his time machine again, then, since it's been around since the pre-1.0 days: http://www.python.org/doc/ref/for.html /F Thanks. for_stmt ::= for target_list in expression_list : suite [else : suite] Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: XML-schema 'best practice' question
On 20 Set, 07:59, Frank Millman [EMAIL PROTECTED] wrote: I want to introduce an element of workflow management (aka Business Process Management) into the business/accounting system I am developing. I used google to try to find out what the current state of the art is. After several months of very confusing research, this is the present situation, as best as I can figure it out. What is the state of the art of existing, working software? Can you leverage it instead of starting from scratch? For example, the existing functionality of your accounting software can be reorganized as a suite of components, web services etc. that can be embedded in workflow definitions, and/or executing a workflow engine can become a command in your application. There is an OMG spec called BPMN, for Business Process Modeling Notation. It provides a graphical notation [snip] there is no standard way of exchanging a diagram between different vendors, or of using it as input to a workflow engine. So BPMN is mere theory. This spec might be a reference for evaluating actual systems, but not a standard itself. There is an OASIS spec called WS-BPEL, for Web Services Business Process Execution Language. It defines a language for specifying business process behavior based on Web Services. This does have a formal xml-based specification. However, it only covers processes invoked via web services - it does not cover workflow-type processes within an organisation. To try to fill this gap, a few vendors got together and submitted a draft specification called BPEL4People. This proposes a series of extensions to the WS-BPEL spec. It is still at the evaluation stage. Some customers pay good money for buzzword compliance, but are you sure you want to be so bleeding edge that you care not only for WS- something specifications, but for evaluation stage ones? There is no need to wait for BPEL4People before designing workflow systems with human editing, approval, etc. Try looking into case studies of how BPEL is actually used in practice. The BPMN spec includes a section which attempts to provide a mapping between BPMN and BPEL, but the authors state that there are areas of incompatibility, so it is not a perfect mapping. Don't worry, BPMN does not exist: there is no incompatibility. On the other hand, comparing and understanding BPMN and BPEL might reveal different purposes and weaknesses between the two systems and help you distinguish what you need, what would be cool and what is only a bad idea or a speculation. Eventually I would like to make sense of all this, but for now I want to focus on BPMN, and ignore BPEL. I can use wxPython to design a BPMN diagram, but I have to invent my own method of serialising it so that I can use it to drive the business process. For good or ill, I decided to use xml, as it seems to offer the best chance of keeping up with the various specifications as they evolve. If you mean to use workflow architectures to add value to your business and accounting software, your priority should be executing workflows, not editing workflow diagrams (which are a useful but unnecessary user interface layer over the actual workflow engine); making your diagrams and definitions compliant with volatile and unproven specifications should come a distant last. I don't know if this is of any interest to anyone, but it was therapeutic for me to try to organise my thoughts and get them down on paper. I am not expecting any comments, but if anyone has any thoughts to toss in, I will read them with interest. 1) There are a number of open-source or affordable workflow engines, mostly BPEL-compliant and written in Java; they should be more useful than reinventing the wheel. 2) With a good XML editor you can produce the workflow definitions, BPEL or otherwise, that your workflow engine needs, and leave the interactive diagram editor for a phase 2 that might not necessarily come; text editing might be convenient enough for your users, and for graphical output something simpler than an editor (e.g a Graphviz exporter) might be enough. 3) Maybe workflow processing can grow inside your existing accounting application without the sort of big bang redesign you seem to be planning; chances are that the needed objects are already in place and you only need to make workflow more explicit and add appropriate new features. Regards, Lorenzo Gatti -- http://mail.python.org/mailman/listinfo/python-list
Re: XML-schema 'best practice' question
Sorry for pressing the send button too fast. On 20 Set, 07:59, Frank Millman [EMAIL PROTECTED] wrote: I want to introduce an element of workflow management (aka Business Process Management) into the business/accounting system I am developing. I used google to try to find out what the current state of the art is. After several months of very confusing research, this is the present situation, as best as I can figure it out. What is the state of the art of existing, working software? Can you leverage it instead of starting from scratch? For example, the existing functionality of your accounting software can be reorganized as a suite of components, web services etc. that can be embedded in workflow definitions, and/or executing a workflow engine can become a command in your application. There is an OMG spec called BPMN, for Business Process Modeling Notation. It provides a graphical notation [snip] there is no standard way of exchanging a diagram between different vendors, or of using it as input to a workflow engine. So BPMN is mere theory. This spec might be a reference for evaluating actual systems, but not a standard itself. There is an OASIS spec called WS-BPEL, for Web Services Business Process Execution Language. It defines a language for specifying business process behavior based on Web Services. This does have a formal xml-based specification. However, it only covers processes invoked via web services - it does not cover workflow-type processes within an organisation. To try to fill this gap, a few vendors got together and submitted a draft specification called BPEL4People. This proposes a series of extensions to the WS-BPEL spec. It is still at the evaluation stage. Some customers pay good money for buzzword compliance, but are you sure you want to be so bleeding edge that you care not only for WS- something specifications, but for evaluation stage ones? There is no need to wait for BPEL4People before designing workflow systems with human editing, approval, etc. Try looking into case studies of how BPEL is actually used in practice. The BPMN spec includes a section which attempts to provide a mapping between BPMN and BPEL, but the authors state that there are areas of incompatibility, so it is not a perfect mapping. Don't worry, BPMN does not exist: there is no incompatibility. On the other hand, comparing and understanding BPMN and BPEL might reveal different purposes and weaknesses between the two systems and help you distinguish what you need, what would be cool and what is only a bad idea or a speculation. Eventually I would like to make sense of all this, but for now I want to focus on BPMN, and ignore BPEL. I can use wxPython to design a BPMN diagram, but I have to invent my own method of serialising it so that I can use it to drive the business process. For good or ill, I decided to use xml, as it seems to offer the best chance of keeping up with the various specifications as they evolve. If you mean to use workflow architectures to add value to your business and accounting software, your priority should be executing workflows, not editing workflow diagrams (which are a useful but unnecessary user interface layer over the actual workflow engine); making your diagrams and definitions compliant with volatile and unproven specifications should come a distant last. I don't know if this is of any interest to anyone, but it was therapeutic for me to try to organise my thoughts and get them down on paper. I am not expecting any comments, but if anyone has any thoughts to toss in, I will read them with interest. 1) There are a number of open-source or affordable workflow engines, mostly BPEL-compliant and written in Java; they should be more useful than reinventing the wheel. 2) With a good XML editor you can produce the workflow definitions, BPEL or otherwise, that your workflow engine needs, and leave the interactive diagram editor for a phase 2 that might not necessarily come; text editing might be convenient enough for your users, and for graphical output something simpler than an editor (e.g a Graphviz exporter) might be enough. 3) Maybe workflow processing can grow inside your existing accounting application without the sort of big bang redesign you seem to be planning; chances are that the needed objects are already in place and you only need to make workflow more explicit and add appropriate new features. Regards, Lorenzo Gatti -- http://mail.python.org/mailman/listinfo/python-list
How to make a reverse for loop in python?
Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) -- http://mail.python.org/mailman/listinfo/python-list
Here's something interesting: sympy crashes in Python 2.6 (Windows)
Beacuse in 2.6, Python apparently has fixed a discrepency that existed in previous versions. In the IDLE that comes with 2.5, typing as, to wit import random as ran, the words import and as highlight in red, so you can't use them as variable names or you'll get a syntax error. Ah, but you CAN use as for a variable: for as in xrange(10): print as works just fine, although it shouldn't. Python 2.6 fixes this discrepency and now gives you a syntax error if you use as for a variable name. The upshot is code (such as sympy) written prior to 2.6 can crash now due to this fix if said code inadverntently used what should have been a reserved word. I was able to fix the code for this as problem, but not the one that came after. I've reported this and interested parties can visit the sympy page and check Issue 1115. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Alex Snast a écrit : Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) for (i = 0; i 10; i--) - for i in range(10): for (i = 10; i = 0; --i) - for i in range(10,-1,-1): Thoma -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
On Sep 20, 11:16�am, Alex Snast [EMAIL PROTECTED] wrote: Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) for i in xrange(10,-1,-1): print i, 10 9 8 7 6 5 4 3 2 1 0 Note the starting number is 10, the ending number is -1 because you want to include 0 and the step size is -1. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Alex Snast [EMAIL PROTECTED] wrote: Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be: for i in range(10, -1, -1): print i except you virtually never want to do that in Python. Don't expect just to translate statement by statement from one language to another: normally in Python you will iterate directly over the sequence you want to process rather than trying to count loop indices with all the telegraph pole errors that result. The usual way to iterate over a sequence in reverse is: for x in reversed(seq): print x although if you know it is a list, string or other object that supports extended slicing you can also do: for x in seq[::-1]: print x this may be less clear than using 'reversed', but does allow you to specify an explicit start, stop and step if you want to do only part of the sequence. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
2008/9/20 Alex Snast [EMAIL PROTECTED]: I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) for i in range(10, 0, -1): print i -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Alex Snast wrote: I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in reversed(range(10)): ... (the latter is mentioned in the tutorial, and is the second hit if you google for python reverse for loop) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Alex Snast wrote: Hello I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) -- http://mail.python.org/mailman/listinfo/python-list What are you trying to loop through? If it's the contents of a list, you can reverse the list (in place) first: L = [1,2,3] L.reverse() for item in L: print item Or you can create a new reversed (copy of the original) list and iterate through it for item in reversed(L): print item If it's just a sequence of numbers you want to generate: range(3) generates a forward list [0,1,2], and range(3,0,-1) generates a backward list [2,1,0] so for i in range(11,0,-1): might be what you want. If your list is huge, consider xrange rather than range. And as always, you could just roll your own index manipulation: i = 10 while i =0: # do whatever i -= 1 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Fredrik Lundh wrote: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in reversed(range(10)): ... (and to include the 10 in the range, add one to the 10 above) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Gary Herron wrote: Or you can create a new reversed (copy of the original) list and iterate through it for item in reversed(L): print item It's not a copy, it's a view: items = [1,2,3] r = reversed(items) items[:] = abc for item in r: print item ... c b a Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
satoru wrote: On Sep 20, 6:35 pm, Aidan [EMAIL PROTECTED] wrote: satoru wrote: hi, all i want to check if a variable is iterable like a list, how can i implement this? this would be one way, though I'm sure others exist: if hasattr(yourVar, '__iter__'): # do stuff thank you,but this will miss out sequences like string just because it doesn't have an attribute named '__iter__' In 3.0, it does. Such consistency is one of the advantages of 3.0. In at least some 2.x's, str still uses the older __getitem__ iteration protocol. I am not sure about other built-in sequences. -- http://mail.python.org/mailman/listinfo/python-list
NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py
To All, I have now been able to generate a .pyd file from a FORTRAN file that I am trying to interface with python. I was able to execute this with an additional insight into how f2py operates. It seems as though the documentation requires an upgrade, since there appears to be missing information that might misdirect a f2py newcomer, such as myself. However, I am now facing the following new error: ImportError: DLL load with error code 193 The python script is as follows: import hello print hello.__doc__ print hello.foo.__doc__ hello.foo(4) The Fortran code is as follows: ! -*- f90 -*- subroutine foo(a) integer a print*, Hello from Fortran! print*, a=, a end I was wondering as to what I should now try in order to finally produce a python sending and receiving information from a FORTRAN .pyd file. Any Suggestions??? Do I have to recompile Python with mingw32 in order to finally resolve this issue?? Thanks, David Blubaugh This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Duncan Booth: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be: for i in range(10, -1, -1): print i I'd use xrange there. Anyway, I have always felt that Python syntax not easy to understand at first sight, expecially when you try to convert a bit more complex inverted for loops from/to C to/from Python. It's one of the few cases where (for example) Pascal (loop) syntax wins a bit over Python syntax :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Sunbeam India UPS Point- unfair Trade Practices in Computer Business
Sunbeam India UPS Point- unfiar Trade Practices in Computer Business Save Money, Tension, and Time. Avoid Nehru Place market to buy Computer Goods Hello All, This is to inform you all the sellers at the Nehru Place are not selling good products. Especially the shop- Nishchal Joshi, Sunbeam India UPS Point, 103, S2 1st Floor, Siddhartha Building, Nehru Place, New Delhi 110019. Phone - 9810276805, Email - [EMAIL PROTECTED] Engineer at Shop- Subash - 996899657 I bought a motherboard from that shop and that computer don't even worked for a single day. We called the person in just two days of purchase and he said he was out of town and so therefore bring it to me after one week. We took the system to his shop after spending money to nehru place, there he kept the system for five days and returned it back to us. However it was not rectified. Then we called him to our house and he charged money for this and did some corrections in the system and restarted the system. We told him to take his motherboard and gave our own old motherboard, then he said that he will rectify it, after making settings he left for the day. When we started the system, it started and got shut down immediately. And after that it never started. We called this person again and told him to take his motherboard back and gave us our old motherboard, but he said I am not the correct person, talk to the engineer who set the system for you. That Engineer Subash works for the Nishchal in his shop. Please suggest what action can be taken against him. Steps in the pipeline - Consumer Forum, Escalating issue to Consumer Affairs, Online Web and Nehru Place Online Community, so that others do not fall prey to this. Thanks Kritika Joshi [EMAIL PROTECTED] Save Money, Tension, and Time. Avoid Nehru Place (Nishchal Joshi, Unbeam India UPS Point, 103, S2 1st Floor, Siddhartha Building, Nehru Place, New Delhi ) market to buy Computer Goods. All the Best. -- http://mail.python.org/mailman/listinfo/python-list
Re: NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py
Blubaugh, David A. wrote: (no need to shout when filling in the subject line, thanks) I have now been able to generate a .pyd file from a FORTRAN file that I am trying to interface with python. I was able to execute this with an additional insight into how f2py operates. ImportError: DLL load with error code 193 Error code 193 is ERROR_BAD_EXE_FORMAT, which means that the thing you're trying to import is not a proper DLL. copy LICENSE.txt LICENSE.pyd 1 file(s) copied. python import LICENSE Traceback (most recent call last): File stdin, line 1, in module ImportError: DLL load failed with error code 193 In general, the tools for building binary extensions for Python assumes that you have at least some basic knowledge about how to build binaries using a compiled language. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sep 20, 5:14 am, Fredrik Lundh [EMAIL PROTECTED] wrote: Kay Schluehr wrote: Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. you're satirising the quoted author's cargo-cultish view of object orientation, right? /F If you define OO as implementation inheritance, then Java is not. It inherits interface only. Another possibility is, has a virtual function table. The fact that Python indexes by name doesn't disqualify it from that definition. I don't know if Java meets it. I don't think raw C structures would be included, and you can define function pointers in them. Wikipedia puts it decently: mainly for OO programming, but with some procedural elements. ducks -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On 20 Sep, 19:42, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: Wikipedia puts it decently: mainly for OO programming, but with some procedural elements. ducks When it comes to Python and object-oriented programming, you can't leave out the ducks. ;-) Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii Menu I/O redirection
Steven D'Aprano [EMAIL PROTECTED] wrote: I'm not sure that closing stdin and stout are a good idea. This could have side-effects for other parts of your program, and will almost certainly end badly if you're running in the interactive interpreter. Its a very simple thingy - there will only ever be one object - The Console, or The Connection The close stuff was there because I thought it would be better to close the RS-232 port if I were using it. I only close it right at the end before exiting - but you are right. - if I invoke the interpreter with -i then it will be seriously broken. Other than that, what you've done seems reasonable, although since every instance of console() has the same state, I'd write it slightly differently: class console(object): This spoofs a single file like object, using stdout - in (Minimalistic proof of concept implementation) read = sys.stdin.read readline = sys.stdin.readline write = sys.stdout.write flush = sys.stdout.flush closeout = sys.stdout.close closein = sys.stdin.close @classmethod def close(cls): cls.closein() cls.closeout() Thanks. It looks neater without all the selfs. Seems to me the next time someone complains about 'self' he should be told : use class attributes and methods, and only one instance *WEG* Questions are: Is this a reasonable way of doing this kind of thing? Is there a canonical or better way of doing it? Am I missing something? It seems to me that you might have been better off to write your program to take two files, an input and an output, instead of forcing both to go to the same file. if 'serial' in sys.argv: # for RS-232 i/o to terminal infile = open('/dev/ttyS0','r+b') outfile = infile else: # console i/o infile = sys.stdin outfile = sys.stdout This is weird - This is exactly how I started off - and then I thought about the errors, and I did not want to pass three files, so I started looking for one. :-) Reading your response, and thinking about what I have done, I get the feeling that its all too complicated - What I will probably end up doing would be to pass no file, and just use standard print statements and sys.stdin.readline, etc. Then if I redirect the stdin,-out and -err, the thing is sorted, without the necessity of jumping through OO hoops, as this class is the only one in the programme - all the rest are functions. It is impossible to think clearly all of the time. It is difficult to think clearly most of the time. In fact it is nice to have an occasional lucid thought... Hope this helps. Yes it has. - Thanks for the input. - Hendrik -- Robert Wilensky: We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of William Shakespeare. Now, thanks to the Internet, we know this not true. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
candide a écrit : Excerpt quoted from http://www.astro.ufl.edu/~warner/prog/python.html : About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. The following definitions are AFAIK the only commonly accepted definitions about OO: 1/ an object is defined by identity, state and behaviour 2/ objects interacts by sending messages each other 3/ an OO program is made of interacting objects I let you find out whether Python meets these 3 definitions - and if Java does (hint : in Python, everything you can bind to a name is an object - this is not true in Java or C++). -- http://mail.python.org/mailman/listinfo/python-list
Re: Here's something interesting: sympy crashes in Python 2.6 (Windows)
On Sat, Sep 20, 2008 at 1:27 PM, Mensanator [EMAIL PROTECTED] wrote: Beacuse in 2.6, Python apparently has fixed a discrepency that existed in previous versions. In the IDLE that comes with 2.5, typing as, to wit import random as ran, the words import and as highlight in red, so you can't use them as variable names or you'll get a syntax error. Ah, but you CAN use as for a variable: for as in xrange(10): print as works just fine, although it shouldn't. Python 2.6 fixes this discrepency and now gives you a syntax error if you use as for a variable name. You should have noticed the warning you received in python 2.5 when using as as a name. The upshot is code (such as sympy) written prior to 2.6 can crash now due to this fix if said code inadverntently used what should have been a reserved word. I was able to fix the code for this as problem, but not the one that came after. I've reported this and interested parties can visit the sympy page and check Issue 1115. -- http://mail.python.org/mailman/listinfo/python-list -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list
writeable buffer and struct.pack_into and struct.unpck_from
Hi, I can't find in the documentation the way to use these two functions. can someone share a simple code that utilize these two functions? -- http://mail.python.org/mailman/listinfo/python-list
ANN: Python FTP Server library (pyftpdlib) 0.5.0 released
Hi, I'm pleased to announce release 0.5.0 of Python FTP Server library (pyftpdlib). http://code.google.com/p/pyftpdlib/ === About === Python FTP server library provides an high-level portable interface to easily write asynchronous FTP servers with Python. Based on asyncore framework pyftpdlib is currently the most complete RFC-959 FTP server implementation available for Python programming language. === Major changes === This new version, aside from fixing some bugs, includes the following major features: - pyftpdlib now provides configurable idle timeouts to disconnect client after a long time of inactivity. - It is now possible to define permission exceptions for certain directories (e.g. creating a user which does not have write permission except for one sub-directory in FTP root). - Imposed a delay before replying for invalid credentials to minimize the risk of brute force password guessing. A complete list of changes including enhancements, bug fixes and instructions for using the new functionalities is available here: http://code.google.com/p/pyftpdlib/wiki/ReleaseNotes05 === More links === * Source tarball: http://pyftpdlib.googlecode.com/files/pyftpdlib-0.5.0.tar.gz * Online docs: http://code.google.com/p/pyftpdlib/wiki/Tutorial * FAQs: http://code.google.com/p/pyftpdlib/wiki/FAQ * RFCs compliance paper: http://code.google.com/p/pyftpdlib/wiki/RFCsCompliance * Issue tracker: http://code.google.com/p/pyftpdlib/issues/list Thanks, --- Giampaolo Rodola' g.rodola [at] gmail [dot] com http://code.google.com/p/pyftpdlib/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Here's something interesting: sympy crashes in Python 2.6 (Windows)
On Sep 20, 1:34�pm, Guilherme Polo [EMAIL PROTECTED] wrote: On Sat, Sep 20, 2008 at 1:27 PM, Mensanator [EMAIL PROTECTED] wrote: Beacuse in 2.6, Python apparently has fixed a discrepency that existed in previous versions. In the IDLE that comes with 2.5, typing as, to wit import random as ran, the words import and as highlight in red, so you can't use them as variable names or you'll get a syntax error. Ah, but you CAN use as for a variable: for as in xrange(10): print as works just fine, although it shouldn't. Python 2.6 fixes this discrepency and now gives you a syntax error if you use as for a variable name. You should have noticed the warning you received in python 2.5 when using as as a name. I'm not the one who wrote sympy, so I guess I'm not the only one who didn't notice it. If it's a well known problem, then sorry I wasted your time. The sympy people thought it was important and, as not everyone uses sympy, I thought I was performing a service to the community mentioning it here. Sheesh. The upshot is code (such as sympy) written prior to 2.6 can crash now due to this fix if said code inadverntently used what should have been a reserved word. I was able to fix the code for this as problem, but not the one that came after. I've reported this and interested parties can visit the sympy page and check Issue 1115. -- http://mail.python.org/mailman/listinfo/python-list -- -- Guilherme H. Polo Goncalves- Hide quoted text - - Show quoted text - -- http://mail.python.org/mailman/listinfo/python-list
Re: Python newbie question re Strings and integers
rmac a écrit : the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) rfind returns an int, so passing it to the int type constructor is useless. filenameStart = int(filename.rfind('/')) idem #print 'Extension Start - ' + str(extensionStart) The print statement isn't restricted to string objects. And FWIW, you can use string formating. The above should be either print Extension start - , extensionStart or print Extension start - %s % extensionStart As a side not, the naming convention in Python is to use all_lower for identifiers. #print 'FileName Start - ' + str(filenameStart) idem. currentSymbol=filename[int(filenameStart),int(extensionStart)] Two more useless int constructor calls. Uncommenting the print statements clearly show the values to be integers If by 'the values', you mean objects bound to identifiers 'filenameStart' and 'extensionStart', I fail to see how they could be anything else... (and without the str casts actually provide int+string errors) Indeed. What should be the semantic of expression 'answer is ' + 42 ??? However, executing this code results in... opening - /Users/rmac/Documents/Sandbox/data/MarketData/AA.csv Traceback (most recent call last): File rHistFileToDB_Equities.py, line 25, in module currentSymbol=filename[int(filenameStart),int(extensionStart)] TypeError: string indices must be integers the expression: int(filenameStart),int(extensionStart) 1/ takes the object currently bound to identifier 'filenameStart' and pass it to the int type constructor 2/ takes the object currently bound to identifier 'extensionStart' and pass it to the int type constructor 3/ build a tuple (actually, a pair of ints) from the results of the two above expressions Then you try to use this tuple as an index on a string. A tuple is not a legal type for string (or any other sequence) subscripting. The complete syntax for string subscripting is described in the FineManual. To make a long story short, it's : string[start:end:step] where end and step are optionals. IOW, the correct syntax here is: filename[filenameStart:extensionStart] Now, while this is the correct *syntax*, it's not the correct *idiom*. There's a module named os.path, which provides the needed service. I leave it up to you to read the relevant part of the documentation... -- http://mail.python.org/mailman/listinfo/python-list
Re: improving a huge double-for cycle
Steven D'Aprano a écrit : On Thu, 18 Sep 2008 20:43:00 +0200, Bruno Desthuilliers wrote: Now the obvious winner is pruebono - even unoptimized, using sets seems to be *way* faster than even the most optimized corrected version of your algorithm. I'm not being snarky about losing priority here, but I submitted essentially the same solution two hours earlier than pruebono. My bad... Now that you mention it, I see you effectively did. My fault, I did a too-fast screening of submitted solutions, and hereby declare you Steven as the winner. Are people not seeing my posts? Have I been kill-filed by everyone except Mensator? I do see your posts. Whether I read them entirely is another question - and in this concrete case, the answer is obviously 'nope'. Put the blame on me. I also asked a question about HTTPError and I haven't seen any responses at all. This is another problem - it happens that no one has a clue, or that the one having a clue lack time (or willingness) to anwer. Once again, sorry if me missing your correct answer drives you paranoid :( -- http://mail.python.org/mailman/listinfo/python-list
RE: NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py
Sir, Let me state that do have extensive experience with developing binary files. Please note that I have followed all of the instructions to the letter as far as developing a DLL to be imported. However, it is not working correctly. I believe it might be my system environment variables?? Thanks for your reply, David Blubaugh From: Fredrik Lundh [mailto:[EMAIL PROTECTED] Sent: Sat 9/20/2008 1:30 PM To: python-list@python.org Subject: Re: NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py Blubaugh, David A. wrote: (no need to shout when filling in the subject line, thanks) I have now been able to generate a .pyd file from a FORTRAN file that I am trying to interface with python. I was able to execute this with an additional insight into how f2py operates. ImportError: DLL load with error code 193 Error code 193 is ERROR_BAD_EXE_FORMAT, which means that the thing you're trying to import is not a proper DLL. copy LICENSE.txt LICENSE.pyd 1 file(s) copied. python import LICENSE Traceback (most recent call last): File stdin, line 1, in module ImportError: DLL load failed with error code 193 In general, the tools for building binary extensions for Python assumes that you have at least some basic knowledge about how to build binaries using a compiled language. /F This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: improving a huge double-for cycle
Bruno Desthuilliers a écrit : Alexzive a écrit : Hello there :) , (snip) Now the obvious winner is pruebono Correction (my bad) : Steven D'Aprano submitted the set-based solution first. So the winners are Steven and pruebono. -- http://mail.python.org/mailman/listinfo/python-list
Re: improving a huge double-for cycle
Harald Luessen a écrit : On Thu, 18 Sep 2008 Bruno Desthuilliers wrote: # Harald : uncomment this and run test_results. As far as I can tell, it # doesn't yields the expected results ## IN7 = IN[:] ## def sortk7(n): ## return n.coordinates[0] ## def doubles7(): ## is ordering better ? - Nope Sir, it's broken... ## IN7.sort(key=sortk) ## SN = [] ## sn_append = SN.append ## in_len = len(IN) ## for i in xrange(in_len): ## node_i = IN[i] ## coords_i = node_i.coordinates ## for j in xrange(i+1, in_len): ## if coords_i[0] == IN[j].coordinates[0]: ## if coords_i[1] == IN[j].coordinates[1]: ## sn_append(node_i) ## else: ## break ## return SN ... Results here (py2.5, gentoo linux, athlonxp1800, 512 ram): test_results() True test_times() doubles0 : 1.55667901039 doubles1 : 0.719144105911 doubles2 : 0.703393936157 doubles3 : 0.700654983521 doubles4 : 0.706257104874 doubles5 : 0.528184890747 doubles6 : 0.461633205414 doubles8 : 0.0134379863739 doubles9 : 0.0108540058136 When you change my code then do it right. :-) You forgot to change the IN to IN7 at _every_ place. And the sortk should be sortk7 in _both_ places. doh :( Sorry Harald, my fault, you're right... I never let the code run before myself. I just wrote it in the newsreader. But now i did and I have a second version as bonus. IN7 = IN[:] def sortk7(n): return n.coordinates[0], n.coordinates[1] def doubles7(): IN7.sort(key=sortk7) SN = [] sn_append = SN.append in_len = len(IN7) for i in xrange(in_len): node_i = IN7[i] coords_i = node_i.coordinates for j in xrange(i+1, in_len): if coords_i[0] == IN7[j].coordinates[0]: if coords_i[1] == IN7[j].coordinates[1]: sn_append(node_i) else: break return SN def comp7( x, y ): return cmp( x.coordinates, y.coordinates ) def doubles7a(): IN7.sort( comp7 ) SN = [] sn_append = SN.append in_len = len(IN7) for i in xrange(in_len): node_i = IN7[i] for j in xrange(i+1, in_len): node_j = IN7[j] if comp7( node_i, node_j ) == 0: sn_append(node_i) else: break return SN Here are the results. (py2.5, WindowsXP, Pentium4, 2.6GHz, 1.5GB): My version is not so bad. doubles0 : 1.03830598582 doubles1 : 0.47943719104 doubles2 : 0.487412506338 doubles3 : 0.475924733451 doubles4 : 0.466548681466 doubles5 : 0.340487967046 doubles6 : 0.278480365521 doubles7 : 0.0953190978183 doubles7a : 0.0784233750379 doubles8 : 0.010236496538 doubles9 : 0.00742803903848 Point taken. Now there's one thing I find questionnable with your solution (which is probably why I didn't bother double-checking it when it *appeared* to be broken) : you assume that it's ok to loose original ordering, which I strongly suspect is not the case for the OP use case, and given the OP use case list's size, working on a copy might not be an acceptable solution. But anyway: this is not an excuse for me having broken your code. My apologies. -- http://mail.python.org/mailman/listinfo/python-list
Re: matplotlib in interactive mode locks when run from subprocess
I think my question was not very clear. I narrowed the problem down to a reconstructable small example, consisting of a python script (a very simple interpreter) and three lines to execute in it: == start simple interpreter file == import os import sys import time def run(): while True: # read a line of text, the thread is stuck here untill a \n is # fed to the stream. time.sleep(0.1) line = try: line = sys.stdin.readline() except Exception, why: sys.stdout.wite(why.message+\n) if line: try: code = compile(line,none,exec) exec(code) except Exception, why: sys.stderr.write(why.message) sys.stderr.write( ) if __name__ == __main__: run() == end of file == Now I run this file (by double clicking it) and I get a prompt. The three lines I type in are: import matplotlib.pylab as pl pl.ion() #interactive mode on pl.plot([1,2,3],[4,6,5]) This produces a tk window, but it's unresponsive. The process does have 5 threads, so matplotlib managed to create the threads, but it seems as if they're blocked. When I run the three lines of code in a normal python shell, I get the proper results: a responsive figure (I can zoom and pan) and my shell is still responsive too. I am in the dark why this does not work. Any thoughts anyone? I've been busy all day trying to get this right, with hardly any progress... :( Almar PS: I run windows xp, my matplotlibrc file has the backend: TkAgg, interactive: True 2008/9/18 Almar Klein [EMAIL PROTECTED] Hi, In wxpython, I made an interactive shell, which creates a remote python subprocess to do the interpreting. Communication is done via a pipe. The idea is that the python session is an actual process separate from the GUI, which has some advantages, like I can have multiple such shells in my application, and I can kill them without worrying that my wx app will crash. To do this I use the wx.Process class, which allows asynchronous communication with the remote process. This all works really, I will also launch wxpython apps. So I was quite happy, untill I tried doing some plotting with matplotlib (in TkAgg backend). The problem is that the process becomes unresponsive when I plot something (No prompt is written to the stdout/stderr). (more details below) I don't know much about creating subprocess and how they are different from a normal process. So can anyone offer some help as to what the problem might be? Thanks in advance, Almar To get to the details: - When I start a process with command python -u -i -- When interactive mode is off, the whole process becomes unresponsive when doing pylab.show() -- When interactive mode in on, on doing pylab.plot(), a figure appears, which I can zoom etc., but the process is now stuck, also after closing the figure - When I start a process with command python -u -c 'import code;code.interact(readfunc=raw_input)' (This is how Pype does it). -- When interactive mode is off, the figures show when doing pylab.show() and the process behaves as normal after closing the figure(s). -- When interactive mode in on, on doing pylab.plot(), a figure appears, but most of the time it is not drawn and emmediately unresponsive, just like the process itself. I have also tried an asynchronous Popen recipe by Joshiah Carlson I found on activestate. And I made my own process class using win32process.CreateProcess. Both alternatives to wx.Process resulted in the same sympoms. Oh, and I run windows. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On 20 Sep., 18:33, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The following definitions are AFAIK the only commonly accepted definitions about OO: 1/ an object is defined by identity, state and behaviour 2/ objects interacts by sending messages each other 3/ an OO program is made of interacting objects I let you find out whether Python meets these 3 definitions - and if Java does (hint : in Python, everything you can bind to a name is an object - this is not true in Java or C++). This is correct but it detracts from a more general problem of language paradigms. Assume you type 2+2 4 Now you are free to interpret this as a simple, primitive arithmetic operation but you can also claim that 2 sends an __add__ message to 2. Hereby the state of the 2 objects are not altered but a new 4 object is created. OO babble is more impressive isn't it? Actually it is simply wrong in the mentioned case and here is the proof: def foo(): return 2+2 import dis dis.dis(foo) 2 0 LOAD_CONST 2 (4) 3 RETURN_VALUE OO is a heuristic method used to understand the semantics of a programming language. It can also inspire language design but as you've rightly said: jugde yourself and see how far you get with it. Applying OO on interpreter level is by no means a sign of a high quality implementation whereas structuring programs in the large will likely benefit from class based organization and encapsulation. Of course one can also reverse the value hierarchy and find perverse joy in having a pure OO language but apply monkey patching everywhere. I suppose you know which language I'm talking about... -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tkinter-discuss] (newbie) can't invoke button for twice
On Sat, Sep 20, 2008 at 4:10 PM, dmitrey [EMAIL PROTECTED] wrote: hi all, I have the problem: a func has been binded to a Button: RunPause = Button(root, textvariable = t, command = lambda: invokeRunPause(p)) def invokeRunPause(p): if p.state == 'init': p.state = 'running' t.set('Pause') p.GUI_root.update_idletasks() p.tmp_result = p.solve(*p._args, **p._kwargs) elif p.state == 'running': So the problem is that I can't invoke the button RunPause till my calculations (in p.solve()) will be finished. I can observe it even graphically, the button doesn't respond when it is pressed. Could anyone provide a solution? It is not only the button that doesn't respond, the entire application won't respond if you are blocking tcl from processing anything. This call to p.solve blocks, and, in turn the interpreter can't process events and the GUI remains frozen till p.solve returns. Ideally you should break this p.solve in steps, so you can schedule next steps and the GUI will remain responsible, but if you can't break it, and if it doesn't make sense to run it in another process then you use a thread to solve this. Thank you ion advance, Dmitrey. -- View this message in context: http://www.nabble.com/%28newbie%29-can%27t-invoke-button-for-twice-tp19588292p19588292.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. ___ Tkinter-discuss mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tkinter-discuss -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sep 20, 3:22 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 20 Sep., 18:33, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The following definitions are AFAIK the only commonly accepted definitions about OO: 1/ an object is defined by identity, state and behaviour 2/ objects interacts by sending messages each other 3/ an OO program is made of interacting objects I let you find out whether Python meets these 3 definitions - and if Java does (hint : in Python, everything you can bind to a name is an object - this is not true in Java or C++). This is correct but it detracts from a more general problem of language paradigms. Assume you type 2+2 4 Now you are free to interpret this as a simple, primitive arithmetic operation but you can also claim that 2 sends an __add__ message to 2. Hereby the state of the 2 objects are not altered but a new 4 object is created. OO babble is more impressive isn't it? Actually it is simply wrong in the mentioned case and here is the proof: def foo(): return 2+2 import dis dis.dis(foo) 2 0 LOAD_CONST 2 (4) 3 RETURN_VALUE OO is a heuristic method used to understand the semantics of a programming language. It can also inspire language design but as you've rightly said: jugde yourself and see how far you get with it. Applying OO on interpreter level is by no means a sign of a high quality implementation whereas structuring programs in the large will likely benefit from class based organization and encapsulation. Of course one can also reverse the value hierarchy and find perverse joy in having a pure OO language but apply monkey patching everywhere. I suppose you know which language I'm talking about... It sounds like you think that you -can- write OO programs in Python, but you don't have to. I agree. -- http://mail.python.org/mailman/listinfo/python-list
explain slice assignment to newb
please explain this behavior to a newb: a = [1,2,3,4] b = [a,b,c,d] a [1, 2, 3, 4] b ['a', 'b', 'c', 'd'] a[0:2] [1, 2] a [1, 2, 3, 4] b[2:4] ['c', 'd'] a[0:2] = b[0:2] b[2:4] = a[2:4] a ['a', 'b', 3, 4] b ['a', 'b', 3, 4] -- http://mail.python.org/mailman/listinfo/python-list
Re: explain slice assignment to newb
On Sep 20, 2:20 pm, Andrew [EMAIL PROTECTED] wrote: please explain this behavior to a newb: a = [1,2,3,4] b = [a,b,c,d] a [1, 2, 3, 4] b ['a', 'b', 'c', 'd'] a[0:2] [1, 2] a [1, 2, 3, 4] b[2:4] ['c', 'd'] a[0:2] = b[0:2] b[2:4] = a[2:4] a ['a', 'b', 3, 4] b ['a', 'b', 3, 4] What else would you expect to happen? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
On Sep 20, 8:13 pm, [EMAIL PROTECTED] wrote: Duncan Booth: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be: for i in range(10, -1, -1): print i I'd use xrange there. Anyway, I have always felt that Python syntax not easy to understand at first sight, expecially when you try to convert a bit more complex inverted for loops from/to C to/from Python. It's one of the few cases where (for example) Pascal (loop) syntax wins a bit over Python syntax :-) Bye, bearophile That's a lot of responses guys. Thanks a lot i think i got it. Another question, are there any pointers in python (or iterators) for when i use a data structure that doesn't support random access? Thanks again, Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
On Sep 20, 8:13 pm, [EMAIL PROTECTED] wrote: Duncan Booth: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) The exact equivalent would be: for i in range(10, -1, -1): print i I'd use xrange there. Anyway, I have always felt that Python syntax not easy to understand at first sight, expecially when you try to convert a bit more complex inverted for loops from/to C to/from Python. It's one of the few cases where (for example) Pascal (loop) syntax wins a bit over Python syntax :-) Bye, bearophile Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. -- http://mail.python.org/mailman/listinfo/python-list
Re: writeable buffer and struct.pack_into and struct.unpck_from
En Sat, 20 Sep 2008 15:45:48 -0300, Tzury Bar Yochay [EMAIL PROTECTED] escribió: I can't find in the documentation the way to use these two functions. can someone share a simple code that utilize these two functions? struct.pack_into is intended to fill a buffer you got from somewhere, probably other language or process. ctypes.create_string_buffer may be used to create a writable buffer in python code. py from ctypes import create_string_buffer py b = create_string_buffer(10) py b.raw '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' py from struct import * py pack_into(hhh, b, 0, 1, 2, -1) py b.raw '\x01\x00\x02\x00\xff\xff\x00\x00\x00\x00' unpack_from does the opposite. Before Python 2.5, you had to use pack to create a string object, and then copy its contents into the destination buffer; using pack_into avoids the memory copy. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Alex Snast wrote: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. You should treat Python lists as an opaque item. You shouldn't concern yourself with the implementation details. Python lists are fast and optimized for most use cases. Unless you have specific needs for highly specialized data types, use lists. Just *don't* try to abuse lists by creating fancy stuff e.g. linked lists. The memory overhead is going to kill your app. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
En Sat, 20 Sep 2008 20:27:41 -0300, Alex Snast [EMAIL PROTECTED] escribió: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. Yes, lists are implemented as dynamic arrays (but you shouldn't care about it). Textbook linked lists are good for a CS course, but useless in most usual circumstances (think of memory fragmentation). There are AVL trees implemented in Python, but not built in. Read the Python Tutorial specially this section http://docs.python.org/tut/node7.html You may be interested in the collections module too http://docs.python.org/lib/module-collections.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
On Sat, 20 Sep 2008 16:22:31 -0700, Alex Snast wrote: That's a lot of responses guys. Thanks a lot i think i got it. Another question, are there any pointers in python (or iterators) for when i use a data structure that doesn't support random access? That surely depends on the data structure. Assume it supports sequential access: data[0], data[1], data[2], etc in that order without skipping or going backwards. Then you can simply do this: for item in data: process(item) which is the equivalent of this: try: i = 0 while True: process(data[i]) i += 1 except IndexError: pass # we're done The data structure might not support sequential indexing, but still support sequential access: for item in iter(data): process(item) If the data structure is some sort of binary tree, then you would use a standard tree-walking algorithm, something like this: def prefix_traversal(node): process(node.info) prefix_traversal(node.left) prefix_traversal(node.right) and similarly for infix and postfix. (Although the specific names 'left', 'right', 'info' are arbitrary.) If you don't have any specific knowledge of how to iterate over the data structure, then try reading the docs *wink*. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing pySerial
En Sat, 20 Sep 2008 02:01:14 -0300, eliben [EMAIL PROTECTED] escribió: Why are people preferring the python.org package over ActiveState's, which seems to be more complete and includes more modules (like pywin32) ? They do a hard work collecting, compiling and packaging the Python distribution with some added modules. But anything you get in the AS free version you can get directly from the original authors; downloading pywin32 from sourceforge isn't so difficult... And AFAIR, it took about 2 months the guys at ActiveState to release the 2.5 version after it came from python.org -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Hi guys!
Hello, this is Rajko Mackic from town Banjaluka, Bosnia and Herzegovina, also known as Cvrcko Does anyone know of any bars in town where I can swallow a bucket of cum? It can be either dog, horse or human cum. Also, does anyone know of any sex bars where people will shit in your mouth? I also like eating shit. -- Name: Rajko Mackic - Cvrcko Street adress: Ravnogorska 35 Town: 78000 Banja Luka Country: Bosnia and Herzegovina Home phone: +38751/302-886 Cell phone: +38765/544-699 Email adress: [EMAIL PROTECTED] ~ The new pumpkin rarely pulls Terrance, it teases Sharon instead. For Susan the tape's sad, beside me it's unique, whereas against you it's believing dirty. Hey, go reject a fork! Why did Alice open throughout all the boats? We can't explain poultices unless Woody will mercilessly judge afterwards. The frames, disks, and shirts are all fat and fresh. Who will we dine after Edwina wastes the thin mirror's goldsmith? It's very outer today, I'll recollect strangely or Christopher will learn the teachers. Hardly any humble brave tyrants hourly solve as the tired wrinkles cover. Hardly any distant buttons are short and other urban ointments are filthy, but will Robette receive that? Let's lift behind the deep highways, but don't promise the heavy diets. Who kicks badly, when Melvin burns the stale code before the autumn? Get your absolutely moulding barber within my cellar. If you will laugh Gay's hill against porters, it will incredibly climb the case. Some shopkeepers arrive, irrigate, and shout. Others sadly expect. To be pathetic or sticky will talk abysmal oranges to wickedly look. Are you healthy, I mean, moving above clever onions? While farmers partly taste pins, the powders often excuse against the blunt jackets. Generally Susanne will order the sticker, and if George actually seeks it too, the bowl will attempt with the polite lane. He can hate durable kettles above the rural bad ocean, whilst Oscar easily scolds them too. You eventually fill against Norma when the kind drapers irritate among the poor summer. As surprisingly as Dolf converses, you can dye the cap much more familiarly. Brion, still killing, behaves almost eerily, as the sauce changes on their coffee. You won't recommend me grasping about your lazy office. Almost no butchers steadily live the lost signal. Cyrus's hat improves among our desk after we sow towards it. Ralph measures the weaver within hers and wanly calls. Some cosmetic tags answer David, and they rigidly walk Quincy too. When Richard's elder gardner dreams, Mark cares for weak, closed islands. He might strongly fear think and plays our cheap, sour painters above a bathroom. I creep the active yogi and cook it in back of its dorm. Tell Katherine it's strong loving within a tree. Why will you jump the angry lower exits before Murray does? I am unbelievably bitter, so I wander you. How does Hector smell so regularly, whenever Ronald likes the solid twig very slowly? Julieta, have a hot printer. You won't clean it. Fucking don't join a dryer! She wants to nibble inner smogs under Usha's castle. She'd rather depart grudgingly than help with Bernadette's younger grocer. Other old dark cards will comb frantically alongside cans. Try pouring the monument's pretty cat and Oliver will attack you! Don't try to seek halfheartedly while you're jumping throughout a easy carpenter. He'll be climbing in front of good Cypriene until his enigma answers quietly. What doesn't Janet smell inadvertently? They are opening before the rain now, won't explain walnuts later. Some light long game covers pools outside Woodrow's rich film. Why did Oscar judge the pear with the handsome spoon? He will talk nearly if Julieta's tailor isn't wet. Just looking beside a ulcer through the store is too young for Woody to care it. Both filling now, Alejandro and Marty irritated the open rivers about smart envelope. Occasionally, dusts kill beside rude fires, unless they're sweet. Her pen was sharp, dull, and fears over the spring. Zack, on floors difficult and upper, attacks towards it, recollecting seemingly. We measure the raw sauce. They are rejecting throughout quiet, towards empty, in back of cold units. My wide potter won't clean before I comb it. If you'll pour Edward's camp with aches, it'll admiringly converse the cup. I was promising frogs to worthwhile Corinne, who's walking in back of the counter's stable. It can receive clean pickles, do you solve them? Many jugs will be weird lean carrots. Roger helps, then Walt stupidly believes a ugly lentil on Catherine's road. We tease them, then we weekly dream Zack and Annabel's blank candle. A lot of shallow dose or canyon, and she'll locally excuse everybody. If the bizarre balls can sow bimonthly, the hollow raindrop may love more ventilators. We laugh weekly, unless Jezebel grasps shoes outside Jimmie's puddle. Jimmy! You'll mould plates. Just now, I'll dine the bandage. All glad
Re: explain slice assignment to newb
Andrew wrote: please explain this behavior to a newb: Read the section on sequence slicing in the Library Reference. Use the interactive interpreter or IDLE to perform experiments, like you did, until you understand to your satisfaction. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
Christian Heimes: Unless you have specific needs for highly specialized data types, use lists. There's also the collections.deque for other related purposes. (I suggest people willing to look at some nice C code to read the sources of deque, Hettinger has created some refined code, very readable). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
On Sat, 20 Sep 2008 16:27:41 -0700, Alex Snast wrote: Another quick question please, is the List data structure just a dynamic array? If so how can you use static size array, linked list, AVL trees etcetera. Before I answer your question, I should say that you can go a LONG way with just the standard Python built-in data structures list, dict and set, plus a handful of standard modules like array and collections. It's often (but not always) better to modify an algorithm to use a built-in data structure than to try to implement your own. The underlying data structure for lists is implementation specific. Only the behaviour is specified by the language. In the standard Python implementation written in C (usually known as Python, although sometimes people explicitly describe it as CPython), lists are implemented as a fixed array of pointers. The array is periodically resized, either up or down, but only as needed. The largest consequence of that is that appending to the end of a list is much faster than inserting at the beginning of the list. Other implementations (IronPython, Jython, PyPy, CLPython...) are free to implement lists whatever way they need. If you want a static list, the simplest way is to create a list and simply not resize it. If you want to enforce that, here's a subclass to get you started: class StaticList(list): def _resize(self): raise RuntimeError(list can't be resized) extend = append = pop = insert = remove = \ __delitem__ = __delslice__ = _resize I haven't dealt with __setitem__ or __setslice__, because they're more complicated: you need to make sure the slice you're setting has the same size as the bit you're replacing, so that this is allowed: mylist[3:6] = [1, 2, 3] but not these: mylist[3:6] = [1, 2] mylist[3:6] = [1, 2, 3, 4] As for linked lists and trees, don't worry about pointers, just go ahead and implement them. # basic, no-frills tree class Node(object): def __init__(self, data, left=None, right=None): self.left = left self.right = right self.info = data tree = Node('top of the tree') tree.left = Node('left subtree') tree.right = Node('right subtree', None, Node('another subtree')) t = tree.right.right t.left = Node('yet another subtree') etc. The CPython implementation of dict is a hash table, and dicts are extremely fast and efficient. So long as you don't mind losing the order of insertion, you won't beat dicts for speed and efficiency in anything you write in pure Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
Kay Schluehr wrote: Actually it is simply wrong in the mentioned case and here is the proof: def foo(): return 2+2 import dis dis.dis(foo) 2 0 LOAD_CONST 2 (4) 3 RETURN_VALUE OO is a heuristic method used to understand the semantics of a programming language. It can also inspire language design but as you've rightly said: jugde yourself and see how far you get with it. It's not wrong. You have found a simple optimization. Lot's of compilers for lots of languages optimize code by code folding. Python's peephole optimizer replaces code like 2+2 with 4. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make a reverse for loop in python?
On Sun, 21 Sep 2008 01:56:59 +0200, Christian Heimes wrote: Just *don't* try to abuse lists by creating fancy stuff e.g. linked lists. The memory overhead is going to kill your app. I agree with your advice not to abuse lists, but not for the reason you give. The memory overhead of a linked list implemented on top of a Python list probably isn't going to be that much greater than a dict or a class. I think the real reasons why linked lists get a bad rep in Python are: (1) they're unnecessary 99% of the time; (2) when they are necessary, a better implementation is to use classes (e.g. see traceback objects); and (3) the standard Lisp idiom for lists is horribly inefficient in CPython: alist = [1, [2, [3, [4, [5, [6, []]] But that's primarily inefficient because of the number of method calls needed to access an item. There is some memory overhead, but memory is cheap and the overhead of using objects in the first place is far larger than the overhead of a few extra pointers. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On Sep 20, 8:06 pm, Christian Heimes [EMAIL PROTECTED] wrote: Kay Schluehr wrote: Actually it is simply wrong in the mentioned case and here is the proof: def foo(): return 2+2 import dis dis.dis(foo) 2 0 LOAD_CONST 2 (4) 3 RETURN_VALUE OO is a heuristic method used to understand the semantics of a programming language. It can also inspire language design but as you've rightly said: jugde yourself and see how far you get with it. It's not wrong. The meaning of the Python program is, internally, on a cycle-by-cycle basis, Object 2; send add( Object 2 ) to Object 2; Return object 4. CPython doesn't do this, but due to the fact that there are no cases in which that distinction affects the output, it's still an implementation of Python. Or at least, a practical implementation. You have found a simple optimization. Lot's of compilers for lots of languages optimize code by code folding. Python's peephole optimizer replaces code like 2+2 with 4. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: explain slice assignment to newb
On Sat, 20 Sep 2008 14:20:20 -0700 (PDT), Andrew [EMAIL PROTECTED] wrote: please explain this behavior to a newb: a = [1,2,3,4] b = [a,b,c,d] a[0:2] = b[0:2] The slice [0:2] represent positions 0 = x 2 Replaces the [1, 2] from [1, 2, 3, 4] with ['a', 'b'] Result: a = ['a', 'b', 3, 4] b[2:4] = a[2:4] The slice [2:4] represent positions 2 = x 4 Replaces the ['c', 'd'] from ['a', 'b', 'c', 'd'] with [3, 4] Result: b = ['a', 'b', 3, 4] a ['a', 'b', 3, 4] b ['a', 'b', 3, 4] Correct -- http://mail.python.org/mailman/listinfo/python-list
Re: improving a huge double-for cycle
On Sat, 20 Sep 2008 19:01:42 +0200, Bruno Desthuilliers wrote: Once again, sorry if me missing your correct answer drives you paranoid :-) What do you mean by that? How many other people have been talking about me? *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: writeable buffer and struct.pack_into and struct.unpck_from
On Sep 20, 6:42 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 20 Sep 2008 15:45:48 -0300, Tzury Bar Yochay [EMAIL PROTECTED] escribió: I can't find in the documentation the way to use these two functions. can someone share a simple code that utilize these two functions? struct.pack_into is intended to fill a buffer you got from somewhere, probably other language or process. ctypes.create_string_buffer may be used to create a writable buffer in python code. py from ctypes import create_string_buffer py b = create_string_buffer(10) py b.raw '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' py from struct import * py pack_into(hhh, b, 0, 1, 2, -1) py b.raw '\x01\x00\x02\x00\xff\xff\x00\x00\x00\x00' unpack_from does the opposite. Before Python 2.5, That was when Python broke string immutability with the ctypes module. you had to use pack to create a string object, and then copy its contents into the destination buffer; using pack_into avoids the memory copy. -- Gabriel Genellina 'mmap' seems to have always offered random-access writes. A search through the implementation for tp_as_buffer returns a lot of zeros however. -- http://mail.python.org/mailman/listinfo/python-list
Re: improving a huge double-for cycle
On Sep 20, 9:20 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Sat, 20 Sep 2008 19:01:42 +0200, Bruno Desthuilliers wrote: Once again, sorry if me missing your correct answer drives you paranoid :-) What do you mean by that? How many other people have been talking about me? *wink* -- Steven Why, no fewer than usual! *wink* -- http://mail.python.org/mailman/listinfo/python-list
BeautifulSoup and Problem Tables
Hi I would appreciate some help. I am trying to learn Python and want to use BeautifulSoup to pull some data from tables. I was really psyched earlier tonight when I discovered that I could do this from BeautifulSoup import BeautifulSoup bst=file(rc:\bstest.htm).read() soup=BeautifulSoup(bst) rows=soup.findAll('tr') len(rows) a=len(rows[0].findAll('td')) b=len(rows[1].findAll('td')) c=len(rows[2].findAll('td')) d=len(rows[3].findAll('td')) e=len(rows[4].findAll('td')) f=len(rows[5].findAll('td')) g=len(rows[6].findAll('td')) h=len(rows[8].findAll('td')) i=len(rows[9].findAll('td')) j=len(rows[10].findAll('td')) k=rows[1].findAll('td')[1].contents[0] So here I am chortling to myself thinking this is too easy. I know that the data columns are in rows[0] and so I can learn some more python to figure out how to create tuples so I can lable each data item using the row and column headings plucked from the contents. However, I discovered that my tables have inconsistent numbers of rows. Even though the tables look pretty. It might be that the column heading for the third column is Apples but the value for Apples in the fourth row is not in the third position in the row but the fourth. Now I am reluctant to make any assumptions because the tables were created inconsistently. What I mean is that in some tables if there is no value for a row/column intersection then there is a blank line, in other tables if there is no value for a row/column intersection then the length of k (as above) is 0. I have been Googling for some insight into this and I have not been successful finding anything. I would really appreciate any suggestions or some direction about how to better describe the problem. -- http://mail.python.org/mailman/listinfo/python-list
Quick Secured Pharmacy Online. bhsrf
Start saving, best online pharmacy here http://gjlabeh.cuchezfarg.com/?cdfikmabehxwvrsygzchcmjl -- http://mail.python.org/mailman/listinfo/python-list
Quick Secured Pharmacy Online. hr3tn
Start saving, best online pharmacy here http://gjlabeh.cuchezfarg.com/?cdfikmabehxwvrsygzchcmjl -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
In article [EMAIL PROTECTED], Thomas G. Willis [EMAIL PROTECTED] wrote: On Sep 20, 5:23=A0am, candide [EMAIL PROTECTED] wrote: Excerpt quoted fromhttp://www.astro.ufl.edu/~warner/prog/python.html: About Python: Python is a high level scripting language with object oriented features. (...) Python supports OOP and classes to an extent, but is not a full OOP language. Thanks for any comment. My comment is Who cares? I was always under the impression that if any language truly was OO it would be smalltalk. And I don't derive any benefit from smalltalk at all. I do however derive substantial benefit from other languages that OO zealots would likely poo poo on including python. ...some experts might say a C++ program is not object-oriented without inheritance and virtual functions. As one of the early Smalltalk implementors myself, I can say they are full of themselves. --zconcept -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Argue for your limitations, and sure enough they're yours. --Richard Bach -- http://mail.python.org/mailman/listinfo/python-list
Re: Not fully OO ?
On 20 Sep., 23:07, Aaron \Castironpi\ Brady [EMAIL PROTECTED] wrote: On Sep 20, 3:22 pm, Kay Schluehr [EMAIL PROTECTED] wrote: On 20 Sep., 18:33, Bruno Desthuilliers [EMAIL PROTECTED] wrote: The following definitions are AFAIK the only commonly accepted definitions about OO: 1/ an object is defined by identity, state and behaviour 2/ objects interacts by sending messages each other 3/ an OO program is made of interacting objects I let you find out whether Python meets these 3 definitions - and if Java does (hint : in Python, everything you can bind to a name is an object - this is not true in Java or C++). This is correct but it detracts from a more general problem of language paradigms. Assume you type 2+2 4 Now you are free to interpret this as a simple, primitive arithmetic operation but you can also claim that 2 sends an __add__ message to 2. Hereby the state of the 2 objects are not altered but a new 4 object is created. OO babble is more impressive isn't it? Actually it is simply wrong in the mentioned case and here is the proof: def foo(): return 2+2 import dis dis.dis(foo) 2 0 LOAD_CONST 2 (4) 3 RETURN_VALUE OO is a heuristic method used to understand the semantics of a programming language. It can also inspire language design but as you've rightly said: jugde yourself and see how far you get with it. Applying OO on interpreter level is by no means a sign of a high quality implementation whereas structuring programs in the large will likely benefit from class based organization and encapsulation. Of course one can also reverse the value hierarchy and find perverse joy in having a pure OO language but apply monkey patching everywhere. I suppose you know which language I'm talking about... It sounds like you think that you -can- write OO programs in Python, but you don't have to. I agree. The whole point of OO is providing high level ( system level ) not low level ( interpreter level ) semantics. Partitioning a system into isolated and communicating objects is a strong and important metaphor. Recently there were some comments on the web that mentioned Erlang to be pretty much OO in this respect although Erlang is functional and has no base level notion of an object. It's even well known that Joe Armstrong holds low opinions about the entire object business. Notice that I believe that the popular meme that OO is bolted on Python has little if nothing to do with OO itself but with API consistency. When people have to type len(x) instead of x.len() this breaks their expectations on how the language has to behave. -- http://mail.python.org/mailman/listinfo/python-list
Re: writeable buffer and struct.pack_into and struct.unpck_from
Thanks Gabriel, I was missing the information how to create a writable buffer. -- http://mail.python.org/mailman/listinfo/python-list
[issue1688] Incorrectly displayed non ascii characters in prompt using input() - Python 3.0a2
Vlastimil Brom [EMAIL PROTECTED] added the comment: While I am not sure about the status of this somewhat older issue, I just wanted to mention, that the behaviour remains the same in Python 3.0rc1 (XPh SP3, Czech) Python 3.0rc1 (r30rc1:66507, Sep 18 2008, 14:47:08) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. input(ěšč: ) ─Ť┼í─Ź: řžý 'řžý' print(ěšč: ) ěšč: Is the patch above supposed to have been committed, or are there yet another difficulties? (Not that it is a huge problem (for me), as applications dealing with non ascii text probably would use a gui, rather than relying on a console, but it's a kind of surprising.) ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3891] collections.deque should have empty() method
Raymond Hettinger [EMAIL PROTECTED] added the comment: Sorry Roy, I think you're way off base on this one. There are standard ways to test for an empty container if c: or if len(c) or if len(c) 0. This is Python 101. Closing this one as it has nothing to do specifically with collections.deque() and is already covered in the Ref Manual. -- resolution: - works for me status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3891 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3905] subprocess failing in GUI applications on Windows
Georg Brandl [EMAIL PROTECTED] added the comment: There are also instances of set_daemon left in socketserver and multiprocessing/dummy. How is that possible? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3905 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3905] subprocess failing in GUI applications on Windows
Georg Brandl [EMAIL PROTECTED] added the comment: Benjamin, I think you're responsible. -- assignee: - benjamin.peterson nosy: +benjamin.peterson, georg.brandl ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3905 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1688] Incorrectly displayed non ascii characters in prompt using input() - Python 3.0a2
Martin v. Löwis [EMAIL PROTECTED] added the comment: Amaury, what further review of the patch do you desire? I had already commented that I consider the patch correct, except that it might use stdout_encoding instead. Also, I wouldn't consider this a release blocker. It is somewhat annoying that input produces moji-bake in certain cases (i.e. non-ASCII characters in the prompt, and a non-UTF-8 terminal), but if the patch wouldn't make it into 3.0, we can still fix it in 3.0.1. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3905] subprocess failing in GUI applications on Windows
Benjamin Peterson [EMAIL PROTECTED] added the comment: The idle problem has already been fixed, and I got the socket server one in r66520. -- assignee: benjamin.peterson - ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3905 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1688] Incorrectly displayed non ascii characters in prompt using input() - Python 3.0a2
Guido van Rossum [EMAIL PROTECTED] added the comment: Given MvL's review, assuming it fixes the Czech problem, I'm all for applying it. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3905] subprocess failing in GUI applications on Windows
Jean-Michel Fauth [EMAIL PROTECTED] added the comment: Just for information and from an end user perspective. I have tried to replace the socketserver.py from the original 3.0rc1 distribution by the socketserver.py as proposed by Benjamin Peterson (r66520). Script difference (line 568): if self.daemon_threads: t.daemon = True t.start() and if self.daemon_threads: t.set_daemon(True) t.start() Unfortunately, no luck, I'm still getting exactly the same error messages, the msg box and the raised AttributeError: AttributeError: 'Thread' object has no attribute 'set_daemon' ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3905 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3915] Broken link in 14.7 curses, Python Library Reference
New submission from Jason Etheridge [EMAIL PROTECTED]: In http://docs.python.org/lib/module-curses.html, the link Curses Programming with Python is broken. It links to http://www.python.org/doc/howto/curses/curses.html, which no longer exists. I found the page externally at http://www.amk.ca/python/howto/curses/. -- assignee: georg.brandl components: Documentation messages: 73469 nosy: georg.brandl, jasoneth severity: normal status: open title: Broken link in 14.7 curses, Python Library Reference type: behavior versions: Python 2.5 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3911] ftplib.FTP.makeport() bug
Giampaolo Rodola' [EMAIL PROTECTED] added the comment: Would you like to contribute a patch? Ok. I started working on a patch which implements a dummy asyncore-based FTP server including tests for all basic FTP() class methods. I'll contribute a patch as soon as I'll wrote IPv6 tests. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3911 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1688] Incorrectly displayed non ascii characters in prompt using input() - Python 3.0a2
Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment: Here is a new version of the patch: the PyString* functions were renamed to PyBytes*, and it now uses stdout_encoding. About the release blocker status: I agree it is not so important, I just wanted to express my it's been here for long, it's almost ready, it would be a pity not to have it in the final 3.0 feelings. -- keywords: +patch Added file: http://bugs.python.org/file11531/inputprompt.patch ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3825] Major reworking of Python 2.5.2 re module
Changes by Matthew Barnett [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file11530/regex_2.6rc2.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3825 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com