Zope 3.1.0 released!
The Zope 3 development team is proud to announce Zope 3.1.0 final. Zope 3 is the next major Zope release and has been written from scratch based on the latest software design patterns and the experiences of Zope 2. It is in our opinion that Zope 3.1 is more than ready for production use, which is why we decided to drop the 'X' for experimental from the name. We will also continue to work on making the transition between Zope 2 and Zope 3 as smooth as possible. As a first step, Zope 2.8 includes Zope 3 features in the form of Five. Now that we have a release that we would like to declare stable next week, we are looking for translators, who translate Zope 3 into their favorite language! We are utilizing the Rosetta system from Ubuntu for managing those translations. If you are not familiar with Rosetta, please send us a mail to zope3-dev@zope.org and we get you set up. Downloads http://zope.org/Products/Zope3/ Installation instructions for both Windows and Un*x/Linux are now available in the top level 'README.txt' file of the distribution. The binary installer is recommended for Windows. Zope 3.1 requires Python 2.3.5 or 2.4.1 to run. You must also have zlib installed on your system. Most Important Changes Since 3.0 - New Pluggable Authentication Utility (PAU), which is similar in philosophy to the Zope 2 PAS. The following features are available in the in the basic PAU facility: + Credentials Plugins: Basic HTTP Auth, Session + Authenticator Plugins: Principal Folder, Group Folder For a detailed description of the pluggable authentication utility, see 'zope/app/authentication/README.txt'. - Major simplifications to the component architecture: + Removal of the concept of a service. All outstanding services were converted to utilities: Error Reporting, FSSync, Authentication. + Site Managers are global and local now; adapters and utilties are directly registered with the site manager. Now global and local component registration and lookup behaves very similar. + Local registrations can now only have two states: active and inactive. This simplified the code so much, that 'zope.app.utility', 'zope.app.registration' and 'zope.app.site' were all merged into 'zope.app.component'. + Implemented menus as utilities. The API also supports sub-menus now. + Implemented views as adapters. Skins and layers are now simply interfaces that the request provides. - Added an integer-id facility for assigning integer identifiers to objects. - Added basic catalog and index frameworks. - Added sources, which are like vocabularies except that they support very large collections of values that must be searched, rather than browsed. - Created a new granting UI that allows advanced searching of principal sources. - Implemented a generic user preferences systsem that was designed to be easily used in TALES expressions and via Python code. Preferences can be edited via 'http://localhost:8080/++preferences++/'. A demo of the preferences can be found at:: http://svn.zope.org/Zope3/trunk/src/zope/app/demo/skinpref/ - ZCML now supports conditional directives using the 'zcml:condition' attribute. The condition is of the form verb argument. Two verbs, 'have feature' and 'installed module' are currently implemented. Features can be declared via the 'meta:provides' directive. - Improved API doctool: Code Browser now shows interfaces, text files and ZCML files; the new Book Module compiles all available doctext files into an organized book; the new Type Module lets you browser all interface types and discover interfaces that provide types; views are shown in the interface details screen; views and adapters are categorized into specific, extended and generic; user preferences allow you to customize certain views; 3rd party modules can now be added to the Code Browser. - Improved I18n-based number and datetime formatting by integrating 'pytz' for timezone support, implementing all missing format characters, and reinterpreting the ICU documentation to correctly parse patterns. - Added '++debug++' traversal adapter that allows you to turn on debugging flags in 'request.debug'. Currently the following flags are defined: source, tal, errors. - Improved logout support. - Developed a generic 'browser:form' directive. It is pretty much the same as the 'browser:editform' directive, except that the data is not stored on some context or adapted context but sent as a dictionary to special method (by default). For a complete list of changes see the 'CHANGES.txt' file. Resources - Zope 3 Development Web Site:http://dev.zope.org/Zope3 - Zope 3 Dev Mailing List:http://mail.zope.org/mailman/listinfo/zope3-dev - Zope 3 Users Mailing List:http://mail.zope.org/mailman/listinfo/zope3-users - IRC
Bwidget for tkinter
hi can i use the bwidgets in tkinter? if so from where can i download the bwidget for tk inter. and i want to know the installation procedure -- http://mail.python.org/mailman/listinfo/python-list
Re: Bwidget for tkinter
[EMAIL PROTECTED] wrote: hi can i use the bwidgets in tkinter? if so from where can i download the bwidget for tk inter. and i want to know the installation procedure googling for bwidget for tkinter gives you a library announcement as the first hit, which points to this page: http://tkinter.unpythonic.net/bwidget/ /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Parrot Python ?
Hi ! Thank for links. @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Op 2005-10-03, George Sakkis schreef [EMAIL PROTECTED]: Michael [EMAIL PROTECTED] wrote: James A. Donald wrote: On Sun, 02 Oct 2005 17:11:13 -0400, Jean-Francois Doyon James A. Donald: Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. No, the error message will be pretty clear actually :) Now why, I wonder, does this loop never end :-) egold = 0 while egold 10: ego1d = egold+1 I know (hope! :-) that's a tongue-in-cheek question, however the answer as to why that's not a problem is more to do with development habits rather than language enforcement. (yes with bad habits that can and will happen) [snipped description of test-driven development culture] As an aside, more to the point of the specific erroneous example is the lack of the standard python idiom for iteration: for egold in xrange(10): pass Learning and using standard idioms is an essential part of learning a language; python is no exception to this. Well I'm a bit getting sick of those references to standard idioms. There are moments those standard idioms don't work, while the gist of the OP's remark still stands like: egold = 0: while egold 10: if test(): ego1d = egold + 1 -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Op 2005-09-30, Steven D'Aprano schreef [EMAIL PROTECTED]: On Fri, 30 Sep 2005 06:52:50 +, Antoon Pardon wrote: Op 2005-09-29, Bill Mill schreef [EMAIL PROTECTED]: But, if your users can't figure out that they shouldn't be changing the variable called t._test__i without expecting side effects, what do you think of the users of your class? Python is for consenting adults. No it is not. Consenting means you had the choice. Python doesn't give you the choice not to consent. Damn straight. I used to be a perfectly happy Pascal programmer, until Guido and the Timbot kicked down my front door and forced me at gun point to start programming in Python. I don't know about you, but when I hear someone saying, this is to be used between consenting adults, I don't expect the choice to be limited between using and not using. Those adults also have to consent on how to use it. If you limit this consenting adults to using python or not, you are making my point. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Op 2005-09-30, Steve Holden schreef [EMAIL PROTECTED]: Antoon Pardon wrote: Op 2005-09-30, Steve Holden schreef [EMAIL PROTECTED]: Antoon Pardon wrote: Op 2005-09-29, Bill Mill schreef [EMAIL PROTECTED]: But, if your users can't figure out that they shouldn't be changing the variable called t._test__i without expecting side effects, what do you think of the users of your class? Python is for consenting adults. No it is not. Consenting means you had the choice. Python doesn't give you the choice not to consent. Unless of course you write it as a C-extension, then you can hide all you want. Good grief, the ultimate choice is to use Python because you like it, or not to use it because you don't. Enough with the picking every available nit, please. Consent or stop complaining :-) This is IMO not a nit. IMO people are redefining words. We are also talking within a certain context. When people use this slogan, they don't mean that people have the choice to not use python. Quite true, but people do none the less have that choice. Some days I wish a few more would exercise it. Yes they have that choice and the problem is that if too many make that choice, python wouldn't evolve. A lot of progress python made, is because people who didn't like some aspects of it, discussed them and either implemeted a change themselves or got someone else interested enough to implement a change. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
El Pitonero [EMAIL PROTECTED] writes: The thing is, there are two sides to every coin. Features surely can be viewed as goodies, or they can be viewed as handcuffs. Let's see, say I'm a bank manager, and I want to close my cash vault at 5pm today and set its time lock so it can't be opened until 9am tomorrow, including by me. Is that handcuffs? It's normal procedure at any bank, for good reason. It's not necessarily some distrustful policy that the bank CEO set to keep me from robbing the bank. I might have set the policy myself. Java lets me do something similar with instance variables. Why is it somehow an advantage for Python to withhold such a capability? Sure, in these very dynamic languages you can ACCIDENTALLY override the default system behavior. How many Python programmers have once upon a time done stupid things like: list = 3 That's just a peculiarity, not any deep aspect of Python. Try it for 'None' instead of 'list': None = 3 SyntaxError: assignment to None Why is 'list' somehow different from 'None'? I'd say there's a case to be made for having the compiler protect 'list' and other builtins the same way it protects 'None'. Python won't be any less dynamic because of it. The upside is exactly the same as the fact that you can override the list() function in Python. Python is dynamic language. That's not exactly an upside, and it has nothing to do with Python being dynamic. C is static but you can override 'printf'. Overriding 'list' in Python is pretty much the same thing. In Python, if you have a private variable: self._x = 3 and you, for curiosity reasons and DURING runtime (after the program is already up and running) want to know the exact moment the self._x variable is accessed (say, print out the local time), or print out the calling stack frames, you can do it. And I mean the program is running. So let's see: def countdown(): n = 3 while n 0: yield n g = countdown() print g.next() # 3 print g.next() # 2 where's the Python feature that lets me modify g's internal value of n at this point? How is that different from modifying a private instance variable? Python feature means something in the language definition, not an artifact of some particular implementation. Is Python somehow deficient because it doesn't give a way to do that? Do you want to write a PEP to add a way? Do you think anyone will take it seriously? [Other stuff incomprehensible and snipped]. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bwidget for tkinter
thanks u man. i am new to tk inter. i tried installing the lib. but while running the demo script am getting following error. python sam.py Traceback (most recent call last): File sam.py, line 1, in ? import bwidget, Tkinter, sys, os File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 149, in ? class _Frame: File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 152, in _Frame getframe = makeswidget(getframe, Tkinter.Frame) File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 74, in makeswidget return _wrap(w, f) File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 59, in _wrap oldfunc.func_name, wrapper.func_defaults, wrapper.func_closure) TypeError: function() takes at most 4 arguments (5 given) can u plz help me -- http://mail.python.org/mailman/listinfo/python-list
bwidget problem
hi i tried installing the bwidget lib . but while running the demo script am getting following error. python sam.py Traceback (most recent call last): File sam.py, line 1, in ? import bwidget, Tkinter, sys, os File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 149, in ? class _Frame: File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 152, in _Frame getframe = makeswidget(getframe, Tkinter.Frame) File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 74, in makeswidget return _wrap(w, f) File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 59, in _wrap oldfunc.func_name, wrapper.func_defaults, wrapper.func_closure) TypeError: function() takes at most 4 arguments (5 given) can u plz help me -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin http://[EMAIL PROTECTED] writes: def countdown(): n = 3 while n 0: yield n Bah, ommitted a line: def countdown(): n = 3 while n 0: yield n n -= 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Bwidget for tkinter
[EMAIL PROTECTED] wrote: thanks u man. i am new to tk inter. i tried installing the lib. but while running the demo script am getting following error. python sam.py Traceback (most recent call last): File sam.py, line 1, in ? import bwidget, Tkinter, sys, os File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 149, in ? class _Frame: File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 152, in _Frame getframe = makeswidget(getframe, Tkinter.Frame) File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 74, in makeswidget return _wrap(w, f) File /usr/local/lib/python2.2/site-packages/bwidget/__init__.py, line 59, in _wrap oldfunc.func_name, wrapper.func_defaults, wrapper.func_closure) TypeError: function() takes at most 4 arguments (5 given) it's likely that it simply doesn't support Python 2.2 (which was released in 2001; we've had two major releases since then). /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On 03 Oct 2005 00:22:22 -0700, Paul Rubin http://[EMAIL PROTECTED] wrote: El Pitonero [EMAIL PROTECTED] writes: The thing is, there are two sides to every coin. Features surely can be viewed as goodies, or they can be viewed as handcuffs. Let's see, say I'm a bank manager, and I want to close my cash vault at 5pm today and set its time lock so it can't be opened until 9am tomorrow, including by me. Is that handcuffs? It's normal procedure at any bank, for good reason. It's not necessarily some distrustful policy that the bank CEO set to keep me from robbing the bank. I might have set the policy myself. Java lets me do something similar with instance variables. Why is it somehow an advantage for Python to withhold such a capability? Sure, in these very dynamic languages you can ACCIDENTALLY override the default system behavior. How many Python programmers have once upon a time done stupid things like: list = 3 That's just a peculiarity, not any deep aspect of Python. Try it for 'None' instead of 'list': None = 3 SyntaxError: assignment to None Why is 'list' somehow different from 'None'? I'd say there's a case to be made for having the compiler protect 'list' and other builtins the same way it protects 'None'. Python won't be any less dynamic because of it. I think I can write you a custom import that will prevent the assignment of a list of names you specify in the code of the imported module. Would that be useful? Or would it be more useful to put that detection in py/lint/checker/etc (where it probably already is?)? Would you want to outlaw 'None' as an attribute name? Python seems to be straddling the fence at this point: class C(object): pass ... c = C() c.None = 'c.None' SyntaxError: assignment to None vars(c)['None'] = 'c.None' c.None 'c.None' ;-) The upside is exactly the same as the fact that you can override the list() function in Python. Python is dynamic language. That's not exactly an upside, and it has nothing to do with Python being dynamic. C is static but you can override 'printf'. Overriding 'list' in Python is pretty much the same thing. In Python, if you have a private variable: self._x = 3 and you, for curiosity reasons and DURING runtime (after the program is already up and running) want to know the exact moment the self._x variable is accessed (say, print out the local time), or print out the calling stack frames, you can do it. And I mean the program is running. So let's see: def countdown(): n = 3 while n 0: yield n g = countdown() print g.next() # 3 print g.next() # 2 where's the Python feature that lets me modify g's internal value of n at this point? How is that different from modifying a private instance variable? Python feature means something in the language definition, not an artifact of some particular implementation. Is Python somehow deficient because it doesn't give a way to do that? Do you want to write a PEP to add a way? Do you think anyone will take it seriously? I could see it as part of a debugging interface that might let you mess more with frames in general. I wouldn't be surprised if a lot of the under-the-hood access we enjoy as it is was a byproduct of scratching debugging-tool-need itches. Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Antoon Pardon wrote: Well I'm a bit getting sick of those references to standard idioms. There are moments those standard idioms don't work, while the gist of the OP's remark still stands like: egold = 0: while egold 10: if test(): ego1d = egold + 1 Oh come on. That is a completely contrived example, and besides you can still rewrite it easily using the 'standard idiom' at which point it becomes rather clearer that it is in danger of being an infinite loop even without assigning to the wrong variable. for egold in range(10): while test(): pass I find it very hard to believe that anyone would actually mistype ego1d while intending to type egold (1 and l aren't exactly close on the keyboard), and if they typed ego1d thinking that was the name of the loop variable they would type it in both cases (or use 'ego1d += 1') which would throw an exception. The only remaining concern is the case where both ego1d and egold are existing variables, or more realistically you increment the wrong existing counter (j instead of i), and your statically typed language isn't going to catch that either. I'm trying to think back through code I've written over the past few years, and I can remember cases where I've ended up with accidental infinite loops in languages which force me to write loops with explicit incremements, but I really can't remember that happening in a Python program. Having just grepped over a pile of Python code, I'm actually suprised to see how often I use 'while' outside generators even in cases where a 'for' loop would be sensible. In particular I have a lot of loops of the form: while node: ... do something with node ... node = node.someAttribute where someAttribute is parentNode or nextSibling or something. These would, of course be better written as for loops with appropriate iterators. e.g. for node in node.iterAncestors(): ... do something with node ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Op 2005-09-30, Steven D'Aprano schreef [EMAIL PROTECTED]: On Fri, 30 Sep 2005 07:37:14 +, Antoon Pardon wrote: Well I have the following reasons not to like the current python way: 1) Beginning all your private variables with an underscore is like starting all your integers with an 'i' or all your dictionary with a 'd' etc. Three points: (1) It is utterly pointless in a statically typed language like C to name integer variables starting with an i, because both you and the compiler already know it is an integer. However, in a dynamically typed language like Python, it may in some circumstances make sense, since you have no other clue as to the expected type of object a variable has. (Descriptive names like arglist are better, but when the descriptive name is ambiguous, or there is no sensible descriptive name, this convention can be helpful.) I don't think such a convention is that helpfull. (2) Hungarian notation wasn't supposed to be about starting integer variables' names with an i, that was a misunderstanding of the Microsoft OS division. See here for further details: http://www.joelonsoftware.com/articles/Wrong.html Nice article and I think such conventions are indeed very helpfull, but we are not talking that kind of convention here. Take a statement like below: _var1 = var2 You can't infer that this is wrong because one starts with an '_' and the other doesn't. (3) Let's do a small thought experiment. Suppose that Python introduces real private variables. Now that Python has private variables, tens of thousands of C++ and Java developers immediately rush to use Python in huge collaborative projects. You're working on one of these huge projects, and reading the source code to a class that takes 45 pages for its definition. You're on page 33, and you see these lines: # cache the expensive lookup for extra speed usercache = self.longcomplexcalculation() Ahah! you say to yourself, That's exactly what I need to make my code run faster. Instead of calling Klass.longcomplexcalculation() every time I need it, I can just look at usercache. Quick: was usercache a private variable? How can you tell, short of searching through those 45 pages of code? You can't. What's the problem, my editor will find that soon enough. Of course, in real Python, as soon as you see _usercache with a leading underscore, you know it is a private variable, and you don't have to search the source code to find out. So that's an advantage to the existing Python system. But you don't know if it is a private variable of this module or a private variable imported from another module. So you don't know if it is something that you can touch freely but clients should be cautious about or something you should be cautious about. So take a module with tens of private variables, which are the one that are imported and which are the local ones. You can search all those pages too. It seems to me that much of this argument is about terminology, not reality. We've made a mistake in describing Python as not having private variables, only semi-private by convention. Bad bad bad. What we should have said is that Python DOES have private variables. In the same way that Python forces you to use a consistent indentation scheme, Python forces you to name all your private attributes with a leading underscore. And just like C++ lets you sneakily access private variables by defining private as public, so Python lets you sneakily access private variables by mangling the name. But private variable are not mangled. Just putting one underscore is apparantlty enough to flag a variable a private, but you need two starting underscores for name mangling. At least that is how I understand: http://www.python.org/doc/2.2.3/tut/node11.html#SECTION001160 Then we'd all be happy, the language zealots would take note that Python's implementation of private variables has a gotcha to watch out for, and we'd all be happy. 2) The editor and font I use make it hard to see underscores. They usually seem to belong more to the line below than to the actual lines. That's a bug in the editor/font combination. I've seen some versions of Abiword cut off the bottom pixel from lines, including underscores. If your editor made y look like v or u, you'd call it a bug, and if it makes an underscore disappear or look like part of the next line, that's a bug too. (Just like Ariel has the bug that the letters r n together look like the letter m. darn vs dam. IMO that an underscore looks like it belong to the next line is not a bug. An underscore doesn't belong to this line, it belongs under it. My idea as somekind of compromise between what happens in languages like C++ and currently in python would be the following: 1) Allow keywords like private (or implemetation) to mark certain variables, functions or classes as an implementation detail. Personnally I would prefer the
Re: Will python never intend to support private, protected and public?
Paul Rubin http://[EMAIL PROTECTED] writes: Mike Meyer [EMAIL PROTECTED] writes: Privilege separation is considered a good coding practice. How does Python help it? With conventions and name mangling. Which are only slightly less effective than the C++/Java technic for doing the same thing. That's not what privilege separation means. It means that the privileged objects stay secure even when the unprivileged part of the program is completely controlled by an attacker. In which case, what's private got to do with this? The examples I've seen of it don't give you privilege seperation any more than python does. Of course, while we're adding things to Python to support what people consider good coding practices, let's not forget: Design by contract. Covariant method specialization. Class invariants. Avoiding variable aliasing. Hungarian Notation. The Law of Demeter. Loop invariants. Avoiding mixed mode arithmetic. The telephone test. Procedure/function sepration. Type discipline. Contravariant method specialization. and so on. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
windows service problem
i code a very simple web server with python, and i want it should run as service on WindowsXP. the problem is i can run the service in debug mode, and it seems works fine(i can connect the server with browser), but when i start the service in the services control panel, i can't connect the server, the server seems not start, and i can't stop the service. any advice? -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Op 2005-09-30, Rocco Moretti schreef [EMAIL PROTECTED]: Antoon Pardon wrote: What if the class author removes a non-private variable or changes a method's documented parameters in the next version of the class, because he think it'll work better, or just because he can? Changing an interface is different from changing the implementation. A (documented) interface is like a contract. The implementation is just one way to follow that contract. Agreed. However, there is also a difference between an interface and non-private variables. E.g. you have a library, and playing with the code, you notice that by passing an empty string as a filename, you get the last file accessed. Cool. You write your program using this feature. Problem is, it's a quirk of the implementation, and in the next version, the library author fixes this bug. Preventing access to private variables wouldn't help - the only thing you touched was the public parameter to a public function. But this behaviour of a particular client can't break your library. Of course, you could have avoided this by only using the documented interface, but if we go that route, you wouldn't have to worry about people accessing private variables, as they wouldn't be documented. I'm not so much worried about client software that breaks, as I'm worried about server code that breaks because a client fiddled with the private stuff. 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. It will prevent problems for others. If you are in a project with multiple authors, your usage of private variables can break code that other people rely on. I you just use undocumented features, you will mostly only create problems in your own code. People who think that forbidding access to private variables/methods will save themselves from upgrade woes are deluding themselves. It helps, just as locks wont save you from burglars if they really want to rob you, but the locks do help. Right, but like doors that automatically lock when they close, items which are there to protect you can be a nusaince, especially when you've left your keys on the dining room table. It is always a trade off. Sometimes you settle for more protection and less comfort other times you do the opposite. If private variables would be possible, nobody would force you to use them if you didn't want to. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
cspython on Windows?
Looking around the web I get the impression development of cspython hasn't kept up with the development of Crystalspace itself, but is it possible without rebuilding the whole of Crystalspace from source, to install cspython on Windows so as to access the Crystalspace runtime environment I've installed using crystalspace_0.99_050823.exe? Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Mike Meyer [EMAIL PROTECTED] writes: That's not what privilege separation means. It means that the privileged objects stay secure even when the unprivileged part of the program is completely controlled by an attacker. In which case, what's private got to do with this? The examples I've seen of it don't give you privilege seperation any more than python does. If you have a java class instance with a private member that's (say) a network socket to a special port, access to the port is controlled entirely by that class. Calling classes can't reach into the instance to get at the socket. Similarly, private variables might hold database passwords, crypto keys, or whatever. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows service problem
JackPhil a écrit : the problem is i can run the service in debug mode, and it seems works fine(i can connect the server with browser), but when i start the service in the services control panel, i can't connect the server, the server seems not start, and i can't stop the service. Make sure it doesn't output anything to stdout or stderr, I've run into problems with that. I always include this kind of code in NT services: class Devnull: def write(self, bf): pass def close(self): pass def flush(self): pass sys.stdout = sys.stderr = Devnull() -- http://mail.python.org/mailman/listinfo/python-list
Re: Not defined
[Rob] from cgkit import * Sphere() Traceback (most recent call last): File interactive input, line 1, in ? NameError: name 'Sphere' is not defined Do you have a file of your own called cgkit.py? You're probably importing that rather than the real thing. Try this: import cgkit print cgkit.__file__ dir(cgkit) -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Op 2005-10-03, Duncan Booth schreef [EMAIL PROTECTED]: Antoon Pardon wrote: Well I'm a bit getting sick of those references to standard idioms. There are moments those standard idioms don't work, while the gist of the OP's remark still stands like: egold = 0: while egold 10: if test(): ego1d = egold + 1 Oh come on. That is a completely contrived example, No it is not. You may not have had any use for this kind of code, but unfamiliary with certain types of problems, doesn't make something contrived. and besides you can still rewrite it easily using the 'standard idiom' at which point it becomes rather clearer that it is in danger of being an infinite loop even without assigning to the wrong variable. for egold in range(10): while test(): pass And trying to force this into standard idiom is just silly. When people write examples they try to get the essential thing into the example in order to make things clear to other people. The real code they may be a lot more complicated. That you can rework the example into standard idiom doesn't mean the real code someone is working with can be reworked in a like manner. I find it very hard to believe that anyone would actually mistype ego1d while intending to type egold (1 and l aren't exactly close on the keyboard), and if they typed ego1d thinking that was the name of the loop variable they would type it in both cases (or use 'ego1d += 1') which would throw an exception. Names do get misspelled and sometimes that misspelling is hard to spot. That you find the specific misspelling used as an example contrived doesn't change that. The only remaining concern is the case where both ego1d and egold are existing variables, or more realistically you increment the wrong existing counter (j instead of i), and your statically typed language isn't going to catch that either. A language where variable have to be declared before use, would allow to give all misspelled (undeclared) variables in on go, instead of just crashing each time one is encounterd. I'm trying to think back through code I've written over the past few years, and I can remember cases where I've ended up with accidental infinite loops in languages which force me to write loops with explicit incremements, but I really can't remember that happening in a Python program. Good for you, but you shouldn't limit your view to your experience. Having just grepped over a pile of Python code, I'm actually suprised to see how often I use 'while' outside generators even in cases where a 'for' loop would be sensible. In particular I have a lot of loops of the form: while node: ... do something with node ... node = node.someAttribute where someAttribute is parentNode or nextSibling or something. These would, of course be better written as for loops with appropriate iterators. e.g. for node in node.iterAncestors(): ... do something with node ... That of course is unfounded. They may be better in your specific code, but what you showed is insufficient to decide that. The first code could for instance be reversing the sequence in the part that is labeled ...do something with node ... -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack
Peter Otten schrieb: g.franzkowiak wrote: tmpList = list(dataObject)[:4]) obj = tmpList[0]+tmpList[1]+tmpList[2]+tmpList[3]. Have you tried just obj = dataObject[:4] without the intermediate list? If that failed, can you tell us the type of the dataObject? E. g. print type(dataObject) class '__main__.NeitherListNorString' Peter The dataObject was read from a named pipe as an byte stream state, dataObject = win32file.ReadFile(handle, nbytes, None) print repr(dataObject) == '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0. With Frederiks help operates this fine gerd -- http://mail.python.org/mailman/listinfo/python-list
Load PDF
Hello, I am attempting to load a pdf file programatically within Adobe Readerusing the Adobe Acrobat 7.0 Browser Control Type Library. If I run this code PythonWin terminates abruptly, can anyone suggest any changes I should make to the following lines of code, thanks. import win32com.client test = win32com.client.Dispatch("AcroPDF.PDF.1")test.LoadFile("D:\\sql.pdf") Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode charmap decoders slow
Tony Nelson wrote: Is there a faster way to decode from charmaps to utf-8 than unicode()? You could try the iconv codec, if your system supports iconv: http://cvs.sourceforge.net/viewcvs.py/python-codecs/practicecodecs/iconv/ Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python based unacceptable language filter
David Pratt [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi. Is anyone aware of any python based unacceptable language filter code to scan and detect bad language in text from uploads etc. Many thanks. David Look up Spambayes - if you can filter on terms like dear friend you can filter on the inverse too, no? It needs samples to work with. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows service problem
fraca7 wrote: Make sure it doesn't output anything to stdout or stderr, I've run into problems with that. I always include this kind of code in NT services: class Devnull: def write(self, bf): pass def close(self): pass def flush(self): pass sys.stdout = sys.stderr = Devnull() Thanks for your instructions. It's resolved my problem. -- http://mail.python.org/mailman/listinfo/python-list
Problem with slices.
I'm for the moment writing two classes. A table, which is like a list, but can start at any integer. A tree which is like a dictionary, but will iterate over the keys in sorted order. The problem is that I would like to implemet slices but, that seems to be impossible with how slices are implemented now. I wrote the following class to test things out. class Tst: def __getitem__(self, key): print key then I called the interpreter and got this: from tst import Tst t=Tst() t[:] slice(0, 2147483647, None) t[:9] slice(0, 9, None) t[:'ok'] slice(None, 'ok', None) t['ok':] slice('ok', None, None) t[6:] slice(6, 2147483647, None) t[1,2] (1, 2) t[1,2:] (1, slice(2, None, None)) t[(1,2):] slice((1, 2), None, None) Now suppose tab is a table with indexes from -5 to 12. tab[:4] would have to make a table ranging from -5 to 4 tab[0:4] would have to make a table ranging from 0 to 4. But each time I would be given the same argument, being slice(0, 4, None). So I would be unable to distinghuish between the two. I don't think it very likely but I could have a table with indexes from 2147483647 to 2147483700, so having 2147483647 as value that indicated till the end of the sequence is a bit awkward. The same problems occur when I have a tree with integer key values. But even if I don't use integers as keys I have a problem with what is returned since None is a valid key and thus it shouldn't be used this way. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack
g.franzkowiak wrote: The dataObject was read from a named pipe as an byte stream state, dataObject = win32file.ReadFile(handle, nbytes, None) print repr(dataObject) == '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0. With Frederiks help operates this fine I do not doubt that. My point was that instead of the suggested # Fredrik obj = .join(list(dataObject[:4])) the simpler # me obj = dataObject[:4] might work as well. I cannot test it here, but judging from http://aspn.activestate.com/ASPN/docs/ActivePython/2.3/pywin32/win32file__ReadFile_meth.html the resulting dataObject is a buffer and buffer slices seem to be just strings. print repr(dataObject) == '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0. Hmm, that looks as if dataObject were a string -- please post the result of print type(dataObject) just to help me restore my peace of mind :-) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with slices.
Antoon Pardon wrote: I'm for the moment writing two classes. A table, which is like a list, but can start at any integer. A tree which is like a dictionary, but will iterate over the keys in sorted order. The problem is that I would like to implemet slices but, that seems to be impossible with how slices are implemented now. I wrote the following class to test things out. class Tst: def __getitem__(self, key): print key then I called the interpreter and got this: from tst import Tst t=Tst() t[:] slice(0, 2147483647, None) t[:9] slice(0, 9, None) t[:'ok'] slice(None, 'ok', None) t['ok':] slice('ok', None, None) t[6:] slice(6, 2147483647, None) t[1,2] (1, 2) t[1,2:] (1, slice(2, None, None)) t[(1,2):] slice((1, 2), None, None) Now suppose tab is a table with indexes from -5 to 12. tab[:4] would have to make a table ranging from -5 to 4 tab[0:4] would have to make a table ranging from 0 to 4. But each time I would be given the same argument, being slice(0, 4, None). So I would be unable to distinghuish between the two. I don't think it very likely but I could have a table with indexes from 2147483647 to 2147483700, so having 2147483647 as value that indicated till the end of the sequence is a bit awkward. The same problems occur when I have a tree with integer key values. But even if I don't use integers as keys I have a problem with what is returned since None is a valid key and thus it shouldn't be used this way. Consider new-style classes: class T(object): ... def __getitem__(self, key): ... return key ... t = T() t[:4] slice(None, 4, None) t[0:4] slice(0, 4, None) t[0:] slice(0, None, None) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
Op 2005-09-30, Sam schreef [EMAIL PROTECTED]: This is a MIME GnuPG-signed message. If you see this text, it means that your E-mail or Usenet software does not support MIME signed messages. The Internet standard for MIME PGP messages, RFC 2015, was published in 1996. To open this message correctly you will need to install E-mail or Usenet software that supports modern Internet standards. --=_mimegpg-commodore.email-scan.com-32420-1128120829-0002 Content-Type: text/plain; format=flowed; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Reinhold Birkenfeld writes: Hi, after Guido's pronouncement yesterday, in one of the next versions of Python there will be a conditional expression with the following syntax: X if C else Y which is the same as today's (Y, X)[bool(C)] What's wrong with C ? X:Y? Aside from : being overloaded? Nothing, but afaiu Guido dislikes it. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
[EMAIL PROTECTED] (Bengt Richter) writes: Would you want to outlaw 'None' as an attribute name? Python seems to be straddling the fence at this point: c.None = 'c.None' SyntaxError: assignment to None Heehee, I think that's just a compiler artifact, the lexer is treating None as a keyword instead of a normal lexical symbol that the compiler treats separately. That's also why it raises SyntaxError instead of some other type of error. Yes, None should be ok as an attribute name. I could see it as part of a debugging interface that might let you mess more with frames in general. I wouldn't be surprised if a lot of the under-the-hood access we enjoy as it is was a byproduct of scratching debugging-tool-need itches. Such an interface should probably work like the Java one, i.e. it would have a special socket listener that you'd poke at the program through, not have debugging code running in the same interpreter space as the target app. -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Antoon Pardon wrote: A language where variable have to be declared before use, would allow to give all misspelled (undeclared) variables in on go, instead of just crashing each time one is encounterd. Wrong. It would catch at compile-time those misspellings which do not happen to coincide with another declared variable. It would give the programmer a false sense of security since they 'know' all their misspellings are caught by the compiler. It would not be a substitute for run-time testing. Moreover, it adds a burden on the programmer who has to write all those declarations, and worse it adds a burden on everyone reading the code who has more lines to read before understanding the code. Also there is increased overhead when maintaining the code as all those declarations have to be kept in line as the code changes over time. It's a trade-off: there is a potential advantage, but lots of disadvantages. I believe that the disadvantages outweight the possible benefit. Fortunately there are plenty of languages to choose from out there, so those who disagree with me are free to use a language which does insist on declarations. -- http://mail.python.org/mailman/listinfo/python-list
Finding the Process Path
I have Python code running in an application, and I would like to find the full path of the process executable where it is running. I can do this with win32api.GetModuleFileName(0) on Windows, but I would like a solution that uses only standard modules and works cross platform. Any suggestions? TIA. Jon K Peck (Kim) [EMAIL PROTECTED] 312-651-3435 233 S Wacker Dr Chicago, IL 60606 -- http://mail.python.org/mailman/listinfo/python-list
Re: Automating, Building, Testing and Deploying to Production Server
yoda wrote: I realize I'm losing so much time I could spend more productively. I'd therefore like to know the different approaches you guys employ to deploy builds from your staging servers (or laptops:) to the production server in an automated repeatable safe manner. How do you automate the process? We have a system called the buildout that checks out a project's code, downloads and builds any dependencies, and configures a working system. (http://svn.zope.org/Sandbox/zc/buildout/trunk/) We use that for setting up new development environments (each developer generally has several builds of any project at one time). What tools do you use and how? We also have a BuildBot setup that runs a buildout and then runs the tests and emails a list if the tests fail (http://buildbot.sf.net). You can see an example of our public buildbot here: http://buildbot.zope.org. What documentation is available for the various tools? We just publicly released the buildout code a couple of weeks ago, and it seriously needs docs and tests. BuildBot doesn't have great docs, but it's configured via Python, so it's not too bad. What is the best, easiest, most automated, method that provides robust versioning and easy rollback? When we deploy via buildout (as opposed to by using an installer or a simple archive) we generally either just tell the buildout to update itself, or if we want the ability to roll back make a new buildout and switch to it (therefore we can switch back to the previous build). We don't do it this way, but because the buildout for a particular project is itself versioned, you could just svn up to the previous version and rebuild it and you'd be back to where you started. -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Re: Python based unacceptable language filter
On Oct 2, 2005, at 9:45 PM, Nigel Rowe wrote: David Pratt wrote: Hi. Is anyone aware of any python based unacceptable language filter code to scan and detect bad language in text from uploads etc. Many thanks. David You might be able to adapt languagetool. http://www.danielnaber.de/languagetool/features.html Later versions have been ported to Java, but the old python version of languagetool is at http://tkltrans.sourceforge.net/#r03 His thesis paper is at http://www.danielnaber.de/languagetool/download/ style_and_grammar_checker.pdf Mind you, given the poor language skills of many native english speakers (not to mention those for whom english is a second language) relying on automated filters to enforce 'good' language seems a trifle extreme. This post for example would probably not pass. Cheers, Nigel PS. For the humour impaired, this g*d d*mm post was a f*cking joke, OK! :-) Mind you, the links are real. -- Nigel Rowe A pox upon the spammers that make me write my address like.. rho (snail) swiftdsl (stop) com (stop) au -- http://mail.python.org/mailman/listinfo/python-list I think he may be referring to bad words, and 'filthy' language. At least that's what i got from the question. There are many PHP implementations on the web, which could be adapted to python fairly easily. Most of which are probably not the most ideal solution and involve alot of stuff like for n in badwords: texttofilter.replace(n, 'bad word deleted') If that's all you need though, maybe it's not so bad. --- Andrew Gwozdziewycz [EMAIL PROTECTED] http://ihadagreatview.org http://plasticandroid.org -- http://mail.python.org/mailman/listinfo/python-list
Reply-To header
Is it just me, or does python-list@python.org not send with a Reply- To header? --- Andrew Gwozdziewycz [EMAIL PROTECTED] http://ihadagreatview.org http://plasticandroid.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the Process Path
Peck, Jon wrote: I have Python code running in an application, and I would like to find the full path of the process executable where it is running. Like this? import sys sys.executable '/usr/bin/python' -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the Process Path
other ways to get at info: if sys.hexversion 0x010502F0: sys.versioninfo, version, etc. platform.architecture, processor etc. distutils.sysconfig.get_makefile_filename( ) Benji York wrote: Peck, Jon wrote: I have Python code running in an application, and I would like to find the full path of the process executable where it is running. Like this? import sys sys.executable '/usr/bin/python' -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Re: Reply-To header
[Andrew] Is it just me, or does python-list@python.org not send with a Reply- To header? It's not just you. I don't get one either. -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python based unacceptable language filter
Hi. Thank you for the links. I am looking for something that would function in a similar way to Yahoo's filter for it's message boards. Perhaps I should have used the term profanity instead of unacceptable language. I am not concerned about correcting sentence structure or poor grammar. I realize screening profanity can be accomplished by simply looping over regular expressions from a database or dictionary to search the text to check against possibilities . I thought it possible that there may be something like this already in existence, perhaps already in a module since it is likely (despite how absurd) - that someone has developed a dictionary of profane word expressions I suspect. What's is perhaps more crazy, is that one has to consider including something like this in an application - but you have to conclude the Internet is what it is. Regards David From Yahoo: The Profanity Filter allows you to control how you want to view messages with profanity in two ways. You can choose to view the messages with the profanity masked with italcized symbols (@$% ), or you can have the messages containing profanity hidden entirely. You can also choose between a weak setting for exact word matches or a strong setting that will filter spelling variations. Well I know this thread is a On Sunday, October 2, 2005, at 10:45 PM, Nigel Rowe wrote: David Pratt wrote: Hi. Is anyone aware of any python based unacceptable language filter code to scan and detect bad language in text from uploads etc. Many thanks. David You might be able to adapt languagetool. http://www.danielnaber.de/languagetool/features.html Later versions have been ported to Java, but the old python version of languagetool is at http://tkltrans.sourceforge.net/#r03 His thesis paper is at http://www.danielnaber.de/languagetool/download/ style_and_grammar_checker.pdf Mind you, given the poor language skills of many native english speakers (not to mention those for whom english is a second language) relying on automated filters to enforce 'good' language seems a trifle extreme. This post for example would probably not pass. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python based unacceptable language filter
Good question, but Y'know, i don't think i'm the only one using a threaded mail reader. Pls don't hijack others' threads. David Pratt wrote: Hi. Is anyone aware of any python based unacceptable language filter code to scan and detect bad language in text from uploads etc. Many thanks. David -- http://mail.python.org/mailman/listinfo/python-list
about pyopengl
I am a chinese boy,my english is not good,so i don not know how to tell you about my question,i hope you can understand what i say. I like python, and now i using pyopengl to draw three-dimensional. but how can i use mouse to control objects?such as selecting object.I know a function( glSelectBuffer() ) can be used,In C language the format is glSelectBuffer(size, buffer), but in python the format is glSelectBuffer(size), how can i get the buffer pointer? The following is one section function of my codes: def ProcessSelection(x,y): viewport=range(4) glSelectBuffer(64) viewport=glGetIntegerv(GL_VIEWPORT) glMatrixMode(GL_PROJECTION) glPushMatrix() glRenderMode(GL_SELECT) glLoadIdentity() gluPickMatrix(x, viewport[3]-y, 2, 2, viewport) gluPerspective(45.0, aspect, 0.1, 200.0) DrawButton() hits=glRenderMode(GL_RENDER) glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW) If you know how to do ,can you mail to me?thank you! my e-mail is [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
Michael a écrit : Rocco Moretti wrote: That is, what would happen with the following constructs: A if B else C if D else F A if B if C else D else F The correct answer should be the person who wrote it would get told off for writing code that a person reading would have no idea what the code was doing (without understanding the precedence). Whilst it's good to have clear understandable, well defined rules for these things, that's no excuse for having unreadable code that other people can't read and understand without having to remember obscure rules. Personally, I'd hope that any code-linting tools would flag such expressions as potentially bad because they're not clear. (Whereas bracketed expressions instantly help here). Actually, you don't need to know operator precedence here because the notation isn't ambiguous in those 2 examples. Of course, it takes some time to understand the thing but it has more to do with the excessive amount of logic in one line than with the syntax. -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
James A. Donald wrote: I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified horrified ??? Ok, so I'll give you more reasons to be 'horrified': - no private/protected/public access restriction - it's just a matter of conventions ('_myvar' - protected, '__myvar' - private) - no constants (here again just a convention : a name in all uppercase is considered a constant - but nothing will prevent anyone to modify it) - possibility to add/delete attributes to an object at runtime - possibility to modify a class at runtime - possibility to change the class of an object at runtime - possibility to rebind a function name at runtime If you find all this horrifying too, then hi-level dynamic languages are not for you !-) to read no variable or argument declarations are necessary. No declarative static typing is necessary - which not the same thing. In Python, type informations belong to the object, not to names that are bound to the object. Of course you cannot use a variable that is not defined ('defining' a variable in Python being just a matter of binding a value to a name). Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. Depends. If you try to use an undefined variable, you'll get a name error: print var1 # var1 is undefined at this stage Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'var1' is not defined Now if the typo is on the LHS, you'll just create a new name in the current namespace: myvra = 42 # should have been 'myvar' and not 'myvra' But you'll usually discover it pretty soon: print myvar Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'myvar' is not defined If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, yes, but this is quite uncommon. The 'enclosing context' is composed of the 'global' (which should be named 'module') namespace and the local namespace. Using globals is bad style, so it shouldn't be too much of a concern, but anyway trying to *assign* to a var living in the global namespace without having previously declared the name as global will not overwrite the global variable - only create a local name that'll shadow the global one. Since Python is very expressive, functions code tend to be small, so the chances of inadvertently reuse a local name are usually pretty low. Now we have the problem of shadowing inherited attributes in OO. But then the same problem exists in most statically typed OOPLs. or inadvertently reference a new variable (a typo) when you intended to reference an existing variable. Nope. Trying to 'reference' an undefined name raises a name error. What can one do to swiftly detect this type of bug? 1/ write small, well-decoupled code 2/ use pychecker or pylint 3/ write unit tests You'll probably find - as I did - that this combination (dynamic typing + [pylint|pychecker] + unit tests) usually leads to fewer bugs than just relying on declarative static typing. What you fear can become reality with some (poorly designed IMHO) scripting languages like PHP, but should not be a concern with Python. Try working with it (and not to fight agaisnt it), and you'll see by yourself if it fits you. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
James A. Donald wrote: James A. Donald: Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. On Sun, 02 Oct 2005 17:11:13 -0400, Jean-François Doyon No, the error message will be pretty clear actually :) Now why, I wonder, does this loop never end :-) egold = 0 while egold 10: ego1d = egold+1 A more pythonic style would be: egold = 0 while egold 10: ego1d += 1 And that one raises a name error !-) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
[EMAIL PROTECTED] wrote: The easiest way to avoid this problem (besides watching for NameError exceptions) is to use an editor that has automatic name completion. Eric3 is a good example. So, even though in theory it could be an issue, I rarely run into this in practice. I don't use emacs automatic completion, and I still rarely (read: 'never') run into this kind of problem in Python. -- bruno desthuilliers ruby -e print '[EMAIL PROTECTED]'.split('@').collect{|p| p.split('.').collect{|w| w.reverse}.join('.')}.join('@') -- http://mail.python.org/mailman/listinfo/python-list
Re: Reply-To header
Richie Hindle wrote: [Andrew] Is it just me, or does python-list@python.org not send with a Reply- To header? It's not just you. I don't get one either. Indeed, and that's by design: http://www.unicom.com/pw/reply-to-harmful.html -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
RE: Finding the Process Path
Thanks, but this doesn't tell me what I am looking for. I am looking for the path for the current process (which will not be the Python interpreter). I see, though, that this is available as sys.executable Regards, Jon Peck -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of gene tani Sent: Monday, October 03, 2005 7:39 AM To: python-list@python.org Subject: Re: Finding the Process Path other ways to get at info: if sys.hexversion 0x010502F0: sys.versioninfo, version, etc. platform.architecture, processor etc. distutils.sysconfig.get_makefile_filename( ) Benji York wrote: Peck, Jon wrote: I have Python code running in an application, and I would like to find the full path of the process executable where it is running. Like this? import sys sys.executable '/usr/bin/python' -- Benji York -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: sorting tuples...
Steve Holden wrote: Dan Sommers wrote: On 27 Sep 2005 19:01:38 -0700, [EMAIL PROTECTED] wrote: with the binary stuff out of the way, what i have is this string data: 20050922 # date line mike mike's message... 20040825 # date line jeremy jeremy's message... ... what i want to do is to use the date line as the first data in a tuple and the succeeding lines goes into the tuple, like: (20050922, mike, mike's message) then when it matches another date line it makes another new tuple with that date line as the header data and the succeeding data, etc.. (20050922, mike, mike's message) (20040825, jeremy, jeremy's message) ... then i would sort the tuples according to the date. is there an easier/proper way of doing this without generating alot of tuples? You want a dictionary. Python dictionaries map keys to values (in other languages, these data structures are known as hashes, maps, or associative arrays). The keys will be the dates; the values will depend on whether or not you have multiple messages for one date. If the dates are unique (which, looking at your data, is probably not true), then each item in the dictionary can be just one (who, message) tuple. If the dates are not unique, then you'll have to manage each item of the dictionary as a list of (who, message) tuples. And before you ask: no, dictionaries are *not* sorted; you'll have to sort a separate list of the keys or the items at the appropriate time. I'm not sure this advice is entirely helpful, since it introduces complexities not really required by the simplistic tuple notation the OP seems to be struggling for. Following the old adage First, make it work; then (if it doesn't work fast enough) make it faster), and making the *dangerous* assumption that each message genuinely is exactly three lines, we might write: msglist = [] f = open(theDataFile.txt, r) for date in f: who = f.next() # pulls a line from the file msg = f.next() # pulls a line from the file msglist,append((date, who, msg)) # now have list of messages as tuples msglist.sort() After this, msglist should be date-sorted list of messages. Though who knows what needs to happen to them next ... just to spit it all out to stdout in a nice formatted form so I can save it to a file. I'm still confused though, but I'm working on it. struct is nice. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.pycon.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Reply-To header
Richie Hindle [EMAIL PROTECTED] wrote: [Andrew] Is it just me, or does python-list@python.org not send with a Reply-To header? It's not just you. I don't get one either. Excellent! That leaves the Reply-To field free for its intended use: to give the return address for an individual reply to the message author. -- \ What I resent is that the range of your vision should be the | `\ limit of my action. -- Henry James | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
NamedTemporaryFile and mode a+rwx
Hi, I'd like to create a temporaty shell script. Therefore I use tempfile with NamedTemporaryFile. The problem is that the _mkstemp_inner create the file using 06000 code. Then the fdopen is called, but the stat of the file does not change to executable. Why the fdopen does not modify the mode of the file ? Without the executable flag, this could not be understood as an executable file. Thanks. the trace : t=tempfile.NamedTemporaryFile(mode=a+rwx) print t.name /tmp/tmp5wwa9K print t.mode a+rwx os.system(ls -l + t.name) -rw--- 1 myLogin 0 Oct 3 15:30 /tmp/tmp5wwa9K os.system(stat + t.name) File: `/tmp/tmp5wwa9K' Size: 0 Blocks: 0 IO Block: 8192 regular empty file Device: 2h/2d Inode: 8593614 Links: 1 Access: (0600/-rw---) Uid: (10373/ numerix) Gid: ( 1102/ rms) Access: 2005-10-03 15:30:38.0 +0200 Modify: 2005-10-03 15:30:38.0 +0200 Change: 2005-10-03 15:30:38.0 +0200 -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Op 2005-10-03, Duncan Booth schreef [EMAIL PROTECTED]: Antoon Pardon wrote: A language where variable have to be declared before use, would allow to give all misspelled (undeclared) variables in on go, instead of just crashing each time one is encounterd. Wrong. It would catch at compile-time those misspellings which do not happen to coincide with another declared variable. Fine, it is still better than python which will crash each time one of these is encountered. It would give the programmer a false sense of security since they 'know' all their misspellings are caught by the compiler. It would not be a substitute for run-time testing. I don't think anyone with a little bit of experience will be so naive. Moreover, it adds a burden on the programmer who has to write all those declarations, So? He has to write all those lines of code too. 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 and worse it adds a burden on everyone reading the code who has more lines to read before understanding the code. Well maybe we should remove all those comments from code too, because all it does is add more lines for people to read. Also there is increased overhead when maintaining the code as all those declarations have to be kept in line as the code changes over time. Which is good. Just as you have to keep the unittests in line as code changes over time. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
You Can FIND any thing u want
Hi This website can help you to find any links you want: http://www.lxlinks.cjb.net Enjoy -- http://mail.python.org/mailman/listinfo/python-list
morphological image processing in Python
Hello, I'm about to start a project which will involve some greyscale image processing using morphological operators (erosion, dilation, distance transforms...), and I was wondering if these operators were available in Python through some open source libraries. A quick google search returned pymorphpro[1], which is unfortunately not free software, and there also seem to be something available in ITK [2]. Unless I'm mistaken, the PIL does not provide these operations, nore do Numeric/numarray/scipy. Have I missed the one true Python mathematical morphology toolbox? Thanks in advance for any advice. [1] http://www.mmorph.com/pymorphpro/index.html [2] http://www.itk.org/ -- Alexandre Fayolle LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org -- http://mail.python.org/mailman/listinfo/python-list
Py2Exe + kinterbasdb
Hi ! I compile an application (that working good in native python) to exe with py2exe. In native mode (python.exe ReportApp.py) it is working, the reports are created good. But when I try to create a report from the compiled exe, it is show an error: Traceback (most recent call last): File Report01.pyc, line 164, in OnButton1Button File report_01.pyc, line 12, in OpenDBForReport File report_db.pyc, line 11, in OpenDB File kinterbasdb\__init__.pyc, line 472, in connect File kinterbasdb\__init__.pyc, line 558, in __init__ File kinterbasdb\__init__.pyc, line 367, in _ensureInitialized File kinterbasdb\__init__.pyc, line 315, in init ImportError: No module named typeconv_backcompat The OpenDB is do this: def OpenDB(paramdb): dsn=paramdb.get('PATH','') usr=paramdb.get('USER','sys'+'dba') pwd=paramdb.get('PASSWORD','any') global DB DB=kim.connect(dsn=dsn, user=usr,password=pwd) return DB It seems to be that the problem occured in __init__.pyc. How to I prevent it ? Please help me ! Thanks. For any help. K. O. R. : dd -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the Process Path
Peck, Jon wrote: Thanks, but this doesn't tell me what I am looking for. I am looking for the path for the current process (which will not be the Python interpreter). Actually the core image will be that of the Python interpreter. I see, though, that this is available as sys.executable The interpreter? That's correct. What you probably want is import os, sys print os.path.abspath(sys.argv[0]) this will give you the path to the Python script the interpreter is running. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
RE: Finding the Process Path
Problem solved, but sys.executable seems to be (mostly) what I need. The context here is that my code is embedded in another process, so the Python interpreter is not the process executable, and in fact argv is not set (for various reasons not related to Python.) If I run this code directly through the interpreter, of course Python is what I get from sys.executable. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Holden Sent: Monday, October 03, 2005 9:26 AM To: python-list@python.org Subject: Re: Finding the Process Path Peck, Jon wrote: Thanks, but this doesn't tell me what I am looking for. I am looking for the path for the current process (which will not be the Python interpreter). Actually the core image will be that of the Python interpreter. I see, though, that this is available as sys.executable The interpreter? That's correct. What you probably want is import os, sys print os.path.abspath(sys.argv[0]) this will give you the path to the Python script the interpreter is running. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: morphological image processing in Python
On Mon, 3 Oct 2005 14:23:11 + (UTC), Alexandre Fayolle [EMAIL PROTECTED] wrote: Hello, I'm about to start a project which will involve some greyscale image processing using morphological operators (erosion, dilation, distance transforms...), and I was wondering if these operators were available in Python through some open source libraries. A quick google search returned pymorphpro[1], which is unfortunately not free software, and there also seem to be something available in ITK [2]. Unless I'm mistaken, the PIL does not provide these operations, nore do Numeric/numarray/scipy. Have I missed the one true Python mathematical morphology toolbox? Thanks in advance for any advice. Actually, numarray does support morphological array operations. See the chapter on 'Multi-dimensional image processing' in the numarray docs. Matt Feinstein -- There is no virtue in believing something that can be proved to be true. -- http://mail.python.org/mailman/listinfo/python-list
Re: morphological image processing in Python
Alexandre Fayolle wrote: Hello, I'm about to start a project which will involve some greyscale image processing using morphological operators (erosion, dilation, distance transforms...), and I was wondering if these operators were available in Python through some open source libraries. A quick google search returned pymorphpro[1], which is unfortunately not free software, and there also seem to be something available in ITK [2]. Unless I'm mistaken, the PIL does not provide these operations, nore do Numeric/numarray/scipy. Have I missed the one true Python mathematical morphology toolbox? numarray http://stsdas.stsci.edu/numarray/numarray-1.3.html/module-numarray.ndimage.html This will be ported to the new scipy shortly. We could use some help. -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
Ron Adam [EMAIL PROTECTED] wrote: So ... A if B else C + X * Y Would evaluate as... ? A if B else (C + X * Y) In general, 'if' and 'else' bind less tight than everything except lambda. http://mail.python.org/pipermail/python-dev/2005-September/056846.html -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Antoon Pardon wrote: and worse it adds a burden on everyone reading the code who has more lines to read before understanding the code. Well maybe we should remove all those comments from code too, because all it does is add more lines for people to read. You'll get no argument from me there. The vast majority of comments I come across in code are a total waste of time. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to send a SIGINT to a Python process?
Michele Simionato [EMAIL PROTECTED] wrote: Is there a way to send a SIGINT/KeyboardInterrupt to a Python process (knowing the pid) that works both on Unix and Windows? No. Windows doesn't support the sending of signals between processes (with the exception of an equivalent of SIGKILL). I guess this explains why server processes running on Windows need to be shutdown and restarted (at least) if you change their configuration -- there's no (convenient or standardised) way of doing the equivalent of SIGHUP. -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings towards penguins one way or the other \X/ |-- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
On Mon, 03 Oct 2005 06:59:04 +, Antoon Pardon wrote: Well I'm a bit getting sick of those references to standard idioms. There are moments those standard idioms don't work, while the gist of the OP's remark still stands like: egold = 0: while egold 10: if test(): ego1d = egold + 1 for item in [x for x in xrange(10) if test()]: But it isn't about the idioms. It is about the trade-offs. Python allows you to do things that you can't do in other languages because you have much more flexibility than is possible with languages that require you to declare variables before using them. The cost is, some tiny subset of possible errors will not be caught by the compiler. But since the compiler can't catch all errors anyway, you need to test for 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. Declared variables have considerable labour costs, and only marginal gains. Since the steps you take to protect against other errors will also protect against mistyping variables, declarations of variables is of little practical benefit. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!
The Main Issue in a nutshell I am a corporate developer, working for a single company. Got a new project coming up and wondering if I should stay with Python for this new, fairly large project, are jump back on the 'safe' M$ bandwagon using a dot net language? Cross platform is NOT an issue, but COMPLETE control/compatability with MsSql Server (current and future versions) certainly is. Quick History Started out 10+ yrs ago using FoxPro, upgrading as Fox did, was a good system but never really loved it due to many factors I won't get into now. Did alot of work in Delphi, once version 5 came out... really loved it for awhile. Began using MS SQL server as database. Had a HUGE re-write of an old dos-based database system to do, did alot of work on it in Delphi 7, but really began to have issues with Delphi, even tho alot of it is fantastic. As I was working on the re-write, had another smaller system to work up, so I was going to have to do both at once... I began to look around for another language as was having issues with Delphi, very long story short, I became enthralled with Python, and using it, with wxWindows to write the interface, and adodbapi.py to communicate with ms sql server, I did the other smaller system. To my big surprise, within a short time where I wrote a wrapper class that emulated working with the Delphi ado record set object, around the very nice (but somewhat limited) adodbapi.py module. For the windows user interface, I also learned how to create wx resource files with the stock resource editor and connect the controls to code. And using a free text editor (pspad) I was MORE PRODUCTIVE than with the super-duper point and click visual Delphi. Ok, I got the small system done very quickly, and dumped my problematic delphi version of the big system, and re-worked it up with my thrown together, totally free Python package, and I swear, had it finished before I would have if I had stayed with the Delphi version. Ok, time goes by, the big system continues to get improved etc... now all of a sudden, the smaller system needs to grow big time, as it has morphed and they need all these new things. THE DILEMMA Ok, I LOVE python, so that is not the issue, but, I am getting very worried about it's growth. I recently re-visted the web looking at alot of projects I assumed would be up and running by now from over a year ago, such as Boa Constructor, Iron Python etc... it seems all these projects get started, but never finished. Also, more and more I need *complete* control of ms sql from my apps, which is simply not available from the adodbapi module I got off the internet... also, ms sql 2005 is getting ready to come out... what if the guy that wrote adodbapi.py does not feel like upgrading it so it even works with MS SQL SERVER 2005? Yeesh... you get the picture... So, wondering if anyone else is having these concerns or not, and if not, why etc... Any input appreciated. Python lover, but worried, diego -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On 03 Oct 2005 04:47:26 -0700, Paul Rubin http://[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Bengt Richter) writes: Would you want to outlaw 'None' as an attribute name? Python seems to be straddling the fence at this point: c.None = 'c.None' SyntaxError: assignment to None Heehee, I think that's just a compiler artifact, the lexer is treating None as a keyword instead of a normal lexical symbol that the compiler treats separately. That's also why it raises SyntaxError instead of some other type of error. Yes, None should be ok as an attribute name. Not sure whether which compiler. This one seems to differ from the C version. import compiler compiler.parse(c.None = 'c.None') Module(None, Stmt([Assign([AssAttr(Name('c'), 'None', 'OP_ASSIGN')], Const('c.None'))])) compiler.compile(c.None = 'c.None', '', 'exec') code object module at 02EE7FA0, file , line 1 import dis dis.dis(compiler.compile(c.None = 'c.None', '', 'exec')) 1 0 LOAD_CONST 1 ('c.None') 3 LOAD_NAME0 (c) 6 STORE_ATTR 1 (None) 9 LOAD_CONST 0 (None) 12 RETURN_VALUE c = type('',(),{})() exec (compiler.compile(c.None = 'c.None', '', 'exec')) c.None 'c.None' So the compiler module is happy to generate code that you can execute, but the builtin compiler seems not to be: c.None = 'c.None' SyntaxError: assignment to None and definitely not run-time: def foo(): ... c.None = 'c.None' ... File stdin, line 2 SyntaxError: assignment to None Seems like a bug wrt the intent of making compiler.compile work exactly like the builtin C version. But maybe it has been fixed -- I am still running 2.4 from the beta I built with mingw (because the new microsoft msi loader won't run on my version of NT4 without upgrading that I've got too much dll hell to do on this box. I should also upgrade mingw/msys and recompile, but I spend time here instead ;-/ ) Python 2.4b1 (#56, Nov 3 2004, 01:47:27) [GCC 3.2.3 (mingw special 20030504-1)] on win32 Type help, copyright, credits or license for more information. Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: Reply-To header
On 10/3/05, Roel Schroeven [EMAIL PROTECTED] wrote: Indeed, and that's by design: http://www.unicom.com/pw/reply-to-harmful.html Of course, that's only one side of the argument: http://www.blackgate.net/consulting/reply-to_munging_useful.html On lists like this, where everyone benefits by sharing information, it seems pretty lame to hide behind purist arguments about Reply-To: headers. The default behavior should be the one most useful to the list. Think for a moment how many useful bits of information you've missed because the default for this list it to make conversations private. -- # p.d. -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Steven D'Aprano a écrit : On Mon, 03 Oct 2005 06:59:04 +, Antoon Pardon wrote: Well I'm a bit getting sick of those references to standard idioms. There are moments those standard idioms don't work, while the gist of the OP's remark still stands like: egold = 0: while egold 10: if test(): ego1d = egold + 1 for item in [x for x in xrange(10) if test()]: But it isn't about the idioms. It is about the trade-offs. Python allows you to do things that you can't do in other languages because you have much more flexibility than is possible with languages that require you to declare variables before using them. The cost is, some tiny subset of possible errors will not be caught by the compiler. But since the compiler can't catch all errors anyway, you need to test for 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. Declared variables have considerable labour costs, and only marginal gains. Since the steps you take to protect against other errors will also protect against mistyping variables, declarations of variables is of little practical benefit. As a matter of fact, doing that one on a HP48 calculator with unit anotated values would have worked perfectly, except for the distance 27 check which would have raised one error. -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack
Peter Otten schrieb: g.franzkowiak wrote: The dataObject was read from a named pipe as an byte stream state, dataObject = win32file.ReadFile(handle, nbytes, None) print repr(dataObject) == '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0. With Frederiks help operates this fine I do not doubt that. My point was that instead of the suggested # Fredrik obj = .join(list(dataObject[:4])) the simpler # me obj = dataObject[:4] might work as well. I cannot test it here, but judging from http://aspn.activestate.com/ASPN/docs/ActivePython/2.3/pywin32/win32file__ReadFile_meth.html the resulting dataObject is a buffer and buffer slices seem to be just strings. print repr(dataObject) == '\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x0. Hmm, that looks as if dataObject were a string -- please post the result of print type(dataObject) just to help me restore my peace of mind :-) Peter Hello Peter, was a node in my mind, the data comes as a string (with readfile always) type(dataObject) = 'str' and type(dataObject:4) = 'str' also ;-) I've dropped the loop with list/join and the result is the same. Thank you :-)) gerd -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
On Mon, 03 Oct 2005 09:14:34 +, Antoon Pardon wrote: If you are in a project with multiple authors, your usage of private variables can break code that other people rely on. If you are in a project with multiple authors, your usage of PUBLIC variables can break code that other people rely on. That's why you have testing. You do test, don't you? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reply-To header
Peter Decker wrote: On 10/3/05, Roel Schroeven [EMAIL PROTECTED] wrote: Indeed, and that's by design: http://www.unicom.com/pw/reply-to-harmful.html Of course, that's only one side of the argument: http://www.blackgate.net/consulting/reply-to_munging_useful.html On lists like this, where everyone benefits by sharing information, it seems pretty lame to hide behind purist arguments about Reply-To: headers. The default behavior should be the one most useful to the list. Think for a moment how many useful bits of information you've missed because the default for this list it to make conversations private. The default of this list is not to make conversations private; in fact the list doesn't have any default. It's you who chooses to send replies to the original author, to the list, or both, by choosing which button to press in your mail client. Unfortunately AFAIK most of the popular mail clients don't offer a 'Reply to list' button. Even mutt only offers that functionality of you manually define all your mailing lists. But that's a design problem in these clients, not in the mailing list software. Not that it matters that much to me, since I read practically all mailing lists via gmane.org. That turns the lists into newsgroups, where the reply button (follow-up, more accurately) does send the reply to the newsgroup. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!
spiffo wrote: Ok, I LOVE python, so that is not the issue, but, I am getting very worried about it's growth. I recently re-visted the web looking at alot of projects I assumed would be up and running by now from over a year ago, such as Boa Constructor, Iron Python etc... it seems all these projects get started, but never finished. Also, more and more I need *complete* control of ms sql from my apps, which is simply not available from the adodbapi module I got off the internet... also, ms sql 2005 is getting ready to come out... what if the guy that wrote adodbapi.py does not feel like upgrading it so it even works with MS SQL SERVER 2005? Yeesh... you get the picture... If everything revolves tightly around a microsoft product (ms sql 2005, which isn't even released yet), you probably are boxed in more towards other microsoft products. That's vendor lock-in for you. You might try VS.NET 2005 and see if C# or VB.NET and the ADO.NET api work well for you: http://lab.msdn.microsoft.com/vs2005/ Of course that plus ms sql 2005 will end up costing a great deal of money. Plus none of it is cross-platform, but you already said you do not need that. There are free .NET alternatives like Mono, Sharpdevelop, boo ( http://boo.codehaus.org/ ) and nemerle, but they are not caught up with .NET 2 stuff yet. Again, it hasn't even been released yet, and there are still bugs in their beta versions. So it wouldn't surprise me if the python libraries can't handle ms sql 2005-specific stuff yet either. So, if you need a short answer now, I'd say go with vs.net 2005, but if you can afford to wait a while, free python and .net alternatives will catch up. -- http://mail.python.org/mailman/listinfo/python-list
Python TNEF (winmail.dat attachment access) library?
Hello, has anyone seen such a beast? I tried googling, PyPI, Parnassus etc. but could not find any pure-python code nor extensions to interface with any of the existing implementations. I am thinking about taking the Ruby code I found at http://www.zweknu.org/technical/index.rhtml?s=p%7c15 and converting that to Python. I have no experience with Ruby so this will be rather interesting... I guess another option would be to use CTypes to plug into some tnef shared library/DLL. I'd prefer a pure-python route though... Any pointers/recommendations appreciated. Thanks, Petri -- http://mail.python.org/mailman/listinfo/python-list
Re: morphological image processing in Python
Alexandre Fayolle 寫道: http://www.mmorph.com/resources.html check this page. Pymorph is a free. Hello, I'm about to start a project which will involve some greyscale image processing using morphological operators (erosion, dilation, distance transforms...), and I was wondering if these operators were available in Python through some open source libraries. A quick google search returned pymorphpro[1], which is unfortunately not free software, and there also seem to be something available in ITK [2]. Unless I'm mistaken, the PIL does not provide these operations, nore do Numeric/numarray/scipy. Have I missed the one true Python mathematical morphology toolbox? Thanks in advance for any advice. [1] http://www.mmorph.com/pymorphpro/index.html [2] http://www.itk.org/ -- Alexandre Fayolle LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org -- http://mail.python.org/mailman/listinfo/python-list
Graphical debugger/code explorer
Hello, in order to understand python code from a larger project (Zope 3) I'm looking for a tool that helps me with that. It should also help What (graphical) application running on Linux can you recommend? Thanks, Florian -- http://mail.python.org/mailman/listinfo/python-list
Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!
Perhaps with the time saved by using Python instead of C# or some such, you could help to improve adodbapi.py, ensuring support for the next version of MS SQLServer, although that might be of little help in the short term. Just a thought. Also, have a gander at http://www.object-craft.com.au/projects/mssql/ I have no knowledge of it, but it may prove useful to you. -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
On Mon, 03 Oct 2005 13:58:33 +, Antoon Pardon wrote: Op 2005-10-03, Duncan Booth schreef [EMAIL PROTECTED]: Antoon Pardon wrote: A language where variable have to be declared before use, would allow to give all misspelled (undeclared) variables in on go, instead of just crashing each time one is encounterd. Wrong. It would catch at compile-time those misspellings which do not happen to coincide with another declared variable. Fine, it is still better than python which will crash each time one of these is encountered. Python doesn't crash when it meets an undeclared variable. It raises an exception. This lets you do things like: try: False except NameError: print bools are not defined, making fake bools... False = 0 True = not False def bool(obj): if obj: return True else: return False # not identical to real bools, but close enough to fake it (usually) Moreover, it adds a burden on the programmer who has to write all those declarations, So? He has to write all those lines of code too. People often promote unittesting here. Writing all those unittest is an added burden too. But people think this burden is worth it. Yes, but there is no evidence that pre-declaration of variables is a burden worth carrying. It doesn't catch any errors that your testing wouldn't catch anyway. 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 Speaking as somebody who spent a long time programming in Pascal, I got heartedly sick and tired of having to jump backwards and forwards from where I was coding to the start of the function to define variables. It got to the stage that sometimes I'd pre-define variables I thought I might need, intending to go back afterwards and delete the ones I didn't need. When the programmer is having to to jump through hoops to satisfy the compiler, there is something wrong. and worse it adds a burden on everyone reading the code who has more lines to read before understanding the code. Well maybe we should remove all those comments from code too, because all it does is add more lines for people to read. Well-written comments should give the reader information which is not in the code. If the comment gives you nothing that wasn't obvious from the code, it is pointless and should be removed. Variable declarations give the reader nothing that isn't in the code. If I write x = 15, then both I and the compiler knows that there is a variable called x. It is blindingly obvious. Why do I need to say define x first? Pre-defining x protects me from one class of error, where I typed x instead of (say) n. That's fine as far as it goes, but that's not necessarily an _error_. If the typo causes an error, e.g.: def spam(n): return spam * x # oops, typo then testing will catch it, and many other errors as well. Declaring the variable doesn't get me anything I wouldn't already get. But if it doesn't cause an error, e.g.: def spam(n): if n: return spam * n else: x = 0 # oops, typo return spam * n This may never cause a failure, since n is always an integer. Since my other testing guarantees that n is always an integer, it doesn't matter that I've created a variable x that doesn't get used. Yes, it would be nice for the compiler to flag this, but if the cost of that niceness is to have to define every single variable, I can live without it. Also there is increased overhead when maintaining the code as all those declarations have to be kept in line as the code changes over time. Which is good. Just as you have to keep the unittests in line as code changes over time. That is not the same at all. Changing variable declarations needs to be done every time you modify the internal implementation of a function. Changing the unittests, or any other testing for that matter, only needs to be done when you change the interface. In principle, if you have an interface designed up front before you write any code, you could write all your tests at the start of the project and never change them again. You can't do that with variable declarations, since every time you change the implementation you have to change the declarations. -- Steven. -- 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: Graphical debugger/code explorer
PYTHON_IDE={ 'spe' : 'http://spe.pycs.net/', 'eric3' : 'http://www.die-offenbachs.de/detlev/eric3.html', 'drpython' : 'http://drpython.sourceforge.net/'} :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode charmap decoders slow
In article [EMAIL PROTECTED], Martin v. Löwis [EMAIL PROTECTED] wrote: Tony Nelson wrote: Is there a faster way to decode from charmaps to utf-8 than unicode()? You could try the iconv codec, if your system supports iconv: http://cvs.sourceforge.net/viewcvs.py/python-codecs/practicecodecs/iconv/ I had seen iconv. Even if my system supports it and it is faster than Python's charmap decoder, it might not be available on other systems. Requiring something unusual in order to do a trivial LUT task isn't an acceptable solution. If I write a charmap decoder as an extension module in Pyrex I can include it with the program. I would prefer a solution that doesn't even need that, preferably in pure Python. Since Python does all the hard wark so fast it certainly could do it, and it can almost do it with .translate(). TonyN.:'[EMAIL PROTECTED] ' http://www.georgeanelson.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin wrote: Steven D'Aprano [EMAIL PROTECTED] writes: No, but that is precisely why Python's semi-private variables are usually better. Names like _X and class.__X are warnings to the developer use these at your own risk, without preventing developers who need them from using them. You have most of the benefits of private variables with none of the disadvantages. I'm sorry but I thought the idea was to actually reduce the risk of bugs, not merely attach the risk to the right person. I'm sorry but you're just plain wrong - at least according to Python's we're all consenting adults here philosophy. If changing the way a class uses its own private variables breaks an application because another class was using the private variable unexpectedly, then that's bad, No, it's just an obvious side-effect of the programmer messing with implementation stuff. He knew from the start it was implementation detail, so he accepted that this may change without notice and break its code. period. regardless of whether the other class's author was notified or not. It's better to let the compiler automatically flag these things, than to depend on conventions. Nope. *you* think it's better. Most of us here obviously think that relying on convention is a good (and even better) solution - and the fact is that it works just fine. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
[EMAIL PROTECTED] wrote: 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. Hmm. Presumably introspection via getattr() is way too dangerous, then? Might as well throw the function away ... regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Python profiler
Hello All, I am trying to measure memory used in a Python program. Also, I would like to gather some statistics about object usages. For example, I would like to be able to see how much time it takes to search for an item in a dict object, how many times it has to access the symbol table to retrieve a specific item, and things like that. Furthermore, I would like to be able to see how a symbol table is created, how many items it has, how many times it is accessed during execution, etc. Python profiler gives timing information about functions/methods. For example, it doesn't show how many times a dictionary object is accessed to retrieve a key or how much time it takes. The dis module doesn't provide detailed information either. For the following code, dict = { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5} print dict.has_key('e') The dis module provides the following: 0 LOAD_GLOBAL0 (dict) 3 LOAD_ATTR1 (has_key) 6 LOAD_CONST 1 ('e') 9 CALL_FUNCTION 1 12 PRINT_ITEM But this doesn't really help to see what's going on with the symbol table. Any help is greatly appreaciated. Thanks a lot! Regards, Dave __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
On Mon, 03 Oct 2005 20:30:35 +0400, en.karpachov wrote: 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. No. Some people just don't get it that declarations aren't almost free, because they cost a lot in human labour, and that they give you practically nothing that your unit testing wouldn't give you anyway. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reply-To header
On 10/3/05, Roel Schroeven [EMAIL PROTECTED] wrote: The default of this list is not to make conversations private; in fact the list doesn't have any default. It's you who chooses to send replies to the original author, to the list, or both, by choosing which button to press in your mail client. Interesting: which button do I press to reply only to the list? I'm using Gmail, and it only has 'Reply' and 'Reply to all' as options. One sends a private reply; the other sends 2 replies. I checked all my other mail clients, and they work the same way. Setting the default Reply-To: to the list means that 'Reply' sends just to the list (the desired behavior most of the time), and 'Reply to all' sends 2 copies. I'm on several other lists, some of which default replies to the list, and others which default to the sender. I've *never* seen threads like this on the former, while such threads appear like clockwork on the latter. Draw your own conclusion. Not that it matters that much to me, since I read practically all mailing lists via gmane.org. That turns the lists into newsgroups, where the reply button (follow-up, more accurately) does send the reply to the newsgroup. So the answer is to not use the email interface, since the newsgroup interface actually gets it right! :) -- # p.d. -- 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: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!
On Mon, 03 Oct 2005 09:01:37 -0500, spiffo wrote: The Main Issue in a nutshell I am a corporate developer, working for a single company. Got a new project coming up and wondering if I should stay with Python for this new, fairly large project, are jump back on the 'safe' M$ bandwagon using a dot net language? What makes you think dot net will be any safer than the last half dozen bet the farm technologies Microsoft used? http://lwn.net/Articles/85797/?format=printable (Disclaimer: the author is my boss.) Cross platform is NOT an issue, but COMPLETE control/compatability with MsSql Server (current and future versions) certainly is. How can you have COMPLETE (your emphasis) control over software when you don't have access to the source code? [snip] Ok, I LOVE python, so that is not the issue, but, I am getting very worried about it's growth. I recently re-visted the web looking at alot of projects I assumed would be up and running by now from over a year ago, such as Boa Constructor, Iron Python etc... it seems all these projects get started, but never finished. I'm not sure what you are trying to say here. Why do you care if a lot of projects are not finished? Do you need them? Why waste time worrying about projects that don't interest you? What do you mean by finished? To my mind, a finished project is an obsolete project that nobody is working on any more. Is that a good thing? Is MS SQL finished? Also, more and more I need *complete* control of ms sql from my apps, which is simply not available from the adodbapi module I got off the internet... also, ms sql 2005 is getting ready to come out... what if the guy that wrote adodbapi.py does not feel like upgrading it so it even works with MS SQL SERVER 2005? Yeesh... you get the picture... Then you could offer him some money to support it. Or, if it is Open Source software, you could support it yourself, or hire a consultant to do it. How much is it worth to you? What would it cost you to *not* use Python? If it would cost you $100,000 to develop your app in Python, and $200,000 to develop it in the alternatives, then that gives you a war-chest of $100,000 you can spend. (Disclaimer: the company I work for does that sort of consulting and development work.) How much money will you save by dropping MS SQL licence fees by migrating to MySQL or Postgres? Will that money saved be enough to hire a full-time developer to keep adodbapi updated? -- Steven. -- 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: Where to find python c-sources
[Tor Erik S�nvisen] socketmodule.c, but I can't locate this file... Where should I look? [John, finding 'socketmodule.c' responds well to I'm Feeling Lucky] Does google vary in its results across the globe? [Michael] The search terms might be obvious to you, but it simply means your google-fu is strong, and the strong should help the weak. (or not attack them at least...) You believe that Tor is dumb enough not to think of searching for socketmodule.c when, um, searching for socketmodule.c? John -- http://mail.python.org/mailman/listinfo/python-list
Re: morphological image processing in Python
Take a look at ADaM and it's python wrappers: http://datamining.itsc.uah.edu/adam/documentation.html -- http://mail.python.org/mailman/listinfo/python-list
Re: no variable or argument declarations are necessary.
Steven D'Aprano [EMAIL PROTECTED] wrote [snipped] 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() Actually modern compilers can (http://www.boost.org/libs/mpl/doc/tutorial/dimensional-analysis.html) at the expense of the programmer's eye health... George -- http://mail.python.org/mailman/listinfo/python-list
Re: Where to find python c-sources
John J. Lee wrote: [Tor Erik S�nvisen] socketmodule.c, but I can't locate this file... Where should I look? [John, finding 'socketmodule.c' responds well to I'm Feeling Lucky] Does google vary in its results across the globe? [Michael] The search terms might be obvious to you, but it simply means your google-fu is strong, and the strong should help the weak. (or not attack them at least...) You believe that Tor is dumb enough not to think of searching for socketmodule.c when, um, searching for socketmodule.c? He said he had tried google - OK, not in the first post but early in this thread - I don't equate that with being dumb - just dumb luck :-) Message-ID: [EMAIL PROTECTED] After all Peter Hansen suggested the search terms python socketmodule.c rather than just socketmodule.c Message-ID: [EMAIL PROTECTED] To you the obvious search term was socketmodule.c which to me simply means you're more aligned with Google than Tor :-) These things happen :-) Regards, Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected and public?
Paul Rubin http://[EMAIL PROTECTED] writes: That's not what privilege separation means. It means that the privileged objects stay secure even when the unprivileged part of the program is completely controlled by an attacker. In which case, what's private got to do with this? The examples I've seen of it don't give you privilege seperation any more than python does. If you have a java class instance with a private member that's (say) a network socket to a special port, access to the port is controlled entirely by that class. Are you sure? My understanding was that Java's introspection mechanism could be used to access private variables. A couple of other things to think about: Are you sure you want to use the C++ model for privilege separation? C++'s design doesn't exactly inspire confidence in me. I'd recommend checking languages that were designed to be OO from scratch, rather than as extensions or rewrites of other languages. I'd also check dynamic languages to see if any of them do this - other than PHP, which apparently adopted the C++ model, and is another language I wouldn't trust for inspiration. In static languages, information of this kind is normally attached to variables. In Python, the only thing a variable knows is the object it references. So do you want the privilege information attached to the variable or the object it references? If you attach it to the variable, you're again making what appears to be a fundamental change in Python, and possibly invoking serious implementation headaches. If you attach it to the object, you solve a lot of the problems Pythons reference model creates, but you also leave open the possibility of simple assignment changing an attribute. Finally, another hole to fix/convention to follow to make this work properly in Python. This one is particularly pernicious, as it allows code that doesn't reference your class at all to violate the private variables. Anyone can dynamically add methods to an instance, the class it belongs to, or to a superclass of that class. This means code in one place can add a method to a superclass of your class that clobbers your private variable, which can then be invoked on an instance of your class to surprise you. So you may have to examine code that doesn't reference your class at all to find the statement that is clobbering your private variable. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
RE: Py2Exe + kinterbasdb
[EMAIL PROTECTED] wrote: I compile an application (that working good in native python) to exe with py2exe. In native mode (python.exe ReportApp.py) it is working, the reports are created good. But when I try to create a report from the compiled exe, it is show an error: Traceback (most recent call last): File Report01.pyc, line 164, in OnButton1Button File report_01.pyc, line 12, in OpenDBForReport File report_db.pyc, line 11, in OpenDB File kinterbasdb\__init__.pyc, line 472, in connect File kinterbasdb\__init__.pyc, line 558, in __init__ File kinterbasdb\__init__.pyc, line 367, in _ensureInitialized File kinterbasdb\__init__.pyc, line 315, in init ImportError: No module named typeconv_backcompat Try adding kinterbasdb to the py2exe packages options as shown below: setup( console=[Report01.py], options={py2exe: {packages: [kinterbasdb]}} ) Jimmy -- http://mail.python.org/mailman/listinfo/python-list
python getopt functionality
hi; I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? thanks moe smadi -- http://mail.python.org/mailman/listinfo/python-list
Re: python getopt functionality
M.N.A.Smadi wrote: I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? http://docs.python.org/lib/module-getopt.html http://docs.python.org/lib/module-optparse.html /F -- http://mail.python.org/mailman/listinfo/python-list
Re: python getopt functionality
M.N.A.Smadi wrote: I have a perl script that I need to port to python. The script takes input from the command line. Is there a standard way of processing command line arguments based on the -flag preceeding the argument? Yes. # pydoc getopt Help on module getopt: NAME getopt - Parser for command line options. FILE /usr/lib/python2.4/getopt.py MODULE DOCS http://www.python.org/doc/current/lib/module-getopt.html [ ... snip ... ] Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
Christophe wrote: Michael a écrit : Rocco Moretti wrote: That is, what would happen with the following constructs: A if B else C if D else F A if B if C else D else F The correct answer should be the person who wrote it would get told off for writing code that a person reading would have no idea what the code was doing (without understanding the precedence). Whilst it's good to have clear understandable, well defined rules for these things, that's no excuse for having unreadable code that other people can't read and understand without having to remember obscure rules. Personally, I'd hope that any code-linting tools would flag such expressions as potentially bad because they're not clear. (Whereas bracketed expressions instantly help here). Actually, you don't need to know operator precedence here because the notation isn't ambiguous in those 2 examples. Of course, it takes some time to understand the thing but it has more to do with the excessive amount of logic in one line than with the syntax. I noted that. However it *does* slow people down which increases the chances of misconception (which is why I'd be in favour of bracketing these expressions). Michael. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will python never intend to support private, protected andpublic?
Mike Meyer wrote: Paul Rubin http://[EMAIL PROTECTED] writes: That's not what privilege separation means. It means that the privileged objects stay secure even when the unprivileged part of the program is completely controlled by an attacker. In which case, what's private got to do with this? The examples I've seen of it don't give you privilege seperation any more than python does. If you have a java class instance with a private member that's (say) a network socket to a special port, access to the port is controlled entirely by that class. Are you sure? My understanding was that Java's introspection mechanism could be used to access private variables. Yes, in a Java application with the default security manager it is trivial to access a private variable of another class using introspection. For example: /* HasPrivate.java */ public class HasPrivate { private int myPrivate = 42; } /* HackPrivate.java */ import java.lang.reflect.Field; public class HackPrivate { public static void main(String[] argv) throws Exception { HasPrivate hp = new HasPrivate(); Field notSoPrivate = hp.getClass().getDeclaredField(myPrivate); notSoPrivate.setAccessible(true); System.out.println(myPrivate = + notSoPrivate.getInt(hp)); } } Kent -- http://mail.python.org/mailman/listinfo/python-list