Re: Proposal: Inline Import
-- http://mail.python.org/mailman/listinfo/python-list
Re: Let My Terminal Go
On 10 Oct 2005 22:58:08 -0700 [EMAIL PROTECTED] wrote: How do I implement this in my application written in python? Google for python daemonize. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Batteries Included?
On 11 Oct 2005 00:10:01 -0700 Paul Rubin wrote: Personally I think including a .exe packager in Python would be a great idea. As a Linux user I can't easily run Windows-specific utilities like Inno Setup. So I don't have a good way to make .exe's from my Python code that Windows users can easily run. Having a cross platform .exe packager included with Python would be useful the same way cross compilers are useful. I'm using an x86 computer but I can easily configure gcc to produce ARM code. Why shouldn't my Linux Python installation be able to produce Windows .exe's? Because you can't run it yourself? If you cannot run the freshly-made exe yourself, why would you want to distrubute it, without even trying? But if you can, then you can run the InnoSetup as well. But, for me, I don't care whether such an option will be included or not. I won't object anyway. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
On 3 Oct 2005 13:58:33 GMT Antoon Pardon wrote: People often promote unittesting here. Writing all those unittest is an added burden too. But people think this burden is worth it. I think writing declaration is also worth it. The gain is not as much as with unittesting but neither is the burden, so that balances out IMO +1 Some people just don't get the simple fact that declarations are essentially kind of unit test you get for free (almost), and the compiler is a testing framework for them. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
On Tue, 04 Oct 2005 01:46:49 +1000 Steven D'Aprano wrote: errors and not rely on the compiler. No compiler will catch this error: x = 12.0 # feet # three pages of code y = 15.0 # metres # three more pages of code distance = x + y if distance 27: fire_retro_rockets() And lo, one multi-billion dollar Mars lander starts braking either too early or too late. Result: a new crater on Mars, named after the NASA employee who thought the compiler would catch errors. So, I guess, you have a spare Mars lander especially for unit-testing? :) -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
On Mon, 03 Oct 2005 17:43:35 +0100 Steve Holden wrote: Hmm. Presumably introspection via getattr() is way too dangerous, then? Sure, it is dangerous. Not a showstopper, though. I mean, the absolute address access in the C is too dangerous, yes, but it doesn't make declarations in C any less useful. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private,protected and public?
On 30 Sep 2005 15:00:39 -0700 Paul Rubin wrote: Rocco Moretti [EMAIL PROTECTED] writes: There is little in the way of technical problems that are solved by language level enforcement of private variables. The issues in question are mostly social ones, and if you're not reading and following the documented interface, stopping private variable access is not going to prevent most of your problems. Well, that says you consider both code auditing and debugging to be social problems rather than technical ones. Maybe that's reasonable, By the way, any programming language is a social issue; only machine code is technical. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
On Fri, 30 Sep 2005 21:28:26 -0400 Terry Reedy wrote: The lesson for me is to spend much less time on Python discussion and much more on unfinished projects. So even if I never use the new syntax, I will have gained something ;-) QOTW? -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On 30 Sep 2005 22:11:46 + John J. Lee wrote: Steve Holden [EMAIL PROTECTED] writes: That would make a good Onion (www.TheOnion.com) headline: Users Discover Computer Security Conflicts with Desire for Convenience :-) The Onion, yay. Area Man Forgets Work Password, Will Employ Post-It Notes in Future Sure. It would be fun to read something about Consenting Adults there, too. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Wed, 28 Sep 2005 08:14:50 -0500 Chris Gonnerman wrote: There are two philosophies about programming: -- Make it hard to do wrong. -- Make it easy to do right. What you are promoting is the first philosophy: Tie the programmer's hands so he can't do wrong. Python for the most part follows the second philosophy, So it is for the very this reason there is no assignment operator in the Python? -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Fri, 30 Sep 2005 00:16:02 +1000 Steven D'Aprano wrote: Say you have written a class, with a private variable. I decide that I need access to that variable, for reasons you never foresaw. What if the access to that variable was forbidden for reasons you never foresaw? What if the class author decide to remove the variable in the next version of the class, because it's not an interface, but only a part of the class implementation? What happens next? I ask you nicely to please change your class and turn that private attribute into a public one. What happens if you refuse? Can I have you taken out and shot and seize ownership of your class, or do I have to copy and paste your class into my code, creating a duplicate class I can modify as much as I like? Yes, that's how it works in the open source. What's wrong with it? You don't need _this_ class, because it's functionality doesn't fit to you. So you take the source code and write another class, doing exactly what you want it to do. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Thu, 29 Sep 2005 17:03:00 +0200 Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: What if the access to that variable was forbidden for reasons you never foresaw? What if the class author decide to remove the variable in the next version of the class, because it's not an interface, but only a part of the class implementation? you mean when he breaks into your computer and installs the new version without you noticing? if you think that once you've put private labels on all accidental stuff, nothing will break during upgrades, you're clearly very new to this thing called pro- gramming... Do you ever heard of that funny things named an interface and an implementation? -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Thu, 29 Sep 2005 16:59:01 +0200 Fredrik Lundh wrote: as long as you don't cheat, that is: # your code class Secret: def __init__(self): self.__hidden = very secret value # my code from yourcode import Secret class Secret(Secret): def gethidden(self): return self.__hidden It's not a cheat, it's an accident you have no protection against. Consider: class Secret(NotSoSecret): # pass Looks like you must know every one of the base classes of the NotSoSecret, whether there is some base class named Secret? And, if so, you must also know these classes _implementation_, every one of their attributes, variables and methods, to avoid accidental overriding? For me, it's not what inheritance is about. This accident should be rare, but possible. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Thu, 29 Sep 2005 21:05:28 +0200 Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: Do you ever heard of that funny things named an interface and an implementation? the shared DLL:s ought to work school of thought, you mean? No, the other way around: my app works when I upgrade libraries it depends on. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Feature Proposal: Sequence .join method
On Thu, 29 Sep 2005 20:37:31 -0600 Steven Bethard wrote: I don't like the idea of having to put this on all sequences. If you want this, I'd instead propose it as a function (perhaps builtin, perhaps in some other module). itertools module seems the right place for it. itertools.chain(*a) is the same as the proposed [].join(a) -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Fri, 30 Sep 2005 06:31:44 +0200 Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: Looks like you must know every one of the base classes of the NotSoSecret, whether there is some base class named Secret? And, if so, you must also know these classes _implementation_ that information isn't hidden, so there's nothing you must know. finding out is a matter of writing a very small program, or tinkering at the interactive prompt for a couple of seconds. are you even aware that you're posting to a Python group ? So you have read every line of the python std library, I guess? (Not to mention libc or kernel32.exe or whatever.) -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
On Thu, 22 Sep 2005 00:23:56 +1000 Steven D'Aprano wrote: I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. So it is the very rationale why dot-files historically considered as hidden in all unix shells and filemanagers. tilting at windmills Can I ask developers to break with the obsolete and annoying habit of creating user-specific config files as ~/.app-name and use ~/settings/app-name instead? /tilting at windmills There is an other way around: look at your home dir as if it is your settings dir and don't clutter it with files other than application config dot-files. Just make ~/files/, ~/bin/ ~/lib/ etc. for it. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Roguelike programmers needed
On Sun, 18 Sep 2005 17:28:30 +0100 Thomas Jollans wrote: what exactly is RPG/roguelike etc ? (what debian package provides an example?) apt-cache search roguelike -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: O'Reilly book on Twisted
On 14 Sep 2005 13:36:53 -0700 Steve M wrote: Does anybody know: What is the relationship between the primary developers of Twisted and the book? Looks like the primary developers will get a copy from the author, at least. :) Having a book is nice, of course, but I'd rather rely on the mailing list and the sources. But I'd buy a book as well, and its cover gives it a +1 point. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Replacement for lambda - 'def' as an expression?
On Tue, 06 Sep 2005 12:19:21 +0200 Torsten Bronger wrote: talin at acm dot org [EMAIL PROTECTED] writes: Anyway, here's an example, then, of how 'def' could be used: add = def( a, b ): return a + b I'm really not an expert in functional programming, so I wonder what's the difference between add = def (assumed that it worked) and def add? In the former case one could write self.add[0] = def(a, b) # etc. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Do int.__lt__/__gt__/etc. exist?
On Wed, 07 Sep 2005 00:02:49 GMT Chris Dutton wrote: I'm just curious. I've been trying to demonstrate functional thinking in Python, but I can't find these methods for int objects. It would be immensely helpful for something like: filter(4 .__lt__, range(10)) As opposed to: filter(lambda a: 4 a, range(10)) Python is neither pure object nor pure functional language. There is an operator module, with its operator.lt, but it is not exactly what you need. You still need lambda with it. The recommended way to do what you want is result = [x for x in xrange(10) if 4 x] -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problems example: gzip module
On 1 Sep 2005 07:24:26 -0700 Peter Wang wrote: Constructor for the GzipFile class, which simulates most of the methods of a file object, with the exception of the readinto() and truncate() yeah, blab blab blab. what the fuck are you talking about? So, how to use it? and in this case the original filename is not included in the header. what the fuck?? since you might wish to append more material after the compressed data. This also allows you to pass a StringIO object opened for writing as fileobj, and retrieve the resulting memory buffer using the StringIO object's getvalue() method. huh? append more material? pass a StringIO? and memory buffer? you see, not everyone who uses GzipFile will be decompressing files. Am I the only one who thinks you are talking with some perverted kind of emacs-doctor-like or elise-like computer program? -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type
On Thu, 25 Aug 2005 00:05:18 -0400 Steve Holden wrote: What on earth makes you call this a bug? And what are you proposing that find() should return if the substring isn't found at all? please don't suggest it should raise an exception, as index() exists to provide that functionality. Returning -1 looks like C-ism for me. It could better return None when none is found. index = Hello.find(z) if index is not None: # ... Now it's too late for it, I know. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt C and Python
On 23 Aug 2005 01:22:31 -0700 James wrote: Some people with C background use Python instead of programming in C.why? Becuase it is much more efficient. It's rather because _they_ are much more efficient (that is, with Python). -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: while c = f.read(1)
On 18 Aug 2005 22:21:53 -0700 Greg McIntyre wrote: I have a Python snippet: f = open(blah.txt, r) while True: c = f.read(1) if c == '': break # EOF # ... work on c Is some way to make this code more compact and simple? It's a bit spaghetti. import itertools f = open(blah.txt, r) for c in itertools.chain(*f): print c # ... The f is iterable itself, yielding a new line from the file every time. Lines are iterable as well, so the itertools.chain iterates through each line and yields a character. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: while c = f.read(1)
On 19 Aug 2005 03:43:31 -0700 Paul Rubin wrote: [EMAIL PROTECTED] writes: import itertools f = open(blah.txt, r) for c in itertools.chain(*f): But that can burn an unlimited amount of memory if there are long stretches of the file with no newlines. There's no real good way around ugly code. I agree. Moreover, in fact, it is the same as just for c in f.read(): # ... -- jk -- http://mail.python.org/mailman/listinfo/python-list
Well, another try Re: while c = f.read(1)
On 18 Aug 2005 22:21:53 -0700 Greg McIntyre wrote: f = open(blah.txt, r) while True: c = f.read(1) if c == '': break # EOF # ... work on c Is some way to make this code more compact and simple? It's a bit spaghetti. This is what I would ideally like: f = open(blah.txt, r) while c = f.read(1): # ... work on c for data in iter(lambda:f.read(1024), ''): for c in data: # ... work on c -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding Python in C, undefined symbol: PyExc_FloatingPointError
On Wed, 17 Aug 2005 14:29:43 +0800 Simon Newton wrote: The C program is being built like so: gcc main.c -c -I-I/usr/include -I/usr/include -I/usr/include/python2.4 -I/usr/include/python2.4 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes gcc main.o -L/usr/lib -lpthread -ldl -lutil -lm /usr/lib/python2.4/config/libpython2.4.a -o main Try to link libpython as a library (as it should be), not as an object module: gcc main.o -L/usr/lib -lpthread -ldl -lutil -lm -lpython2.4 -o main -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile time checking?
On Fri, 12 Aug 2005 22:25:07 -0700 Steve Jorgensen wrote: Since Python does not use manifest typing, there's not much you can do about this, but typeless languages like this are great if you're using a process that finds the errors the compiler would otherwise find. I'm referring, of course, to Test Driven Development (TDD). If you do TDD, you won't miss compile-time checking much. In fact, the extra kruft that manifest typing requires is an annoying burden when doing TDD, so Python is a breath of fresh air in this regard. What test should one implement to catch that kind of errors like in OP example? On 10 Aug 2005 08:53:15 -0700, Qopit [EMAIL PROTECTED] wrote: # def tester(a,b,c): print bogus test function,a,b,c tester(1,2,3) #this runs fine tester(1,2)#this obviously causes a run-time TypeError exception # -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python supports LSP, does it?
On Thu, 11 Aug 2005 15:02:08 -0400 Terry Reedy wrote: I remember discussion of the LSP on comp.object some years ago when I was reading it. (I presume there still are, just don't read it anymore.). One of the problems is that biology and evolution do not obey it. Birds (in general) can fly, I suspect it is not the exact scientific criteria used in the biology whether an animal ISA bird, is it? I mean, flying is not bird property in the biological sense, so it is nothing against the LSP here. but those in the ratite family, evolved later than order aves, cannot. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python supports LSP, does it?
On Thu, 11 Aug 2005 01:19:19 +0100 phil hunt wrote: According to Wikipedia, the Liskov substitution principle is: Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T To me, this is nonsense. Under this definition any subtype must behave the same as its parent type, becausde if it doesn't there will be some q(y) that are different to q(x). But if it behaves the same, what's the point of having a subtype? It does not behave the same, it has the same properties. In other words, if there is some true assertion about _any_ object of type x, then it's true about any object of type y, if y is derived from x. Quick-and-dirty example: any object of type list is iterable, and it is true as well for any object of some type derived from list. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: What are modules really for?
On Wed, 10 Aug 2005 09:36:13 +0100 N.Davis wrote: As for multiple inheritance, yes I've always been aware of it being available in C++, but I learned C++ at a company which banned multiple inheritance in their coding standards, with comments about The GOTO of the 1990s. Looks like something religious. It seems they was completely ignorant about what the multiple inheritance is and what is it for. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile time checking?
On 10 Aug 2005 08:53:15 -0700 Qopit wrote: def tester(a,b,c): print bogus test function,a,b,c tester(1,2,3) #this runs fine tester(1,2)#this obviously causes a run-time TypeError exception /tmp% cat a.py def tester(a,b,c): print bogus test function,a,b,c tester(1,2,3) #this runs fine tester(1,2)#this obviously causes a run-time TypeError exception /tmp% pychecker a.py Processing a... bogus test function 1 2 3 Caught exception importing module a: File /usr/lib/site-python/pychecker/checker.py, line 587, in setupMainCode() module = imp.load_module(self.moduleName, file, filename, smt) File a.py, line 4 tester(1,2)#this obviously causes a run-time TypeError exception TypeError: tester() takes exactly 3 arguments (2 given) Warnings... a:1: NOT PROCESSED UNABLE TO IMPORT /tmp% pychecker -V 0.8.14 -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: What are modules really for?
On Tue, 09 Aug 2005 16:32:31 +0100 N.Davis wrote: With single inheritance in C++ or Java, if you wanted to see what a method did and it appeared to be inherited, you would simply look in the base class's file, and if necessary recurse up the inheritance hierarchy until you found the method. With Python an inherited method could be in one of many base classes And Python doesn't differ from C++ in this matter, as C++ have multiple inheritance during (more than) last 15 years. If you don't use it in C++ then feel free not to use it in Python as well. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing a variable number of arguments to a wrapped function.
On 5 Aug 2005 08:34:32 -0700 [EMAIL PROTECTED] wrote: Is there a better way of doing this so that I don't have to go through every permutation of possible arguments (the example here from the matplotlib 'plot' function): def makeplot(self, xvalues, yvalues, linecolor='', linewidth=''): if linecolor and linewidth: plot(xvalues, yvalues, linecolor, linewidth=linewidth) elif linecolor: plot(xvalues, yvalues, linecolor) elif linewidth: plot(xvalues, yvalues, linewidth=linewidth) else: plot(xvalues, yvalues) What's wrong with: def makeplot(self, xvalues, yvalues, **kwargs): plot(xvalues, yvalues, **kwargs) or even: def makeplot(self, *a, **ka): plot(*a, **ka) ? -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE's
On Mon, 01 Aug 2005 18:21:08 -0400 Benji York wrote: Jon Hewer wrote: But, if i use Vi, then whenever i want to test some code i have to open up python, import the necessary modules and run it - I like the idea of developing python in an IDE and just hitting a run button. map F5 :wCR:!python %CR Or, probably even better: map F5 :wCR:!xterm -e python -i % CRCR -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Wheel-reinvention with Python (was: Ten Essential DevelopmentPractices)
On Fri, Jul 29, 2005 at 01:18:10PM -0400, Jeremy Moles wrote: On Fri, 2005-07-29 at 17:59 +0200, Torsten Bronger wrote: one thinks well, perfect, I have the choice between four Four? 1. wx 2. PyGTK 3. Tk (Are you including this one even?) 4. ??? Well, QT at least. And sure there is Tk. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a line in a text file
Tue, Jul 26, 2005 at 01:41:36PM +1000, Steven D'Aprano пишет: Long ago, when dinosaurs roamed the Earth, (a.k.a. before OS X on the Macintosh) Apple suggested a bit of Pascal code for safely updating a file: http://developer.apple.com/documentation/mac/Files/Files-25.html#MARKER-9-163 That snippet doesn't write data to the existing file. It writes data into the new tempfile and then renames it, as well as the FileInput object does. Most of the code is Macintosh-specific, but the principle is not: when over-writing a file, make sure that the user can recover from any error up to and including power failure without losing the data on disk. Well, it's what (R)DBMS are for, but plain files are not. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Invoke a method to a specific thread
Mon, Jul 25, 2005 at 01:20:39PM +0800, Varghj?rta пишет: When doing GUI apps in C# I often have to call a method that will modify the GUI somehow from a different thread then the GUI is on (to allow for GUI responsiveness). I simply call Invoke() or BeginInvoke which resides in another thread with a delegate pointing to the method I want to start in that thread. How would I go about doing this in Python? I don't know of this functionality in the standard python library, but look at the Twisted framework (http://twistedmatrix.com). What you need is http://twistedmatrix.com/projects/core/documentation/howto/threading.html#auto2 -- jk -- http://mail.python.org/mailman/listinfo/python-list