Re: python interfaces
Sion Arrowsmith wrote: > hyperboreean <[EMAIL PROTECTED]> wrote: >> Why doesn't python provide interfaces trough its standard library? > > Because they're pointless. Wrong. I'm using Eclipse with the Java Development Tools (JDT) who do a wonderful job using interfaces to perform lots of checking, warning and code generation *nearly in real time while I am editing my code*. Because JDT knows interfaces it knows what to do and to suggest. > Java interfaces are a hack around the complexities of multiple > inheritence. A hack is something applied subsequently to solve a software problem while avoiding large changes. Java interfaces originate from careful language design. You are free to dislike Java interfaces but calling them a hack is just plain wrong. Once software becomes really big interfaces are very useful to handle complexity. Ever wondered why the Zope people introduced interfaces in their Python code? > Interfaces used purely with the idea of type safety provide > precious little gain for the added clutter and inconvenience. An interface is a software specification allowing you to use a software package without extensive code studies. This is a good thing. Interfaces have nothing to do with multiple inheritance and are not about type safety in the first place. They just tell you how to connect, how to plug in. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: python interfaces
Sion Arrowsmith wrote: > hyperboreean <[EMAIL PROTECTED]> wrote: >> Why doesn't python provide interfaces trough its standard library? > > Because they're pointless. Wrong. I'm using Eclipse with the Java Development Tools (JDT) who do a wonderful job using interfaces to perform lots of checking, warning and code generation *nearly in real time while I am editing my code*. Because JDT knows interfaces it knows what to do and to suggest. An interface is a software specification allowing you to use a software package without extensive code studies. This is a good thing. > Java interfaces are a hack around the complexities of multiple > inheritence. A hack is something applied subsequently to solve a software problem while avoiding large changes. Java interfaces originate from careful language design. You are free to dislike Java interfaces but calling them a hack is just plain wrong. Once software becomes really big interfaces are very useful to handle complexity. Ever wondered why the Zope people introduced interfaces in their Python code? > Interfaces used purely with the idea of type safety provide > precious little gain for the added clutter and inconvenience. An interface is a software specification allowing you to use a software package without extensive code studies. This is a good thing. Interfaces have nothing to do with multiple inheritance. They just tell you how to connect, how to plug in. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
Martin v. Löwis wrote: > Python code is written by many people in the world who are not familiar > with the English language, or even well-acquainted with the Latin > writing system. I believe that there is a not a single programmer in the world who doesn't know ASCII. It isn't hard to learn the latin alphabet and you have to know it anyway to use the keywords and the other ASCII characters to write numbers, punctuation etc. Most non-western alphabets have ASCII transcription rules and contain ASCII as a subset. On the other hand non-ascii identifiers lead to fragmentation and less understanding in the programming world so I don't like them. I also don't like non-ascii domain names where the same arguments apply. Let the data be expressed with Unicode but the logic with ASCII. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: is laziness a programer's virtue?
Xah Lee wrote: > For those reading this, i also want to mention, that although i think > Perl is a motherfucking language on earth, and its leader and > “inventor” Larry Wall has done massive damage to the computing world, > but Perl the community is in fact very tolerant in general (which is > to Larry's credit), when compared to the motherfucking Pythoners (who > knew SHIT) as well as many of the self-appointed lisp bigwig > characters. Be careful not to damage the English language by making "motherfucking" a compliment :) -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: scipy 0.52 det crashes python
Robert Kern schrieb: > Most likely your build of scipy was built with an ATLAS library that uses SSE2 > instructions (IIRC) while your processor doesn't support those instructions. > The > solution is to rebuild scipy with an ATLAS library built for your platform. Thanks, Robert. -- Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
scipy 0.52 det crashes python
I tried some scipy examples using scipy 0.52, numpy 1.02 and python 2.5 on a WinXP SP2 machine. numpy.linalg.det() works but scipy.linalg.det() crashes python. Has anybody experienced this and can point me to a solution? Thanks for your help. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: explicit self revisited
Steven D'Aprano schrieb: > Implicit self will never be used for Python, because it is redundant so > long as there is a need for explicit self, and there is a need for > explicit self because there are a number of basic, dare I say > *fundamental* programming techniques that require an explicit self. > > For example, delegation. > > class MyClass(Parent): > def method(self, arg): > Parent.method(self, arg) > # what are you going to write? Parent.method(,arg) maybe? The idea is: let self (or self.) be represented by the dot alone, therefore: Parent.method(., arg) # :) > Here's another fundamental technique that implicit self breaks. > > class MyList(list): > def __iadd__(self, other): > # in-place addition > other = transform(other) # do something to the argument > super(MyList, self).__iadd__(other) # call the superclass > # could be written .__class__.__iadd__(other) > # BUT be aware the semantics are NOT the same! > return self # and return the suitably modified instance return . > You can't explicitly return the instance unless you have an explicit name > for it. (And if you are thinking of creating more magic syntax that > implicitly returns self, just don't bother.) No magic. Just a dot. But perhaps a dot is too tiny. We could take JUST_ME or ME_AND_BOBBY_MCGEE instead, of course as a reserved keyword followed by a dot ;) Thanks for your hints, Steven. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: explicit self revisited
Michele Simionato wrote: > Peter Maas wrote: >> All these reasons are valid and retained by the following suggestion: let >> self be represented by the dot > > This suggestion has been discussed in the past (I remember having the > same idea myself when I first learned Python). But at the end I believe > the explicit 'self' is a better solution, because there are cases where > it is useful to have it Thanks, Michele. My intention wasn't to abandon explicit self but to replace it by a shorter and unique entity. I searched a little for similar suggestions in the past but didn't find them so I decided to post. I admit that my suggestion was half-baked. But at least I learned something: a heated debate isn't bound to become an endless thread if the OP abstains from answering idiot replies ;) -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
explicit self revisited
The Python FAQ 1.4.5 gives 3 reasons for explicit self (condensed version): 1. Instance variables can be easily distinguished from local variables. 2. A method from a particular class can be called as baseclass.methodname(self, ). 3. No need for declarations to disambiguate assignments to local/instance variables. All these reasons are valid and retained by the following suggestion: let self be represented by the dot, e.g. replace class someTest(unittest.TestCase): def setUp(self): self.ly = yList() self.m1 = self.ly[0].message self.m2 = self.ly[1].message self.m3 = self.ly[2].message def testList(self): self.assertEqual(len(self.ly),3) self.assertEqual(self.m1),"Ho") self.assertEqual(self.m2),"HoHo") self.assertEqual(self.m3),"HoHoHo") by class x(unittest.TestCase): def .setUp(): .ly = yList() .m1 = .ly[0].message .m2 = .ly[1].message .m3 = .ly[2].message def .testList(): .assertEqual(len(.ly),3) .assertEqual(.m1),"Ho") .assertEqual(.m2),"HoHo") .assertEqual(.m3),"HoHoHo") Methods could still be referenced e.g. as x.testList(someInstance). The current self syntax could still be valid (for backward compatibility.) Advantages of the new syntax: 1. Enhanced readability, less verbosity 2. Unambiguous: no need to tell newbies that a virtuous pythoneer has to stick to self instead of abbreviate it as s. 3. One argument less for "Python OO bolted on" propaganda. The second reason is the most important for me. I consider syntax control by a code of conduct as lame. The "leading dot" syntax could have further advantages: class x(object): a = "" # static variable .b = 0 # instance variable This could replace parameterless __init__ methods. Methods without leading dots could be considered static without a staticmethod decorator. For backward compatibility this behaviour should be explicitly activated e.g. by __autostatic__ = true. What do you think? -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
Peter Decker wrote: > I think you should take a good look at Dabo and the visual tools they > are creating. Thanks for the hint, Peter. I've heard of Dabo and it's on my list of things to be inspected. Perhaps my postings have been misunderstood. I don't feel uneasy with Python. I'm using it since 4 years and know how to find the tools I need. But I feel uneasy with an excessive readiness of some c.l.p participants to accept Python as it is and even to react defiantly on friendly suggestions how to make Python a more obvious choice for newcomers. I think this is important for Python's survival. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
Kay Schluehr wrote: > Peter Maas wrote: >> How many programmers don't use Python because of the self issue? > > The only reason I know why self shall not be inforced is reducing the > number of troll postings. The only method that works to reduce the number of troll postings is: spot them, then ignore them. But some lengthy threads in c.l.p suggest that quite a few c.l.p participants enjoy conversation with trolls or are slow at spotting :) -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
Paul Boddie wrote: > People who bring up stuff about self and indentation are just showing > their ignorance, in my opinion, since Python isn't the first language > to use self in such a way, and many C++ and Java programs use this > pervasively in order to make attribute scope explicit, whereas the > indentation matter is only troublesome with bad editing practices. I > don't think the community should spend any more time on these > criticisms. How many programmers don't use Python because of the self issue? I'm not for changing the semantics here but when I wrote a method with lots of selfs recently I tried how it would look like if it would be allowed not to write down 'self', i.e. from def deposit(self, amount): self.balance = self.balance + amount to def deposit( , amount): .balance = .balance + amount I see an advantage in not mentioning 'self': using shorter alternatives like 'my' is possible but considered bad style. I find it unsatisfactory to provide a degree of freedom and not wanting it to be used. Leaving out 'self' is like leaving out block markers. You leave out something that's a matter of taste (self, me, my, block marker positions) and bring the code in minimal form. Explicit use of self could of course still be allowed. And a favorite argument against Python would become pointless. > However, the GIL and issues of tools and IDEs should be considered in a > more sophisticated way. If I wouldn't read discussions about it I wouldn't probably know that it exists. But as far as I have understood removing the GIL means a lot of work and breaking existing code. Perhaps the GIL will die naturally with the advent of a production ready PyPy. And the Twisted people keep telling "Repeat with me: there are no threads" :) > Meanwhile, whilst not an IDE advocate myself, there really does need to > be further improvements in the analysis of Python source code so that > people can build improved tools to check Python programs for obvious > "compile-time" errors and to inspect the behaviour of large amounts of > code. I agree. One reads occasionally on the python-dev or python-3000 mailing > lists that some proposed change or other may or may not have an impact > on "real world" systems such as the standard library, but that no-one > can really say: we need to move beyond the "Python is just so dynamic" > meme and develop tools like PyLint and PyChecker much further. I find it important that Python allows dynamic coding but I agree that it should allow more compile time checks which would probably also help to produce faster code. > This kind of stuff can be tackled by providing better introductory, > educational or promotional material, with the latter especially > important to stop the uninformed "rubbishing" that advocates of certain > other languages seem particularly inclined to indulge in. I don't think so because advocates tend to use arguments just because they are handy, not because they don't know better. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
Bruno Desthuilliers wrote: > Peter Maas wrote: [...] >> a reference implementation for web programming as part of the standard >> library, > > wsgiref is part of the 2.5 stdlib. Yes, but it's not an implementation. Think of something like Tomcat for the Java Servlet Specification. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
Bruno Desthuilliers schrieb: > Marc 'BlackJack' Rintsch wrote: > (snip) > Python itself is a RAD tool. > > +1 QOTW No, please stop self-assuring, self-pleasing QOTWs! This afternoon I was in the local book warehouse and went to the computer book department. They had banned 2-3 Python books together with some Perl- and C/C++ stuff into the last row. At the regular place I found a huge pile of Java books and - in comparison to Java - a small but growing number of books about Ruby in general, Ruby on Rails and - new to me - JRuby. Now I don't think that Ruby is a bad language. But I think Python is better and it started earlier. I don't know whether Ruby on Rails was a fluke or the result of clever analysis. Since a large part of programming is web programming it is not bad to have a good and visible tool in place to attract programmers. It is also a good idea to hook on Java's success but while Jython 2.2 is in alpha state since 3 years I see an increasing number of books/articles telling how to migrate from Java to (J)Ruby. Since I started using Python 4 years ago I hear Ruby people announce with an amazing audacitiy that Ruby is bound to be number one and will for sure leave Python behind. To prevent this to happen parts of the Python community should have a more critical attitude to the language. Too often I hear the same mantras being repeated over and over again (GIL, self, IDE etc.). I don't say these mantras are all wrong but perhaps it would be good to remove the GIL just to stop people talking about Python's lack of multi-threading or polish Python's class syntax to stop people talking about Python's OO being bolted on etc. Programmers often choose their languages by very silly reasoning (silliest being the indentation issue) and maybe we should take the silliness into account instead of laughing about those silly folks. I for my part would be happy to see a Delphi-like RAD tool for Python, a reference implementation for web programming as part of the standard library, Jython 2.5, Python for PHP or whatever attracts new programmers. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
Diez B. Roggisch wrote: > The amazing flexibility stems from the fact that it is _runtime_. This is > _exactly_ the difference between static and dynamic typing. Not _exactly_. You can have static typing in an interpreted language (Java) and dynamic typing in a machine language (Basic with variants). -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style classes slower than old-style classes? (Was: n-body problem at shootout.alioth.debian.org)
Peter Maas schrieb: > 1 runs of nbody.py, time in sec Correction: 1 iterations of advance(). -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: New-style classes slower than old-style classes? (Was: n-body problem at shootout.alioth.debian.org)
Richard Jones wrote: > Giovanni Bajo wrote: [...] >> Anyway, this is a bug on its own I believe. I don't think new-style >> classes are meant to be 25% slower than old-style classes. Can any guru >> clarify this? > > Please try 2.5 - there's been significant optimisation work put into 2.5 I checked that: 1 runs of nbody.py, time in sec | classic | new-style | n/c ---+-+---+-- python 2.4 | 2.33 s | 2.89 s | 1.24 python 2.5 | 2.06 s | 2.61 s | 1.27 2.4/2.5 | 1.13 | 1.11 |- You are right, 2.5 is better than 2.4. But the runtime penalty for using new-style classes remains. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
Paul McGuire wrote: > The advance method is the most fertile place for optimization, since it is > called approximately n(n-1)/2 times (where n=2E7). I was able to trim about > 25% from the Python runtime with these changes: [...] My results: Your changes: 18% runtime decrease Your changes + objects->lists: 25% runtime decrease The Python program is much closer to the Perl program then (~2250 vs 1900 sec) but replacing the objects by lists is not worth the effort because the gain is small and the Python program becomes less readable. Taking arrays (from module array) instead of lists increases runtime by 19%! If it weren't for the shootout I would of course take psyco and numpy. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
Giovanni Bajo wrote: > Did you try using an old-style class instead of a new-style class? The original program has an old style class, changing it to a new style class increases run time by 25% (version is 2.4.3 btw). -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
[EMAIL PROTECTED] wrote: >> You might also put the outer loop calling function advance so many >> times, into the advance function: > > Remember that the autors of the Shootout refuse some changes to the > code (like this one), to allow a fair comparison. The rules are strict. I'm only aware of the rule that the language has to be used "as-is", e.g. you must not encapsulate time-critical parts in a C extension and announce the result as "fast Python". To put the outer loop inside a function is a degree of freedom which is available in every language so should be allowed in a shoot-out. The global arrays in the Perl program are on the same track. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
Matteo wrote: > Of course, numpy is not a standard package (though there is a proposal > to add a standard 'array' package to python, based of numpy/numeric), > but if you want to do any numerics with python, you shouldn't be > without it. I know that nbody.py could be speeded up by psyco and numpy but I was curious why plain Python was slower than plain Perl. Thanks for your hints, guys! -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
John J. Lee wrote: > Replacing ** with multiplication in advance() cut it down to 0.78 > times the original running time for me. That brings it along side > PHP, one place below Perl (I didn't bother to upload the edited script). I tried this also but got only 90%. Strange. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
n-body problem at shootout.alioth.debian.org
I have noticed that in the language shootout at shootout.alioth.debian.org the Python program for the n-body problem is about 50% slower than the Perl program. This is an unusual big difference. I tried to make the Python program faster but without success. Has anybody an explanation for the difference? It's pure math so I expected Perl and Python to have about the same speed. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Create TarFile using python
itzel wrote: > I have a problem. I'm new in python and I need a script that group a > list of files using Tar file utility and then, compress that block > using a compress utility (gzip i think). I already found some > information and i try to apply it, but my scripy doesn't work. Did you look here?: http://docs.python.org/lib/tar-examples.html Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Test for number?
Tim Williams wrote: > On 04/09/06, Dr. Pastor <[EMAIL PROTECTED]> wrote: >> In the following code I would like to ascertain >> that x has/is a number. What the simplest TEST should be? def isnumber(value): try: value/1 return true except TypeError: return false I think this works for all builtin types. Of course one could overload '/' for a non-numeric class. The best solution would be to introduce a super class base_number for int, long, float and decimal, similar to base_string for str and unicode. This would probably be not too hard to implement and surely not break old code :) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you want in a new web framework?
Alex Martelli wrote: > Peter Maas <[EMAIL PROTECTED]> wrote: > >> Cliff Wells wrote: >>> On Wed, 2006-08-23 at 22:13 +0200, Peter Maas wrote: >>>> Alex Martelli wrote: >> [...] >>>>> I have already suggested to the BDFL that he can remedy this situation >>>>> in Py3k: all he has to do, of course, is to add a LOT more keywords. >>>> Here is another remedy: he adds one of the frameworks to the standard >>>> library :) >>> That didn't help Tk maintain a monopoly on Python GUI toolkits. >> I must not be a monopoly. A center of gravity would be nice, too. > > <http://www.youtube.com/watch?v=hFGz-t5R0BE?> .... > > [it helps to know some Italian, No problem: "Centro di Gravità Permanente" = "permanent center of gravity" :) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you want in a new web framework?
[EMAIL PROTECTED] wrote: >> Here is another remedy: he adds one of the frameworks to the standard >> library :) >> >> Peter Maas, Aachen > > But there are already 3 ;-) > > http://docs.python.org/lib/module-BaseHTTPServer.html > http://docs.python.org/lib/module-SimpleHTTPServer.html > http://docs.python.org/lib/module-CGIHTTPServer.html These aren't web frameworks, just HTTP servers. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you want in a new web framework?
Cliff Wells wrote: > On Wed, 2006-08-23 at 22:13 +0200, Peter Maas wrote: >> Alex Martelli wrote: [...] >>> I have already suggested to the BDFL that he can remedy this situation >>> in Py3k: all he has to do, of course, is to add a LOT more keywords. >> Here is another remedy: he adds one of the frameworks to the standard >> library :) > > That didn't help Tk maintain a monopoly on Python GUI toolkits. I must not be a monopoly. A center of gravity would be nice, too. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you want in a new web framework?
Alex Martelli wrote: > Indeed, it has been truthfully observed that Python's the only language > with more web frameworks than keywords. > > I have already suggested to the BDFL that he can remedy this situation > in Py3k: all he has to do, of course, is to add a LOT more keywords. Here is another remedy: he adds one of the frameworks to the standard library :) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the ascii code of Chinese characters?
Gerhard Fiedler wrote: > Well, ASCII can represent the Unicode numerically -- if that is what the OP > wants. No. ASCII characters range is 0..127 while Unicode characters range is at least 0..65535. > For example, "U+81EC" (all ASCII) is one possible -- not very > readable though -- representation of a Hanzi character (see > http://www.cojak.org/index.php?function=code_lookup&term=81EC). U+81EC means a Unicode character which is represented by the number 0x81EC. There are some encodings defined which map Unicode sequences to byte sequences: UTF-8 maps Unicode strings to sequences of bytes in the range 0..255, UTF-7 maps Unicode strings to sequences of bytes in the range 0..127. You *could* read the latter as ASCII sequences but this is not correct. How to do it in Python? Let chinesePhrase be a Unicode string with Chinese content. Then chinesePhrase_7bit = chinesePhrase.encode('utf-7') will produce a sequences of bytes in the range 0..127 representing chinesePhrase and *looking like* a (meaningless) ASCII sequence. chinesePhrase_16bit = chinesePhrase.encode('utf-16be') will produce a sequence with Unicode numbers packed in a byte string in big endian order. This is probably closest to what the OP wants. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Import bug: Module executed twice when imported!
Michael Abbott wrote: > In article <[EMAIL PROTECTED]>, > Michael Abbott <[EMAIL PROTECTED]> wrote: > >> --- test.py --- >> import imptest >> execfile('subtest.py', dict(__name__ = 'subtest.py')) >> --- imptest.py --- >> print 'Imptest imported' >> --- subtest.py --- >> import imptest >> --- >> >>$ python test.py >>Imptest imported >>Imptest imported >>$ > > I claim this as an unreported (and highly obscure) Python bug. The docs tell us (http://www.python.org/doc/2.4.2/lib/built-in-funcs.html): - begin --- execfile(filename[, globals[, locals]]) This function is similar to the exec statement, but parses a file instead of a string. It is different from the import statement in that it does not use the module administration -- it reads the file unconditionally and does not create a new module. - end - I claim this as a well documented (and thus exspectable) Python behaviour. execfile() just executes a file unconditionally without searching in sys.modules. That's its purpose, otherwise it would be a synonym of the import statement. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming language productivity
John Bokma wrote: > Also note that Python programmers write more lines/hour which they need to > finish in the same time as Perl programmers :-D. You probably want to say that a Python program tends to have more lines than an equivalent Perl program. I think that a LOC comparison between a language that enforces line breaks and another language that enables putting an lots of code in one line doesn't make much sense. I wonder why comparisons aren't made in terms of word count. Word count would include literals, constants, variables, keywords, operators, bracket- and block delimiter pairs. Python indent/unindent would of course also count as block delimiters. I think this would be a more precise measure for software size. Peter Maas, Aachen. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can Python installation be as clean as PHP?
Jack wrote: > With Python, things are really messy. I have to run the installer > to install dozens of directories and hundreds of files, and I don't > really know if all of them are necessary. PHP has LOTS of functions in a single namespace. I don't know wether they are in separate files or packed in the exexutable but I'm sure that you don't need them all ;) > Plus, lots of libraries > are in .py, which is of course not as efficient/clean as having all > of the core functions built-in in the C/C++ core, like in PHP. Python is faster than PHP in most situations (2-3x). Look at http://dada.perl.it/shooutout for win32 and http://shooutout.alioth.debian.org for linux. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Roy Smith schrieb: > Python is a very dynamic language. Java is a very static language. What is the difference between "static" and "very static"? Is Java more static than Fortran I? ;) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing interfaces in Python...
Fredrik Lundh schrieb: > Jonathan Daugherty wrote_ > >> # In Python, you would simply call the functions you need. No need to >> # make things that rigidly defined. >> >> Except when you need to handle exceptions when those methods don't >> exist. I think interfaces can definitely be useful. > > so with interfaces, missing methods will suddenly appear out of thin > air ? He probably means that with interfaces one could test compliance with the interface as a whole instead of testing each member and each signature as a single piece. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: convert hex to decimal
[EMAIL PROTECTED] schrieb: > popS = string.join(pop.readlines()) Why not popS = pop.read()? > The output from the second popen is: > > SNMPv2-SMI::enterprises.9.9.168.1.2.1.1.13.51858 = Hex-STRING: 00 00 00 > 26 > > > I need to get the Hex-STRING into the following format: 0.0038.. I know > how to covert 26 to 38 but I haven't figured out how to pad it or place Have look at ljust/rjust(width[, fillchar]) > the decimal point between the while number and the decimal. What's a while number? Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy in scientific computation
Steve Holden schrieb: > sturlamolden wrote: >> First there are a few things I don't like: >> >> 1. Intendation as a part of the syntax, really annoying. >> > Troll. You think this is going away because *you* don't like it? You are over-reacting. Keep in mind that sturlamolden has criticized Python and not you :) I think there is a more convincing reply to indentation phobia: It is natural that compiler and programmer agree on how to identify block structures. Anybody who disagrees should bang his code against the left side or put everything in one line to get rid of annoying line breaks. :) Peter Maas, AAchen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advocacy in scientific computation
Duncan Booth schrieb: > sturlamolden wrote: >> 1. Can python do "pass by reference"? Are datastructures represented by >> references as in Java (I don't know yet). >> > Python only does "pass by reference", although it is more normally referred > to as "pass by object reference" to distinguish it from language where the > references refer to variables rather than objects. > > What it doesn't do is let you rebind a variable in the caller's scope which > is what many people expect as a consequence of pass by reference. If you > pass an object to a function (and in Python *every* value is an object) > then when you mutate the object the changes are visible to everything else > using the same object. Of course, some objects aren't mutable so it isn't > that easy to tell that they are always passed by reference. This is hard to understand for an outsider. If you pass an int, a float, a string or any other "atomic" object to a function you have "pass by value" semantics. If you put a compound object like a list or a dictionary or any other object that acts as an editable data container you can return modified *contents* (list elements etc.) to the caller, exactly like in Java and different from C/C++. Peter Maas, AAchen -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 354: Enumerations in Python
Paul Rubin schrieb: >> But if you have a good usage case for an empty enum, please feel free >> to tell us. > > Do you have a good usage case for the number > 647574296340241173406516439806634217274336603815968998799147348150763731 ? Yes, it could be the value of my property in any currency :) But your argument is wrong. There's no logical or even aesthetical reason to have empty enums. An empty set is an instance of the set type like 0 or your big number are instances of the integer type and are neccessary to make some operations complete. But an empty enum is a *type* without values, therefore a type that cannot be instantiated i.e. a useless type. I don't like Python enums at all. It is kind of "I want to have that C++ thing, too". In Python enums can be emulated so there's no need to have syntactical support for them. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
Peter Maas schrieb: > But tuples mean threefold, twofold etc. and the Latin equivalents > are triplex duplex simples. triplex duplex simplex Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
Dave Hansen schrieb: >> Latin n-tuple >> --- >> ... ... >> triplex triple >> duplexduple >> simplex simple > > When I was in 4th grade, I was taught to count to ten in latin: unos, > duos, trace, quatro, quinque, sex, septem, octem, novem, decem unus duo tres quattuor ... octo ... But tuples mean threefold, twofold etc. and the Latin equivalents are triplex duplex simples. That simple sounds weird may be due to the fact that English speakeers perceive it as a native word rather than a Latin import. > Though I suspect "single" is correct. Consider coronary bypass > operations -- single, double, triple, quadruple... That's OK but single stems from singularis (one-of-a-kind) rather than from simplex (onefold) and doesn't fit as nicely to the other tuples. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you pronounce 'tuple'?
John Salerno schrieb: > Terry Hancock wrote: > >> So what's a 1-element tuple, anyway? A "mople"? "monople"? >> It does seem like this lopsided pythonic creature (1,) ought >> to have a name to reflect its ugly, newbie-unfriendly >> nature. >> >> Are we having fun yet? ;-) > > I kind of like 'moople'. :) tuples are of latin origin, so one can derive the tuple words systematically: Latin n-tuple --- ... ... triplex triple duplexduple simplex simple I wouldn't mind calling (1,) a simple but I'm not a native English speaker so I have no idea wether it sounds ridiculous to English ears. If simple is too simple for you just call it simplum or simplon or simplex. ;) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: html entity to unicode
[EMAIL PROTECTED] schrieb: > Hi, > > I'm parsing html. I have a page with a lot of html enitties for hebrew > characters. When i print what i get are blanks, dots and commas. How > can i decode this entities to unicode charachters? Python doc 13.4 htmlentitydefs -- Definitions of HTML general entities [...] name2codepoint A dictionary that maps HTML entity names to the Unicode codepoints. New in version 2.3. codepoint2name A dictionary that maps Unicode codepoints to HTML entity names. New in version 2.3. Peter Maas Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: What editor shall I use?
Lad schrieb: > What editor shall I use if my Python script must contain utf-8 > characters? > I use XP An extremely capable, easy to use and small editor is Neil Hodgson's SciTE. It's my favorite editor on Windows and Linux. There is a Windows installer at http://users.hfx.eastlink.ca/~gisdev/scite-1.67-setup-3.exe Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: beta.python.org content
Tony Meyer schrieb: >> - The logo does indeed resemble a cross. How about rotating it at 45 deg >>to make it look like an x? Or give it a circular shape? Please note >>that there are no religious motives in this remark :) > > -1. Then what are the motives? I don't like the shape. Snakes and right angles - it's a contradiction. This is just my personal taste. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: beta.python.org content
Steve Holden schrieb: > How does > > http://beta.python.org/about/beginners/ > > look? I like it :) Some minor points: - The logo does indeed resemble a cross. How about rotating it at 45 deg to make it look like an x? Or give it a circular shape? Please note that there are no religious motives in this remark :) - I really liked the different looking Pythons in the logo corner. Couldn't they find asylum somewhere in the new site? - I would prefer stronger, less flimsy colours. But apart from these superficial points: well done :) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: "Dynamic" website content
sophie_newbie schrieb: > Flushing to stdout doesn't seem to work anyway. > > Honestly have no idea how you'd implement it in Javascript so might > have an ask on one of their forums... > I think you need HTTP push to update the client page. See http://wp.netscape.com/assist/net_sites/pushpull.html for information about HTTP push. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie with some doubts.
Claudio Grondi schrieb: >> Im newbie to Python (I found it three weeks ago) , in fact Im newbie to >> programming. I'm being reading and training with the language, but I >> still wondering about what Classes are used to. Could you please give >> me some examples?? [...] > I don't know any really good examples which were able to demonstrate > what Classes are good for and I am in programming already for decades. Then you have in all those decades for sure never seen a GUI program done with the Win32 API (not OO, ugly, hard to grasp) and a Delphi equivalent (OO, elegant, easy). > There is actually no real need for usage of Classes. This is your opinion, not a fact as your wording suggests. If the OP is asking for examples it doesn't make sense to answer "Hey, I don't know any examples". > The notion, that they could be useful comes eventually with longer > programming experience and/or with growing size of the code library. I don't think so. OO is modeled after human reasoning. Look e.g. at phrases like Bob calls a friend, Bob learns math. What is better: Bob.call(friend) or human_call(Bob, friend), Bob.learn(math) or human_learn(Bob, math)? On the other hand there are cases where the emphasis is on the verb, e.g. compute the sine of alpha: sin(alpha) is perfect, no need to code alpha.sin(). Therefore I like hybrid languages like python giving the programmer the freedom to choose an appropriate model. > If you can avoid to learn about them, at least at the beginning, > take the chance - it will save you much trouble and help to get > things done. Excuse me, but to present your personal experience as a law of nature is not very helpful for a newbie seeking for advice not for propaganda. It is plain wrong to claim that procedural programming is kind of natural and OOP is rocket science. > I for myself try to avoid classes where I can, especially > inheritance, because I consider the latter in most cases evil. There are terrible OO libraries out there but this is not a genuine feature of OOP. Bad code can be written in lots of ways. > There are sure many others who can't imagin to program > without classes, so don't conclude that there is a > contradiction here - it's just the question of taste It's not a question of taste it's a question of the kind of problem to solve. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Chris Mellon schrieb: >>There is a company who is developing and marketing a single application. >>It is a simulation software for industrial processes which embodies an >>enormous amount of knowledge accumulated by the hard work of many >>individuals since about twenty years, algorithmic, process, implementation, >>market knowlegde. This application is of great value to the customers >>because it helps them save lots of money and improve the quality of their >>products. No wonder that they have (and are willing) to pay a considerable >>price for it. >> > > > You just described UNIX, which has been all but replaced by open > source projects, and the general state of the operating system market > a few decades ago. No, I didn't describe UNIX. UNIX and OSs in general are software which is needed by everybody who is using a computer. You have many developers all over the world willing to contribute. But the software I mentioned is a highly specialized field with a (compared to OS users) a tiny number of customers and a degree of complexity at least the same as an OS. So I think that an OSS model wouldn't work here. Also using UNIX as an example is qustionable here because of its special history. UNIX was to a large extent developed in academic environments and later closed sourced by AT&T at a time when much OS specific knowledge was available in universities. >>If the company would decide to go open source it would be dead very soon >>because it wouldn't no longer have a competitive advantage. Most customers >>wouldn't see the necessity to pay high prices, the competition would use >>the source code in their own products, the earnings would fall rapidly and >>there wouldn't be enough money availabe to pay highly skilled developpers, >>engineers and scientists for continued development. >> >>In certain sense suppliers and customers ARE enemies because they have >>different interests. The customer will pay a price only if it is neccessary >>to get the product. If he can get it legally for nothing he won't pay anything >>or at least not enough. >> >>So please: continue praising OSS (as I do) but don't make ideological claims >>that it fits everywhere. > You're looking at the wrong things here. What you're describing is > actually a potentially very successfull open source project Successful for whom? > - many > companies, single source, highly technical, high price. An open source > project could easily succeed in this area. Of course, it would not be > in the interest of the current monopoly supplier to open source thier > product. The supplier doesn't have a monopoly. He has competition but the supplier started first, has always been the pacemaker and has therefore an advance. His revenues are based on this advance. If somebody would suggest him to go open source - what would be the advantage for him? Doing business is a game, games are about winning and it isn't realistic to tell a player to commit suicide. > But a third party that started such a project could quite > possibly succeed. There are several 3rd parties all with closed source :) If an OSS 3rd party would enter the game it would have to answer the question how to fund the development. To succeed the OSS player would have to catch up to its closed source competitors. This is anything but easy - there is a lot of knowlegde (a crucial part of it not available for the public) to be worked out. The developers have to earn money, who pays them? I think a lot of people believe OSS isn't about money. This is wrong. Either OSS developers are working in their spare time for their own pleasure. This puts some limits on their projects. Or they are working all the day on OSS projects. Then they have to be paid, e.g. by academic institutions (tax payer) or by companies like IBM and Novell who are funding OSS because they have appropriate business models. There's nothing wrong about this. But to pretend that OSS miraculously solves the money problem for consumers _and_ producers is wrong IMO. There are conditions for OSS for to succeed. It is worthwile to get to know these conditions. To claim that there are no conditions at all and OSS is successful by itself is certainly not true. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
yepp schrieb: > Once you got the model of free and open source software you can't but shake > your head at obfuscating people treating their users as enemies. Sorry but this is naive nonsense. Open source is a good model but it can't be applied everywhere. Look at the following example: There is a company who is developing and marketing a single application. It is a simulation software for industrial processes which embodies an enormous amount of knowledge accumulated by the hard work of many individuals since about twenty years, algorithmic, process, implementation, market knowlegde. This application is of great value to the customers because it helps them save lots of money and improve the quality of their products. No wonder that they have (and are willing) to pay a considerable price for it. If the company would decide to go open source it would be dead very soon because it wouldn't no longer have a competitive advantage. Most customers wouldn't see the necessity to pay high prices, the competition would use the source code in their own products, the earnings would fall rapidly and there wouldn't be enough money availabe to pay highly skilled developpers, engineers and scientists for continued development. In certain sense suppliers and customers ARE enemies because they have different interests. The customer will pay a price only if it is neccessary to get the product. If he can get it legally for nothing he won't pay anything or at least not enough. So please: continue praising OSS (as I do) but don't make ideological claims that it fits everywhere. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Still Loving Python
Mike Meyer schrieb: > I agree. I've tried a number of different gui builders. I find it much > faster to type something like: > > ui.add_button("New", self.new) > ui.add_button("Open", self.open) > ui.add_button("Save", self.save) > ui.add_button("Save As", self.save_as) > > Than have to drag four menu buttons from a pallette, then open the > properties of each one to edit the text of the button and the callback > entry (or whatever dance they need so you can enter the required > text). If you design a moderately complex UI a designer will be faster. It's not the speed of typing vs. dragging that matters. You see the result instantly and don't have to start your program, look, type code, start again and so on. A GUI builder is more pleasant to work with, at least with a good one like Delphi or Qt designer. It's not a good idea to do everything in code. I find it tiresome to create menus and toolbars by writing code. It's not as bad as creating an image by typing addpixel(x,y,color) a million times but it comes close. Creating visual resources visually is the direct way, creating them in code is a detour. Code is too lengthy and too versatile for such a job. -- Peter Maas, Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list
Re: Zope vs Php
Steve schrieb: >>From what I can tell you can't just do > <% > #python code > %> > some title > > this is what we would like to do with session support and things that > php provides? Google for "python web frame works". Most have session support, and some offer Python Code embedded in HTML (e.g. Webware, mod_python and Spyce). I never realized what's so great about this because <% #python code %> some title and print output(python-code) + " some title". are equivalent. Another approach is using Templates. Most web frameworks have Templates. My favorite is Cheetah. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') -- -- http://mail.python.org/mailman/listinfo/python-list
Re: SciPy python 2.4 wintel binaries
jelle schrieb: > I dearly miss having the power of SciPy on my python 2.4 installation. > The topic of SciPy python 2.4 wintel binaries has been discussed before > on this list, but I haven't been able to find a compiled binary. If you really need SciPy, you should install Python 2.3 (Enthought Edition) in a separate directory as long as a Python 2.4 SciPy binary is not available. Python 2.3 EE comes with a bunch of useful additions, e.g. SciPy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bicycle Repair Man usability
Sybren Stuvel schrieb: > I use BRM if I need to rename a function or variable, and that's about > it. I do the rest by hand faster than I can figure out how to use > additional software. Sounds like "I can walk from Aachen to Cologne faster than figure out how to drive a car" ;) I don't know BRM nor any other refactoring tool but for a thorough decision one would have to know the ratio time(learningTool)/time(doingByHand) to calculate the break even point in terms of number(doingByHand). -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: .pth files in working directory
Peter Hansen schrieb: > Peter Maas wrote: >> But sitecustomize.py changes the Python installation, doesn't it? >> This wouldn't be an advantage over putting a .pth file into >> .../site-packages. > > > You can have a local sitecustomize.py in the current directory, which > wouldn't change the Python installation. Would that help? I think this is what I need. Thanks, Peter. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: .pth files in working directory
Michael Ekstrand schrieb: > If top/ is the working directory for your Python interpreter, the > problem is solved automatically. Python puts the current working > directory in the default search path. So, if you run IIS sets the the site path as working directory. So I would probably have to change wd at the beginnig of every module. Each module would read the top location from a .pth file in its directory. Yes that's possible. Thanks for your help. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: module not found in IIS virtual dir
Peter Maas schrieb: > I'm trying to call python scripts from IIS in the following tree: [...] > If I run selectFiles.py from the command line everything is ok. But > if I call it via IIS (http://localhost/vselect/selectFiles.py) there > is an error "No module named util" [...] Forget it. It was an ACL issue. Silly mistake. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: .pth files in working directory
Peter Hansen schrieb: > Not sure from the above description exactly what it is you want, I want a tree top/ install.py sub1/ __init__.py mod1.py sub2/ mod2.py where I can do "from sub1 import mod1" in mod2.py no matter what the absolute path of top is. To achieve this I start install.py once to retrieve the absolute dir of itself (= abspath of top/) and creates .pth files with its absolute dir in every subdirectory. > but > generally such non-standard sys.path and .pth manipulations are best > handled by a sitecustomize.py file, possibly which makes its own calls > to site.addsitedir() and such. Try "help(site)" for more. But sitecustomize.py changes the Python installation, doesn't it? This wouldn't be an advantage over putting a .pth file into .../site-packages. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
module not found in IIS virtual dir
I'm trying to call python scripts from IIS in the following tree: upgrade/ util/ __init__.py logonUser.py select/ selectFiles.py - select/ is referred from IIS as a virtual dir vselect. - upgrade/ is inserted into the Python path via .pth file in .../site-packages. - selectFiles.py has a line "from util import logonUser". If I run selectFiles.py from the command line everything is ok. But if I call it via IIS (http://localhost/vselect/selectFiles.py) there is an error "No module named util" due the fact that selectFiles.py still sees upgrade/ in the Python Path but upgrade/util/logonUser.py can no longer be found by selectfiles.py (os.path.exists returns false). This is strange because other modules, e.g. odbc.py are still importable. Hope you can help me. Thanks. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
.pth files in working directory
My goal is to have the top level of a directory tree in the Python path without touching anything outside the directory. I tried to create .pth files with the top level path in every subdirectory but this doesn't work despite working directory being part of the Python path. Creating the pth file in .../site-packages works but I prefer to have everything inside the directory tree so that removing the tree is sufficient for a complete uninstall. Any hints are appreciated, thanks. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problems example: gzip module
Xah Lee schrieb: > today i need to use Python to decompress gzip files. > > since i'm familiar with Python doc and have 10 years of computing > experience with 4 years in unix admin and perl, i have quickly located > the official doc: > > http://python.org/doc/2.4.1/lib/module-gzip.html > > but after a minute of scanning, please someone tell me what the fuck is > it talking about? > > Fuck the Python programing morons. > > Thanks. > > I just need to decompress files. Is it: > > import gzip; > gzip.GzipFile("/Users/xah/access_log.1.gz"); > > can someone put a example into that fucking doc so that people don't > have to wade thru whatever fuck it is trying to sound big? Here's the example: import gzip # read fucked fuckedfile = gzip.GzipFile('somefile.gz') content = fuckedfile.read() fuckedfile.close() # write unfucked unfuckedfile = file('somefile','w') unfuckedfile.write(content) unfuckedfile.close() Please feel free to insert this fucking example into the fucking docs. Have a nice ... eh fucking day :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: variable hell
Benji York schrieb: >> >>> suffix = 'var' >> >>> vars()['a%s' % suffix] = 45 >> >>> avar >> 45 > > > Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about > the "vars" built in: > > The returned dictionary should not be modified: the effects on the > corresponding symbol table are undefined. I tried this once and it worked. This may be too naive, so thanks for the warning :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: variable hell
Nx schrieb: > Hi > > I am unpacking a list into variables, for some reason they need to be > unpacked into variable names like a0,a1,a2upto aN whatever is > in the list. > > How to create the variables dynamically ? > > I am looking for something like > pseudo code line follows : > > a%s = str(value) >>> suffix = 'var' >>> vars()['a%s' % suffix] = 45 >>> avar 45 -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Testing for presence of arguments
Madhusudan Singh schrieb: > Dan Sommers wrote: [...] >>class _SemiPrivateClass: >>pass >> >>def f(required_argument=_SemiPrivateClass): >>if required_argument == _SemiPrivateClass: >>print "required_argument was probably not present" >>else: >>print "required_argument was present" [...] > Thanks for the suggestion, but seems needlessly complicated for > something very simple. What is "very simple"? The problem or the solution? :) If you examine this suggestion more closely you will note that it is more or less the same as Benji York's one except Benji used a built-in class. If you are interested in getting help on usenet you should abstain from devaluating efforts to give you a useful reply. "Thanks for the suggestion" or even no answer would have been sufficient. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Obfuscator for Python Code
Peter Maas schrieb: > codecraig schrieb: > >> Is there any obfuscator out there that obfuscates the python code (byte >> code i guess)??? > > http://www.lysator.liu.se/~ast rand/projects/pyobfuscate/ Delete space: http://www.lysator.liu.se/~astrand/projects/pyobfuscate/ -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Obfuscator for Python Code
codecraig schrieb: > Is there any obfuscator out there that obfuscates the python code (byte > code i guess)??? http://www.lysator.liu.se/~ast rand/projects/pyobfuscate/ -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Library vs Framework (was Dr. Dobb's Python-URL!)
Simon Brunning schrieb: > On 8/15/05, Rocco Moretti <[EMAIL PROTECTED]> wrote: > >>Which lead me to the question - what's the difference between a library >>and a framework? > > > If you call its code, it's a library. If it calls yours, it's a framework. IOW Apache with modpython is a framework for web apps because it calls your Python handlers. According to Andy Smith the Apache/ modpython combo sucks because it takes away the freedom to call a HTTP library and write your own HTTP server ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: API class creation
kman3048 schrieb: > Now, I need to create a Class and fill it with Methods and Variables. > There are means to create (and attache) methods and variables. > However, I have not found how to create a Class within a Module. Or do import aModule c = aClassGenerator() setattr(aModule,'c',c) ci = aModule.c() -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Opinions on KYLIX 3 (Delphi 4 Linux)
Jeff Epler schrieb: > I honestly don't know why anyone would spend money for a development > environment, no matter how fancy. I don't know why anyone would develop > software in a language that doesn't have at least one open > implementation. FreePascal is OSS. I recently developed a mixed Delphi/FreePascal application. FreePascal doesn't have a GUI Builder like Delphi but is very complete and mature. > It's a great way to get screwed when Borland goes under or decides > they only want to sell a new, incompatible product. What do you do with > your existing product when that happens? Re-train on a new platform, > and re-write from scratch? Port it to FreePascal :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Guido's "Python Regrets" ever get implemented/fixed?
George Sakkis schrieb: > Given that the latest 2.x python will be 2.9 Why not 2.13 or 2.4711? Version strings are sequences of arbitrary integers separated by dots and not decimal numbers, or are they? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)
Simon Brunning schrieb: > Sibylle Koczian needs to sort part of a list. His first attempt made > the natural mistake - sorting a *copy* of part of the list: I think it was _her_ first attempt. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: When someone from Britain speaks, Americans hear a "British accent"...
muldoon schrieb: >Now, what forum would you recommend? Any help would be appreciated. alt.culture.us.* -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
Brian schrieb: > Microsoft Visual Basic (.NET) would be your best bet for this type of > software development. It allows you to create GUI apps that can work > with a variety of database options, such as Access or MS SQL Server. Maybe you're right with .net, but I'd go for C# when doing .net. Basic is the ugliest and most mind corrupting language I've come across. And the OP has a C/C++ background. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Daten Kinderheilkunde
Sehr geehrter Herr Wurm, vielen Dank für die Zusendung der Daten. Es handelt sich allerdings nicht um jpeg-Dateien, wie die Erweiterung nahelegt. Wir konnten sie nur mit dem PictureViewer auf einem Apple anzeigen. Sie werden unter MacOS als Adobe-Photoshop-Dokument angezeigt. Können wir die Dateien als jpegs bekommen oder sollen wir sie selbst umwandeln? Mit freundlichen Gruessen, Peter Maas -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Daten Kinderheilkunde
Peter Maas schrieb: > vielen Dank für die Zusendung der Daten. Es handelt sich allerdings > nicht um jpeg-Dateien, wie die Erweiterung nahelegt. Wir konnten sie > nur mit dem PictureViewer auf einem Apple anzeigen. Sie werden unter > MacOS als Adobe-Photoshop-Dokument angezeigt. Sorry, my fault. Please disregard this :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python API to manipulate CAB files.
Isaac Rodriguez schrieb: > Does anyone know of a Python API to manipulate CAB files? If there is a Windows API you can probybly call it from Python using Mark Hammond's Win32 extensions. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: A tool for Python - request for some advice
TPJ schrieb: > First I have to admit that my English isn't good enough. I'm still > studying and sometimes I just can't express what I want to express. No excuses, please! Keep in mind that your English is much better than the Polish of most of us. And just in case you were fishing for compliments: Your English IS good enough. ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: What is different with Python ?
Magnus Lycka schrieb: > Peter Maas wrote: > >> Learning is investigating. By top-down I mean high level (cat, >> dog, table sun, sky) to low level (molecules, atoms, fields ...). > > > Aha. So you must learn cosmology first then. I don't think so. ;) I wasn't talking about size but about sensual accessibility. And I'm going to withdraw from this discussion. My English is not good enough for this kind of stuff. And ... it's off topic! ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: What is different with Python ?
Andrew Dalke schrieb: > Peter Maas wrote: > >>I think Peter is right. Proceeding top-down is the natural way of >>learning (first learn about plants, then proceed to cells, molecules, >>atoms and elementary particles). > > > Why in the world is that way "natural"? I could see how biology > could start from molecular biology - how hereditary and self-regulating > systems work at the simplest level - and using that as the scaffolding > to describe how cells and multi-cellular systems work. Yes, but what did you notice first when you were a child - plants or molecules? I imagine little Andrew in the kindergarten fascinated by molecules and suddenly shouting "Hey, we can make plants out of these little thingies!" ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: What is different with Python ?
Andrea Griffini schrieb: > On Mon, 13 Jun 2005 13:35:00 +0200, Peter Maas <[EMAIL PROTECTED]> > wrote: > > >>I think Peter is right. Proceeding top-down is the natural way of >>learning. > > > Depends if you wanna build or investigate. Learning is investigating. By top-down I mean high level (cat, dog, table sun, sky) to low level (molecules, atoms, fields ...). And to know the lowest levels is not strictly necessary for programming. I have seen good programmers who didn't know about logic gates. > Hehehe... a large python string is a nice idea for modelling > memory. This shows clearly what I mean with that without firm > understanding of the basis you can do pretty huge and stupid > mistakes (hint: strings are immutable in python... ever > wondered what does that fancy word mean ?) Don't nail me down on that stupid string, I know it's immutable but didn't think about it when answering your post. Take instead. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: What is different with Python ?
Andrea Griffini schrieb: > On Sat, 11 Jun 2005 21:52:57 -0400, Peter Hansen <[EMAIL PROTECTED]> > wrote: > > >>I think new CS students have more than enough to learn with their >>*first* language without having to discover the trials and tribulations >>of memory management (or those other things that Python hides so well). > > > I'm not sure that postponing learning what memory > is, what a pointer is and others "bare metal" > problems is a good idea. I think Peter is right. Proceeding top-down is the natural way of learning (first learn about plants, then proceed to cells, molecules, atoms and elementary particles). If you learn a computer language you have to know about variables, of course. You have to know that they are stored in memory. It is even useful to know about variable address and variable contents but this doesn't mean that you have to know about memory management. MM is a low level problem that has to do with the internals of a computer system and shouldn't be part of a first *language* course. The concepts of memory, data and addresses can easily be demonstrated in high level languages including python e.g. by using a large string as a memory model. Proceeding to bare metal will follow driven by curiosity. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: The need to put "self" in every method
Aahz schrieb: >>Because Python has no declarations there must be a different way to >>indicate in which category an identifier falls. [...] > Any objection to swiping this for the FAQ? (Probably with some minor > edits.) There is already a 'self' section (1.4.4) in the official Python FAQ. Looks like this has been forgotten. Perhaps it would be helpful to create a short version of the FAQ with the top most frequently asked questions/stumbling blocks/annoyances titled "top 10 things you always wanted to know about Python and didn't dare to ask" and post it weekly in this newsgroup :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: The need to put "self" in every method
Fernando M. schrieb: > i was just wondering about the need to put "self" as the first > parameter in every method a class has because, if it's always needed, > why the obligation to write it? couldn't it be implicit? > > Or is it a special reason for this being this way? See section 1.4.4 in http://www.python.org/doc/faq/general.html -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Here
Rob Cowie schrieb: > As a relative newbie myself I think I can say Python is used for > anything any major programming language is used for. My list was meant as an enumeration of tasks for which _I_ _currently_ use Python. You are of course right that Python covers a much wider range, although "anything any major programming language is used for" is probably too wide. I would e.g. exclude device drivers, router firmware etc. ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Here
Mark Sargent schrieb: > I want to get into python to use it for > Linux/Unix related stuff. A question I have, is, those of you who use it > for the same things, what do you primarily use it for. Could you show me > some examples.? - little daily stuff e.g. transforming data - sysadmin tasks (backup scripts) - web applications (replacing asp/php) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: blabla
Noud Aldenhoven schrieb: > Python rulz and sorry for this spam... news.test is made for testing :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: goto statement
Maxim Kasimov schrieb: but what if i just can't to do this becouse i'm working thrue ssh, and have to use only installed editors (such as vi) - at first line of block enter: ma (mark line as 'a') - go to last line of block - enter :'a,.s/^/###/ (insert 3 comment chars at begin of line, starting from line marked as 'a' to current line) :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python appropriate for web applications?
Unknown User schrieb: I am a Python programmer and I'm thinking about learning PHP, which is similar to C++ wrong (quite different from Python). true I want to start writing web applications. Do you think if I learn > PHP I'll develop faster? Nobody but you can anawer this question. You'll have to try. Does PHP have more features? PHP has a rich library which probably outperforms any Python alternative in terms of features. But this doesn't necessarily mean that you will develop faster in PHP. The problem with Python is that you have to make a choice among many solutions (roughly ordered by inreasing complexity): - plain cgi - Quixote - modpython - CherryPy - Spice - Webware - Twisted - ZOPE ... Have a look at http://www.python.org/topics/web/ How about the speed of execution? There is no simple answer. Both languages use C functions which are executed at CPU speed. But with interpreted code Python seems to be approximately 3-4 times faster than PHP (http://dada.perl.it/shootout/). What are the pros and cons? http://www.allsites.com/Top.Computers.Programming.Languages.Comparison_and_Review.html -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Language for Systems Administrator
Ville Vainio schrieb: If you don't need to edit already existing system scripts, you don't really need to know bash scripting. For debugging purposes, it's easy to see what commands the script executes to perform a task. This is only true for trivial bash scripts. I have seen bash scripts which were quite hard to read especially for beginners. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting the word to conventional programmers
Peter Hansen schrieb: Cameron Laird wrote: *DevSource* profiles "The State of the Scripting Universe" in http://www.devsource.com/article2/0,1759,1778141,00.asp >. Which, sadly, doesn't seem to work with Firefox here, though IE shows it fine. :-( Mozilla 1.7.3 shows it fine, too. FF bug or config issue? -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple account program
wes weston schrieb: >Why have transactions not associated with accounts? > All transactions are related to an account; have > a self.TransActList in Account. >You have "amount" in both Withdrawl and Deposit > both derived from Transaction. If Transactions always > have an amount, why not put amount in the transactions > class? That's a good idea. I don't know if Igorati is just doing an exercise or has the ambition to create a usable application. In the latter case it would be a good idea to learn the basics of double accounting (DA). In DA each transaction is associated with 2 accounts. DA tries to avoid signed numbers, but uses the terms debit and credit instead. debit and credit aren't simply synonyms for minus and plus because there are two types of accounts: assets and liabilities. Liabilities have a minus sign built in. For me this is crazy and I used to confuse things until I found three rules to memorize this: 1. Positive flow of money is always recorded on the debit side. 2. Assets account balances are computed without sign change. 3. Liability account balances are computed with sign change. In matrix form: debit credit assets accont+ - liabil account - + Example: You empty your piggybank to pay your debts: Amount is recorded on the debit side of debts and on the credit side of piggybank (rule 1). Both balances are lower, because credit is negative for assets (rule 2) and debit is negative for liabilities (rule 3). So the easiest way to handle this programmatically is to have two lists, accounts and transactions. Each transaction generates a new entry in the list of transactions: translist.append(trans(credit_account, debit_account, amount)) where amount is always positive. The account class has a balance method: class account: def balance(self, translist): bal = 0 for e in translist: if self == e.debit_account: bal += e.amount if self == e.credit_account: bal -= e.amount if self.acctype == "liability": bal = -bal return bal -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Kay Schluehr schrieb: Some people refused properties in Python for exactly this reason. Defining somewhat like: def _get_X(self): return self._X def _set_X(self,X): self._X = X X = property(_get_X, _set_X ) in a Java-style fashion is indeed awfull and clumsy and that people dismiss such boilerplate code is understandable. This is original Delphi-Style, btw. But why is this boilerplate code? You define a property, and tell how it is read and written. How does your preferred code look like? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Fernando schrieb: The real problem with Python is that it has been very successful as a scripting language in the static-typing/C/C++ world. Those programmers, instead of adapting their evil ways to Python, and realizing the advantages of a dynamic language, are influencing Python's design and forcing it into the static-typing mold. Examples? Python is going the C++ way: piling feature upon feature, adding bells and whistles while ignoring or damaging its core design. What is core design? What are bells and whistles? I find it surprising that you talk about adding bells and whistles, whereas the URL you are referring to is about removing features. The new 'perlified' syntax for decorators, the new static type bonds and the weird decision to kill lambda instead of fixing it are good examples that show that Python is going the wrong way. I don't think that the introduction of '@' for decorators justifies the term perlification. If special characters are avoided at all costs Python could become too verbose like Java which is often critized for that in c.l.py. What used to be a cool language will soon be an interpreted C/C++ without any redeeming value. A real pity... What do you mean with cool? Which parts of Python are C/C++ish? Which features leave Python "without any redeeming value"? This phrase is close to trolling because is vague, emotional and unspecific. The fear of the anti-static fanatics is unfounded. Guido has made clear that he is thinking of a pychecker-like mechanism for validating programs at compile time. There's nothing wrong with defining interfaces and conditions and being able to check them before actually running the program. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Carl Banks schrieb: In Python, classes aren't some magical land where the usual rules don't hold (as they are in many other languages). That's why "self." is used on class variables, for instance. A class is nothing more than a scope that uses a smittering of magic to turn it into a type. scope -> dictionary -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging Python Scripts inside other processes
A. Klingenstein schrieb: I embedded Python in a Windows C++ program. Now I want to debug my embedded scripts which of course won't run in any IDE process. Commercial IDEs like WingIDE can attach to external processes by importing a module in the scripts. Is there a debugger capable of this which is Free or Open Source? What I need are the following things: - runs in Windows - single stepping - variable watches - breakpoints Does your Windows C++ program have a working stdin/stdout/stderr, i.e. kind of a console? Then you could insert import pdb pdb.set_trace() at a position in your embedded scripts where you want debugging to start. If your C++ program doesn't have a console then perhaps you can provide one with a Win32 call? Just guessing here. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating module skeleton from unit tests
Edvard Majakari schrieb: Greetings, fellow Pythonistas! I'm about to create three modules. As an avid TDD fan I'd like to create typical 'use-cases' for each of these modules. One of them is rather large, and I wondered if it would be easy enough to create a code skeleton out of unit test module. I think this is too difficult, because there are many ways to write code (even skeletons) for a use case. An easier approach would be to write the skeleton manually, embed the test cases in the doc strings and generate the test code from the doc strings. If I remember correctly IBM has published something to generate unit tests from code. Python has a doctest module to support testing derived from doc strings. This can be combined with unit tests. > The problem can be solved more easily if you design the module skeleton first, then the tests and then the logic for the skeleton - you would be creating tests before the code, but many people > wouldn't regard it as TDD then. You shouldn't care if your approach works for you. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: list of all type names
Klaus Neuner schrieb: Python has one feature that I really hate: There are certain special names like 'file' and 'dict' with a predefined meaning. Yet, it is allowed to redefine these special names as in This is not a specific Python feature: If you include a header file in C that redefines fopen(), wou will probably also run into problems. dict = [1:'bla'] I would avoid the use of generic names for variables but rather use dict1 or aDict etc. If you want to avoid a name collision without the use of naming conventions you could rename __builtins__: bi = __builtins__ del __builtins__ Then you can define what you like but you will have to reference dict, list etc. as bi.dict, bi.list, ... For a fast check simply type e.g. dict in the interactive Interpreter. If you get a NameError it is not built-in. :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Fredrik Lundh schrieb: +00: googled for the mingw home page +00: found the mingw download page +02: finally figured out what to download +03: noticed that my usual SF site only offered 1K/s; aborted download +07: finished downloading the mingw kit from another SF site +17: finished installing +18: added \mingw\bin to the path +18: typed "python setup.py install --compiler=mingw32" +18: got a linker error; googled for help +19: copied python24.dll to \mingw\lib +20: finished building the sample library (cElementTree); all tests pass Impressive. How did you record the minutes? ;) I'd like to know wether this is a single observation or true for most if not all your MinGW builds? I used Borland's C++ Compiler (free and commercial) and had frequently to tweak .def files and the source to make it work. I also had to transform the python dll with COFF2OMF because the library interfaces of python.dll and the Borland binaries were different. If your MinGW experience described above is typical then I'll get a stop watch and give it a try ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES
Terry Reedy schrieb: "Peter Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] http://nobelprize.org/medicine/educational/pavlov/ and then do something useful :) Thanks. I showed this to my daughter, who enjoyed the game, and explained your point re Pavlov posting, and about Pavlov advertising, etc. Fine that at least one person benefitted from my post :) I came across this when I browsed through the Lazaridis thread which was - if for nothing else - good for some laughs. But at the same time I felt uncomfortable to see how many bright Pythoneers cared to give well thought, helpful and friendly answers to somebody who was acting unpolite and kind of stupid, even mechanical. This newsgroup is used to be helpful to newbies and Lazaridis was ringing the newbie bell. Perhaps we will soon see a triumphant publication with the title "Ilias Lazaridis - the ELIZA of the 21st century. A milestone towards the perfect Turing test" ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES
Ilias Lazaridis schrieb: I'm a newcomer to python: Sorry, I'm breaking my promise to post only once to this thread. But I've found the ultimate recipe to resolve all issues of this and other similar threads: Please read http://nobelprize.org/medicine/educational/pavlov/ and then do something useful :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list