ANN (Screencast): Using python at WebFaction
Hello everyone, WebFaction (formerly Python-Hosting.com) have just released a screencast demo of their control panel. The 6 minute demo shows how you can setup some sites in a few clicks, using a variety of applications (including some Python ones such as Django and TurboGears). The one-click installer already supports all major tools, including Rails, WordPress, Django, TurboGears, Plone, Trac and Subversion, but also lightweight tools such as static HTML, CGI or PHP. The demo is available at: http://blog.webfaction.com/control-panel-demo Remi. http://www.webfaction.com - Hosting for an agile web -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: wx.Yield() during socket timeout
Kiran wrote: Hello All, I am creating a socket connection in order to read and write to a location. My problem is,the gui becomes unresponsive if the socket times out. I know that a good solution is to have the socket read and write with a thread. However, I have tried this and have a problem where ONLY on linux does the program crash, it DOES NOT crash on windows xp. I have been trying to figure out why for about a week and have just given up. You must have a bug in your threading code. I am doing something similar to what you describe, and it works perfectly, on Windows and on Linux. Threading *is* the correct approach for what you are attempting. Don't give up. Try to isolate where the crash happens, and post the relevant section of code here. If I can't spot the error, there is a good chance someone else will. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Can PyObjC be used on shared Mac OS X hosting?
Does anyone have experience with (or failing that, theoretical knowledge about) installing using the PyObjC bridge on a Mac OS X machine in a context where one doesn't have root/admin access (and therefore can't install things in conventional locations)? Can such a thing be done? -- http://mail.python.org/mailman/listinfo/python-list
Re: python + postgres psql + os.popen
damacy írta: hello, everyone. i am trying to write a program which executes SQL commands stored in .sql files. i wrote a function called psql() whose contents look like the following. ... os.popen(command) file = os.popen(command, 'w') file.write(password) file.close() ... where command looks like psql -h [host] -d [dbname] -U [username] -W -f [filename] this works well. however, it does not show me any warning nor error messages if there is one. for example, i am trying to create a table which already exists in the database, it should show me a warning/error message saying there already is one present in the database, or something like that. can anyone help me? You can put this in the beginning of your SQL file: \set ON_ERROR_STOP If you also want to know what command caused the error: \set ECHO all You can also use a library written for Python. For example, psycopg http://initd.org/projects/psycopg1 Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
David Hopwood wrote: Marshall wrote: Chris Smith wrote: Marshall [EMAIL PROTECTED] wrote: I think what this highlights is the fact that our existing terminology is not up to the task of representing all the possible design choices we could make. Some parts of dynamic vs. static a mutually exclusive; some parts are orthogonal. Really? I can see that in a strong enough static type system, many dynamic typing features would become unobservable and therefore would be pragmatically excluded from any probable implementations... but I don't see any other kind of mutual exclusion between the two. Well, it strikes me that some of what the dynamic camp likes is the actual *absence* of declared types, or the necessity of having them. So why aren't they happy with something like, say, Alice ML, which is statically typed, but has a dynamic type and type inference? I mean this as a serious question. Note: I haven't yet worked with such a language, but here is my take anyway. A statically type language requires you to think about two models of your program at the same time: the static type model and the dynamic behavioral model. A static type system ensures that these two _different_ (that's important!) perspectives are always in sync. This is especially valuable in settings where you know your domain well and want to rely on feedback by your compiler that you haven't made any mistakes in encoding your knowledge. (A static type system based on type inferencing doesn't essentially change the requirement to think in two models at the same time.) A dynamically typed language is especially well suited when you don't (yet) have a good idea about your domain and you want to use programming especially to explore that domain. Some static typing advocates claim that static typing is still suitable for exploring domains because of the compiler's feedback about the preliminary encoding of your incomplete knowledge, but the disadvantages are a) that you still have to think about two models at the same time when you don't even have _one_ model ready and b) that you cannot just run your incomplete program to see what it does as part of your exploration. A statically typed language with a dynamic type treats dynamic typing as the exception, not as the general approach, so this doesn't help a lot in the second setting (or so it seems to me). A language like Common Lisp treats static typing as the exception, so you can write a program without static types / type checks, but later on add type declarations as soon as you get a better understanding of your domain. Common Lisp implementations like CMUCL or SBCL even include static type inference to aid you here, which gives you warnings but still allows you to run a program even in the presence of static type errors. I guess the feedback you get from such a system is probably not strong enough to be appreciated by static typing advocates in the first setting (where you have a good understanding of your domain). Pascal -- 3rd European Lisp Workshop July 3 - Nantes, France - co-located with ECOOP 2006 http://lisp-ecoop06.bknr.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What is a type error?
Chris Smith wrote: While this effort to salvage the term type error in dynamic languages is interesting, I fear it will fail. Either we'll all have to admit that type in the dynamic sense is a psychological concept with no precise technical definition (as was at least hinted by Anton's post earlier, whether intentionally or not) or someone is going to have to propose a technical meaning that makes sense, independently of what is meant by type in a static system. What about this: You get a type error when the program attempts to invoke an operation on values that are not appropriate for this operation. Examples: adding numbers to strings; determining the string-length of a number; applying a function on the wrong number of parameters; applying a non-function; accessing an array with out-of-bound indexes; etc. In the terminology I'm suggesting, the object has no type in this language (assuming we're talking about a Smalltalk-like language without any type system extensions). I suspect you'll see the Smalltalk version of the objections raised in response to my post earlier. In other words, whatever terminology you think is consistent, you'll probably have a tough time convincing Smalltalkers to stop saying type if they did before. If you exclude message not understood as a type error, then I think you're excluding type errors from Smalltalk entirely, which contradicts the psychological understanding again. Sending a message to an object that does not understand that message is a type error. The message not understood machinery can be seen either as a way to escape from this type error in case it occurs and allow the program to still do something useful, or to actually remove (some) potential type errors. Which view you take probably depends on what your concrete implementation of message not understood does. For example, if it simply forwards the message to another object that is known to be able to respond to it, then you remove a potential type error; however, if it pops up a dialog box to ask the user how to continue from here, it is still a type error, but just gives you a way to deal with it at runtime. Pascal -- 3rd European Lisp Workshop July 3 - Nantes, France - co-located with ECOOP 2006 http://lisp-ecoop06.bknr.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: python + postgres psql + os.popen
damacy wrote: hello, everyone. i am trying to write a program which executes SQL commands stored in .sql files. i wrote a function called psql() whose contents look like the following. ... os.popen(command) file = os.popen(command, 'w') file.write(password) file.close() ... where command looks like psql -h [host] -d [dbname] -U [username] -W -f [filename] this works well. But is a very strange way to access a RDBMS from Python code. Are you aware of the existence of db modules ? can anyone help me? http://www.python.org/dev/peps/pep-0249/ http://initd.org/projects/psycopg1 -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
How to generate all permutations of a string?
Hi guys, I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) def permute(string): l= [] l.append(string) string1 = '' for i in range(0,len(string)-1,1): string1 = string[1:len(string)] + string[:1] l.append(string1) string = string1 return l -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to split a class definition?
[EMAIL PROTECTED] wrote: Hi, Is it possible to split a Class definition over two or more text files? Yes, but not directly. Could you tell us why you think you have such a need ? (if so, how:) Please answer my previous question first !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython GUI designer
[EMAIL PROTECTED] wrote: Are there any good commercial project built with wx ? I am a newbie and a have to write a small application in Python. I was wondering which optin would be best for me in terms of least learning curve and getting the final product ASAP. Thanks It's not a commercial project, but the current BitTorrent beta's (versions 4.9.x) are written with wx ... To me, the appearant lack of a good and easy-to-use multi-column tree widget was a showstopper to diving deeper into wxPython, though. I decided to use PyGTK for now, which I'm a bit more familiar already and which I know has a multi-column tree good enough for me (and I found it easy to add inline-editing too). I don't know how good PyQT is on windows; other than that, in my opinion PyGTK gives the best / most complete GUI for Python with reasonable ease-of-programming. Cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: tkMessagebox.askyesno always returns False
It's a moderately large application, and so impractical to post it all. I'll have a go at isolating circumstances where this fault occurs then post the preceeding code - but not before this evening (London time) when I might have some free time. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Can PyObjC be used on shared Mac OS X hosting?
weston schrieb: Does anyone have experience with (or failing that, theoretical knowledge about) installing using the PyObjC bridge on a Mac OS X machine in a context where one doesn't have root/admin access (and therefore can't install things in conventional locations)? Can such a thing be done? Yes, it can be done. You can install a python frameworkbuild in ~/Library/Frameworks, and then install pyobjc using that python installation. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing two arrays
Thanks Diez, It will take a little while for this one to sink in but it gets the job done now and will for future cases. /Sheldon Diez B. Roggisch skrev: print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == y))] instead. Diez Hi Diez, I wish I say that I understood what you wrote here but I can't. Do you mind explaining a little more? I actually made a typo, instead of where in the above use if. and the whole thing won't compute what you are after. This will: [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals] Sorry for that. Its a nested list-comprehension. Actually, the outer thingy is a list-comprehension while the inner is a generator expression. There is of course a difference, but for now this doesn't matter too much. a list comprehension of form [expression for variable in iterable if condition] is a more compact form for result = [] for variable in iterable: if condition: result.append(expression) A generator expression works the same with () instead of []. Now let's decompose the above statment: (x == y for x, y in zip(a, b) )) variable = x, y iterable = zip(a, b) expression = x == y So: the iterable is returned by the function zip. That is a built-in which will take 2 or more lists and return a list of tuples, where the first element is from the first list, then the second and so on. So your example lists become: a = [0,1,2,5,6,6] b = [5,4,1,6,4,6] zip(a, b) = [(0,5), (1,4), (2,1), (5,6), (6,4), (6,6)] So iterating over this yields the pairs of (0,5) and so forth. Next thing is that with x, y = p python unpacks a tuple and refers to its contents by name x for the first one and y for the second. So overall, we loop in sync over both lists, and getting x and y to point to the corresponding elements. Now the expression x == y will result True if x == y - False otherwise. So the result of the inner listcomp/genexp looks like this: res = [False, False, False, False, False, True] As you can see: for each pair x,y in the original lists we come up with the result of comparing them. Now the outer listcomp using res instead of the genexps for clarity reads like this: [i for i, equals in enumerate(res) if equals] variable = i, equals iterable = enumerate(res) expression = i condition = equals enumerate is another built-in that takes an iterable and returns a tuple of (pos, element) for each element in the iterable. So for our list, it will return: [(0, False), (1, False), (2, False), (3, False), (4, False), (5, True)] These tupkes values are assigened to i and equals for each element of the above list. The condtion equals will then guarantee that only those expressions are evaluated where equals is True - the last pair, so to speak. The expression then only stores the index i. Which will give us the desired result. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing two arrays
Thanks Diez, It will take a little while for this one to sink in but it gets the job done now and will for future cases. /Sheldon Diez B. Roggisch skrev: print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == y))] instead. Diez Hi Diez, I wish I say that I understood what you wrote here but I can't. Do you mind explaining a little more? I actually made a typo, instead of where in the above use if. and the whole thing won't compute what you are after. This will: [i for i, equals in enumerate((x == y for x, y in zip(a, b))) if equals] Sorry for that. Its a nested list-comprehension. Actually, the outer thingy is a list-comprehension while the inner is a generator expression. There is of course a difference, but for now this doesn't matter too much. a list comprehension of form [expression for variable in iterable if condition] is a more compact form for result = [] for variable in iterable: if condition: result.append(expression) A generator expression works the same with () instead of []. Now let's decompose the above statment: (x == y for x, y in zip(a, b) )) variable = x, y iterable = zip(a, b) expression = x == y So: the iterable is returned by the function zip. That is a built-in which will take 2 or more lists and return a list of tuples, where the first element is from the first list, then the second and so on. So your example lists become: a = [0,1,2,5,6,6] b = [5,4,1,6,4,6] zip(a, b) = [(0,5), (1,4), (2,1), (5,6), (6,4), (6,6)] So iterating over this yields the pairs of (0,5) and so forth. Next thing is that with x, y = p python unpacks a tuple and refers to its contents by name x for the first one and y for the second. So overall, we loop in sync over both lists, and getting x and y to point to the corresponding elements. Now the expression x == y will result True if x == y - False otherwise. So the result of the inner listcomp/genexp looks like this: res = [False, False, False, False, False, True] As you can see: for each pair x,y in the original lists we come up with the result of comparing them. Now the outer listcomp using res instead of the genexps for clarity reads like this: [i for i, equals in enumerate(res) if equals] variable = i, equals iterable = enumerate(res) expression = i condition = equals enumerate is another built-in that takes an iterable and returns a tuple of (pos, element) for each element in the iterable. So for our list, it will return: [(0, False), (1, False), (2, False), (3, False), (4, False), (5, True)] These tupkes values are assigened to i and equals for each element of the above list. The condtion equals will then guarantee that only those expressions are evaluated where equals is True - the last pair, so to speak. The expression then only stores the index i. Which will give us the desired result. Diez -- http://mail.python.org/mailman/listinfo/python-list
OverflowError: math range error...
Hi, I have a written a script that will check to see if the divisor is zero before executing but python will not allow this: if statistic_array[0:4] 0.0: statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array \ [0,4]),1.0))/100.0 Does anyone know why Python is complaining: statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array[0,4]),1.0))/100.0 OverflowError: math range error and how do I get around this problem? This stupid because there is a if statement preventing this dividing by zero. Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
In article [EMAIL PROTECTED], Girish Sahani [EMAIL PROTECTED] wrote: I want to generate all permutations of a string. def permute(Seq) : generator which yields successive permutations of the elements of Seq. if len(Seq) == 0 : yield () else : for i in range(0, len(Seq)) : for rest in permute(Seq[:i] + Seq[i + 1:]) : yield (Seq[i],) + rest #end for #end for #end if #end permute -- http://mail.python.org/mailman/listinfo/python-list
Re: Cycles between package imports
In article [EMAIL PROTECTED], Martin Blais [EMAIL PROTECTED] wrote: On 18 Jun 2006 05:25:14 -0700, John Roth [EMAIL PROTECTED] wrote: The general rule is: don't do that. It doesn't work, and the hoops you have to go through to force it to work are so complex and bizzare that they're not worth it. Redesign the modules so you don't have cyclic dependencies. This is a matter completely aside the question. No it isn't. I agree with John Roth. Whether it's worth it or not depends on the specific case --not included in the example-- and in the case where it shows up in my code, removing the cycle actually made sense (it does, most of the time, but not always). See, even you are unable to come up with an example where a cyclic import makes sense. In general, the complications they introduce are simply not worth it. This was discovered decades ago, during the development of languages like Ada and Modula-2 which could do automatic initialization and finalization of library modules arranged by the compiler/linker system. -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? If the data is composed by a large number of records, like a database dump of some sort, then probably you could have a look to a stax processor for python like pulldom. In this way you could process each single record one at the time, without loading the entiere document. Regards, Antonio -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
A statically type language requires you to think about two models of your program at the same time: the static type model and the dynamic behavioral model. A static type system ensures that these two _different_ (that's important!) perspectives are always in sync. I have trouble understanding your use of the wording Model of a program. If it is a system that behaves according to the rules of your program then statements about your program should consider *all* possible models. If it is a formal system that makes statements about properties of your program than the static type system is a simplified model that is suitable for automatic analysis and your runtime model is in most cases nonexistent. Can you give a definition of a model of a program? Can you explain why Lisp doesn't have two (SBCL does do a lot of typechecking and gives type errors)? This is especially valuable in settings where you know your domain well and want to rely on feedback by your compiler that you haven't made any mistakes in encoding your knowledge. (A static type system based on type inferencing doesn't essentially change the requirement to think in two models at the same time.) It is also valuable when you don't know your domain very well and you want to rely on feedback by your compiler that you haven't made any mistakes in encoding your limited knowledge A dynamically typed language is especially well suited when you don't (yet) have a good idea about your domain and you want to use programming especially to explore that domain. our domain). In the sense that you can start writing code without the compiler pointing out all but the most glaring holes in your program, I agree. Most of your arguments aren't very convincing and the thruth is that I have seem lisp programmers using the debugger to find out that you can't add a number and a hastable. The static view was not there and the dynamic view must have been too complicated so they had nothing to think about. Immanuel -- http://mail.python.org/mailman/listinfo/python-list
Help req: Problems with MySQLdb
I have written an application that connects to a database on a remote machine which uses MySQLdb 1.2.0. The application works perfectly when connecting to the database from a remote machine, however when it attempts to connect to a database on the same machine a connection error is generated. I have attached what little info I can below. DBSERVERIP = 1.2.3.4 db = MySQLdb.connect(host=DBSERVERIP, user=user, passwd=password, db=nuke) --- it refuses to connect on the above line and the exception is caught and a message displayed. I have tried changing the server IP to localhost or the hostname, however the same problem arises. Information: Python 2.3.5, MySQLdb 1.2.0, MySQL 5.0.21 and Windows 2K pro. I would be grateful for any help with this problem. Kind regards, rod -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
Mind, that Lawrence's solution may contain doubles: [ i for i in permute(aa) ] [('a', 'a'), ('a', 'a')] If you don't want this, use sets. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
In article [EMAIL PROTECTED], Girish Sahani [EMAIL PROTECTED] wrote: I want to generate all permutations of a string. def permute(Seq) : generator which yields successive permutations of the elements of Seq. if len(Seq) == 0 : yield () else : for i in range(0, len(Seq)) : for rest in permute(Seq[:i] + Seq[i + 1:]) : yield (Seq[i],) + rest #end for #end for #end if #end permute thanks lawrence...however this func doesnt return the permuted strings, so i added some code as follows to generate a list of all the permutations: def permute(seq): l = [] if len(seq) == 0: yield [] else: for i in range(0,len(seq)): for rest in permute(seq[:i] + seq[i+1:]): yield (seq[i],) + rest for t in permute(seq): l.append(''.join(t)) return l This gives me a syntax error! I need to output a list that has all the permutations of the input string. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python to PHP Login System (HTTP Post)
You need to use httplib. http://docs.python.org/lib/httplib-examples.html Jeethu Rao -- http://mail.python.org/mailman/listinfo/python-list
Re: Help req: Problems with MySQLdb
Hi, Thanks for your email. Well I am kind of new to exceptions in Python, but here is the code used below, as you can see it is somewhat basic. Is there a way to display more information about the exception? Best, rod try: #Exception handler for database queries db = MySQLdb.connect(host=DBSERVERIP, user=user, passwd=password, db=nuke) except: print A database connection error has occurred return False else: #The rest of the program Sybren Stuvel wrote: rodmc enlightened us with: --- it refuses to connect on the above line and the exception is caught and a message displayed. So why do you think this exception and the error message contain no useful information at all? Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem on win xp and run time error
Chris Lambacher wrote: On Sat, Jun 17, 2006 at 07:32:34AM +, Michele Petrazzo wrote: Chris Lambacher wrote: On Fri, Jun 16, 2006 at 06:11:53PM +, Michele Petrazzo wrote: Hi list, just found in this moment that my applications stop to work with win xp and receive this error: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. (Note that the same application [python source code + py2exe] with python 2.3.x work well!) Don't use the single file executatble option with py2exe and the problem will go away. I'm not using that option! (that has also problems on win9x with python+wx) Do you get the problem when you are not using py2exe? That will be your real clue about what the culprit is. No, but... I'm not using any of the bundle_files options, but only: zipfile = lib/libraries.zip Try setting that to the default value for the moment and see if it gets you anywhere. You might also want to try an older version of py2exe. I would blame an interaction between py2exe and some extension you are using, unless you can get it to happen without py2exe. Was, I think, a win problem because after the last windows update all now work! Thanks for the support, Michele -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Marshall wrote: Andreas Rossberg wrote: Chris Uppal wrote: I have never been very happy with relating type to sets of values (objects, whatever). Indeed, this view is much too narrow. In particular, it cannot explain abstract types, which is *the* central aspect of decent type systems. What prohibits us from describing an abstract type as a set of values? If you identify an abstract type with the set of underlying values then it is equivalent to the underlying representation type, i.e. there is no abstraction. There were papers observing this as early as 1970. References? This is 1973, actually, but most relevant: James Morris Types Are Not Sets. Proc. 1st ACM Symposium on Principles of Programming Languages, 1973 (There are also theoretic problems with the types-as-sets view, because sufficiently rich type systems can no longer be given direct models in standard set theory. For example, first-class polymorphism would run afoul the axiom of foundation.) There is no reason why we must limit ourselves to standard set theory any more than we have to limit ourselves to standard type theory. Both are progressing, and set theory seems to me to be a good choice for a foundation. What else would you use? I'm no expert here, but Category Theory is a preferred choice in many areas of PLT. - Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Rob Warnock wrote: Here's what the Scheme Standard has to say: http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-4.html 1.1 Semantics ... Scheme has latent as opposed to manifest types. Types are assoc- iated with values (also called objects) rather than with variables. (Some authors refer to languages with latent types as weakly typed or dynamically typed languages.) Other languages with latent types are APL, Snobol, and other dialects of Lisp. Languages with manifest types (sometimes referred to as strongly typed or statically typed languages) include Algol 60, Pascal, and C. Maybe this is the original source of the myth that static typing is all about assigning types to variables... With all my respect to the Scheme people, I'm afraid this paragraph is pretty off, no matter where you stand. Besides the issue just mentioned it equates manifest with static types. I understand manifest to mean explicit in code, which of course is nonsense - static typing does not require explicit types. Also, I never heard weakly typed used in the way they suggest - in my book, C is a weakly typed language (= typed, but grossly unsound). To me, the word latent means that when handed a value of unknown type at runtime, I can look at it or perform TYPE-OF on it or TYPECASE or something and thereby discover its actual type at the moment[1], whereas manifest means that types[2] are lexically apparent in the code. Mh, I'd say typecase is actually a form of reflection, which is yet a different issue. Moreover, there are statically typed languages with typecase (e.g. Modula-3, and several more modern ones) or related constructs (consider instanceof). - Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
[EMAIL PROTECTED] wrote: A statically type language requires you to think about two models of your program at the same time: the static type model and the dynamic behavioral model. A static type system ensures that these two _different_ (that's important!) perspectives are always in sync. I have trouble understanding your use of the wording Model of a program. If it is a system that behaves according to the rules of your program then statements about your program should consider *all* possible models. If it is a formal system that makes statements about properties of your program than the static type system is a simplified model that is suitable for automatic analysis and your runtime model is in most cases nonexistent. Can you give a definition of a model of a program? Can you explain why Lisp doesn't have two (SBCL does do a lot of typechecking and gives type errors)? I wasn't talking about models that the language implementation may or may not have, but the models that I as a programmer must have in order to convince the compiler to let me program run. Consider a simple expression like 'a + b': In a dynamically typed language, all I need to have in mind is that the program will attempt to add two numbers. In a statically typed language, I additionally need to know that there must a guarantee that a and b will always hold numbers. In a trivial example like this, this doesn't hurt a lot, but can be problematic as soon as the program size grows. This is especially valuable in settings where you know your domain well and want to rely on feedback by your compiler that you haven't made any mistakes in encoding your knowledge. (A static type system based on type inferencing doesn't essentially change the requirement to think in two models at the same time.) It is also valuable when you don't know your domain very well and you want to rely on feedback by your compiler that you haven't made any mistakes in encoding your limited knowledge I have more or less used exactly the same words in the paragraph that followed the one you cited from my previous posting, and I have already given a reply there. A dynamically typed language is especially well suited when you don't (yet) have a good idea about your domain and you want to use programming especially to explore that domain. our domain). In the sense that you can start writing code without the compiler pointing out all but the most glaring holes in your program, I agree. I don't know what language environments you are used to, but the Common Lisp compilers I use always point out the most glaring holes in my programs. But maybe I just have trouble understanding your use of the wording most glaring holes. Can you give a definition of most glaring holes? ;) Most of your arguments aren't very convincing and the thruth is that I have seem lisp programmers using the debugger to find out that you can't add a number and a hastable. The static view was not there and the dynamic view must have been too complicated so they had nothing to think about. We have all seen less-than-average programmers who would fail in all kinds of languages. What they do is typically not very illuminating. My goal is not to convince anyone, my goal is to illustrate for those who are interested in getting a possibly different perspective. Pascal -- 3rd European Lisp Workshop July 3 - Nantes, France - co-located with ECOOP 2006 http://lisp-ecoop06.bknr.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Help req: Problems with MySQLdb
rodmc wrote: (top-post corrected) Sybren Stuvel wrote: rodmc enlightened us with: --- it refuses to connect on the above line and the exception is caught and a message displayed. So why do you think this exception and the error message contain no useful information at all? Hi, Thanks for your email. Well I am kind of new to exceptions in Python, but here is the code used below, as you can see it is somewhat basic. Is there a way to display more information about the exception? Yes : don't catch it. You'll then have all the needed infos. If you want to catch it so you can do some logging, issue a more user-friendly error message etc, then do something like this: try: SomethingThatMayRaise() except ClassOfExceptedException, e: # e is the exception, let you access error message, traceback etc doSomethingWithException(e) Some general rules about exception handling: - *don't* use bare except clause. Never. Well, almost never (cf below) - if you can't fix the problem, just let the exception propagate - at the top level of the main program, have a catch-almost-all exception handler, that will do logging if possible, proper error reporting if possible, sanity clean-up if possible, and then crash as noisily as possible. try: #Exception handler for database queries db = MySQLdb.connect(host=DBSERVERIP, user=user, passwd=password, db=nuke) except: print A database connection error has occurred return False This is the most useless and worst possible way to handle exceptions. Just get rid of this exception handler - letting the program crash with full traceback would be much much better - at least you'd have a chance to get some usefull informations about what went wrong. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
Le Jeudi 22 Juin 2006 10:07, Girish Sahani a écrit : Hi guys, I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) Here is mine, maybe more versatile : def permute(iterable) : if len(iterable) == 1 : yield iterable else : next = permute(iterable[1:]) for i in next : if isinstance(iterable[0], basestring) : elt = iterable.__class__(iterable[0]) else : elt = iterable.__class__((iterable[0],)) for j, k in enumerate(i) : yield i[0:j] + elt + i[j:] yield i + elt In [2]: list(permute((1, 2, 3))) Out[2]: [(1, 2, 3), (2, 1, 3), (2, 3, 1), (1, 3, 2), (3, 1, 2), (3, 2, 1)] In [3]: list(permute('abc')) Out[3]: ['abc', 'bac', 'bca', 'acb', 'cab', 'cba'] In [4]: list(permute('aba')) Out[4]: ['aba', 'baa', 'baa', 'aab', 'aab', 'aba'] In [5]: set(permute('aba')) Out[5]: set(['aba', 'aab', 'baa']) In [6]: list(permute([1, 3, 3])) Out[6]: [[1, 3, 3], [3, 1, 3], [3, 3, 1], [1, 3, 3], [3, 1, 3], [3, 3, 1]] In [7]: set(permute([1, 3, 3])) # warning --- exceptions.TypeError Traceback (most recent call last) /home/maric/ipython console TypeError: list objects are unhashable In [8]: set(permute((1, 3, 3))) Out[8]: set([(3, 3, 1), (3, 1, 3), (1, 3, 3)]) regards, -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
bug in Makepy
I was trying to use Makepy to wrap a typelib, but couldn't find the one I wanted in the list of libs offered, and couldn't find a way to browse to a specific one. Turns out the reason was that the lib was version 10, which was listed in the registry in hex as version a.0. The tlb chooser in Makepy rejects hex values. The author was evidently aware of this, since there is a comment in the code about it. Here is a fix -- add 4 lines in site-packages\win32com\client\selecttlb.py: try: # For some reason, this code used to assume the values were hex. # This seems to not be true - particularly for CDO 1.21 # *sigh* - it appears there are no rules here at all, so when we need # to know the info, we must load the tlb by filename and request it. # The Resolve() method on the TypelibSpec does this. major = int(major_minor[0]) minor = int(major_minor[1]) except ValueError: # try again in case values are in hex = try: = major = int(major_minor[0], 16) = minor = int(major_minor[1], 16) = except ValueError: # crap in the registry! continue Hope this helps someone. -- Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
In article [EMAIL PROTECTED], Girish Sahani [EMAIL PROTECTED] wrote: Hi guys, I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) def permute(string): l= [] l.append(string) string1 = '' for i in range(0,len(string)-1,1): string1 = string[1:len(string)] + string[:1] l.append(string1) string = string1 return l Those so passionate about enumerations as to consider *everything* known about them, and not just a specific Python function, will want to be aware of the referent of URL: http://www.unixreview.com/documents/s=10089/ur0606j/ur0606j.html and related materials. and its referents. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to wrap a whole script in try..except?
On 21/06/06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Hari Sekhon wrote: I want to wrap a whole script in try ... except. What is the best way of doing this? Consider the following: - try:import modules CODEdef notifyme(traceback): code to tell me there is a problem except Exception, traceback:notifyme(traceback) Would this code not work because if any part of CODE encounters an exception then it won't reach the notifyme() function definition and therefore the whole thing won't work and I won't get notified when a traceback occurs, in fact the call to notifyme() under except will itself probably trace back as well!Yes. Do I have to instead do: import a couple of modules def notifyme():code to tell me there is a problem try:CODE except Exception, traceback:notifyme(traceback)Would work, but... How you you handle this?I don't put the main logic at the top level - I use a main() function. import some modulesdef notifyme(e):# code here...def main(*args):try:# code herereturn 0except Exception, e:notifyme(e)return some-non-zero-error-code if __name__ == '__main__':import syssys.exit(main(*sys.argv))--bruno desthuillierspython -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) forp in ' [EMAIL PROTECTED]'.split('@')])--http://mail.python.org/mailman/listinfo/python-listWhy bother passing the args in def main(*args): and main(* sys.argv)? Couldn't you just use sys.argv straight off inside main, no passing args aroundI can see you are probably a C programmer as well?-h -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Costanza wrote: Consider a simple expression like 'a + b': In a dynamically typed language, all I need to have in mind is that the program will attempt to add two numbers. In a statically typed language, I additionally need to know that there must a guarantee that a and b will always hold numbers. I'm confused. Are you telling that you just write a+b in your programs without trying to ensure that a and b are in fact numbers?? - Andreas -- http://mail.python.org/mailman/listinfo/python-list
upgrading python on virtual hosting server
Hello, I have a dedicated linux server with several virtual domains on it. These domains are chrooted for security. I need to upgrade python and be able to have it available for all accounts. I am also concerned that I may muck up some of the server processes that use python. Can someone tell me: 1) Where should I do the install? 2) How do I make sure that the new version is available to all users? 3) What do I need to do to make sure that current services can use the new version? Thank you, Brian -- http://mail.python.org/mailman/listinfo/python-list
smtplib problem for newbie
Hi, I am writing a few different scripts that need to send email confirmation and I wanted to use smtplib instead of cheating and using os.system('mail -s foo) Some of the examples I have seen don't seem to work for me. (Note, I am new to Python and probably doing something stupid...thanks :) ) Here is one I grabbed http://effbot.org/librarybook/smtplib.htm import smtplib import string, sys HOST = localhost FROM = [EMAIL PROTECTED] TO = [EMAIL PROTECTED] SUBJECT = for your information! BODY = next week: how to fling an otter body = string.join(( From: %s % FROM, To: %s % TO, Subject: %s % SUBJECT, , BODY), \r\n) print body server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO], body) server.quit() If I change this to suit my needs it looks like this: #!/usr/bin/python import smtplib import string, sys HOST = localhost FROM = [EMAIL PROTECTED] TO = [EMAIL PROTECTED] SUBJECT = for your information! BODY = next week: how to fling an otter body = string.join(( From: %s % FROM, To: %s % TO, Subject: %s % SUBJECT, , BODY), \r\n) print body server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO], body) server.quit() When I run it I get this: Traceback (most recent call last): File ./3mail.py, line 2, in ? import smtplib File /usr/lib64/python2.3/smtplib.py, line 49, in ? from email.base64MIME import encode as encode_base64 File /usr/lib64/python2.3/email/base64MIME.py, line 28, in ? from email.Utils import fix_eols File /usr/lib64/python2.3/email/Utils.py, line 10, in ? import random File /usr/lib64/python2.3/random.py, line 818, in ? _inst = Random() File /usr/lib64/python2.3/random.py, line 87, in __init__ self.seed(x) File /usr/lib64/python2.3/random.py, line 100, in seed a = long(time.time() * 256) # use fractional seconds TypeError: 'module' object is not callable -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Andreas Rossberg wrote: Pascal Costanza wrote: Consider a simple expression like 'a + b': In a dynamically typed language, all I need to have in mind is that the program will attempt to add two numbers. In a statically typed language, I additionally need to know that there must a guarantee that a and b will always hold numbers. I'm confused. Are you telling that you just write a+b in your programs without trying to ensure that a and b are in fact numbers?? Basically, yes. Note that this is a simplistic example. Consider, instead, sending a message to an object, or calling a generic function, without ensuring that there will be applicable methods for all possible cases. When I get a message not understood exception, I can then decide whether that kind of object shouldn't be a receiver in the first place, or else whether I should define an appropriate method. I don't want to be forced to decide this upfront, because either I don't want to be bothered, or maybe I simply can't because I don't understand the domain well enough yet, or maybe I want to keep a hook to be able to update the program appropriately while it is running. Pascal -- 3rd European Lisp Workshop July 3 - Nantes, France - co-located with ECOOP 2006 http://lisp-ecoop06.bknr.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Andreas Rossberg [EMAIL PROTECTED] writes: Pascal Costanza wrote: Consider a simple expression like 'a + b': In a dynamically typed language, all I need to have in mind is that the program will attempt to add two numbers. In a statically typed language, I additionally need to know that there must a guarantee that a and b will always hold numbers. I'm confused. Are you telling that you just write a+b in your programs without trying to ensure that a and b are in fact numbers?? Of course. (shadow '(+ *)) (defun + (rest args) `(+ ,@args)) (defun * (rest args) `(* ,@args)) (let ((var 'x) (init 'b) (slop 'a)) (+ init (* slop var))) -- (+ B (* A X)) -- __Pascal Bourguignon__ http://www.informatimago.com/ Nobody can fix the economy. Nobody can be trusted with their finger on the button. Nobody's perfect. VOTE FOR NOBODY. -- http://mail.python.org/mailman/listinfo/python-list
Entity GUI tool?
Ubuntu Drake comes with or allows you to install something called entity which sounds like it ought to be the world's ultimate Python GUI tool. Nonetheless all I can get it to do looks like this: Usage: entity [-Vhm] [-g domain] [-l config path] [-a files] [file] -V Print version and exit. -g Turn on debug messages. Accepts domain as argument, or 'all' -a Load all files on command line into Entity. -m Generate module config files. -l Specify alternate location for libraries and configuration directories. -h Print this message and exit. entity 1.0.1, compiled: Dec 11 2005 00:49:34 Report bugs to [EMAIL PROTECTED] Anybody know anything more about this one? -- http://mail.python.org/mailman/listinfo/python-list
Re: Entity GUI tool?
The ubuntu synaptic package manager claims: XML-based GUI builder for GTK+ Entity is an XML-based GUI builder and application scripting framework. It combines the ease of use of XML for GUI layout and the power of Perl, Python, TCL, JavaScript, and C for the application logic. An Entity GUI is usually much shorter than the same program written in any other language. This package contains the core portions of Entity along with Perl -- http://mail.python.org/mailman/listinfo/python-list
Re: bug in Makepy
This only works if the hexadecimal representation has digits in [A-F]. What if the stored value is 10, but in hexadecimal? I don't get what you mean. If the value is 10, but in hexadecimal, isn't that A? The problem my fix solves is where the folder under the typelib guid is named something like a.0. It does what I need. If you see a case it doesn't handle, maybe you could propose a better fix? -- Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Costanza [EMAIL PROTECTED] writes: Andreas Rossberg wrote: Pascal Costanza wrote: Consider a simple expression like 'a + b': In a dynamically typed language, all I need to have in mind is that the program will attempt to add two numbers. In a statically typed language, I additionally need to know that there must a guarantee that a and b will always hold numbers. I'm confused. Are you telling that you just write a+b in your programs without trying to ensure that a and b are in fact numbers?? Basically, yes. Note that this is a simplistic example. Consider, instead, sending a message to an object, or calling a generic function, without ensuring that there will be applicable methods for all possible cases. When I get a message not understood exception, I can then decide whether that kind of object shouldn't be a receiver in the first place, or else whether I should define an appropriate method. I don't want to be forced to decide this upfront, because either I don't want to be bothered, or maybe I simply can't because I don't understand the domain well enough yet, or maybe I want to keep a hook to be able to update the program appropriately while it is running. Moreover, a good proportion of the program and a good number of algorithms don't even need to know the type of the objects they manipulate. For example, sort doesn't need to know what type the objects it sorts are. It only needs to be given a function that is able to compare the objects. Only a few primitive functions need specific types. So basically, you've got a big black box of applicaition code in the middle that doesn't care what type of value they get, and you've got a few input values of a specific type, a few processing functions needing a specific type and returning a specific type, and a few output values that are expected to be of a specific type. At anytime, you may change the type of the input values, and ensure that the needed processing functions will be able to handle this new input type, and the output gets mapped to the expected type. Why should adding a few functions or methods, and providing input values of a new type be rejected from a statically checked point of view by a compiled program that would be mostly bit-for-bit the same with or without this new type? Of course, in the process of so modifying the program, we may get some dynamically detected type errors that we would correct as Pascal indicated. -- __Pascal Bourguignon__ http://www.informatimago.com/ Specifications are for the weak and timid! -- http://mail.python.org/mailman/listinfo/python-list
Re: smtplib problem for newbie
It turns out it is a cgi issue. If I run this code outside of the cgi-bin it runs just fine. The webhosting company I am using allows python cgi code to run, but I might need to check with them about how it works. Does anyone have advice on python cgi vs. psp vs. python web application frameworks? I do plan on getting my head wrapped around writing python in the web application environment but am a bit confused still. Also, wondering how django compares to ruby on rails etc. Sorry, newbie bewilderment Noah On 6/22/06, Noah Gift [EMAIL PROTECTED] wrote: Hi, I am writing a few different scripts that need to send email confirmation and I wanted to use smtplib instead of cheating and using os.system('mail -s foo) Some of the examples I have seen don't seem to work for me. (Note, I am new to Python and probably doing something stupid...thanks :) ) Here is one I grabbed http://effbot.org/librarybook/smtplib.htm import smtplib import string, sys HOST = localhost FROM = [EMAIL PROTECTED] TO = [EMAIL PROTECTED] SUBJECT = for your information! BODY = next week: how to fling an otter body = string.join(( From: %s % FROM, To: %s % TO, Subject: %s % SUBJECT, , BODY), \r\n) print body server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO], body) server.quit() If I change this to suit my needs it looks like this: #!/usr/bin/python import smtplib import string, sys HOST = localhost FROM = [EMAIL PROTECTED] TO = [EMAIL PROTECTED] SUBJECT = for your information! BODY = next week: how to fling an otter body = string.join(( From: %s % FROM, To: %s % TO, Subject: %s % SUBJECT, , BODY), \r\n) print body server = smtplib.SMTP(HOST) server.sendmail(FROM, [TO], body) server.quit() When I run it I get this: Traceback (most recent call last): File ./3mail.py, line 2, in ? import smtplib File /usr/lib64/python2.3/smtplib.py, line 49, in ? from email.base64MIME import encode as encode_base64 File /usr/lib64/python2.3/email/base64MIME.py, line 28, in ? from email.Utils import fix_eols File /usr/lib64/python2.3/email/Utils.py, line 10, in ? import random File /usr/lib64/python2.3/random.py, line 818, in ? _inst = Random() File /usr/lib64/python2.3/random.py, line 87, in __init__ self.seed(x) File /usr/lib64/python2.3/random.py, line 100, in seed a = long(time.time() * 256) # use fractional seconds TypeError: 'module' object is not callable -- http://mail.python.org/mailman/listinfo/python-list
Re: need all python dialog equivalent
Eric S. Johansson [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: dialog binary is 110 KB. Won't it fit ? missing library. I have ncurses and newt and dialog seems to require something called ncursesw. I've been trying to find the Python newt seems to require if you're installing some package. dialog builds/works against either ncurses/ncursesw -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net -- http://mail.python.org/mailman/listinfo/python-list
Re: returning index of minimum in a list of lists
[EMAIL PROTECTED] wrote: Hi all, Is there a simple python function to return the list index of the minimum entry in a list of lists? ie, for [[3,3,3,3], [3,3,3,1], [3,3,3,3]] to return 2,4. Or, same question but just for a list of numbers, not a list of lists. Thanks, Josh Untested: items = [] for x, a in enumerate(L): for y, b in enumerate(a): items.append((b, (x,y))) x, y = min(items)[1] You could also change this to a generator: def f(L): for x, a in enumerate(L): for y, b in ebumerate(a): yield b, (x,y) x, y = min(f(L))[1] -- http://mail.python.org/mailman/listinfo/python-list
(Iron)Python on new MS robotics platform
Both remote (PC-based) and autonomous (robot-based) execution scenarios can be developed using a selection of programming languages, including those in Microsoft Visual Studio® and Microsoft Visual Studio Express languages (Visual C#® and Visual Basic® .NET), JScript® and Microsoft IronPython 1.0 Beta 1, and third-party languages that conform to its services-based architecture. http://www.microsoft.com/presspass/press/2006/jun06/06-20MSRoboticsStudioPR.mspx -- http://mail.python.org/mailman/listinfo/python-list
Using Python as a web scripting language
Hello everyone,I am learning Python and have heard it can be used similarly to PHP for web scripting. Because I find the latter not entirely to my liking, I would like to use Python. How should I configure my web server, what do I need, where should I start at, etc. I realise this sort of question pops up regularly, so just give me a starting point and I'll work my way from there (hopefully). Thanks in advance,Vlad Dogaru--If I have somehow managed to break some sort of rules, either etiquette or English, by all means educate me. -- http://mail.python.org/mailman/listinfo/python-list
Re: smtplib problem for newbie
Noah Gift wrote: [snip] a = long(time.time() * 256) # use fractional seconds TypeError: 'module' object is not callable Part of your program includes a file or directory that you called 'long'. You should not re-use names of built-ins in your programs.. they cause you to get errors like the above. see: long('12') 12L open(long.py,'w') open file 'long.py', mode 'w' at 0x401e3380 import long long('12') Traceback (most recent call last): File stdin, line 1, in ? TypeError: 'module' object is not callable -- - Justin -- http://mail.python.org/mailman/listinfo/python-list
Registry of Methods via Decorators
I want to make a registry of methods of a class during creation. My attempt was this classdecorators.py Author: Justin Bayer Creation Date: 2006-06-22 Copyright (c) 2006 Chess Pattern Soft, All rights reserved. class decorated(object): methods = [] @classmethod def collect_methods(cls, method): cls.methods.append(method.__name__) return method class dec2(decorated): @collect_methods def first_func(self): pass @collect_methods def second_func(self): pass def main(): print dec2.methods if __name__ == '__main__': main() This does not work and exits with NameError: (name 'collect_methods' is not defined,). Which is understandable due to the fact that the class dec2 is not complete. Anyone can give me a hint how to work around this? -- http://mail.python.org/mailman/listinfo/python-list
Feed wxComboBox with dictionary/hash
Hi folks, I am relatively new to Python. Although I read a lot of howtos, introductions and wikis, I am still having trouble ;-) My querstion: As the subject says, I'd like to feed a wx.ComboBox with a dictionary/hash. According to the posting of Stano Paska (wxComboBox combobox, 20 Jul. 2004), there seems to be a way to do this: You must use something like combo.Append('aaa', 'a') combo.Append('bbb', 'b') ... My problem is: my data has thousands of entries. Therefore, I'd like to feed the combobox with a dictionary (which itself is fed by a database query). My first question: how can a wx.ComboBox be fed by a dictionary? For further help, Stano says: read manual for more details... Ok, I'd like to. But which one? I was reading http://www.wxpython.org/docs/api/wx.ComboBox-class.html and didn't even find the above mentioned append method :-( TIA, Roland R. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Bourguignon [EMAIL PROTECTED] writes: Moreover, a good proportion of the program and a good number of algorithms don't even need to know the type of the objects they manipulate. For example, sort doesn't need to know what type the objects it sorts are. It only needs to be given a function that is able to compare the objects. Of course, some statically typed languages handle this sort of thing routinely. Only a few primitive functions need specific types. Your sort function from above also has a specific type -- a type which represents the fact that the objects to be sorted must be acceptable input to the comparison function. So basically, you've got a big black box of applicaition code in the middle that doesn't care what type of value they get, and you've got a few input values of a specific type, a few processing functions needing a specific type and returning a specific type, and a few output values that are expected to be of a specific type. At anytime, you may change the type of the input values, and ensure that the needed processing functions will be able to handle this new input type, and the output gets mapped to the expected type. ...or you type-check your black box and make sure that no matter how you will ever change the type of the inputs (in accordance with the interface type of the box) you get a valid program. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
Girish Sahani wrote: I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496724 anton -- http://mail.python.org/mailman/listinfo/python-list
Re: What is a type error?
Pascal Costanza [EMAIL PROTECTED] writes: Chris Smith wrote: While this effort to salvage the term type error in dynamic languages is interesting, I fear it will fail. Either we'll all have to admit that type in the dynamic sense is a psychological concept with no precise technical definition (as was at least hinted by Anton's post earlier, whether intentionally or not) or someone is going to have to propose a technical meaning that makes sense, independently of what is meant by type in a static system. What about this: You get a type error when the program attempts to invoke an operation on values that are not appropriate for this operation. Examples: adding numbers to strings; determining the string-length of a number; applying a function on the wrong number of parameters; applying a non-function; accessing an array with out-of-bound indexes; etc. Yes, the phrase runtime type error is actually a misnomer. What one usually means by that is a situation where the operational semantics is stuck, i.e., where the program, while not yet arrived at what's considered a result, cannot make any progress because the current configuration does not match any of the rules of the dynamic semantics. The reason why we call this a type error is that such situations are precisely the ones we want to statically rule out using sound static type systems. So it is a type error in the sense that the static semantics was not strong enough to rule it out. Sending a message to an object that does not understand that message is a type error. The message not understood machinery can be seen either as a way to escape from this type error in case it occurs and allow the program to still do something useful, or to actually remove (some) potential type errors. I disagree with this. If the program keeps running in a defined way, then it is not what I would call a type error. It definitely is not an error in the sense I described above. -- http://mail.python.org/mailman/listinfo/python-list
Re: The code that could not be...
Alex A. Naanou wrote: The object's __dict__ can only be a dict derivative and at that none of the Python's mapping API will be used (the dict is accessed directly). [snip] I wrote a patch some time back, it appears rather stable and is being production tested. you can download it here: http://pli.sourceforge.net/object_dict_interface_use_fix.patch Could you post this to Python's sourceforge tracker[1]? You're likely to get more reviewers that way. BTW, I too would like to see this happen -- thanks so much for providing an implementation! [1] http://sourceforge.net/tracker/?group_id=5470atid=105470 STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: What is a type error?
Pascal Costanza [EMAIL PROTECTED] wrote: What about this: You get a type error when the program attempts to invoke an operation on values that are not appropriate for this operation. Examples: adding numbers to strings; determining the string-length of a number; applying a function on the wrong number of parameters; applying a non-function; accessing an array with out-of-bound indexes; etc. Hmm. I'm afraid I'm going to be picky here. I think you need to clarify what is meant by appropriate. If you mean the operation will not complete successfully as I suspect you do, then we're closer... but this little snippet of Java (HORRIBLE, DO NOT USE!) confuses the matter for me: int i = 0; try { while (true) process(myArray[i++]); } catch (IndexOutOfBoundsException e) { } That's an array index from out of bounds that not only fails to be a type error, but also fails to be an error at all! (Don't get confused by Java's having a static type system for other purposes... we are looking at array indexing here, which Java checks dynamically. I would have used a dynamically typed language, if I could have written this as quickly.) I'm also unsure how your definition above would apply to languages that do normal order evaluation, in which (at least in my limited brain) it's nearly impossible to break down a program into sequences of operations on actual values. I suppose, though, that they do eventually happen with primitives at the leaves of the derivation tree, so the definition would still apply. -- Chris Smith - Lead Software Developer / Technical Trainer MindIQ Corporation -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Rob Warnock wrote: Marshall [EMAIL PROTECTED] wrote: Can you be more explicit about what latent types means? I'm sorry to say it's not at all natural or intuitive to me. Are you referring to the types in the programmers head, or the ones at runtime, or what? Here's what the Scheme Standard has to say: http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-4.html 1.1 Semantics ... Scheme has latent as opposed to manifest types. Types are assoc- iated with values (also called objects) rather than with variables. (Some authors refer to languages with latent types as weakly typed or dynamically typed languages.) Other languages with latent types are APL, Snobol, and other dialects of Lisp. Languages with manifest types (sometimes referred to as strongly typed or statically typed languages) include Algol 60, Pascal, and C. To me, the word latent means that when handed a value of unknown type at runtime, I can look at it or perform TYPE-OF on it or TYPECASE or something and thereby discover its actual type at the moment[1], whereas manifest means that types[2] are lexically apparent in the code. Hmmm. If I read the R5RS text correctly, it is simply doing the either/or thing that often happens with static/dynamic only using different terms. I don't see any difference between latent and dynamic. Also, this phrase types associated with values instead of variables that I'm starting to see a lot is beginning to freak me out: the implication is that other languages have types associated with variables and not values, which doesn't describe anything I can think of. In your followup paragraph, you've contrasted runtime type introspection, vs. explicit type declarations, which seem orthorgonal to me. (Not that you said they weren't.) Marshall -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
Girish Sahani wrote: Hi guys, I want to generate all permutations of a string. I've managed to generate all cyclic permutations. Please help :) http://gflanagan.net/site/python/05/Johnson.html Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Costanza wrote: A statically type language requires you to think about two models of your program at the same time: the static type model and the dynamic behavioral model. A static type system ensures that these two _different_ (that's important!) perspectives are always in sync. This is especially valuable in settings where you know your domain well and want to rely on feedback by your compiler that you haven't made any mistakes in encoding your knowledge. (A static type system based on type inferencing doesn't essentially change the requirement to think in two models at the same time.) A dynamically typed language is especially well suited when you don't (yet) have a good idea about your domain and you want to use programming especially to explore that domain. Some static typing advocates claim that static typing is still suitable for exploring domains because of the compiler's feedback about the preliminary encoding of your incomplete knowledge, but the disadvantages are a) that you still have to think about two models at the same time when you don't even have _one_ model ready and b) that you cannot just run your incomplete program to see what it does as part of your exploration. A statically typed language with a dynamic type treats dynamic typing as the exception, not as the general approach, so this doesn't help a lot in the second setting (or so it seems to me). A language like Common Lisp treats static typing as the exception, so you can write a program without static types / type checks, but later on add type declarations as soon as you get a better understanding of your domain. Common Lisp implementations like CMUCL or SBCL even include static type inference to aid you here, which gives you warnings but still allows you to run a program even in the presence of static type errors. I guess the feedback you get from such a system is probably not strong enough to be appreciated by static typing advocates in the first setting (where you have a good understanding of your domain). I am sceptical of the idea that when programming in a dynamically typed language one doesn't have to think about both models as well. I don't have a good model of the mental process of working in a dynamically typed language, but how could that be the case? (I'm not asking rhetorically.) Do you then run your program over and over, mechanically correcting the code each time you discover a type error? In other words, if you're not thinking of the type model, are you using the runtime behavior of the program as an assistant, the way I use the static analysis of the program as an assistant? I don't accept the idea about pairing the appropriateness of each system according to whether one is doing exploratory programming. I do exploratory programming all the time, and I use the static type system as an aide in doing so. Rather I think this is just another manifestation of the differences in the mental processes between static typed programmers and dynamic type programmers, which we are beginning to glimpse but which is still mostly unknown. Oh, and I also want to say that of all the cross-posted mega threads on static vs. dynamic typing, this is the best one ever. Most info; least flames. Yay us! Marshall -- http://mail.python.org/mailman/listinfo/python-list
Re: Registry of Methods via Decorators
bayerj wrote: I want to make a registry of methods of a class during creation. My attempt was this classdecorators.py Author: Justin Bayer Creation Date: 2006-06-22 Copyright (c) 2006 Chess Pattern Soft, All rights reserved. class decorated(object): methods = [] @classmethod def collect_methods(cls, method): cls.methods.append(method.__name__) return method class dec2(decorated): @collect_methods def first_func(self): pass @collect_methods def second_func(self): pass def main(): print dec2.methods if __name__ == '__main__': main() This does not work and exits with NameError: (name 'collect_methods' is not defined,). Which is understandable due to the fact that the class dec2 is not complete. Anyone can give me a hint how to work around this? If you insist on doing black-magic (else go directly to the end of this post), here's a way to do it, based on Ian Bicking's __classinit__ recipe http://blog.ianbicking.org/a-conservative-metaclass.html (BTW, Ian, many many thanks for this trick - I really love it). class DeclarativeMeta(type): def __new__(meta, class_name, bases, new_attrs): cls = type.__new__(meta, class_name, bases, new_attrs) cls.__classinit__.im_func(cls, new_attrs) return cls class Declarative(object): __metaclass__ = DeclarativeMeta def __classinit__(cls, new_attrs): pass class MethodCollector(Declarative): def __classinit__(cls, new_attrs): cls.methods = [name for name, attr in new_attrs.items() \ if callable(attr)] class dec2(MethodCollector): def first_func(self): pass def second_func(self): pass If you want to choose which methods to collect, then it's just a matter of adding a simple decorator and a test in MethodCollector.__classinit__: def collect(func): func._collected = True return func class MethodCollector(Declarative): def __classinit__(cls, new_attrs): cls.methods = [name for name, attr in new_attrs.items() \ if callable(attr) \ and getattr(attr, '_collected', False)] class dec2(MethodCollector): @collect def first_func(self): pass @collect def second_func(self): pass def not_collected(self): pass *BUT* is it really useful to go thru all this mess ? class DeadSimple(object): @classmethod def methods(cls): return [name for name in dir(cls) \ if not name.startswith('__') \ and callable(getattr(cls, name))] My 2 cents... -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Registry of Methods via Decorators
bayerj wrote: I want to make a registry of methods of a class during creation. I think you're going to need a metaclass for this, e.g.:: import inspect def registered(func): ... func.registered = True ... return func ... class RegisterFuncs(type): ... def __init__(cls, name, bases, classdict): ... cls.methods = [] ... for name, value in classdict.iteritems(): ... if inspect.isfunction(value): ... if hasattr(value, 'registered'): ... cls.methods.append(name) ... class C(object): ... __metaclass__ = RegisterFuncs ... @registered ... def first_func(self): ... pass ... @registered ... def second_func(self): ... pass ... C.methods ['first_func', 'second_func'] If you just want to store *all* method names, you can dispense with the @registered decorator and the hasattr() check. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Registry of Methods via Decorators
Hi, Le Jeudi 22 Juin 2006 15:32, bayerj a écrit : I want to make a registry of methods of a class during creation. Why ? you already have them in dec2.__dict__ : In [42]: import types In [43]: class a : : def b(self) : return : @classmethod : def c(self) : return : : In [44]: [ k for k, v in a.__dict__.items() if isinstance(v, types.FunctionType) ] Out[44]: ['b'] In [45]: [ k for k, v in a.__dict__.items() if isinstance(v, classmethod) ] Out[45]: ['c'] Warning : In [46]: list(isinstance(i, types.MethodType) for i in (a.b, a().b, a.__dict__['b'])) Out[46]: [True, True, False] In [47]: list(isinstance(i, types.FunctionType) for i in (a.b, a().b, a.__dict__['b'])) Out[47]: [False, False, True] I would prefer write some inspection method that retrieve all these infos. My attempt was this And that can't work, classdecorators.py Author: Justin Bayer Creation Date: 2006-06-22 Copyright (c) 2006 Chess Pattern Soft, All rights reserved. class decorated(object): methods = [] @classmethod def collect_methods(cls, method): cls.methods.append(method.__name__) return method class dec2(decorated): @collect_methods def first_func(self): pass @collect_methods def second_func(self): pass This is trying to do : first_func = collect_methods(first_fun) but collect_methods doesn't exists in the global namespace (indeed you got a NameError exception). You can't reference it as decorated.collect_methods because the methods will be appended to the decorated.methods list and not one list specific to dec2. You neither can refer it as dec2.collect_methods because dec2 is still undefined. def main(): print dec2.methods if __name__ == '__main__': main() This does not work and exits with NameError: (name 'collect_methods' is not defined,). Which is understandable due to the fact that the class dec2 is not complete. Not exactly. At any moment in a python program, there are two and only two scope, global and local, global is usually the module level scope (where no 'collect_methods' exists), and, in the case of a class definition, local is the class __dict__ (the local namespace is not same the class and its method). But I'm not sure of what you really want : a list of all decorated methods of all subclasses of a class, or a list of marked method in each class ? -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Andreas Rossberg wrote: Marshall wrote: What prohibits us from describing an abstract type as a set of values? If you identify an abstract type with the set of underlying values then it is equivalent to the underlying representation type, i.e. there is no abstraction. I don't follow. Are you saying that a set cannot be described intentionally? How is the set of all objects that implement the Foo interface not sufficiently abstract? Is it possible you are mixing in implementation concerns? There were papers observing this as early as 1970. References? This is 1973, actually, but most relevant: James Morris Types Are Not Sets. Proc. 1st ACM Symposium on Principles of Programming Languages, 1973 Okay. Since this paper is in the ACM walled garden, I'll have to wait until next week to get a look at it. But thanks for the reference. (There are also theoretic problems with the types-as-sets view, because sufficiently rich type systems can no longer be given direct models in standard set theory. For example, first-class polymorphism would run afoul the axiom of foundation.) There is no reason why we must limit ourselves to standard set theory any more than we have to limit ourselves to standard type theory. Both are progressing, and set theory seems to me to be a good choice for a foundation. What else would you use? I'm no expert here, but Category Theory is a preferred choice in many areas of PLT. Fair enough. Marshall -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Andreas Rossberg wrote: [me:] It's worth noting, too, that (in some sense) the type of an object can change over time[*]. No. Since a type expresses invariants, this is precisely what may *not* happen. If certain properties of an object may change then the type of the object has to reflect that possibility. Otherwise you cannot legitimately call it a type. Well, it seems to me that you are /assuming/ a notion of what kinds of logic can be called type (theories), and I don't share your assumptions. No offence intended. Actually I would go a little further than that. Granted that whatever logic one wants to apply in order to prove whatever about a program execution is abstract -- and so timeless -- that does not (to my mind) imply that it must be /static/. However, even if we grant that additional restriction, that doesn't imply that the analysis itself must not be cognisant of time. I see no reason, even in practise, why a static analysis should not be able to see that the set of acceptable operations (for some definition of acceptable) for some object/value/variable can be different at different times in the execution. If the analysis is rich enough to check that the temporal constraints are [not] satisfied, then I don't see why you should want to use another word than type to describe the results of its analysis. -- chris -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
I wrote: It would be interesting to see what a language designed specifically to support user-defined, pluggable, and perhaps composable, type systems would look like. Since writing that I've come across some thoughts by Gilad Bracha (a Name known to Java and Smalltalk enthusiasts alike) here: http://blogs.sun.com/roller/page/gbracha?entry=a_few_ideas_on_type and a long, and occasionally interesting, related thread on LtU: http://lambda-the-ultimate.org/node/1311 Not much discussion of concrete language design, though. -- chris -- http://mail.python.org/mailman/listinfo/python-list
Re: What is a type error?
Chris Smith wrote: Some people here seem to be saying that there is a universal concept of type error in dynamic typing, but I've still yet to see a good precise definition (nor a good precise definition of dynamic typing at all). How about this, at least as a strawman: I think we're agreed (you and I anyway, if not everyone in this thread) that we don't want to talk of the type system for a given language. We want to allow a variety of verification logics. So a static type system is a logic which can be implemented based purely on the program text without making assumptions about runtime events (or making maximally pessimistic assumptions -- which comes to the same thing really). I suggest that a dynamic type system is a verification logic which (in principle) has available as input not only the program text, but also the entire history of the program execution up to the moment when the to-be-checked operation is invoked. I don't mean to imply that an operation /must/ not be checked until it is invoked (although a particular logic/implementation might not do so). For instance an out-of-bound array access might be rejected: When the attempt was made to read that slot. When, in the surrounding code, it first became unavoidable that the about read /would/ be reached. When the array was first passed to a function which /might/ read that slot. ...and so on... Note that not all errors that I would want to call type errors are necessarily caught by the runtime -- it might go happily ahead never realising that it had just allowed one of the constraints of one of the logics I use to reason about the program. What's known as an undetected bug -- but just because the runtime doesn't see it, doesn't mean that I wouldn't say I'd made a type error. (The same applies to any specific static type system too, of course.) But the checks the runtime does perform (whatever they are, and whenever they happen), do between them constitute /a/ logic of correctness. In many highly dynamic languages that logic is very close to being maximally optimistic, but it doesn't have to be (e.g. the runtime type checking in the JMV is pretty pessimistic in many cases). Anyway, that's more or less what I mean when I talk of dynamically typed language and their dynamic type systems. I suspect you'll see the Smalltalk version of the objections raised in response to my post earlier. In other words, whatever terminology you think is consistent, you'll probably have a tough time convincing Smalltalkers to stop saying type if they did before. If you exclude message not understood as a type error, then I think you're excluding type errors from Smalltalk entirely, which contradicts the psychological understanding again. Taking Smalltalk /specifically/, there is a definite sense in which it is typeless -- or trivially typed -- in that in that language there are no[*] operations which are forbidden[**], and none which might not be invoked deliberately (e.g. I have code which deliberately reads off the end of a container object -- just to make sure I raise the right error for that container, rather than raising my own error). But, on the other hand, I do still want to talk of type, and type system, and type errors even when I program Smalltalk, and when I do I'm thinking about type in something like the above sense. -- chris [*] I can't think of any offhand -- there may be a few. [**] Although there are operations which are not possible, reading another object's instvars directly for instance, which I suppose could be taken to induce a non-trivial (and static) type logic. -- http://mail.python.org/mailman/listinfo/python-list
Re: The code that could not be...
Alex A. Naanou wrote: To mention several tasks that can be made trivial using this technique are, for instance zope-like acquisitions, various ACLs, interfaces and other namespace manipulation patterns. eh ? why not use Python's OO mechanisms for this, like everyone else is doing... /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Registry of Methods via Decorators
bayerj schrieb: I want to make a registry of methods of a class during creation. My attempt was this classdecorators.py Author: Justin Bayer Creation Date: 2006-06-22 Copyright (c) 2006 Chess Pattern Soft, All rights reserved. class decorated(object): methods = [] @classmethod def collect_methods(cls, method): cls.methods.append(method.__name__) return method class dec2(decorated): @collect_methods def first_func(self): pass @collect_methods def second_func(self): pass replace '@collect_methods' with '@decorated.collect_methods' and this will do what you want. But keep in mind, that the 'methods' list in decorated will be used for all derived classes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Feed wxComboBox with dictionary/hash
Roland Rickborn wrote: Hi folks, I am relatively new to Python. Although I read a lot of howtos, introductions and wikis, I am still having trouble ;-) My querstion: As the subject says, I'd like to feed a wx.ComboBox with a dictionary/hash. According to the posting of Stano Paska (wxComboBox combobox, 20 Jul. 2004), there seems to be a way to do this: You must use something like combo.Append('aaa', 'a') combo.Append('bbb', 'b') ... My problem is: my data has thousands of entries. Therefore, I'd like to feed the combobox with a dictionary (which itself is fed by a database query). My first question: how can a wx.ComboBox be fed by a dictionary? For further help, Stano says: read manual for more details... Ok, I'd like to. But which one? I was reading http://www.wxpython.org/docs/api/wx.ComboBox-class.html and didn't even find the above mentioned append method :-( TIA, Roland R. wxComboBox inherits from wxControlWithItems (as does wx.ListBox, and other controls which hold lists). See: http://wxwidgets.org/manuals/2.6.3/wx_wxcontrolwithitems.html#wxcontrolwithitems Iain -- http://mail.python.org/mailman/listinfo/python-list
Re: Registry of Methods via Decorators
Stephan Diehl wrote: replace '@collect_methods' with '@decorated.collect_methods' and this will do what you want. That is unlikely as it will keep a single list of methods for all classes derived from decorated: calling decorated.collect_methods will pass decorated as the cls parameter. What the OP wants it a separate list for each subclass. The way to do that of course is as others have suggested, just stick an attribute on each decorated function and then collect_methods goes through the class dict when it is called and picks out the correct methods. It could even build a list cached on the class at that time if it needs to (although the speedup is unlikely to be significant over just iterating through all the methods picking out the marked ones). -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Costanza wrote: Consider a simple expression like 'a + b': In a dynamically typed language, all I need to have in mind is that the program will attempt to add two numbers. In a statically typed language, I additionally need to know that there must a guarantee that a and b will always hold numbers. I still don't really see the difference. I would not expect that the dynamic programmer will be thinking that this code will have two numbers most of the time but sometimes not, and fail. I would expect that in both static and dynamic, the thought is that that code is adding two numbers, with the difference being the static context gives one a proof that this is so. In this simple example, the static case is better, but this is not free, and the cost of the static case is evident elsewhere, but maybe not illuminated by this example. This thread's exploration of the mindset of the two kinds of programmers is difficult. It is actually quite difficult, (possibly impossible) to reconstruct mental states though introspection. Nonetheless I don't see any other way to proceed. Pair programming? My goal is not to convince anyone, my goal is to illustrate for those who are interested in getting a possibly different perspective. Yes, and thank you for doing so. Marshall -- http://mail.python.org/mailman/listinfo/python-list
Blog source code in Python
Is there a blog application source available in Python? Thank you for reply L. -- http://mail.python.org/mailman/listinfo/python-list
serial port servo control
So I ordered a mini SSC II (the servo controller), in order to control some servos from the computer. I was hoping to use python to do the control but have two questions... 1) How should I write to the serial port with python? I found the module pyserial: http://pyserial.sourceforge.net/ on the python cheeseshop, and it looks solid but I thought you might have a better suggestion. 2) To control the servos I have to send the SSC II a string of 3 numbers, 3 bytes long (so 3 numbers in the range 0 - 255, each as a single byte, one after another). In C I'd do this by sending 3 char's, as they're only 1 byte, but i'm not exactly sure how to do it in Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Blog source code in Python
Lad wrote: Is there a blog application source available in Python? google down today? how many do you need ? http://newsbruiser.tigris.org/ http://pyblosxom.sourceforge.net/ http://wiki.python.org/moin/PythonBlogSoftware etc /F -- http://mail.python.org/mailman/listinfo/python-list
Re: serial port servo control
[EMAIL PROTECTED] schrieb: So I ordered a mini SSC II (the servo controller), in order to control some servos from the computer. I was hoping to use python to do the control but have two questions... 1) How should I write to the serial port with python? I found the module pyserial: http://pyserial.sourceforge.net/ on the python cheeseshop, and it looks solid but I thought you might have a better suggestion. pyserial is what you need. 2) To control the servos I have to send the SSC II a string of 3 numbers, 3 bytes long (so 3 numbers in the range 0 - 255, each as a single byte, one after another). In C I'd do this by sending 3 char's, as they're only 1 byte, but i'm not exactly sure how to do it in Python. Strings in python are byte-strings. So you can use them. Additionally, I recommend looking into the module struct. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Chris Uppal wrote: It's worth noting, too, that (in some sense) the type of an object can change over time[*]. No. Since a type expresses invariants, this is precisely what may *not* happen. If certain properties of an object may change then the type of the object has to reflect that possibility. Otherwise you cannot legitimately call it a type. Well, it seems to me that you are /assuming/ a notion of what kinds of logic can be called type (theories), and I don't share your assumptions. No offence intended. OK, but can you point me to any literature on type theory that makes a different assumption? I see no reason, even in practise, why a static analysis should not be able to see that the set of acceptable operations (for some definition of acceptable) for some object/value/variable can be different at different times in the execution. Neither do I. But what is wrong with a mutable reference-to-union type, as I suggested? It expresses this perfectly well. - Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Bourguignon wrote: For example, sort doesn't need to know what type the objects it sorts are. It only needs to be given a function that is able to compare the objects. Sure. That's why any decent type system supports polymorphism of this sort. (And some of them can even infer which comparison function to pass for individual calls, so that the programmer does not have to bother.) - Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: Blog source code in Python
Lazy Lad wrote: Is there a blog application source available in Python? Several. Did you try Google before you posted your question? The search term python blog has http://wiki.python.org/moin/PythonBlogSoftware within the first 10 hits. Cheers, -- Klaus Alexander Seistrup Copenhagen, Denmark http://surdej.dk/ -- http://mail.python.org/mailman/listinfo/python-list
Re: serial port servo control
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 1) How should I write to the serial port with python? I found the module pyserial: I don't think there is any need to hunt for anything better. In C I'd do this by sending 3 char's, as they're only 1 byte, but i'm not exactly sure how to do it in Python. Use a string type. output = chr(x) + chr(y) + chr(z) for example. There is no restriction on null bytes in strings, so they are appropriate for binary data. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Dr.Ruud wrote: Rob Thorpe schreef: Dr.Ruud: Marshall: dynamic types. I don't have a firm definition for that term, but my working model is runtime type tags. In which case, I would say that among statically typed languages, Java does have dynamic types, but C does not. C++ is somewhere in the middle. C has union. That's not the same thing. That is your opinion. In the context of this discussion I don't see any problem to put C's union under dynamic types. Lets put it like this:- 1. In C++ and Java it is possible to make a variable that can A)Take on many different types and B)Where the programmer can test what the type is. 2. In C it is possible to make a variable that can do 1A but not 1B. This is a statement of fact, not opinion. I call languages that do #1 dynamically typed, in line with common usage. The value of a union in C can be any of a set of specified types. But the program cannot find out which, and the language doesn't know either. With C++ and Java dynamic types the program can test to find the type. When such a test is needed for the program with the union, it has it. What do you mean? There is no way to test the type of the value inside a union in C. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Rob Warnock wrote: Another language which has *neither* latent (dynamic) nor manifest (static) types is (was?) BLISS[1], in which, like assembler, variables are just addresses[2], and values are just a machine word of bits. 360-family assembler, yes. 8086-family assembler, not so much. -- John W. Kennedy The blind rulers of Logres Nourished the land on a fallacy of rational virtue. -- Charles Williams. Taliessin through Logres: Prelude -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Darren New schrieb: Andreas Rossberg wrote: AFAICT, ADT describes a type whose values can only be accessed by a certain fixed set of operations. No. AFAIU, an ADT defines the type based on the operations. The stack holding the integers 1 and 2 is the value (push(2, push(1, empty(. There's no internal representation. The values and operations are defined by preconditions and postconditions. Are you sure that you aren't confusing *abstract* with *algebraic* data types? In my book, abstract types usually have an internal representation, and that can even be stateful. I don't remember having encountered definitions of ADT as restrictive as you describe it. Both a stack and a queue could be written in most languages as values that can only be accessed by a fixed set of operations having the same possible internal representations and the same function signatures. They're far from the same type, because they're not abstract. Different abstract types can have the same signature. That does not make them the same type. The types are distinguished by their identity. Likewise, two classes can have the same set of methods, without being the same class (at least in languages that have nominal typing, which includes almost all typed OOPLs). I'm pretty sure in Pascal you could say Type Apple = Integer; Orange = Integer; and then vars of type apple and orange were not interchangable. No, the following compiles perfectly fine (using GNU Pascal): program bla; type apple = integer; orange = integer; var a : apple; o : orange; begin a := o end. - Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
David Hopwood wrote: Rob Thorpe wrote: Vesa Karvonen wrote: In comp.lang.functional Anton van Straaten [EMAIL PROTECTED] wrote: Let me add another complex subtlety, then: the above description misses an important point, which is that *automated* type checking is not the whole story. I.e. that compile time/runtime distinction is a kind of red herring. I agree. I think that instead of statically typed we should say typed and instead of (dynamically|latently) typed we should say untyped. [...] It's certainly close enough to say that the *language* is untyped. Indeed. Either a language has a type system and is typed or has no type system and is untyped. I see very little room for confusion here. In my experience, the people who confuse these things are people from the dynamic/latent camp who wish to see types everywhere because they confuse typing with safety or having well-defined semantics. No. It's because the things that we call latent types we use for the same purpose that programmers of static typed languages use static types for. Statically typed programmers ensure that the value of some expression is of some type by having the compiler check it. Programmers of latently typed languages check, if they think it's important, by asking what the type of the result is. The objection here is that advocates of statically typed language seem to be claiming the type as their own word, and asking that others use their definitions of typing, which are really specific to their subjects of interest. As far as I can tell, the people who advocate using typed and untyped in this way are people who just want to be able to discuss all languages in a unified terminological framework, and many of them are specifically not advocates of statically typed languages. Its easy to create a reasonable framework. My earlier posts show simple ways of looking at it that could be further refined, I'm sure there are others who have already done this. The real objection to this was that latently/dynamically typed languages have a place in it. But some of the advocates of statically typed languages wish to lump these languages together with assembly language a untyped in an attempt to label them as unsafe. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Marshall wrote: What prohibits us from describing an abstract type as a set of values? If you identify an abstract type with the set of underlying values then it is equivalent to the underlying representation type, i.e. there is no abstraction. I don't follow. Are you saying that a set cannot be described intentionally? How is the set of all objects that implement the Foo interface not sufficiently abstract? Is it possible you are mixing in implementation concerns? Values refers to the concrete values existent in the semantics of a programming language. This set is usually infinite, but basically fixed. To describe the set of values of an abstract type you would need fresh values that did not exist before (otherwise the abstract type would be equivalent to some already existent type). So you'd need at least a theory for name generation or something similar to describe abstract types in a types-as-sets metaphor. - Andreas -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
[EMAIL PROTECTED] wrote: Are you sure that you aren't confusing *abstract* with *algebraic* data types? I've never heard of algebraic data types. It's always been abstract data types. Perhaps I stopped studying it, and the terminology changed when many people started to consider encapsulation as abstraction. I have any number of old textbooks and journals that refer to these as abstract data types, including texts that show an abstract data type and then explain how to program it as an encapsulated object class. No, the following compiles perfectly fine (using GNU Pascal): That'll teach me to rely on 15-year-old memories. :-) Maybe I'm remembering the wishful thinking from when I used Pascal. -- Darren New / San Diego, CA, USA (PST) My Bath Fu is strong, as I have studied under the Showerin' Monks. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
John W. Kennedy wrote: 360-family assembler, yes. 8086-family assembler, not so much. And Burroughs B-series, not at all. There was one ADD instruction, and it looked at the data in the addresses to determine whether to add ints or floats. :-) -- Darren New / San Diego, CA, USA (PST) My Bath Fu is strong, as I have studied under the Showerin' Monks. -- http://mail.python.org/mailman/listinfo/python-list
Re: python + postgres psql + os.popen
damacy wrote: hello, everyone. ... this works well. however, it does not show me any warning nor error messages if there is one. for example, i am trying to create a table which already exists in the database, it should show me a warning/error message saying there already is one present in the database, or something like that. can anyone help me? I recently needed to use psql from python on a computer that I couldn't install psycopg on and I used something similar to this to do it (I edited the code slightly to make it clearer): from subprocess import Popen, PIPE # Pass the password through an environment # variable to prevent psql asking for it. psql_env = dict(PGPASSWORD='') # Create the subprocess. proc = Popen(cmd, shell=True, env=psql_env, stdout=PIPE, stderr=PIPE) # Try reading it's data. data = proc.stdout.read() # Check for errors. err = proc.stderr.read() if err: raise Exception(err) It worked nicely for me, YMMV. Hope that helps, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: VPW: T-Shirt design contest
Bruno Desthuilliers submitted this really cool rant/essay/something from Tim Lesher that I hadn't seen before. I think that the original source is: http://apipes.blogspot.com/2005/01/choose-python.html Choose Python. Choose readability. Choose the simple over the complex and the complex over the complicated. Choose dynamic typing. Choose duck typing. Choose decorators. Choose generators. Choose metaclasses if you don’t value your sanity. Choose to import this. Choose an almost-fanatical devotion to the BDFL, unless he comes up with something like optional static typing, in which case choose to whine about it in your blog until he stops. Choose Effbot. Choose Timbot. Choose wx. Choose to come up with a bloody implementation before spouting off on comp.lang.python or Python-Dev. Choose the explicit rather than the implicit. Choose one obvious way to do it, especially if you are Dutch. Choose list comprehensions. Choose Paul Graham’s essays and s/LISP/Python/g. Choose Jython when your marketing people choose Java. Choose speed of development over speed of execution, but when in doubt, import psyco. Choose to finish early and laugh at your colleagues as they waste their miserable lives bowing down in subservience to that sadistic little C++ compiler. Choose your future. Choose Python. I think that it might be a bit long to put on a T-Shirt but it is definitely cool :-) Still collecting ideas at: http://www.vanpyz.org/conference/tshirt_contest.html Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Feed wxComboBox with dictionary/hash
Roland Rickborn wrote: Hi folks, ... As the subject says, I'd like to feed a wx.ComboBox with a dictionary/hash. According to the posting of Stano Paska (wxComboBox combobox, 20 Jul. 2004), there seems to be a way to do this: You must use something like combo.Append('aaa', 'a') combo.Append('bbb', 'b') ... My problem is: my data has thousands of entries. Therefore, I'd like to feed the combobox with a dictionary (which itself is fed by a database query). My first question: how can a wx.ComboBox be fed by a dictionary? ... TIA, Roland R. I don't know if this is the best way to do this, but you could just feed the wx.ComboBox from the dict in a loop like this: for k, v in data_dict.iteritems(): combo.Append(k, v) From the manual link that Iain King posted (http://wxwidgets.org/manuals/2.6.3/wx_wxcontrolwithitems.html#wxcontrolwithitems) it appears that you might be able to pass a list of strings to the Append() method. However, it also appears that you wouldn't be able to associate any clientData with the strings. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Rob Thorpe wrote: Its easy to create a reasonable framework. Luca Cardelli has given the most convincing one in his seminal tutorial Type Systems, where he identifies typed and safe as two orthogonal dimensions and gives the following matrix: | typed | untyped ---+---+-- safe | ML| Lisp unsafe | C | Assembler Now, jargon dynamically typed is simply untyped safe, while weakly typed is typed unsafe. The real objection to this was that latently/dynamically typed languages have a place in it. But some of the advocates of statically typed languages wish to lump these languages together with assembly language a untyped in an attempt to label them as unsafe. No, see above. And I would assume that that is how most proponents of the typed/untyped dichotomy understand it. - Andreas -- http://mail.python.org/mailman/listinfo/python-list
struct.unpack on 64-bit platforms
Hi, I am trying to unpack a 32-bit unsigned integer from a string using struct.unpack. so using string.unpack('L', data) would work fine on 32-bit systems, But apparently, on 64-bit platforms it tries to read 64-bit unsigned integer (since that's what the C Type unsigned long means on 64-bit platforms). So what's the way to make it read exactly 32-bits, on all platforms? Thanks, Nadav -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack on 64-bit platforms
Nadav Samet wrote: Hi, I am trying to unpack a 32-bit unsigned integer from a string using struct.unpack. so using string.unpack('L', data) would work fine on 32-bit systems, But apparently, on 64-bit platforms it tries to read 64-bit unsigned integer (since that's what the C Type unsigned long means on 64-bit platforms). So what's the way to make it read exactly 32-bits, on all platforms? Looking into the docs, prepending your format string with = should make L exactly 32 bits on each platform. Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: tkMessagebox.askyesno always returns False
I've managed to narrow down the circimstances in which the error occurs. The application is a file manager (not terribly original,I know, but my main purpose is to gain experience in using Tkinter). It displays the contents of a directory in a list box, and then applies the function (in this case rename) to the selected items. There is also a secondary list, named tag_list, which can be loaded from disc and used to preselect files. If I call the function filter_taglist once, it behaves itself but after I load a differenct tag list and repeat, then the confirm dialog always returns False and the action fails. I'm baffled Code snippets below show 1. Loading the tag file from disc 2. Matching the tag file to the main file list 3. Renaming all selected files (comments starting ## have been added in this post) code # Load from file def load_taglist(self,ask_file_name=1): #if ask_file_name get tagfile name if ask_file_name: a=fd.askopenfilename(title='Tag File',initialdir=os.path.split(self.tagfile)[0],filetypes=[('Tagfiles','*.tag'),('All files','*')]) if a=='': return self.tagfile=a ## entTag is an entry bix which shows the name of the current tag file self.entTag.delete(0,tk.END) self.entTag.insert(0,os.path.split(self.tagfile)[1]) # read file self.taglist=[] try: fp=file(self.tagfile,'r') while 1: a=pstring(fp.readline()) if a.text=='': break a.stripcrlf() self.taglist.append(a.text) fp.close() except: mb.showerror(self.tagfile,'Error reading from tag file') self.show_taglist() /code code ## This function reads every file in the list box and checks it against the tag list def filter_taglist(self): for i in range(self.lstFiles.size()): f=self.lstFiles.get(i) if f in self.taglist: self.lstFiles.select_set(i) self.lstFiles.see(i) /code code ## This function applies a user specified function to each selected file def file_control(self,action): ## set up list of files - element 0 is the path and elements 1 up are the files ## get_listbox_contents(1) is a function which returns a list of ## listbox selected contents (instead of just their position number) file_list=[self.file_path,]+widget(self.lstFiles).get_listbox_contents(1) exit_flag=0 file_count=len(file_list)-1 if file_count==0: mb.showwarning(self.title,action+': No files selected') return # Initial conditions. If the user cancels, or the conditions are insufficient, # set an escape flag if action=='Rename': i=mb.askyesno(file_list[0],'Ok to rename %d selected file(s)' % file_count) if i==0: exit_flag=1 ## etc code -- http://mail.python.org/mailman/listinfo/python-list
Re: VPW: T-Shirt design contest
Brian Quinlan wrote: Bruno Desthuilliers submitted this really cool rant/essay/something from Tim Lesher that I hadn't seen before. I think that the original source is: http://apipes.blogspot.com/2005/01/choose-python.html (snip) I think that it might be a bit long to put on a T-Shirt but it is definitely cool :-) I do have the (A4 format) printout of the PDF version on the wall, and it would definitively fit the back of a T-shirt !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Status of optional static typing in Python?
Hi guys, I'm looking at developing a somewhat complex system, and I think some static typing will help me keep limit my confusion. I.e.: http://www.artima.com/weblogs/viewpost.jsp?thread=87182 Does anyone know if/when that feature may become part of Python? Thanks very much, Christian -- Christian Convey Computer Scientist, Naval Undersea Warfare Centers Newport, RI (401) 832-6824 [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
George Neuner sez: On Wed, 21 Jun 2006 16:12:48 + (UTC), Dimitri Maziuk [EMAIL PROTECTED] wrote: George Neuner sez: On Mon, 19 Jun 2006 22:02:55 + (UTC), Dimitri Maziuk [EMAIL PROTECTED] wrote: Yet Another Dan sez: ... Requiring an array index to be an integer is considered a typing problem because it can be checked based on only the variable itself, whereas checking whether it's in bounds requires knowledge about the array. You mean like subtype MyArrayIndexType is INTEGER 7 .. 11 type MyArrayType is array (MyArrayIndexType) of MyElementType If the index computation involves wider types it can still produce illegal index values. The runtime computation of an illegal index value is not prevented by narrowing subtypes and cannot be statically checked. My vague recollection is that no, it won't unless _you_ explicitly code an unchecked type conversion. But it's been a while. You can't totally prevent it ... if the index computation involves types having a wider range ... The point is really that the checks that prevent these things must be performed at runtime and can't be prevented by any practical type analysis performed at compile time. I'm not a type theorist but my opinion is that a static type system that could, a priori, prevent the problem is impossible. Right, but if you look carefully at the paragraph I originally fup'ed to, you'll notice that it doesn't say runtime or compile-time. I was commenting on array bounds not a typing problem bit -- it is if you define the index as distinct type, and there is at least one language that supports it. In this context I don't think it matters when the check is performed. It does matter in the larger context of this thread, though. IMO the important part here is that the crash report clearly points to the caller code that generated illegal index, not to my library code. That is the basic argument in favour of compile time error checking, extended to runtime errors. I don't really care if it's the compiler or runtime that tells the luser your code is broken, as long as it makes it clear it's *his* code that's broken, not mine. Dima -- I like the US government, makes the Aussie one look less dumb and THAT is a pretty big effort. -- Craig Small -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Matthias Blume [EMAIL PROTECTED] writes: Pascal Bourguignon [EMAIL PROTECTED] writes: Moreover, a good proportion of the program and a good number of algorithms don't even need to know the type of the objects they manipulate. For example, sort doesn't need to know what type the objects it sorts are. It only needs to be given a function that is able to compare the objects. Of course, some statically typed languages handle this sort of thing routinely. Only a few primitive functions need specific types. Your sort function from above also has a specific type -- a type which represents the fact that the objects to be sorted must be acceptable input to the comparison function. Well, not exactly. sort is a higher level function. The type of its arguments is an implicit parameter of the sort function. (sort Hello World (function char=)) -- HWdellloor (sort '(52 12 42 37) (function =)) -- (12 37 42 52) (sort (list (make-instance 'person :name Pascal) (make-instance 'unit :name Pascal) (make-instance 'programming-language :name Pascal)) (lambda (a b) (string= (class-name (class-of a)) (class-name (class-of b) -- (#PERSON #x205763FE #PROGRAMMING-LANGUAGE #x205765BE #UNIT #x205764DE) In Common Lisp, sort is specified to take a parameter of type SEQUENCE = (or vector list), and if a list it should be a proper list, and a function taking two arguments (of any type) and returning a generalized boolean (that is anything can be returned, NIL is false, something else is true) So you could say that: (sort (sequence element-type) (function (element-type element-type) boolean)) -- (sequence element-type) but element-type is not a direct parameter of sort, and can change for all calls event at the same call point: (mapcar (lambda (s) (sort s (lambda (a b) (= (sxhash a) (sxhash b) (list (vector 52 12 42 37) (list 52 12 42 37) (list abc 'def (make-instance 'person :name Zorro) 76))) -- (#(12 37 42 52) (12 37 42 52) (76 #PERSON #x2058D496 DEF abc)) So basically, you've got a big black box of applicaition code in the middle that doesn't care what type of value they get, and you've got a few input values of a specific type, a few processing functions needing a specific type and returning a specific type, and a few output values that are expected to be of a specific type. At anytime, you may change the type of the input values, and ensure that the needed processing functions will be able to handle this new input type, and the output gets mapped to the expected type. ...or you type-check your black box and make sure that no matter how you will ever change the type of the inputs (in accordance with the interface type of the box) you get a valid program. When? At run-time? All the modifications I spoke of can be done at run-time in Lisp. -- __Pascal Bourguignon__ http://www.informatimago.com/ The mighty hunter Returns with gifts of plump birds, Your foot just squashed one. -- http://mail.python.org/mailman/listinfo/python-list
Re: OverflowError: math range error...
Sheldon wrote: Hi, I have a written a script that will check to see if the divisor is zero before executing but python will not allow this: if statistic_array[0:4] 0.0: statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array \ [0,4]),1.0))/100.0 Does anyone know why Python is complaining: statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array[0,4]),1.0))/100.0 OverflowError: math range error and how do I get around this problem? This stupid because there is a if statement preventing this dividing by zero. Sincerely, Sheldon I don't know what special math modules you're using, but python usually raises ZeroDivisionError for divide-by-zero problems. Try printing the intermediate values of each step in your problem code. d = divide(statistic_array[0,0:4], statistic_array[0,4]) print d m = multiply(d, 1.0) print m i = int(m) print i statistic_array[0,0:4] = i That might help you track down what's wrong. -- http://mail.python.org/mailman/listinfo/python-list
Re: OverflowError: math range error...
Sheldon wrote: Hi, I have a written a script that will check to see if the divisor is zero before executing but python will not allow this: if statistic_array[0:4] 0.0: statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array \ [0,4]),1.0))/100.0 Does anyone know why Python is complaining: statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array[0,4]),1.0))/100.0 OverflowError: math range error and how do I get around this problem? This stupid because there is a if statement preventing this dividing by zero. What kind of arrays are you using? If it's Numeric (and I think it is because numarray and numpy would throw an error at the if: statement), then your test is incorrect. Comparisons yield arrays of boolean values. When a Numeric boolean array is used as a truth value (like in an if: statement), then it will return True is *any* of the values are True. Use Numeric.alltrue(statistic_array[:4] 0.0) instead. Both numarray and numpy throw an exception when one attempts to use arrays as truth values since the desired meaning (alltrue or sometrue) is ambiguous. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Pascal Bourguignon [EMAIL PROTECTED] writes: Matthias Blume [EMAIL PROTECTED] writes: Pascal Bourguignon [EMAIL PROTECTED] writes: Moreover, a good proportion of the program and a good number of algorithms don't even need to know the type of the objects they manipulate. For example, sort doesn't need to know what type the objects it sorts are. It only needs to be given a function that is able to compare the objects. Of course, some statically typed languages handle this sort of thing routinely. Only a few primitive functions need specific types. Your sort function from above also has a specific type -- a type which represents the fact that the objects to be sorted must be acceptable input to the comparison function. Well, not exactly. What do you mean by not exactly. sort is a higher level function. The type of its arguments is an implicit parameter of the sort function. What do you mean by higher-level? Maybe you meant higher-order or polymorphic? [ rest snipped ] You might want to look up System F. So basically, you've got a big black box of applicaition code in the middle that doesn't care what type of value they get, and you've got a few input values of a specific type, a few processing functions needing a specific type and returning a specific type, and a few output values that are expected to be of a specific type. At anytime, you may change the type of the input values, and ensure that the needed processing functions will be able to handle this new input type, and the output gets mapped to the expected type. ...or you type-check your black box and make sure that no matter how you will ever change the type of the inputs (in accordance with the interface type of the box) you get a valid program. When? When what? -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expressiveness in a Computer Language
Marshall wrote: In this simple example, the static case is better, but this is not free, and the cost of the static case is evident elsewhere, but maybe not illuminated by this example. Ugh, please forgive my ham-fisted use of the word better. Let me try again: In this simple example, the static case is provides you with a guarantee of type safety, but this is not free, and the cost of the static case may be evident elsewhere, even if not illuminated by this example. Marshall -- http://mail.python.org/mailman/listinfo/python-list