[ANN] pylint 0.24 / logilab-astng 0.22
Hi there! I'm pleased to announce new releases of pylint and its underlying library logilab-astng. See http://www.logilab.org/project/pylint/0.24.0 and http://www.logilab.org/project/logilab-astng/0.22.0 for more info. Those releases include mostly fixes and a few enhancements. Python 2.6 relative / absolute imports should now work fine and Python 3 support has been enhanced. There are still two remaining failures in astng test suite when using python 3, but we're unfortunatly missing resources to fix them yet. Many thanks to everyone who contributed to this release by submitting patches or by participating to the latest bugs day. What is pylint ? Pylint is a python tool that checks if a module satisfy a coding standard. Pylint can be seen as another pychecker since nearly all tests you can do with pychecker can also be done with Pylint. But Pylint offers some more features, like checking line-code's length, checking if variable names are well-formed according to your coding standard, or checking if declared interfaces are truly implemented, and much more (see http://www.logilab.org/projects/pylint/ for the complete check list). The big advantage with Pylint is that it is highly configurable, customizable, and you can easily write a small plugin to add a personal feature. The usage it quite simple : $ pylint mypackage.mymodule This command will output all the errors and warnings related to the tested code (here : mypackage.mymodule), will dump a little summary at the end, and will give a mark to the tested code. Pylint is free software distributed under the GNU Public Licence. Home page - http://www.logilab.org/project/pylint http://www.logilab.org/project/logilab-astng Download http://www.logilab.org/ftp/pub/pylint http://www.logilab.org/ftp/pub/logilab/astng Mailing list python-proje...@logilab.org (moderated) Register, archive on http://lists.logilab.org/mailman/listinfo/python-projects Enjoy! -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework:http://www.cubicweb.org -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: list(), tuple() should not place at Built-in functions in documentation
Terry Reedy, 19.07.2011 18:31: Chapter 5 is mostly about the behavior of built-in class instances. For some classes, like range, instances only come from class calls and the behavior of instances is intimately tied to the constructor arguments. Having the constructor described in C.5 might be useful. I strongly disagree. To me, range() being implemented as a class or function is a clear implementation detail that is of no importance to virtually all use cases. It's only ever used as a function that returns a list (in Py2) or something iterable (in Py3). Whether that iterable is of type range or not is irrelevant. Even in Py2, it could return a subtype of list, and would still fulfil its interface. So, IMO, it makes no sense to have range() described in the builtin types section. It would rather be confusing. It's perfectly correct and sufficient to describe it in the builtin functions section. Remember that Python is duck-typed. It makes no difference if you call a function that returns a new instance of a type, or the type itself to return an instance of itself (or something completely different, if it wants to). The distinction between types and functions is blurred in Python, and that's a good thing. Just look at the itertools module. Some of the functions are implemented as functions, some are implemented as types, and some are functions that delegate to a type. But they all have the same interface, which makes them easy to understand as a whole and which keeps the implementation details out of the way. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 18.07.2011 16:39, Xah Lee wrote: On Jul 17, 12:47 am, Xah Leexah...@gmail.com wrote: 2011-07-16 folks, this one will be interesting one. the problem is to write a script that can check a dir of text files (and all subdirs) and reports if a file has any mismatched matching brackets. … Ok, here's my solution (pasted at bottom). I haven't tried to make it elegant or terse, yet, seeing that many are already much elegent than i could possibly do so with my code. my solution basically use a stack. (i think all of us are doing similar) Here's the steps: • Go thru the file char by char, find a bracket char. • check if the one on stack is a matching opening char. If so remove it. Else, push the current onto the stack. • Repeat the above till end of file. • If the stack is not empty, then the file got mismatched brackets. Report it. • Do the above on all files. Small correction: my solution works differently (although internally the regexp engine will roughly do the same). So, my approach summarized - traverse a directory tree - for each found item of type file -read the whole content -throw it at a regexp which is anchored at the beginning and does the recursive parsing -report file if the match is shorter than the file Note: special feature for recursive matching is used which Perl's regexp engine likely can do as well but many others don't. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 19 juil, 21:09, Terry Reedy tjre...@udel.edu wrote: On 7/19/2011 2:12 PM, Xah Lee wrote: Also, you may have answered this earlier but I'll ask again anyways: You ask for the first mismatched pair, Are you referring to the inner most mismatched, or the outermost? For example, suppose you have this file: foo[(])bar Would the ( be the first mismatched character or would the ]? yes i haven't been precise. Thanks for brining it up. thinking about it now, i think it's a bit hard to define precisely. Then it is hard to code precisely. Not really. The trick is to count the different opener/closer separately. That is what I am doing to check balanced brackets in chemical formulas. The rules are howerver not the same as in math. Interestingly, I fall on this problem. enumerate() is very nice to parse a string from left to right. for i, c in enumerate('abcd'): ... print i, c ... 0 a 1 b 2 c 3 d But, if I want to parse a string from right to left, what's the trick? The best I found so far: s = 'abcd' for i, c in enumerate(reversed(s)): ... print len(s) - 1 - i, c ... 3 d 2 c 1 b 0 a -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Jul 17, 8:47 am, Xah Lee xah...@gmail.com wrote: 2011-07-16 folks, this one will be interesting one. the problem is to write a script that can check a dir of text files (and all subdirs) and reports if a file has any mismatched matching brackets. • The files will be utf-8 encoded (unix style line ending). • If a file has mismatched matching-pairs, the script will display the file name, and the line number and column number of the first instance where a mismatched bracket occures. (or, just the char number instead (as in emacs's “point”)) • the matching pairs are all single unicode chars. They are these and nothing else: () {} [] “” ‹› «» 【】 〈〉 《》 「」 『』 Note that ‘single curly quote’ is not consider matching pair here. • You script must be standalone. Must not be using some parser tools. But can call lib that's part of standard distribution in your lang. Here's a example of mismatched bracket: ([)], (“[[”), ((, 】etc. (and yes, the brackets may be nested. There are usually text between these chars.) I'll be writing a emacs lisp solution and post in 2 days. Ι welcome other lang implementations. In particular, perl, python, php, ruby, tcl, lua, Haskell, Ocaml. I'll also be able to eval common lisp (clisp) and Scheme lisp (scsh), Java. Other lang such as Clojure, Scala, C, C++, or any others, are all welcome, but i won't be able to eval it. javascript implementation will be very interesting too, but please indicate which and where to install the command line version. I hope you'll find this a interesting “challenge”. This is a parsing problem. I haven't studied parsers except some Wikipedia reading, so my solution will probably be naive. I hope to see and learn from your solution too. i hope you'll participate. Just post solution here. Thanks. Xah Parsing technology based on BNF enables an elegant solution. First take a basic bracket balancing program which parenthesises the contents of the input. e.g. in Shen-YACC (defcc br ( br ) br$ := [br | br$]; item br; e := [];) (defcc br$ br;) (defcc item -*- := (if (element? -*- [( )]) (fail) [-*-]);) Given (compile br [( 1 2 3 ) 4]) the program produces [[1 2 3] 4]. When this program is used to parse the input, whatever residue is left indicates where the parse has failed. In Shen-YACC (define tellme Stuff - (let Br (br (@p Stuff [])) Residue (fst Br) (if (empty? Residue) (snd Br) (error parse failure at position ~A~% (- (length Stuff) (length Residue)) e.g. (tellme [( 1 2 3 ) ( 4]) parse failure at position 5 (tellme [( 1 2 3 ) ( ) 4]) [[1 2 3] [] 4] The extension of this program to the case described is fairly simple. Qi-YACC is very similar. Nice problem. I do not have further time to correspond right now. Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way with more than one max possible
On Tue, Jul 19, 2011 at 10:10 PM, CM cmpyt...@gmail.com wrote: On Jul 19, 11:17 pm, CM cmpyt...@gmail.com wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything. I want to configure something else based on the winner of such a dict, with these rules: snip I realize, now though, (and Chris asked about this) that I was imprecise in my rules. They really should be stated as: 1. In this dict, if there is a UNIQUE max value, then its *key* is the winner. 2. If there are any TIES for max value, then the *key* 'b' is the winner by default. The point is, I am trying to determine the name of the winning category, either 'a', 'b', or 'c', not the value of its winning score. So in your solutions there is sorting by values, which makes sense. But how can I go back to keys from there? Sorry for the mistake (but even so, I learned something already). # still presumes at least 2 items from heapq import nlargest winner, runner_up = nlargest(2, the_dict, lambda k: the_dict[k]) if the_dict[winner] == the_dict[runner_up]: winner = 'b' Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Tue, Jul 19, 2011 at 8:12 PM, sturlamolden sturlamol...@yahoo.no wrote: 3. Unpythonic memory management: Python references to deleted C++ objects (PyQt). Manual dialog destruction (wxPython). Parent-child ownership might be smart in C++, but in Python we have a garbage collector. Perhaps you already know this, but recent versions of wxPython allow dialogs to be used as context managers, which destroys them when the with block is exited. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
Steven D'Aprano, 20.07.2011 06:28: Python has a GIL. Except for Jython, IronPython and PyPy. PyPy has a GIL, too. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Wed, Jul 20, 2011 at 12:29 AM, jmfauth wxjmfa...@gmail.com wrote: Then it is hard to code precisely. Not really. The trick is to count the different opener/closer separately. That is what I am doing to check balanced brackets in chemical formulas. The rules are howerver not the same as in math. I think the difficulty is not in the algorithm, but in adhering to the desired output when it is ambiguously described. But, if I want to parse a string from right to left, what's the trick? The best I found so far: s = 'abcd' for i, c in enumerate(reversed(s)): ... print len(s) - 1 - i, c That violates DRY, since you have reversal logic in the iterator algebra and then again in the loop body. I prefer to keep all such logic in the iterator algebra, if possible. This is one possibility, if you don't mind it building an intermediate list: for i, c in reversed(list(enumerate(s))): ... Otherwise, here's another non-DRY solution: from itertools import izip for i, c in izip(reversed(xrange(len(s))), reversed(s)): ... Unfortunately, this is one space where there just doesn't seem to be a single obvious way to do it. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Wed, 20 Jul 2011 05:20 pm Stefan Behnel wrote: Steven D'Aprano, 20.07.2011 06:28: Python has a GIL. Except for Jython, IronPython and PyPy. PyPy has a GIL, too. Isn't it optional though? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: (Maybe off topic) Can someone explain what a finite state machine is?
On Tue, 19 Jul 2011 11:32 pm Matty Sarro wrote: Hey everyone. I am currently reading through an RFC, and it mentions that a client and server half of a transaction are embodied by finite state machines. I am reading through the wikipedia article for finite state machines, and sadly it's going a bit above my head. I don't really have a background in engineering, and would really love to understand what is being said. Does anyone have a simple way to explain it? Consider a heater with a thermostat. That's a finite state machine. It's a machine, it has a finite number of states, namely, the combinations of these: on or off too warm, too cold or in-between The machine has transitions between states: if too warm, then turn off if too cold, then turn on if in-between, then don't change Here's one way to simulate such a simple FSM in Python: import time class Heater: low = 0 high = 10 def __init__(self, starting_temperature=7): self.temp = starting_temperature self.state = off def run(self): while True: if self.state == on: # Heating. self.temp += 1 if self.state == off: # Slowly cooling. self.temp -= 1 if self.temp self.low: print(turning on) self.state = on if self.temp self.high: print(turning off) self.state = off time.sleep(1) heater = Heater() heater.run() turning on turning off turning on turning off Traceback (most recent call last): File stdin, line 1, in module File stdin, line 9, in run KeyboardInterrupt More complex finite state machines can have many different states, and much more complicated behaviour. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 On 2011.07.20 02:28 AM, Steven D'Aprano wrote: Isn't it optional though? No. http://doc.pypy.org/en/latest/faq.html#does-pypy-have-a-gil-why - -- CPython 3.2.1 | Windows NT 6.1.7601.17592 | Thunderbird 5.0 PGP/GPG Public Key ID: 0xF88E034060A78FCB -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAwAGBQJOJojrAAoJEPiOA0Bgp4/LXdgH/RJefVrvsawewQsxMex9NlMl IRS6lMjVMFgsXHh2V2F+DfQ0bZ9904dgsgyU3zHkfevI3Stctrr8qainxlmUxj3q EFTzzQLUurY+tyR1sz5y9MtxWbjvOIQrZ8VN0aj/1ks+TU7fq+2d+sa+KFgMhP+k F2TQeZhDBYhm+NE7h7MHsYhnRHtA5nWW2UByFXu/gcdrk9rB+3nqHuxj4ROh7Ots vHbS9W/BsDver0e2Z9w4TxZ5Jb9cAjdkAqcK4Tqth0WMhvnIpnRGxM8npwD/xsKs 9jVkZhdG1BSvXdRUqLYTucA0lfTqNMh1CZtWzvOQIBqH1cdqKP+S7zdOloyti5Y= =H+A1 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Geodetic functions library GeoDLL 32 Bit and 64 Bit
Hi developers, who develops programs with geodetic functionality like world-wide coordinate transformations or distance calculations, can work with the latest version of my GeoDLL. The Dynamic Link Library can easily be used with any programming language to add geodetic functionality to own applications. GeoDLL supports 2D and 3D coordinate transformation, geodetic datum shift and reference system convertion, meridian strip changing, user defined coordinate and reference systems, distance calculation, Digital Elevation Model, NTv2 handling, Direct / Inverse Solutions and a lot of other geodetic functions. The DLL has become very fast and save by forceful development in C++ with Microsoft Visual Studio 2010. The geodetic functions of the new version 12.05 now are available in 32bit and 64bit architecture. You find a downloadable test version on http://www.killetsoft.de/p_gdla_e.htm. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On 20 juil, 09:29, Ian Kelly ian.g.ke...@gmail.com wrote: Otherwise, here's another non-DRY solution: from itertools import izip for i, c in izip(reversed(xrange(len(s))), reversed(s)): ... Unfortunately, this is one space where there just doesn't seem to be a single obvious way to do it. Well, I see. Thanks. There is still the old, brave solution, I'm in fact using. s = 'abcd' for i in xrange(len(s)-1, -1, -1): ... print i, s[i] ... 3 d 2 c 1 b 0 a --- DRY? acronym for ? -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Wed, 20 Jul 2011 05:54 pm jmfauth wrote: DRY? acronym for ? I'd like to tell you, but I already told somebody else... *grins* http://en.wikipedia.org/wiki/Don't_repeat_yourself http://c2.com/cgi/wiki?DontRepeatYourself -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Wed, 20 Jul 2011 05:51 pm Andrew Berg wrote: -BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 On 2011.07.20 02:28 AM, Steven D'Aprano wrote: Isn't it optional though? No. http://doc.pypy.org/en/latest/faq.html#does-pypy-have-a-gil-why Ah, my mistake, thank you. I knew PyPy had multiple garbage collectors, and confabulated that it didn't have a GIL. So, that's two GILs, two without for the Big Four. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: The following modules appear to be missing - py2exe
hello, thanks for your answer. From the stuff below, you appear to be compiling for Windows. yes The following modules appear to be missing ['Carbon', 'Carbon.Files', This is Mac gui stuff which you neither need nor want in a Windows binary. I suspect mis-specification somewhere. ok so this is not necessary. '_scproxy', 'fixedpoint', 'gdk', 'mx', 'unix', 'glib. compiling with gcc? You appear to be missing its glib. I compile with py2exe and have no idea how to retrieve missing libs. I tried to ask at http://sourceforge.net/mailarchive/forum.php?thread_name=CABFuWSwv76-Hz-fNrqN_2__%2Bb7ZpPuBb%3DT%2B-i0-MF%2BJvjj8Fqg%40mail.gmail.comforum_name=py2exe-users as well and Dieter responded it is py2exe troubles with gdk and glib packages. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20/07/11 04:12, sturlamolden wrote: 3. Unpythonic memory management: Python references to deleted C++ objects (PyQt). Manual dialog destruction (wxPython). Parent-child ownership might be smart in C++, but in Python we have a garbage collector. I wonder - what do you think of GTK+? I've only used Qt with C++, and I've always been highly suspicious of wx (something about the API, or the documentation… I haven't had a look at it in a long time), but I always found PyGTK quite nice. 4. They might look bad (Tkinter, Swing with Jython). Oh well. Really, while Swing and Tkinter are particularly bad as they draw their own widgets (instead of using a native toolkit), if you want your GUI to look good, you'll need to write a separate GUI for each platform that follows each platform's UI conventions. 5. All projects to write a Python GUI toolkit die before they are finished. (General lack of interest, bindings for Qt or wxWidgets bloatware are mature, momentum for web development etc.) Aye, existing GUI toolkits are mature. They work. They do the job. 5. No particular GUI thread synchronization is needed -- Python has a GIL. That's where you're wrong: the GIL is not a feature of Python. It is an unfortunate implementation detail of current versions of CPython. (and PyPy, apparently) 6. Expose the event loop to Python. You can tap into the Gtk/GLib event loop. Don't other toolkits allow you to write your own loop, using some kind of process_events() function to take care of the GUI? 7. Preferably BSD-style license, not even LGPL. Umm? 8. Written for Python in Python -- not bindings for a C++ or tcl toolkit. HOLD ON a second: 4. They might look bad (Tkinter, Swing with Jython). [...] , if based on native widgets: What do you propose? We know what happens when you write a fresh GUI toolkit: Swing and Tkinter show us. The only reasonable option to create a toolkit that actually looks good is to base it on the usual GUI libraries. The Eclipse SWT library does some of this for Java does some of this, though it also has flaws (e.g. manual memory management). A Python GUI toolkit could be partially based on the SWT code. Okay, I haven't used SWT yet: manual memory management? Java is GC! It is perfectly reasonable to be required to manually call some sort of destroy() method to tell the toolkit what you no longer want the user to see: firstly, you have the display a reference to your window, in a manner of speaking, by showing it. Secondly, in a GC environment like a JVM or the CLI, it could take a moment. Was that what you meant? Is it worth the hassle to start a new GUI toolkit project? No. Or should modern deskop apps be written with something completely different, such as HTML5? NO!! Don't be silly. Even using a crappy windowing toolkit is a lot simpler than doing the HTML/JavaScript/HTTP/etc dance. -- http://mail.python.org/mailman/listinfo/python-list
total_ordering behaviour
Hello all, I've noticed some strange behaviour of functools.total_ordering decorator, at least it seems strange to me. Let's consider code snippet below import functools @functools.total_ordering class MyComparableType(object): def __init__(self, value, ref): self.value = value self.ref = ref def __eq__(self, other): # compare two MyComparableType objects or MyComparableType object and some number if type(other) == MyComparableType: return self.value == other.value return self.value == other def __gt__(self, other): # compare two MyComparableType objects or MyComparableType object and some number if type(other) == MyComparableType: return self.value other.value return self.value other foo = MyComparableType(10, None) bar = MyComparableType(20, foo) print foo bar # works ok, True print foo bar # works ok, False print foo 5 # works ok, True print foo 8 # error! we jump into infinite recursion and eventually get stack overflow error It works fine in most cases but crashes when I try to check foo 8. As I understand the reason why this happens is because of this code in functools.py, total_ordering decorator, which adds missing comparisons definitions .. '__gt__': [('__lt__', lambda self, other: other self), ('__ge__', lambda self, other: not other self), ('__le__', lambda self, other: not self other)], ... and python coercion rules say: For objects x and y, first x.__op__(y) is tried. If this is not implemented or returns NotImplemented, y.__rop__(x) is tried. If this is also not implemented or returns NotImplemented, a TypeError exception is raised. But see the following exception: Exception to the previous item: if the left operand is an instance of a built-in type or a new-style class, and the right operand is an instance of a proper subclass of that type or class and overrides the base’s __rop__() method, the right operand’s __rop__() method is tried before the left operand’s __op__() method. So it behaves like it should according to this rule and produces stack overflow because of the infinite recursion calls in the last comparison (foo 8). There is a way to fix this by replacing missing comparisons definitions in total_ordering to be like this: '__gt__': [('__lt__', lambda self, other: not self other and not self == other), ('__ge__', lambda self, other: self other or self == other ), ('__le__', lambda self, other: not self other)], then script above will work perfectly well in all the cases and there is just one more check added in two of three definitions. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
i've just cleaned up my elisp code and wrote a short elisp tutorial. Here: 〈Emacs Lisp: Batch Script to Validate Matching Brackets〉 http://xahlee.org/emacs/elisp_validate_matching_brackets.html plain text version follows. Please let me know what you think. am still working on going thru all code in other langs. Will get to the ruby one, and that perl regex, and the other fixed python ones. (possibly also the 2 common lisp codes but am not sure they are runnable as is or just some non-working showoff. lol) === Emacs Lisp: Batch Script to Validate Matching Brackets Xah Lee, 2011-07-19 This page shows you how to write a elisp script that checks thousands of files for mismatched brackets. The Problem Summary I have 5 thousands files containing many matching pairs. I want to to know if any of them contains mismatched brackets. Detail The matching pairs includes these: () {} [] “” ‹› «» 〈〉 《》 【】 〖〗 「」 『』. The program should be able to check all files in a dir, and report any file that has mismatched bracket, and also indicate the line number or positon where a mismatch occurs. For those curious, if you want to know what these brackets are, see: • Syntax Design: Use of Unicode Matching Brackets as Specialized Delimiters • Intro to Chinese Punctuation with Computer Language Syntax Perspectives For other notes and conveniences about dealing with brackets in emacs, see: • Emacs: Defining Keys to Navigate Brackets • “extend-selection” at A Text Editor Feature: Extend Selection by Semantic Unit • “select-text-in-quote” at Suggestions on Emacs's mark-word Command Solution Here's outline of steps. • Go thru the file char by char, find a bracket char. • Check if the one on stack is a matching opening char. If so remove it. Else, push the current onto the stack. • Repeat the above till no more bracket char in the file. • If the stack is not empty, then the file got mismatched brackets. Report it. • Do the above on all files. Here's some interesting use of lisp features to implement the above. Define Matching Pair Chars as “alist” We begin by defining the chars we want to check, as a “association list” (aka “alist”). Like this: (setq matchPairs '( (( . )) ({ . }) ([ . ]) (“ . ”) (‹ . ›) (« . ») (【 . 】) (〖 . 〗) (〈 . 〉) (《 . 》) (「 . 」) (『 . 』) ) ) If you care only to check for curly quotes, you can remove elements above. This is convenient because some files necessarily have mismatched pairs such as the parenthesis, because that char is used for many non-bracketing purposes (e.g. ASCII smiley). A “alist” in lisp is basically a list of pairs (called key and value), with the ability to search for a key or a value. The first element of a pair is called its key, the second element is its value. Each pair is a “cons”, like this: (cons mykey myvalue), which can also be written using this syntax: (mykey . myvalue) for more easy reading. The purpose of lisp's “alist” is similar to Python's dictionary or Pretty Home Page's array. It is also similar to hashmap, except that alist can have duplicate keys, can search by values, maintains order, and alist is not intended for massive number of elements. Elisp has a hashmap datatype if you need that. (See: Emacs Lisp Tutorial: Hash Table.) (info (elisp) Association Lists) Generate Regex String from alist To search for a set of chars in emacs, we can read the buffer char-by- char, or, we can simply use “search-forward-regexp”. To use that, first we need to generate a regex string from our matchPairs alist. First, we defines/declare the string. Not a necessary step, but we do it for clarity. (setq searchRegex ) Then we go thru the matchPairs alist. For each pair, we use “car” and “cdr” to get the chars and “concat” it to the string. Like this: (mapc (lambda (mypair) (setq searchRegex (concat searchRegex (regexp-quote (car mypair)) | (regexp-quote (cdr mypair)) |) ) ) matchPairs) Then we remove the ending “|”. (setq searchRegex (substring searchRegex 0 -1)) ; remove the ending “|” Then, change | it to \\|. In elisp regex, the | is literal. The “regex or” is \|. And if you are using regex in elisp, elisp does not have a special regex string syntax, it only understands normal strings. So, to feed to regex \|, you need to espace the first backslash. So, your regex needs to have \\|. Here's how we do
Re: Pythonic way with more than one max possible
On 20/07/11 06:19, Steven D'Aprano wrote: On Wed, 20 Jul 2011 01:17 pm CM wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything. I want to configure something else based on the winner of such a dict, with these rules: 1. In this dict, if there is a UNIQUE max value, that's the winner. 2. If there are any TIES for max value, b is the winner by default. The problem for me, as I see it, is I don't know any elegant ways to do this in Python. The max(dict) function doesn't distinguish between unique and non-unique maxes. I could go through and test the various possibilities (to see if the max value had any matches in the other values), but, knowing Python, there is probably something close to one way to do it. Any suggestions? # Untested. def get_winner(adict): values = sorted(adict.values(), reverse=True) if values[0] == values[1]: return adict['b'] else: return values[0] # Untested, with keys: def get_winner(adict): values = sorted(adict.items(), reverse=True, key=(lambda k_v: k_v[1])) if values[0][1] == values[1][1]: return 'b' else: return values[0][0] Assumes that adict has at least two items. May be slow if it has millions of items. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Tue, 2011-07-19 at 19:12 -0700, sturlamolden wrote: What is wrong with them 1. Designed for other languages, particularly C++, tcl and Java. 2. Bloatware. Qt and wxWidgets are C++ application frameworks. (Python has a standard library!) I've no idea what this means. I happily use pygtk. As for application frameworks maybe you are referring to their having their own event-loop, etc... They don't have any choice. A UI toolkit has to have an event-loop and related pluming. Gtk builds on top of glib; which has its own event-loop etc... This makes perfect sense to me. 3. Unpythonic memory management: Python references to deleted C++ objects (PyQt). Manual dialog destruction (wxPython). Parent-child ownership might be smart in C++, but in Python we have a garbage collector. Widget registration / hierarchy != memory management. 4. They might look bad (Tkinter, Swing with Jython). Sorry, I think Gtk apps are very nice looking. 5. All projects to write a Python GUI toolkit die before they are finished. (General lack of interest, bindings for Qt or wxWidgets bloatware are mature, momentum for web development etc.) PyGTK just released version 3 with GObject introspection. etk.docking went beta a few months ago [a pygtk docking solution]. All seems pretty alive to me. And the developers respond to questions. How I would prefer the GUI library to be, if based on native widgets 1. Lean and mean -- do nothing but GUI. No database API, networking API, threading API, etc. Sounds like PyGtk to me. All that other stuff and you are on your own. Although I'd like to have data-model binding. 2. Do as much processing in Python as possible. No more native code (C, C++, Cython) than needed. Unreasonable. 3. Instances of extension types can clean themselves up on deallocation. No parent-child ownership model to mess things up. No manual clean-up. Python does all the reference counting we need. NEVER GOING TO HAPPEN. UI's don't work that way. They are inherently hierarchical. Just get over it. 4. No artist framework. Use OpenGL, Cairo, AGG or whatever else is suitable Gtk supports multiple canvas modes. 5. No particular GUI thread synchronization is needed -- Python has a GIL. Wrong. 6. Expose the event loop to Python. It is. 8. Written for Python in Python -- not bindings for a C++ or tcl toolkit. Why. Pointless. That is just re-implementation. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 07/19/2011 09:12 PM, sturlamolden wrote: How I would prefer the GUI library to be, if based on native widgets: http://xkcd.com/927/ :-) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Wed, 2011-07-20 at 11:59 +0200, Thomas Jollans wrote: On 20/07/11 04:12, sturlamolden wrote: 5. No particular GUI thread synchronization is needed -- Python has a GIL. That's where you're wrong: the GIL is not a feature of Python. It is an unfortunate implementation detail of current versions of CPython. (and PyPy, apparently) And this GIL is certainly *not* a synchronization solution. Even with a GIL you can hang yourself with threads - I've verified this. :) 6. Expose the event loop to Python. You can tap into the Gtk/GLib event loop. +1 What do you propose? We know what happens when you write a fresh GUI toolkit: Swing and Tkinter show us. The only reasonable option to create a toolkit that actually looks good is to base it on the usual GUI libraries. +1 It is perfectly reasonable to be required to manually call some sort of Is it worth the hassle to start a new GUI toolkit project? No. +1, or -1, errr.. which ever one means I agree with no. Or should modern deskop apps be written with something completely different, such as HTML5 NO!! Barf. Of course, Gtk [at least experimentally] supports an HTML5 canvas. A good UI library provides a lot beyond painting-the-screen (there are events, and packing/geometry, etc...). So even if you use HTML5 you are then going to lay something on top of that [JavaScript + JQuery...]. Don't be silly. Even using a crappy windowing toolkit is a lot simpler than doing the HTML/JavaScript/HTTP/etc dance. +1 -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
sturlamolden, 20.07.2011 04:12: Or should modern deskop apps be written with something completely different, such as HTML5? Depends. For many desktop apps, this is actually quite workable, with the additional advantage of having an Internet-/Intranet-ready implementation available in case you happen to need it later on. Plus, you can take advantage of any HTML designers (as in humans) you happen to have around, whereas you are often a bit on your own when you design a GUI using a toolkit, especially when you want it to work well in a cross-platform way. Stefan -- http://mail.python.org/mailman/listinfo/python-list
sphinx
Hi guys! I'm trying to create method to perform query at sphinx index, can anyone does something like this before? I appreciate ! Ageu -- * A Vida é arte do Saber...Quem quiser saber tem que Estudar!* http://bucolick.tumblr.com http://artecultural.wordpress.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
Thomas Jollans t...@jollybox.de writes: On 20/07/11 04:12, sturlamolden wrote: 3. Unpythonic memory management: Python references to deleted C++ objects (PyQt). Manual dialog destruction (wxPython). Parent-child ownership might be smart in C++, but in Python we have a garbage collector. I wonder - what do you think of GTK+? I've only used Qt with C++, and I've always been highly suspicious of wx (something about the API, or the documentation… I haven't had a look at it in a long time), but I always found PyGTK quite nice. GTK+ doesn't work well at all on Mac, so if cross-platform includes Macs, it's not a contender. To quote the gtk-osx.sourceforge.net page: Developers considering GTK+ as a cross-platform environment for new work are advised to evaluate other toolkits carefully before committing to GTK if they consider OSX an important market. From experience, GTK apps are pretty awful on OSX. -Johann -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Jul 19, 9:12 pm, sturlamolden sturlamol...@yahoo.no wrote: What is wrong with them: 1. Designed for other languages, particularly C++, tcl and Java. This fact bugs me but no one is willing to put forth an effort to make things happen. So we are stuck with what we have now. 3. Unpythonic memory management: Python references to deleted C++ objects (PyQt). Manual dialog destruction (wxPython). Users should NEVER need to explicitly destroy a dialog. However it would (should) be easy to subclass the wxDialg and create your own logic tied to the ok and cancel buttons. See tkSimpleDialog for old inspiration or see my threads on tkSimpleDialog improved for modern inspiration. Parent-child ownership might be smart in C++, but in Python we have a garbage collector. There is nothing wrong with hierarchy. Please show examples where this relationship fails. 5. All projects to write a Python GUI toolkit die before they are finished. (General lack of interest, bindings for Qt or wxWidgets bloatware are mature, momentum for web development etc.) Well you've got to get some like minds together. I would be willing to participate on something more Pythonic. PyGUI looks promising. How I would prefer the GUI library to be, if based on native widgets: 1. Lean and mean -- do nothing but GUI. No database API, networking API, threading API, etc. PyGUI 2. Do as much processing in Python as possible. No more native code (C, C++, Cython) than needed. Some heavy lifting must be done in these languages. 3. Instances of extension types can clean themselves up on deallocation. No parent-child ownership model to mess things up. I don't see how that messes things up? 4. No artist framework. Use OpenGL, Cairo, AGG or whatever else is suitable. Hopefully you want a canvas at least. I don't think i could get by without one. Not only is a canvas good for drawing graphics via user input but also for creating custom widgets that the GUI does not expose. 6. Expose the event loop to Python. This would be nice. 8. Written for Python in Python -- not bindings for a C++ or tcl toolkit. Agreed! Wx is nice but feels too much like writing C. Is it worth the hassle to start a new GUI toolkit project? It's a huge hassle and might be much better to grow/repair some existing API's. PyGUI is one however it's very young. Tkinter could use some re-factoring however it will always be based on an embedded TCL interpreter doing magic behind the scenes. Or should modern deskop apps be written with something completely different, such as HTML5? F___ NO! That sort of thing needs many more years to mature. Currently we are in the beginning phases when everybody has their idea of what is perfect and nobody agrees on which is best. Plus you have many incompatibilities between the major browsers. People like to parrot off about how cross-platform these things are compared to GUI; and that's true only for the same version of the same browser. You just switch from OS incompatibility to browser incompatibility. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Jul 19, 9:44 pm, Kevin Walzer k...@codebykevin.com wrote: 2. Bloatware. Qt and wxWidgets are C++ application frameworks. (Python has a standard library!) Again, so? This isn't applicable to Tk, by the way. It's a GUI toolkit specifically designed for scripting languages. Tk is SPECIFICALLY designed for TCL. Tkinter works ONLY by embedding a TCL interpreter. You statements are misleading. 3. Unpythonic memory management: Python references to deleted C++ objects (PyQt). Manual dialog destruction (wxPython). Parent-child ownership might be smart in C++, but in Python we have a garbage collector. Again, so? Again, this isn't applicable to Tk. He did not even mention Tk in that block, do you have a TK persecution complex? 4. They might look bad (Tkinter, Swing with Jython). Then again, they might not. A lot depends on the skill of the developer. I write highly polished commercial apps with Tk GUI's. I'm sick of developers blaming their ugly apps on the toolkit rather than their own lack of design training and/or skills. This is true. Lots of people lack the skill to create professional quality GUI applications however lots of GUI devs lack the skill to create clean and intuitive API's also. Tkinter/TclTk and WxPython \WxWidgets has lots of warts in this respect. 5. All projects to write a Python GUI toolkit die before they are finished. (General lack of interest, bindings for Qt or wxWidgets bloatware are mature, momentum for web development etc.) That's right. People issue a clarion call for a new GUI toolkit, then discover that even a so-called ugly, limited, minimalist toolkit like Tk has twenty years of development behind it. And people think they can duplicate this effort in a few months by starting a flame war on comp.lang.python? Just because someone wants to entertain ideas for a new GUI does mean they are starting flame wars. I would say out all the responses so far YOURS is the most emotional. 1. Lean and mean -- do nothing but GUI. No database API, networking API, threading API, etc. Presenting...Tk. True Tkinter does no Database, networking, threading, etc. However i would not call an embedded TCl interpreter lean and mean. 2. Do as much processing in Python as possible. No more native code (C, C++, Cython) than needed. And what's wrong with native (ie. compiled) code? Python is written in native code, isn't it? To extend Python in significant ways, it is often necessary to drop down into native code. I will agree with Kevin here. Hey, he's not ALWAYS wrong you know; just most of the time! ;-) 6. Expose the event loop to Python. Presenting...Tk. Tk's event binding (whist quite powerful) is also quite overwhelming in the sheer number of event sequences alone and leads to spaghetti code. See my recent thread about the subject. 8. Written for Python in Python -- not bindings for a C++ or tcl toolkit. Well, that's the holy grail, but given the history of other toolkits, you'll reach a comparable level of maturity in 2031. I think it could happen much sooner if people got serious. However it won't happen tomorrow for sure. Is it worth the hassle to start a new GUI toolkit project? Not unless you want to reinvent the wheel yet again. The old reinvent the wheel argument is only valid when wheels already exists. Currently we have triangles (or maybe pentagons) but no wheels. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 11:59, Thomas Jollans t...@jollybox.de wrote: I wonder - what do you think of GTK+? PyGTK with GLADE is the easier to use, but a bit awkward looking on Windows and Mac. (Not to mention the number of dependencies that must be installed, inclusing a GTK runtime.) Really, while Swing and Tkinter are particularly bad as they draw their own widgets GTK and Qt do that as well. The Eclipse SWT library does some of this for Java does some of this, though it also has flaws (e.g. manual memory management). A Python GUI toolkit could be partially based on the SWT code. Okay, I haven't used SWT yet: manual memory management? Java is GC! So is Python, yet wxPython require manual destruction of dialogs as well. It is perfectly reasonable to be required to manually call some sort of destroy() method to tell the toolkit what you no longer want the user to see Yes, but not to avoid a memory leak. Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 2011-07-20, Thomas Jollans t...@jollybox.de wrote: 5. No particular GUI thread synchronization is needed -- Python has a GIL. That's where you're wrong: the GIL is not a feature of Python. It is an unfortunate implementation detail of current versions of CPython. (and PyPy, apparently) And there are always people trying to figure out how to get rid of it. So far the cures have been worse than the disease, but that may not always be the case... -- Grant Edwards grant.b.edwardsYow! ... the HIGHWAY is at made out of LIME JELLO and gmail.commy HONDA is a barbequeued OYSTER! Yum! -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 2011-07-20, Adam Tauno Williams awill...@whitemice.org wrote: On Tue, 2011-07-19 at 19:12 -0700, sturlamolden wrote: What is wrong with them 1. Designed for other languages, particularly C++, tcl and Java. 2. Bloatware. Qt and wxWidgets are C++ application frameworks. (Python has a standard library!) I've no idea what this means. I happily use pygtk. I agree. PyGTK works great -- on platforms where GTK works great. -- Grant Edwards grant.b.edwardsYow! !! I am having fun!!! at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
sturlamolden wrote: On 20 Jul, 11:59, Thomas Jollans t...@jollybox.de wrote: It is perfectly reasonable to be required to manually call some sort of destroy() method to tell the toolkit what you no longer want the user to see Yes, but not to avoid a memory leak. OTOH, if you intend to re-use the Dialog object, it's not a memory leak. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 11:59, Thomas Jollans t...@jollybox.de wrote: Okay, I haven't used SWT yet: manual memory management? Java is GC! It is perfectly reasonable to be required to manually call some sort of destroy() method to tell the toolkit what you no longer want the user to see: firstly, you have the display a reference to your window, in a manner of speaking, by showing it. Secondly, in a GC environment like a JVM or the CLI, it could take a moment. Was that what you meant? A .hide() method is warranted, but not a .destory() method to deallocate C resources. Python calls tp_dealloc when needed. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 16:17, Mel mwil...@the-wire.com wrote: OTOH, if you intend to re-use the Dialog object, it's not a memory leak. It cannot be reused if you don't have any references pointing to it. Sure it is nice to have dialogs that can be hidden and re-displayed, but only those that can be accessed again. tp_dealloc should free any C resources the object is holding. There is no need to save anything beyond the call to tp_dealloc. Before the call to tp_dealloc any C resources should be kept, for the reason you mentioned. That is why the parent-child method of clean-up is at odds with the Python garbage collection. Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 13:04, Adam Tauno Williams awill...@whitemice.org wrote: 3. Instances of extension types can clean themselves up on deallocation. No parent-child ownership model to mess things up. No manual clean-up. Python does all the reference counting we need. NEVER GOING TO HAPPEN. UI's don't work that way. They are inherently hierarchical. Just get over it. Swing relies on the Java GC. Tkinter also does this correct. A hierarchy is nice for event processing an layout management, but not for memory mangement. C resources should be freed by Python calling tp_dealloc, not by the parent calling a .destroy() method on it's children. Python is not C++, so we have a method to automatically reclaim C resources. I don't want a toolkit to deallocate objects while Python still holds references to them (PyQt) or require a manual call to deallocate a widget tree (wxPython). Python knows when it's time to deallocate C resources, and then makes a call to the tp_dealloc member of the type object. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 13:08, Tim Chase python.l...@tim.thechases.com wrote: http://xkcd.com/927/ :-) Indeed. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Jul 20, 9:27 am, sturlamolden sturlamol...@yahoo.no wrote: On 20 Jul, 16:17, Mel mwil...@the-wire.com wrote: OTOH, if you intend to re-use the Dialog object, it's not a memory leak. It cannot be reused if you don't have any references pointing to it. Sure it is nice to have dialogs that can be hidden and re-displayed, but only those that can be accessed again. I find that keeping a dialog alive (and hidden) is bad practice EXCEPT in the case where a dialog will be used many, many times in an application. Since that kind of re-usage is rare destroying the dialog and freeing the graphical resources it consumes is important. However a dialog should handle it's own state. That is, and application should never have to keep up with dialog default values and re-insert then every time, NO, the dialog should do this all by itself. My solution is to create a simple container class that creates and destroys the dialog as needed (when show is called) however keeps a state of the last user inputs so the main application does not have to. class Dialog(): def __init__(self): self.state = [] # the dialog IS NOT created here! def show(self): # Create the dialog here # and load any initial values # from self.state. def cb_okbutton(self): # Process the inputs, store the # current values in self.state # and destroy. def cb_cancelbutton(self) # destroy the dialog. This is a proper design pattern for all GUI dialogs. *school-bell* -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20/07/11 15:47, sturlamolden wrote: On 20 Jul, 11:59, Thomas Jollans t...@jollybox.de wrote: I wonder - what do you think of GTK+? PyGTK with GLADE is the easier to use, but a bit awkward looking on Windows and Mac. (Not to mention the number of dependencies that must be installed, inclusing a GTK runtime.) Don't know about Mac, I was under the impression that GTK was fine on Windows these days. You can bundle GTK+ just as easily as Qt or Wx. It might, of course, be less usual. Really, while Swing and Tkinter are particularly bad as they draw their own widgets GTK and Qt do that as well. Qt uses the native libraries on Windows and OSX. -- http://mail.python.org/mailman/listinfo/python-list
problem in compiling the module in VC2010
Hi all, I am compiling the example with MCVS2010 #include Python.h static PyObject * ex_foo(PyObject *self, PyObject *args) { printf(Hello, world\n); Py_INCREF(Py_None); return Py_None; } static PyMethodDef example_methods[] = { {foo, ex_foo, METH_VARARGS, foo() doc string}, {NULL, NULL} }; static struct PyModuleDef examplemodule = { PyModuleDef_HEAD_INIT, example, example module doc string, -1, example_methods, NULL, NULL, NULL, NULL }; PyMODINIT_FUNC PyInit_example(void) { return PyModule_Create(examplemodule); } But it reports the following message: error LNK2001: unresolved external symbol __imp___Py_NoneStruct error LNK2019: unresolved external symbol __imp__PyModule_Create2 referenced in function _PyInit_example My os is windows 7 64-bit. Compiler: VC2010 -- http://mail.python.org/mailman/listinfo/python-list
Re: total_ordering behaviour
On Wed, Jul 20, 2011 at 4:18 AM, risboo6909 tty...@gmail.com wrote: Hello all, I've noticed some strange behaviour of functools.total_ordering decorator, at least it seems strange to me. Looks like this is already known and fixed as of March: http://bugs.python.org/issue10042 -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 17:21, Thomas Jollans t...@jollybox.de wrote: Don't know about Mac, I was under the impression that GTK was fine on Windows these days. GTK looks awful on Windows, requires a dozen of installers (non of which comes from a single source), is not properly stabile (nobody cares?), and does not work on 64-bit. -- http://mail.python.org/mailman/listinfo/python-list
Re: problem in compiling the module in VC2010
Am 20.07.2011 17:33, schrieb llwa...@gmail.com: Hi all, I am compiling the example with MCVS2010 VC 2010 is not officially supported. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: total_ordering behaviour
On Jul 20, 7:39 pm, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Jul 20, 2011 at 4:18 AM, risboo6909 tty...@gmail.com wrote: Hello all, I've noticed some strange behaviour of functools.total_ordering decorator, at least it seems strange to me. Looks like this is already known and fixed as of March: http://bugs.python.org/issue10042 Thanks, you right, I didn't notice that this bug has already been fixed -- http://mail.python.org/mailman/listinfo/python-list
SMS
One method you can use is to connect to an SMS API provider from your web application, which will enable you to send SMS via an internet connection, typically using a protocol like HTTP; You can try Nexmo SMS API, it supports HTTP REST and SMPP and we have documentation published in our website with information and examples on how to connect and send, which for a programmer in any language can be pretty simple. http://nexmo.com/documentation/libs/index.html Examples for Python are still to come to the documentation page, however, you can try github and find code to send sms for python in github. e.g. https://github.com/marcuz/pynexmo With Nexmo, you can send to 200 countries, and it has Long Numbers available in a few countries for inbound traffic.You need to have a CallBack URL for inbound to which Nexmo sends a request for each incoming message to your long number. It is a pay as you go service, so you decide how much you need to buy to send SMS (pricing per country/operator is on the website). For inbound, you pay per long number monthly (not per message). The end user does not pay for receiving. http://nexmo.com Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
a better parsing challenge. how can you parse usenet to keep this troll from posting on the wrong groups on usenet? first one to do so, wins the praise of his peers. 2nd one to do it makes sure the filter stays in place. all the rest will be rewarded by not seeing the troll anymore. anyone who actually engages in a thread with the troll should parse themselves out of existance. uri -- Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com -- Perl Developer Recruiting and Placement Services - - Perl Code Review, Architecture, Development, Training, Support --- -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 06:28, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: Have you tried Tkinter version 8.0 or better, which offers a native look and feel? Python 2.7.2 |EPD 7.1-1 (64-bit)| (default, Jul 3 2011, 15:34:33) [MSC v.1500 64 bit (AMD64)] on win32 Type packages, demo or enthought for more information. import Tkinter Tkinter.TkVersion 8.5 -- http://mail.python.org/mailman/listinfo/python-list
Re: (Maybe off topic) Can someone explain what a finite state machine is?
On Jul 19, 6:32 pm, Matty Sarro msa...@gmail.com wrote: Hey everyone. I am currently reading through an RFC, and it mentions that a client and server half of a transaction are embodied by finite state machines. I am reading through the wikipedia article for finite state machines, and sadly it's going a bit above my head. I don't really have a background in engineering, and would really love to understand what is being said. Does anyone have a simple way to explain it? Yes... background in engineering is what a layperson would assume from the words finite state machine but this is not really so (unless you think math is the same as engineering) because the words were invented by mathematicians (no normal engineer would call a machine an 'automaton' -- the original name!) So assuming and staying within python a natural example would be what is called lexical analysis or tokenizing. Say you have a line of python like: def foo(count, x =if nothing is given) # catch a comment anyone? the python interpreter in its lexical analysis phase breaks this up as |def|foo|(|count|,|x||=|if nothing is given|)|Comment DISCARDED Some of the things it does are: 1. Separating between all these tokens or lexemes 2. Distinguishing identifiers like foo, count, x (there's no difference at this stage) from keywords like def 3. Discarding spaces but after using them to separate 'def' from 'foo' 4. Identifying special symbols like ( , = etc 5. Throwing away the comment Now how does python know that the catch in the comment (or the if in the string) are not the python keywords? Well this is where the notion of state comes in: It starts in a default or normal state but when it sees the it goes to (or is it gotos?) a state which we may call InsideStringState. In this state everything is swallowed up indiscriminately until the next Likewise an InCommentState would swallow up everything from # to newline. So to tokenize python it would be natural to think with 3 states: Normal, InString and InComment Of course in real programming languages there would be many more states than 3. eg What happens when the machine is in InString state and you encounter a backslash? Or more hairy example: Say you have a language like C whose comments are /*... */ Now when you see a / is it a divide symbol or a comment? All such problems get solved by introducing suitable states like MaybeComment In short, dont focus your attention on 'machine' but on 'state' and you should be fine -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Jul 19, 11:28 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: Have you tried Tkinter version 8.0 or better, which offers a native look and feel? Steven, you have no buisness offering advice on Tkinter since you yourself have proclaimed that YOU NEVER used the module and never will. Stick to what you know please. -- http://mail.python.org/mailman/listinfo/python-list
Re: Geodetic functions library GeoDLL 32 Bit and 64 Bit
Hi, do you think this is the right place to advertise proprietary and commercial software? Lutz -- http://mail.python.org/mailman/listinfo/python-list
ANN: ActivePython 3.2.1.2 is now available
ActiveState is pleased to announce ActivePython 3.2.1.2, a complete, ready-to-install binary distribution of Python 3.2. http://www.activestate.com/activepython/downloads What's New in ActivePython-3.2.1.2 == (combining with the very recently released 3.2.1.1) New Features Upgrades --- - Upgrade to Python 3.2.1 (`release notes http://hg.python.org/cpython/file/v3.2.1/Misc/NEWS`__) - Upgrade to pythonselect 1.3 which supports Windows - Include virtualenv (1.6.3) and pip (1.0.2) - Upgrade to PyPM 1.3.5: - [Windows] `Bug #89474 http://bugs.activestate.com/show_bug.cgi?id=89474`_: automatically expand %APPDATA%\Python\Scripts - Bug #90382: --no-ignore option to fail immediately for missing packages - Upgraded the following packages: - Distribute-0.6.19 Noteworthy Changes Bug Fixes -- - PyPM: - `sudo pypm ..` should always use root user's BE license file - Bug #89540: `uninstall` command now properly removes symlinks - Bug #89648: shebang fixer skips symlinks - Upgrade SQLAlchemy to 0.6.8 - Upgrade to six 1.0.0 What is ActivePython? = ActivePython is ActiveState's binary distribution of Python. Builds for Windows, Mac OS X, Linux are made freely available. Solaris, HP-UX and AIX builds, and access to older versions are available in ActivePython Business, Enterprise and OEM editions: http://www.activestate.com/python ActivePython includes the Python core and the many core extensions: zlib and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3) database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for Tkinter, ElementTree for XML processing, ctypes (on supported platforms) for low-level library access, and others. The Windows distribution ships with PyWin32 -- a suite of Windows tools developed by Mark Hammond, including bindings to the Win32 API and Windows COM. ActivePython also includes a binary package manager for Python (PyPM) that can be used to install packages much easily. For example: C:\pypm install numpy [...] C:\python import numpy.linalg See this page for full details: http://docs.activestate.com/activepython/3.2/whatsincluded.html As well, ActivePython ships with a wealth of documentation for both new and experienced Python programmers. In addition to the core Python docs, ActivePython includes the What's New in Python series, Dive into Python, the Python FAQs HOWTOs, and the Python Enhancement Proposals (PEPs). An online version of the docs can be found here: http://docs.activestate.com/activepython/3.2/ We would welcome any and all feedback to: activepython-feedb...@activestate.com Please file bugs against ActivePython at: http://bugs.activestate.com/enter_bug.cgi?product=ActivePython Supported Platforms === ActivePython is available for the following platforms: - Windows (x86 and x64) - Mac OS X (x86 and x86_64; 10.5+) - Linux (x86 and x86_64) - Solaris/SPARC (32-bit and 64-bit) (Business, Enterprise or OEM edition only) - Solaris/x86 (32-bit) (Business, Enterprise or OEM edition only) - HP-UX/PA-RISC (32-bit) (Business, Enterprise or OEM edition only) - HP-UX/IA-64 (32-bit and 64-bit) (Enterprise or OEM edition only) - AIX/PowerPC (32-bit and 64-bit) (Business, Enterprise or OEM edition only) More information about the Business Edition can be found here: http://www.activestate.com/business-edition Custom builds are available in the Enterprise Edition: http://www.activestate.com/enterprise-edition Thanks, and enjoy! The Python Team -- Sridhar Ratnakumar sridharr at activestate.com -- http://mail.python.org/mailman/listinfo/python-list
A little complex usage of Beautiful Soup Parsing Help!
I am using Beautiful Soup to parse a html to find all text that is Not contained inside any anchor elements I came up with this code which finds all links within href but not the other way around. How can I modify this code to get only plain text using Beautiful Soup, so that I can do some find and replace and modify the soup? for a in soup.findAll('a',href=True): print a['href'] Example: htmlbody div a href=www.test1.com/identifytest1/a /div divbr/div diva href=www.test2.com/identifytest2/a/div divbr/divdivbr/div div This should be identified Identify me 1 Identify me 2 p id=firstpara align=center This paragraph should beb identified /b./p /div /body/html Output: This should be identified Identify me 1 Identify me 2 This paragraph should be identified. I am doing this operation to find text not within `a/a` : then find Identify and do replace operation with Replaced So the final output will be like this: htmlbody div a href=www.test1.com/identifytest1/a /div divbr/div diva href=www.test2.com/identifytest2/a/div divbr/divdivbr/div div This should be identified Repalced me 1 Replaced me 2 p id=firstpara align=center This paragraph should beb identified /b./p /div /body/html Thanks for your time and help ! -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Jul 20, 9:31 pm, Uri Guttman u...@stemsystems.com wrote: a better parsing challenge. how can you parse usenet to keep this troll from posting on the wrong groups on usenet? first one to do so, wins the praise of his peers. 2nd one to do it makes sure the filter stays in place. all the rest will be rewarded by not seeing the troll anymore. anyone who actually engages in a thread with the troll should parse themselves out of existance. Goedelian paradox: Is this thread in existence? -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
Uri == Uri Guttman u...@stemsystems.com writes: Uri a better parsing challenge. how can you parse usenet to keep this troll Uri from posting on the wrong groups on usenet? first one to do so, wins the Uri praise of his peers. 2nd one to do it makes sure the filter stays in Uri place. all the rest will be rewarded by not seeing the troll anymore. Uri anyone who actually engages in a thread with the troll should parse Uri themselves out of existance. Since the newsgroups: line is not supposed to have spaces in it, that makes both his post and your post invalid. Hence, filter on invalid posts. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way with more than one max possible
Thanks, everyone. Very helpful! Che -- http://mail.python.org/mailman/listinfo/python-list
Re: list(), tuple() should not place at Built-in functions in documentation
On 7/20/2011 2:21 AM, Stefan Behnel wrote: Terry Reedy, 19.07.2011 18:31: Chapter 5 is mostly about the behavior of built-in class instances. For some classes, like range, instances only come from class calls and the behavior of instances is intimately tied to the constructor arguments. Having the constructor described in C.5 might be useful. I strongly disagree. Wow. Strongly disagreeing with a mild statement like 'might be useful' is really strong. But let me explain (using slice rather than range). Three of the four non-special attributes of the slice objects produced by the slice() function are the three arguments of the function. (The fourth is an obscure method.) So the function and its result object are closely tied together, and unusually so. Hence it *might* be useful to discuss that particular pair together, especially since both are used rarely and always together. This is a rather minimal concession to the OP. But the overall thrust and conclusion of both that post of mine and the previous one is that 'function' in 'built-in functions' is best understood generically as including objects of type 'type' as well as objects of 'builtin_function_or_method' (and any other built-in callable if there happen to be any). So the rest of your post is strong agreement with what I have said since the beginning of the thread. What one needs to know about range is that it produces a non-iterator re-iterable virtual sequence object that supports a basic subset of the sequence operations. The function belongs in the function chapter and the sequence object in the sequence section of the classes chapter. The OP's point makes more sense in the context of other languages that make an artificial distinction between functions and constructors and require that the latter be preceded by keyword new. I prefer Python's uniformity. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: a little parsing challenge ☺
On Wed, Jul 20 2011, Randal L. Schwartz wrote: Uri == Uri Guttman u...@stemsystems.com writes: Uri a better parsing challenge. how can you parse usenet to keep this troll Uri from posting on the wrong groups on usenet? first one to do so, wins the Uri praise of his peers. 2nd one to do it makes sure the filter stays in Uri place. all the rest will be rewarded by not seeing the troll anymore. Uri anyone who actually engages in a thread with the troll should parse Uri themselves out of existance. Since the newsgroups: line is not supposed to have spaces in it, that makes both his post and your post invalid. Hence, filter on invalid posts. I suspect that the spaces you are seeing are being added by Gnus. I see them too (and I see them in your post as well), but they disappear when I use C-u g and view the source of the posts. Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Jul 20, 10:32 am, rantingrick rantingr...@gmail.com wrote: Steven, you have no buisness offering advice on Tkinter since you yourself have proclaimed that YOU NEVER used the module and never will. Stick to what you know please. Allow me. Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of- GUIs scratchy window with grooves and lines everywhere. Tkinter is awesome because you can nest anything inside anything else, and it has an elaborate extendable properties system. Oh, and you can TDD it. Unlike some more modern GUIs I could mention... -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 22:58, Phlip phlip2...@gmail.com wrote: Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of- GUIs scratchy window with grooves and lines everywhere. The widget set is limited compared to GTK or Qt, though it has the most common GUI controls, and it does not look that bad with the recent ttk styling (it actually doesn't look like Motif anymore). But it does not have a good GUI builder (that I know of). Sturla -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
Excerpts from Phlip's message of Wed Jul 20 16:58:08 -0400 2011: On Jul 20, 10:32am, rantingrick rantingr...@gmail.com wrote: Steven, you have no buisness offering advice on Tkinter since you yourself have proclaimed that YOU NEVER used the module and never will. Stick to what you know please. Allow me. Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of- GUIs scratchy window with grooves and lines everywhere. Themed Tk (TTK) has come a far way. I'll leave the research for you, however, as I can not give this post the time it deserves. -- Corey Richardson Those who deny freedom to others, deserve it not for themselves -- Abraham Lincoln signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20 Jul, 22:58, Phlip phlip2...@gmail.com wrote: Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of- GUIs scratchy window with grooves and lines everywhere. And using it with OpenGL has been impossible since Python 2.2 (or whatever). -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On Jul 20, 3:13 pm, sturlamolden sturlamol...@yahoo.no wrote: On 20 Jul, 22:58, Phlip phlip2...@gmail.com wrote: Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of- GUIs scratchy window with grooves and lines everywhere. The widget set is limited compared to GTK or Qt, though it has the most common GUI controls, and it does not look that bad with the recent ttk styling (it actually doesn't look like Motif anymore). But it does not have a good GUI builder (that I know of). Oh, and you can TDD it, too... -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 21 Jul, 00:52, Phlip phlip2...@gmail.com wrote: Oh, and you can TDD it, too... No, I can't TDD with Tkinter. All my tests fail when there is no OpenGL support (Togl is gone). For TDD to work, the tests must have a chance of passing. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter in Python has native widgets (was: I am fed up with Python GUI toolkits...)
Phlip phlip2...@gmail.com writes: Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of- GUIs scratchy window with grooves and lines everywhere. Applications have been written that look like that, sure. Many of them were *written* in the 1980s and 1990s, so the wonder is not how they look but that they still work today at all. To continue supporting those old applications, written with the assumption that the widgets will look like Motif, Tk must default to looking like ugly old Motif. But it simply is not true that Tk applications *must* look like Motif, or even close. We have for a long time had the “themed Tk” extension URL:http://wiki.tcl.tk/14796 which makes themed and/or native widgets in Tk. Python's Tkinter has this at the ‘tkinter.ttk’ module URL:http://docs.python.org/py3k/library/tkinter.ttk.html, or for Python 2 at URL:http://pypi.python.org/pypi/pyttk. Oh, and you can TDD it. Unlike some more modern GUIs I could mention... Yes, the ability to test one's GUI from unit test code is a huge plus. -- \ “Everyone is entitled to their own opinions, but they are not | `\entitled to their own facts.” —US Senator Pat Moynihan | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
RE: *Ben Finney changes thread subject* Please everyone, do not change the subject of someone's thread because it's considered rude. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: What Programing Language are the Largest Website Written In?
On Jul 13, 1:04 pm, ccc31807 carte...@gmail.com wrote: On Jul 12, 7:54 am, Xah Lee xah...@gmail.com wrote: maybe this will be of interest. 〈What Programing Language Are the Largest Website Written In?〉http://xahlee.org/comp/website_lang_popularity.html About five years ago, I did some pretty extensive research, and concluded that the biggest sites were written serverside with JSP. Obviously, this wouldn't include The Biggest site, but if you were a big, multinational corporation, or listed on the NYSE, you used JSP for your web programming. I doubt very seriously PHP is used for the biggest sites -- I'd still guess JSP, or maybe a MS technology (not VB), but it's only a guess. CC. I believe Facebook uses a PHP/C compiler. i.e. the site is written in PHP, but compiled down to C/C++... MZ -- http://mail.python.org/mailman/listinfo/python-list
Re: changing thread topics (was: I am fed up with Python GUI toolkits...)
On 07/20/2011 08:17 PM, rantingrick wrote: RE: *Ben Finney changes thread subject* Please everyone, do not change the subject of someone's thread because it's considered rude. Thank you. Right...do not change the subject because it's considered rude. Change it because the topic drifted from the original topic and a fitting subject line helps people decide whether they want to read any subsequent sub-threads. That's just email etiquette as old as the tubes. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: What Programing Language are the Largest Website Written In?
2011/7/20 igotmumps m...@mumps.ca: On Jul 13, 1:04 pm, ccc31807 carte...@gmail.com wrote: On Jul 12, 7:54 am, Xah Lee xah...@gmail.com wrote: maybe this will be of interest. 〈What Programing Language Are the Largest Website Written In?〉http://xahlee.org/comp/website_lang_popularity.html About five years ago, I did some pretty extensive research, and concluded that the biggest sites were written serverside with JSP. Obviously, this wouldn't include The Biggest site, but if you were a big, multinational corporation, or listed on the NYSE, you used JSP for your web programming. I doubt very seriously PHP is used for the biggest sites -- I'd still guess JSP, or maybe a MS technology (not VB), but it's only a guess. CC. I believe Facebook uses a PHP/C compiler. i.e. the site is written in PHP, but compiled down to C/C++... MZ not all sites use one language exclusively. For example, facebook status updates use their python non blocking web server Tornado. Not sure if that means the interface code is python but just putting that out there. Where I work, the majority of the site is ruby, about 70% and 30% python. Many ad-hoc parts of the site use different languages (primarily python) to provide data for reports. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
RE: *Tim Chase changes topic and talks smack* On Jul 20, 8:38 pm, Tim Chase python.l...@tim.thechases.com wrote: On 07/20/2011 08:17 PM, rantingrick wrote: RE: *Ben Finney changes thread subject* Please everyone, do not change the subject of someone's thread because it's considered rude. Thank you. Right...do not change the subject because it's considered rude. Change it because the topic drifted from the original topic and a fitting subject line helps people decide whether they want to read any subsequent sub-threads. That's just email etiquette as old as the tubes. What about the etiquette of staying on topic? The only person who is OFFICIALLY allowed to change the subject matter of a thread is the OP. Sure some folks might make an off topic post here and there however i find it bombastically rude when folks just change a topic of thread they do not own. How would you like it if i came to your house and wrote my name on your refrigerator door, or used your toilet without asking, or slept in your bed? I would not do that because i have manners. Feel free to make yourself comfortable but don't put you feet on the coffee table. -- http://mail.python.org/mailman/listinfo/python-list
Changing subject sucks. Re: I am fed up with Python GUI toolkits...
On Jul 20, 6:17 pm, rantingrick rantingr...@gmail.com wrote: RE: *Ben Finney changes thread subject* Please everyone, do not change the subject of someone's thread because it's considered rude. Thank you. No it isn't. Rambling off on a new topic under the wrong subject is rude. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
rantingrick rantingr...@gmail.com wrote: The old reinvent the wheel argument is only valid when wheels already exists. Currently we have triangles (or maybe pentagons) but no wheels. No, currently we have a small handful of people who feel the wheels are triangles but have done nothing more than complain about it, while those who don't feel likewise continue to cycle on them smoothly. The reinvent the wheel argument is only valid when the affected people do something other than whine. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
rantingrick rantingr...@gmail.com wrote: What about the etiquette of staying on topic? Such as raising your personal opinion of online etiquette in a thread on GUI toolkits? As always, there's what you say, and there's what you do, and never the twain shall meet. -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing subject sucks. Re: I am fed up with Python GUI toolkits...
On Thu, 21 Jul 2011 12:34 pm Phlip wrote: On Jul 20, 6:17 pm, rantingrick rantingr...@gmail.com wrote: RE: *Ben Finney changes thread subject* Please everyone, do not change the subject of someone's thread because it's considered rude. Thank you. No it isn't. Rambling off on a new topic under the wrong subject is rude. Ha ha, rantingrick lecturing others on rudeness! How cute! Or hypocritical. Sometimes I get those two confused. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: I am fed up with Python GUI toolkits...
On 20Jul2011 19:06, rantingrick rantingr...@gmail.com wrote: | | RE: *Tim Chase changes topic and talks smack* | | On Jul 20, 8:38 pm, Tim Chase python.l...@tim.thechases.com wrote: | On 07/20/2011 08:17 PM, rantingrick wrote: | | RE: *Ben Finney changes thread subject* | | Please everyone, do not change the subject of someone's thread because | it's considered rude. Thank you. | | Right...do not change the subject because it's considered rude. | Change it because the topic drifted from the original topic and a | fitting subject line helps people decide whether they want to | read any subsequent sub-threads. That's just email etiquette as | old as the tubes. | | What about the etiquette of staying on topic? The only person who is | OFFICIALLY allowed to change the subject matter of a thread is the OP. | Sure some folks might make an off topic post here and there however i | find it bombastically rude when folks just change a topic of thread | they do not own. You're labouring under a misapprehension. The OP doesn't own the thread. Starting a thread on a public list is like throwing a party. People are going to come. And talk, damn their impudence! It is good to stay near the topic, but threads will inevitably drift unless they're talking about something utterly trite. It is good of an author to mark his/her departure from the main topic, should it be significant, with a subject change. Or even a new thread. | How would you like it if i came to your house You can stop there, thanks. You continue to confuse a cooperative anarchy with some kind of stringent autocracy or heavily premoderated forum or something. As with your docstring formatting opinions or your spaces-vs-tabs opinions: mandating behaviour is a little pointless - it can't be enforced, few directives are unambiguously one sidedly good and so mandating stuff is divisive and will drive people away. Cheers, -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ It's quite difficult to remind people that all this stuff was here for a million years before people. So the idea that we are required to manage it is ridiculous. What we are having to manage is us. - Bill Ballantine, marine biologist -- http://mail.python.org/mailman/listinfo/python-list
[issue12545] Incorrect handling of return codes in the posix_lseek function in posixmodule.c
Charles-François Natali neolo...@free.fr added the comment: Hi. I can submit a patch for the first part. Should I submit on this issue tracker item? Sure. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12545 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12583] More detailed ImportError messages
Ram Rachum cool...@cool-rr.com added the comment: David, I don't think you've read my message carefully enough. I'm well aware that there are other ways in Python to import than the `import` statement. I'm proposing that it doesn't matter. I asked, isn't a circular import when you try to import a module `foo` while in a lower stack level you haven't finished importing `foo` yet? If this is true, then you just need to have some kind of flag for each module saying This module is currently being imported, which you set to `True` when you start importing and back to `False` when you finished importing. (It doesn't have to look exactly like this, it could be a context manager, or alternatively a centralized list of all module that are currently in the middle of an import.) Then when you have an `ImportError`, you check whether the module that the user tried to import has that flag raised, and if so notify him that it's probably a circular import problem. Will that work? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12583 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12524] change httplib docs POST example
Changes by Bharadwaj barbi.br...@gmail.com: Added file: http://bugs.python.org/file22704/http_example2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12545] Incorrect handling of return codes in the posix_lseek function in posixmodule.c
STINNER Victor victor.stin...@haypocalc.com added the comment: So I'd suggest forgetting about this part. If someone really wants this feature (relative seek of more than 2^63), he/she should open a new issue. This issue remembers me a mktime() issue: mktime() may return -1 even if it is not an error. time_mktime() uses now a sentinel to detect an error: buf.tm_wday = -1; /* sentinel; original value ignored */ tt = mktime(buf); /* Return value of -1 does not necessarily mean an error, but tm_wday * cannot remain set to -1 if mktime succeeded. */ if (tt == (time_t)(-1) buf.tm_wday == -1) /* OverflowError */ For lseek, we can rely on errno. Try something like that: errno = 0; offset = lseek(...); if (offset == (off_t)-1 errno) /* error */ We can write a test using a sparse file... Or maybe a mmap object? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12545 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12592] modify configure.in to detect OpenBSD 5.x
New submission from rpointel pyt...@xiri.fr: Hi, I tested to build Python 2.7 and Python 3.2.1 (it would be the same with others versions of Python) and it failed to build on OpenBSD 5.0 (beta version). This is the diff to correctly work on OpenBSD 5.x: --- configure.in.orig Sat Jul 9 08:58:56 2011 +++ configure.inWed Jul 20 10:19:37 2011 @@ -320,7 +320,7 @@ # As this has a different meaning on Linux, only define it on OpenBSD AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) ;; - OpenBSD/4.@:@789@:@) + OpenBSD/4.@:@789@:@ | OpenBSD/5.*) # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is # also defined. This can be overridden by defining _BSD_SOURCE # As this has a different meaning on Linux, only define it on OpenBSD Could you add this modification in the different versions of Python ? Thanks a lot, Remi. -- components: Installation messages: 140724 nosy: rpointel priority: normal severity: normal status: open title: modify configure.in to detect OpenBSD 5.x versions: Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12592 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12593] define OpenBSD in configure.in if Py_ENABLE_SHARED == 1
New submission from rpointel pyt...@xiri.fr: Hi, Could you define OpenBSD in enable_shared section of the configure.in ? I just tested with Python 3.2.1, but it could be usefull to add it in the other versions of Python 3.x. This is the diff which seems to work : --- configure.in.orig Sat Jul 9 08:58:56 2011 +++ configure.inWed Jul 20 10:19:37 2011 @@ -755,7 +755,7 @@ PY3LIBRARY=libpython3.so fi ;; -Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*) +Linux*|GNU*|NetBSD*|FreeBSD*|OpenBSD*|DragonFly*) LDLIBRARY='libpython$(LDVERSION).so' BLDLIBRARY='-L. -lpython$(LDVERSION)' RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} Thanks a lot, Remi. -- components: Installation messages: 140725 nosy: rpointel priority: normal severity: normal status: open title: define OpenBSD in configure.in if Py_ENABLE_SHARED == 1 versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12593 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12591] text files returned by subprocess.Popen with universal_newlines=True are not iterable
R. David Murray rdmur...@bitdance.com added the comment: This isn't a problem with ConfigParser, it's a problem with the text file object returned by Subprocess. You can reproduce the bug by trying to iterate over the TextIOWrapper returned by subprocess. (It is true, however, that the ConfigParser docs should be specific that it isn't any file, but any text file. If you would like to open a separate issue about that, that would be great). -- nosy: +gregory.p.smith, haypo, lukasz.langa, pitrou, r.david.murray stage: - needs patch title: configparser can't read_file the output of subprocess.Popen - text files returned by subprocess.Popen with universal_newlines=True are not iterable type: - behavior versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12591 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12583] More detailed ImportError messages
R. David Murray rdmur...@bitdance.com added the comment: It might. Although I did miss your message about the flag, my point really was that you'll find that import is very complicated when you try to write the patch to do it. There may not be one central place you can set and query that flag, because of the various ways import can happen and the byzantine nature of the import code. It doesn't seem likely that anyone on the current team is going to tackle tying this, but you are welcome to. We always need more contributors. Just bear in mind that we weigh the benefits of patches against the additional code complexity they introduce (if they do; the most fortunate patches simplify things). I think that's what Brett meant by probably not worth it. Brett wrote importlib to move a lot of the complication into Python code where it would be easier to work with. That transition hasn't happened yet. I hear that the import-sig is talking about doing some interesting things to (hopefully) make life better for everyone, so you might want to sign on there and find out what is going on before starting on a patch. -- priority: normal - low stage: - needs patch type: - feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12583 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12593] define OpenBSD in configure.in if Py_ENABLE_SHARED == 1
Stefan Krah stefan-use...@bytereef.org added the comment: This is a duplicate of #12560. -- nosy: +skrah resolution: - duplicate stage: - committed/rejected status: open - closed superseder: - libpython.so not built on OpenBSD type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12593 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12560] libpython.so not built on OpenBSD
Changes by Stefan Krah stefan-use...@bytereef.org: -- nosy: +rpointel ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Austin Bingham austin.bing...@gmail.com added the comment: Has a decision been made to implement some form of parametric tests? Is working being done? Along with parameterizing individual test methods, I'd also like to throw out a request for parametric TestCases. In some cases I find that I want the behavior of setUp() or tearDown() to vary based on some set of parameters, but the individual tests are not parametric per se. -- nosy: +abingham ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Brian Curtin br...@python.org added the comment: By this issue existing, that's the decision that we should probably do this, and I think the discussion shows we agree it should happen. How it's done is another way, and we have roughly a year to get it figured out before 3.3 gets closer. I have a patch that implements this as a decorator, but it's out of date by now and not feature complete. It's on my todo list of patches to revive. -- components: +Tests stage: - needs patch versions: +Python 3.3 -Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12524] change httplib docs POST example
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset ab4d403cb0c0 by Senthil Kumaran in branch '3.2': Fix closes issue12524 - update http.client POST example with a working example. http://hg.python.org/cpython/rev/ab4d403cb0c0 New changeset bc71fff2b6c7 by Senthil Kumaran in branch 'default': merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example. http://hg.python.org/cpython/rev/bc71fff2b6c7 New changeset b754641a429f by Senthil Kumaran in branch '2.7': merge from 3.2 - Fix closes issue12524 - update http.client POST example with a working example. - Patch contributed by Bharadwaj http://hg.python.org/cpython/rev/b754641a429f -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
R. David Murray rdmur...@bitdance.com added the comment: Brian, if you don't have time to work on it in the next little while, maybe you could post your partial patch in case someone else wants to work on it? Might be a good project for someone on the mentoring list. Unless someone sees a clever way to implement both with the same mechanism, parameterizing test cases should probably be a separate issue. Doing it via subclassing is straightforward, which also argues for a separate issue, since an 'is this worth it' discussion should be done separately for that feature. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Michael Foord mich...@voidspace.org.uk added the comment: *If* we add this to unittest then we need to decide between test load time parameterised tests and test run time parameterisation. Load time is more backwards compatible / easier (all tests can be generated at load time and the number of tests can be known). Run time is more useful. (With load time parameterisation the danger is that test generation can fail so we need to have the test run not bomb out in this case.) A hack for run time parameterisation is to have all tests represented by a single test but generate a single failure that represents all the failures. I think this would be an acceptable approach. It could still be done with a decorator. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12524] change httplib docs POST example
Senthil Kumaran sent...@uthcode.com added the comment: Thanks for the patch, Bharadwaj. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Michael Foord mich...@voidspace.org.uk added the comment: And yes, parameterising test cases is a different issue. bzr does this IIRC. This is easier in some ways, and can be done through load_tests, or any other test load time mechanism. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
R. David Murray rdmur...@bitdance.com added the comment: Michael, would your single test clearly indicate all the individual failures by name? If not, then I would not find it useful. I can already easily parameterize inside a single test using a loop, it's the detailed reporting piece that I want support for. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
R. David Murray rdmur...@bitdance.com added the comment: The reporting piece, and ideally being able to use the arguments to unittest to run a single one of the parameterized tests. (I can get the reporting piece now using the locals() hack, but that doesn't support test selection). Does test selection support required load time parameterization? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Michael Foord mich...@voidspace.org.uk added the comment: Test selection would require load time parameterisation - although the current test selection mechanism is through importing which would probably *not* work without a specific fix. Same for run time parameterisation. Well how *exactly* you generate the names is an open question, and once you've solved that problem it should be no harder to show them clearly in the failure message with a single test report than with multiple test reports. The way to generate the names is to number each test *and* show the parameterised data as part of the name (which can lead to *huge* names if you're not careful - or just object reprs in names which isn't necessarily useful). I have a decorator example that does runtime parameterisation, concatenating failures to a single report but still keeping the generated name for each failure. Another issue is whether or not parameterised tests share a TestCase instance or have separate ones. If you're doing load time generation it makes sense to have a separate test case instance, with setUp and tearDown run individually. This needs to be clearly documented as the parameter generation would run against an uninitialised (not setUp) testcase. Obviously reporting multiple test failures separately (run time parameterisation) is a bit nicer, but runtime test generation doesn't play well with anything that works with test suites - where you expect all tests to be represented by a single test case instance in the suite. I'm not sure that's a solveable problem. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Michael Foord mich...@voidspace.org.uk added the comment: Dammit, I've reversed my thinking in some of those messages. Load time parameterisation *does* give you separate test reporting. It is run time parameterisation that doesn't. Depending on how you do it (i.e. if the decorator generates the tests and attaches them as TestCase methods) you can do it at import time. And then normal test selection works if you know the test name. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7897] Support parametrized tests in unittest
Michael Foord mich...@voidspace.org.uk added the comment: So if we do import time *or* test load time parameterisation then we can do separate failure reporting. We may still want to improve test selection for parameterised tests. There are use cases for run time parameterisation (for example generating tests from a database that is only available during the test run was one use case someone has that can't be met by early parameterisation). If we do run time parameterisation then I think we can only maintain compatibility with existing uses of test suites by having a single test case instance per parameterised test, and single combined failure report. I would prefer *not* to add run time parameterisation. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7897 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8728] 2.7 regression in httplib.py: AttributeError: 'NoneType' object has no attribute 'makefile'
Éric Araujo mer...@netwok.org added the comment: If possible, the code example would use only Python, not httplib2 or Active State Python :) -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8728 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12555] PEP 3151 implementation
Changes by Éric Araujo mer...@netwok.org: Added file: http://bugs.python.org/file22705/40ae82fafaed.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7620] Vim syntax highlight
Éric Araujo mer...@netwok.org added the comment: Thanks for your willingness to contribute to Python and your work on a patch. We’re currently debating whether we should update or remove the Misc/Vim files, on #9893, so if we reach an agreement that maintaining these files is too costly for little benefit, you will have worked in vain. Sorry if that happens, and I hope you’ll find other bugs where your patches will be accepted. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7620 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com