Re: WxPython versus Tkinter.
From: "Robert Kern" in? Robin Dunn is the wxPython project lead. Ok, in this case I understand why WxPython can't be included in stdlib. I think there was a communication problem because the oldest list members start with the idea that all the list members know who is who and they may be thinking that I don't want to accept the reality or that I have bad feelings about some list members or something like that. There is a large difference between the being "promoted by Python" and being "included in Python's standard library. The latter is the issue at hand, not the former. wxPython is already "promoted" by Python's documentation: If there is a bigger chance that a beginner start using Tkinter without knowing its issues, this means that Python promotes the wrong tool. As I said, the main issue is not that Python doesn't promote WxPython. I have even suggested that Python might not include any GUI if this would be prefered, but what's wrong is that Python promotes a GUI which is not accessible by including it as a default GUI. As we all know, Python doesn't care too much about maintaining a backward compatibility and there are much many other things which are not compatible between different Python versions, but some Python programmers consider this a virtue because they say that what was wrong was eliminated. If they are right, then why wouldn't be a good idea to also remove a wrong GUI lib? Just because the majority prefers it? Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Alexander Kapps" Please don't use the lower Linux user percentage as an argument here. If you follow that path further, you would need to agree that it's only an "insignificant" percent of people who need a screen reader, so why bother? I didn't say that the Linux users or Mac users are not important. MFC or standard Win32 GUI is better accessible than wxWIDGETS but I considered that wxWIDGETS should be prefered (and not only Win32 controls) because it is *portable*, exactly because it also work on other platforms than Windows. But this doesn't mean that giving the most used screen reader as an example for testing the inaccessibility of Tk is not something that should be done (especially that Tk-based GUIS are inaccessible for other screen readers also.) Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Littlefield, Tyler" It doesn't support a good voice synthesizer like Eloquence or IBM Via voice, but only eSpeak which sounds horrible, it doesn't have a scripting language ready to use as JAWS and Window Eyes do, it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, it offers a poor accessibility in many applications and many other issues. You are wrong, on all accounts. I have specificly asked about these things on the NVDA mailing list at the end of the last year, and I have also tried NVDA and all those things are very true. Which are those "wrong" things? Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "geremy condra" The bottom line is that, yes, you do still have to convince people that accessibility is important if you want them to do anything about it. I have to do almost exactly the same thing in my field- everybody knows that security is important, but every time I go to disclose a vulnerability I have to be very careful if I want to convince the vendor to fix the problem. During those discussions, an ounce of civility is worth more than ten tons of righteousness, not only because it helps convince people to do what you want but because they frequently walk away from it feeling good about the experience and eager to not make the same mistake again. Yes you might be right. It is just my way of communicating and it might be too direct and some people might not like it. I always consider the expressions like "How do you do" as having absolutely no value, because they are just nice expressions made for easing the communication, but yes, most people seem to like them and don't like to discuss directly about the sensible problems. As the other list members have started thinking that I know who is who and they thought that I should understand why WxPython can't be included, I have made the same mistake by thinking that the others are really aware about the importance of accessibility. But you are right, this may be a mistake from my part too and I am sorry if I offended somebody. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Brendan Simon (eTRIX)" Since it seems the python motto is "Batteries included", then it would seem to me that wxPython is the natural fit as it also has "Batteries included" (e.g. accessibility, native look-n-feel, mature and evolving, can produce simple or complex gui programs, etc, etc). Yes Brendan, you are perfectly right, but unfortunately WxPython developers don't want to have it included in the stdlib. Finally I understood that this is the main problem, because if they would want to do it in the conditions imposed by Python, it would have been much easier and many of other problems could have been solved. But WxPython is their work and they decision is their. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Grant Edwards" And, based on your behavior, you apparently don't like convincing others or advancing the cause of accessibility. It seems you prefer to annoy and alienate others. From what I said, what was annoying? I don't want to convince anyone, but I just want to inform the others and let them know if they are doing something not recommended. IOW, you don't really care about increasing accessibility, you just want to hear the sound of your own voice as you shout into the wind. Where have you seen that I don't care about accessibility? I say that I don't need to convince because today everyone should be convinced about accessibility, because we are talking with programmers here, not with cow-boys. but is that atitude worst than of those who don't care about discriminatory practices? Yes, it is worse. People who don't care are neither helping nor hurting your cause. However, you're actively hurting it. I was talking *only* to those who care and I just informed them that Tkinter is not accessible. Was that so bad or so impolitely as you said? Do you think that there are so many those who don't care (even on this list) and I hurt them? Do you think that I should care about the feeling of those who don't care about the accessibility? Do you think that they have bigger problems than those who are hurt by lack of care? People will not separate your personality from the cause you espouse. Wow! that's really bad. I thought that I might find here people that might have something against my opinions, that is very normal, that's why we are discussing, but I didn't think that I will also find people that will have something against me, just because of my opinions. I know people with different political opinions, with different programming languages preferences, that like other kind of women, that prefer other kkind of food, with whom I have often philosophical debates often, but whith whom I can be a good friend and collaborator and co-worker for some projects. You may not like it, but that's a fact. If you are in favor of XYZ, and act rude and insulting while espousing XYZ, people will react against not only you but _also_ XYZ. I know what you are reffering to. :-) And I was hoping that there won't be people that don't like me personally for what I think about some things that have nothing related to them personally. But I don't say that you are wrong. After some reactions on the list I can say that you might be really right. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Littlefield, Tyler" >I don't want to convince anyone, but I just want to inform the others and let >them know if they are doing something not recommended. not recommended by -you-, which is different than by a community or the subset of people you are attempting to represent. furthermore, your attidude is that of "comply to my definition of what is needed, or you are selfish, rude, mean, cruel, etc." Then when that fails, you try cramming words in people's mouth to make them feel like they kick puppies, and to bring everyone else to this same conclusion. We are talking about accessibility here. Are you saying that Tkinter can be recommended from the perspective of accessibility? Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: how to read the last line of a huge file???
On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: I have do some log processing which is usually huge. The length of each line is variable. How can I get the last line?? Don't tell me to use readlines or something like linecache... This is not optimum or efficient, but it works! If you want to see what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a print statement to the bottom of the while loop. :) import os with open('biglogfile.log', 'r') as fh: fh.seek(-4096, os.SEEK_END) buffer = fh.read(4096) # We are expecting a trailing newline. while "\n" not in buffer[:-1]: fh.seek(-8192, os.SEEK_CUR) buffer = fh.read(4096) + buffer # Eliminate empty lines, they aren't useful. lines = [line for line in buffer.split('\n') if line] print lines[-1] — Alice. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: use class factory to set required class variables?
On Wed, 26 Jan 2011 13:37:20 -0800, Alan wrote: > I have a class ``A`` that is intentionally incomplete: it has methods > that refer to class variables that do not exist. For the record, in Python it is usual to refer to "attributes" rather than "class variables" and "instance variables". In Python, classes are first-class objects (pun not intended) like ints, strings, floats etc., and so a "class variable" would be a variable holding a class, just as a string variable would be a variable holding a string, an int variable holds an int, etc. > The class ``A`` has > several complicated methods, a number of which reference the "missing" > class variables. Obviously, I do not directly use ``A``. This is called an abstract class -- you need to subclass it to use it. > I have a class factory ``f``` that subclasses ``A`` *only* in order to > define the class variables. > > The motivation/problem: > I did this because I need many versions of class ``A``, which differ > only in the class variables, which are not known until run time. > > Q: On the face of it, did I pick a reasonable solution to my problem? > If so is this a standard pattern? If not, can you mention a better > approach? You have a class factory which subclasses an abstract class. Seems perfectly reasonable to me. More than reasonable -- it sounds like a *good* way of dealing with the problem. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorator question
On Jan 27, 2:42 am, "Thomas L. Shinnick" wrote: > At 08:17 PM 1/26/2011, Chris wrote: > > >I have a class (A, for instance) that possesses a boolean (A.b, for > >instance) that is liable to change over an instance's lifetime. > > >Many of the methods of this class (A.foo, for instance) should not > >execute as long as this boolean is false, but should instead raise an > >exception. > > >Can I use a decorator to implement this functionality? More exactly, > >could I define a function called 'checker' that accomplishes this: > > Mark Summerfield's book "Programming in Python 3" has an example > something like this (p.357) called 'positive_result'. I hesitate to > quote the entire thing, so I'll quote only the inner 'half' of the decorator: > def wrapper(*args, **kwargs): > result = function(*args, **kwargs) > assert result >= 0, function.__name__ + "() result isn't >= 0" > return result > > I would guess you would have to count on the first item in the > methods' args to be self, and use that to test whether your attribute > is false/true? > > Mark? > > >def checker(f): > > ... > > >class A(): > > > b = True > > > @checker > > def foo(self,...): > > print 'in foo' > > >a = A() > >a.foo() > >a.b = False > >a.foo() > > >would result in: > > >'in foo' > >Exception: ... > > >This exact solution isn't necessary, just something that doesn't > >require me to have the clunky: > > >def foo(self,...): > > if self.b: > > ... > > else: raise Exception('b attribute must be true before executing > >this method') > > >in every method. > > >Thanks, > > >Chris Here's a simple example that I think does what you're after: ## #!/usr/bin/env python3 import functools def execute_if_valid(function): @functools.wraps(function) def wrapper(*args, **kwargs): if not args[0].valid: raise Exception("invalid instance") return function(*args, **kwargs) return wrapper class A: valid = True def foo(self): print("called foo() on a valid or invalid instance") @execute_if_valid def bar(self): print("called bar() on a valid instance") a = A() a.foo() a.bar() a.valid = False a.foo() a.bar() ## Here's its output: ## called foo() on a valid or invalid instance called bar() on a valid instance called foo() on a valid or invalid instance Traceback (most recent call last): File "./test.py", line 32, in a.bar() File "./test.py", line 10, in wrapper raise Exception("invalid instance") Exception: invalid instance ## -- http://mail.python.org/mailman/listinfo/python-list
Re: use class factory to set required class variables?
Alan wrote: I have a class ``A`` that is intentionally incomplete: it has methods that refer to class variables that do not exist. The class ``A`` has several complicated methods, a number of which reference the "missing" class variables. Obviously, I do not directly use ``A``. I have a class factory ``f``` that subclasses ``A`` *only* in order to define the class variables. The motivation/problem: I did this because I need many versions of class ``A``, which differ only in the class variables, which are not known until run time. Q: On the face of it, did I pick a reasonable solution to my problem? If so is this a standard pattern? If not, can you mention a better approach? My solution is working for me, but the class ``A`` is bugging me, because of the odd (to me) way in which it is incomplete. Obviously, I'm not a computer science type ... Thanks, Alan Isaac Your design is perfectly fine. A is an abstract class, aka interface class. This is a very common pattern, that can solve many problems. However, and this is a personal advice, try to declare all the required attributes/methods in the abstract class, setting them to None or raising a NotImplementedError. That would help anyone, including you, to know what is required to define when subclassing A. class A: A_VALUE = None def aMethod(self): raise NotImplementedError() FYI, there is a python module that provide some feature to enhance your abstract classes: http://docs.python.org/library/abc.html. These are more advanced features, you may just ignore that module for now. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
wxPython is not suitable for inclusion for many reasons. One reason is that it is a *huge* library which requires a lot of constant work (bugfixing, documentation, lots of commits, etc...) which cannot weight on python development. Keeping the two worlds separated is better for both of them, especially for wxPython which doesn't have to follow the strict politics surrounding the python stdlib. For example, wxPython is free to break some API backward compatibility on every new major version if this is desired. Such a thing couldn't happen if it were in the stdlib for obvious reasons. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/26 Brendan Simon (eTRIX) : > Since it seems the python motto is "Batteries included", then it would seem > to me that wxPython is the natural fit as it also has "Batteries included" > (e.g. accessibility, native look-n-feel, mature and evolving, can produce > simple or complex gui programs, etc, etc). > > -- > Brendan Simon > www.etrix.com.au > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Executing multiple subprocesses and waiting
JB wrote: One of my python scripts that takes a bunch of inputs from a tKinter gui, generates a set of command line stings, and then threads them off to subprocess for calls to other programs like Nuke and our render farm has recently started randomly crashing pythonw.exe. I'm taking a look at my threading setup and attempting to clean it up. I was wondering what a smart way of doing what I describe is? Take a list of strings containing command line calls to other programs, process them one at a time (waiting for the previous one to complete before starting the next) and then finishing elegantly. Currently, the gui passes them all to a "workerThread" which loops through each string, sending it to a "processThread" which makes a call to subprocess to execute it. This has worked fine for over a year so the recent crashing is mystifying me. I'm wondering if it's increased network stress (we've grown) or something similar? Any thoughts and suggestions on waiting for threads to complete are appreciated. Google 'Python execnet'. The main purpose of this module is to execute jobs on a bunch of different machines. However by simply declaring your local as unique available gateway, execnet will take care of queueing the jobs on your local. Look for examples with 'Popen' type gateways. I love this module, (and any other that are doing the network stuff for you). JM -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Octavian, If I understand your message, you are frustrated with Tkinter because it doesn't support accessability. In several messages on this thread I pointed out that Tkinter can easily be made accessable under Linux and Mac OS X. Rather than throw out Tkinter entirely, why not work with the community to make Tkinter accessable under Windows. That sounds a lot easier than trying to fight for wxWidgets as a Tkinter replacement when so many good arguments have been made against this strategy. Malcolm -- http://mail.python.org/mailman/listinfo/python-list
Re: use class factory to set required class variables?
On Jan 27, 2011, at 4:03 AM, Steven D'Aprano wrote: > On Wed, 26 Jan 2011 13:37:20 -0800, Alan wrote: > >> I have a class ``A`` that is intentionally incomplete: it has methods >> that refer to class variables that do not exist. > > For the record, in Python it is usual to refer to "attributes" rather > than "class variables" and "instance variables". In Python, classes are > first-class objects (pun not intended) like ints, strings, floats etc., > and so a "class variable" would be a variable holding a class, just as a > string variable would be a variable holding a string, an int variable > holds an int, etc. > Being nit-picky, this is a slightly flawed justification of the terminology. In Smalltalk, classes are first class objects (pun similarly not intended). Yet in Smalltalk we refer to class variables and instance variables. These are not necessarily variables that 'hold' classes. In fact, all classes are instances, and so all variables hold instances... So there's something not quite right about your 'first class objects ... so ... would be a ...'. This may well be a standard Python convention, and it is certainly not objectionable. But it isn't well-justified on the basis of the 'first-class-ness' of classes as objects... Best regards, Bill -- http://mail.python.org/mailman/listinfo/python-list
Wrappers in python
What are wrappers? What entities do they wrap around? Struggling to understand the concept. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: Octavian, If I understand your message, you are frustrated with Tkinter because it doesn't support accessability. In several messages on this thread I pointed out that Tkinter can easily be made accessable under Linux and Mac OS X. Rather than throw out Tkinter entirely, why not work with the community to make Tkinter accessable under Windows. I am willing to help, but unfortunately I don't know neither TCL or C nor the technical details about the accessibility standards that need to be implemented. I am mainly a web/CLI programmer. I know Perl very well and I just started to also learn Python especially because Python is a little better than Perl for creating desktop apps for Windows. In these conditions, if I could be of any help, I am willing to contribute, but to be sincere I don't think that I would be a great help. If someone knows more about this field and thinks that I could be helpful however, I'd like to know. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrappers in python
sl33k_ wrote: What are wrappers? What entities do they wrap around? Struggling to understand the concept. We would need a little bit of a context to answer that question, you could be refering to differents things. I'll give it a try on one common usage for wrapper: A wrapper is a python module that interface between python and a 3rd party library offering a non python interface. Consider Google chart api. This is the native URL API: https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World pygooglechart is the python wrapper for that api, allowing you to get the same effect, using Python objects: from pygooglechart import PieChart3D # Create a chart object of 250x100 pixels chart = PieChart3D(250, 100) # Add some data chart.add_data([20, 10]) # Assign the labels to the pie data chart.set_pie_labels(['Hello', 'World']) # Print the chart URL print chart.get_url() Python wrapper allows users to write only python code, even when calling non python 3rd libraries. Another example of wrapper is pgdb. It allows you to interface with a postgreSQL database without knowing about the native interface, you can commit and fetch data from the database by writing python code only. Nice ! JM -- http://mail.python.org/mailman/listinfo/python-list
Re: how to read the last line of a huge file???
In article , Alice BevanâMcGregor wrote: > On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: > > > I have do some log processing which is usually huge. The length of each > > line is variable. How can I get the last line?? Don't tell me to use > > readlines or something like linecache... > > This is not optimum or efficient, but it works! If you want to see > what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a > print statement to the bottom of the while loop. :) > > import os > > with open('biglogfile.log', 'r') as fh: > fh.seek(-4096, os.SEEK_END) > buffer = fh.read(4096) > > # We are expecting a trailing newline. > while "\n" not in buffer[:-1]: > fh.seek(-8192, os.SEEK_CUR) > buffer = fh.read(4096) + buffer > > # Eliminate empty lines, they aren't useful. > lines = [line for line in buffer.split('\n') if line] > print lines[-1] > > â Alice. :) Back in the old days, if you wanted to read a file backwards, you just used a tape drive that had read-reverse capability :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
>but what's wrong is that Python promotes a GUI which is not accessible by including it as a default GUI. You seem to have overlooked this multiple times and instead decided to shove words in my mouth and continue on your line of selfishness which is justified apparently now by the fact that you are ESL. I have mentioned many, many times that we work to make TKInter accessible; it is something I plan to start working on this weekend. But rather than that, you seem to still want to switch gui libraries in python, which I might add, will not happen over night, nor will the accessibilifying (my new word) TKInter. It's a process that will take time. So, I ask since you keep jumping around this point, what is wrong with fixing TKInter? -- Thanks, Ty -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Eloq is an add-on, but it does support it. >but only eSpeak which sounds horrible That's your personal preference. Plenty use and like ESpeak. >it doesn't have a scripting language ready to use as JAWS and Window Eyes do, Scripting is done in Python, (no, not some native scripting language), and are done as modules. You write your script in python, and off you go. Problem solved. >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. >it offers a poor accessibility in many applications Very very very wrong. It works better with some apps than Jaws does, and about as good in many others. NVDA (like all other readers, and any program for that matter) still does have problems, but none that you mentioned. >and many other issues. -other- says that there were issues to begin with; the only issue here is you promoting the most "widely used screen reader," because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. -- Thanks, Ty -- http://mail.python.org/mailman/listinfo/python-list
Re: how to read the last line of a huge file???
27.01.2011, 15:55, "Roy Smith" : > In article ;, > Alice Bevan–McGregor ; wrote: > >> On 2011-01-26 02:59:26 -0800, Xavier Heruacles said: >>> I have do some log processing which is usually huge. The length of each >>> line is variable. How can I get the last line?? Don't tell me to use >>> readlines or something like linecache... >> This is not optimum or efficient, but it works! If you want to see >> what's going on, use 4 instead of 4096 and 8 instead of 8192 and add a >> print statement to the bottom of the while loop. :) >> >> import os >> >> with open('biglogfile.log', 'r') as fh: >> fh.seek(-4096, os.SEEK_END) >> buffer = fh.read(4096) >> >> # We are expecting a trailing newline. >> while "\n" not in buffer[:-1]: >> fh.seek(-8192, os.SEEK_CUR) >> buffer = fh.read(4096) + buffer >> >> # Eliminate empty lines, they aren't useful. >> lines = [line for line in buffer.split('\n') if line] >> print lines[-1] >> >> — Alice. :) > > Back in the old days, if you wanted to read a file backwards, you just > used a tape drive that had read-reverse capability :-) > > -- > http://mail.python.org/mailman/listinfo/python-list Yeah. And if you wanted to zoom image -- you just had to go couple steps closer to it) -- jabber: k...@ya.ru -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
>We are talking about accessibility here. Are you saying that Tkinter can be >recommended from the perspective of accessibility? See my comment about shoving words in people's mouths; I did not hint, nor did I come near saying that in that message. On 1/27/2011 1:17 AM, Octavian Rasnita wrote: From: "Littlefield, Tyler" >I don't want to convince anyone, but I just want to inform the others and let >them know if they are doing something not recommended. not recommended by -you-, which is different than by a community or the subset of people you are attempting to represent. furthermore, your attidude is that of "comply to my definition of what is needed, or you are selfish, rude, mean, cruel, etc." Then when that fails, you try cramming words in people's mouth to make them feel like they kick puppies, and to bring everyone else to this same conclusion. We are talking about accessibility here. Are you saying that Tkinter can be recommended from the perspective of accessibility? Octavian -- Thanks, Ty -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/26/2011 11:02 PM Octavian Rasnita said... As we all know, Python doesn't care too much about maintaining a backward compatibility Where'd you get this idea? Between v2 and v3 yes, that was the intent. But otherwise, I think there's another miscommunication behind this... See http://www.python.org/dev/peps/pep-0291/ Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: help with multiprocessing pool
On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: > Hi all, > > I could really use some help with a problem I'm having. Hiya Craig, I don't know if I can help, but it's really difficult to do without a full working example. Also, your code has several OS X-isms in it so I guess that's the platform you're on. But in case you're on Windows, note that that platform requires some extra care when using multiprocessing: http://docs.python.org/library/multiprocessing.html#windows Good luck Philip > I wrote a function that can take a pattern of actions and it apply it to the > filesystem. > It takes a list of starting paths, and a pattern like this: > > pattern = { >InGlob('Test/**'):{ > MatchRemove('DS_Store'):[], >NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >MatchAdd('alphaID_','alpha_found'):[], > InDir('alphaID_'):{ >NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >InDir('betaID_'):{ >NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >MatchAdd('gammaID_','gamma_found'):[] > > so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary > where: > > dict['gamma_found'] = [list of paths that matched] (i.e. > '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') > dict['warning'] = [list of paths that failed to match] (ie. > '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') > > Since some of these volumes are on network shares I also wanted to > parallelize this so that it would not block on IO. I started the > parallelization by using multiprocessing.Pool and got it to work if I ran the > fsparser from the interpreter. It ran in *much* less time and produced > correct output that matched the non-parallelized version. The problem begins > if I then try to use the parallelized function from within the code. > > For example I wrote a class whose instances are created around valid FS > paths, that are cached to reduce expensive FS lookups. > > class Experiment(object): > > SlidePaths = None > > @classmethod >def getSlidePaths(cls): > if cls.SlidePaths == None: > cls.SlidePaths = fsparser(['/Volumes/**'],pattern) > return cls.SlidePaths > > @classmethod > def lookupPathWithGammaID(cls,id): >paths = cls.getSlidePaths() >... >return paths[selected] > > @classmethod >def fromGamaID(cls,id): > path = cls.lookupPathWithGammaID(id) >return cls(path) > > def __init__(self,path) > self.Path = path > ... > > ... > > If I do the following from the interpreter it works: > from experiment import Experiment expt = Experiment.fromGammaID(10102) > > but if I write a script called test.py: > > from experiment import Experiment > expt1 = Experiment.fromGammaID(10102) > expt2 = Experiment.fromGammaID(10103) > comparison = expt1.compareTo(expt2) > > it fails, if I try to import it or run it from bash prompt: > from test import comparison (hangs forever) > $ python test.py (hangs forever) > > I would really like some help trying to figure this out... I thought it > should work easily since all the spawned processes don't share data or state > (their results are merged in the main thread). The classes used in the > pattern are also simple python objects (use python primitives). > > > These are the main functions: > > def mapAction(pool,paths,action): >merge = {'next':[]} >for result in pool.map(action,paths): >if result == None: >continue >merge = mergeDicts(merge,result) >return merge > > > def mergeDicts(d1,d2): >for key in d2: >if key not in d1: >d1[key] = d2[key] >else: >d1[key] += d2[key] >return d1 > > > def evalFSPattern(paths,pattern): >pool = Pool(10) >results = {} >for action in pattern: >tomerge1 = mapAction(pool,paths,action) >tomerge2 = evalFSPattern(tomerge1['next'],pattern[action]) >del tomerge1['next'] >results = mergeDicts(results,tomerge1) >results = mergeDicts(results,tomerge2) >return results > > the classes used in the pattern (InGlob,NoMatchAdd,etc.) are callable classes > that take a single parameter (a path) and return a dict result or None which > makes them trivial to adapt to Pool.map. > > Note if I change the mapAction function to: > > def mapAction(pool,paths,action): >merge = {'next':[]} >for path in paths: > result = action(path) > if result == None: >continue >merge = mergeDicts(merge,result) >return merge > > everything works just fine. > > > Thanks. > > > -- > http://mail.python.org/mailman/listinfo/pytho
Re: Which is the best book to learn python
On 2011-01-26 01:43 , Luis M. González wrote: > On Jan 24, 2:09 pm, santosh hs wrote: >> i am beginner to python please tell me which is the best available >> reference for beginner to start from novice > > If you are a complete beginner to programming, I suggest start with a > tutorial such as "A Byte of Python" (google this). > I learned my first steps with Josh Cogliati's "Non-Programmers > Tutorial For Python" > http://www.oopweb.com/Python/Documents/easytut/VolumeFrames.html Josh moved this tutorial to Wikibooks some years ago, where it has been improved since then. Today there are two versions, one for Python 2.x and one for Python 3: http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_2.6 http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python_3 I have used it to introduce people to programming with very good results. If you want to get the maximum out of Lutz & Asher's "Learning Python", which is a very good book as well, you should have programmed in some way before. Ben -- http://mail.python.org/mailman/listinfo/python-list
Pickling/Unpickling python Exceptions
Hi all, I'm migrating code from python 2.4 to python 2.6 and I've got into troubles with pickling/unpickling python Exceptions. The following code works fine in 2.4 but not in 2.6. See Exception1 example I have found on python mail list similar problem http://mail.python.org/pipermail/python-list/2009-December/1228773.html They recommend to use __reduce__. But this does not help as I'm getting different Exception class after pickle See Exception_with_reduce example I also have found possible solution to this problem here http://bugs.python.org/issue1692335 As a workaround they propose to pass Exception arguments into base class See Exception2 example But there is another problem. Constructor is called 2 times which is not acceptable to me. Could you please advice on the solution? -- test program -- import cPickle class Exception1(Exception): def __init__(self,arg1): print "constructor called" Exception.__init__(self) class Exception2(Exception): def __init__(self,arg1): print "constructor called" Exception.__init__(self,arg1) class Exception_with_reduce(Exception): def __reduce__(self): try: getnewargs = self.__getnewargs__ except AttributeError: newargs = (self.__class__,) else: newargs = (self.__class__,) + getnewargs() try: getstate = self.__getstate__ except AttributeError: state = self.__dict__ else: state = getstate() return (Exception, newargs, state) def __init__(self,arg1): print "constructor called" Exception.__init__(self,arg1) def test(E,args): try: print ">>",E.__name__ e = E(*args) print "- pickling" s = cPickle.dumps(e) print "- unpickling" e = cPickle.loads(s) if E != e.__class__: print "! failed: expected %s, got %s"%(E.__name__,e.__class__.__name__) except Exception, e: print "! failed:",e print "\ finished" print import os if os.path.isfile("/home/ast1/blabla"): try: s = open("/home/ast1/blabla","r").read() e = cPickle.loads(s) print e.__class__ except Exception, e: print "error:",e test(Exception1,[1]) test(Exception2,[1]) test(Exception_with_reduce,[1]) -- -- run results on python 2.6: -- constructor called >> Exception1 constructor called - pickling - unpickling ! failed: ('__init__() takes exactly 2 arguments (1 given)', , ()) \ finished >> Exception2 constructor called - pickling - unpickling constructor called \ finished >> Exception_with_reduce constructor called - pickling - unpickling ! failed: expected Exception_with_reduce, got Exception \ finished -- run results on python 2.4: -- __main__.Exception2 >> Exception1 constructor called - pickling - unpickling \ finished >> Exception2 constructor called - pickling - unpickling \ finished >> Exception_with_reduce constructor called - pickling - unpickling \ finished -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/26/11 11:02 PM, Octavian Rasnita wrote: > As we all know, Python doesn't care too much about maintaining a > backward compatibility What? Nonsense. There are strict compatibility requirements. There was a one-time break with these; 2.x->3.x -- but that's it. It may never happen again. If another happens, its years down the road. If ever. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is the best book to learn python
I am very new to object oriented concept, so I need to learn everything frm basic, Will the above books fulfill My need On Monday, January 24, 2011, Jean-Michel Pichavant wrote: > santosh hs wrote: > > Hi All, > i am beginner to python please tell me which is the best available > reference for beginner to start from novice > > > > Hi, > > You could have searched the archive, this question was raised many times. > > http://wiki.python.org/moin/IntroductoryBooks > > I read "Learning Python" when I started. Since it's the only one I read I > cannot tell you which one is the best (if there is). > Python is easy to learn, I'm not sure it's possible to write a bad book about > it. > > JM > > -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Littlefield, Tyler" > >but what's wrong is that Python promotes a GUI which is not accessible > by including it as a default GUI. > You seem to have overlooked this multiple times and instead decided to > shove words in my mouth and continue on your line of selfishness which > is justified apparently now by the fact that you are ESL. I have > mentioned many, many times that we work to make TKInter accessible; it > is something I plan to start working on this weekend. But rather than > that, you seem to still want to switch gui libraries in python, which I > might add, will not happen over night, nor will the accessibilifying (my > new word) TKInter. It's a process that will take time. So, I ask since > you keep jumping around this point, what is wrong with fixing TKInter? Hi Tyler, Nothing is wrong with adding accessibility to Tkinter. It is really great. What's wrong is that it is not available now and I believe only what I can see, because only what can be used now can be helpful. If Tkinter will be accessible in the future it will be very great, but it will be only in that moment. It is not now. Now we have just your promise that you will try to make Tk accessible but I think that you agree that for the moment this has no value for those who need accessibility. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Littlefield, Tyler" > >It doesn't support a good voice synthesizer like Eloquence or IBM Via > voice > Eloq is an add-on, but it does support it. If you are saying this, it means that you haven't used it for a long time, or you just heard about it by searching on the web. Eloq is supported, but only as an unofficial hack because the NVDA developers pretend that it is illegally to offer support for Eloquence. They said that Nuance ask them to remove that support from NVDA, and as a consequence, the support for Eloquence was removed and it is harder to find the NVDA Eloquence driver from unofficial sources (and that unofficial support is not the same under all versions of NVDA...) > >but only eSpeak which sounds horrible > That's your personal preference. Plenty use and like ESpeak. That's my personal preference and the preference of all the blind people I know in my country with only one or two exceptions. (If you'd know Romanian, I could give you the address of a forum to ask there if you don't believe me.) And note that Eloquence doesn't support my native language, but eSpeak does it, however they still don't like eSpeak. Why do you think we don't like it? Because it is so good? > >it doesn't have a scripting language ready to use as JAWS and Window > Eyes do, > Scripting is done in Python, (no, not some native scripting language), > and are done as modules. You write your script in python, and off you > go. Problem solved. Have you done such a script for NVDA? I've created a sample script in Python that uses the COM interface and I have asked on the NVDA mailing list and on NVDA-dev mailing list if I can use it, but NVDA doesn't offer that feature yet. And I was saying that "NVDA doesn't have a scripting language ready to use". The scripting language can be Python, but it should accept a scripting code, easy to install with a copy/paste, not an NVDA patch. That means "ready to use". >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. Tyler, you are a Linux and Mac user and you search with Google and try to explain how many things you know about NVDA, but it is obviously that what JAWS can offer NVDA can't. That flat review can be used to read some things from the screen, and they say that it might also show the coordinates of the objects, however unlike JAWS, it can't show the coordinates of each character on the screen, and this is important by someone who is totally blind for checking the positions of different text elements on a web page, or in a desktop app. But NVDA can't be used for that. > the only issue here is you promoting the most "widely used screen reader," > because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. Tyler, the other list members sustain you because you are also against changing something in order to improve the accessibility and just promise that you will make Tk accessible, and I am sure they won't say anything about your atitude, but your atitude really sucks because it is obviously that you don't know many things about NVDA, and you haven't tried it, you even show that you don't care about the most used OS, you use Mac and Linux, but keep telling me that I don't know about it although I am an NVDA user for a long time. And all these useless phrases are just for answering to your useless hijack of the discussion, because we are not talking about NVDA here, but about the lack of accessibility in Tk-based applications, and Tk is as inaccessible in JAWS as in NVDA, Window Eyes or other screen readers, so it doesn't matter what screen reader we use for testing that inaccessibility. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 3:35 am, rantingrick wrote: A certain small subset of any group will always be emotionally driven. However we should not concern ourselves with this sort of non- objectivity. So, would this be like when rr disqualified himself by demanding posters have at least a 120 IQ? ;) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Terry Reedy wrote: > Tk itself is purely a gui package -- abstract widgits, geometry placers > to make them visible, and an event system to make them active. But it > does have the baggage of needing tcl included. About a decade ago, some > people had the idea of removing the tcl dependency, but nothing seems to > have come of that. For some people, the tcl baggage is reason enough to > be rid of tk. Thanks for raising this point. While I don't want to exhaustively respond to this, I would like to raise a few important points. 1. The performance issues of having Tk use Tcl are negligible; the bulk of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very fast nowadays, using all the usual techniques that modern dynamic languages use. 2. Some people do have moral/purity objections to including Tcl, and while I understand where the sentiment comes from, I think there are few solid engineering reasons for this. 3. Removing Tcl from Tk makes keeping up with changes in Tk very difficult. The Perl people found this out; Perl/Tk extracted Tcl, and as a result remained using a 10 year old version of Tk because upgrading would have been too painful. The newer Perl binding (Tkx) is in fact a ridiculously thin binding over the Tcl API, and makes keeping up to date with the newest Tk changes trivial, often requiring no code changes in the Perl binding. If anyone does have questions, comments or concerns about Python including a Tcl interpreter to use Tk, I'd be happy to try to explain or address them. Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 2011-01-27, Octavian Rasnita wrote: > Yes you might be right. It is just my way of communicating and it > might be too direct and some people might not like it. Too direct is putting it mildly. > I always consider the expressions like "How do you do" as having > absolutely no value, because they are just nice expressions made for > easing the communication, So you're saying that you don't see any value in easing communication, nor presumably in communication itself? > but yes, most people seem to like them and don't like to discuss > directly about the sensible problems. If you don't care about communicating with others, then being civil probably does have no value (except for keeping a job or being avoiding being beaten up on the playground). If you want to communicate (especially if you want somebody else to _do_ something), then being civil and following normal social rules (etiquette) is _very_ valuable. Without it the only thing you accomplish is to turn people against you and whatever you're saying. There is no inherent "value" in driving on the right side of the road vs. the left. However, there is a lot of value in driving on the side of road that others expect you to. I'd tell you to try driving on the other side of the road sometime to see how "easing communication" can be valuable, but I'm afraid you'd try it... -- Grant Edwards grant.b.edwardsYow! I'm RELIGIOUS!! at I love a man with gmail.coma HAIRPIECE!! Equip me with MISSILES!! -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 2011-01-27, Octavian Rasnita wrote: > From: "Grant Edwards" >> And, based on your behavior, you apparently don't like convincing >> others or advancing the cause of accessibility. It seems you prefer to >> annoy and alienate others. > >>From what I said, what was annoying? > >>> I don't want to convince anyone, but I just want to inform the others >>> and let them know if they are doing something not recommended. >> >> IOW, you don't really care about increasing accessibility, you just >> want to hear the sound of your own voice as you shout into the wind. > > Where have you seen that I don't care about accessibility? You said that you don't care about convincing anybody either that accessibility is import or about convincing anybody to do anything about it. To me that means you don't care about accessiblity. >> People will not separate your personality from the cause you espouse. > > Wow! that's really bad. It's less than ideal, but it the way people are. Is that a surprise to you? > I thought that I might find here people that might have something > against my opinions, that is very normal, that's why we are > discussing, but I didn't think that I will also find people that will > have something against me, just because of my opinions. That's not what I said. I said that if you state your opininions in a rude, insulting, or disrepectful manner, that will turn people against your opinions regardless of the inherent value of the actual opinions themselves. This should not be a surprise to anybody over the age of three. > I know people with different political opinions, with different > programming languages preferences, that like other kind of women, > that prefer other kkind of food, with whom I have often philosophical > debates often, but whith whom I can be a good friend and collaborator > and co-worker for some projects. That's not what we're talking about. We're not talking about your opinions on some unrelated topic. We're talking about the manner in which you express your opinions on this topic. >> You may not like it, but that's a fact. If you are in favor of XYZ, >> and act rude and insulting while espousing XYZ, people will react >> against not only you but _also_ XYZ. > > I know what you are reffering to. :-) > > And I was hoping that there won't be people that don't like me > personally for what I think about some things that have nothing > related to them personally. Again, it's not your beliefs about other tops that are causing problems for you. What's causing problems is the manner in which you are expressing your beliefs about this topic. > But I don't say that you are wrong. After some reactions on the list > I can say that you might be really right. -- Grant Edwards grant.b.edwardsYow! I would like to at urinate in an OVULAR, gmail.comporcelain pool -- -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 2011-01-27, Octavian Rasnita wrote: > From: Octavian, > >> If I understand your message, you are frustrated with Tkinter because >> it doesn't support accessability. >> >> In several messages on this thread I pointed out that Tkinter can >> easily be made accessable under Linux and Mac OS X. >> >> Rather than throw out Tkinter entirely, why not work with the community >> to make Tkinter accessable under Windows. > > > I am willing to help, but unfortunately I don't know neither TCL or C > nor the technical details about the accessibility standards that need > to be implemented. I am mainly a web/CLI programmer. A very important way to help would be to test accessibility features and post accurate, detailed, bug-reports. -- Grant Edwards grant.b.edwardsYow! I'm not available at for comment.. gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Need GUI pop-up to edit a (unicode ?) string
On 2011-01-27, Stephen Hansen wrote: > On 1/25/11 3:02 PM, rantingrick wrote: >> This is a major flaw in the design and i would be >> happy to fix the flaw. However our "friend" Fredrick decided to >> copyright the module to himself! What a jerk! Which is quite >> disgusting considering that Tkinter, and TclTk are completely open >> source! > > Uh. ... LOL. > > Copyright doesn't mean what you think it means. > > Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. > > In fact: everything that is "open source" is copyrighted. By > definition[* see footnote]. One (domestic US) exception would be open-source software written by an employee of the US federal government. Works produced by the US Government are not copyrighted under US domestic copyright law. Such works are copyrighted under international law (which is probably what the Python maintainers care about). -- Grant Edwards grant.b.edwardsYow! Wow! Look!! A stray at meatball!! Let's interview gmail.comit! -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Emile van Sebille" > On 1/26/2011 11:02 PM Octavian Rasnita said... > >> As we all know, Python doesn't care too much about maintaining a >> backward compatibility > > Where'd you get this idea? Between v2 and v3 yes, that was the intent. To be sincere I was thinking to the differences between Python 2 and 3. > But otherwise, I think there's another miscommunication behind this... It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. py2exe offers the following installation kits, depending on the Python version. If you know, please tell me why there are different packages for different versions of Python? py2exe-0.6.9.win32-py2.5.exe py2exe-0.6.9.win32-py2.4.exe py2exe-0.6.9.win32-py2.3.exe py2exe-0.6.9.win32-py2.6.exe py2exe-0.6.9.win32-py2.7.exe Thanks. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: "Littlefield, Tyler" > >We are talking about accessibility here. Are you saying that Tkinter > can be >recommended from the perspective of accessibility? > See my comment about shoving words in people's mouths; I did not hint, > nor did I come near saying that in that message. But you asked who says that Tkinter is not recommended. Everything that's not accessible is not recommended. Tkinter should be at most accepted because there is no better solution, at least for Python 3, not because it is the recommended solution. Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: help with multiprocessing pool
The code will be multi-platform. The OSXisms are there as an example, though I am developing on OS X machine. I've distilled my problem down to a simpler case, so hopefully that'll help troubleshoot. I have 2 files: test.py: -- from multiprocessing import Pool def square(x): return x*x def squares(numbers): pool = Pool(12) return pool.map(square,numbers) test2.py: -- from test import squares maxvalues = squares(range(3)) print maxvalues Now if I import squares into the interactive interpreter: from test import squares print squares(range(3)) I get the correct result, but if I try to import maxvalues from test2 the interactive interpreter python hangs. if I run the script from bash, though, it seems to run fine. I think it might have something to do with this note in the docs, though I am not sure how to use this information to fix my problem: Note: Functionality within this package requires that the __main__ method be importable by the children. This is covered inProgramming guidelines however it is worth pointing out here. This means that some examples, such as themultiprocessing.Pool examples will not work in the interactive interpreter. Thanks. On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: > > On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: > >> Hi all, >> >> I could really use some help with a problem I'm having. > > > Hiya Craig, > I don't know if I can help, but it's really difficult to do without a full > working example. > > Also, your code has several OS X-isms in it so I guess that's the platform > you're on. But in case you're on Windows, note that that platform requires > some extra care when using multiprocessing: > http://docs.python.org/library/multiprocessing.html#windows > > > Good luck > Philip > > >> I wrote a function that can take a pattern of actions and it apply it to the >> filesystem. >> It takes a list of starting paths, and a pattern like this: >> >> pattern = { >> InGlob('Test/**'):{ >> MatchRemove('DS_Store'):[], >> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >> MatchAdd('alphaID_','alpha_found'):[], >> InDir('alphaID_'):{ >> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >> InDir('betaID_'):{ >> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >> MatchAdd('gammaID_','gamma_found'):[] >> >> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a >> dictionary where: >> >> dict['gamma_found'] = [list of paths that matched] (i.e. >> '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >> dict['warning'] = [list of paths that failed to match] (ie. >> '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >> >> Since some of these volumes are on network shares I also wanted to >> parallelize this so that it would not block on IO. I started the >> parallelization by using multiprocessing.Pool and got it to work if I ran >> the fsparser from the interpreter. It ran in *much* less time and produced >> correct output that matched the non-parallelized version. The problem >> begins if I then try to use the parallelized function from within the code. >> >> For example I wrote a class whose instances are created around valid FS >> paths, that are cached to reduce expensive FS lookups. >> >> class Experiment(object): >> >> SlidePaths = None >> >> @classmethod >> def getSlidePaths(cls): >> if cls.SlidePaths == None: >> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >>return cls.SlidePaths >> >> @classmethod >> def lookupPathWithGammaID(cls,id): >> paths = cls.getSlidePaths() >> ... >> return paths[selected] >> >> @classmethod >> def fromGamaID(cls,id): >> path = cls.lookupPathWithGammaID(id) >> return cls(path) >> >> def __init__(self,path) >> self.Path = path >> ... >> >> ... >> >> If I do the following from the interpreter it works: >> > from experiment import Experiment > expt = Experiment.fromGammaID(10102) >> >> but if I write a script called test.py: >> >> from experiment import Experiment >> expt1 = Experiment.fromGammaID(10102) >> expt2 = Experiment.fromGammaID(10103) >> comparison = expt1.compareTo(expt2) >> >> it fails, if I try to import it or run it from bash prompt: >> > from test import comparison (hangs forever) >> $ python test.py (hangs forever) >> >> I would really like some help trying to figure this out... I thought it >> should work easily since all the spawned processes don't share data or state >> (their results are merged in the main thread). The classe
Re: WxPython versus Tkinter.
On 1/27/11 9:55 AM, Grant Edwards wrote: > On 2011-01-27, Octavian Rasnita wrote: >> From: "Grant Edwards" >>> People will not separate your personality from the cause you espouse. >> >> Wow! that's really bad. > > It's less than ideal, but it the way people are. > > Is that a surprise to you? Seriously. Octavian's attitude in this thread makes me want to go use Tkinter just to spite him. And I'm net-buds with Tyler, and I'm working on a project that I thought accessibility for the blind was very important for. But no more! Way to set the cause back, Octavian. :P You have -1 converts! -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ * Disclaimer: You are stupid if you think this is true. But seriously, Octavian makes it REALLY hard to continue caring about something that I actually cared about before and thought was important. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 1:28 am, "Octavian Rasnita" wrote: > From: "Brendan Simon (eTRIX)" > > > Since it seems the python motto is "Batteries included", then it would > > seem to me that wxPython is the natural fit as it also has "Batteries > > included" (e.g. accessibility, native look-n-feel, mature and evolving, > > can produce simple or complex gui programs, etc, etc). > > Yes Brendan, you are perfectly right, but unfortunately WxPython developers > don't want to have it included in the stdlib. [...] > But WxPython is their work and they decision is their. Actually we don't want "Robins wxPython" in the stdlib "as is" anyway. What we DO want is an abstraction API for the short term that plugs into Robin's wx. Then over the long term we will either convince him to create a better API OR just create our own wxPython directly from WxWidgets and mold it into the stdlib. So hinging on the argument of what one *single* man thinks is a non-starter. We all respect Robin however python is greater then me, then you, and yes, EVEN Guido van Rossum! Python belongs to the world now. And what is best for Python's community AS A WHOLE is what we should be concerned about. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
>Tyler, you are a Linux and Mac user and you search with Google and try to >explain how many things you know about NVDA, but it is obviously that what >JAWS 1) Because you, your crew, and your group on a specific forum doesn't like ESpeak doesn't disqualify an entire reader. The eloquence fixes are illegal to be packaged with NVDA, so you -need- to get a separate patch, yes. That doesn't mean it can't be done. As to me being a Linux and Mac user, that doesn't disqualify what I'm telling you either, because unlike your limitations, I don't just decide to only use one reader. I use Linux, Mac, and windows (windows more than both, actually). Yes, I'm giving you what I got from googling, because that's my way of telling you to do your homework before you start ranting about a reader you clearly know nothing of. The fact that it appears on google says a lot. At least to me, maybe it's something you haven't been able to comprehend. On 1/27/2011 10:22 AM, Octavian Rasnita wrote: From: "Littlefield, Tyler" It doesn't support a good voice synthesizer like Eloquence or IBM Via voice Eloq is an add-on, but it does support it. If you are saying this, it means that you haven't used it for a long time, or you just heard about it by searching on the web. Eloq is supported, but only as an unofficial hack because the NVDA developers pretend that it is illegally to offer support for Eloquence. They said that Nuance ask them to remove that support from NVDA, and as a consequence, the support for Eloquence was removed and it is harder to find the NVDA Eloquence driver from unofficial sources (and that unofficial support is not the same under all versions of NVDA...) but only eSpeak which sounds horrible That's your personal preference. Plenty use and like ESpeak. That's my personal preference and the preference of all the blind people I know in my country with only one or two exceptions. (If you'd know Romanian, I could give you the address of a forum to ask there if you don't believe me.) And note that Eloquence doesn't support my native language, but eSpeak does it, however they still don't like eSpeak. Why do you think we don't like it? Because it is so good? it doesn't have a scripting language ready to use as JAWS and Window Eyes do, Scripting is done in Python, (no, not some native scripting language), and are done as modules. You write your script in python, and off you go. Problem solved. Have you done such a script for NVDA? I've created a sample script in Python that uses the COM interface and I have asked on the NVDA mailing list and on NVDA-dev mailing list if I can use it, but NVDA doesn't offer that feature yet. And I was saying that "NVDA doesn't have a scripting language ready to use". The scripting language can be Python, but it should accept a scripting code, easy to install with a copy/paste, not an NVDA patch. That means "ready to use". >it doesn't offer the possibility of reading with the mouse cursor as JAWS does with its so called JAWS cursor, It's called flat review. Googling this term brings up a key reference at like the third or fourth result down. Tyler, you are a Linux and Mac user and you search with Google and try to explain how many things you know about NVDA, but it is obviously that what JAWS can offer NVDA can't. That flat review can be used to read some things from the screen, and they say that it might also show the coordinates of the objects, however unlike JAWS, it can't show the coordinates of each character on the screen, and this is important by someone who is totally blind for checking the positions of different text elements on a web page, or in a desktop app. But NVDA can't be used for that. the only issue here is you promoting the most "widely used screen reader," because it's what you use, and you not being able to use google and do your homework before you start talking about products you know nothing of. Tyler, the other list members sustain you because you are also against changing something in order to improve the accessibility and just promise that you will make Tk accessible, and I am sure they won't say anything about your atitude, but your atitude really sucks because it is obviously that you don't know many things about NVDA, and you haven't tried it, you even show that you don't care about the most used OS, you use Mac and Linux, but keep telling me that I don't know about it although I am an NVDA user for a long time. And all these useless phrases are just for answering to your useless hijack of the discussion, because we are not talking about NVDA here, but about the lack of accessibility in Tk-based applications, and Tk is as inaccessible in JAWS as in NVDA, Window Eyes or other screen readers, so it doesn't matter what screen reader we use for testing that inaccessibility. Octavian -- Thanks, Ty -- http://mail.python.org/mailman/listinfo/python-list
Re: Need GUI pop-up to edit a (unicode ?) string
On 1/27/11 10:04 AM, Grant Edwards wrote: > On 2011-01-27, Stephen Hansen wrote: >> On 1/25/11 3:02 PM, rantingrick wrote: >>> This is a major flaw in the design and i would be >>> happy to fix the flaw. However our "friend" Fredrick decided to >>> copyright the module to himself! What a jerk! Which is quite >>> disgusting considering that Tkinter, and TclTk are completely open >>> source! >> >> Uh. ... LOL. >> >> Copyright doesn't mean what you think it means. >> >> Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. >> >> In fact: everything that is "open source" is copyrighted. By >> definition[* see footnote]. > > One (domestic US) exception would be open-source software written by > an employee of the US federal government. Works produced by the US > Government are not copyrighted under US domestic copyright law. Such > works are copyrighted under international law (which is probably what > the Python maintainers care about). I've actually wondered a bit about that: but the only open source software that I'm aware of that's been government-adjacent has ended up being written/owned by some University or joint venture funded by a government agency -- it didn't fall into the public domain category of content created directly by the federal government. Are you aware of any code out there that is? Just curious. I'm not arguing that the exception doesn't exist or anything. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
lxml.etree, namespaces and element insertion
The other day i was processing an xml tree using lxml.etree. That tree contained a namespace. During that processing i inserted an element. Later on i tried to find that element using xpath. And to my suprise that element was not found! Maybe my suprise is just the result of my marginal knowledge about xml namespaces. After some examination i found out that the reason for not finding the element was that i did not supply a namespace when inserting the element. This behavior can be reproduced be the folowing code: from lxml import etree import sys print "Python:", sys.version_info print "lxml.etree:", etree.__version__ string_data = [ '', '', '' ] trees = map(etree.fromstring, string_data) print "\n Before insertion:" for t in trees: print etree.tostring(t, pretty_print=True) trees[1].insert(-1, etree.Element("sometag")) trees[2].insert(-1, etree.Element("{NameSpace.com}sometag", nsmap={None : "NameSpace.com"})) print "\n After insertion:" for t in trees: print etree.tostring(t, pretty_print=True) print "\n Using xpath:" for t in trees: elements = t.xpath("//ns:sometag", namespaces={'ns': 'NameSpace.com'}) print len(elements), if elements: print [e.tag for e in elements] else: print elements Its output is: Python: (2, 6, 6, 'final', 0) lxml.etree: 2.2.8 Before insertion: After insertion: Using xpath: 1 ['{NameSpace.com}sometag'] 0 [] 1 ['{NameSpace.com}sometag'] So my suprise was that in the second case the xpath result is an empty list. I have two questions on this: - Is what i am seeing expected behavior? - How am i supposed to detect a missing namespace, if there are no differences in the serialized representation? (That's what i initially used to debug the problem.) -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 2:13 am, "Octavian Rasnita" wrote: > > You may not like it, but that's a fact. If you are in favor of XYZ, > > and act rude and insulting while espousing XYZ, people will react > > against not only you but _also_ XYZ. > > I know what you are reffering to. :-) > And I was hoping that there won't be people that don't like me personally > for what I think about some things that have nothing related to them > personally. > But I don't say that you are wrong. After some reactions on the list I can > say that you might be really right. Sadly many people lack the ability to make objective decisions. They let emotion get in the way of good choices. People should put aside petty differences and make judgments solely on facts. Yes, you can disagree with someone passionately on one subject and yet agree passionately on another. Case in point: If Guido and myself sit down for a political discussion we would probably poke each others eyes out in a very short time. However i still hold a great respect for Guido and that will never change. Now matter how much i may disagree with him on certain matters, he still forged the path and brought us Python. I will never think harsh of him just because we do not agree on everything. I believe in freedom of speech, freedom of expression, and freedom of ideas. Some of you out there need to take this advice yourselves. Stop hating those who may thing differently because one day you may find out your position was wrong. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 2:17 am, "Octavian Rasnita" wrote: > From: "Littlefield, Tyler" [...] > > Then when that fails, you try cramming > > words in people's mouth to make them feel like they kick puppies, and to > > bring everyone else to this same conclusion. Tyler no one can *make* you *feel* like anything unless you let them. Actually i think what you are *feeling* now is guilt. The human conscience has a way of catching up with us when we exaggerate too much. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 10:09 AM Octavian Rasnita said... From: "Emile van Sebille" On 1/26/2011 11:02 PM Octavian Rasnita said... As we all know, Python doesn't care too much about maintaining a backward compatibility Where'd you get this idea? Between v2 and v3 yes, that was the intent. To be sincere I was thinking to the differences between Python 2 and 3. But otherwise, I think there's another miscommunication behind this... It might be true, however I have seen some modules that say that are ment for Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these versions also. Yes - but don't confuse forward compatibility (which means programs you write today in the current version will work on the prior versions) with backward compatibility (which means programs written for earlier versions will run under newer versions) I suspect that a lot of python 1.x code will work just fine under 2.x just as most 2.n will work under 2.m (where m>n). There are few exceptions, and those mostly in the standard library. I recall only getting stung once (something to do with passing in a tuple instead of two parameters in one or another imported module). Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 26, 1:16 pm, Alexander Kapps wrote: > Please don't use the lower Linux user percentage as an argument > here. If you follow that path further, you would need to agree that > it's only an "insignificant" percent of people who need a screen > reader, so why bother? Please don't use the lower accessibility percentage to prop up the low Linux percentage in an attempt to win your argument. Because healthy Linux users ARE NOT equal to handicapped people! And let's just get to the real point of this statement... This argument stems from me saying that Lunux users should stop complaining about downloading gtk to use wxPython because they use a non-hand- holding OS. And now you attempt to compare yourself to handicapped people in a veiled way so we feel sorry for you? Well it worked! I DO feel sorry for you. Congratulations! -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
> It might be true, however I have seen some modules that say that are ment for > Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these > versions also. Python cares *a lot* about maintaining backward compatibiilty between all major versions. This is so true that I managed to use a unique code base for pyftpdlib which supports python from 2.3 to 2.7. Same for psutil which covers versions from 2.4 to 3.2 by using a unique code base! > It might be true, however I have seen some modules that say that are ment for > Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these > versions also. Usually the differences between one version and another rely on *new features* only. One might decide to target a module only for a certain version of the 2.x serie because that certain version introduced a new functionnality which was not available before (silly example http://docs.python.org/library/os.html#os.initgroups ). All the other functionnalities are likely to remain the same and fully backward compatible. > py2exe offers the following installation kits, depending on the Python > version. If you know, please tell me why there are different packages for > different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe That's a different story: those are pre-compiled binaries which are generated from a *unique* source code which support all those versions. If you have a compiler you can install pywin32 extension by using any Python version. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/27 Octavian Rasnita : > From: "Emile van Sebille" >> On 1/26/2011 11:02 PM Octavian Rasnita said... >> >>> As we all know, Python doesn't care too much about maintaining a >>> backward compatibility >> >> Where'd you get this idea? Between v2 and v3 yes, that was the intent. > > To be sincere I was thinking to the differences between Python 2 and 3. > >> But otherwise, I think there's another miscommunication behind this... > > It might be true, however I have seen some modules that say that are ment for > Python 2.5, for 2.6 or for 2.7, so there seem to be differences between these > versions also. > > py2exe offers the following installation kits, depending on the Python > version. If you know, please tell me why there are different packages for > different versions of Python? > > py2exe-0.6.9.win32-py2.5.exe > py2exe-0.6.9.win32-py2.4.exe > py2exe-0.6.9.win32-py2.3.exe > py2exe-0.6.9.win32-py2.6.exe > py2exe-0.6.9.win32-py2.7.exe > > Thanks. > > Octavian > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: help with multiprocessing pool
On Jan 27, 2011, at 1:12 PM, Craig Yoshioka wrote: > The code will be multi-platform. The OSXisms are there as an example, though > I am developing on OS X machine. > > I've distilled my problem down to a simpler case, so hopefully that'll help > troubleshoot. > > I have 2 files: > > test.py: > -- > from multiprocessing import Pool > > def square(x): >return x*x > > def squares(numbers): > pool = Pool(12) > return pool.map(square,numbers) > > > test2.py: > -- > from test import squares > > maxvalues = squares(range(3)) > print maxvalues > > > > Now if I import squares into the interactive interpreter: > > from test import squares > print squares(range(3)) > > I get the correct result, but if I try to import maxvalues from test2 the > interactive interpreter python hangs. > if I run the script from bash, though, it seems to run fine. The short, complete example is much more useful, but it sounds like it demonstrates a different problem than you first described. Your first posting said that your code worked in the interpreter but failed when run from the command line. This code has the opposite problem. Correct? > I think it might have something to do with this note in the docs, though I am > not sure how to use this information to fix my problem: > > Note: Functionality within this package requires that the __main__ method be > importable by the children. This is covered inProgramming guidelines however > it is worth pointing out here. This means that some examples, such as > themultiprocessing.Pool examples will not work in the interactive interpreter. I suspect this is the problem with the demo above. Your original code ran fine in the interpreter, though, correct? bye Philip > > On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: > >> >> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: >> >>> Hi all, >>> >>> I could really use some help with a problem I'm having. >> >> >> Hiya Craig, >> I don't know if I can help, but it's really difficult to do without a full >> working example. >> >> Also, your code has several OS X-isms in it so I guess that's the platform >> you're on. But in case you're on Windows, note that that platform requires >> some extra care when using multiprocessing: >> http://docs.python.org/library/multiprocessing.html#windows >> >> >> Good luck >> Philip >> >> >>> I wrote a function that can take a pattern of actions and it apply it to >>> the filesystem. >>> It takes a list of starting paths, and a pattern like this: >>> >>> pattern = { >>> InGlob('Test/**'):{ >>> MatchRemove('DS_Store'):[], >>> NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], >>> MatchAdd('alphaID_','alpha_found'):[], >>> InDir('alphaID_'):{ >>> NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], >>> InDir('betaID_'):{ >>> NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], >>> MatchAdd('gammaID_','gamma_found'):[] >>> >>> so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a >>> dictionary where: >>> >>> dict['gamma_found'] = [list of paths that matched] (i.e. >>> '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') >>> dict['warning'] = [list of paths that failed to match] (ie. >>> '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') >>> >>> Since some of these volumes are on network shares I also wanted to >>> parallelize this so that it would not block on IO. I started the >>> parallelization by using multiprocessing.Pool and got it to work if I ran >>> the fsparser from the interpreter. It ran in *much* less time and produced >>> correct output that matched the non-parallelized version. The problem >>> begins if I then try to use the parallelized function from within the code. >>> >>> For example I wrote a class whose instances are created around valid FS >>> paths, that are cached to reduce expensive FS lookups. >>> >>> class Experiment(object): >>> >>> SlidePaths = None >>> >>> @classmethod >>> def getSlidePaths(cls): >>>if cls.SlidePaths == None: >>> cls.SlidePaths = fsparser(['/Volumes/**'],pattern) >>> return cls.SlidePaths >>> >>> @classmethod >>> def lookupPathWithGammaID(cls,id): >>> paths = cls.getSlidePaths() >>> ... >>> return paths[selected] >>> >>> @classmethod >>> def fromGamaID(cls,id): >>> path = cls.lookupPathWithGammaID(id) >>> return cls(path) >>> >>> def __init__(self,path) >>> self.Path = path >>> ... >>> >>> ... >>> >>> If I do the following from the interpreter it works: >>> >> from experiment import Experiment >> expt = Experiment.fro
Re: WxPython versus Tkinter.
>* Disclaimer: You are stupid if you think this is true. But seriously, >Octavian makes it REALLY hard to continue caring about something that I >actually cared about before and thought was important. People like Octavian do that. Sadly, it is one of the things holding the blind community back. I hope that with my arguments (for those that didn't just toss everything related to this thread), I have been able to get people to see a little differently and not consider Octavian as the voice for us all. I am by no means the guru with accessibility, but I can boast having worked with all three platforms (and now IOS) that were mentioned in this thread in terms of accessibility. If someone would like to make an app more accessible or anything the like, I would love to give comments and feedback. -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is the best book to learn python
santosh hs wrote: I am very new to object oriented concept, so I need to learn everything frm basic, Will the above books fulfill My need read this http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm and stop when they start to talk about VBscript :) JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Need GUI pop-up to edit a (unicode ?) string
On 2011-01-27, Stephen Hansen wrote: > On 1/27/11 10:04 AM, Grant Edwards wrote: >> On 2011-01-27, Stephen Hansen wrote: >> >>> In fact: everything that is "open source" is copyrighted. By >>> definition[* see footnote]. >> >> One (domestic US) exception would be open-source software written by >> an employee of the US federal government. Works produced by the US >> Government are not copyrighted under US domestic copyright law. Such >> works are copyrighted under international law (which is probably what >> the Python maintainers care about). > > I've actually wondered a bit about that: but the only open source > software that I'm aware of that's been government-adjacent has ended > up being written/owned by some University or joint venture funded by > a government agency -- it didn't fall into the public domain category > of content created directly by the federal government. That seems to be the usual case. > Are you aware of any code out there that is? Just curious. I'm not > arguing that the exception doesn't exist or anything. No, I can't point to anything significant or recent. I have vague memories of stuff from a long time ago (back when open-source software travelled hand-to-hand on DECUS tapes) written by people at NOAA or USGS that was copyright-free. -- Grant Edwards grant.b.edwardsYow! RELATIVES!! at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 11:47 am, Grant Edwards wrote: > On 2011-01-27, Octavian Rasnita wrote: > If you don't care about communicating with others, then being civil > probably does have no value (except for keeping a job or being > avoiding being beaten up on the playground). If you want to > communicate (especially if you want somebody else to _do_ something), > then being civil and following normal social rules (etiquette) is > _very_ valuable. Without it the only thing you accomplish is to turn > people against you and whatever you're saying. When has Octavian been uncivil? This lecture of Octavian is ludicris! > There is no inherent "value" in driving on the right side of the road > vs. the left. However, there is a lot of value in driving on the side > of road that others expect you to. I'd tell you to try driving on the > other side of the road sometime to see how "easing communication" can > be valuable, but I'm afraid you'd try it... So i get it. When Ocatavian agrees with YOU he will be driving on the "right" side of the road. Until then, he is breaking the law and could cause a head on collision that could kill people. Wow good thing you were here to warn him of his "illegal" position and set him strait! You are such a friendly totalitarian, how do you keep a strait face -- Col. Hans Landa? -- http://mail.python.org/mailman/listinfo/python-list
Re: Which is the best book to learn python
On Jan 27, 3:43 pm, Jean-Michel Pichavant wrote: > santosh hs wrote: > > I am very new to object oriented concept, so I need to learn > > everything frm basic, Will the above books fulfill > > My need > > read thishttp://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm > > and stop when they start to talk about VBscript :) > > JM I strongly second this suggestion. Alan Gauld's example of a banking application was just what I needed to finally understand object oriented programming. This is how my head made the "click". Luis -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
On Wed, Jan 26, 2011 at 7:23 PM, Daniel Urban wrote: >> That's just what I'd like and I suppose can't be currently done with >> current ABC, PyProtocols or zope.interface implementations, right? > > It can. With __instancecheck__ you can override isinstance. It is > possible (for example) to write a subclass of abc.ABCMeta, which > extends __instancecheck__ to use an _instancehook classmethod > similarly to __subclasshook__. Then in your MyInterface class you can > implement _instancehook to check for methods/signatures/whatever you > want. Yes, __instancecheck__ could be used as an alternative hook with respect to maybe_implemented_by(), but there's no such logic for signature checking. That's a minor detail, I think. -- Alan Franzoni -- contact me at public@[mysurname].eu -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/11 10:11 AM, rantingrick wrote: > On Jan 27, 1:28 am, "Octavian Rasnita" wrote: >> But WxPython is their work and they decision is their. > Actually we The word "we" does not mean what you think it means. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote: > Yes, __instancecheck__ could be used as an alternative hook with > respect to maybe_implemented_by(), but there's no such logic for > signature checking. That's a minor detail, I think. On the contrary, now that I double checked, it can't be used that way; I don't want to modify the object I'm testing (it could be a third party object) nor I want to force it to be "registered" as a certain ABC; so __instancecheck__() is just useless here. -- Alan Franzoni -- contact me at public@[mysurname].eu -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 11:45 pm, rantingrick wrote: > > When has Octavian been uncivil? This lecture of Octavian is ludicris! > You are such a friendly totalitarian, how do you keep a strait face -- > Col. Hans Landa? And this mutual 'support' between Octavian and Ranter is ludicris(sic) Its quite clear to everyone here that -- RR has no interest in accessibility and is using it only for brownie points -- Octavian has no interest in a 21st century snazzy-looking toolkit which he cant see You guys would do yourselves a favor by forgetting about wx and getting your hands dirty with tkinter: - Octavian to (help) make it accessible - RR to make it look modern -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml.etree, namespaces and element insertion
hein, 27.01.2011 19:16: The other day i was processing an xml tree using lxml.etree. That tree contained a namespace. During that processing i inserted an element. Later on i tried to find that element using xpath. And to my suprise that element was not found! Maybe my suprise is just the result of my marginal knowledge about xml namespaces. After some examination i found out that the reason for not finding the element was that i did not supply a namespace when inserting the element. [...] I have two questions on this: - Is what i am seeing expected behavior? Yes. It's a common problem for new users, though. - How am i supposed to detect a missing namespace, if there are no differences in the serialized representation? (That's what i initially used to debug the problem.) This is a known problem of XML namespaces, which were only designed as an add-on to XML after the fact. The only advice I can give: be careful with the default namespace. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 12:31 PM, Mark Roseman wrote: Terry Reedy wrote: Tk itself is purely a gui package -- abstract widgits, geometry placers to make them visible, and an event system to make them active. But it does have the baggage of needing tcl included. About a decade ago, some people had the idea of removing the tcl dependency, but nothing seems to have come of that. For some people, the tcl baggage is reason enough to be rid of tk. Thanks for raising this point. While I don't want to exhaustively respond to this, I would like to raise a few important points. 1. The performance issues of having Tk use Tcl are negligible; the bulk of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very fast nowadays, using all the usual techniques that modern dynamic languages use. I have the impression that tcl is mostly used in initial setup and configuration, as opposed to repetitive drawing to the screen. But I do not really know. 2. Some people do have moral/purity objections to including Tcl, and while I understand where the sentiment comes from, I think there are few solid engineering reasons for this. There are two types of objections which have much less force now than a decade ago. One is the size issue. A tcl-less tk would presumably be smaller and thus add less to the Window distribution. The other is that tcl and Python were once seen as competing scripting languages, so why promote the competitor? Well, if there really was a contest, Python won. 3. Removing Tcl from Tk makes keeping up with changes in Tk very difficult. The Perl people found this out; Perl/Tk extracted Tcl, and as a result remained using a 10 year old version of Tk because upgrading would have been too painful. The newer Perl binding (Tkx) is in fact a ridiculously thin binding over the Tcl API, and makes keeping up to date with the newest Tk changes trivial, often requiring no code changes in the Perl binding. Good point. Python should (continue to) just use the latest tk from its maintainers. If *they* were to decouple it from tcl (unlikely, it seems), fine. If not, so be it ;-). If anyone does have questions, comments or concerns about Python including a Tcl interpreter to use Tk, I'd be happy to try to explain or address them. Thanks for the additional info. We need more of that. --- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 27.01.2011 19:33, rantingrick wrote: Please don't use the lower accessibility percentage to prop up the low Linux percentage in an attempt to win your argument. Because healthy Linux users ARE NOT equal to handicapped people! Please don't put words into my mouth, idiot. And read my complete post. Nobody compares Linux users with handicapped people. I equalize handicapped Linux users with handicapped Windows users. And like it or not, the number of Linux users (handicapped or not) is raising. Again read my complete post. And let's just get to the real point of this statement... This argument stems from me saying that Lunux users should stop complaining about downloading gtk to use wxPython because they use a non-hand- holding OS. Another example of your limited understanding. Do you really believe the problem lies in downloading dependencies? Hasn't somebody already explained that it's about development dependencies? And now you attempt to compare yourself to handicapped people in a veiled way so we feel sorry for you? Well it worked! I DO feel sorry for you. Congratulations! I'm entirely sure that you deliberately misunderstood me and now try to discredit me with putting this nonsense into my mouth. You are really a sad, disgusting asshole. Don't bother replying. I won't read. (How many more plonks will it take till you consider changing your behaviour?) -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
Alan Franzoni wrote: Hello, I'd like to have a system which lets me do certain actions if the duck-type of a certain objects matches what I expect, i.e. I'd like to have a formalization of what it's sometimes done through getattr() calls: if getattr(myobj, "somemethod", None) is not None: myobj.somemethod(somevalue) [...] I'd like to do a kind of runtime-check for signatures. Of course there couldn't be an absolute certainty of interface implementation, because a runtime dynamic proxy method (accepting *args and **kwargs in its signature, as an example) might just fool my signature check. When you signature check, do you mean counting the number of arguments, or actually checking argument types? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Terry Reedy wrote: > > 1. The performance issues of having Tk use Tcl are negligible; the bulk > > of Tk (code-wise and time-wise) are spent in C. Tcl itself is also very > > fast nowadays, using all the usual techniques that modern dynamic > > languages use. > > I have the impression that tcl is mostly used in initial setup and > configuration, as opposed to repetitive drawing to the screen. But I do > not really know. Tcl as a scripting language is used during some initialization things, used to invoke callbacks, and a few other non-performance critical areas. It sometimes helps to think of Tcl as a very powerful C library that happens to have a scripting language on top. :-) For example, there are C functions in the Tcl library that do things like string management, cross platform I/O, very efficient hash tables, dynamic lists, etc. that are used everywhere inside Tk. But none of those calls mean a trip through the Tcl interpreter per se. Every dynamic language would have similar internals of course, though with slight differences and different API's. Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 12:54 PM, Octavian Rasnita wrote: Everything that's not accessible is not recommended. By you. We get that. >Tkinter should be at most accepted because there is no better solution, As I said at the beginning of this thread, tkinter is currently the only option. What would have happened if there had been a real competitor when 3.0 was being developed? What would happen in the future if one were developed? I do not think anyone really knows. at least for Python 3, not because it is the recommended solution. AS far as I know, Guido has never recommended any particular gui and I believe he has avoided doing so when asked. He is happy that there are different choices. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
>Because healthy Linux users ARE NOT equal to handicapped people! O? I bet I could run circles around RR in the shell, any day. Why are you trying to promote accessibility for a group of people you consider not equal to a group of "healthy" people? -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 12:57 PM, Grant Edwards wrote: A very important way to help would be to test accessibility features and post accurate, detailed, bug-reports. For example: pygui pretty much uses native widgets on Windows and OX and gtk (I believe) on *nix. How is the accessibility of those widget sets *as accessed through pygui*? Is it different from the 'native' accessibility of each of those set? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 2:00 pm, Terry Reedy wrote: > AS far as I know, Guido has never recommended any particular gui and I > believe he has avoided doing so when asked. He is happy that there are > different choices. different choices OUTSIDE the stdlib. INSIDE the stdlib we have no choice. Just wanted to make that clear. -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml.etree, namespaces and element insertion
On 2011-01-27, hein wrote: > - How am i supposed to detect a missing namespace, if there > are no differences in the serialized representation? (That's > what i initially used to debug the problem.) lxml's pretty printer is at fault, as it emits unprefixed names whenever possible while serializing. For debugging, try using .dump instead. Hopefully that makes the error obvious. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
On Thu, Jan 27, 2011 at 8:58 PM, Ethan Furman wrote: > When you signature check, do you mean counting the number of arguments, or > actually checking argument types? In order to check for argument types I should either assume type annotation (python 3 only, optional) or parse the docstring for the method, which might not be available or be out of sync. I just want to check for method name, number and/or names of the arguments. It might not be trivial in python because the very same argument can be passed either as a positional or a kw argument, so def method1(self, a, b): ... def method1(self, c, d): ... could satisfy or not the very same interface, depending whether the args are passed as postional or kw. -- Alan Franzoni -- contact me at public@[mysurname].eu -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 2:00 pm, Terry Reedy wrote: > On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > > > Everything that's not accessible is not recommended. > > By you. We get that. > > >Tkinter should be at most accepted because there is no better solution, > > As I said at the beginning of this thread, tkinter is currently the only > option. What would have happened if there had been a real competitor > when 3.0 was being developed? What would happen in the future if one > were developed? I do not think anyone really knows. > > > at least for Python 3, not because it is the recommended solution. > > AS far as I know, Guido has never recommended any particular gui and I > believe he has avoided doing so when asked. Yes but his silence speaks louder than words. He is saying " While i won't defend Tkinter publicly, i won't promote any others as well". This is a standard response you'd expect from a politician. These types of questions avoid dealing with the elephant in the room. We can't just assume that Tkinter is best for Python just because "Guido" does not want to "ruffle" some features. Actually if you look back over the very few post where Guido did offer an argument for Tkinter you'll the find the argument to be very weak. And to make matters worse no one has the balls to question or argue Guido. Now whilst i greatly respect Guido i will not hesitate for one second to call him on weak arguments. Case in point: Just recently i posted one of Guido's such arguments in another thread and responded to the argument. The original thread was from roughly eight years ago. Yes this is how long it has been since Guido offered argument for Tkinter. Does he honestly think that the world has not changed significantly in eight years as to render Tkinter into legacy? Does he also want us to believe that the world has not changed dramatically in the last twenty years since Tkinter was introduced? I have yet to get a response for his weak argument eight years ago and i can expect we will hear nothing now. My point is this: If you (Guido) are going to offer weak arguments then you must answer challenges to these weak arguments with facts. So I now challenge Guido to inject a solid argument for keeping Tkinter and i challenge him now. Before the entire world we will hash this out once and for all. Just be aware Guido, that i will NOT be afraid to question your facts and present good arguments based on fact. If you *do* inject your opinion on this very important subject matter --and do so here in a public forum-- then i believe the community will take you more seriously. And *i* will take you more seriously. All of your subordinates are unable to challenge me. Will you answer the challenge Guido van Rossum? Will you? The community at large needs to know what Guido van Rossum thinks. You owe us that much Guido. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 12:47 PM rantingrick said... different choices OUTSIDE the stdlib. INSIDE the stdlib we have no choice. Just wanted to make that clear. Only when you restrict yourself to the artificial restriction of 'no third party downloads allowed -- python must supply the right choice for my application no matter what' On that basis, os's ought to come with your browser and editor of choice as choice is the domain of the environment - not the user. If you think anyone capable of writing a gui application is incapable and needs to be babysat to that degree, then we're all stupid. T'ain't so. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
On Jan 24, 2:13 am, Alan Franzoni wrote: > Hello, > I'd like to have a system which lets me do certain actions if the > duck-type of a certain objects matches what I expect, i.e. I'd like to > have a formalization of what it's sometimes done through getattr() > calls: > > if getattr(myobj, "somemethod", None) is not None: > myobj.somemethod(somevalue) > > The above approach is sometimes too naive, because a) clutters code > with many getattr calls and ifs b) I might want to check for multiple > attributes and c) only checks for the method name and not for the > method's signature. Write some kind of signature proxy to do it. class SomeSignature(object): def __init__(self,target): self.target = target def somemethod(self,value): if hasattr(self.target,"somemethod"): self.target.somemethod(value) SomeSignature(myobj).somemethod(somevalue) Generalizing the proxy to easily accommodate all kinds of signatures to your heart's delight left as an exercise (and it's likley to involve metaclass programming). > After looking at PyProtocols, zope.interface and python's own abc > module, I'm left with a doubt: does any behaviour-based "interface > testing" system exist for Python? Based on this thread, you have quite specific requirements, so it's doubtful someone else has implemented exactly what you want. And because it hasn't been mentioned in this thread yet--surprisingly-- many people in Python prefer the EAFP strategy, "Easier to Ask Forgiveness than Permission", that is, to just do it and handle the resulting exception: try: myobj.somemethod(somevalue) except AttributeError: # doesn't fit signature, so do nothing pass Personally, I have my doubts about the method in general. It's definitely preferrable in many cases (like opening a file, where it avoids a race condition) but for something like this I don't see it working out too well. But I'm just throwing it out there. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 3:19 pm, Emile van Sebille wrote: > On 1/27/2011 12:47 PM rantingrick said... > > > different choices OUTSIDE the stdlib. INSIDE the stdlib we have no > > choice. Just wanted to make that clear. > > Only when you restrict yourself to the artificial restriction of 'no > third party downloads allowed -- python must supply the right choice for > my application no matter what' Some people ARE in enviroments where they would like to add third party downloads but cannot. > On that basis, os's ought to come with your browser and editor of choice > as choice is the domain of the environment - not the user. Well then explain why Windows still ships with that god awful windows explorer? Tkinter IS Windows Explorer. Antiquated, legacy, bloatware. And it need to die! But this misses the entire point. We are not trying to please everyone because THAT would be impossible. What we are trying to do is keep Python relevant in the 21st century. Continuing to lug Tkinter around is killing Python's evolution. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 01/27/2011 04:10 PM, rantingrick wrote: > On Jan 27, 2:00 pm, Terry Reedy wrote: >> On 1/27/2011 12:54 PM, Octavian Rasnita wrote: >> >>> Everything that's not accessible is not recommended. >> >> By you. We get that. >> >> >Tkinter should be at most accepted because there is no better solution, >> >> As I said at the beginning of this thread, tkinter is currently the only >> option. What would have happened if there had been a real competitor >> when 3.0 was being developed? What would happen in the future if one >> were developed? I do not think anyone really knows. >> >>> at least for Python 3, not because it is the recommended solution. >> >> AS far as I know, Guido has never recommended any particular gui and I >> believe he has avoided doing so when asked. > > Yes but his silence speaks louder than words. He is saying " While i > won't defend Tkinter publicly, i won't promote any others as well". > This is a standard response you'd expect from a politician. These > types of questions avoid dealing with the elephant in the room. > > We can't just assume that Tkinter is best for Python just because > "Guido" does not want to "ruffle" some features. Actually if you look > back over the very few post where Guido did offer an argument for > Tkinter you'll the find the argument to be very weak. And to make > matters worse no one has the balls to question or argue Guido. Now > whilst i greatly respect Guido i will not hesitate for one second to > call him on weak arguments. > > Case in point: Just recently i posted one of Guido's such arguments in > another thread and responded to the argument. The original thread was > from roughly eight years ago. Yes this is how long it has been since > Guido offered argument for Tkinter. Does he honestly think that the > world has not changed significantly in eight years as to render > Tkinter into legacy? Does he also want us to believe that the world > has not changed dramatically in the last twenty years since Tkinter > was introduced? I have yet to get a response for his weak argument > eight years ago and i can expect we will hear nothing now. > wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first. -- Guido van Rossum (from http://www.wxpython.org/quotes.php) A weak argument - yes. But the thought is there, and it's the thought that counts, right? ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 2011-01-27, rantingrick wrote: >> AS far as I know, Guido has never recommended any particular gui and I >> believe he has avoided doing so when asked. > > Yes but his silence speaks louder than words. He is saying " While i > won't defend Tkinter publicly, i won't promote any others as well". > This is a standard response you'd expect from a politician. These > types of questions avoid dealing with the elephant in the room. I think there are a lot of people who think that including a GUI in the standard library was a mistake and the best solution would be to get rid of Tkinter and replace it with nothing. If I were Guido and thought that, I'd probably keep mum about it as well. :) [I'm not claiming Guidoe does think that, but there are some pretty good arguments for not including a GUI at all.] > The community at large needs to know what Guido van Rossum thinks. You > owe us that much Guido. He doesn't "owe" you or me anything. -- Grant Edwards grant.b.edwardsYow! I'm not available at for comment.. gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 1:38 PM rantingrick said... Continuing to lug Tkinter around is killing Python's evolution. Huh? Can you provide a reference where someone passed over python because of tkinter's inclusion in the standard library? You certainly can't mean that python's evolution over the past 10+ years from 1.5 days to 3.2rc1 was effectively killed. Why would anyone assume any different for the next ten? Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 3:48 pm, Corey Richardson wrote: > On 01/27/2011 04:10 PM, rantingrick wrote: > > > > > > > > > > > On Jan 27, 2:00 pm, Terry Reedy wrote: > >> On 1/27/2011 12:54 PM, Octavian Rasnita wrote: > > >>> Everything that's not accessible is not recommended. > > >> By you. We get that. > > >> >Tkinter should be at most accepted because there is no better solution, > > >> As I said at the beginning of this thread, tkinter is currently the only > >> option. What would have happened if there had been a real competitor > >> when 3.0 was being developed? What would happen in the future if one > >> were developed? I do not think anyone really knows. > > >>> at least for Python 3, not because it is the recommended solution. > > >> AS far as I know, Guido has never recommended any particular gui and I > >> believe he has avoided doing so when asked. > > > Yes but his silence speaks louder than words. He is saying " While i > > won't defend Tkinter publicly, i won't promote any others as well". > > This is a standard response you'd expect from a politician. These > > types of questions avoid dealing with the elephant in the room. > > > We can't just assume that Tkinter is best for Python just because > > "Guido" does not want to "ruffle" some features. Actually if you look > > back over the very few post where Guido did offer an argument for > > Tkinter you'll the find the argument to be very weak. And to make > > matters worse no one has the balls to question or argue Guido. Now > > whilst i greatly respect Guido i will not hesitate for one second to > > call him on weak arguments. > > > Case in point: Just recently i posted one of Guido's such arguments in > > another thread and responded to the argument. The original thread was > > from roughly eight years ago. Yes this is how long it has been since > > Guido offered argument for Tkinter. Does he honestly think that the > > world has not changed significantly in eight years as to render > > Tkinter into legacy? Does he also want us to believe that the world > > has not changed dramatically in the last twenty years since Tkinter > > was introduced? I have yet to get a response for his weak argument > > eight years ago and i can expect we will hear nothing now. > > wxPython is the best and most mature cross-platform GUI toolkit, given a > number of constraints. The only reason wxPython isn't the standard > Python GUI toolkit is that Tkinter was there first. > -- Guido van Rossum You forgot to put a date on that statement. Like of all of Guido's statements about Python they are from many, many years ago. And when i say many years i am talking 1990's. NEWSFLASH! The world has changed, GUI's have changed. All we have are these quotes from the 1990's to go on and i have had enough of this silence from Guido. Guid, SHOW YOURSELF! Come out from behind the safety and security of python-dev. Come out and show the peasants that you are in fact still a part of this community. Come out and walk among us. Come out and re- join the people in united celebration of 21st century evolution. But most of all, come out and defend those weak arguments you gave eight years ago. Even IF we "imagine" your arguments where enough to keep Tkinter then, how can you expect us to believe that now those arguments still hold merit in the year 2011? It is high time for you (Guido van Rossum) to weigh in on this discussion. The time of myths and legends is over, the time of community is NOW! Show yourself! -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrappers in python
On Jan 27, 4:10 am, sl33k_ wrote: > What are wrappers? > > What entities do they wrap around? > > Struggling to understand the concept. http://www.castle-cadenza.demon.co.uk/wrapper.htm Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
On Thu, Jan 27, 2011 at 10:30 PM, Carl Banks wrote: > Write some kind of signature proxy to do it. I don't have a specific implementation idea yet, I see how that grows. > Based on this thread, you have quite specific requirements, so it's > doubtful someone else has implemented exactly what you want. Yes, but asking is better than blinding reimplementing :-) > And because it hasn't been mentioned in this thread yet--surprisingly-- > many people in Python prefer the EAFP strategy, "Easier to Ask > Forgiveness than Permission", that is, to just do it and handle the > resulting exception: > > try: > myobj.somemethod(somevalue) > except AttributeError: > # doesn't fit signature, so do nothing > pass Sure. That's an approach. But this has drawbacks. - it violates the CQS principle: http://en.wikipedia.org/wiki/Command-query_separation - Maybe my interface has not just a single method, and I might want to call multiple methods on my object. I need to check for all signatures before proceeding. - When calling the method, if an exception is raised - either AttributeError or TypeError most of the times - it could not be generated from my own call, but from a call deeper into the stack; It's easy to just think "that object doesn't support that interface" I could mistake an object for not supporting an interface, and I could silently swallow a true runtime exception instead. Maybe some stack analysis could be performed, but I'd prefer to check as much as I can *before* calling. - Sometimes I'd like to group objects depending on their *behaviour* (not their type), and then feed them somewhere else without actually calling their methods. If I can know their behaviour just after they've been called, it might be just too late. -- Alan Franzoni -- contact me at public@[mysurname].eu -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 3:48 pm, Corey Richardson wrote: > A weak argument - yes. But the thought is there, and it's the thought > that counts, right? ;-) What thought? It screams lack of thought to me. We should just ignore a clearly better option because some other option was chosen first, THATS IT? Thats the best he can do? And it shows lack of resolve to move forward even in light of clearly better solutions. It boils down to lack of vision. They say as you grow older you start "setting your ways". Case in point <-- -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 3:54 pm, Grant Edwards wrote: > On 2011-01-27, rantingrick wrote: > > >> AS far as I know, Guido has never recommended any particular gui and I > >> believe he has avoided doing so when asked. > > > Yes but his silence speaks louder than words. He is saying " While i > > won't defend Tkinter publicly, i won't promote any others as well". > > This is a standard response you'd expect from a politician. These > > types of questions avoid dealing with the elephant in the room. > > I think there are a lot of people who think that including a GUI in > the standard library was a mistake and the best solution would be to > get rid of Tkinter and replace it with nothing. If I were Guido and > thought that, I'd probably keep mum about it as well. :) Well i have considered that *maybe* he does feel this way. And by removing Tkinter not only would we take a huge burden from py-dev but we would also free Tkinter from the chains of stdlib. Could this help move Tkinter forward, i think so. > > The community at large needs to know what Guido van Rossum thinks. You > > owe us that much Guido. > > He doesn't "owe" you or me anything. Actually yes, he must give us good reason for this "holding on" to legacy technology. We deserve at least the respect of an explanation. That IS NOT too much to ask. I am tired of hearing Guido's thoughts second hand, i want to hear it strait from the horses mouth! -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 01/27/2011 05:08 PM, rantingrick wrote: >> wxPython is the best and most mature cross-platform GUI toolkit, given a >> number of constraints. The only reason wxPython isn't the standard >> Python GUI toolkit is that Tkinter was there first. >> -- Guido van Rossum > > You forgot to put a date on that statement. I didn't forget - there was no date provided. -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour-based interface/protocol implementation?
On Thu, Jan 27, 2011 at 20:05, Alan Franzoni wrote: > On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote: >> Yes, __instancecheck__ could be used as an alternative hook with >> respect to maybe_implemented_by(), but there's no such logic for >> signature checking. That's a minor detail, I think. > > On the contrary, now that I double checked, it can't be used that way; > I don't want to modify the object I'm testing (it could be a third > party object) nor I want to force it to be "registered" as a certain > ABC; so __instancecheck__() is just useless here. Actually it can. You don't have to modify the object, just check for the desired methods/signature/whatever. See for example the implementation of collections.Hashable.__subclasshook__ in _abcoll.py and the abc.ABCMeta.__instancecheck__ method. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Need GUI pop-up to edit a (unicode ?) string
On 2011-01-27 12:18 , Stephen Hansen wrote: On 1/27/11 10:04 AM, Grant Edwards wrote: On 2011-01-27, Stephen Hansen wrote: On 1/25/11 3:02 PM, rantingrick wrote: This is a major flaw in the design and i would be happy to fix the flaw. However our "friend" Fredrick decided to copyright the module to himself! What a jerk! Which is quite disgusting considering that Tkinter, and TclTk are completely open source! Uh. ... LOL. Copyright doesn't mean what you think it means. Tkinter is copyrighted. Python is copyrighted. Tcl/TK is copyrgithed. In fact: everything that is "open source" is copyrighted. By definition[* see footnote]. One (domestic US) exception would be open-source software written by an employee of the US federal government. Works produced by the US Government are not copyrighted under US domestic copyright law. Such works are copyrighted under international law (which is probably what the Python maintainers care about). I've actually wondered a bit about that: but the only open source software that I'm aware of that's been government-adjacent has ended up being written/owned by some University or joint venture funded by a government agency -- it didn't fall into the public domain category of content created directly by the federal government. Are you aware of any code out there that is? Just curious. I'm not arguing that the exception doesn't exist or anything. A lot of stuff from NIST is legitimately public domain. E.g. http://fingerprint.nist.gov/NFIS/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating custom Python objects from C code
In article , Eric Frederich wrote: > >I have read through all the documentation here: > >http://docs.python.org/extending/newtypes.html > >I have not seen any documentation anywhere else explaining how to >create custom defined objects from C. I have this need to create >custom objects from C and pass them as arguments to a function call. You should definitely investigate Cython, but if you really want to roll your own, look in the examples inside the Python source itself. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson -- http://mail.python.org/mailman/listinfo/python-list
Re: Return Statement
mpnordland wrote: On 01/26/2011 03:26 PM, sl33k_ wrote: How does "return True" and "return False" affect the execution of the calling function? Basically it will affect it in whatever way you design it to for example: def lie_test(statement): if statement is True: return False else: return False Now, this is psuedo code somewhat. "if statement is True:" would always equate to "True" unless statement was an empty string, None, or 0. Um, no. Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> if 'some stuff' is True: ... print 'True' ... else: ... print "it's a dang lie!" ... it's a dang lie! You need either < if bool(statement) is True: >, or < if bool(statement): >, or, simplest, < if statement: > As to return False if statement equals true, look at the function name. It is testing to see if it is a lie, and if it is true, then it's not a lie. Your last statement, though, should be return True -- the way you have it now the function always returns False. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 2:28 PM rantingrick said... And by removing Tkinter not only would we take a huge burden from py-dev but we would also free Tkinter from the chains of stdlib. Actually, IIRC, very little effort is put into maintaining tkinter by the py-dev crowd. I think I saw a post by Martin that he'll put some time in every couple years integrating submitted patches. So, no traction with that argument either. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: help with multiprocessing pool
I did eventually get the original code to run from the command line but not the interpreter, so the new example does have a similar problem. Of course it's not as simple as saying I can't run an imported parallelized function from the interpreter because I can, as long as the parallelized function is being invoked directly. But if I caused the parallelized function to be invoked indirectly, for example, by importing a class that uses the parallelized function to set a class variable, it'll hang the interpreter. for now I added the following to any module that uses parallelized functions import __main__ if hasattr(__main__,'__file__'): __SHOULD_MULTITHREAD__ = True else: __SHOULD_MULTITHREAD__ = False and the parallelized functions check this flag to determine wether to run serially or not. This at least lets me import my classes into the interpreter so I can 'play' with them, although they initialize much slower. I'm not sure why Pool needs the __main__ module, except maybe someone sticks centralized process tracking information in there... sigh add it to the fuel of my love/hate with Python. On Jan 27, 2011, at 10:38 AM, Philip Semanchuk wrote: > > On Jan 27, 2011, at 1:12 PM, Craig Yoshioka wrote: > >> The code will be multi-platform. The OSXisms are there as an example, >> though I am developing on OS X machine. >> >> I've distilled my problem down to a simpler case, so hopefully that'll help >> troubleshoot. >> >> I have 2 files: >> >> test.py: >> -- >> from multiprocessing import Pool >> >> def square(x): >> return x*x >> >> def squares(numbers): >>pool = Pool(12) >>return pool.map(square,numbers) >> >> >> test2.py: >> -- >> from test import squares >> >> maxvalues = squares(range(3)) >> print maxvalues >> >> >> >> Now if I import squares into the interactive interpreter: >> >> from test import squares >> print squares(range(3)) >> >> I get the correct result, but if I try to import maxvalues from test2 the >> interactive interpreter python hangs. >> if I run the script from bash, though, it seems to run fine. > > The short, complete example is much more useful, but it sounds like it > demonstrates a different problem than you first described. Your first posting > said that your code worked in the interpreter but failed when run from the > command line. This code has the opposite problem. Correct? > >> I think it might have something to do with this note in the docs, though I >> am not sure how to use this information to fix my problem: >> >> Note: Functionality within this package requires that the __main__ method be >> importable by the children. This is covered inProgramming guidelines however >> it is worth pointing out here. This means that some examples, such as >> themultiprocessing.Pool examples will not work in the interactive >> interpreter. > > I suspect this is the problem with the demo above. Your original code ran > fine in the interpreter, though, correct? > > bye > Philip > > >> >> On Jan 27, 2011, at 6:39 AM, Philip Semanchuk wrote: >> >>> >>> On Jan 25, 2011, at 8:19 PM, Craig Yoshioka wrote: >>> Hi all, I could really use some help with a problem I'm having. >>> >>> >>> Hiya Craig, >>> I don't know if I can help, but it's really difficult to do without a full >>> working example. >>> >>> Also, your code has several OS X-isms in it so I guess that's the platform >>> you're on. But in case you're on Windows, note that that platform requires >>> some extra care when using multiprocessing: >>> http://docs.python.org/library/multiprocessing.html#windows >>> >>> >>> Good luck >>> Philip >>> >>> I wrote a function that can take a pattern of actions and it apply it to the filesystem. It takes a list of starting paths, and a pattern like this: pattern = { InGlob('Test/**'):{ MatchRemove('DS_Store'):[], NoMatchAdd('(alhpaID_)|(DS_Store)','warnings'):[], MatchAdd('alphaID_','alpha_found'):[], InDir('alphaID_'):{ NoMatchAdd('(betaID_)|(DS_Store)','warnings'):[], InDir('betaID_'):{ NoMatchAdd('(gammaID_)|(DS_Store)','warnings'):[], MatchAdd('gammaID_','gamma_found'):[] so if you run evalFSPattern(['Volumes/**'],pattern) it'll return a dictionary where: dict['gamma_found'] = [list of paths that matched] (i.e. '/Volumes/HD1/Test/alphaID_3382/betaID_38824/gammaID_848384') dict['warning'] = [list of paths that failed to match] (ie. '/Volumes/HD1/Test/alphaID_3382/gammaID_47383') Since some of these volumes are on network shares I also wanted to parallelize this so that it would not block on IO. I started the >>
Re: WxPython versus Tkinter.
On 1/27/11 1:11 PM, rantingrick wrote: Actually we don't want "Robins wxPython" in the stdlib "as is" anyway. What we DO want is an abstraction API for the short term that plugs into Robin's wx. Then over the long term we will either convince him to create a better API OR just create our own wxPython directly from WxWidgets and mold it into the stdlib. So hinging on the argument of what one*single* man thinks is a non-starter. I saw this comment elsewhere in the thread, and I'm a bit confused. As I understand it, you want to layer a Tkinter-style abstraction API over wxPython? You had mentioned that you want to include something like Tkinter's grid/pack/place management API's, its event-handling mechanism, its use of tags, and a few other things? I'd like to suggest that these things are already in the stdlib, in the form of Tkinter itself. And at least some thing these things are tightly bound to Tkinter's inclusion of the Tcl interpreter. For instance, Tcl has a powerful and flexible event loop mechanism. Does wxWidgets have something similar? And are Tkinter's grid/pack/place geometry managers (which are defined at the C level) compatible with wx sizers, which are also defined at the lower C++ level? While this thread has taken many twists and turns, it nonetheless seems to me that the proposal being offered is to layer a Tkinter-style API over a Tkinter-scale subset of wxPython's widgets (listbox, button, menu, etc.). After all that work, what would really be gained? We'd have the same small core of widgets, with an arguably less stable base (since wxPython seems to have problems with segfaults on Linux). It is not persuasive to say that Tkinter is "legacy" while wxPython is "the future." Both Tk and wxWidgets date to the early 1990s. Tk did stagnate for a number of years, but its development in the past few years has been reinvigorated by the ttk themed widgets, in addition to various extension packages that use Tk's C API, and it is now a peer to wxWidgets in its GUI capabilties. I can't speak to Tkinter's performance relative to wxPython and the Tcl interpreter, but any performance gains that are achieved by wxPython's underlying C++ library may be obviated by lesser stability. After all the back-and-forth, I am simply not persuaded, especially since the proposal being offered is not to replace Tkinter with wxPython in the stdlib, but to instead replace Tkinter with a yet-to-be-designed wxTkinter amalgamation (a Tkinter body on a wxPython chassis). --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 1/27/2011 4:48 PM, Corey Richardson wrote: wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first. -- Guido van Rossum (from http://www.wxpython.org/quotes.php) Of course, that is not the only reason now. Python has moved on to a 21st century version, while wxpython is still stuck on the 20century version. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Return Statement
I stand corrected :) -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 27, 5:50 pm, Kevin Walzer wrote: > On 1/27/11 1:11 PM, rantingrick wrote: [...] Hello again Kevin and nice to have you back! Yes the minor details have been evolving over the course of this and another thread. We have been floating new ideas all along the way in an effort to get the best result. In the very beginning because we all know that wxPython IS HUGE i offered a divide and conquer approach... * Small "Tkinter-like" stdlib module. * Full featured third party download. By doing this we can keep the stdlib smaller and leave the bulk of wx in a 3rd party download. Then we floated around installing the entire wxPython library because after all hard drives are only getting bigger. However i think that neither are the best Option. In any event the ideas (like any ideas in a lively discussion) are very fluid in nature. Part of generating the best conclusion is by twisting and turning every idea until it fits neatly into some stated goals. And yes, we want to get the most bang for our community buck! I am now convinced that "Robins wxPython" is woefully inadequate due to the API. We can never consider putting such a blasphemy into the stdlib. Does that mean we should ignore the great benefits of wxWidgets? HELL NO, we would be fools if we did! Now i am thinking along the lines of an abstraction API that plugs into wxPython. We keep Tkinter until say "Python4000", but in the meantime we create a "pythonic wxPython" from the ground up (stealing as much as we can from Robin!). By doing this we can integrate wxPython at whatever rate the community can bear at the time. The only thing better would be to convince all GUI library creators to start thinking globally. To start setting a global standard for all GUI libraries. Then all we would have to do is create a Python API and just "plug" it in generically to WX, TK, GTK, QT, Etc, Etc. I know this sounds like a pipe dream, but this is what must happen at some point. And we should all be demanding this everyday. Always Remember: Selfishness = Multiplicity = Entropy = Shock = Stagnation = None > While this thread has taken many twists and turns, it nonetheless seems > to me that the proposal being offered is to layer a Tkinter-style API > over a Tkinter-scale subset of wxPython's widgets (listbox, button, > menu, etc.). After all that work, what would really be gained? We'd have > the same small core of widgets, with an arguably less stable base (since > wxPython seems to have problems with segfaults on Linux). Yes this discussion has taken many turns. Read my previous statement for insight. > It is not persuasive to say that Tkinter is "legacy" while wxPython is > "the future." Both Tk and wxWidgets date to the early 1990s. Tk did > stagnate for a number of years, but its development in the past few > years has been reinvigorated by the ttk themed widgets, in addition to > various extension packages that use Tk's C API, Yes Tk has just recently "come out of stagnation". But for how long? How long must we wait for them to "get it together"? Thats my point. We will all be dead and rotting by the time Tkinter is including a ListCtrl and accessibility. And i don't know about you Kevin, but i really don't want to wait that long! > and it is now a peer to > wxWidgets in its GUI capabilties. I can't speak to Tkinter's performance > relative to wxPython and the Tcl interpreter, but any performance gains > that are achieved by wxPython's underlying C++ library may be obviated > by lesser stability. wxPython IS NOT less stable than Tkinter: That is a FACT. However, WxPythons API was written in such a horribly unpythonic way (sorry Robin) that someone could find themselves in trouble IF they are not experienced enough to use the library. However, we can easily fix an API. What we can't fix is lack of vision and stagnation in an outside community. We must help ourselves because no one else is going to do it for us! > After all the back-and-forth, I am simply not persuaded, especially > since the proposal being offered is not to replace Tkinter with wxPython > in the stdlib, but to instead replace Tkinter with a yet-to-be-designed > wxTkinter amalgamation (a Tkinter body on a wxPython chassis). Not exactly Kevin. What i intend to do is take your Yugo (Tkinter) to my shop and rip out the antiquated engine, rusty transmission, and remove those "may-pop" tires. Then i plan to replace them with the best high performance parts that are available (wxWidgets) and probably even give her a nice paint job too (Tkinter API)! And when i am done, all your friends are going to be jealous and all the women are going to want a ride in your new hotrod. Kevin, i am going to make you the coolest cat in town! But nobody said it was going to an easy task! ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: replacing lines in a file
thanks for explaining what I was doing wrong and how reading the file works. What would you suggest I do to remedy the situation? -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 28/01/2011 00:54, rantingrick AKA "Brian" wrote: Yes the minor details have been evolving over the course of this and another thread. We have been floating new ideas all along the way in an effort to get the best result. In the very beginning because we all know that wxPython IS HUGE i offered a divide and conquer approach... In other, greater words: "He's making it up as he goes along." -- http://mail.python.org/mailman/listinfo/python-list
Re: replacing lines in a file
On 28/01/2011 00:58, mpnordland wrote: thanks for explaining what I was doing wrong and how reading the file works. What would you suggest I do to remedy the situation? Write the new config out to a new file and then replace the old file with the new file. I'd use shutil.move(...) to do the replacement. This means that the existing config file will remain unchanged until you've successfully created the new config file (it's somewhat annoying if you're modifying a file and there's an exception part way through due to a bug, leaving 'invalid' contents!) -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
rantingrick wrote: > You'll need to read that snippet in context to understand what i was > talking about. Again, see my "tip of the day" in my last post to you. Pass. I'd have to see value in what you say inside of the endless masturbatory self-aggrandizement that you pass off as "visionary" posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 01/27/2011 09:53 PM, alex23 wrote: > rantingrick wrote: >> You'll need to read that snippet in context to understand what i was >> talking about. Again, see my "tip of the day" in my last post to you. > > Pass. I'd have to see value in what you say inside of the endless > masturbatory self-aggrandizement that you pass off as "visionary" > posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah > INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc Because insults and flaming totally get anyone anywhere. If you don't have anything civil to say, don't say it at all (Because sometimes un-nice things need to be said). -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
"Octavian Rasnita" wrote: > Ok, in this case I understand why WxPython can't be included in stdlib. > I think there was a communication problem because the oldest list members > start with the idea that all the list members know who is who and they may > be thinking that I don't want to accept the reality or that I have bad > feelings about some list members or something like that. The only expectation I as a list member have of you is that you maybe hit the web and do a bit of search & research before starting on an endless tirade. Implying that it was the responsibility of everyone here to explain every little aspect of an issue you're supposedly passionate about makes you seem either lazy or ignorant. -- http://mail.python.org/mailman/listinfo/python-list